modelrig 0.11.0 → 0.12.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 +82 -0
- package/dist/adapters/anthropic.d.ts +4 -4
- package/dist/adapters/anthropic.d.ts.map +1 -1
- package/dist/adapters/anthropic.js +8 -1
- package/dist/adapters/deepseek.d.ts +2 -4
- package/dist/adapters/deepseek.d.ts.map +1 -1
- package/dist/adapters/deepseek.js +9 -5
- package/dist/adapters/gemini.d.ts +4 -1
- package/dist/adapters/gemini.d.ts.map +1 -1
- package/dist/adapters/gemini.js +16 -1
- package/dist/adapters/grok.d.ts +2 -4
- package/dist/adapters/grok.d.ts.map +1 -1
- package/dist/adapters/grok.js +8 -4
- package/dist/adapters/history-mapping.d.ts +126 -0
- package/dist/adapters/history-mapping.d.ts.map +1 -0
- package/dist/adapters/history-mapping.js +230 -0
- package/dist/adapters/openai-compat.d.ts +2 -4
- package/dist/adapters/openai-compat.d.ts.map +1 -1
- package/dist/adapters/openai-compat.js +9 -5
- package/dist/adapters/openai.d.ts +2 -4
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +8 -4
- package/dist/adapters/responses-api.d.ts.map +1 -1
- package/dist/adapters/responses-api.js +9 -4
- package/dist/artifacts/artifact.d.ts.map +1 -1
- package/dist/artifacts/artifact.js +79 -0
- package/dist/artifacts/conversation.d.ts +128 -0
- package/dist/artifacts/conversation.d.ts.map +1 -0
- package/dist/artifacts/conversation.js +172 -0
- package/dist/artifacts/index.d.ts +1 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/media.d.ts +46 -0
- package/dist/artifacts/media.d.ts.map +1 -0
- package/dist/artifacts/media.js +88 -0
- package/dist/artifacts/run-context.d.ts +61 -2
- package/dist/artifacts/run-context.d.ts.map +1 -1
- package/dist/artifacts/run-context.js +183 -12
- package/dist/artifacts/scrub.d.ts +3 -0
- package/dist/artifacts/scrub.d.ts.map +1 -1
- package/dist/bakeoff/engine.d.ts.map +1 -1
- package/dist/bakeoff/engine.js +34 -7
- package/dist/bakeoff/eval-cases.d.ts +5 -0
- package/dist/bakeoff/eval-cases.d.ts.map +1 -1
- package/dist/bakeoff/eval-cases.js +10 -1
- package/dist/bakeoff/replay.d.ts +15 -0
- package/dist/bakeoff/replay.d.ts.map +1 -1
- package/dist/bakeoff/replay.js +19 -1
- package/dist/bakeoff/report.d.ts.map +1 -1
- package/dist/bakeoff/report.js +9 -2
- package/dist/bakeoff/turn-replay.d.ts +93 -0
- package/dist/bakeoff/turn-replay.d.ts.map +1 -0
- package/dist/bakeoff/turn-replay.js +150 -0
- package/dist/bakeoff/types.d.ts +12 -0
- package/dist/bakeoff/types.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -3
- package/dist/doctor-preflight.d.ts.map +1 -1
- package/dist/doctor-preflight.js +6 -1
- package/dist/feedback/grade.d.ts +7 -2
- package/dist/feedback/grade.d.ts.map +1 -1
- package/dist/feedback/grade.js +14 -0
- package/dist/feedback/outcome.d.ts +103 -0
- package/dist/feedback/outcome.d.ts.map +1 -0
- package/dist/feedback/outcome.js +175 -0
- package/dist/gateway/history-bridge.d.ts +32 -0
- package/dist/gateway/history-bridge.d.ts.map +1 -0
- package/dist/gateway/history-bridge.js +64 -0
- package/dist/gateway/serve-client.d.ts.map +1 -1
- package/dist/gateway/serve-client.js +6 -0
- package/dist/index.d.ts +44 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -9
- package/dist/init/init-cli.d.ts.map +1 -1
- package/dist/init/init-cli.js +21 -4
- package/dist/init/observe-cli.js +1 -1
- package/dist/init/observe.d.ts +7 -1
- package/dist/init/observe.d.ts.map +1 -1
- package/dist/init/observe.js +74 -22
- package/dist/init/starter.d.ts +36 -0
- package/dist/init/starter.d.ts.map +1 -0
- package/dist/init/starter.js +85 -0
- package/dist/registry/build.d.ts +4 -0
- package/dist/registry/build.d.ts.map +1 -1
- package/dist/registry/generation-models.d.ts +68 -0
- package/dist/registry/generation-models.d.ts.map +1 -0
- package/dist/registry/generation-models.js +168 -0
- package/dist/registry/model-kind.d.ts +34 -0
- package/dist/registry/model-kind.d.ts.map +1 -0
- package/dist/registry/model-kind.js +40 -0
- package/dist/registry/pricing-shape.d.ts +29 -1
- package/dist/registry/pricing-shape.d.ts.map +1 -1
- package/dist/registry/pricing-shape.js +9 -0
- package/dist/registry/pricing.d.ts +26 -0
- package/dist/registry/pricing.d.ts.map +1 -1
- package/dist/registry/pricing.js +29 -0
- package/dist/registry/rows.d.ts.map +1 -1
- package/dist/registry/rows.js +3 -1
- package/dist/registry/unit-pricing.d.ts +32 -0
- package/dist/registry/unit-pricing.d.ts.map +1 -0
- package/dist/registry/unit-pricing.js +62 -0
- package/dist/routes/input-loader.d.ts +38 -0
- package/dist/routes/input-loader.d.ts.map +1 -0
- package/dist/routes/input-loader.js +80 -0
- package/dist/routes/loader.d.ts.map +1 -1
- package/dist/routes/loader.js +3 -0
- package/dist/routes/resolved-bundle.d.ts +2 -0
- package/dist/routes/resolved-bundle.d.ts.map +1 -1
- package/dist/routes/resolved-bundle.js +3 -0
- package/dist/run/cost.d.ts +28 -0
- package/dist/run/cost.d.ts.map +1 -1
- package/dist/run/cost.js +74 -0
- package/dist/run/dispatch.d.ts +4 -1
- package/dist/run/dispatch.d.ts.map +1 -1
- package/dist/run/dispatch.js +3 -0
- package/dist/run/limits.d.ts +88 -0
- package/dist/run/limits.d.ts.map +1 -0
- package/dist/run/limits.js +155 -0
- package/dist/run/messages.d.ts +199 -0
- package/dist/run/messages.d.ts.map +1 -0
- package/dist/run/messages.js +430 -0
- package/dist/run/raw-finalize.d.ts +5 -2
- package/dist/run/raw-finalize.d.ts.map +1 -1
- package/dist/run/raw-finalize.js +8 -5
- package/dist/run/raw-request.d.ts.map +1 -1
- package/dist/run/raw-request.js +2 -1
- package/dist/run/raw.d.ts +10 -4
- package/dist/run/raw.d.ts.map +1 -1
- package/dist/run/raw.js +11 -3
- package/dist/run/rawonly.d.ts +29 -5
- package/dist/run/rawonly.d.ts.map +1 -1
- package/dist/run/rawonly.js +54 -19
- package/dist/run/record-attempt.d.ts.map +1 -1
- package/dist/run/record-attempt.js +16 -6
- package/dist/run/record-call.d.ts +13 -2
- package/dist/run/record-call.d.ts.map +1 -1
- package/dist/run/record-call.js +50 -7
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +12 -8
- package/dist/telemetry/attempt-meta.d.ts +49 -1
- package/dist/telemetry/attempt-meta.d.ts.map +1 -1
- package/dist/telemetry/attempt-meta.js +45 -1
- package/dist/telemetry/exporter.d.ts.map +1 -1
- package/dist/telemetry/exporter.js +2 -1
- package/dist/telemetry/grade-mappers.d.ts +1 -1
- package/dist/telemetry/grade-mappers.d.ts.map +1 -1
- package/dist/telemetry/grade-mappers.js +7 -1
- package/dist/telemetry/grade-task.d.ts +49 -0
- package/dist/telemetry/grade-task.d.ts.map +1 -0
- package/dist/telemetry/grade-task.js +85 -0
- package/dist/telemetry/grades-sql.d.ts +16 -1
- package/dist/telemetry/grades-sql.d.ts.map +1 -1
- package/dist/telemetry/grades-sql.js +64 -4
- package/dist/telemetry/ingest-protocol.d.ts +24 -1
- package/dist/telemetry/ingest-protocol.d.ts.map +1 -1
- package/dist/telemetry/ingest-protocol.js +72 -43
- package/dist/telemetry/otel-content.d.ts +31 -0
- package/dist/telemetry/otel-content.d.ts.map +1 -0
- package/dist/telemetry/otel-content.js +106 -0
- package/dist/telemetry/otel-hierarchy.d.ts +57 -0
- package/dist/telemetry/otel-hierarchy.d.ts.map +1 -0
- package/dist/telemetry/otel-hierarchy.js +155 -0
- package/dist/telemetry/otel-normalize.d.ts +15 -1
- package/dist/telemetry/otel-normalize.d.ts.map +1 -1
- package/dist/telemetry/otel-normalize.js +24 -39
- package/dist/telemetry/sinks.d.ts +4 -1
- package/dist/telemetry/sinks.d.ts.map +1 -1
- package/dist/telemetry/sinks.js +53 -34
- package/dist/telemetry/store-migrations.d.ts.map +1 -1
- package/dist/telemetry/store-migrations.js +8 -0
- package/dist/telemetry/store.d.ts +9 -0
- package/dist/telemetry/store.d.ts.map +1 -1
- package/dist/telemetry/store.js +10 -0
- package/dist/telemetry/uniform-rows.d.ts +43 -0
- package/dist/telemetry/uniform-rows.d.ts.map +1 -0
- package/dist/telemetry/uniform-rows.js +139 -0
- package/dist/types/failures-teaching.d.ts.map +1 -1
- package/dist/types/failures-teaching.js +11 -0
- package/dist/types/failures.d.ts +1 -1
- package/dist/types/failures.d.ts.map +1 -1
- package/dist/types/failures.js +2 -0
- package/dist/types/provider.d.ts +12 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/route.d.ts +13 -0
- package/dist/types/route.d.ts.map +1 -1
- package/dist/types/telemetry.d.ts +14 -1
- package/dist/types/telemetry.d.ts.map +1 -1
- package/docs/agent-skill/SKILL.md +122 -12
- package/docs/how-it-fits.md +4 -4
- package/docs/instrumentation.md +148 -44
- package/docs/llms.txt +143 -13
- package/docs/mcp-oracle.md +15 -4
- package/docs/quickstart.md +129 -16
- package/package.json +4 -2
- package/registry/registry.json +456 -0
- package/templates/creative-approval.json +81 -0
- package/templates/support-conversation.json +82 -0
package/dist/run/rawonly.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* 700-LOC cap — `createRig` remains the ONE construction path (a separate
|
|
18
18
|
* `createRawRig()` factory was considered and REJECTED, spec §2 R1).
|
|
19
19
|
*/
|
|
20
|
-
import type
|
|
20
|
+
import { type RigConfig } from "../config";
|
|
21
21
|
import { type LoadedRoutes } from "../routes/loader";
|
|
22
22
|
import { RigFailureError } from "../types/failures";
|
|
23
23
|
import type { Rig } from "../index";
|
|
@@ -27,7 +27,12 @@ export declare const RAW_ONLY_FIX_HINT = "this rig was constructed runRaw-only (
|
|
|
27
27
|
/** Build the TERMINAL failure a route-dependent surface throws when the rig was
|
|
28
28
|
* constructed runRaw-only. Reuses `invariant_violation` (already TERMINAL + in
|
|
29
29
|
* the teaching table) — no new FailureClass (spec §3 rationale). */
|
|
30
|
-
|
|
30
|
+
/** Why a rig is raw-only: constructed with `routesDir: null`, or fell back
|
|
31
|
+
* because the default routes directory is absent (SURF-1). */
|
|
32
|
+
export type RawOnlyReason = "routesDir-null" | "absent-default";
|
|
33
|
+
/** The fix hint when the absent-default fallback made the rig raw-only. */
|
|
34
|
+
export declare const ABSENT_DEFAULT_FIX_HINT = "create ./modelrig/routes with your route files (`npx modelrig init` drafts them), or set MODELRIG_ROUTES_DIR";
|
|
35
|
+
export declare function rawOnlyRouteFailure(surface: string, reason?: RawOnlyReason): RigFailureError;
|
|
31
36
|
/** Narrow a config's `routesDir` to a string for a route-REQUIRED context (the
|
|
32
37
|
* route-oriented CLI subcommands: bakeoff/watch/swap/init/observe/validate),
|
|
33
38
|
* throwing the teaching failure if the rig was built runRaw-only.
|
|
@@ -35,6 +40,21 @@ export declare function rawOnlyRouteFailure(surface: string): RigFailureError;
|
|
|
35
40
|
* env-built configs — it guards a hand-built `routesDir: null` reaching a
|
|
36
41
|
* route-only command, and satisfies the `string | null` type at those seams. */
|
|
37
42
|
export declare function requireRoutesDir(config: RigConfig, surface: string): string;
|
|
43
|
+
/** The warning createRig prints when it falls back to a raw-only rig because the
|
|
44
|
+
* DEFAULT routes directory does not exist (SURF-1, audit #1). One constant so
|
|
45
|
+
* the docs and the test quote the same words. */
|
|
46
|
+
export declare const ABSENT_DEFAULT_ROUTES_WARNING: string;
|
|
47
|
+
/**
|
|
48
|
+
* The routes directory createRig actually loads (SURF-1 ruling on audit #1):
|
|
49
|
+
* - `null` stays `null` (CE-8 runRaw-only, silent);
|
|
50
|
+
* - the UNCONFIGURED default (loadConfigFromEnv filled in `./modelrig/routes`;
|
|
51
|
+
* no MODELRIG_ROUTES_DIR, no routesDir override, no `extraRoutesDir`) that
|
|
52
|
+
* does not exist on disk → warn once, return `null`, so
|
|
53
|
+
* a customer who only records calls never crashes on import;
|
|
54
|
+
* - anything explicitly configured is returned as-is, and a missing one still
|
|
55
|
+
* throws the teaching RouteConfigError from the loader.
|
|
56
|
+
*/
|
|
57
|
+
export declare function effectiveRoutesDir(config: RigConfig): string | null;
|
|
38
58
|
/** The empty route store for a runRaw-only rig: `list()` is `[]` (so
|
|
39
59
|
* serveability, capture-detection, and the exported route mirror are all no-ops)
|
|
40
60
|
* and `get()` teaches, though no public surface reaches it — every route method
|
|
@@ -48,13 +68,17 @@ export declare function loadRoutesOrReport(config: RigConfig, routesDir: string)
|
|
|
48
68
|
* `routesDir === null` so every one of them throws the teaching failure rather
|
|
49
69
|
* than dereferencing an empty store. Spread LAST over the real methods in
|
|
50
70
|
* `createRig`, so later keys win. */
|
|
51
|
-
type RouteMethods = Pick<Rig, "run" | "runStream" | "runBundle" | "runBundleStream" | "replay" | "bakeoff" | "
|
|
52
|
-
/** The throwing overrides for a runRaw-only rig (spec §2 R1).
|
|
71
|
+
type RouteMethods = Pick<Rig, "run" | "runStream" | "runBundle" | "runBundleStream" | "replay" | "bakeoff" | "verifySwap">;
|
|
72
|
+
/** The throwing overrides for a runRaw-only rig (spec §2 R1).
|
|
73
|
+
* `bakeoffFromEvalCases` is deliberately NOT overridden (SURF-1, audit #12): it
|
|
74
|
+
* reads eval cases from the local store first, so with none promoted (or none
|
|
75
|
+
* rehydratable) it reports honestly without any routes dir; only a case that
|
|
76
|
+
* actually replays reaches `routes.get`, which teaches the same failure. Each names the
|
|
53
77
|
* surface + the route/task the caller asked for, so the terminal error points at
|
|
54
78
|
* exactly the call that needs a `routesDir`. Promise-returning surfaces REJECT
|
|
55
79
|
* (matching the routed lane, where errors surface as rejections); the two
|
|
56
80
|
* streaming surfaces return a handle synchronously, so they throw synchronously
|
|
57
81
|
* — the caller never reaches an event to await. */
|
|
58
|
-
export declare function rawOnlyRouteMethods(): RouteMethods;
|
|
82
|
+
export declare function rawOnlyRouteMethods(reason?: RawOnlyReason): RouteMethods;
|
|
59
83
|
export {};
|
|
60
84
|
//# sourceMappingURL=rawonly.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawonly.d.ts","sourceRoot":"","sources":["../../src/run/rawonly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"rawonly.d.ts","sourceRoot":"","sources":["../../src/run/rawonly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;sEACsE;AACtE,eAAO,MAAM,iBAAiB,uGACwE,CAAC;AAEvG;;oEAEoE;AACpE;8DAC8D;AAC9D,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEhE,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,iHAC4E,CAAC;AAEjH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,aAAgC,GAAG,eAAe,CAS9G;AAsBD;;;;;gFAKgF;AAChF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED;;iDAEiD;AACjD,eAAO,MAAM,6BAA6B,QAIW,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED;;;mDAGmD;AACnD,wBAAgB,eAAe,IAAI,YAAY,CAS9C;AAED;;0EAE0E;AAC1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,CASrF;AAED;;;qCAGqC;AACrC,KAAK,YAAY,GAAG,IAAI,CACtB,GAAG,EACD,KAAK,GACL,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,QAAQ,GACR,SAAS,GACT,YAAY,CACf,CAAC;AAEF;;;;;;;;;mDASmD;AACnD,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,aAAgC,GAAG,YAAY,CAW1F"}
|
package/dist/run/rawonly.js
CHANGED
|
@@ -19,26 +19,30 @@
|
|
|
19
19
|
* `createRawRig()` factory was considered and REJECTED, spec §2 R1).
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.RAW_ONLY_FIX_HINT = void 0;
|
|
22
|
+
exports.ABSENT_DEFAULT_ROUTES_WARNING = exports.ABSENT_DEFAULT_FIX_HINT = exports.RAW_ONLY_FIX_HINT = void 0;
|
|
23
23
|
exports.rawOnlyRouteFailure = rawOnlyRouteFailure;
|
|
24
24
|
exports.requireRoutesDir = requireRoutesDir;
|
|
25
|
+
exports.effectiveRoutesDir = effectiveRoutesDir;
|
|
25
26
|
exports.emptyRouteStore = emptyRouteStore;
|
|
26
27
|
exports.loadRoutesOrReport = loadRoutesOrReport;
|
|
27
28
|
exports.rawOnlyRouteMethods = rawOnlyRouteMethods;
|
|
29
|
+
const node_fs_1 = require("node:fs");
|
|
30
|
+
const config_1 = require("../config");
|
|
28
31
|
const loader_1 = require("../routes/loader");
|
|
29
32
|
const load_error_report_1 = require("../telemetry/load-error-report");
|
|
30
33
|
const failures_1 = require("../types/failures");
|
|
31
34
|
/** The teaching remediation for a route-lane call on a runRaw-only rig (spec §2
|
|
32
35
|
* R1). One constant so the failure and the docs stay in lock-step. */
|
|
33
36
|
exports.RAW_ONLY_FIX_HINT = "this rig was constructed runRaw-only (routesDir: null); give createRig a routesDir to serve routes";
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function rawOnlyRouteFailure(surface) {
|
|
37
|
+
/** The fix hint when the absent-default fallback made the rig raw-only. */
|
|
38
|
+
exports.ABSENT_DEFAULT_FIX_HINT = "create ./modelrig/routes with your route files (`npx modelrig init` drafts them), or set MODELRIG_ROUTES_DIR";
|
|
39
|
+
function rawOnlyRouteFailure(surface, reason = "routesDir-null") {
|
|
38
40
|
return new failures_1.RigFailureError({
|
|
39
41
|
class: "invariant_violation",
|
|
40
|
-
message:
|
|
41
|
-
|
|
42
|
+
message: reason === "absent-default"
|
|
43
|
+
? `${surface} needs routes, but there is no routes directory at ./modelrig/routes, so this rig is raw-only`
|
|
44
|
+
: `${surface} needs routes, but this rig was constructed runRaw-only (routesDir: null)`,
|
|
45
|
+
fixHint: reason === "absent-default" ? exports.ABSENT_DEFAULT_FIX_HINT : exports.RAW_ONLY_FIX_HINT,
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
/** A `RunStreamHandle` that fails the runRaw-only way: `result` rejects and the
|
|
@@ -46,8 +50,8 @@ function rawOnlyRouteFailure(surface) {
|
|
|
46
50
|
* throws synchronously (a stream surface always hands back a handle, errors ride
|
|
47
51
|
* `result`/`events`). A synchronous throw here would break the caller's
|
|
48
52
|
* `const h = rig.runStream(...); await h.result` shape. */
|
|
49
|
-
function rawOnlyStreamHandle(surface) {
|
|
50
|
-
const err = rawOnlyRouteFailure(surface);
|
|
53
|
+
function rawOnlyStreamHandle(surface, reason) {
|
|
54
|
+
const err = rawOnlyRouteFailure(surface, reason);
|
|
51
55
|
const result = Promise.reject(err);
|
|
52
56
|
// Keep the rejection handled so an unconsumed handle never becomes an
|
|
53
57
|
// unhandledRejection; the events iterator surfaces the same error.
|
|
@@ -71,6 +75,33 @@ function requireRoutesDir(config, surface) {
|
|
|
71
75
|
throw rawOnlyRouteFailure(surface);
|
|
72
76
|
return config.routesDir;
|
|
73
77
|
}
|
|
78
|
+
/** The warning createRig prints when it falls back to a raw-only rig because the
|
|
79
|
+
* DEFAULT routes directory does not exist (SURF-1, audit #1). One constant so
|
|
80
|
+
* the docs and the test quote the same words. */
|
|
81
|
+
exports.ABSENT_DEFAULT_ROUTES_WARNING = "[modelrig] no routes directory at ./modelrig/routes, so this rig is raw-only: rig.runRaw, " +
|
|
82
|
+
"rig.runRawStream and rig.recordCall work, and rig.run / rig.runBundle need routes. " +
|
|
83
|
+
"Create routes with `npx modelrig init`, set MODELRIG_ROUTES_DIR, or pass `routesDir: null` " +
|
|
84
|
+
"to say raw-only on purpose and silence this line.";
|
|
85
|
+
/**
|
|
86
|
+
* The routes directory createRig actually loads (SURF-1 ruling on audit #1):
|
|
87
|
+
* - `null` stays `null` (CE-8 runRaw-only, silent);
|
|
88
|
+
* - the UNCONFIGURED default (loadConfigFromEnv filled in `./modelrig/routes`;
|
|
89
|
+
* no MODELRIG_ROUTES_DIR, no routesDir override, no `extraRoutesDir`) that
|
|
90
|
+
* does not exist on disk → warn once, return `null`, so
|
|
91
|
+
* a customer who only records calls never crashes on import;
|
|
92
|
+
* - anything explicitly configured is returned as-is, and a missing one still
|
|
93
|
+
* throws the teaching RouteConfigError from the loader.
|
|
94
|
+
*/
|
|
95
|
+
function effectiveRoutesDir(config) {
|
|
96
|
+
const dir = config.routesDir;
|
|
97
|
+
if (dir === null)
|
|
98
|
+
return null;
|
|
99
|
+
if (config.extraRoutesDir === undefined && (0, config_1.isDefaultRoutesDir)(config) && !(0, node_fs_1.existsSync)(dir)) {
|
|
100
|
+
console.warn(exports.ABSENT_DEFAULT_ROUTES_WARNING);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return dir;
|
|
104
|
+
}
|
|
74
105
|
/** The empty route store for a runRaw-only rig: `list()` is `[]` (so
|
|
75
106
|
* serveability, capture-detection, and the exported route mirror are all no-ops)
|
|
76
107
|
* and `get()` teaches, though no public surface reaches it — every route method
|
|
@@ -100,21 +131,25 @@ function loadRoutesOrReport(config, routesDir) {
|
|
|
100
131
|
throw err;
|
|
101
132
|
}
|
|
102
133
|
}
|
|
103
|
-
/** The throwing overrides for a runRaw-only rig (spec §2 R1).
|
|
134
|
+
/** The throwing overrides for a runRaw-only rig (spec §2 R1).
|
|
135
|
+
* `bakeoffFromEvalCases` is deliberately NOT overridden (SURF-1, audit #12): it
|
|
136
|
+
* reads eval cases from the local store first, so with none promoted (or none
|
|
137
|
+
* rehydratable) it reports honestly without any routes dir; only a case that
|
|
138
|
+
* actually replays reaches `routes.get`, which teaches the same failure. Each names the
|
|
104
139
|
* surface + the route/task the caller asked for, so the terminal error points at
|
|
105
140
|
* exactly the call that needs a `routesDir`. Promise-returning surfaces REJECT
|
|
106
141
|
* (matching the routed lane, where errors surface as rejections); the two
|
|
107
142
|
* streaming surfaces return a handle synchronously, so they throw synchronously
|
|
108
143
|
* — the caller never reaches an event to await. */
|
|
109
|
-
function rawOnlyRouteMethods() {
|
|
144
|
+
function rawOnlyRouteMethods(reason = "routesDir-null") {
|
|
145
|
+
const fail = (surface) => Promise.reject(rawOnlyRouteFailure(surface, reason));
|
|
110
146
|
return {
|
|
111
|
-
run: (route) =>
|
|
112
|
-
runStream: (route) => rawOnlyStreamHandle(`runStream("${route}")
|
|
113
|
-
runBundle: (bundle) =>
|
|
114
|
-
runBundleStream: (bundle) => rawOnlyStreamHandle(`runBundleStream("${bundle.route}")
|
|
115
|
-
replay: (route) =>
|
|
116
|
-
bakeoff: (route) =>
|
|
117
|
-
|
|
118
|
-
verifySwap: (route) => Promise.reject(rawOnlyRouteFailure(`verifySwap("${route}")`)),
|
|
147
|
+
run: (route) => fail(`run("${route}")`),
|
|
148
|
+
runStream: (route) => rawOnlyStreamHandle(`runStream("${route}")`, reason),
|
|
149
|
+
runBundle: (bundle) => fail(`runBundle("${bundle.route}")`),
|
|
150
|
+
runBundleStream: (bundle) => rawOnlyStreamHandle(`runBundleStream("${bundle.route}")`, reason),
|
|
151
|
+
replay: (route) => fail(`replay("${route}")`),
|
|
152
|
+
bakeoff: (route) => fail(`bakeoff("${route}")`),
|
|
153
|
+
verifySwap: (route) => fail(`verifySwap("${route}")`),
|
|
119
154
|
};
|
|
120
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-attempt.d.ts","sourceRoot":"","sources":["../../src/run/record-attempt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAgB,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B;;;gDAG4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;qFAEiF;IACjF,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC;;;wEAGoE;IACpE,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC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OAAO,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;qFAEiF;IACjF,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC;;;wEAGoE;IACpE,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjD;;iEAE6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;kEAK8D;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,OAAO,EACpB,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC7B,aAAa,CAUf;AAED;;yCAEyC;AACzC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAuJlG"}
|
|
@@ -75,12 +75,16 @@ function createRecordAttempt(deps) {
|
|
|
75
75
|
const isPrimary = attempt.repairedBy === undefined;
|
|
76
76
|
const cacheStamp = isPrimary ? (0, cache_stamp_1.cacheStampForCandidate)(route, attempt.candidate) : null;
|
|
77
77
|
// The customer key marks rows whose REQUEST carried the handle. A terminal
|
|
78
|
-
// failure (budget_exhausted / invariant_violation) is
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
78
|
+
// failure (budget_exhausted / invariant_violation) is always a PRE-DISPATCH
|
|
79
|
+
// outcome — the wire never carried the handle — so those rows must not claim
|
|
80
|
+
// a customer key. Terminal classes come from failRun, and from adapter guards
|
|
81
|
+
// that refuse BEFORE building a provider client (gemini's non-thinking-model
|
|
82
|
+
// `reasoning` guard; the ARC-β messages-lane history guards in anthropic.ts /
|
|
83
|
+
// gemini.ts, which the run loop normally pre-empts by skipping incompatible
|
|
84
|
+
// candidates — run/messages.ts). No adapter returns a terminal class after a
|
|
85
|
+
// provider call. (A grounding-search failure is the one non-terminal
|
|
86
|
+
// pre-dispatch path, but a customer cachedContents handle and the inject rung
|
|
87
|
+
// are mutually exclusive, so it is unreachable in practice.)
|
|
84
88
|
const preDispatch = attempt.failure !== null && failures_1.TERMINAL_CLASSES.has(attempt.failure.class);
|
|
85
89
|
const dropped = droppedCacheHandle.has(`${attempt.candidate.provider} ${attempt.candidate.model}`);
|
|
86
90
|
const customer = isPrimary && !preDispatch ? (0, cache_handle_1.customerCacheHandle)(cache, attempt.candidate, dropped) : null;
|
|
@@ -183,6 +187,12 @@ function createRecordAttempt(deps) {
|
|
|
183
187
|
startedAt: row.ts,
|
|
184
188
|
endedAt: new Date().toISOString(),
|
|
185
189
|
failureClass: row.failureClass,
|
|
190
|
+
// ARC-5: cost + requested tool calls feed the run-limit tally (a success
|
|
191
|
+
// with no tool call breaks a repeat streak; a failure leaves it as is).
|
|
192
|
+
costUsd: row.costEstimateUsd,
|
|
193
|
+
...(attempt.toolCalls !== undefined
|
|
194
|
+
? { toolCalls: attempt.toolCalls.map((t) => ({ name: t.function.name, arguments: t.function.arguments })) }
|
|
195
|
+
: attempt.failure === null ? { toolCalls: [] } : {}),
|
|
186
196
|
});
|
|
187
197
|
}
|
|
188
198
|
return row.id;
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* No route/registry/capability-gate dependency beyond the raw lane's own (cost
|
|
26
26
|
* + telemetry + run context) — the raw lane's no-hard-hot-path invariant holds.
|
|
27
27
|
*/
|
|
28
|
+
import { type RecordedUnits } from "../telemetry/attempt-meta";
|
|
28
29
|
import type { FailureClass } from "../types/failures";
|
|
29
30
|
import type { ProviderId, ServiceTier } from "../types/provider";
|
|
30
31
|
import type { RunTags } from "../types/route";
|
|
@@ -50,7 +51,16 @@ export interface RecordCallInput {
|
|
|
50
51
|
* recorded at $0 with `pricingMissing: true`. */
|
|
51
52
|
readonly provider: ProviderId | (string & {});
|
|
52
53
|
readonly model: string;
|
|
54
|
+
/** Token usage. A generation call billed per image/second/character reports
|
|
55
|
+
* `{ tokensIn: 0, tokensOut: 0 }` and its `units`. */
|
|
53
56
|
readonly usage: RecordCallUsage;
|
|
57
|
+
/** ARC-4: the call's non-token units — images generated, seconds of audio or
|
|
58
|
+
* video, characters synthesized, diffusion steps. Non-negative finite
|
|
59
|
+
* numbers; at least one must be > 0 when the token counts are all zero.
|
|
60
|
+
* Recorded on `meta.units` and priced from the registry, then the vendored
|
|
61
|
+
* pricing map, else `pricingMissing` (never from token rates). `steps` is
|
|
62
|
+
* recorded, never priced. */
|
|
63
|
+
readonly units?: RecordedUnits;
|
|
54
64
|
/** The tier that SERVED the call — the row is priced at it (flex is cheaper),
|
|
55
65
|
* exactly as the raw lane prices. Default `"standard"`. */
|
|
56
66
|
readonly servedTier?: ServiceTier;
|
|
@@ -76,8 +86,9 @@ export interface RecordCallResult {
|
|
|
76
86
|
* was rejected and nothing was recorded. */
|
|
77
87
|
readonly inferenceId: string | null;
|
|
78
88
|
readonly callId: string | null;
|
|
79
|
-
/** The
|
|
80
|
-
* row, as on the raw lane). 0 when
|
|
89
|
+
/** The row's list-price cost — tokens plus any priced `units` (a
|
|
90
|
+
* `webSearchCalls` surcharge rides its own row, as on the raw lane). 0 when
|
|
91
|
+
* unpriced or rejected. */
|
|
81
92
|
readonly costEstimateUsd: number;
|
|
82
93
|
readonly pricingMissing: boolean;
|
|
83
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-call.d.ts","sourceRoot":"","sources":["../../src/run/record-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
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AAC,EAAE,WAAW,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5C;8EAC0E;IAC1E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC;sDACkD;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B;gDAC4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;+BAE2B;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAQD,kGAAkG;AAClG,eAAO,MAAM,eAAe,MAAM,CAAC;AAcnC,wDAAwD;AACxD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAMD,+EAA+E;AAC/E,eAAO,MAAM,MAAM,aAAgB,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AA4ID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAarF"}
|
package/dist/run/record-call.js
CHANGED
|
@@ -117,6 +117,9 @@ function validateShape(input) {
|
|
|
117
117
|
fix: `shorten the provider or model id so "provider/model" is at most ${exports.MAX_ROUTE_CHARS} characters`,
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
+
const unitsProblem = validateUnits(i.units, i.usage);
|
|
121
|
+
if (unitsProblem !== null)
|
|
122
|
+
return unitsProblem;
|
|
120
123
|
const u = i.usage;
|
|
121
124
|
if (typeof u !== "object" || u === null || !isCount(u.tokensIn) || !isCount(u.tokensOut)) {
|
|
122
125
|
return {
|
|
@@ -174,6 +177,34 @@ function validateShape(input) {
|
|
|
174
177
|
}
|
|
175
178
|
return null;
|
|
176
179
|
}
|
|
180
|
+
const UNIT_KEY_SET = new Set(attempt_meta_1.UNIT_KEYS);
|
|
181
|
+
/** ARC-4 `units` rules. Every fix string is built from SDK constants only (it
|
|
182
|
+
* doubles as the warning-latch rule id). */
|
|
183
|
+
function validateUnits(units, usage) {
|
|
184
|
+
if (units === undefined)
|
|
185
|
+
return null;
|
|
186
|
+
if (typeof units !== "object" || units === null || Array.isArray(units)) {
|
|
187
|
+
return { problem: "units is not an object", fix: `pass units as { ${attempt_meta_1.UNIT_KEYS.join("?, ")}? } numbers, or omit it` };
|
|
188
|
+
}
|
|
189
|
+
for (const [k, v] of Object.entries(units)) {
|
|
190
|
+
if (!UNIT_KEY_SET.has(k)) {
|
|
191
|
+
return { problem: "units carries an unknown key", fix: `units keys are ${attempt_meta_1.UNIT_KEYS.join(", ")}` };
|
|
192
|
+
}
|
|
193
|
+
if (v !== undefined && !isCount(v)) {
|
|
194
|
+
return { problem: `units.${k} is not a non-negative number`, fix: `omit units.${k} or pass a finite number ≥ 0` };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const u = (typeof usage === "object" && usage !== null ? usage : {});
|
|
198
|
+
const tokensZero = tok(u.tokensIn) === 0 && tok(u.tokensOut) === 0;
|
|
199
|
+
const anyUnit = Object.values(units).some((v) => typeof v === "number" && v > 0);
|
|
200
|
+
if (tokensZero && !anyUnit) {
|
|
201
|
+
return {
|
|
202
|
+
problem: "units are all zero and the call reports no tokens",
|
|
203
|
+
fix: "report what the call produced — e.g. units: { images: 1 } for one generated image, { seconds: 8 } for an 8 s clip, { characters: 1200 } for a TTS request",
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
177
208
|
/** Normalize a caller finish reason: an enum value passes; a provider-native one
|
|
178
209
|
* maps through the adapters' own table; empty ⇒ absent. */
|
|
179
210
|
function finishReasonOf(provider, raw) {
|
|
@@ -212,21 +243,31 @@ function record(deps, input) {
|
|
|
212
243
|
const servedTier = input.servedTier ?? "standard";
|
|
213
244
|
const requestedTier = input.requestedTier ?? servedTier;
|
|
214
245
|
// MUST-3: integers only on the row (rounded + clamped — see toCount).
|
|
246
|
+
const reported = input.usage;
|
|
215
247
|
const usage = {
|
|
216
|
-
tokensIn: tok(
|
|
217
|
-
tokensOut: tok(
|
|
218
|
-
tokensCached: tok(
|
|
219
|
-
...(
|
|
248
|
+
tokensIn: tok(reported.tokensIn),
|
|
249
|
+
tokensOut: tok(reported.tokensOut),
|
|
250
|
+
tokensCached: tok(reported.tokensCached),
|
|
251
|
+
...(reported.tokensCacheWrite !== undefined ? { tokensCacheWrite: tok(reported.tokensCacheWrite) } : {}),
|
|
220
252
|
servedTier,
|
|
221
253
|
...(input.ttfbMs !== undefined ? { ttfbMs: toCount(input.ttfbMs, exports.MAX_MS) } : {}),
|
|
222
254
|
};
|
|
223
255
|
const latencyMs = toCount(input.latencyMs, exports.MAX_MS);
|
|
256
|
+
const units = (0, attempt_meta_1.cleanUnits)(input.units);
|
|
224
257
|
// Priced exactly like the raw lane: list price at the SERVED tier. A provider
|
|
225
258
|
// ModelRig has no price table for is recorded honestly at $0, flagged.
|
|
226
259
|
const unpricedRatePerTok = (deps.unpricedRateUsdPerMTok ?? cost_1.DEFAULT_UNPRICED_RATE_USD_PER_MTOK) / 1000000;
|
|
227
|
-
const
|
|
260
|
+
const tokenCost = known
|
|
228
261
|
? (0, cost_1.attemptCost)(provider, input.model, usage, unpricedRatePerTok)
|
|
229
262
|
: { costUsd: 0, pricingMissing: true };
|
|
263
|
+
// ARC-4: units price separately (registry → pricing map → missing; never from
|
|
264
|
+
// token rates) and ADD to the token cost. With units present, a zero-token
|
|
265
|
+
// call's token price is moot, so only nonzero tokens can flag it missing.
|
|
266
|
+
// No units ⇒ exactly the token path (byte-identical).
|
|
267
|
+
const unitCost = units !== undefined ? (0, cost_1.estimateUnitCostUsd)(provider, input.model, units) : null;
|
|
268
|
+
const tokensReported = usage.tokensIn > 0 || usage.tokensOut > 0;
|
|
269
|
+
const costUsd = tokenCost.costUsd + (unitCost?.costUsd ?? 0);
|
|
270
|
+
const pricingMissing = unitCost === null ? tokenCost.pricingMissing : unitCost.pricingMissing || (tokensReported && tokenCost.pricingMissing);
|
|
230
271
|
// Tags: caller tags + the ambient step/run_id (same order as finalizeRaw), then
|
|
231
272
|
// the SDK-owned markers LAST so a caller value cannot override them.
|
|
232
273
|
const stepTag = step !== null ? { step: step.stepKey } : {};
|
|
@@ -240,7 +281,7 @@ function record(deps, input) {
|
|
|
240
281
|
const adapterMeta = {
|
|
241
282
|
...(finishReason !== undefined ? { finish_reason: finishReason } : {}),
|
|
242
283
|
...(input.providerRequestId !== undefined ? { provider_request_id: input.providerRequestId } : {}),
|
|
243
|
-
...(
|
|
284
|
+
...(reported.reasoningTokens !== undefined ? { reasoning_tokens: tok(reported.reasoningTokens) } : {}),
|
|
244
285
|
};
|
|
245
286
|
// No rendered request and no output text: ModelRig never saw the content, so
|
|
246
287
|
// there is no input/output hash. Cost components only for a priced provider.
|
|
@@ -249,6 +290,8 @@ function record(deps, input) {
|
|
|
249
290
|
provenance: "caller-reported",
|
|
250
291
|
...(known ? { provider: provider, model: input.model } : {}),
|
|
251
292
|
usage,
|
|
293
|
+
...(units !== undefined ? { units } : {}),
|
|
294
|
+
...(unitCost !== null && unitCost.costUsd > 0 ? { unitCostUsd: unitCost.costUsd } : {}),
|
|
252
295
|
});
|
|
253
296
|
const id = (0, node_crypto_1.randomUUID)();
|
|
254
297
|
const callId = (0, node_crypto_1.randomUUID)();
|
|
@@ -268,7 +311,7 @@ function record(deps, input) {
|
|
|
268
311
|
callId,
|
|
269
312
|
meta,
|
|
270
313
|
});
|
|
271
|
-
(0, raw_finalize_1.emitRawStep)(step, input.tags?.step ?? rawModelId, id, failureClass);
|
|
314
|
+
(0, raw_finalize_1.emitRawStep)(step, input.tags?.step ?? rawModelId, id, failureClass, { costUsd }); // ARC-5: accumulates toward run limits (cannot prevent — the next dispatch throws)
|
|
272
315
|
const searchCalls = input.webSearchCalls ?? 0;
|
|
273
316
|
if (searchCalls >= 1) {
|
|
274
317
|
(0, raw_search_cost_1.recordRawSearchCostRow)(deps.telemetry, { provider, rawModelId, tags, callId, searchCalls });
|
package/dist/run/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMrD,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,mBAAmB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAK3D,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAOhF,OAAO,KAAK,EAAE,cAAc,EAAoC,MAAM,aAAa,CAAC;AAU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AAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CA+chG"}
|
package/dist/run/run.js
CHANGED
|
@@ -36,6 +36,7 @@ const quality_gate_1 = require("./quality-gate");
|
|
|
36
36
|
const accept_1 = require("./accept");
|
|
37
37
|
const run_context_1 = require("../artifacts/run-context");
|
|
38
38
|
const capture_write_1 = require("./capture-write");
|
|
39
|
+
const messages_1 = require("./messages");
|
|
39
40
|
/** Phase 1 prompt convention: the bundle's system template carries the whole
|
|
40
41
|
* task (constitution, data, step instructions); the user turn is a terse
|
|
41
42
|
* trigger. Providers treat long system prompts + short user turns well, and
|
|
@@ -65,12 +66,14 @@ async function run(deps, routeName, opts) {
|
|
|
65
66
|
const baseRoute = deps.routes.get(routeName);
|
|
66
67
|
const variant = (0, variant_1.resolveVariant)(baseRoute, opts.variant, mode);
|
|
67
68
|
const servedVariant = variant?.name ?? null;
|
|
68
|
-
const
|
|
69
|
+
const requiredRoute = (0, resolve_1.applyRunRequirements)((0, variant_1.effectiveRoute)(baseRoute, variant), opts.zeroRetention === true);
|
|
70
|
+
const { history, route, skipTag } = (0, messages_1.routedHistory)(requiredRoute, opts); // ARC-β messages lane (run/messages.ts): no history ⇒ same route, byte-identical; R2-2 skips incompatible candidates
|
|
69
71
|
const destination = (0, resolve_destination_1.resolveDestination)(route.destination, opts.destination); // U2 (D-2): RunOptions > route > `direct`. Guard runs below, once the serving provider is resolved (U3).
|
|
70
72
|
// RC-1: inside a run context the SDK stamps `run_id` (episodeKey, else run id)
|
|
71
73
|
// when the caller passed none — the bridge between tags and the run graph.
|
|
72
74
|
const runCtx = (0, run_context_1.getActiveRunContext)();
|
|
73
|
-
|
|
75
|
+
(0, run_context_1.enforceRunLimits)(); // ARC-5: pre-dispatch run-limit check (throws RunLimitExceeded; no-op without limits)
|
|
76
|
+
const runTags = (0, messages_1.withSkipTag)((0, run_context_1.withRunIdTag)(opts.tags, runCtx), skipTag);
|
|
74
77
|
const effectiveTags = route.require.includes("zero_retention") ? { ...runTags, zdr_enforced: "true" } : runTags;
|
|
75
78
|
// Data-hygiene warning (spec WS5): once per process per dimension.
|
|
76
79
|
(0, manifest_1.warnMissingRequiredDimensions)(deps.manifest ?? null, effectiveTags);
|
|
@@ -96,7 +99,7 @@ async function run(deps, routeName, opts) {
|
|
|
96
99
|
// Capture-WRITE gate (settings-plane §1.5, closes gate 5): the control-plane
|
|
97
100
|
// capture flag wins over the YAML flag, the task's scrub setting is honored,
|
|
98
101
|
// and capture OFF is a no-op writer (byte-identical). See ./capture-write.ts.
|
|
99
|
-
const captureAttempt = (0, capture_write_1.buildCaptureWriter)(deps.settings ?? null, deps.captures, route, opts.input);
|
|
102
|
+
const captureAttempt = (0, capture_write_1.buildCaptureWriter)(deps.settings ?? null, deps.captures, route, (0, messages_1.captureInputFor)(opts.input, history, opts));
|
|
100
103
|
const droppedCacheHandle = new Set(); // CE-1 retry-drop (spec §2.2)
|
|
101
104
|
// Per-attempt telemetry recorder (extracted to ./record-attempt.ts — WS-A,
|
|
102
105
|
// to keep run.ts under the LOC cap and shrink the run-loop conflict surface).
|
|
@@ -210,7 +213,8 @@ async function run(deps, routeName, opts) {
|
|
|
210
213
|
// Issue #5 (R1): the user turn — the route's `prompt.user` when declared
|
|
211
214
|
// (rendered with the SAME context, so an untrusted variable is removed from
|
|
212
215
|
// it too and arrives via the spotlight block), else the fixed trigger.
|
|
213
|
-
const userPrompt = userTurnFor(route, renderCtx);
|
|
216
|
+
const userPrompt = history !== undefined ? (0, messages_1.messagesUserTurn)(route, renderCtx) : userTurnFor(route, renderCtx);
|
|
217
|
+
const metaUser = (0, messages_1.userSideForHash)(userPrompt, history); // ARC-β: the envelope hash covers the history
|
|
214
218
|
// Variant augmentation (WS1): appended after capability-conditionals,
|
|
215
219
|
// before json coaching — promptAppend first, then the reasoning scaffold.
|
|
216
220
|
if (variant?.promptAppend !== undefined) {
|
|
@@ -274,7 +278,7 @@ async function run(deps, routeName, opts) {
|
|
|
274
278
|
// pricing snapshot (prompt-length input + full output budget).
|
|
275
279
|
if (guard !== null) {
|
|
276
280
|
// A1: an unpriced model must never precheck at $0 (fail closed).
|
|
277
|
-
const breach = guard.precheck((0, cost_1.dispatchEstimateUsd)(candidate.provider, candidate.model, systemPrompt.length + userPrompt.length, unpricedRatePerTok));
|
|
281
|
+
const breach = guard.precheck((0, cost_1.dispatchEstimateUsd)(candidate.provider, candidate.model, systemPrompt.length + userPrompt.length + (0, messages_1.historyChars)(history), unpricedRatePerTok));
|
|
278
282
|
if (breach !== null) {
|
|
279
283
|
failRun(candidate, breach, 0);
|
|
280
284
|
}
|
|
@@ -308,11 +312,11 @@ async function run(deps, routeName, opts) {
|
|
|
308
312
|
servedVariant,
|
|
309
313
|
pricingMissing,
|
|
310
314
|
callId: ladder.callId, destination,
|
|
311
|
-
metaInputs: (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective:
|
|
315
|
+
metaInputs: (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective: metaUser, outputSchema: route.outputSchema, outputKind: route.outputKind, result, tools: opts.tools }),
|
|
312
316
|
});
|
|
313
317
|
}
|
|
314
318
|
const outcome = (0, validate_1.validateOutput)(route, result.text);
|
|
315
|
-
const metaInputs = (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective:
|
|
319
|
+
const metaInputs = (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective: metaUser, outputSchema: route.outputSchema, outputKind: route.outputKind, result, tools: opts.tools });
|
|
316
320
|
if (outcome.valid) {
|
|
317
321
|
// Q1 quality gate (spec §4.1): a schema-valid output must still clear the
|
|
318
322
|
// builder's bar before it is accepted. Tool-call turns never reach here;
|
|
@@ -432,7 +436,7 @@ async function run(deps, routeName, opts) {
|
|
|
432
436
|
...(result.usage?.ttfbMs !== undefined ? { ttfbMs: result.usage.ttfbMs } : {}),
|
|
433
437
|
failure,
|
|
434
438
|
pricingMissing: failurePricingMissing,
|
|
435
|
-
metaInputs: (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective:
|
|
439
|
+
metaInputs: (0, dispatch_1.attemptMetaInputs)({ systemPrompt, userDirective: metaUser, outputSchema: route.outputSchema, outputKind: route.outputKind, result, tools: opts.tools }),
|
|
436
440
|
});
|
|
437
441
|
if (failures_1.TERMINAL_CLASSES.has(failure.class)) {
|
|
438
442
|
throw new failures_1.RigFailureError(failure);
|
|
@@ -130,16 +130,58 @@ export interface AttemptMetaV1 {
|
|
|
130
130
|
* ModelRig dispatched the attempt and measured it (every other row). Additive
|
|
131
131
|
* — no version bump. */
|
|
132
132
|
readonly provenance?: AttemptProvenance;
|
|
133
|
+
/** ARC-4 (ARC-γ): the call's non-token units (`rig.recordCall({ units })`) —
|
|
134
|
+
* numbers only, keys from {@link UNIT_KEYS}. Additive, no column (zero DDL):
|
|
135
|
+
* rides `inferences.meta.units`. Absent ⇒ a token-only call. */
|
|
136
|
+
readonly units?: RecordedUnits;
|
|
133
137
|
}
|
|
134
138
|
/** OBS-1: the one non-default provenance value (see {@link AttemptMetaV1.provenance}). */
|
|
135
139
|
export type AttemptProvenance = "caller-reported";
|
|
140
|
+
/** ARC-4 (ARC-γ): the non-token units a generation call is billed in — the ONE
|
|
141
|
+
* list. `rig.recordCall({ units })` validates against it, `meta.units` carries
|
|
142
|
+
* exactly these keys, and unit pricing (run/cost.ts) prices from it (the drift
|
|
143
|
+
* test pins all three). `steps` is recorded but never priced: no source we
|
|
144
|
+
* vendor publishes a per-step rate (L5). */
|
|
145
|
+
export declare const UNIT_KEYS: readonly ["images", "seconds", "characters", "steps"];
|
|
146
|
+
export type UnitKey = (typeof UNIT_KEYS)[number];
|
|
147
|
+
/** Non-negative finite counts of a call's non-token units (ARC-4). */
|
|
148
|
+
export type RecordedUnits = {
|
|
149
|
+
readonly [K in UnitKey]?: number;
|
|
150
|
+
};
|
|
151
|
+
/** The units envelope, cleaned: only {@link UNIT_KEYS}, only finite numbers
|
|
152
|
+
* ≥ 0. Returns undefined when nothing survives (absent ⇒ no `units` key). */
|
|
153
|
+
export declare function cleanUnits(raw: unknown): RecordedUnits | undefined;
|
|
154
|
+
/** The `RunMeta.trigger` vocabulary (WI-1 + ARC-1 `conversation`, set by
|
|
155
|
+
* `rig.conversation`). The ONE list — the type and its drift test read it. */
|
|
156
|
+
export declare const RUN_TRIGGERS: readonly ["cron", "api", "manual", "replay", "other", "conversation"];
|
|
157
|
+
export type RunTrigger = (typeof RUN_TRIGGERS)[number];
|
|
158
|
+
/** ARC-5: the `RunMeta.failure_reason` values a run-limit breach writes —
|
|
159
|
+
* `limit:<which>`, one per `RunLimits` field (run/limits.ts). Other reasons are
|
|
160
|
+
* caller-supplied identifiers (R9). */
|
|
161
|
+
export declare const LIMIT_FAILURE_REASONS: readonly ["limit:max_usd", "limit:max_calls", "limit:max_wall_ms", "limit:max_repeat_tool_call"];
|
|
162
|
+
export type LimitFailureReason = (typeof LIMIT_FAILURE_REASONS)[number];
|
|
136
163
|
export interface RunMetaV1 {
|
|
137
164
|
readonly v: 1;
|
|
138
165
|
readonly pipeline_sha?: string;
|
|
139
166
|
readonly config_hash?: string;
|
|
140
|
-
readonly trigger?:
|
|
167
|
+
readonly trigger?: RunTrigger;
|
|
141
168
|
readonly actor?: string;
|
|
142
169
|
readonly input_hash?: string;
|
|
170
|
+
/**
|
|
171
|
+
* R9 (InferWealth report integrity, 2026-10-22): the run's failure reason —
|
|
172
|
+
* an identifier (e.g. a gate code `eps_integrity_failure`), set only when the
|
|
173
|
+
* run ends `failed` via `run.end("failed", { failureReason })` or
|
|
174
|
+
* `run.setFailureReason()`. `run-outcome@v1` labels a failed run with it.
|
|
175
|
+
*/
|
|
176
|
+
readonly failure_reason?: string;
|
|
177
|
+
/** ARC-5: the run's limits as set on run.start / rig.conversation (snake_case
|
|
178
|
+
* numbers). Additive; absent when no limits were set. */
|
|
179
|
+
readonly limits?: {
|
|
180
|
+
readonly max_usd?: number;
|
|
181
|
+
readonly max_calls?: number;
|
|
182
|
+
readonly max_wall_ms?: number;
|
|
183
|
+
readonly max_repeat_tool_call?: number;
|
|
184
|
+
};
|
|
143
185
|
}
|
|
144
186
|
/**
|
|
145
187
|
* The per-attempt content the RECORDER carries from the run/raw loop to the
|
|
@@ -205,6 +247,12 @@ export interface AttemptMetaInputs {
|
|
|
205
247
|
/** OBS-1: stamp `meta.provenance` (`rig.recordCall` rows only). Absent ⇒ no
|
|
206
248
|
* key ⇒ byte-identical to every dispatched row. */
|
|
207
249
|
readonly provenance?: AttemptProvenance;
|
|
250
|
+
/** ARC-4: the call's non-token units, stamped on `meta.units` after
|
|
251
|
+
* {@link cleanUnits}. Absent ⇒ no key ⇒ byte-identical. */
|
|
252
|
+
readonly units?: RecordedUnits;
|
|
253
|
+
/** ARC-4: the unit cost (USD) already priced for this call — added to
|
|
254
|
+
* `meta.cost.other` so the components still sum to the row. Absent ⇒ 0. */
|
|
255
|
+
readonly unitCostUsd?: number;
|
|
208
256
|
}
|
|
209
257
|
/** The classification-rule string test (spec §2, §5 wire backstop): a value is
|
|
210
258
|
* an ENUM / IDENTIFIER / HASH only if it is at most 128 chars AND contains no
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt-meta.d.ts","sourceRoot":"","sources":["../../src/telemetry/attempt-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO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