modelrig 0.9.0 → 0.10.0
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/CHANGELOG.md +179 -0
- package/README.md +51 -27
- package/data/PROVENANCE.md +14 -0
- package/data/pricing-map.json +26 -0
- package/dist/adapters/attempt-meta-map.d.ts +8 -1
- package/dist/adapters/attempt-meta-map.d.ts.map +1 -1
- package/dist/adapters/attempt-meta-map.js +4 -0
- package/dist/adapters/build-adapters.js +2 -2
- package/dist/adapters/gemini.d.ts +28 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +38 -9
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +53 -4
- package/dist/adapters/openai-compat.d.ts +8 -2
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +8 -1
- package/dist/adapters/openai-stream.d.ts +10 -2
- package/dist/adapters/openai-stream.d.ts.map +1 -1
- package/dist/adapters/openai-stream.js +5 -1
- package/dist/adapters/openai.d.ts +10 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +57 -7
- package/dist/adapters/responses-api.d.ts +61 -0
- package/dist/adapters/responses-api.d.ts.map +1 -0
- package/dist/adapters/responses-api.js +124 -0
- package/dist/artifacts/artifact.d.ts +20 -0
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +207 -171
- package/dist/artifacts/index.d.ts +3 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +8 -1
- package/dist/bakeoff/groundedness.d.ts +58 -0
- package/dist/bakeoff/groundedness.d.ts.map +1 -0
- package/dist/bakeoff/groundedness.js +165 -0
- package/dist/bakeoff/quality.d.ts +14 -1
- package/dist/bakeoff/quality.d.ts.map +1 -1
- package/dist/bakeoff/quality.js +10 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -0
- package/dist/doctor-cli.d.ts +7 -0
- package/dist/doctor-cli.d.ts.map +1 -0
- package/dist/doctor-cli.js +67 -0
- package/dist/doctor-preflight.d.ts +52 -0
- package/dist/doctor-preflight.d.ts.map +1 -0
- package/dist/doctor-preflight.js +112 -0
- package/dist/feedback/grade.d.ts +8 -1
- package/dist/feedback/grade.d.ts.map +1 -1
- package/dist/feedback/grade.js +4 -0
- package/dist/gateway/http-protocol.d.ts +19 -0
- package/dist/gateway/http-protocol.d.ts.map +1 -1
- package/dist/gateway/serve-client.d.ts +99 -0
- package/dist/gateway/serve-client.d.ts.map +1 -0
- package/dist/gateway/serve-client.js +360 -0
- package/dist/index.d.ts +25 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -8
- package/dist/prompts/manifest.d.ts +128 -0
- package/dist/prompts/manifest.d.ts.map +1 -0
- package/dist/prompts/manifest.js +214 -0
- package/dist/prompts/prompt-fetch.d.ts +84 -0
- package/dist/prompts/prompt-fetch.d.ts.map +1 -0
- package/dist/prompts/prompt-fetch.js +120 -0
- package/dist/prompts/prompt-resolve.d.ts +76 -0
- package/dist/prompts/prompt-resolve.d.ts.map +1 -0
- package/dist/prompts/prompt-resolve.js +93 -0
- package/dist/prompts/slot-resolver.d.ts +91 -0
- package/dist/prompts/slot-resolver.d.ts.map +1 -0
- package/dist/prompts/slot-resolver.js +135 -0
- package/dist/prompts/tools-register.d.ts +60 -0
- package/dist/prompts/tools-register.d.ts.map +1 -0
- package/dist/prompts/tools-register.js +48 -0
- package/dist/prompts/version-hash.d.ts +29 -0
- package/dist/prompts/version-hash.d.ts.map +1 -0
- package/dist/prompts/version-hash.js +54 -0
- package/dist/prompts-export-cli.d.ts +21 -0
- package/dist/prompts-export-cli.d.ts.map +1 -0
- package/dist/prompts-export-cli.js +130 -0
- package/dist/registry/cache-policy.d.ts.map +1 -1
- package/dist/registry/cache-policy.js +22 -0
- package/dist/registry/pricing-shape.d.ts +38 -8
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +40 -12
- package/dist/registry/pricing.d.ts +6 -5
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +9 -5
- package/dist/routes/destination-loader.d.ts +16 -0
- package/dist/routes/destination-loader.d.ts.map +1 -0
- package/dist/routes/destination-loader.js +29 -0
- package/dist/routes/draft.d.ts +7 -0
- package/dist/routes/draft.d.ts.map +1 -1
- package/dist/routes/draft.js +12 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +27 -54
- package/dist/routes/output-loader.d.ts +42 -0
- package/dist/routes/output-loader.d.ts.map +1 -0
- package/dist/routes/output-loader.js +112 -0
- package/dist/routes/prompt-loader.d.ts +49 -0
- package/dist/routes/prompt-loader.d.ts.map +1 -0
- package/dist/routes/prompt-loader.js +113 -0
- package/dist/routes/resolved-bundle.d.ts +19 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +24 -0
- package/dist/routes/screen-loader.d.ts +1 -1
- package/dist/routes/screen-loader.d.ts.map +1 -1
- package/dist/routes/screen-loader.js +8 -1
- package/dist/run/accept.d.ts +3 -0
- package/dist/run/accept.d.ts.map +1 -1
- package/dist/run/accept.js +1 -0
- package/dist/run/cost.d.ts +31 -2
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +57 -2
- package/dist/run/destination.d.ts +39 -0
- package/dist/run/destination.d.ts.map +1 -0
- package/dist/run/destination.js +45 -0
- package/dist/run/dispatch.d.ts +25 -3
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +26 -4
- package/dist/run/raw-defaults.d.ts.map +1 -1
- package/dist/run/raw-defaults.js +6 -1
- package/dist/run/raw-finalize.d.ts +50 -0
- package/dist/run/raw-finalize.d.ts.map +1 -0
- package/dist/run/raw-finalize.js +266 -0
- package/dist/run/raw-knobs.d.ts +36 -0
- package/dist/run/raw-knobs.d.ts.map +1 -0
- package/dist/run/raw-knobs.js +99 -0
- package/dist/run/raw-request.d.ts +24 -0
- package/dist/run/raw-request.d.ts.map +1 -0
- package/dist/run/raw-request.js +69 -0
- package/dist/run/raw-schema.d.ts +76 -0
- package/dist/run/raw-schema.d.ts.map +1 -0
- package/dist/run/raw-schema.js +166 -0
- package/dist/run/raw-search-cost.d.ts +48 -0
- package/dist/run/raw-search-cost.d.ts.map +1 -0
- package/dist/run/raw-search-cost.js +78 -0
- package/dist/run/raw-support.d.ts +64 -6
- package/dist/run/raw-support.d.ts.map +1 -1
- package/dist/run/raw-support.js +84 -11
- package/dist/run/raw.d.ts +25 -26
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +30 -351
- package/dist/run/record-attempt.d.ts +8 -0
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +26 -12
- package/dist/run/repair-attempt.d.ts +68 -0
- package/dist/run/repair-attempt.d.ts.map +1 -0
- package/dist/run/repair-attempt.js +180 -0
- package/dist/run/resolve-destination.d.ts +49 -0
- package/dist/run/resolve-destination.d.ts.map +1 -0
- package/dist/run/resolve-destination.js +76 -0
- package/dist/run/routing-docs.d.ts.map +1 -1
- package/dist/run/routing-docs.js +9 -4
- package/dist/run/run.d.ts +30 -1
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +75 -148
- package/dist/run/telemetry-row.d.ts +92 -0
- package/dist/run/telemetry-row.d.ts.map +1 -0
- package/dist/run/telemetry-row.js +81 -0
- package/dist/run/validate.d.ts +12 -1
- package/dist/run/validate.d.ts.map +1 -1
- package/dist/run/validate.js +31 -0
- package/dist/run/web-search-pricing.d.ts +43 -0
- package/dist/run/web-search-pricing.d.ts.map +1 -0
- package/dist/run/web-search-pricing.js +56 -0
- package/dist/settings/grading-guide.d.ts +27 -1
- package/dist/settings/grading-guide.d.ts.map +1 -1
- package/dist/status.d.ts +6 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +4 -1
- package/dist/telemetry/artifact-store.d.ts.map +1 -1
- package/dist/telemetry/artifact-store.js +11 -0
- package/dist/telemetry/attempt-meta.d.ts +55 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +24 -1
- package/dist/telemetry/exporter-setup.d.ts +2 -0
- package/dist/telemetry/exporter-setup.d.ts.map +1 -1
- package/dist/telemetry/exporter-setup.js +6 -1
- package/dist/telemetry/grade-mappers.d.ts +5 -2
- package/dist/telemetry/grade-mappers.d.ts.map +1 -1
- package/dist/telemetry/grade-mappers.js +8 -2
- package/dist/telemetry/grades-sql.d.ts +4 -1
- package/dist/telemetry/grades-sql.d.ts.map +1 -1
- package/dist/telemetry/grades-sql.js +26 -3
- package/dist/telemetry/ingest-protocol.d.ts +26 -2
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +32 -29
- package/dist/telemetry/org-identity.d.ts +44 -0
- package/dist/telemetry/org-identity.d.ts.map +1 -0
- package/dist/telemetry/org-identity.js +98 -0
- package/dist/telemetry/route-registration.d.ts +48 -0
- package/dist/telemetry/route-registration.d.ts.map +1 -0
- package/dist/telemetry/route-registration.js +77 -0
- package/dist/telemetry/sinks.d.ts +10 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +52 -6
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +13 -0
- package/dist/tenancy/api-key-format.d.ts +16 -1
- package/dist/tenancy/api-key-format.d.ts.map +1 -1
- package/dist/tenancy/api-key-format.js +17 -0
- package/dist/types/provider.d.ts +20 -3
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/provider.js +1 -0
- package/dist/types/route.d.ts +76 -0
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +30 -2
- package/dist/types/telemetry.d.ts.map +1 -1
- package/docs/agent-skill/SKILL.md +73 -5
- package/docs/instrumentation.md +81 -36
- package/docs/llms.txt +95 -16
- package/docs/managed-serving.md +150 -0
- package/docs/mcp-oracle.md +75 -2
- package/docs/migration-playbook.md +5 -4
- package/docs/quickstart.md +169 -83
- package/package.json +3 -2
- package/registry/registry.json +82 -0
- package/dist/feedback/feedback.d.ts +0 -35
- package/dist/feedback/feedback.d.ts.map +0 -1
- package/dist/feedback/feedback.js +0 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok.d.ts","sourceRoot":"","sources":["../../src/adapters/grok.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMhE,OAAO,KAAK,EAAuB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"grok.d.ts","sourceRoot":"","sources":["../../src/adapters/grok.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMhE,OAAO,KAAK,EAAuB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAUhG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAKD,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAc7E;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAkDtE;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,IAAI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AAG,eAAe,CAqN5E"}
|
package/dist/adapters/grok.js
CHANGED
|
@@ -25,6 +25,7 @@ const openai_stream_1 = require("./openai-stream");
|
|
|
25
25
|
const attempt_meta_map_1 = require("./attempt-meta-map");
|
|
26
26
|
const sampling_1 = require("./sampling");
|
|
27
27
|
const raw_support_1 = require("../run/raw-support");
|
|
28
|
+
const responses_api_1 = require("./responses-api");
|
|
28
29
|
const GROK_BASE_URL = "https://api.x.ai/v1";
|
|
29
30
|
const DEFAULT_MAX_TOKENS = 32000;
|
|
30
31
|
function grokSupports(feature, _model) {
|
|
@@ -75,6 +76,23 @@ function classifyGrokFailure(message) {
|
|
|
75
76
|
fixHint: "this Grok model does not accept reasoning_effort — remove reasoning or pick a Grok reasoning variant",
|
|
76
77
|
};
|
|
77
78
|
}
|
|
79
|
+
// Native Web Search (spec N1, CE-9b, R1): xAI retired the old Live Search
|
|
80
|
+
// (`search_parameters` → HTTP 410); the native path is the Responses-API
|
|
81
|
+
// `web_search` tool. A 410 on the retired surface, or a `web_search` tool
|
|
82
|
+
// rejection, is taught rather than surfaced as a cryptic error. Retryable to
|
|
83
|
+
// the next candidate (network), never terminal.
|
|
84
|
+
if (/\b410\b|retired|no longer (available|supported)|search_parameters/.test(msg)) {
|
|
85
|
+
return {
|
|
86
|
+
cls: "network",
|
|
87
|
+
fixHint: "xAI retired the legacy Live Search surface (HTTP 410) — native grounding now uses the Responses-API web_search tool; upgrade the xAI SDK/endpoint or remove grounding",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (/web_search|web search/.test(msg)) {
|
|
91
|
+
return {
|
|
92
|
+
cls: "network",
|
|
93
|
+
fixHint: "this Grok model does not support the native web_search tool on the Responses API — remove grounding, or pick a Grok model that supports native web search (or use the inject rung)",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
78
96
|
return { cls: "network" };
|
|
79
97
|
}
|
|
80
98
|
function buildGrokParams(model, req) {
|
|
@@ -99,10 +117,10 @@ function buildGrokParams(model, req) {
|
|
|
99
117
|
...(req.reasoning !== undefined
|
|
100
118
|
? { reasoning_effort: (0, raw_support_1.coarsenGrokReasoningEffort)(req.reasoning.level) }
|
|
101
119
|
: {}),
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
// `
|
|
105
|
-
//
|
|
120
|
+
// Grounding is NOT mapped on the Chat Completions path: the native
|
|
121
|
+
// `web_search` tool is Responses-API-only, so a grounded request is routed to
|
|
122
|
+
// `client.responses.create` (buildResponsesParams) in `call()` above — this
|
|
123
|
+
// chat path only ever runs for a NON-grounded request (absent ⇒ byte-identical).
|
|
106
124
|
// response_format: a native strict json_schema (routed lane) wins; else the
|
|
107
125
|
// RAW lane's mime-shaping json_object (CE-9 R4). Absent both ⇒ no key.
|
|
108
126
|
...(req.outputSchema !== null
|
|
@@ -157,6 +175,37 @@ function createGrokAdapter(config) {
|
|
|
157
175
|
baseURL: GROK_BASE_URL,
|
|
158
176
|
timeout: req.timeoutMs,
|
|
159
177
|
});
|
|
178
|
+
// Native Web Search (spec N1/N4): a GROUNDED request dispatches to the
|
|
179
|
+
// Responses API (`web_search` tool — xAI Agent Tools) and buffers the
|
|
180
|
+
// result. Non-grounded requests fall through to the EXISTING
|
|
181
|
+
// chat.completions path, unchanged (absent ⇒ byte-identical). The shape
|
|
182
|
+
// lives in responses-api.ts.
|
|
183
|
+
if (req.grounding === true) {
|
|
184
|
+
const groundedAt = Date.now();
|
|
185
|
+
// 7.x Responses types include `web_search` natively (the 4.x union only
|
|
186
|
+
// knew `web_search_preview`) — buildResponsesParams returns the SDK's own
|
|
187
|
+
// ResponseCreateParamsNonStreaming, so NO cast is needed here.
|
|
188
|
+
const raw = await client.responses.create((0, responses_api_1.buildResponsesParams)(req));
|
|
189
|
+
const mapped = (0, responses_api_1.mapResponsesResult)(raw);
|
|
190
|
+
const usage = { ...mapped.usage, ttfbMs: Date.now() - groundedAt };
|
|
191
|
+
attemptMeta = (0, attempt_meta_map_1.buildAdapterMeta)("grok", {
|
|
192
|
+
req,
|
|
193
|
+
finishReasonRaw: null,
|
|
194
|
+
grounding: { citations: mapped.citations.length, searchProvider: "grok" },
|
|
195
|
+
streaming: false,
|
|
196
|
+
});
|
|
197
|
+
if (mapped.text.trim().length === 0) {
|
|
198
|
+
return fail("content_invalid", "empty response from Grok web_search (Responses API)", undefined, usage);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
ok: true,
|
|
202
|
+
text: mapped.text,
|
|
203
|
+
usage,
|
|
204
|
+
citations: mapped.citations,
|
|
205
|
+
...(mapped.searchCalls !== undefined ? { searchCalls: mapped.searchCalls } : {}),
|
|
206
|
+
meta: attemptMeta,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
160
209
|
const params = buildGrokParams(model, req);
|
|
161
210
|
const stream = await client.chat.completions.create(params);
|
|
162
211
|
let text = "";
|
|
@@ -31,8 +31,14 @@ export interface OpenAICompatHost {
|
|
|
31
31
|
/** The researched Tier-2 hosts (provider-coverage-plan §2, architect pick
|
|
32
32
|
* 2026-08-02): DeepInfra (widest open catalog, lowest price) + Fireworks
|
|
33
33
|
* (SOC 2/HIPAA reliability counterweight). Same weights on both on purpose
|
|
34
|
-
* — host-level conformance/latency/price deltas become registry facts.
|
|
35
|
-
|
|
34
|
+
* — host-level conformance/latency/price deltas become registry facts.
|
|
35
|
+
*
|
|
36
|
+
* B4a joins Z.ai (Zhipu, the GLM family) as a first-party OpenAI-compat host on
|
|
37
|
+
* its international endpoint. NO `shapeModelId`: Z.ai serves models by their bare
|
|
38
|
+
* id (`glm-5p2`) with no wire prefix (unlike Fireworks' `accounts/…` path), so
|
|
39
|
+
* the model id passes through verbatim — same as DeepInfra. Grounding stays
|
|
40
|
+
* fail-closed (raw-support.ts) until B4b wires native GLM `web_search`. */
|
|
41
|
+
export declare const OPENAI_COMPAT_HOSTS: Readonly<Record<"deepinfra" | "fireworks" | "zai", OpenAICompatHost>>;
|
|
36
42
|
export declare function classifyCompatFailure(message: string, host: string): ClassifiedFailure;
|
|
37
43
|
interface ChatMessage {
|
|
38
44
|
readonly role: "system" | "user";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-compat.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EACf,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMhE,OAAO,KAAK,EAAuB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAUhG;;8CAE8C;AAC9C,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACnD;AAED
|
|
1
|
+
{"version":3,"file":"openai-compat.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EACf,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMhE,OAAO,KAAK,EAAuB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAUhG;;8CAE8C;AAC9C,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACn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M,EAAE,MAAM,CAAA;SAAE,CAAC;KACjG,CAAC;IACN,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAOD;;2DAE2D;AAC3D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,YAAY,EACjB,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,GACxC,wBAAwB,CAmD1B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD;+DAC2D;IAC3D,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC;CAC5E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,eAAe,CA8L5F"}
|
|
@@ -42,10 +42,17 @@ function shapeFireworksModelId(model) {
|
|
|
42
42
|
/** The researched Tier-2 hosts (provider-coverage-plan §2, architect pick
|
|
43
43
|
* 2026-08-02): DeepInfra (widest open catalog, lowest price) + Fireworks
|
|
44
44
|
* (SOC 2/HIPAA reliability counterweight). Same weights on both on purpose
|
|
45
|
-
* — host-level conformance/latency/price deltas become registry facts.
|
|
45
|
+
* — host-level conformance/latency/price deltas become registry facts.
|
|
46
|
+
*
|
|
47
|
+
* B4a joins Z.ai (Zhipu, the GLM family) as a first-party OpenAI-compat host on
|
|
48
|
+
* its international endpoint. NO `shapeModelId`: Z.ai serves models by their bare
|
|
49
|
+
* id (`glm-5p2`) with no wire prefix (unlike Fireworks' `accounts/…` path), so
|
|
50
|
+
* the model id passes through verbatim — same as DeepInfra. Grounding stays
|
|
51
|
+
* fail-closed (raw-support.ts) until B4b wires native GLM `web_search`. */
|
|
46
52
|
exports.OPENAI_COMPAT_HOSTS = {
|
|
47
53
|
deepinfra: { baseUrl: "https://api.deepinfra.com/v1/openai" },
|
|
48
54
|
fireworks: { baseUrl: "https://api.fireworks.ai/inference/v1", shapeModelId: shapeFireworksModelId },
|
|
55
|
+
zai: { baseUrl: "https://api.z.ai/api/paas/v4" },
|
|
49
56
|
};
|
|
50
57
|
function classifyCompatFailure(message, host) {
|
|
51
58
|
const msg = message.toLowerCase();
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* dispatch, which is the spec's sanctioned `buffered` mode.
|
|
14
14
|
*/
|
|
15
15
|
import type { AdapterRequest, AdapterStreamEvent, ProviderId, ServiceTier } from "../types/provider";
|
|
16
|
+
import type { ServedTierSource } from "../telemetry/attempt-meta";
|
|
16
17
|
import type { OpenAIToolCallDelta } from "./tool-mapping";
|
|
17
18
|
/** The permissive chunk shape common to the OpenAI-dialect hosts. */
|
|
18
19
|
export interface OpenAIDialectChunk {
|
|
@@ -46,8 +47,15 @@ export interface OpenAIStreamConfig {
|
|
|
46
47
|
readonly provider: ProviderId;
|
|
47
48
|
/** Where cached-token counts live in this dialect's usage block. */
|
|
48
49
|
readonly cachedTokenSource: "details" | "cache_hit";
|
|
49
|
-
/** Served-tier resolver (openai maps flex/priority; the rest are standard).
|
|
50
|
-
|
|
50
|
+
/** Served-tier resolver (openai maps flex/priority; the rest are standard).
|
|
51
|
+
* Issue #2 (L6 F5): a resolver may return `{ tier, source }` to disclose
|
|
52
|
+
* whether the tier was echoed by the provider or fell back to the requested
|
|
53
|
+
* tier (`meta.served_tier_source`); a bare tier (the tier-less hosts) leaves
|
|
54
|
+
* the meta key absent. */
|
|
55
|
+
readonly mapServedTier: (raw: string | null, requested: ServiceTier) => ServiceTier | {
|
|
56
|
+
readonly tier: ServiceTier;
|
|
57
|
+
readonly source: ServedTierSource;
|
|
58
|
+
};
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
61
|
* Drain an OpenAI-dialect completion stream into `AdapterStreamEvent`s. Emits a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-stream.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAElB,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-stream.d.ts","sourceRoot":"","sources":["../../src/adapters/openai-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAElB,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE;YACf,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;SACtD,CAAC;QACF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACxC,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAChC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QACpC,QAAQ,CAAC,qBAAqB,CAAC,EAAE;YAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;QAC1C;;6DAEqD;QACrD,QAAQ,CAAC,oBAAoB,CAAC,EAAE;YAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1E,GAAG,IAAI,CAAC;CACV;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,GAAG,WAAW,CAAC;IACpD;;;;8BAI0B;IAC1B,QAAQ,CAAC,aAAa,EAAE,CACtB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,SAAS,EAAE,WAAW,KACnB,WAAW,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;KAAE,CAAC;CACtF;AAED;;;;;;GAMG;AACH,wBAAuB,mBAAmB,CACxC,MAAM,EAAE,aAAa,CAAC,kBAAkB,CAAC,EACzC,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,kBAAkB,GACtB,cAAc,CAAC,kBAAkB,CAAC,CA2HpC"}
|
|
@@ -72,12 +72,15 @@ async function* streamOpenAIDialect(chunks, req, dispatchedAt, cfg) {
|
|
|
72
72
|
// prompt_tokens already INCLUDES cached (and any write) on the OpenAI dialect,
|
|
73
73
|
// so tokensIn = promptTokens honors the subset invariant as-is. There is no 1h
|
|
74
74
|
// TTL tier on this dialect (OpenAI 5.6 writes are a single 30m tier) → 1h = 0.
|
|
75
|
+
const resolvedTier = cfg.mapServedTier(responseTier, req.requestedTier);
|
|
76
|
+
const servedTier = typeof resolvedTier === "string" ? resolvedTier : resolvedTier.tier;
|
|
77
|
+
const servedTierSource = typeof resolvedTier === "string" ? undefined : resolvedTier.source;
|
|
75
78
|
const usage = {
|
|
76
79
|
tokensIn: promptTokens,
|
|
77
80
|
tokensOut: completionTokens,
|
|
78
81
|
tokensCached: cachedTokens,
|
|
79
82
|
tokensCacheWrite: cacheWriteTokens,
|
|
80
|
-
servedTier
|
|
83
|
+
servedTier,
|
|
81
84
|
...(ttfbMs !== undefined ? { ttfbMs } : {}),
|
|
82
85
|
};
|
|
83
86
|
const toolCalls = toolCallAcc.finalize();
|
|
@@ -91,6 +94,7 @@ async function* streamOpenAIDialect(chunks, req, dispatchedAt, cfg) {
|
|
|
91
94
|
providerRequestId: responseId,
|
|
92
95
|
toolCalls,
|
|
93
96
|
streaming: true,
|
|
97
|
+
...(servedTierSource !== undefined ? { servedTierSource } : {}),
|
|
94
98
|
});
|
|
95
99
|
const fail = (message, fixHint) => ({
|
|
96
100
|
kind: "final",
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* Copyright (c) 2023 Berri AI, MIT License — retain this notice if LiteLLM's
|
|
12
12
|
* openai transformation logic is consulted during the port.
|
|
13
13
|
*/
|
|
14
|
-
import type { CapabilityFlag, ProviderAdapter } from "../types/provider";
|
|
14
|
+
import type { CapabilityFlag, ProviderAdapter, ServiceTier } from "../types/provider";
|
|
15
15
|
import type { ClassifiedFailure, ShapingInput } from "./gemini";
|
|
16
16
|
import type { OpenAIWireTool, OpenAIWireToolChoice } from "./tool-mapping";
|
|
17
|
+
import type { ServedTierSource } from "../telemetry/attempt-meta";
|
|
17
18
|
export interface OpenAIAdapterConfig {
|
|
18
19
|
readonly apiKey: string;
|
|
19
20
|
}
|
|
@@ -57,6 +58,14 @@ export interface OpenAIShapedParams {
|
|
|
57
58
|
readonly tool_choice?: OpenAIWireToolChoice;
|
|
58
59
|
}
|
|
59
60
|
export declare function buildOpenAIParams(model: string, req: ShapingInput): OpenAIShapedParams;
|
|
61
|
+
/** Served tier from the response's `service_tier` echo; absent ⇒ the requested
|
|
62
|
+
* tier (a flex request without an echo bills flex in production). Issue #2 (L6
|
|
63
|
+
* F5): the fallback is disclosed on `meta.served_tier_source` now that cost rows
|
|
64
|
+
* price at the served tier. Pure; exported for the unit test. */
|
|
65
|
+
export declare function mapOpenAIServedTier(raw: string | null, requested: ServiceTier): {
|
|
66
|
+
readonly tier: ServiceTier;
|
|
67
|
+
readonly source: ServedTierSource;
|
|
68
|
+
};
|
|
60
69
|
export declare function createOpenAIAdapter(config: OpenAIAdapterConfig): ProviderAdapter;
|
|
61
70
|
export {};
|
|
62
71
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/adapters/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMhE,OAAO,KAAK,EAAuB,cAAc,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAIhG,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAMD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAI9D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,KA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,CAAC;IACN,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,kBAAkB,CAuDtF;AAOD;;;iEAGiE;AACjE,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,SAAS,EAAE,WAAW,GACrB;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAKnE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,eAAe,CAuQhF"}
|
package/dist/adapters/openai.js
CHANGED
|
@@ -20,12 +20,14 @@ exports.isModelFlexEligible = isModelFlexEligible;
|
|
|
20
20
|
exports.openaiSupports = openaiSupports;
|
|
21
21
|
exports.classifyOpenAIFailure = classifyOpenAIFailure;
|
|
22
22
|
exports.buildOpenAIParams = buildOpenAIParams;
|
|
23
|
+
exports.mapOpenAIServedTier = mapOpenAIServedTier;
|
|
23
24
|
exports.createOpenAIAdapter = createOpenAIAdapter;
|
|
24
25
|
const openai_1 = __importDefault(require("openai"));
|
|
25
26
|
const tool_mapping_1 = require("./tool-mapping");
|
|
26
27
|
const openai_stream_1 = require("./openai-stream");
|
|
27
28
|
const attempt_meta_map_1 = require("./attempt-meta-map");
|
|
28
29
|
const sampling_1 = require("./sampling");
|
|
30
|
+
const responses_api_1 = require("./responses-api");
|
|
29
31
|
/** OpenAI's documented flex-eligible allowlist as of 2026-05 (ported).
|
|
30
32
|
* Mini and nano variants are silently downgraded to default tier. */
|
|
31
33
|
const FLEX_ELIGIBLE_PREFIXES = ["gpt-5.4", "gpt-5.2", "gpt-5.1", "gpt-5", "gpt-4.1"];
|
|
@@ -84,6 +86,17 @@ function classifyOpenAIFailure(message) {
|
|
|
84
86
|
fixHint: "this model does not accept reasoning_effort — remove reasoning or pick a reasoning model (e.g. an o-series / gpt-5 reasoning model)",
|
|
85
87
|
};
|
|
86
88
|
}
|
|
89
|
+
// Native Web Search (spec N1, R1): a Responses-API `web_search` tool rejection
|
|
90
|
+
// (400 unsupported tool / unknown tool / model without web search) is taught,
|
|
91
|
+
// not surfaced as a cryptic generic 400 — the point of forwarding verbatim
|
|
92
|
+
// rather than a per-model allowlist. Retryable to the next candidate (network),
|
|
93
|
+
// never terminal.
|
|
94
|
+
if (/web_search|web search/.test(msg)) {
|
|
95
|
+
return {
|
|
96
|
+
cls: "network",
|
|
97
|
+
fixHint: "this OpenAI model does not support the native web_search tool on the Responses API — remove grounding, or pick a model that supports native web search (or use the inject rung)",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
87
100
|
return { cls: "network" };
|
|
88
101
|
}
|
|
89
102
|
const DEFAULT_MAX_COMPLETION_TOKENS = 32000;
|
|
@@ -147,14 +160,18 @@ function buildOpenAIParams(model, req) {
|
|
|
147
160
|
* completion tokens on a 50K+ token prompt = flex degradation / stream drop. */
|
|
148
161
|
const SUSPICIOUSLY_SHORT_VISIBLE = 200;
|
|
149
162
|
const LONG_FORM_PROMPT_THRESHOLD = 50000;
|
|
150
|
-
|
|
163
|
+
/** Served tier from the response's `service_tier` echo; absent ⇒ the requested
|
|
164
|
+
* tier (a flex request without an echo bills flex in production). Issue #2 (L6
|
|
165
|
+
* F5): the fallback is disclosed on `meta.served_tier_source` now that cost rows
|
|
166
|
+
* price at the served tier. Pure; exported for the unit test. */
|
|
167
|
+
function mapOpenAIServedTier(raw, requested) {
|
|
151
168
|
if (raw === "flex")
|
|
152
|
-
return "flex";
|
|
169
|
+
return { tier: "flex", source: "provider" };
|
|
153
170
|
if (raw === "priority")
|
|
154
|
-
return "priority";
|
|
171
|
+
return { tier: "priority", source: "provider" };
|
|
155
172
|
if (raw === "default" || raw === "auto")
|
|
156
|
-
return "standard";
|
|
157
|
-
return requested === "flex" || requested === "priority" ? requested : "standard";
|
|
173
|
+
return { tier: "standard", source: "provider" };
|
|
174
|
+
return { tier: requested === "flex" || requested === "priority" ? requested : "standard", source: "requested_fallback" };
|
|
158
175
|
}
|
|
159
176
|
function createOpenAIAdapter(config) {
|
|
160
177
|
return {
|
|
@@ -183,6 +200,37 @@ function createOpenAIAdapter(config) {
|
|
|
183
200
|
});
|
|
184
201
|
try {
|
|
185
202
|
const client = new openai_1.default({ apiKey: config.apiKey, timeout: req.timeoutMs });
|
|
203
|
+
// Native Web Search (spec N1/N4): a GROUNDED request dispatches to the
|
|
204
|
+
// Responses API (`web_search` tool) and buffers the result. Non-grounded
|
|
205
|
+
// requests fall through to the EXISTING chat.completions path, unchanged
|
|
206
|
+
// (absent ⇒ byte-identical). Kept as thin as possible — the shape lives
|
|
207
|
+
// in responses-api.ts.
|
|
208
|
+
if (req.grounding === true) {
|
|
209
|
+
const groundedAt = Date.now();
|
|
210
|
+
// 7.x Responses types include `web_search` natively (the 4.x union only
|
|
211
|
+
// knew `web_search_preview`) — buildResponsesParams returns the SDK's own
|
|
212
|
+
// ResponseCreateParamsNonStreaming, so NO cast is needed here.
|
|
213
|
+
const raw = await client.responses.create((0, responses_api_1.buildResponsesParams)(req));
|
|
214
|
+
const mapped = (0, responses_api_1.mapResponsesResult)(raw);
|
|
215
|
+
const usage = { ...mapped.usage, ttfbMs: Date.now() - groundedAt };
|
|
216
|
+
attemptMeta = (0, attempt_meta_map_1.buildAdapterMeta)("openai", {
|
|
217
|
+
req,
|
|
218
|
+
finishReasonRaw: null,
|
|
219
|
+
grounding: { citations: mapped.citations.length, searchProvider: "openai" },
|
|
220
|
+
streaming: false,
|
|
221
|
+
});
|
|
222
|
+
if (mapped.text.trim().length === 0) {
|
|
223
|
+
return fail("content_invalid", "empty response from OpenAI web_search (Responses API)", undefined, usage);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
ok: true,
|
|
227
|
+
text: mapped.text,
|
|
228
|
+
usage,
|
|
229
|
+
citations: mapped.citations,
|
|
230
|
+
...(mapped.searchCalls !== undefined ? { searchCalls: mapped.searchCalls } : {}),
|
|
231
|
+
meta: attemptMeta,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
186
234
|
const params = buildOpenAIParams(model, req);
|
|
187
235
|
const dispatchedAt = Date.now();
|
|
188
236
|
const stream = await client.chat.completions.create(params);
|
|
@@ -228,13 +276,14 @@ function createOpenAIAdapter(config) {
|
|
|
228
276
|
reasoningTokens = chunk.usage.completion_tokens_details?.reasoning_tokens ?? 0;
|
|
229
277
|
}
|
|
230
278
|
}
|
|
279
|
+
const servedTierInfo = mapOpenAIServedTier(responseTier, req.requestedTier);
|
|
231
280
|
// prompt_tokens already INCLUDES cached+write → tokensIn is subset-correct.
|
|
232
281
|
const usage = {
|
|
233
282
|
tokensIn: promptTokens,
|
|
234
283
|
tokensOut: completionTokens,
|
|
235
284
|
tokensCached: cachedTokens,
|
|
236
285
|
tokensCacheWrite: cacheWriteTokens,
|
|
237
|
-
servedTier:
|
|
286
|
+
servedTier: servedTierInfo.tier,
|
|
238
287
|
...(ttfbMs !== undefined ? { ttfbMs } : {}),
|
|
239
288
|
};
|
|
240
289
|
// Tool-call turn (spec §4.4): the model chose to call a tool. Surface
|
|
@@ -253,6 +302,7 @@ function createOpenAIAdapter(config) {
|
|
|
253
302
|
providerRequestId: responseId,
|
|
254
303
|
toolCalls,
|
|
255
304
|
streaming: false,
|
|
305
|
+
servedTierSource: servedTierInfo.source,
|
|
256
306
|
});
|
|
257
307
|
// Any streamed refusal is terminal for this call, even alongside
|
|
258
308
|
// partial content — OpenAI's structured-output semantics (ported).
|
|
@@ -307,7 +357,7 @@ function createOpenAIAdapter(config) {
|
|
|
307
357
|
yield* (0, openai_stream_1.streamOpenAIDialect)(stream, req, dispatchedAt, {
|
|
308
358
|
provider: "openai",
|
|
309
359
|
cachedTokenSource: "details",
|
|
310
|
-
mapServedTier,
|
|
360
|
+
mapServedTier: mapOpenAIServedTier,
|
|
311
361
|
});
|
|
312
362
|
}
|
|
313
363
|
catch (error) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responses-API dispatch path (Native Web Search lane, spec N1–N2) — the SHARED
|
|
3
|
+
* request/response mapping for providers whose native `web_search` tool lives only
|
|
4
|
+
* on `/v1/responses` (OpenAI + xAI/Grok today; same shape). This is a NEW dispatch
|
|
5
|
+
* path, NOT an extension of the Chat Completions `tools` block — see research §2.
|
|
6
|
+
*
|
|
7
|
+
* DOCTRINE (inherited from CE-9):
|
|
8
|
+
* - ABSENT ⇒ BYTE-IDENTICAL. This path is entered ONLY for a grounded request
|
|
9
|
+
* (`req.grounding === true`). A non-grounded request stays on the adapter's
|
|
10
|
+
* existing `chat.completions.create` call, unchanged. The per-adapter branch
|
|
11
|
+
* lives in openai.ts / grok.ts (Step 2); this module owns only the Responses shape.
|
|
12
|
+
* - FORWARD-VERBATIM + CLASSIFY-TEACHABLY: forward the web_search tool + sampling/
|
|
13
|
+
* reasoning under their Responses-dialect names; let the provider enforce; map a
|
|
14
|
+
* rejection onto an EXISTING FailureClass with a teaching fixHint (no new class).
|
|
15
|
+
* - CITATIONS: map `response` citations onto the `url_citation` shape already used
|
|
16
|
+
* by the inject rung (src/run/grounding.ts) — do NOT invent a second type.
|
|
17
|
+
*/
|
|
18
|
+
import type OpenAI from "openai";
|
|
19
|
+
import type { AdapterRequest, AdapterUsage } from "../types/provider";
|
|
20
|
+
import type { UrlCitation } from "../run/grounding";
|
|
21
|
+
/**
|
|
22
|
+
* Shaped parameters for `client.responses.create` on the grounded path. This is
|
|
23
|
+
* the SDK's own non-streaming Responses request type (openai@7.x
|
|
24
|
+
* `ResponseCreateParamsNonStreaming`) — the grounded path buffers a single
|
|
25
|
+
* `Response` (no `stream: true`), so the params type-check natively against
|
|
26
|
+
* `client.responses.create` with NO cast. `input` is the message list
|
|
27
|
+
* (EasyInputMessage `{ role, content }`), `tools` carries the native
|
|
28
|
+
* `web_search` server tool (now a first-class member of the SDK `Tool` union —
|
|
29
|
+
* the 4.x types only knew `web_search_preview`, which is why this path used to
|
|
30
|
+
* cast), and sampling/reasoning ride their Responses-dialect names
|
|
31
|
+
* (`temperature`/`top_p` unchanged, `max_output_tokens`, `reasoning.effort`).
|
|
32
|
+
*/
|
|
33
|
+
export type ResponsesShapedParams = OpenAI.Responses.ResponseCreateParamsNonStreaming;
|
|
34
|
+
/** Normalized result of a grounded Responses call (spec N2). Citations reuse the
|
|
35
|
+
* inject rung's `url_citation` shape (`src/run/grounding.ts`) — no second type. */
|
|
36
|
+
export interface ResponsesResult {
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly usage: AdapterUsage;
|
|
39
|
+
readonly citations: readonly UrlCitation[];
|
|
40
|
+
/** Native web_search tool calls billed on this response (spec N3). Absent ⇒ the
|
|
41
|
+
* raw success path assumes 1 (disclosed). */
|
|
42
|
+
readonly searchCalls?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build the `responses.create` params for a grounded request. Appends the
|
|
46
|
+
* `web_search` tool; forwards sampling/reasoning. Callers MUST only invoke this when
|
|
47
|
+
* `req.grounding === true` (the guard already enforced provider support pre-dispatch).
|
|
48
|
+
*
|
|
49
|
+
* Reasoning maps 1:1 for OpenAI (`level` → `reasoning.effort`); for grok the neutral
|
|
50
|
+
* four-level `level` is coarsened to xAI's `low|high` via `coarsenGrokReasoningEffort`
|
|
51
|
+
* (the SAME disclosed mapping the Chat Completions path uses — never a silent drop).
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildResponsesParams(req: AdapterRequest): ResponsesShapedParams;
|
|
54
|
+
/**
|
|
55
|
+
* Map a raw `responses.create` result onto ModelRig's normalized shape: output text,
|
|
56
|
+
* AdapterUsage (cache-read is a SUBSET of `tokensIn`, per the WS-A invariant), and
|
|
57
|
+
* citations in the `url_citation` shape. A zero-citation grounded response is
|
|
58
|
+
* SURFACED (empty array), never thrown (spec N2).
|
|
59
|
+
*/
|
|
60
|
+
export declare function mapResponsesResult(response: unknown): ResponsesResult;
|
|
61
|
+
//# sourceMappingURL=responses-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses-api.d.ts","sourceRoot":"","sources":["../../src/adapters/responses-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAOpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,SAAS,CAAC,gCAAgC,CAAC;AAEtF;mFACmF;AACnF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C;iDAC6C;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,qBAAqB,CA8B/E;AA6BD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,eAAe,CAyDrE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Responses-API dispatch path (Native Web Search lane, spec N1–N2) — the SHARED
|
|
4
|
+
* request/response mapping for providers whose native `web_search` tool lives only
|
|
5
|
+
* on `/v1/responses` (OpenAI + xAI/Grok today; same shape). This is a NEW dispatch
|
|
6
|
+
* path, NOT an extension of the Chat Completions `tools` block — see research §2.
|
|
7
|
+
*
|
|
8
|
+
* DOCTRINE (inherited from CE-9):
|
|
9
|
+
* - ABSENT ⇒ BYTE-IDENTICAL. This path is entered ONLY for a grounded request
|
|
10
|
+
* (`req.grounding === true`). A non-grounded request stays on the adapter's
|
|
11
|
+
* existing `chat.completions.create` call, unchanged. The per-adapter branch
|
|
12
|
+
* lives in openai.ts / grok.ts (Step 2); this module owns only the Responses shape.
|
|
13
|
+
* - FORWARD-VERBATIM + CLASSIFY-TEACHABLY: forward the web_search tool + sampling/
|
|
14
|
+
* reasoning under their Responses-dialect names; let the provider enforce; map a
|
|
15
|
+
* rejection onto an EXISTING FailureClass with a teaching fixHint (no new class).
|
|
16
|
+
* - CITATIONS: map `response` citations onto the `url_citation` shape already used
|
|
17
|
+
* by the inject rung (src/run/grounding.ts) — do NOT invent a second type.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.buildResponsesParams = buildResponsesParams;
|
|
21
|
+
exports.mapResponsesResult = mapResponsesResult;
|
|
22
|
+
const sampling_1 = require("./sampling");
|
|
23
|
+
const raw_support_1 = require("../run/raw-support");
|
|
24
|
+
/** Parity with the Chat Completions default output cap (openai.ts / grok.ts). */
|
|
25
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 32000;
|
|
26
|
+
/**
|
|
27
|
+
* Build the `responses.create` params for a grounded request. Appends the
|
|
28
|
+
* `web_search` tool; forwards sampling/reasoning. Callers MUST only invoke this when
|
|
29
|
+
* `req.grounding === true` (the guard already enforced provider support pre-dispatch).
|
|
30
|
+
*
|
|
31
|
+
* Reasoning maps 1:1 for OpenAI (`level` → `reasoning.effort`); for grok the neutral
|
|
32
|
+
* four-level `level` is coarsened to xAI's `low|high` via `coarsenGrokReasoningEffort`
|
|
33
|
+
* (the SAME disclosed mapping the Chat Completions path uses — never a silent drop).
|
|
34
|
+
*/
|
|
35
|
+
function buildResponsesParams(req) {
|
|
36
|
+
const input = [
|
|
37
|
+
...(req.systemPrompt !== "" ? [{ role: "system", content: req.systemPrompt }] : []),
|
|
38
|
+
{ role: "user", content: req.userPrompt },
|
|
39
|
+
];
|
|
40
|
+
const reasoning = req.reasoning !== undefined
|
|
41
|
+
? {
|
|
42
|
+
reasoning: {
|
|
43
|
+
effort: req.candidate.provider === "grok"
|
|
44
|
+
? (0, raw_support_1.coarsenGrokReasoningEffort)(req.reasoning.level)
|
|
45
|
+
: req.reasoning.level,
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
: {};
|
|
49
|
+
return {
|
|
50
|
+
model: req.candidate.model,
|
|
51
|
+
input,
|
|
52
|
+
// Native web-search server tool, left at defaults. As of openai@7.x the
|
|
53
|
+
// `web_search` tool type also accepts `filters`, `external_web_access`, and
|
|
54
|
+
// `search_context_size` (a token/context-budget knob) — NOT wired here on
|
|
55
|
+
// purpose (they need product knobs); available for a follow-up mission.
|
|
56
|
+
tools: [{ type: "web_search" }],
|
|
57
|
+
max_output_tokens: (0, sampling_1.effectiveMaxOutputTokens)(req, DEFAULT_MAX_OUTPUT_TOKENS),
|
|
58
|
+
// temperature / top_p share the Chat Completions dialect names on the
|
|
59
|
+
// Responses API — reuse the one sampling mapper (absent ⇒ no keys added).
|
|
60
|
+
...(0, sampling_1.openAISamplingFields)(req),
|
|
61
|
+
...reasoning,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Map a raw `responses.create` result onto ModelRig's normalized shape: output text,
|
|
66
|
+
* AdapterUsage (cache-read is a SUBSET of `tokensIn`, per the WS-A invariant), and
|
|
67
|
+
* citations in the `url_citation` shape. A zero-citation grounded response is
|
|
68
|
+
* SURFACED (empty array), never thrown (spec N2).
|
|
69
|
+
*/
|
|
70
|
+
function mapResponsesResult(response) {
|
|
71
|
+
const r = (typeof response === "object" && response !== null ? response : {});
|
|
72
|
+
const items = Array.isArray(r.output) ? r.output : [];
|
|
73
|
+
// Text: prefer the SDK convenience aggregate, else concatenate output_text parts.
|
|
74
|
+
const aggregate = typeof r.output_text === "string" ? r.output_text : "";
|
|
75
|
+
const text = aggregate !== ""
|
|
76
|
+
? aggregate
|
|
77
|
+
: items
|
|
78
|
+
.filter((it) => it.type === "message")
|
|
79
|
+
.flatMap((it) => it.content ?? [])
|
|
80
|
+
.filter((c) => c.type === "output_text" && typeof c.text === "string")
|
|
81
|
+
.map((c) => c.text)
|
|
82
|
+
.join("");
|
|
83
|
+
// Citations: url_citation annotations on output_text parts, deduped by URL,
|
|
84
|
+
// first-seen title wins. Reuses the inject rung's UrlCitation shape.
|
|
85
|
+
const seen = new Set();
|
|
86
|
+
const citations = [];
|
|
87
|
+
for (const it of items) {
|
|
88
|
+
if (it.type !== "message")
|
|
89
|
+
continue;
|
|
90
|
+
for (const part of it.content ?? []) {
|
|
91
|
+
if (part.type !== "output_text")
|
|
92
|
+
continue;
|
|
93
|
+
for (const ann of part.annotations ?? []) {
|
|
94
|
+
if (ann.type !== "url_citation" || typeof ann.url !== "string" || ann.url === "")
|
|
95
|
+
continue;
|
|
96
|
+
if (seen.has(ann.url))
|
|
97
|
+
continue;
|
|
98
|
+
seen.add(ann.url);
|
|
99
|
+
citations.push({
|
|
100
|
+
type: "url_citation",
|
|
101
|
+
url: ann.url,
|
|
102
|
+
...(typeof ann.title === "string" && ann.title !== "" ? { title: ann.title } : {}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// usage: input_tokens already INCLUDES cached_tokens → tokensIn is subset-correct
|
|
108
|
+
// (WS-A). The Responses API reports no cache-write on these providers ⇒ 0/omit.
|
|
109
|
+
const usage = {
|
|
110
|
+
tokensIn: r.usage?.input_tokens ?? 0,
|
|
111
|
+
tokensOut: r.usage?.output_tokens ?? 0,
|
|
112
|
+
tokensCached: r.usage?.input_tokens_details?.cached_tokens ?? 0,
|
|
113
|
+
servedTier: "standard",
|
|
114
|
+
};
|
|
115
|
+
// searchCalls: count the web_search_call output items (spec N3). None ⇒ undefined
|
|
116
|
+
// (the raw success path assumes 1, disclosed).
|
|
117
|
+
const searchCalls = items.filter((it) => it.type === "web_search_call").length;
|
|
118
|
+
return {
|
|
119
|
+
text,
|
|
120
|
+
usage,
|
|
121
|
+
citations,
|
|
122
|
+
...(searchCalls > 0 ? { searchCalls } : {}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -18,6 +18,7 @@ import type { EvalCaseOrigin } from "../types/telemetry";
|
|
|
18
18
|
import { type ScrubMode } from "./scrub";
|
|
19
19
|
import { type TaskSettingsResolver } from "../settings/task-settings";
|
|
20
20
|
import type { ContentUploadInput, ContentUploadOutcome } from "./content-uploader";
|
|
21
|
+
import { type Manifest } from "../prompts/manifest";
|
|
21
22
|
/** The upload transport `save` fires content through — injected so the SDK's
|
|
22
23
|
* networked implementation and the tests share one seam. */
|
|
23
24
|
export type ArtifactContentUploader = (input: ContentUploadInput) => Promise<ContentUploadOutcome>;
|
|
@@ -64,6 +65,15 @@ export interface ArtifactSaveOptions {
|
|
|
64
65
|
readonly supersedes?: ArtifactHandle;
|
|
65
66
|
readonly expiresAt?: string;
|
|
66
67
|
}
|
|
68
|
+
/** Options for {@link ArtifactApi.saveManifest} — the grouping keys the manifest
|
|
69
|
+
* artifact inherits from its prompt (task/step), mirroring a normal save. */
|
|
70
|
+
export interface ArtifactManifestOptions {
|
|
71
|
+
/** Artifact name; defaults to `<prompt name>.manifest` / `"manifest"`. */
|
|
72
|
+
readonly name?: string;
|
|
73
|
+
readonly task?: string;
|
|
74
|
+
readonly stepKey?: string;
|
|
75
|
+
readonly attemptNo?: number;
|
|
76
|
+
}
|
|
67
77
|
export interface ArtifactPromoteOptions {
|
|
68
78
|
readonly note?: string;
|
|
69
79
|
/** The route/task this case belongs to. Falls back to the task the source
|
|
@@ -81,6 +91,16 @@ export interface ArtifactApi {
|
|
|
81
91
|
* a handle. Returns null when the namespace is disabled or a zeroRetention run
|
|
82
92
|
* refuses it (fail-closed). */
|
|
83
93
|
save(value: unknown, opts: ArtifactSaveOptions): ArtifactHandle | null;
|
|
94
|
+
/** PSR-1: attach a **structure-only** assembly manifest (spec §2.1) to a
|
|
95
|
+
* `prompt` artifact. Validates the manifest, saves it as a linked free-text
|
|
96
|
+
* `type: "manifest"` artifact (ZERO-DDL — the `type` column is open), and
|
|
97
|
+
* links `prompt → manifest` with a `derived_from` edge so the manifest joins
|
|
98
|
+
* the existing prompt lineage and stays addressable for PSR-2 ingest. Returns
|
|
99
|
+
* the manifest handle, or null when the manifest is invalid (a counted,
|
|
100
|
+
* teaching warn — never throws) or custody/zeroRetention refuses the save.
|
|
101
|
+
* A no-op unless explicitly called, so `save` stays byte-identical (the emit
|
|
102
|
+
* is inert without a manifest). */
|
|
103
|
+
saveManifest(prompt: ArtifactHandle | string, manifest: Manifest, opts?: ArtifactManifestOptions): ArtifactHandle | null;
|
|
84
104
|
/** Mark an artifact consumed by the current run (feeds derived_from lineage). */
|
|
85
105
|
load(ref: ArtifactHandle | string): void;
|
|
86
106
|
/** Explicit lineage edge the runtime cannot infer. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO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