@songtonyli/dsh-cli 0.1.58 → 0.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +1 -0
- package/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js +59 -4
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.i18n.yaml +73 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/README.zh.md +166 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/exec-shim.js +227 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/lib/index.js +704 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-apple-container/package.json +62 -0
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-sandbox-policy/lib/index.js +23 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
- package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +1 -0
- package/node_modules/@deepseek-ai/dsh-system-prompt/lib/index.js +1 -0
- package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +22 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +24 -0
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.i18n.yaml +4 -4
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/README.zh.md +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/lib/index.js +28 -3
- package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +7 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/lib/index.js +14 -6
- package/node_modules/@deepseek-ai/dsh-tui-app/cordis.patch.yml +20 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/package.json +1 -0
- package/node_modules/@deepseek-ai/libreoffice-kit/README.md +20 -5
- package/node_modules/@deepseek-ai/libreoffice-kit/README.zh.md +21 -6
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/cli.js +499 -253
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/font-snapshot-worker.js +37 -26
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/index.js +498 -252
- package/node_modules/@deepseek-ai/libreoffice-kit/lib/worker.js +39 -13
- package/node_modules/@deepseek-ai/libreoffice-kit/package.json +5 -3
- package/node_modules/@earendil-works/pi-ai/README.md +4 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +117 -18
- package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js +19 -8
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +24 -2
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js +3 -2
- package/node_modules/@earendil-works/pi-ai/package.json +6 -2
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@shikijs/core/dist/index.mjs +15 -12
- package/node_modules/@shikijs/core/package.json +4 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-compile.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/engine-raw.mjs +2 -4
- package/node_modules/@shikijs/engine-javascript/dist/index.mjs +1 -1
- package/node_modules/@shikijs/engine-javascript/dist/string-TLTPtCPs.mjs +115 -0
- package/node_modules/@shikijs/engine-javascript/package.json +3 -3
- package/node_modules/@shikijs/engine-oniguruma/package.json +3 -3
- package/node_modules/@shikijs/langs/dist/ada.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ahk.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/beancount.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/coq.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/csharp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/css.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dart.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/dotenv.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/emacs-lisp.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/gn.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/handlebars.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/julia.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/latex.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/luau.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/marko.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/moonbit.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow-groovy.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nextflow.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/nushell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/php.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/powershell.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/ruby.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/rust.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/sql.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/svelte.mjs +1 -1
- package/node_modules/@shikijs/langs/dist/twig.mjs +3 -3
- package/node_modules/@shikijs/langs/dist/typespec.mjs +1 -1
- package/node_modules/@shikijs/langs/package.json +3 -3
- package/node_modules/@shikijs/primitive/dist/index.mjs +2 -1
- package/node_modules/@shikijs/primitive/package.json +3 -3
- package/node_modules/@shikijs/themes/dist/monokai.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/one-dark-pro.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/red.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-dark.mjs +1 -1
- package/node_modules/@shikijs/themes/dist/solarized-light.mjs +1 -1
- package/node_modules/@shikijs/themes/package.json +3 -3
- package/node_modules/@shikijs/types/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +33 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +33 -11
- package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +3 -0
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/node-addon-native-custom-loader/lib/index.js +23 -10
- package/node_modules/node-addon-native-custom-loader/package.json +6 -1
- package/node_modules/node-addon-require-builtin/package.json +7 -2
- package/node_modules/powershell-utils/index.js +40 -19
- package/node_modules/powershell-utils/package.json +1 -1
- package/node_modules/powershell-utils/readme.md +69 -13
- package/node_modules/shiki/package.json +10 -10
- package/node_modules/wsl-utils/index.js +18 -37
- package/node_modules/wsl-utils/package.json +2 -2
- package/package.json +33 -29
- package/node_modules/@shikijs/engine-javascript/dist/scanner-DX8LRFGE.mjs +0 -77
- package/node_modules/open/node_modules/powershell-utils/index.js +0 -79
- package/node_modules/open/node_modules/powershell-utils/license +0 -9
- package/node_modules/open/node_modules/powershell-utils/package.json +0 -47
- package/node_modules/open/node_modules/powershell-utils/readme.md +0 -209
|
@@ -43,6 +43,29 @@ function failureCode(error) {
|
|
|
43
43
|
return typeof code === "string" && CODES.has(code) ? code : "failed";
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
|
+
//#region lib/types/font-file-identity.js
|
|
47
|
+
/** Preserve 64-bit device and inode values without JavaScript integer rounding. */
|
|
48
|
+
function fontFileIdentity(status) {
|
|
49
|
+
return {
|
|
50
|
+
dev: status.dev.toString(),
|
|
51
|
+
ino: status.ino.toString(),
|
|
52
|
+
size: Number(status.size),
|
|
53
|
+
mtimeMs: Number(status.mtimeNs) / 1e6,
|
|
54
|
+
ctimeMs: Number(status.ctimeNs) / 1e6
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Compare a source descriptor's exact identity with its indexed font metadata. */
|
|
58
|
+
function matchesFontFile(status, expected) {
|
|
59
|
+
const current = fontFileIdentity(status);
|
|
60
|
+
return [
|
|
61
|
+
"dev",
|
|
62
|
+
"ino",
|
|
63
|
+
"size",
|
|
64
|
+
"mtimeMs",
|
|
65
|
+
"ctimeMs"
|
|
66
|
+
].every((key) => current[key] === expected[key]);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
46
69
|
//#region lib/types/fonts.js
|
|
47
70
|
/** Host font metadata snapshots and conversion-local glyph matching over original files. */
|
|
48
71
|
const VCL_WEIGHTS = [
|
|
@@ -67,14 +90,6 @@ const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
|
67
90
|
"systemui",
|
|
68
91
|
"symbol"
|
|
69
92
|
]);
|
|
70
|
-
/** File identity read from the descriptor, before and after, to detect concurrent replacement. */
|
|
71
|
-
const STAT_KEYS = [
|
|
72
|
-
"dev",
|
|
73
|
-
"ino",
|
|
74
|
-
"size",
|
|
75
|
-
"mtimeMs",
|
|
76
|
-
"ctimeMs"
|
|
77
|
-
];
|
|
78
93
|
/**
|
|
79
94
|
* Case- and separator-insensitive family key used to compare names across sources.
|
|
80
95
|
* @param value - Family, style, or postscript name as recorded by a document or font.
|
|
@@ -218,16 +233,15 @@ var SystemFontCatalog = class {
|
|
|
218
233
|
function readFont(face) {
|
|
219
234
|
const fd = openSync(face.path, constants.O_RDONLY | constants.O_NONBLOCK | constants.O_NOFOLLOW);
|
|
220
235
|
try {
|
|
221
|
-
const before = fstatSync(fd);
|
|
222
|
-
if (!before.isFile() ||
|
|
236
|
+
const before = fstatSync(fd, { bigint: true });
|
|
237
|
+
if (!before.isFile() || !matchesFontFile(before, face)) throw new Error("An indexed font changed; recreate the converter.");
|
|
223
238
|
const bytes = Buffer.alloc(face.size);
|
|
224
239
|
for (let offset = 0; offset < bytes.length;) {
|
|
225
240
|
const count = readSync(fd, bytes, offset, bytes.length - offset, offset);
|
|
226
241
|
if (!count) throw new Error("An indexed font was truncated.");
|
|
227
242
|
offset += count;
|
|
228
243
|
}
|
|
229
|
-
|
|
230
|
-
if (STAT_KEYS.some((key) => after[key] !== face[key])) throw new Error("An indexed font changed while reading.");
|
|
244
|
+
if (!matchesFontFile(fstatSync(fd, { bigint: true }), face)) throw new Error("An indexed font changed while reading.");
|
|
231
245
|
return bytes;
|
|
232
246
|
} finally {
|
|
233
247
|
closeSync(fd);
|
|
@@ -846,6 +860,17 @@ async function convertWithWasm(request) {
|
|
|
846
860
|
};
|
|
847
861
|
});
|
|
848
862
|
}
|
|
863
|
+
/** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
|
|
864
|
+
function unmirrorRtlTile({ width, height, rgba }) {
|
|
865
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < Math.floor(width / 2); x++) {
|
|
866
|
+
const left = (y * width + x) * 4, right = (y * width + width - 1 - x) * 4;
|
|
867
|
+
for (let channel = 0; channel < 4; channel++) {
|
|
868
|
+
const value = rgba[left + channel];
|
|
869
|
+
rgba[left + channel] = rgba[right + channel];
|
|
870
|
+
rgba[right + channel] = value;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
849
874
|
/** Split a region on its output-pixel grid, bounding the plan before allocating it. */
|
|
850
875
|
function splitRasterRectangle(rectangle, scale, limits) {
|
|
851
876
|
const { x, y, width, height } = rectangle;
|
|
@@ -1107,7 +1132,7 @@ function dimension(data, first, last, maximum, scale) {
|
|
|
1107
1132
|
}
|
|
1108
1133
|
return [start / scale, (position - start) / scale];
|
|
1109
1134
|
}
|
|
1110
|
-
/** Logical columns advance from A;
|
|
1135
|
+
/** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
|
|
1111
1136
|
function sheetRangeRectangle(geometry, range, scale) {
|
|
1112
1137
|
if (!Number.isFinite(scale) || scale <= 0 || scale > 16) throw new TypeError("Invalid worksheet raster scale.");
|
|
1113
1138
|
const [x, width] = dimension(geometry.columns, range.firstColumn, range.lastColumn, MAX_COLUMN, scale);
|
|
@@ -1343,6 +1368,7 @@ async function renderImagesWithWasm(request) {
|
|
|
1343
1368
|
...region.rectangle,
|
|
1344
1369
|
scale
|
|
1345
1370
|
}, [region.page], () => engineError(session.module, session.office), session.pdf);
|
|
1371
|
+
if (region.rtl) unmirrorRtlTile(tile);
|
|
1346
1372
|
const png = encodePng(tile.width, tile.height, tile.rgba);
|
|
1347
1373
|
total += png.length;
|
|
1348
1374
|
if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/libreoffice-kit",
|
|
3
3
|
"description": "Convert, recalculate, and render Office documents with prebuilt LibreOffice",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"license": "MPL-2.0",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "
|
|
17
|
+
"url": "https://github.com/deepseek-ai/dsh-libreoffice-kit",
|
|
18
18
|
"directory": "packages/entry"
|
|
19
19
|
},
|
|
20
|
+
"homepage": "https://github.com/deepseek-ai/dsh-libreoffice-kit",
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
23
|
"types": "./lib/types/index.d.ts",
|
|
@@ -37,9 +38,10 @@
|
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"fflate": "0.8.2",
|
|
39
40
|
"fontkit": "2.0.4",
|
|
41
|
+
"koffi": "3.1.1",
|
|
40
42
|
"saxes": "6.0.0"
|
|
41
43
|
},
|
|
42
44
|
"bin": {
|
|
43
|
-
"
|
|
45
|
+
"dsoffice": "./lib/cli.js"
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -1653,10 +1653,10 @@ Browser compatibility notes:
|
|
|
1653
1653
|
|
|
1654
1654
|
## Bundling and Tree Shaking
|
|
1655
1655
|
|
|
1656
|
-
For small bundles, import only the providers you need:
|
|
1656
|
+
For small bundles and low-overhead unbundled scripts, import the model runtime and only the providers you need:
|
|
1657
1657
|
|
|
1658
1658
|
```typescript
|
|
1659
|
-
import { createModels } from '@earendil-works/pi-ai';
|
|
1659
|
+
import { createModels } from '@earendil-works/pi-ai/models';
|
|
1660
1660
|
import { openaiProvider } from '@earendil-works/pi-ai/providers/openai';
|
|
1661
1661
|
|
|
1662
1662
|
const models = createModels();
|
|
@@ -1665,7 +1665,8 @@ models.setProvider(openaiProvider());
|
|
|
1665
1665
|
|
|
1666
1666
|
Rules:
|
|
1667
1667
|
|
|
1668
|
-
- `@earendil-works/pi-ai`
|
|
1668
|
+
- `@earendil-works/pi-ai/models` exports the model runtime (`createModels`, `createProvider`, model helpers, and their types) without TypeBox, built-in catalogs, or SDK implementations. Other types can still use `import type` from the root.
|
|
1669
|
+
- `@earendil-works/pi-ai` is the core entrypoint and does not import built-in catalogs, real provider factories, or SDK implementations, but it eagerly imports TypeBox and schema validation. Unbundled Node scripts do not tree-shake its unused exports; prefer `./models`, `./providers/faux`, and specific `./utils/*` subpaths when those are all you need.
|
|
1669
1670
|
- `@earendil-works/pi-ai/providers/<provider>` imports that provider's catalog and lazy API wrapper only.
|
|
1670
1671
|
- `@earendil-works/pi-ai/providers/all` imports every built-in provider factory and all catalogs. Use it only when you want the full built-in set.
|
|
1671
1672
|
- With code splitting, provider SDKs stay in lazy chunks and load on first request.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
1
|
+
import Anthropic, {} from "@anthropic-ai/sdk";
|
|
2
|
+
import { ANTHROPIC_FEDERATION_RULE_ID_ENV, ANTHROPIC_IDENTITY_TOKEN_FILE_ENV, ANTHROPIC_ORGANIZATION_ID_ENV, ANTHROPIC_SERVICE_ACCOUNT_ID_ENV, ANTHROPIC_WORKSPACE_ID_ENV, } from "../env-api-keys.js";
|
|
2
3
|
import { calculateCost } from "../models.js";
|
|
3
4
|
import { appendAssistantMessageDiagnostic } from "../utils/diagnostics.js";
|
|
4
5
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
@@ -10,7 +11,7 @@ import { retryProviderRequest } from "../utils/provider-retry.js";
|
|
|
10
11
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
11
12
|
import { getSystemMessageText, renderSystemMessageUpdate } from "../utils/text.js";
|
|
12
13
|
import { getCurrentTools, getDeclaredTools, getInitialSystemMessage, hasToolRedefinitions, resolveTranscript, } from "../utils/transcript.js";
|
|
13
|
-
import { getJsonSchemaToolParameters, resolveJsonSchemaStrictSampling } from "./constrained-sampling.js";
|
|
14
|
+
import { getJsonSchemaToolParameters, resolveJsonSchemaStrictSampling, } from "./constrained-sampling.js";
|
|
14
15
|
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
|
|
15
16
|
import { adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToContext } from "./simple-options.js";
|
|
16
17
|
import { transformMessages } from "./transform-messages.js";
|
|
@@ -169,16 +170,58 @@ function hasHeader(headers, name) {
|
|
|
169
170
|
}
|
|
170
171
|
return false;
|
|
171
172
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (hasHeader(headers, "authorization") ||
|
|
173
|
+
function hasRequestAuth(apiKey, headers) {
|
|
174
|
+
return (!!apiKey ||
|
|
175
|
+
hasHeader(headers, "authorization") ||
|
|
176
176
|
hasHeader(headers, "x-api-key") ||
|
|
177
|
-
hasHeader(headers, "cf-aig-authorization"))
|
|
178
|
-
|
|
177
|
+
hasHeader(headers, "cf-aig-authorization"));
|
|
178
|
+
}
|
|
179
|
+
function assertRequestAuth(provider, apiKey, headers) {
|
|
180
|
+
if (!hasRequestAuth(apiKey, headers))
|
|
181
|
+
throw new Error(`No API key for provider: ${provider}`);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Anthropic SDK client that never runs the SDK's own credential chain
|
|
185
|
+
* (ANTHROPIC_PROFILE config files, federation env vars). Without this, every
|
|
186
|
+
* client built with `apiKey: null, authToken: null` for header-owned auth would
|
|
187
|
+
* also resolve and exchange SDK credentials behind pi's auth resolver.
|
|
188
|
+
*/
|
|
189
|
+
class PiAnthropic extends Anthropic {
|
|
190
|
+
_shouldResolveDefaultCredentials() {
|
|
191
|
+
return false;
|
|
179
192
|
}
|
|
180
|
-
throw new Error(`No API key for provider: ${provider}`);
|
|
181
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Workload identity federation config from the ANTHROPIC_* variables the
|
|
196
|
+
* Anthropic SDK documents; the SDK performs the token exchange and refresh.
|
|
197
|
+
* Only for the anthropic provider, since the exchange is an Anthropic API
|
|
198
|
+
* endpoint, and only when no key or auth header was resolved.
|
|
199
|
+
*/
|
|
200
|
+
function getAnthropicFederation(model, apiKey, headers, env) {
|
|
201
|
+
if (model.provider !== "anthropic" || hasRequestAuth(apiKey, headers))
|
|
202
|
+
return undefined;
|
|
203
|
+
const federationRuleId = getProviderEnvValue(ANTHROPIC_FEDERATION_RULE_ID_ENV, env);
|
|
204
|
+
const organizationId = getProviderEnvValue(ANTHROPIC_ORGANIZATION_ID_ENV, env);
|
|
205
|
+
const identityTokenFile = getProviderEnvValue(ANTHROPIC_IDENTITY_TOKEN_FILE_ENV, env);
|
|
206
|
+
if (!federationRuleId || !organizationId || !identityTokenFile)
|
|
207
|
+
return undefined;
|
|
208
|
+
return {
|
|
209
|
+
organization_id: organizationId,
|
|
210
|
+
workspace_id: getProviderEnvValue(ANTHROPIC_WORKSPACE_ID_ENV, env),
|
|
211
|
+
authentication: {
|
|
212
|
+
type: "oidc_federation",
|
|
213
|
+
federation_rule_id: federationRuleId,
|
|
214
|
+
service_account_id: getProviderEnvValue(ANTHROPIC_SERVICE_ACCOUNT_ID_ENV, env),
|
|
215
|
+
identity_token: { source: "file", path: identityTokenFile },
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The SDK caches the federated access token per client, but pi creates a client
|
|
221
|
+
* per request. Keep one client for the current federation config and fetch, and
|
|
222
|
+
* clone it per request with `withOptions()`, which shares the token cache.
|
|
223
|
+
*/
|
|
224
|
+
let federationClient;
|
|
182
225
|
const ANTHROPIC_MESSAGE_EVENTS = new Set([
|
|
183
226
|
"message_start",
|
|
184
227
|
"message_delta",
|
|
@@ -365,7 +408,9 @@ export const stream = (model, context, options) => {
|
|
|
365
408
|
}
|
|
366
409
|
else {
|
|
367
410
|
const apiKey = options?.apiKey;
|
|
368
|
-
|
|
411
|
+
const federation = getAnthropicFederation(model, apiKey, options?.headers, options?.env);
|
|
412
|
+
if (!federation)
|
|
413
|
+
assertRequestAuth(model.provider, apiKey, options?.headers);
|
|
369
414
|
let copilotDynamicHeaders;
|
|
370
415
|
if (model.provider === "github-copilot") {
|
|
371
416
|
const hasImages = hasCopilotVisionInput(normalizedContext.messages);
|
|
@@ -376,7 +421,7 @@ export const stream = (model, context, options) => {
|
|
|
376
421
|
}
|
|
377
422
|
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
378
423
|
const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
|
|
379
|
-
const created = createClient(model, apiKey, options?.headers, options?.fetch, copilotDynamicHeaders, cacheSessionId);
|
|
424
|
+
const created = createClient(model, apiKey, options?.headers, options?.fetch, copilotDynamicHeaders, cacheSessionId, federation);
|
|
380
425
|
client = created.client;
|
|
381
426
|
isOAuth = created.isOAuthToken;
|
|
382
427
|
}
|
|
@@ -508,6 +553,7 @@ export const stream = (model, context, options) => {
|
|
|
508
553
|
const block = blocks[index];
|
|
509
554
|
if (block && block.type === "toolCall") {
|
|
510
555
|
block.partialJson += event.delta.partial_json;
|
|
556
|
+
block.arguments = parseStreamingJson(block.partialJson);
|
|
511
557
|
stream.push({
|
|
512
558
|
type: "toolcall_delta",
|
|
513
559
|
contentIndex: index,
|
|
@@ -665,7 +711,9 @@ function mapThinkingLevelToEffort(model, level) {
|
|
|
665
711
|
}
|
|
666
712
|
}
|
|
667
713
|
export const streamSimple = (model, context, options) => {
|
|
668
|
-
|
|
714
|
+
if (!getAnthropicFederation(model, options?.apiKey, options?.headers, options?.env)) {
|
|
715
|
+
assertRequestAuth(model.provider, options?.apiKey, options?.headers);
|
|
716
|
+
}
|
|
669
717
|
const base = {
|
|
670
718
|
...buildBaseOptions(model, context, options, options?.apiKey),
|
|
671
719
|
toolChoice: options?.toolChoice,
|
|
@@ -700,10 +748,10 @@ export const streamSimple = (model, context, options) => {
|
|
|
700
748
|
function isOAuthToken(apiKey) {
|
|
701
749
|
return apiKey.includes("sk-ant-oat");
|
|
702
750
|
}
|
|
703
|
-
function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sessionId) {
|
|
751
|
+
function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sessionId, federation) {
|
|
704
752
|
// Copilot: Bearer auth.
|
|
705
753
|
if (model.provider === "github-copilot") {
|
|
706
|
-
const client = new
|
|
754
|
+
const client = new PiAnthropic({
|
|
707
755
|
apiKey: null,
|
|
708
756
|
authToken: apiKey ?? null,
|
|
709
757
|
baseURL: model.baseUrl,
|
|
@@ -718,7 +766,7 @@ function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sess
|
|
|
718
766
|
}
|
|
719
767
|
// OAuth: Bearer auth, Claude Code identity headers
|
|
720
768
|
if (apiKey && isOAuthToken(apiKey)) {
|
|
721
|
-
const client = new
|
|
769
|
+
const client = new PiAnthropic({
|
|
722
770
|
apiKey: null,
|
|
723
771
|
authToken: apiKey,
|
|
724
772
|
baseURL: model.baseUrl,
|
|
@@ -733,7 +781,7 @@ function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sess
|
|
|
733
781
|
});
|
|
734
782
|
return { client, isOAuthToken: true };
|
|
735
783
|
}
|
|
736
|
-
// API key
|
|
784
|
+
// API key, header-owned auth, or workload identity federation.
|
|
737
785
|
const compat = getAnthropicCompat(model);
|
|
738
786
|
const sessionAffinityHeaders = {};
|
|
739
787
|
if (sessionId && compat.sendSessionAffinityHeaders) {
|
|
@@ -744,7 +792,22 @@ function createClient(model, apiKey, optionsHeaders, fetch, dynamicHeaders, sess
|
|
|
744
792
|
accept: "application/json",
|
|
745
793
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
746
794
|
}, sessionAffinityHeaders, model.headers, optionsHeaders);
|
|
747
|
-
|
|
795
|
+
if (federation) {
|
|
796
|
+
const key = JSON.stringify([model.baseUrl, federation]);
|
|
797
|
+
if (federationClient?.key !== key || federationClient.fetch !== fetch) {
|
|
798
|
+
const client = new PiAnthropic({
|
|
799
|
+
apiKey: null,
|
|
800
|
+
authToken: null,
|
|
801
|
+
config: federation,
|
|
802
|
+
baseURL: model.baseUrl,
|
|
803
|
+
dangerouslyAllowBrowser: true,
|
|
804
|
+
fetch,
|
|
805
|
+
});
|
|
806
|
+
federationClient = { key, fetch, client };
|
|
807
|
+
}
|
|
808
|
+
return { client: federationClient.client.withOptions({ defaultHeaders }), isOAuthToken: false };
|
|
809
|
+
}
|
|
810
|
+
const client = new PiAnthropic({
|
|
748
811
|
apiKey: apiKey ?? null,
|
|
749
812
|
authToken: null,
|
|
750
813
|
baseURL: model.baseUrl,
|
|
@@ -1155,11 +1218,47 @@ function insertThinkingLevelMessages(converted, activeEffort) {
|
|
|
1155
1218
|
function shouldUseFineGrainedToolStreamingBeta(model, context) {
|
|
1156
1219
|
return getCurrentTools(context.messages).length > 0 && !getAnthropicCompat(model).supportsEagerToolInputStreaming;
|
|
1157
1220
|
}
|
|
1221
|
+
// Keywords Anthropic strict tool use rejects with a 400 for the whole request.
|
|
1222
|
+
// https://platform.claude.com/docs/en/build-with-claude/structured-outputs#json-schema-limitations
|
|
1223
|
+
const ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS = new Set([
|
|
1224
|
+
"minimum",
|
|
1225
|
+
"maximum",
|
|
1226
|
+
"exclusiveMinimum",
|
|
1227
|
+
"exclusiveMaximum",
|
|
1228
|
+
"multipleOf",
|
|
1229
|
+
"maxItems",
|
|
1230
|
+
"uniqueItems",
|
|
1231
|
+
"minContains",
|
|
1232
|
+
"maxContains",
|
|
1233
|
+
"minProperties",
|
|
1234
|
+
"maxProperties",
|
|
1235
|
+
]);
|
|
1236
|
+
const ANTHROPIC_STRICT_STRING_FORMATS = new Set([
|
|
1237
|
+
"date-time",
|
|
1238
|
+
"time",
|
|
1239
|
+
"date",
|
|
1240
|
+
"duration",
|
|
1241
|
+
"email",
|
|
1242
|
+
"hostname",
|
|
1243
|
+
"uri",
|
|
1244
|
+
"ipv4",
|
|
1245
|
+
"ipv6",
|
|
1246
|
+
"uuid",
|
|
1247
|
+
]);
|
|
1248
|
+
const isAnthropicStrictUnsupportedKeyword = (key, value) => {
|
|
1249
|
+
if (ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS.has(key))
|
|
1250
|
+
return true;
|
|
1251
|
+
if (key === "minItems")
|
|
1252
|
+
return value !== 0 && value !== 1;
|
|
1253
|
+
if (key === "format")
|
|
1254
|
+
return typeof value !== "string" || !ANTHROPIC_STRICT_STRING_FORMATS.has(value);
|
|
1255
|
+
return false;
|
|
1256
|
+
};
|
|
1158
1257
|
function convertTools(tools, isOAuthToken, supportsEagerToolInputStreaming, supportsStrictTools, cacheControl) {
|
|
1159
1258
|
if (!tools)
|
|
1160
1259
|
return [];
|
|
1161
1260
|
return tools.map((tool, index) => {
|
|
1162
|
-
const strict = resolveJsonSchemaStrictSampling(tool, supportsStrictTools);
|
|
1261
|
+
const strict = resolveJsonSchemaStrictSampling(tool, supportsStrictTools, isAnthropicStrictUnsupportedKeyword);
|
|
1163
1262
|
const parameters = getJsonSchemaToolParameters(tool, strict);
|
|
1164
1263
|
const schema = parameters;
|
|
1165
1264
|
const legacyInputSchema = {
|
|
@@ -460,6 +460,7 @@ function handleContentBlockDelta(event, blocks, output, stream) {
|
|
|
460
460
|
}
|
|
461
461
|
else if (delta?.toolUse && block?.type === "toolCall") {
|
|
462
462
|
block.partialJson = (block.partialJson || "") + (delta.toolUse.input || "");
|
|
463
|
+
block.arguments = parseStreamingJson(block.partialJson);
|
|
463
464
|
stream.push({ type: "toolcall_delta", contentIndex: index, delta: delta.toolUse.input || "", partial: output });
|
|
464
465
|
}
|
|
465
466
|
else if (delta?.reasoningContent) {
|
|
@@ -39,7 +39,7 @@ function schemaAllowsNull(schema) {
|
|
|
39
39
|
return true;
|
|
40
40
|
return Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));
|
|
41
41
|
}
|
|
42
|
-
function makeJsonSchemaNodeStrict(schema) {
|
|
42
|
+
function makeJsonSchemaNodeStrict(schema, isUnsupportedKeyword) {
|
|
43
43
|
if (!isJsonSchemaObject(schema)) {
|
|
44
44
|
throw new UnsupportedStrictJsonSchemaError("boolean schemas are unsupported");
|
|
45
45
|
}
|
|
@@ -48,6 +48,13 @@ function makeJsonSchemaNodeStrict(schema) {
|
|
|
48
48
|
throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
if (isUnsupportedKeyword) {
|
|
52
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
53
|
+
if (isUnsupportedKeyword(key, value)) {
|
|
54
|
+
throw new UnsupportedStrictJsonSchemaError(`${key}: ${JSON.stringify(value)} is unsupported`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
if (schema.anyOf !== undefined) {
|
|
52
59
|
if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {
|
|
53
60
|
throw new UnsupportedStrictJsonSchemaError("anyOf must contain at least one schema");
|
|
@@ -56,14 +63,14 @@ function makeJsonSchemaNodeStrict(schema) {
|
|
|
56
63
|
if (isStructuredSchema(variant)) {
|
|
57
64
|
throw new UnsupportedStrictJsonSchemaError("object and array unions are unsupported");
|
|
58
65
|
}
|
|
59
|
-
makeJsonSchemaNodeStrict(variant);
|
|
66
|
+
makeJsonSchemaNodeStrict(variant, isUnsupportedKeyword);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
if (schema.items !== undefined) {
|
|
63
70
|
if (Array.isArray(schema.items)) {
|
|
64
71
|
throw new UnsupportedStrictJsonSchemaError("tuple schemas are unsupported");
|
|
65
72
|
}
|
|
66
|
-
makeJsonSchemaNodeStrict(schema.items);
|
|
73
|
+
makeJsonSchemaNodeStrict(schema.items, isUnsupportedKeyword);
|
|
67
74
|
}
|
|
68
75
|
const isObjectSchema = schema.type === "object";
|
|
69
76
|
if (schema.properties !== undefined && !isObjectSchema) {
|
|
@@ -88,7 +95,7 @@ function makeJsonSchemaNodeStrict(schema) {
|
|
|
88
95
|
throw new UnsupportedStrictJsonSchemaError("required contains an unknown property");
|
|
89
96
|
}
|
|
90
97
|
for (const [key, property] of Object.entries(properties)) {
|
|
91
|
-
makeJsonSchemaNodeStrict(property);
|
|
98
|
+
makeJsonSchemaNodeStrict(property, isUnsupportedKeyword);
|
|
92
99
|
if (!required.has(key) && !schemaAllowsNull(property)) {
|
|
93
100
|
properties[key] = { anyOf: [property, { type: "null" }] };
|
|
94
101
|
}
|
|
@@ -97,12 +104,12 @@ function makeJsonSchemaNodeStrict(schema) {
|
|
|
97
104
|
schema.additionalProperties = false;
|
|
98
105
|
}
|
|
99
106
|
/** Convert a tool schema to the strict subset expected by provider constrained sampling. */
|
|
100
|
-
export function makeStrictJsonSchema(schema) {
|
|
107
|
+
export function makeStrictJsonSchema(schema, isUnsupportedKeyword) {
|
|
101
108
|
const cloned = structuredClone(schema);
|
|
102
109
|
if (!isJsonSchemaObject(cloned)) {
|
|
103
110
|
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
104
111
|
}
|
|
105
|
-
makeJsonSchemaNodeStrict(cloned);
|
|
112
|
+
makeJsonSchemaNodeStrict(cloned, isUnsupportedKeyword);
|
|
106
113
|
if (cloned.type !== "object") {
|
|
107
114
|
throw new UnsupportedStrictJsonSchemaError("root schema must have type object");
|
|
108
115
|
}
|
|
@@ -160,13 +167,17 @@ function inferGrammarInputProperty(tool) {
|
|
|
160
167
|
}
|
|
161
168
|
return inputProperty;
|
|
162
169
|
}
|
|
163
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Decide whether a JSON-schema tool is sent in strict mode. `isUnsupportedKeyword` lets a provider
|
|
172
|
+
* reject extra keywords its strict mode does not accept, so "prefer" tools fall back to non-strict.
|
|
173
|
+
*/
|
|
174
|
+
export function resolveJsonSchemaStrictSampling(tool, supportsStrictMode, isUnsupportedKeyword) {
|
|
164
175
|
const config = tool.constrainedSampling;
|
|
165
176
|
if (!config || config.type !== "json_schema")
|
|
166
177
|
return undefined;
|
|
167
178
|
if (supportsStrictMode) {
|
|
168
179
|
try {
|
|
169
|
-
makeStrictJsonSchema(tool.parameters);
|
|
180
|
+
makeStrictJsonSchema(tool.parameters, isUnsupportedKeyword);
|
|
170
181
|
return true;
|
|
171
182
|
}
|
|
172
183
|
catch (error) {
|
|
@@ -554,6 +554,7 @@ async function consumeChatStream(model, output, stream, mistralStream, onProvide
|
|
|
554
554
|
? toolCall.function.arguments
|
|
555
555
|
: JSON.stringify(toolCall.function.arguments || {});
|
|
556
556
|
block.partialArgs = (block.partialArgs || "") + argsDelta;
|
|
557
|
+
block.arguments = parseStreamingJson(block.partialArgs);
|
|
557
558
|
stream.push({
|
|
558
559
|
type: "toolcall_delta",
|
|
559
560
|
contentIndex: toolBlocksByKey.get(key),
|
|
@@ -438,6 +438,7 @@ export const stream = (model, context, options) => {
|
|
|
438
438
|
if (toolCall.function?.arguments) {
|
|
439
439
|
delta = toolCall.function.arguments;
|
|
440
440
|
block.partialArgs = (block.partialArgs ?? "") + toolCall.function.arguments;
|
|
441
|
+
block.arguments = parseStreamingJson(block.partialArgs);
|
|
441
442
|
}
|
|
442
443
|
else if (toolCall.custom?.input) {
|
|
443
444
|
const nextInput = getCustomToolCallInput(block) + toolCall.custom.input;
|
|
@@ -547,6 +547,7 @@ export async function processResponsesStream(openaiStream, output, stream, model
|
|
|
547
547
|
if (!slot || slot.block.partialJson === undefined)
|
|
548
548
|
continue;
|
|
549
549
|
slot.block.partialJson += event.delta;
|
|
550
|
+
slot.block.arguments = parseStreamingJson(slot.block.partialJson);
|
|
550
551
|
pushToolCallDelta(slot, event.delta);
|
|
551
552
|
}
|
|
552
553
|
else if (event.type === "response.function_call_arguments.done") {
|
|
@@ -155,6 +155,8 @@ function createEventConverter(model) {
|
|
|
155
155
|
case "toolcall_delta": {
|
|
156
156
|
const json = `${toolJson.get(event.contentIndex) ?? ""}${event.delta}`;
|
|
157
157
|
toolJson.set(event.contentIndex, json);
|
|
158
|
+
partial.content[event.contentIndex].arguments =
|
|
159
|
+
parseStreamingJson(json);
|
|
158
160
|
break;
|
|
159
161
|
}
|
|
160
162
|
case "toolcall_end":
|
|
@@ -30,6 +30,11 @@ import { getProviderEnvValue } from "./utils/provider-env.js";
|
|
|
30
30
|
export const ANTHROPIC_AUTH_TOKEN_ENV = "ANTHROPIC_AUTH_TOKEN";
|
|
31
31
|
export const ANTHROPIC_OAUTH_TOKEN_ENV = "ANTHROPIC_OAUTH_TOKEN";
|
|
32
32
|
export const ANTHROPIC_API_KEY_ENV = "ANTHROPIC_API_KEY";
|
|
33
|
+
export const ANTHROPIC_FEDERATION_RULE_ID_ENV = "ANTHROPIC_FEDERATION_RULE_ID";
|
|
34
|
+
export const ANTHROPIC_ORGANIZATION_ID_ENV = "ANTHROPIC_ORGANIZATION_ID";
|
|
35
|
+
export const ANTHROPIC_SERVICE_ACCOUNT_ID_ENV = "ANTHROPIC_SERVICE_ACCOUNT_ID";
|
|
36
|
+
export const ANTHROPIC_IDENTITY_TOKEN_FILE_ENV = "ANTHROPIC_IDENTITY_TOKEN_FILE";
|
|
37
|
+
export const ANTHROPIC_WORKSPACE_ID_ENV = "ANTHROPIC_WORKSPACE_ID";
|
|
33
38
|
let cachedVertexAdcCredentialsExists = null;
|
|
34
39
|
function hasVertexAdcCredentials(env) {
|
|
35
40
|
const explicitCredentialsPath = env?.GOOGLE_APPLICATION_CREDENTIALS;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { anthropicMessagesApi } from "../api/anthropic-messages.lazy.js";
|
|
2
2
|
import { lazyOAuth } from "../auth/helpers.js";
|
|
3
3
|
import { loadAnthropicOAuth } from "../auth/oauth/load.js";
|
|
4
|
-
import { ANTHROPIC_API_KEY_ENV, ANTHROPIC_AUTH_TOKEN_ENV, ANTHROPIC_OAUTH_TOKEN_ENV } from "../env-api-keys.js";
|
|
4
|
+
import { ANTHROPIC_API_KEY_ENV, ANTHROPIC_AUTH_TOKEN_ENV, ANTHROPIC_FEDERATION_RULE_ID_ENV, ANTHROPIC_IDENTITY_TOKEN_FILE_ENV, ANTHROPIC_OAUTH_TOKEN_ENV, ANTHROPIC_ORGANIZATION_ID_ENV, ANTHROPIC_SERVICE_ACCOUNT_ID_ENV, ANTHROPIC_WORKSPACE_ID_ENV, } from "../env-api-keys.js";
|
|
5
5
|
import { createProvider } from "../models.js";
|
|
6
6
|
import { ANTHROPIC_MODELS } from "./anthropic.models.js";
|
|
7
7
|
function anthropicApiKeyAuth() {
|
|
@@ -32,7 +32,29 @@ function anthropicApiKeyAuth() {
|
|
|
32
32
|
if (apiKey)
|
|
33
33
|
return { auth: { apiKey }, source: envVar };
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
// Workload identity federation: the Anthropic SDK exchanges the identity
|
|
36
|
+
// token for a short-lived access token and refreshes it itself. Last in
|
|
37
|
+
// line so keys and ANTHROPIC_AUTH_TOKEN keep winning, as in the SDK. The
|
|
38
|
+
// ids are provider config rather than auth, so they travel in `env`.
|
|
39
|
+
const federation = {};
|
|
40
|
+
for (const envVar of [
|
|
41
|
+
ANTHROPIC_FEDERATION_RULE_ID_ENV,
|
|
42
|
+
ANTHROPIC_ORGANIZATION_ID_ENV,
|
|
43
|
+
ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,
|
|
44
|
+
]) {
|
|
45
|
+
const value = await ctx.env(envVar);
|
|
46
|
+
signal.throwIfAborted();
|
|
47
|
+
if (!value)
|
|
48
|
+
return undefined;
|
|
49
|
+
federation[envVar] = value;
|
|
50
|
+
}
|
|
51
|
+
for (const envVar of [ANTHROPIC_SERVICE_ACCOUNT_ID_ENV, ANTHROPIC_WORKSPACE_ID_ENV]) {
|
|
52
|
+
const value = await ctx.env(envVar);
|
|
53
|
+
signal.throwIfAborted();
|
|
54
|
+
if (value)
|
|
55
|
+
federation[envVar] = value;
|
|
56
|
+
}
|
|
57
|
+
return { auth: {}, env: federation, source: "workload identity federation" };
|
|
36
58
|
},
|
|
37
59
|
};
|
|
38
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":6,"generatedAt":"2026-09-
|
|
1
|
+
{"schemaVersion":6,"generatedAt":"2026-09-30T19:17:00.024Z","structureHash":"3e97a64c71ef31a515f668d9fbc653d49b3ece171d88bfd103001e963497661f","files":{"amazon-bedrock.json":"a780b6402760cb3c7f25233bc68057df76dfcd0feb0913d419bb059e984441f0","ant-ling.json":"628feab3ef6c7d80ce96f75999804e1d9f05fec3851e5302e30fff3b69db90f6","anthropic.json":"3ff00b68990382e42626ebd1b65dcc28ae3cad9e6faa8920331ba92f067f1b3a","azure-openai-responses.json":"adeb2cf9d944d84f81b0d633c2e4e6bfa548a806c431902bd037c5f36500be21","baseten.json":"b04d1423d6958bec857ffccc36726f091ec1a8f3a09cf0836b64cc94b0ee697d","cerebras.json":"3eccb58c5de3d0dc7ba49dc6e477ba29f00cb3150ce0a35cc90d59e6b5ab368e","cloudflare-ai-gateway.json":"52decade622d1d25f1af90385b1aec7331dad00d56e010a5e4d15118efae67ce","cloudflare-workers-ai.json":"b9f76cc83756a05920a8a7046c515919a1de918331b860a211f309bb716c4bb0","deepseek.json":"10a296fb3e898f7715c80890c8af0af4f5fd58f22dbcd6612fdc5d762157ccdc","fireworks.json":"d6144ba451bd7a0617669527bec1898f97a633f7d7ea5035d8e03234550340c0","github-copilot.json":"573f05c2dfc0c8158e252dd286d6b174cd323f965284d7ae157439d8e3dea92c","google-vertex.json":"40090c680538bc867f2624d986a449f361be4dfa6ba96d7a27402050f036e009","google.json":"c0f5a633e5e5a5044432db3e537f4bc674d4de18df09325c6349547fcc13cabe","groq.json":"910952ad9dad07856983459d63fce0148dba1203edd7b10d801a77c5824f3405","huggingface.json":"1b8604bd31a5e05fe43a40ec1ec6dfc1a51a28b0b020151ef057fab43f57c923","kimi-coding.json":"582250b920454d98940da3e7e99d30b807edbea28f2eb8ac15f658d2ef41e8fc","meta.json":"0c7e9a370a7005c5a89dc94f0f93bc67b8935c3f802de324f11af6ff56fff429","minimax-cn.json":"f962c20ee6a6a342820f778e9dc363a18a524bf11998f6e2c57f2989915d62e5","minimax.json":"17a432f80d0ea6dd26eade80a4314250d3a855678601728a5f70dd8fa0d21dd2","mistral.json":"10f33bff9adf1248f7e6848e5890c265399f1f94e5b42cfdc28c109d547af98d","moonshotai-cn.json":"79c9585dc84ee525ebaebbc78b3c55f3d369ec884d4f943488f1e0b14e3587f5","moonshotai.json":"1da2c4e34f22aef17a07c974d85bdee8e1b68b6dc712e3769c935b3f1e7dadca","nvidia.json":"3b4e7b799bf3eaacd1af0491eef77fe33147ea7f72a3a9fa54d77af0e7eacf4c","openai-codex.json":"3cc35a7e122e5c77ee8ec30a9a3bd8bd59629997e85ba2cb3f9e0ed62e9a09c0","openai.json":"87faafcdd168c9b6fdaef521137834a207437daf0d71641fd0a2f3dddf4d1ecb","opencode-go.json":"d05b3eb87b81c6e5a94801484e668e660fe60c68f06a972b716d581c3bbd7c25","opencode.json":"50ea65154b6f3ec63fa03a99b663b00e194d22b54195a25ba3dd1306db659e26","openrouter.json":"5cf86aa12c4b0ff254b39410f2410cf972d1fe1340fc81251ecc5eb5bdfb37a6","qwen-token-plan-cn.json":"2469a4091c474ec3db0a49a9962d8d2726c074ad9065b96bc4e0c87861c4c6c5","qwen-token-plan-individual.json":"0fb7cf64faf39d1a3b0a884210a86c87084b805eda15644f5f39293287b959dd","qwen-token-plan.json":"eff10620cb577142de4ec02698d5961a71fda2fe4f6ae7ea9432bad9d6844176","radius.json":"c8e24a65119360946749c6d5e45782d84ab2794df661b369bb27c2bff3b72e67","together.json":"94ec3839972061405885d64f5fdbde48eb1f29a159be5e607e9770befd54e28e","typesafe.json":"a4429a2f696d5cc5273969af61a7310bda07d6bdcd27bf9ac9c76c534cc43716","vercel-ai-gateway.json":"4b430ccfdee72e776fa5337931a245c49b2f7ec729cccce359953f04aa544c6a","xai.json":"879c49b78b663a52a220ac4ee013e726b10c4f50aaa03bc58ee53a4b54c76928","xiaomi-token-plan-ams.json":"ca65178f4525d9705bc8d085ed136cecbe149c4080e857ea6a64ae643d2ac00a","xiaomi-token-plan-cn.json":"b065326926681c2262084e59c1c19ebdaf146c07107b5242c76b456becf74db0","xiaomi-token-plan-sgp.json":"92c3d6d707f81fd9cd2b6d1fb57dc431d90ba51e10fe49d97bc8806035c23492","xiaomi.json":"b81d01a374f7b558728c78d81f4168efa9c8996e6e2b5618409a8094b083c759","zai-coding-cn.json":"ee5ee705fb6e413a6088db5e3616c27fce802a8ece6c355f1db35490d787f610","zai.json":"58e6642fdfb736f0b9a4a277c760c536a3cea66a030abbfb2615f7b2851d5c6f"}}
|