modelrig 0.2.0 → 0.4.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 +204 -0
- package/README.md +68 -4
- package/dist/adapters/deepseek.d.ts.map +1 -1
- package/dist/adapters/deepseek.js +8 -1
- package/dist/adapters/gemini.d.ts +16 -0
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +44 -3
- package/dist/adapters/grok.d.ts +7 -0
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +23 -1
- package/dist/adapters/openai-compat.d.ts +7 -0
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +24 -1
- package/dist/adapters/openai.d.ts +7 -0
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +23 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -4
- package/dist/config.d.ts +7 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -25
- package/dist/init/init-cli.d.ts.map +1 -1
- package/dist/init/init-cli.js +2 -1
- package/dist/init/observe-cli.d.ts.map +1 -1
- package/dist/init/observe-cli.js +2 -1
- package/dist/routes/loader.d.ts +11 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +29 -0
- package/dist/routes/sampling-config.d.ts.map +1 -1
- package/dist/routes/sampling-config.js +11 -0
- package/dist/run/dispatch.d.ts +14 -2
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +31 -2
- package/dist/run/ladder-key.d.ts +40 -0
- package/dist/run/ladder-key.d.ts.map +1 -0
- package/dist/run/ladder-key.js +39 -0
- package/dist/run/raw-support.d.ts +123 -0
- package/dist/run/raw-support.d.ts.map +1 -0
- package/dist/run/raw-support.js +150 -0
- package/dist/run/raw.d.ts +73 -1
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +129 -8
- package/dist/run/rawonly.d.ts +60 -0
- package/dist/run/rawonly.d.ts.map +1 -0
- package/dist/run/rawonly.js +120 -0
- package/dist/run/record-attempt.d.ts +14 -1
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +43 -2
- package/dist/run/resolve.d.ts +4 -0
- package/dist/run/resolve.d.ts.map +1 -1
- package/dist/run/resolve.js +9 -2
- package/dist/run/routing-docs.d.ts +73 -0
- package/dist/run/routing-docs.d.ts.map +1 -0
- package/dist/run/routing-docs.js +222 -0
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +24 -22
- package/dist/telemetry/exporter.d.ts.map +1 -1
- package/dist/telemetry/exporter.js +6 -0
- package/dist/telemetry/ingest-protocol.d.ts +7 -0
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/load-error-report.d.ts.map +1 -1
- package/dist/telemetry/load-error-report.js +4 -1
- package/dist/telemetry/otel-map.d.ts.map +1 -1
- package/dist/telemetry/otel-map.js +8 -0
- package/dist/telemetry/store-migrations.d.ts +15 -0
- package/dist/telemetry/store-migrations.d.ts.map +1 -0
- package/dist/telemetry/store-migrations.js +119 -0
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/store.js +26 -93
- package/dist/types/failures-teaching.js +1 -1
- package/dist/types/provider.d.ts +38 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/route.d.ts +6 -1
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +31 -0
- package/dist/types/telemetry.d.ts.map +1 -1
- package/dist/validate-cli.d.ts.map +1 -1
- package/dist/validate-cli.js +17 -4
- package/package.json +1 -1
package/dist/run/dispatch.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.recordSearchCostRow = recordSearchCostRow;
|
|
14
|
+
exports.jsonModeCoaching = jsonModeCoaching;
|
|
14
15
|
exports.buildAdapterRequest = buildAdapterRequest;
|
|
15
16
|
exports.buildRepairAdapterRequest = buildRepairAdapterRequest;
|
|
16
17
|
exports.dispatchCandidate = dispatchCandidate;
|
|
@@ -21,7 +22,11 @@ const cache_handle_1 = require("./cache-handle");
|
|
|
21
22
|
/** Record the grounding-inject search's own telemetry row (WS3): a $-only line
|
|
22
23
|
* under the synthetic "search" provider. Extracted from run.ts to keep it under
|
|
23
24
|
* the LOC cap; behaviour is byte-identical to the prior inline recorder. */
|
|
24
|
-
function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, searchProviderId, costUsd) {
|
|
25
|
+
function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, searchProviderId, costUsd, ladder) {
|
|
26
|
+
// Ladder key (spec §2.1 R0): the search-cost row belongs to the same call and
|
|
27
|
+
// rides the same monotonic seq; candidate_index is the candidate this search
|
|
28
|
+
// grounds for (the current one — the run loop set it before the search).
|
|
29
|
+
const ladderKey = ladder.stamp();
|
|
25
30
|
telemetry.record({
|
|
26
31
|
id: (0, node_crypto_1.randomUUID)(),
|
|
27
32
|
ts: new Date().toISOString(),
|
|
@@ -41,15 +46,33 @@ function recordSearchCostRow(telemetry, route, effectiveTags, servedVariant, sea
|
|
|
41
46
|
ttfbMs: null,
|
|
42
47
|
failureClass: null,
|
|
43
48
|
attemptsJson: "{}",
|
|
44
|
-
|
|
49
|
+
// Rung tag (R1 review, F1): the grounding-inject search-cost row.
|
|
50
|
+
tagsJson: JSON.stringify({ ...effectiveTags, rung: "search" }),
|
|
45
51
|
fingerprintCell: route.fingerprintCell,
|
|
46
52
|
servedVariant,
|
|
47
53
|
repairedBy: null,
|
|
48
54
|
pricingMissing: false,
|
|
49
55
|
cacheKey: null,
|
|
50
56
|
prefixFingerprint: null,
|
|
57
|
+
callId: ladderKey.callId,
|
|
58
|
+
attemptSeq: ladderKey.attemptSeq,
|
|
59
|
+
candidateIndex: ladderKey.candidateIndex,
|
|
51
60
|
});
|
|
52
61
|
}
|
|
62
|
+
/** Schema coaching for the json_mode rung — ported from the production DeepSeek
|
|
63
|
+
* provider's schema-in-prompt guidance (minLength-is-a-FLOOR etc.). Lives here
|
|
64
|
+
* with the other request-shaping helpers to keep run.ts under the LOC cap. */
|
|
65
|
+
function jsonModeCoaching(schema) {
|
|
66
|
+
return ("\n\n---\nOUTPUT FORMAT (STRICT): Respond with a SINGLE valid JSON object and nothing else — " +
|
|
67
|
+
'no markdown fences, no introductory text, no sign-off. Your response MUST start with "{" and ' +
|
|
68
|
+
'end with "}". Sanitize every nested string so embedded quotes/brackets do not break the root ' +
|
|
69
|
+
"JSON escaping. The object MUST conform to this JSON Schema — match key names and types " +
|
|
70
|
+
"EXACTLY, include ALL required fields, and do not add commentary fields. CRITICAL: where the " +
|
|
71
|
+
"schema sets a minLength on a narrative/prose field, that is a FLOOR, not a target — write " +
|
|
72
|
+
"thorough, non-repetitive analysis that comfortably EXCEEDS the minimum (do not pad with " +
|
|
73
|
+
"repetition; add real substance). When unsure how long to make a prose field, write more, " +
|
|
74
|
+
`not less:\n\n${JSON.stringify(schema)}`);
|
|
75
|
+
}
|
|
53
76
|
/** Build the primary-attempt AdapterRequest — adds the grounding hint and the
|
|
54
77
|
* unified tools/toolChoice passthrough (spec §4.4). */
|
|
55
78
|
function buildAdapterRequest(parts) {
|
|
@@ -165,6 +188,11 @@ function emitToolCallResult(record, parts) {
|
|
|
165
188
|
...(result.usage.ttfbMs !== undefined ? { ttfbMs: result.usage.ttfbMs } : {}),
|
|
166
189
|
failure: null,
|
|
167
190
|
pricingMissing: parts.pricingMissing,
|
|
191
|
+
// Rung tag (R1 review, F1): a tool-call turn is a real model call but NOT a
|
|
192
|
+
// schema-validated serve — the recorder cannot tell it from a primary, so it
|
|
193
|
+
// is stamped explicitly. The rollup counts it as a tool-call turn, never a
|
|
194
|
+
// dispatch or a serve (its cost still counts).
|
|
195
|
+
rung: "tool_call",
|
|
168
196
|
});
|
|
169
197
|
return {
|
|
170
198
|
output: null,
|
|
@@ -185,6 +213,7 @@ function emitToolCallResult(record, parts) {
|
|
|
185
213
|
attemptsByClass,
|
|
186
214
|
servedVariant,
|
|
187
215
|
repairedBy: null,
|
|
216
|
+
callId: parts.callId,
|
|
188
217
|
toolCalls: result.toolCalls,
|
|
189
218
|
},
|
|
190
219
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-call telemetry ladder key — routing-console spec §2.1 / §4.1 (R0).
|
|
3
|
+
*
|
|
4
|
+
* One `callId` is minted per `rig.run` / `runStream` / `runBundle` / `runRaw`
|
|
5
|
+
* invocation and shared by EVERY telemetry row that call writes (primary, retry,
|
|
6
|
+
* repair, grounding-search, tool-call). `attemptSeq` is a 1-based counter that
|
|
7
|
+
* is monotonic across all of those rows, and `candidateIndex` is the position of
|
|
8
|
+
* the candidate the row is about within the call's effective declared list.
|
|
9
|
+
*
|
|
10
|
+
* The minter owns the seq counter and the current candidate index so the run
|
|
11
|
+
* loop does not have to thread them through every `recordAttempt` call site
|
|
12
|
+
* (run.ts sits at its LOC cap). The loop calls `setCandidateIndex` as the
|
|
13
|
+
* candidate iterator advances; the recorder (and the search-cost recorder) call
|
|
14
|
+
* `stamp()` once per row. A repair row is stamped DURING the current candidate's
|
|
15
|
+
* turn — before the iterator advances — so it inherits that candidate's index,
|
|
16
|
+
* which IS "the candidate being repaired" per spec §2.1.
|
|
17
|
+
*/
|
|
18
|
+
/** One stamped ladder key — the three fields persisted onto a telemetry row. */
|
|
19
|
+
export interface LadderKey {
|
|
20
|
+
readonly callId: string;
|
|
21
|
+
readonly attemptSeq: number;
|
|
22
|
+
readonly candidateIndex: number | null;
|
|
23
|
+
}
|
|
24
|
+
/** Hands out ladder keys for a single call. Created once per invocation. */
|
|
25
|
+
export interface LadderKeyMinter {
|
|
26
|
+
/** The `call_id` shared by every row of this invocation. */
|
|
27
|
+
readonly callId: string;
|
|
28
|
+
/** Record the candidate the run loop is currently attempting. Every later
|
|
29
|
+
* `stamp()` reads this value; a null clears it (no active candidate). */
|
|
30
|
+
setCandidateIndex(index: number | null): void;
|
|
31
|
+
/** Stamp the next row: bump `attempt_seq` (1-based, monotonic) and read the
|
|
32
|
+
* current `candidate_index`. */
|
|
33
|
+
stamp(): LadderKey;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build a ladder-key minter. `callId` defaults to a fresh uuid; the raw lane and
|
|
37
|
+
* tests may pass one in. Pure but for the uuid — no I/O, no shared state.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createLadderKeyMinter(callId?: string): LadderKeyMinter;
|
|
40
|
+
//# sourceMappingURL=ladder-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ladder-key.d.ts","sourceRoot":"","sources":["../../src/run/ladder-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;6EACyE;IACzE,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9C;oCACgC;IAChC,KAAK,IAAI,SAAS,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,MAAqB,GAAG,eAAe,CAapF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The per-call telemetry ladder key — routing-console spec §2.1 / §4.1 (R0).
|
|
4
|
+
*
|
|
5
|
+
* One `callId` is minted per `rig.run` / `runStream` / `runBundle` / `runRaw`
|
|
6
|
+
* invocation and shared by EVERY telemetry row that call writes (primary, retry,
|
|
7
|
+
* repair, grounding-search, tool-call). `attemptSeq` is a 1-based counter that
|
|
8
|
+
* is monotonic across all of those rows, and `candidateIndex` is the position of
|
|
9
|
+
* the candidate the row is about within the call's effective declared list.
|
|
10
|
+
*
|
|
11
|
+
* The minter owns the seq counter and the current candidate index so the run
|
|
12
|
+
* loop does not have to thread them through every `recordAttempt` call site
|
|
13
|
+
* (run.ts sits at its LOC cap). The loop calls `setCandidateIndex` as the
|
|
14
|
+
* candidate iterator advances; the recorder (and the search-cost recorder) call
|
|
15
|
+
* `stamp()` once per row. A repair row is stamped DURING the current candidate's
|
|
16
|
+
* turn — before the iterator advances — so it inherits that candidate's index,
|
|
17
|
+
* which IS "the candidate being repaired" per spec §2.1.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.createLadderKeyMinter = createLadderKeyMinter;
|
|
21
|
+
const node_crypto_1 = require("node:crypto");
|
|
22
|
+
/**
|
|
23
|
+
* Build a ladder-key minter. `callId` defaults to a fresh uuid; the raw lane and
|
|
24
|
+
* tests may pass one in. Pure but for the uuid — no I/O, no shared state.
|
|
25
|
+
*/
|
|
26
|
+
function createLadderKeyMinter(callId = (0, node_crypto_1.randomUUID)()) {
|
|
27
|
+
let attemptSeq = 0;
|
|
28
|
+
let candidateIndex = null;
|
|
29
|
+
return {
|
|
30
|
+
callId,
|
|
31
|
+
setCandidateIndex(index) {
|
|
32
|
+
candidateIndex = index;
|
|
33
|
+
},
|
|
34
|
+
stamp() {
|
|
35
|
+
attemptSeq += 1;
|
|
36
|
+
return { callId, attemptSeq, candidateIndex };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CE-9 (spec R5) — the raw-lane provider × knob support matrix, the SINGLE
|
|
3
|
+
* source of truth for which knobs each provider honors on `rig.runRaw`.
|
|
4
|
+
*
|
|
5
|
+
* BOTH the runtime guard (`assertRawKnobsSupported`, run/raw.ts) and the docs
|
|
6
|
+
* generator (scripts/build-docs-site.ts) import `RAW_KNOB_SUPPORT` — so the
|
|
7
|
+
* fail-closed behavior a customer hits at runtime and the published matrix they
|
|
8
|
+
* read beforehand can never disagree. The guard's provider sets are no longer
|
|
9
|
+
* inline literals; adding a provider (or widening a knob) is one edit here.
|
|
10
|
+
*
|
|
11
|
+
* The knob discipline this table encodes (spec R1/R2/R4):
|
|
12
|
+
* - grounding: gemini honors native web grounding (grok's Live Search was retired by
|
|
13
|
+
* xAI — 410 on the CE-9 live gate — so grok is fail-closed until CE-9b lands the
|
|
14
|
+
* Responses-API web_search path); every other provider
|
|
15
|
+
* FAILS CLOSED pre-dispatch (guarded).
|
|
16
|
+
* - reasoning: NO per-model allowlist outside gemini (the drift cost the
|
|
17
|
+
* customer flagged). openai/deepinfra/fireworks forward `level` verbatim as
|
|
18
|
+
* `reasoning_effort` and let the provider enforce (a rejection is classified
|
|
19
|
+
* teachably in each adapter); grok forwards a DISCLOSED coarsening
|
|
20
|
+
* (`coarsenGrokReasoningEffort`); gemini stays model-gated (the adapter
|
|
21
|
+
* rejects a non-thinking model); deepseek + anthropic FAIL CLOSED at the
|
|
22
|
+
* guard with a provider-specific fixHint.
|
|
23
|
+
* - responseFormat ("json_object"): the OpenAI-dialect providers + gemini
|
|
24
|
+
* (mime-shaping only) honor it; anthropic FAILS CLOSED (guarded). This is
|
|
25
|
+
* mime-shaping, NOT schema enforcement — F4 stands (no validation/repair,
|
|
26
|
+
* `meta.validated` stays false).
|
|
27
|
+
* - cache + serviceTier are INFORMATIONAL here (never a hard fail): the cache
|
|
28
|
+
* directive is provider-neutral (a resource HANDLE on gemini, a routing HINT
|
|
29
|
+
* on the prompt_cache_key providers) and serviceTier forwards everywhere.
|
|
30
|
+
*/
|
|
31
|
+
import type { ProviderId, ReasoningLevel } from "../types/provider";
|
|
32
|
+
/** How a provider treats a declared `reasoning.level` on the raw lane (R1). */
|
|
33
|
+
export type ReasoningSupportKind =
|
|
34
|
+
/** openai / deepinfra / fireworks — `level` → `reasoning_effort` 1:1,
|
|
35
|
+
* forwarded verbatim; an "unsupported parameter" rejection is classified
|
|
36
|
+
* teachably by the adapter (no per-model allowlist). */
|
|
37
|
+
"forward"
|
|
38
|
+
/** grok — `level` coarsened to xAI's `low|high` via
|
|
39
|
+
* `coarsenGrokReasoningEffort` (a DISCLOSED lossy mapping, never silent). */
|
|
40
|
+
| "coarsen"
|
|
41
|
+
/** gemini — honored only on a thinking-capable model; the adapter rejects a
|
|
42
|
+
* non-thinking model classified (`geminiReasoningUnsupported`). */
|
|
43
|
+
| "model-gated"
|
|
44
|
+
/** deepseek / anthropic — no effort control exists; rejected pre-dispatch by
|
|
45
|
+
* the guard with a provider-specific fixHint. */
|
|
46
|
+
| "fail-closed";
|
|
47
|
+
/** Cache-directive semantics per provider (R3) — documentation only; the raw
|
|
48
|
+
* lane never fails a call over the cache directive. */
|
|
49
|
+
export type CacheSemantics =
|
|
50
|
+
/** gemini — `cache.key` is a `cachedContent` resource HANDLE (customer-owned;
|
|
51
|
+
* ModelRig never creates/refreshes/deletes it). */
|
|
52
|
+
"handle"
|
|
53
|
+
/** openai / grok / deepinfra / fireworks — `cache.key` → `prompt_cache_key`, a
|
|
54
|
+
* routing HINT (openai also maps `ttlSeconds ≥ 86400` → 24h retention). */
|
|
55
|
+
| "hint"
|
|
56
|
+
/** deepseek — automatic prefix cache; the key is not used. */
|
|
57
|
+
| "implicit"
|
|
58
|
+
/** anthropic — prefix caching via `cache_control` markers; the key is not
|
|
59
|
+
* used (out of scope for the raw lane). */
|
|
60
|
+
| "marker";
|
|
61
|
+
/** A guarded knob (grounding / responseFormat): boolean support + the matrix
|
|
62
|
+
* cell text. The guard computes its thrown fixHint from the matrix (the list of
|
|
63
|
+
* supported providers), so widening the matrix updates the error too. */
|
|
64
|
+
export interface KnobFact {
|
|
65
|
+
readonly supported: boolean;
|
|
66
|
+
/** Human teaching string rendered in the docs matrix cell. */
|
|
67
|
+
readonly note: string;
|
|
68
|
+
}
|
|
69
|
+
/** Reasoning support per provider (R1) — `kind` drives the guard (only
|
|
70
|
+
* `fail-closed` throws) and the docs. */
|
|
71
|
+
export interface ReasoningFact {
|
|
72
|
+
readonly kind: ReasoningSupportKind;
|
|
73
|
+
readonly note: string;
|
|
74
|
+
/** Rendered by the guard's thrown error when `kind === "fail-closed"`. */
|
|
75
|
+
readonly fixHint?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface CacheFact {
|
|
78
|
+
readonly semantics: CacheSemantics;
|
|
79
|
+
readonly note: string;
|
|
80
|
+
}
|
|
81
|
+
export interface RawKnobSupport {
|
|
82
|
+
/** GUARDED — a declared `grounding` on an unsupported provider throws. */
|
|
83
|
+
readonly grounding: KnobFact;
|
|
84
|
+
/** GUARDED only when `kind === "fail-closed"` (deepseek/anthropic). */
|
|
85
|
+
readonly reasoning: ReasoningFact;
|
|
86
|
+
/** GUARDED — a declared `responseFormat` on an unsupported provider throws. */
|
|
87
|
+
readonly responseFormat: KnobFact;
|
|
88
|
+
/** INFORMATIONAL — the cache directive never hard-fails on the raw lane. */
|
|
89
|
+
readonly cache: CacheFact;
|
|
90
|
+
/** INFORMATIONAL — serviceTier forwards to every adapter; the served tier
|
|
91
|
+
* reports the truth. */
|
|
92
|
+
readonly serviceTier: KnobFact;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The grok reasoning coarsening (R1): xAI's `reasoning_effort` accepts only
|
|
96
|
+
* `"low" | "high"`, so the four-level neutral vocabulary is coarsened —
|
|
97
|
+
* `minimal, low → "low"`; `medium, high → "high"`. This is a DISCLOSED, lossy
|
|
98
|
+
* mapping (it appears in the matrix note, the grok field's doc comment, and the
|
|
99
|
+
* `grok.test.ts` test), never a silent semantic drop. Kept here — beside the
|
|
100
|
+
* matrix that documents it — as the ONE place the algorithm lives (grok.ts
|
|
101
|
+
* imports it).
|
|
102
|
+
*/
|
|
103
|
+
export declare function coarsenGrokReasoningEffort(level: ReasoningLevel): "low" | "high";
|
|
104
|
+
/** The matrix. Exhaustive over ProviderId — a new provider forces a compile
|
|
105
|
+
* error here (Record<ProviderId, …>), so it can never be silently unlisted. */
|
|
106
|
+
export declare const RAW_KNOB_SUPPORT: Record<ProviderId, RawKnobSupport>;
|
|
107
|
+
/** Pure lookup into the matrix (spec R6, exported from the package root). A
|
|
108
|
+
* customer's multi-provider dispatcher ASKS this instead of duplicating the
|
|
109
|
+
* provider lists. */
|
|
110
|
+
export declare function rawKnobSupport(provider: ProviderId): RawKnobSupport;
|
|
111
|
+
/** Providers that honor a knob, in PROVIDER_IDS order — used by the guard to
|
|
112
|
+
* build a "supported on X, Y only" fixHint from the matrix (so the error text
|
|
113
|
+
* can never drift from the table). */
|
|
114
|
+
export declare function groundingSupportedProviders(): readonly ProviderId[];
|
|
115
|
+
export declare function responseFormatSupportedProviders(): readonly ProviderId[];
|
|
116
|
+
/** Matrix-level notes rendered below the table (spec §3.2 restated in docs). */
|
|
117
|
+
export declare const RAW_KNOB_MATRIX_NOTES: readonly string[];
|
|
118
|
+
/** Render the provider × knob matrix as a Markdown table + notes, FROM the
|
|
119
|
+
* matrix (never a hand-written table — R5). Consumed by the docs generator
|
|
120
|
+
* (scripts/build-docs-site.ts) so the published matrix and the runtime guard
|
|
121
|
+
* derive from the same source. */
|
|
122
|
+
export declare function renderRawKnobMatrix(): string;
|
|
123
|
+
//# sourceMappingURL=raw-support.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-support.d.ts","sourceRoot":"","sources":["../../src/run/raw-support.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB;AAC9B;;wDAEwD;AACtD,SAAS;AACX;6EAC6E;GAC3E,SAAS;AACX;mEACmE;GACjE,aAAa;AACf;iDACiD;GAC/C,aAAa,CAAC;AAElB;uDACuD;AACvD,MAAM,MAAM,cAAc;AACxB;mDACmD;AACjD,QAAQ;AACV;2EAC2E;GACzE,MAAM;AACR,8DAA8D;GAC5D,UAAU;AACZ;2CAC2C;GACzC,QAAQ,CAAC;AAEb;;yEAEyE;AACzE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;yCACyC;AACzC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B;4BACwB;IACxB,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,GAAG,MAAM,CAEhF;AAED;+EAC+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,cAAc,CA+D/D,CAAC;AAEF;;qBAEqB;AACrB,wBAAgB,cAAc,CAAC,QAAQ,EAAE,UAAU,GAAG,cAAc,CAEnE;AAED;;sCAEsC;AACtC,wBAAgB,2BAA2B,IAAI,SAAS,UAAU,EAAE,CAEnE;AAED,wBAAgB,gCAAgC,IAAI,SAAS,UAAU,EAAE,CAExE;AAED,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAKlD,CAAC;AAEF;;;kCAGkC;AAClC,wBAAgB,mBAAmB,IAAI,MAAM,CAQ5C"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CE-9 (spec R5) — the raw-lane provider × knob support matrix, the SINGLE
|
|
4
|
+
* source of truth for which knobs each provider honors on `rig.runRaw`.
|
|
5
|
+
*
|
|
6
|
+
* BOTH the runtime guard (`assertRawKnobsSupported`, run/raw.ts) and the docs
|
|
7
|
+
* generator (scripts/build-docs-site.ts) import `RAW_KNOB_SUPPORT` — so the
|
|
8
|
+
* fail-closed behavior a customer hits at runtime and the published matrix they
|
|
9
|
+
* read beforehand can never disagree. The guard's provider sets are no longer
|
|
10
|
+
* inline literals; adding a provider (or widening a knob) is one edit here.
|
|
11
|
+
*
|
|
12
|
+
* The knob discipline this table encodes (spec R1/R2/R4):
|
|
13
|
+
* - grounding: gemini honors native web grounding (grok's Live Search was retired by
|
|
14
|
+
* xAI — 410 on the CE-9 live gate — so grok is fail-closed until CE-9b lands the
|
|
15
|
+
* Responses-API web_search path); every other provider
|
|
16
|
+
* FAILS CLOSED pre-dispatch (guarded).
|
|
17
|
+
* - reasoning: NO per-model allowlist outside gemini (the drift cost the
|
|
18
|
+
* customer flagged). openai/deepinfra/fireworks forward `level` verbatim as
|
|
19
|
+
* `reasoning_effort` and let the provider enforce (a rejection is classified
|
|
20
|
+
* teachably in each adapter); grok forwards a DISCLOSED coarsening
|
|
21
|
+
* (`coarsenGrokReasoningEffort`); gemini stays model-gated (the adapter
|
|
22
|
+
* rejects a non-thinking model); deepseek + anthropic FAIL CLOSED at the
|
|
23
|
+
* guard with a provider-specific fixHint.
|
|
24
|
+
* - responseFormat ("json_object"): the OpenAI-dialect providers + gemini
|
|
25
|
+
* (mime-shaping only) honor it; anthropic FAILS CLOSED (guarded). This is
|
|
26
|
+
* mime-shaping, NOT schema enforcement — F4 stands (no validation/repair,
|
|
27
|
+
* `meta.validated` stays false).
|
|
28
|
+
* - cache + serviceTier are INFORMATIONAL here (never a hard fail): the cache
|
|
29
|
+
* directive is provider-neutral (a resource HANDLE on gemini, a routing HINT
|
|
30
|
+
* on the prompt_cache_key providers) and serviceTier forwards everywhere.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.RAW_KNOB_MATRIX_NOTES = exports.RAW_KNOB_SUPPORT = void 0;
|
|
34
|
+
exports.coarsenGrokReasoningEffort = coarsenGrokReasoningEffort;
|
|
35
|
+
exports.rawKnobSupport = rawKnobSupport;
|
|
36
|
+
exports.groundingSupportedProviders = groundingSupportedProviders;
|
|
37
|
+
exports.responseFormatSupportedProviders = responseFormatSupportedProviders;
|
|
38
|
+
exports.renderRawKnobMatrix = renderRawKnobMatrix;
|
|
39
|
+
const provider_1 = require("../types/provider");
|
|
40
|
+
/**
|
|
41
|
+
* The grok reasoning coarsening (R1): xAI's `reasoning_effort` accepts only
|
|
42
|
+
* `"low" | "high"`, so the four-level neutral vocabulary is coarsened —
|
|
43
|
+
* `minimal, low → "low"`; `medium, high → "high"`. This is a DISCLOSED, lossy
|
|
44
|
+
* mapping (it appears in the matrix note, the grok field's doc comment, and the
|
|
45
|
+
* `grok.test.ts` test), never a silent semantic drop. Kept here — beside the
|
|
46
|
+
* matrix that documents it — as the ONE place the algorithm lives (grok.ts
|
|
47
|
+
* imports it).
|
|
48
|
+
*/
|
|
49
|
+
function coarsenGrokReasoningEffort(level) {
|
|
50
|
+
return level === "minimal" || level === "low" ? "low" : "high";
|
|
51
|
+
}
|
|
52
|
+
/** The matrix. Exhaustive over ProviderId — a new provider forces a compile
|
|
53
|
+
* error here (Record<ProviderId, …>), so it can never be silently unlisted. */
|
|
54
|
+
exports.RAW_KNOB_SUPPORT = {
|
|
55
|
+
gemini: {
|
|
56
|
+
grounding: { supported: true, note: "native — Google Search (`googleSearch` tool)" },
|
|
57
|
+
reasoning: { kind: "model-gated", note: "`level` → `thinkingConfig.thinkingLevel`, thinking-capable models only (see `GEMINI_THINKING_CAPABLE_MODELS`)" },
|
|
58
|
+
responseFormat: { supported: true, note: "`responseMimeType: application/json` (mime-shaping only — no schema, `validated` stays false)" },
|
|
59
|
+
cache: { semantics: "handle", note: "`cache.key` = a `cachedContent` resource handle (customer-owned lifecycle)" },
|
|
60
|
+
serviceTier: { supported: true, note: "`flex` / `standard` / `priority` honored" },
|
|
61
|
+
},
|
|
62
|
+
openai: {
|
|
63
|
+
grounding: { supported: false, note: "fail-closed" },
|
|
64
|
+
reasoning: { kind: "forward", note: "`level` → `reasoning_effort` (1:1); a non-reasoning model's rejection is classified teachably" },
|
|
65
|
+
responseFormat: { supported: true, note: "`response_format: { type: json_object }`" },
|
|
66
|
+
cache: { semantics: "hint", note: "`cache.key` → `prompt_cache_key`; `ttlSeconds ≥ 86400` → `prompt_cache_retention: 24h`" },
|
|
67
|
+
serviceTier: { supported: true, note: "`flex` (allowlist) / `priority`; flex→standard is a customer-side degrade (§3.2)" },
|
|
68
|
+
},
|
|
69
|
+
grok: {
|
|
70
|
+
grounding: { supported: false, note: "fail-closed — xAI retired Live Search (HTTP 410, 2026-08-21); native `web_search` needs the Responses API, tracked as CE-9b" },
|
|
71
|
+
reasoning: { kind: "coarsen", note: 'coarsened (disclosed): `minimal,low → "low"`; `medium,high → "high"` → `reasoning_effort`' },
|
|
72
|
+
responseFormat: { supported: true, note: "`response_format: { type: json_object }`" },
|
|
73
|
+
cache: { semantics: "hint", note: "`cache.key` → `prompt_cache_key` (routing hint)" },
|
|
74
|
+
serviceTier: { supported: false, note: "no tiers — always `standard`" },
|
|
75
|
+
},
|
|
76
|
+
deepseek: {
|
|
77
|
+
grounding: { supported: false, note: "fail-closed" },
|
|
78
|
+
reasoning: {
|
|
79
|
+
kind: "fail-closed",
|
|
80
|
+
note: "no effort control — reasoning is model selection (`deepseek-reasoner`)",
|
|
81
|
+
fixHint: "DeepSeek has no reasoning-effort control — select the deepseek-reasoner model instead and remove reasoning",
|
|
82
|
+
},
|
|
83
|
+
responseFormat: { supported: true, note: "`response_format: { type: json_object }` — the prompt must contain the word \"JSON\" (caller's responsibility on the raw lane)" },
|
|
84
|
+
cache: { semantics: "implicit", note: "automatic prefix cache — the key is not used" },
|
|
85
|
+
serviceTier: { supported: false, note: "no tiers — always `standard`" },
|
|
86
|
+
},
|
|
87
|
+
anthropic: {
|
|
88
|
+
grounding: { supported: false, note: "fail-closed" },
|
|
89
|
+
reasoning: {
|
|
90
|
+
kind: "fail-closed",
|
|
91
|
+
note: "extended thinking is not wired on the raw lane (future work)",
|
|
92
|
+
fixHint: "Anthropic extended thinking is not wired on the raw lane in v1 — remove reasoning",
|
|
93
|
+
},
|
|
94
|
+
responseFormat: {
|
|
95
|
+
supported: false,
|
|
96
|
+
note: "fail-closed — no json_object equivalent (structured output is a forced tool call)",
|
|
97
|
+
},
|
|
98
|
+
cache: { semantics: "marker", note: "prefix caching via `cache_control` markers — the key is not used" },
|
|
99
|
+
serviceTier: { supported: false, note: "no tiers — always `standard`" },
|
|
100
|
+
},
|
|
101
|
+
deepinfra: {
|
|
102
|
+
grounding: { supported: false, note: "fail-closed" },
|
|
103
|
+
reasoning: { kind: "forward", note: "`level` → `reasoning_effort` (1:1); a non-reasoning model's rejection is classified teachably" },
|
|
104
|
+
responseFormat: { supported: true, note: "`response_format: { type: json_object }`" },
|
|
105
|
+
cache: { semantics: "hint", note: "`cache.key` → `prompt_cache_key` (routing hint)" },
|
|
106
|
+
serviceTier: { supported: false, note: "no tiers — always `standard`" },
|
|
107
|
+
},
|
|
108
|
+
fireworks: {
|
|
109
|
+
grounding: { supported: false, note: "fail-closed" },
|
|
110
|
+
reasoning: { kind: "forward", note: "`level` → `reasoning_effort` (1:1); a non-reasoning model's rejection is classified teachably" },
|
|
111
|
+
responseFormat: { supported: true, note: "`response_format: { type: json_object }`" },
|
|
112
|
+
cache: { semantics: "hint", note: "`cache.key` → `prompt_cache_key` (routing hint; caching is automatic host-side)" },
|
|
113
|
+
serviceTier: { supported: false, note: "no tiers — always `standard`" },
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
/** Pure lookup into the matrix (spec R6, exported from the package root). A
|
|
117
|
+
* customer's multi-provider dispatcher ASKS this instead of duplicating the
|
|
118
|
+
* provider lists. */
|
|
119
|
+
function rawKnobSupport(provider) {
|
|
120
|
+
return exports.RAW_KNOB_SUPPORT[provider];
|
|
121
|
+
}
|
|
122
|
+
/** Providers that honor a knob, in PROVIDER_IDS order — used by the guard to
|
|
123
|
+
* build a "supported on X, Y only" fixHint from the matrix (so the error text
|
|
124
|
+
* can never drift from the table). */
|
|
125
|
+
function groundingSupportedProviders() {
|
|
126
|
+
return provider_1.PROVIDER_IDS.filter((p) => exports.RAW_KNOB_SUPPORT[p].grounding.supported);
|
|
127
|
+
}
|
|
128
|
+
function responseFormatSupportedProviders() {
|
|
129
|
+
return provider_1.PROVIDER_IDS.filter((p) => exports.RAW_KNOB_SUPPORT[p].responseFormat.supported);
|
|
130
|
+
}
|
|
131
|
+
/** Matrix-level notes rendered below the table (spec §3.2 restated in docs). */
|
|
132
|
+
exports.RAW_KNOB_MATRIX_NOTES = [
|
|
133
|
+
"**Fail-closed is discoverable, not a surprise.** A knob a provider cannot honor throws `RigFailureError` `invariant_violation` PRE-DISPATCH (no meter, no provider call, no telemetry row) — read this table before you call, not after.",
|
|
134
|
+
"**reasoning has NO per-model allowlist outside gemini.** openai/deepinfra/fireworks forward `level` verbatim and let the provider enforce; a rejection surfaces as a classified failure that names the fix. grok coarsens (disclosed above). deepseek reasoning is model selection (`deepseek-reasoner`); anthropic extended thinking is unwired.",
|
|
135
|
+
"**responseFormat is mime-shaping, not schema enforcement.** `json_object` forces syntactic JSON only — the raw lane still never validates or repairs, and `meta.validated` stays `false` (F4).",
|
|
136
|
+
"**§3.2 flex degrade is customer-side.** ModelRig does not replicate the gemini direct-path infra-retry wrapper on the raw lane; under `flex` a capacity rejection surfaces classified (`capacity_shed`) for your own `→ standard` retry ladder — a NAMED difference for your migration record, not a silent one.",
|
|
137
|
+
];
|
|
138
|
+
/** Render the provider × knob matrix as a Markdown table + notes, FROM the
|
|
139
|
+
* matrix (never a hand-written table — R5). Consumed by the docs generator
|
|
140
|
+
* (scripts/build-docs-site.ts) so the published matrix and the runtime guard
|
|
141
|
+
* derive from the same source. */
|
|
142
|
+
function renderRawKnobMatrix() {
|
|
143
|
+
const header = "| Provider | grounding | reasoning | responseFormat | cache | serviceTier |";
|
|
144
|
+
const sep = "|---|---|---|---|---|---|";
|
|
145
|
+
const rows = provider_1.PROVIDER_IDS.map((p) => {
|
|
146
|
+
const s = exports.RAW_KNOB_SUPPORT[p];
|
|
147
|
+
return `| \`${p}\` | ${s.grounding.note} | ${s.reasoning.note} | ${s.responseFormat.note} | ${s.cache.note} | ${s.serviceTier.note} |`;
|
|
148
|
+
});
|
|
149
|
+
return [header, sep, ...rows, "", ...exports.RAW_KNOB_MATRIX_NOTES].join("\n");
|
|
150
|
+
}
|
package/dist/run/raw.d.ts
CHANGED
|
@@ -23,8 +23,25 @@
|
|
|
23
23
|
* `AdapterRequest.sampling`) when the caller supplies them; absent, they are
|
|
24
24
|
* still dropped and the dispatch is byte-identical to pre-CE-6. `max_tokens`
|
|
25
25
|
* maps to `maxOutputTokens` (unchanged).
|
|
26
|
+
* - CE-2: the raw lane exposes three more provider knobs — `grounding`
|
|
27
|
+
* (native web grounding), `serviceTier`, and `reasoning` (thinking effort).
|
|
28
|
+
* Each is ADDITIVE: absent ⇒ byte-identical dispatch. A DECLARED directive is
|
|
29
|
+
* never silently dropped — `grounding`/`reasoning` on a provider that cannot
|
|
30
|
+
* honor it are rejected fail-closed PRE-DISPATCH (`assertRawKnobsSupported`),
|
|
31
|
+
* with no meter, no provider call, and no telemetry row. `serviceTier`
|
|
32
|
+
* forwards to every adapter's tier path and `meta.requestedTier` now reports
|
|
33
|
+
* the DECLARED tier (an honesty fix — it previously hardcoded `"standard"`).
|
|
34
|
+
* - CE-9: multi-provider parity. `grounding` now also serves grok (xAI Live
|
|
35
|
+
* Search); `reasoning` generalizes beyond gemini WITHOUT a per-model
|
|
36
|
+
* allowlist — openai/deepinfra/fireworks forward `level` → `reasoning_effort`
|
|
37
|
+
* verbatim (provider enforces, rejection classified teachably), grok coarsens
|
|
38
|
+
* (disclosed), gemini stays model-gated, deepseek/anthropic fail closed; a
|
|
39
|
+
* new `responseFormat: "json_object"` knob mime-shapes on the OpenAI-dialect
|
|
40
|
+
* providers + gemini (anthropic fails closed). The provider×knob support set
|
|
41
|
+
* is ONE table (`run/raw-support.ts`) the guard AND the published docs matrix
|
|
42
|
+
* both read — they can never disagree (R5).
|
|
26
43
|
*/
|
|
27
|
-
import type { AdapterRequest, CandidateRef, ProviderId, ToolChoice, ToolDefinition } from "../types/provider";
|
|
44
|
+
import type { AdapterRequest, CandidateRef, ProviderId, ReasoningParams, ServiceTier, ToolChoice, ToolDefinition } from "../types/provider";
|
|
28
45
|
import type { RunResult, RunTags } from "../types/route";
|
|
29
46
|
import type { RunStreamHandle } from "./stream";
|
|
30
47
|
import type { TelemetryStore } from "../types/telemetry";
|
|
@@ -63,6 +80,39 @@ export interface RawRunInput {
|
|
|
63
80
|
readonly key: string;
|
|
64
81
|
readonly ttlSeconds?: number;
|
|
65
82
|
};
|
|
83
|
+
/** CE-2 F1 — native provider grounding on the raw lane (spec §3 F1). Object
|
|
84
|
+
* form so `"inject"` can join later without reshaping; v1 accepts ONLY
|
|
85
|
+
* `"native"`, which maps to `AdapterRequest.grounding = true`. GEMINI-ONLY in
|
|
86
|
+
* v1: declared on any other provider throws `RigFailureError`
|
|
87
|
+
* `invariant_violation` pre-dispatch (`assertRawKnobsSupported`). Interplay
|
|
88
|
+
* with `cache.key`: no code needed here — the gemini adapter's `cachedContent`
|
|
89
|
+
* path excludes tools (the googleSearch tool is expected to be baked into the
|
|
90
|
+
* customer's cache resource at creation). */
|
|
91
|
+
readonly grounding?: {
|
|
92
|
+
readonly mode: "native";
|
|
93
|
+
};
|
|
94
|
+
/** CE-2 F2 — service tier on the raw lane (spec §3 F2). Forwarded to
|
|
95
|
+
* `AdapterRequest.requestedTier` (default `"standard"`). ModelRig does NOT
|
|
96
|
+
* perform flex→standard degrade on the raw lane — a capacity rejection
|
|
97
|
+
* surfaces CLASSIFIED (`capacity_shed`) and the customer's own ladder retries
|
|
98
|
+
* at `"standard"`. `meta.servedTier`/`meta.requestedTier` report the truth. */
|
|
99
|
+
readonly serviceTier?: ServiceTier;
|
|
100
|
+
/** CE-2 F3 — reasoning/thinking effort on the raw lane (spec §3 F3). Absent ⇒
|
|
101
|
+
* byte-identical (gemini keeps its hardcoded `"high"`). GEMINI-ONLY in v1 (and
|
|
102
|
+
* only on a thinking-capable model): declared on any other provider throws
|
|
103
|
+
* pre-dispatch (`assertRawKnobsSupported`); declared on a non-thinking gemini
|
|
104
|
+
* model is rejected classified by the adapter (`geminiReasoningUnsupported`). */
|
|
105
|
+
readonly reasoning?: ReasoningParams;
|
|
106
|
+
/** CE-9 R4 — syntactic-JSON response shaping on the raw lane. `"json_object"`
|
|
107
|
+
* maps to each provider's json_object / json-mime directive (OpenAI-dialect
|
|
108
|
+
* providers + gemini); ABSENT ⇒ byte-identical (no key added). This is
|
|
109
|
+
* MIME-SHAPING, NOT schema enforcement — F4 stands: no validation, no repair,
|
|
110
|
+
* `meta.validated` stays false. GUARDED: anthropic has no equivalent and is
|
|
111
|
+
* rejected fail-closed pre-dispatch (`assertRawKnobsSupported`). DeepSeek's
|
|
112
|
+
* documented wrinkle — its json_object mode 400s when the literal word "JSON"
|
|
113
|
+
* appears nowhere in the prompt — is the CALLER's prompt responsibility on the
|
|
114
|
+
* raw lane (documented in the R5 matrix, never injected here). */
|
|
115
|
+
readonly responseFormat?: "json_object";
|
|
66
116
|
}
|
|
67
117
|
export interface RawRunDeps {
|
|
68
118
|
readonly telemetry: TelemetryStore;
|
|
@@ -71,6 +121,28 @@ export interface RawRunDeps {
|
|
|
71
121
|
* it never charges the unpriced fallback; a missing price records `$0`. */
|
|
72
122
|
readonly unpricedRateUsdPerMTok?: number;
|
|
73
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* CE-2/CE-9 fail-closed guard (spec §3 F1/F3, CE-9 R1/R2/R4). A DECLARED
|
|
126
|
+
* directive is NEVER silently dropped: a `grounding`/`responseFormat` on a
|
|
127
|
+
* provider that cannot honor it, a `reasoning` on a provider with NO effort
|
|
128
|
+
* control (deepseek/anthropic), or a `grounding.mode` other than the
|
|
129
|
+
* v1-supported `"native"` throws `RigFailureError` `invariant_violation` (the
|
|
130
|
+
* existing TERMINAL class; no new FailureClass member) BEFORE any adapter is
|
|
131
|
+
* built, any provider call is made, or any telemetry row is written.
|
|
132
|
+
*
|
|
133
|
+
* The support facts come from `RAW_KNOB_SUPPORT` (run/raw-support.ts) — the ONE
|
|
134
|
+
* table the published docs matrix also reads, so the guard and the docs can
|
|
135
|
+
* never disagree (R5). What the guard does NOT reject (and why):
|
|
136
|
+
* - reasoning on openai/deepinfra/fireworks is FORWARDED verbatim
|
|
137
|
+
* (`kind: "forward"`) and the provider enforces — a rejection is classified
|
|
138
|
+
* teachably by the adapter (no per-model allowlist, R1).
|
|
139
|
+
* - reasoning on grok is a DISCLOSED coarsening (`kind: "coarsen"`).
|
|
140
|
+
* - reasoning on gemini is model-gated (`kind: "model-gated"`) — the adapter
|
|
141
|
+
* rejects a non-thinking model (`geminiReasoningUnsupported`).
|
|
142
|
+
* Exported so the guard is unit-testable without a network. Idempotent and
|
|
143
|
+
* side-effect-free.
|
|
144
|
+
*/
|
|
145
|
+
export declare function assertRawKnobsSupported(input: RawRunInput): void;
|
|
74
146
|
/** Pure raw-lane request shaping — exported for unit tests (no network). */
|
|
75
147
|
export declare function buildRawRequest(candidate: CandidateRef, input: RawRunInput): AdapterRequest;
|
|
76
148
|
/** Buffered raw dispatch (spec §4.2). Records telemetry, returns the RunResult,
|
package/dist/run/raw.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../src/run/raw.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../src/run/raw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAiBH,OAAO,KAAK,EACV,cAAc,EAGd,YAAY,EAGZ,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAW,SAAS,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAA+B,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEtF;;;sCAGsC;AACtC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;iFAC6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;6EAGyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;;;;;;0BAOsB;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE;;;;;;;iDAO6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IACjD;;;;mFAI+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;;qFAIiF;IACjF,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC;;;;;;;;sEAQkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC;;+EAE2E;IAC3E,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAC1C;AA0CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAiDhE;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,GAAG,cAAc,CAqC3F;AAsKD;wDACwD;AACxD,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CASrF;AAcD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,GAAG,eAAe,CA6ClF"}
|