Skip to content

Commit 00ca67b

Browse files
authored
AC-858: Align the TypeScript SDK dependency model (#1222)
* chore(ac-858): make the TS SDK dependency model intentional and single-sourced openai and @anthropic-ai/sdk were declared as both hard dependencies and optional peers. The integrations load them guardedly (dynamic require / absence-tolerant), and the repo's sdk-import-discipline gate enforces no required static imports, so the hard-dependency entries were accidental duplication. Drop both from dependencies; keep them as optional peerDependencies (with devDependencies for tests/scripts). Align the @anthropic-ai/sdk peer range to the documented >=0.18 <2 contract (^0.32 only permitted 0.32.x). npm run lint, sdk-import-discipline, side-effects, bundle-size, license, no-postinstall, no-telemetry, and the integration tests all pass. * fix(ac-858): regenerate npm lockfile, document optional-peer install, extend guards to Anthropic (PR #1222 review) F1: regenerate ts/package-lock.json so both SDKs are dev-only and the Anthropic peer range is >=0.18 <2 (the repo tracks package-lock.json alongside bun.lock; the prior commit updated only bun.lock). F2: README documents installing the now-optional provider SDKs (npm/bun install autoctx @anthropic-ai/sdk, and openai), with a reminder above the Anthropic example that imports the peer. F3: extend the SDK guards to the Anthropic half. check-sdk-import-discipline now covers integrations/anthropic + detectors/anthropic-{python,ts} (a static @anthropic-ai/sdk import there now fails, verified), and check-no-telemetry scans the Anthropic source dirs. The license/postinstall/telemetry transitive roots stay openai-only by design: no shipped source imports or requires @anthropic-ai/sdk, so its tree is outside our runtime closure (documented).
1 parent 1eb9368 commit 00ca67b

9 files changed

Lines changed: 236 additions & 20 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [Unreleased]
6+
7+
### Changed
8+
9+
- The TypeScript package no longer declares `openai` and `@anthropic-ai/sdk` as both hard `dependencies` and optional peers. They are now optional `peerDependencies` (with `devDependencies` for tests and scripts), matching how the integrations load them (guarded, absence-tolerant). The `@anthropic-ai/sdk` peer range is aligned to the documented `>=0.18 <2` compatibility contract (the prior `^0.32` only permitted `0.32.x`). Consumers that do not use the OpenAI or Anthropic integrations no longer pull the SDKs transitively (AC-858).
10+
511
## [0.12.0] - 2026-07-19
612

713
### Added

ts/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ npm install -g autoctx
1414

1515
Important: use `autoctx`, not `autocontext`. `autocontext` on npm is a different package and not this project.
1616

17+
### Optional provider SDKs
18+
19+
The OpenAI and Anthropic integrations (`autoctx/integrations/openai`, `autoctx/integrations/anthropic`) and their detectors treat the provider SDKs as optional peer dependencies, so installing `autoctx` does not pull them in. Install the one you use alongside `autoctx`:
20+
21+
```bash
22+
# Anthropic integration and the Anthropic examples below
23+
npm install autoctx @anthropic-ai/sdk
24+
# OpenAI integration
25+
npm install autoctx openai
26+
```
27+
28+
(Bun: `bun add autoctx @anthropic-ai/sdk` or `bun add autoctx openai`.) The integrations degrade gracefully when the SDK is absent, but any example that imports a provider SDK requires it to be installed.
29+
1730
From a checkout:
1831

1932
```bash
@@ -180,6 +193,8 @@ import { connectMcpRuntimeTools } from "autoctx/runtimes/mcp";
180193

181194
## Production traces
182195

196+
Requires the optional `@anthropic-ai/sdk` peer (`npm install @anthropic-ai/sdk`, or `openai` for the OpenAI integration). See [Optional provider SDKs](#optional-provider-sdks).
197+
183198
```ts
184199
import Anthropic from "@anthropic-ai/sdk";
185200
import { FileSink, instrumentClient } from "autoctx/integrations/anthropic";

ts/bun.lock

Lines changed: 133 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/package-lock.json

Lines changed: 32 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
"access": "public"
191191
},
192192
"peerDependencies": {
193-
"@anthropic-ai/sdk": "^0.32",
193+
"@anthropic-ai/sdk": ">=0.18 <2",
194194
"openai": "^4"
195195
},
196196
"peerDependenciesMeta": {
@@ -202,17 +202,18 @@
202202
}
203203
},
204204
"devDependencies": {
205+
"@anthropic-ai/sdk": "^0.91.1",
205206
"@apidevtools/json-schema-ref-parser": "^15.3.5",
206207
"@types/better-sqlite3": "^7.6.0",
207208
"@types/react": "^18.3.0",
208209
"@types/ws": "^8.5.13",
209210
"fast-check": "^4.7.0",
210211
"json-schema-to-typescript": "^15.0.4",
212+
"openai": "^4",
211213
"typescript": "^5.7.0",
212214
"vitest": "^3.0.0"
213215
},
214216
"dependencies": {
215-
"@anthropic-ai/sdk": "^0.91.1",
216217
"@modelcontextprotocol/sdk": "^1.27.1",
217218
"ajv": "^8.18.0",
218219
"ajv-formats": "^3.0.1",
@@ -221,7 +222,6 @@
221222
"ignore": "5.3.2",
222223
"ink": "^5.1.0",
223224
"ink-text-input": "^6.0.0",
224-
"openai": "^4",
225225
"react": "^18.3.1",
226226
"secure-exec": "^0.1.0",
227227
"tree-sitter": "0.21.1",

ts/scripts/check-license-compatibility.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const ALLOWLIST = new Set([
3838
"(BSD-3-Clause OR MIT)",
3939
]);
4040

41-
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai
41+
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai.
42+
// @anthropic-ai/sdk is intentionally absent: no shipped source imports or requires it,
43+
// so its transitive tree is not part of our runtime closure to audit.
4244
const SDK_RUNTIME_ROOTS = ["ajv", "ajv-formats", "ulid", "openai"];
4345

4446
if (!existsSync(PKG_LOCK)) {

ts/scripts/check-no-postinstall-scripts.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const SELF_PKG = join(ROOT, "package.json");
3131
const STRICT_HOOKS = ["preinstall", "install", "postinstall"];
3232
const SELF_ONLY_HOOKS = ["prepublish", "prepare"];
3333

34-
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai
34+
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai.
35+
// @anthropic-ai/sdk is intentionally absent: no shipped source imports or requires it,
36+
// so its transitive tree is not part of our runtime closure to audit.
3537
const SDK_RUNTIME_ROOTS = ["ajv", "ajv-formats", "ulid", "openai"];
3638

3739
function loadPkg(path) {

ts/scripts/check-no-telemetry.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ const PKG_LOCK = join(ROOT, "package-lock.json");
2828
const SUBPATH_SRC_DIRS = [
2929
join(ROOT, "src", "production-traces", "sdk"),
3030
join(ROOT, "src", "integrations", "openai"),
31+
join(ROOT, "src", "integrations", "anthropic"),
3132
join(ROOT, "src", "control-plane", "instrument", "detectors", "openai-python"),
3233
join(ROOT, "src", "control-plane", "instrument", "detectors", "openai-ts"),
34+
join(ROOT, "src", "control-plane", "instrument", "detectors", "anthropic-python"),
35+
join(ROOT, "src", "control-plane", "instrument", "detectors", "anthropic-ts"),
3336
];
3437

35-
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai
38+
// Roots: production-traces/sdk direct deps + openai peer dep used by integrations/openai.
39+
// @anthropic-ai/sdk is intentionally absent: no shipped source imports or requires
40+
// it (the Anthropic integration processes provider data shapes), so its transitive
41+
// tree is not part of our runtime closure to audit.
3642
const SDK_RUNTIME_ROOTS = ["ajv", "ajv-formats", "ulid", "openai"];
3743

3844
const TELEMETRY_IMPORT_RES = [

0 commit comments

Comments
 (0)