deps: Bump @anthropic-ai/sdk from 0.133.0 to 1.3.0 in /sdk/typescript (#4554)

Qualify the TypeScript SDK's native Anthropic adapter against
Anthropic's stable 1.3.0 client, rather than testing only the old
0.133.0 development peer. Current-peer compatibility is a required
qualification target for this SDK maintenance work, including the native
Anthropic client admitted by the existing `@anthropic-ai/sdk >=0.30.0`
range. The README installs Headroom only; Anthropic is an optional,
separately installed peer, not an automatically installed dependency.
This PR makes the selected 1.3.0 qualification concrete with actual HTTP
transport and Headroom compression, including the native blocks that
must survive unchanged.

## Dependency assessment

- **Why package/version:** retain Anthropic's official client as an
optional integration peer instead of duplicating its authentication,
request serialization, retries and response API. Version 1.3.0 is the
selected stable peer qualification target for the native adapter under
the required current-client compatibility scope. The broad peer range
permits 1.x but is not itself evidence that it was tested, nor a
requirement for users to install it. This is deliberate compatibility
qualification, not a claim that Enterprise Claude Tag endpoints are used
by Headroom or that an unrelated upstream feature fixes compression.
[Official
release](https://github.com/anthropics/anthropic-sdk-typescript/releases/tag/sdk-v1.3.0).
- **Maintenance/security:** maintained by Anthropic, with the reviewed
release/source history covering the stable client and request-layer
changes. Fresh SDK audit reports zero vulnerabilities; this is not a
guarantee about all past/future upstream security issues. Actual
transport, build and test results support acceptance rather than the
major version number alone.
- **Install surface:** the only added lock package is
`@opentelemetry/api` 1.9.0 (SDK requirement ^1.4.1). Existing
standardwebhooks and json-schema-to-ts dependencies remain. No new
install-script flag, native package or exporter is introduced. The
Anthropic SDK remains a development/test dependency here; published
optional peer ranges are unchanged. A registry install and the client's
existing provider HTTP requests remain network surfaces. Node 22.22.0
was tested; the distribution has no engines field, so this result is not
a claim of qualification on every Node version.
- **Tracing/privacy:** the new client can emit API-call spans when the
application has registered an OpenTelemetry tracer provider. Defaults
use metadata-only content mode and permit trace-context propagation;
prompt/response content capture requires content mode selection.
`openTelemetry: false` or the documented ANTHROPIC_OPEN_TELEMETRY
environment setting disables spans. The API package supplies no exporter
itself, but an application's existing tracer/exporter can receive the
new spans. This behavior and configuration are part of the upgrade's
surface, not assumed absent because the dependency is JavaScript-only.
Exporter/propagation behavior was inspected but not exercised by the
transport proof.

The branch is synchronized with main, including the merged #4599
glob/minimatch audit remediation and its existing exact bundled
exceptions/November 15 expiry. The SDK lock conflict with merged #4621
is resolved by retaining all six of that group's updates and applying
the Anthropic 1.3.0 change to that combined lock. A parsed comparison
with main confirms the only package-version difference is Anthropic and
the only added package is the telemetry API.

## Real behavior proof

Windows, Node 22.22.0, Python 3.12.13, the actual 1.3.0 client from the
PR lock, and Headroom's built native Anthropic adapter. The local proxy
used an existing native Headroom extension, isolated temporary
workspace/config storage, stateless operation, disabled subscription
tracking, and skipped upstream discovery. A loopback provider fixture
sends a valid SDK response. No cloud credential, real model inference,
or genuine thinking signature was used.

```powershell
cd sdk/typescript
npm ci --ignore-scripts --no-audit --no-fund
npm run build
cd ../..
python scripts/verify_anthropic_peer.py
```

Observed, exit 0:

```text
PASS: actual Anthropic SDK client + Headroom adapter preserve thinking, cache markers, tool pairs, system and metadata on the wire
Real Headroom /v1/compress response: [200]
```

The actual 1.3.0 `client.messages.create()` passes through
`withHeadroom`, makes a real compression HTTP request with fallback
disabled, then sends a real HTTP request to `/v1/messages`. The fixture
asserts the complete message array (opaque thinking/signature, paired
tool use/result and cache markers), separate system blocks and metadata;
the returned SDK text is also asserted. No SDK/client/compression
function is replaced. The short payload does not trigger token
reduction, so this proves native transport/payload preservation rather
than a long-input compression ratio or vendor acceptance of the
synthetic signature.

SDK tests: **406 passed, 33 skipped**. Typecheck, ESM/CJS/declaration
build and zero-finding audit pass. Python lint/format, Node syntax and
whitespace checks pass.

After the main/SDK-group synchronization, the native proof and all these
checks passed again. The committed `python
scripts/verify_sdk_provider_peers.py` also passes on the combined tree:
the actual Vercel Anthropic provider retains final JSON text, the OpenAI
provider resolves two async credentials separately, and the native
OpenAI client completes its request, with four real `/v1/compress`
responses of 200. Thus the conflict resolution preserves the
already-qualified peer matrix alongside the new native Anthropic client.

Untested: live Anthropic credentials/models, streaming/beta/new
Enterprise APIs, signed-thinking validation by Anthropic, tracing
export/propagation, browser behavior, active compression of long inputs,
other Node/platform combinations, and the 33 skipped tests. Current-head
hosted CI remains required.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
This commit is contained in:
dependabot[bot]
2026-11-02 22:44:52 -06:00
committed by GitHub
co-authored by JerrettDavis
parent 5c785e6938
commit 74277d47ec
4 changed files with 154 additions and 36 deletions
+62
View File
@@ -0,0 +1,62 @@
import assert from 'node:assert/strict';
import { createServer } from 'node:http';
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
import path from 'node:path';
const sdk = path.resolve(process.argv[2]);
const require = createRequire(path.join(sdk, 'package.json'));
const Anthropic = require('@anthropic-ai/sdk').default;
const { withHeadroom } = await import(pathToFileURL(path.join(sdk, 'dist/adapters/anthropic.js')));
assert.ok(['localhost', '127.0.0.1'].includes(new URL(process.env.HEADROOM_BASE_URL).hostname));
const calls = [];
const server = createServer(async (request, response) => {
const chunks = [];
for await (const chunk of request) chunks.push(chunk);
calls.push({ body: JSON.parse(Buffer.concat(chunks).toString()), path: request.url });
response.writeHead(200, { 'content-type': 'application/json' });
response.end(JSON.stringify({
id: 'msg-local-peer-proof', type: 'message', role: 'assistant',
model: 'claude-sonnet-4-5-20250929',
content: [{ type: 'text', text: 'fixture answer' }],
stop_reason: 'end_turn', stop_sequence: null,
usage: { input_tokens: 100, output_tokens: 8 },
}));
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
try {
const messages = [
{ role: 'user', content: [{ type: 'text', text: 'Read the fixture.', cache_control: { type: 'ephemeral' } }] },
{ role: 'assistant', content: [
{ type: 'thinking', thinking: 'Opaque fixture reasoning.', signature: 'opaque-fixture-signature' },
{ type: 'tool_use', id: 'tool-local-1', name: 'lookup', input: { query: 'fixture' } },
] },
{ role: 'user', content: [{
type: 'tool_result', tool_use_id: 'tool-local-1', content: 'short fixture result',
cache_control: { type: 'ephemeral' },
}] },
];
const system = [{ type: 'text', text: 'Return the fixture answer.', cache_control: { type: 'ephemeral' } }];
const metadata = { user_id: 'local-fixture' };
const client = withHeadroom(new Anthropic({
apiKey: 'local-fixture-only',
baseURL: `http://127.0.0.1:${server.address().port}`,
}), { baseUrl: process.env.HEADROOM_BASE_URL, fallback: false, retries: 0 });
const result = await client.messages.create({
model: 'claude-sonnet-4-5-20250929', max_tokens: 2048,
thinking: { type: 'enabled', budget_tokens: 1024 }, messages, system, metadata,
tools: [{ name: 'lookup', input_schema: {
type: 'object', properties: { query: { type: 'string' } }, required: ['query'],
} }],
});
assert.equal(calls.length, 1);
assert.equal(calls[0].path, '/v1/messages');
assert.deepEqual(calls[0].body.messages, messages);
assert.deepEqual(calls[0].body.system, system);
assert.deepEqual(calls[0].body.metadata, metadata);
assert.equal(result.content[0].text, 'fixture answer');
console.log('PASS: actual Anthropic SDK client + Headroom adapter preserve thinking, cache markers, tool pairs, system and metadata on the wire');
} finally {
server.closeAllConnections();
await new Promise(resolve => server.close(resolve));
}
+75
View File
@@ -0,0 +1,75 @@
import os
import socket
import subprocess
import sys
import tempfile
import threading
import time
from pathlib import Path
os.environ["HEADROOM_SKIP_UPSTREAM_CHECK"] = "1"
os.environ["HEADROOM_DISTRIBUTION"] = "local"
os.environ["HF_HUB_DISABLE_TELEMETRY"] = "1"
root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parents[1]
state = tempfile.TemporaryDirectory(prefix="headroom-sdk-proof-")
os.environ["HEADROOM_WORKSPACE_DIR"] = state.name
os.environ["HEADROOM_CONFIG_DIR"] = str(Path(state.name) / "config")
sys.path.insert(0, str(root))
import uvicorn
from headroom.proxy.server import ProxyConfig, create_app
app = create_app(
ProxyConfig(
optimize=True,
cache_enabled=False,
rate_limit_enabled=False,
cost_tracking_enabled=False,
log_requests=False,
ccr_inject_tool=False,
ccr_handle_responses=False,
ccr_context_tracking=False,
image_optimize=False,
disable_kompress=True,
subscription_tracking_enabled=False,
stateless=True,
)
)
seen = []
@app.middleware("http")
async def count_compress(request, call_next):
response = await call_next(request)
if request.url.path == "/v1/compress":
seen.append(response.status_code)
return response
listener = socket.socket()
listener.bind(("127.0.0.1", 0))
port = listener.getsockname()[1]
server = uvicorn.Server(uvicorn.Config(app, log_level="warning"))
thread = threading.Thread(target=server.run, kwargs={"sockets": [listener]}, daemon=True)
thread.start()
try:
for _ in range(300):
if server.started:
break
if not thread.is_alive():
raise RuntimeError("proxy stopped before startup")
time.sleep(0.1)
assert server.started
env = dict(os.environ, HEADROOM_BASE_URL=f"http://127.0.0.1:{port}")
command = ["node", str(Path(__file__).with_suffix(".mjs")), str(root / "sdk/typescript")]
if len(sys.argv) > 2:
command.append(sys.argv[2])
result = subprocess.run(command, env=env)
assert seen and all(status == 200 for status in seen), seen
print("Real Headroom /v1/compress response:", seen, flush=True)
raise SystemExit(result.returncode)
finally:
server.should_exit = True
thread.join(timeout=15)
listener.close()
state.cleanup()
+16 -35
View File
@@ -12,7 +12,7 @@
"@ai-sdk/anthropic": "^4.0.94",
"@ai-sdk/openai": "^4.0.106",
"@ai-sdk/provider": "^4.0.35",
"@anthropic-ai/sdk": "^0.133.0",
"@anthropic-ai/sdk": "^1.3.0",
"@types/node": "^26.6.6",
"ai": "^7.0.159",
"dotenv": "^18.0.1",
@@ -131,12 +131,13 @@
}
},
"node_modules/@anthropic-ai/sdk": {
"version": "0.133.0",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.133.0.tgz",
"integrity": "sha512-jlqUN8p8ESTJj+GJnA4KjzbEfF1waEoGzRT8jwytlYGFFgv+/DUQOxlYGvYw10UzhD1kwLqYzxvA3FrTB2YWuQ==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.3.0.tgz",
"integrity": "sha512-k7z9BlLLPxfZH+ov7dS6EnaN/wiZeV8YNT1LZfrpAHIy7oY7pHr4UzirF9f2OlHtFEnRBOX+AZQ91Y5fK+TPTw==",
"dev": true,
"license": "MIT",
"license": "Apache-2.0",
"dependencies": {
"@opentelemetry/api": "^1.4.1",
"json-schema-to-ts": "^3.1.1",
"standardwebhooks": "^1.0.0"
},
@@ -643,6 +644,16 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@opentelemetry/api": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.10.0.tgz",
"integrity": "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oxc-project/types": {
"version": "0.155.0",
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz",
@@ -770,9 +781,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -791,9 +799,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -812,9 +817,6 @@
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -833,9 +835,6 @@
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -854,9 +853,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -875,9 +871,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1897,9 +1890,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1922,9 +1912,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1947,9 +1934,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -1972,9 +1956,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
+1 -1
View File
@@ -123,7 +123,7 @@
"@ai-sdk/anthropic": "^4.0.94",
"@ai-sdk/openai": "^4.0.106",
"@ai-sdk/provider": "^4.0.35",
"@anthropic-ai/sdk": "^0.133.0",
"@anthropic-ai/sdk": "^1.3.0",
"@types/node": "^26.6.6",
"ai": "^7.0.159",
"dotenv": "^18.0.1",