@tangle-network/agent-eval 0.190.0 → 0.191.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 +46 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-DNV_U6QR.d.ts → agent-profile-DDfIjdyS.d.ts} +3 -3
- package/dist/{agent-profile-DNV_U6QR.d.ts.map → agent-profile-DDfIjdyS.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +11 -11
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +6 -6
- package/dist/{insight-report-CvPkEIcC.d.ts → analyze-runs-CPiKLJFs.d.ts} +73 -3
- package/dist/analyze-runs-CPiKLJFs.d.ts.map +1 -0
- package/dist/{attribute-vocabulary-DLJ6303h.d.ts → attribute-vocabulary-CcXqHODT.d.ts} +23 -12
- package/dist/attribute-vocabulary-CcXqHODT.d.ts.map +1 -0
- package/dist/{benchmark-command-TZlsuAh9.js → benchmark-command-3tZJnD82.js} +12 -11
- package/dist/benchmark-command-3tZJnD82.js.map +1 -0
- package/dist/benchmarks/index.d.ts +3 -3
- package/dist/benchmarks/index.js +3 -3
- package/dist/campaign/index.d.ts +6 -6
- package/dist/campaign/index.js +9 -7
- package/dist/{campaign-_29Qpc9Z.js → campaign-C8iWEF0M.js} +11 -9
- package/dist/{campaign-_29Qpc9Z.js.map → campaign-C8iWEF0M.js.map} +1 -1
- package/dist/{campaign-evidence-CWF8pEIk.js → campaign-evidence-BqjlTM3P.js} +11 -112
- package/dist/campaign-evidence-BqjlTM3P.js.map +1 -0
- package/dist/{chat-client-DbH06Ek6.js → chat-client-B_ItsSBw.js} +2 -2
- package/dist/{chat-client-DbH06Ek6.js.map → chat-client-B_ItsSBw.js.map} +1 -1
- package/dist/{chat-json-call-B0xTEY0I.js → chat-json-call-CXHBvUz8.js} +2 -2
- package/dist/{chat-json-call-B0xTEY0I.js.map → chat-json-call-CXHBvUz8.js.map} +1 -1
- package/dist/claim-V9Zqbq0J.js +54 -0
- package/dist/claim-V9Zqbq0J.js.map +1 -0
- package/dist/cli.js +101 -4
- package/dist/cli.js.map +1 -1
- package/dist/client-wFyDisxi.d.ts +236 -0
- package/dist/client-wFyDisxi.d.ts.map +1 -0
- package/dist/contract/index.d.ts +10 -11
- package/dist/contract/index.js +11 -141
- package/dist/contract/index.js.map +1 -1
- package/dist/{default-registry-B5HrwrPM.d.ts → default-registry-DK_9aVJf.d.ts} +6 -6
- package/dist/{default-registry-B5HrwrPM.d.ts.map → default-registry-DK_9aVJf.d.ts.map} +1 -1
- package/dist/{default-registry-16I-Bxlf.js → default-registry-xMLX160E.js} +3 -3
- package/dist/{default-registry-16I-Bxlf.js.map → default-registry-xMLX160E.js.map} +1 -1
- package/dist/{define-agent-eval-DrGfrCTZ.js → define-agent-eval-BE43YTm4.js} +27 -109
- package/dist/define-agent-eval-BE43YTm4.js.map +1 -0
- package/dist/{define-agent-eval-BWeyIpny.d.ts → define-agent-eval-P28y7mI1.d.ts} +16 -20
- package/dist/define-agent-eval-P28y7mI1.d.ts.map +1 -0
- package/dist/diagnosis/index.d.ts +16 -4
- package/dist/diagnosis/index.d.ts.map +1 -1
- package/dist/diagnosis/index.js +10 -3
- package/dist/diagnosis/index.js.map +1 -1
- package/dist/{dspy-rlm-engine-CTIGomgr.js → dspy-rlm-engine-MfpwoEaj.js} +3 -3
- package/dist/{dspy-rlm-engine-CTIGomgr.js.map → dspy-rlm-engine-MfpwoEaj.js.map} +1 -1
- package/dist/{engine-BkLCnZQX.d.ts → engine-vNiM02Ub.d.ts} +4 -4
- package/dist/{engine-BkLCnZQX.d.ts.map → engine-vNiM02Ub.d.ts.map} +1 -1
- package/dist/{eval-campaign-CMKRjWl0.js → eval-campaign-CwsBn0Gm.js} +2 -2
- package/dist/{eval-campaign-CMKRjWl0.js.map → eval-campaign-CwsBn0Gm.js.map} +1 -1
- package/dist/evaluation.d.ts +2 -2
- package/dist/{exact-types-CfpP2A4Z.d.ts → exact-types-KGxBWH4b.d.ts} +2 -2
- package/dist/{exact-types-CfpP2A4Z.d.ts.map → exact-types-KGxBWH4b.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +1 -1
- package/dist/experiment/index.js +2 -1
- package/dist/experiment/index.js.map +1 -1
- package/dist/{external-optimizer-process-Mc83UoWl.js → external-optimizer-process-xFTliuiK.js} +3 -3
- package/dist/{external-optimizer-process-Mc83UoWl.js.map → external-optimizer-process-xFTliuiK.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-C0dHXH8e.js → external-optimizer-subprocess-B234V9V0.js} +5 -28
- package/dist/external-optimizer-subprocess-B234V9V0.js.map +1 -0
- package/dist/{extract-usage-BrQ8mCLX.js → extract-usage-DFATEuWW.js} +2 -2
- package/dist/{extract-usage-BrQ8mCLX.js.map → extract-usage-DFATEuWW.js.map} +1 -1
- package/dist/{feedback-trajectory-BYjh7NEM.d.ts → feedback-trajectory-BXCGTRkz.d.ts} +3 -3
- package/dist/{feedback-trajectory-BYjh7NEM.d.ts.map → feedback-trajectory-BXCGTRkz.d.ts.map} +1 -1
- package/dist/hosted/index.d.ts +66 -6
- package/dist/hosted/index.d.ts.map +1 -1
- package/dist/hosted/index.js +2 -2
- package/dist/{index-Ci0-EYzc.d.ts → index-CzfnASj_.d.ts} +18 -11
- package/dist/index-CzfnASj_.d.ts.map +1 -0
- package/dist/{index-2e_MTznj.d.ts → index-D-TN7ZRM.d.ts} +6 -6
- package/dist/{index-2e_MTznj.d.ts.map → index-D-TN7ZRM.d.ts.map} +1 -1
- package/dist/{index-BR_R1eBE.d.ts → index-DH-MWH5f.d.ts} +10 -104
- package/dist/index-DH-MWH5f.d.ts.map +1 -0
- package/dist/{index-BqDJ6fUK.d.ts → index-I4UJGRno.d.ts} +74 -2
- package/dist/index-I4UJGRno.d.ts.map +1 -0
- package/dist/index.d.ts +17 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -17
- package/dist/jev.d.ts +2 -2
- package/dist/{journal-CDP0Vhx_.js → journal-c3qY0SDP.js} +246 -5
- package/dist/journal-c3qY0SDP.js.map +1 -0
- package/dist/{kind-factory-ByZeXDqF.js → kind-factory-CdPPHtGZ.js} +10 -26
- package/dist/kind-factory-CdPPHtGZ.js.map +1 -0
- package/dist/ledger-core/index.d.ts +2 -2
- package/dist/ledger-core/index.js +2 -2
- package/dist/{llm-client-BqmRnibA.js → llm-client-KYQBh9C8.js} +2 -2
- package/dist/{llm-client-BqmRnibA.js.map → llm-client-KYQBh9C8.js.map} +1 -1
- package/dist/{llm-judge-bwbgDMP0.js → llm-judge-NJOHM0iA.js} +11 -1428
- package/dist/llm-judge-NJOHM0iA.js.map +1 -0
- package/dist/{matrix-CNypzP-v.d.ts → matrix-CgqdFm5N.d.ts} +2 -2
- package/dist/{matrix-CNypzP-v.d.ts.map → matrix-CgqdFm5N.d.ts.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/{otel-spans-CQY1pNiN.js → otel-spans-DS7t1t1J.js} +8 -19
- package/dist/otel-spans-DS7t1t1J.js.map +1 -0
- package/dist/otlp-attributes-D9ptWaIJ.js +53 -0
- package/dist/otlp-attributes-D9ptWaIJ.js.map +1 -0
- package/dist/pipelines/index.d.ts +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{prime-protocol-Fwvctmhm.d.ts → prime-protocol-T0i6xcAs.d.ts} +2 -2
- package/dist/{prime-protocol-Fwvctmhm.d.ts.map → prime-protocol-T0i6xcAs.d.ts.map} +1 -1
- package/dist/{produced-state-zSaGDC_Q.js → produced-state-CY-L7CqS.js} +4 -4
- package/dist/{produced-state-zSaGDC_Q.js.map → produced-state-CY-L7CqS.js.map} +1 -1
- package/dist/{raw-provider-sink-DIRCZjP_.js → raw-provider-sink-DYh4Bszw.js} +2 -2
- package/dist/{raw-provider-sink-DIRCZjP_.js.map → raw-provider-sink-DYh4Bszw.js.map} +1 -1
- package/dist/{redact-8fX8-uKr.js → redact-B7rt9Zot.js} +117 -6
- package/dist/redact-B7rt9Zot.js.map +1 -0
- package/dist/{redact-Du3WKUOP.d.ts → redact-CopuMxll.d.ts} +2 -2
- package/dist/{redact-Du3WKUOP.d.ts.map → redact-CopuMxll.d.ts.map} +1 -1
- package/dist/{registry-mAQVtuLx.d.ts → registry-Bu3lNole.d.ts} +3 -3
- package/dist/{registry-mAQVtuLx.d.ts.map → registry-Bu3lNole.d.ts.map} +1 -1
- package/dist/rl.d.ts +1 -1
- package/dist/rl.js +2 -2
- package/dist/{run-record-DnMFyg_g.js → run-record-tNnlQIrD.js} +2 -10
- package/dist/{run-record-DnMFyg_g.js.map → run-record-tNnlQIrD.js.map} +1 -1
- package/dist/search-ledger-CQ8Uy4FK.js +1451 -0
- package/dist/search-ledger-CQ8Uy4FK.js.map +1 -0
- package/dist/search-ledger-file-EvdDZRhv.js +27 -0
- package/dist/search-ledger-file-EvdDZRhv.js.map +1 -0
- package/dist/search-shipper-C55V7HE3.js +781 -0
- package/dist/search-shipper-C55V7HE3.js.map +1 -0
- package/dist/{semantic-concept-judge-BY0me-Jq.js → semantic-concept-judge-Bt7bXAAo.js} +6 -6
- package/dist/{semantic-concept-judge-BY0me-Jq.js.map → semantic-concept-judge-Bt7bXAAo.js.map} +1 -1
- package/dist/{server-DnJCDLf8.js → server-DtetGGoA.js} +2 -2
- package/dist/{server-DnJCDLf8.js.map → server-DtetGGoA.js.map} +1 -1
- package/dist/{skillopt-optimization-method-CfnQEjgT.js → skillopt-optimization-method-DwO3TOAV.js} +7 -6
- package/dist/{skillopt-optimization-method-CfnQEjgT.js.map → skillopt-optimization-method-DwO3TOAV.js.map} +1 -1
- package/dist/{spans-D1RftP_w.d.ts → spans-BWtjk_9c.d.ts} +2 -2
- package/dist/{spans-D1RftP_w.d.ts.map → spans-BWtjk_9c.d.ts.map} +1 -1
- package/dist/{statistical-heldout-CLpjYffJ.d.ts → statistical-heldout-BED3wBtX.d.ts} +2 -2
- package/dist/{statistical-heldout-CLpjYffJ.d.ts.map → statistical-heldout-BED3wBtX.d.ts.map} +1 -1
- package/dist/{store-otlp-84DH0OEH.js → store-otlp-BPowgPm6.js} +2 -2
- package/dist/{store-otlp-84DH0OEH.js.map → store-otlp-BPowgPm6.js.map} +1 -1
- package/dist/{store-tool-spans-DSbYpl7f.js → store-tool-spans-BcC_5ef-.js} +6 -6
- package/dist/{store-tool-spans-DSbYpl7f.js.map → store-tool-spans-BcC_5ef-.js.map} +1 -1
- package/dist/{store-tool-spans-BBXs8hDP.d.ts → store-tool-spans-Cfh9XUCm.d.ts} +5 -9
- package/dist/store-tool-spans-Cfh9XUCm.d.ts.map +1 -0
- package/dist/{task-failure-attributes-B34TiMBe.js → task-failure-attributes-CEqEfuIY.js} +17 -9
- package/dist/task-failure-attributes-CEqEfuIY.js.map +1 -0
- package/dist/{tool-groups-W7MJobX_.d.ts → tool-groups-D-mkeN0N.d.ts} +3 -3
- package/dist/tool-groups-D-mkeN0N.d.ts.map +1 -0
- package/dist/trace-attributes.d.ts +1 -1
- package/dist/trace-attributes.js +23 -75
- package/dist/trace-attributes.js.map +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/traces.d.ts +12 -19
- package/dist/traces.d.ts.map +1 -1
- package/dist/traces.js +18 -18
- package/dist/traces.js.map +1 -1
- package/dist/{types-BvmWNjjs.d.ts → types-BmQRs661.d.ts} +2 -2
- package/dist/{types-BvmWNjjs.d.ts.map → types-BmQRs661.d.ts.map} +1 -1
- package/dist/{types-Bay1dh2o.d.ts → types-CeDfCRXp.d.ts} +11 -16
- package/dist/types-CeDfCRXp.d.ts.map +1 -0
- package/dist/{types-Cvqy7asY.d.ts → types-ClK-sHs8.d.ts} +2 -2
- package/dist/{types-Cvqy7asY.d.ts.map → types-ClK-sHs8.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/hosted-ingest-spec.md +92 -133
- package/docs/public-api.md +58 -43
- package/docs/search-ledger.md +17 -0
- package/package.json +2 -2
- package/dist/analyze-runs-BvK4-wSs.d.ts +0 -75
- package/dist/analyze-runs-BvK4-wSs.d.ts.map +0 -1
- package/dist/attribute-vocabulary-DLJ6303h.d.ts.map +0 -1
- package/dist/benchmark-command-TZlsuAh9.js.map +0 -1
- package/dist/campaign-evidence-CWF8pEIk.js.map +0 -1
- package/dist/client-BhEyAdfe.d.ts +0 -202
- package/dist/client-BhEyAdfe.d.ts.map +0 -1
- package/dist/client-QwJpsNYU.js +0 -655
- package/dist/client-QwJpsNYU.js.map +0 -1
- package/dist/define-agent-eval-BWeyIpny.d.ts.map +0 -1
- package/dist/define-agent-eval-DrGfrCTZ.js.map +0 -1
- package/dist/external-optimizer-subprocess-C0dHXH8e.js.map +0 -1
- package/dist/index-BR_R1eBE.d.ts.map +0 -1
- package/dist/index-BqDJ6fUK.d.ts.map +0 -1
- package/dist/index-Ci0-EYzc.d.ts.map +0 -1
- package/dist/insight-report-CvPkEIcC.d.ts.map +0 -1
- package/dist/journal-CDP0Vhx_.js.map +0 -1
- package/dist/kind-factory-ByZeXDqF.js.map +0 -1
- package/dist/llm-judge-bwbgDMP0.js.map +0 -1
- package/dist/otel-spans-CQY1pNiN.js.map +0 -1
- package/dist/otlp-attributes-BpC_blLF.js +0 -83
- package/dist/otlp-attributes-BpC_blLF.js.map +0 -1
- package/dist/redact-8fX8-uKr.js.map +0 -1
- package/dist/store-tool-spans-BBXs8hDP.d.ts.map +0 -1
- package/dist/task-failure-attributes-B34TiMBe.js.map +0 -1
- package/dist/tool-groups-W7MJobX_.d.ts.map +0 -1
- package/dist/types-Bay1dh2o.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-client-DbH06Ek6.js","names":[],"sources":["../src/analyst/chat-client.ts"],"sourcesContent":["/**\n * Provider-neutral chat contract for every model call made by agent-eval.\n *\n * The caller owns model execution. Evaluation code receives canonical requests\n * and results without importing a provider SDK, and agent-eval reads no\n * environment variable to find a provider credential: every transport is bound\n * at the call site.\n *\n * Two ways to bind one. `custom` and `sandbox-sdk` take a `chat` function the\n * caller wrote. `openai-compatible` takes an endpoint and a credential the\n * caller passes as values, and agent-eval issues the HTTP request itself.\n *\n * WHY THE THIRD ONE EXISTS. Every consumer that wanted a plain OpenAI-style\n * endpoint had to hand-write the same fetch loop — retry on 429 and 5xx,\n * `json_schema` degrade, fenced-JSON stripping, and, load-bearing here, the\n * `servedModel` echo that `assertServedModel` and `assertCrossFamilyServed`\n * read. A hand-written transport that omits `servedModel` makes both identity\n * checks read `unreported`, so the two-vendor judge rule they enforce silently\n * measures nothing. Measured motive: agent-eval 0.172.1 exported no such\n * transport, so a two-model judge panel in discovery-lab reached\n * `createChatClient({ transport: 'custom', baseUrl, apiKey })` — fields that\n * exist on no transport option — and every call threw\n * `TypeError: opts.chat is not a function`, which surfaced as\n * `aggregateJudgeVerdicts: all 2 judges failed`.\n *\n * The credential still never comes from agent-eval's environment. `baseUrl`\n * and the bearer are required arguments with no default and no fallback, so a\n * misconfigured caller gets a refusal at construction, never a call to an\n * endpoint it did not name.\n */\n\nimport {\n type LlmCallRequest,\n type LlmCallResult,\n LlmClient,\n type LlmClientOptions,\n} from '../llm-client'\n\n/**\n * Unified chat interface using the package's canonical LLM request and result.\n */\nexport interface ChatClient {\n /** Display name of the bound transport, included in telemetry. */\n readonly transport: ChatTransport\n /** Default model when the caller omits one. */\n readonly defaultModel?: string\n /** Total provider attempts this transport can make for one chat call. */\n readonly maximumAttempts?: number\n\n /** Implementations must enforce `req.maxTokens` when it is present. */\n chat(req: ChatRequest, opts?: ChatCallOpts): Promise<ChatResponse>\n}\n\nexport type ChatTransport =\n | 'sandbox-sdk' // box.streamPrompt() — chat completion via sandbox SDK\n | 'custom' // caller-adapted SDK or transport\n | 'openai-compatible' // caller-named /v1 endpoint, driven by this package\n | 'mock' // test-time injection\n\nexport interface ChatRequest extends Omit<LlmCallRequest, 'model'> {\n /** Optional — falls back to ChatClient.defaultModel. */\n model?: string\n}\n\nexport type ChatResponse = LlmCallResult\n\nexport interface ChatCallOpts {\n /** Cancel the in-flight request. */\n signal?: AbortSignal\n /** Hard USD ceiling for this single call (informational; the underlying transport may not enforce). */\n maxCostUsd?: number\n /** Correlation tag carried into request headers when the transport allows. */\n correlationId?: string\n /** Stable provider idempotency key for retries/redrives of one paid call. */\n idempotencyKey?: string\n}\n\n// ── Factory ─────────────────────────────────────────────────────────\n\nexport type CreateChatClientOpts =\n | SandboxSdkTransportOpts\n | CustomTransportOpts\n | OpenAiCompatibleTransportOpts\n | MockTransportOpts\n\ninterface BaseTransportOpts {\n defaultModel?: string\n /** Total provider attempts. Required for opaque transports used in capped runs. */\n maximumAttempts?: number\n}\n\n/**\n * Sandbox-SDK transport. The caller supplies a canonical chat function for an\n * already-configured Sandbox handle, so agent-eval does not import the SDK.\n */\nexport interface SandboxSdkTransportOpts extends BaseTransportOpts {\n transport: 'sandbox-sdk'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/** Caller-adapted SDK or transport returning the canonical ChatResponse shape. */\nexport interface CustomTransportOpts extends BaseTransportOpts {\n transport: 'custom'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * OpenAI-compatible HTTP transport: the caller names a `/v1` endpoint and\n * hands over a bearer, and this package drives `POST {baseUrl}/chat/completions`.\n *\n * Use this instead of hand-rolling a `custom` transport around `fetch`. The\n * result carries `servedModel` — the model id the provider echoed, verbatim —\n * which is the only field `assertServedModel` and `assertCrossFamilyServed`\n * can read to witness a gateway answering from a different model than the one\n * requested.\n *\n * `baseUrl` ends at the `/v1` prefix; the `/chat/completions` path is this\n * package's to append. A `baseUrl` that already carries the path is a\n * construction error, not a request to a doubled URL.\n *\n * Exactly one credential form is required — `apiKey`, `bearer`, or\n * `authHeader`. There is no environment fallback: agent-eval never goes\n * looking for a key.\n */\nexport interface OpenAiCompatibleTransportOpts\n extends BaseTransportOpts,\n Pick<\n LlmClientOptions,\n | 'assertServedModel'\n | 'customTokenPricing'\n | 'deadlineMs'\n | 'defaultTimeoutMs'\n | 'fetch'\n | 'jsonPayloadMode'\n | 'jsonSchemaTransport'\n | 'provider'\n | 'rawSink'\n | 'signal'\n | 'thinking'\n > {\n transport: 'openai-compatible'\n /** Endpoint ending at the `/v1` prefix. Required — there is no default endpoint. */\n baseUrl: string\n /** Bearer credential. One of `apiKey`, `bearer`, or `authHeader` is required. */\n apiKey?: string\n /** Bearer credential, alternate spelling. */\n bearer?: string\n /** Non-bearer authorization header, for endpoints that want their own scheme. */\n authHeader?: { name: string; value: string }\n}\n\n/**\n * Mock transport for tests. The handler receives the request and returns\n * whatever the test wants. No retries, no JSON-schema degrade.\n */\nexport interface MockTransportOpts extends BaseTransportOpts {\n transport: 'mock'\n handler: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * Build a ChatClient bound to a specific transport. The returned client\n * is safe to share across analysts in a single registry run.\n */\nexport function createChatClient(opts: CreateChatClientOpts): ChatClient {\n switch (opts.transport) {\n case 'sandbox-sdk':\n return {\n transport: 'sandbox-sdk',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'custom':\n return {\n transport: 'custom',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'openai-compatible':\n return openAiCompatibleClient(opts)\n case 'mock':\n return {\n transport: 'mock',\n defaultModel: opts.defaultModel,\n maximumAttempts: 1,\n chat: async (req, callOpts) => opts.handler(resolveModel(req, opts.defaultModel), callOpts),\n }\n }\n}\n\nfunction resolveModel(req: ChatRequest, defaultModel: string | undefined): ChatRequest {\n if (req.model) return req\n if (!defaultModel) {\n throw new Error(\n 'ChatClient.chat: no model on request and no defaultModel on the client. ' +\n 'Either pass req.model or bind defaultModel at createChatClient().',\n )\n }\n return { ...req, model: defaultModel }\n}\n\n/**\n * Build the OpenAI-compatible client, refusing a half-configured one first.\n *\n * Both refusals are construction-time on purpose. A missing credential or a\n * doubled path is a caller mistake that a request would turn into a 401 or a\n * 404 from an endpoint the caller did not intend to reach — the failure then\n * reads as a provider problem instead of a configuration one.\n */\nfunction openAiCompatibleClient(opts: OpenAiCompatibleTransportOpts): ChatClient {\n const baseUrl = opts.baseUrl?.trim().replace(/\\/+$/, '') ?? ''\n if (!baseUrl) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl is required and has no default.\",\n )\n }\n if (/\\/chat\\/completions$/.test(baseUrl)) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl ends at the /v1 prefix; \" +\n `this package appends /chat/completions. Got ${baseUrl}`,\n )\n }\n if (!opts.apiKey?.trim() && !opts.bearer?.trim() && !opts.authHeader) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): one of apiKey, bearer, or authHeader \" +\n 'is required. agent-eval reads no environment variable for a credential.',\n )\n }\n\n const clientOptions: LlmClientOptions = {\n baseUrl,\n ...(opts.apiKey ? { apiKey: opts.apiKey } : {}),\n ...(opts.bearer ? { bearer: opts.bearer } : {}),\n ...(opts.authHeader ? { authHeader: opts.authHeader } : {}),\n ...(opts.maximumAttempts === undefined ? {} : { maximumAttempts: opts.maximumAttempts }),\n ...(opts.assertServedModel === undefined ? {} : { assertServedModel: opts.assertServedModel }),\n ...(opts.customTokenPricing === undefined\n ? {}\n : { customTokenPricing: opts.customTokenPricing }),\n ...(opts.deadlineMs === undefined ? {} : { deadlineMs: opts.deadlineMs }),\n ...(opts.defaultTimeoutMs === undefined ? {} : { defaultTimeoutMs: opts.defaultTimeoutMs }),\n ...(opts.fetch === undefined ? {} : { fetch: opts.fetch }),\n ...(opts.jsonPayloadMode === undefined ? {} : { jsonPayloadMode: opts.jsonPayloadMode }),\n ...(opts.jsonSchemaTransport === undefined\n ? {}\n : { jsonSchemaTransport: opts.jsonSchemaTransport }),\n ...(opts.provider === undefined ? {} : { provider: opts.provider }),\n ...(opts.rawSink === undefined ? {} : { rawSink: opts.rawSink }),\n ...(opts.signal === undefined ? {} : { signal: opts.signal }),\n ...(opts.thinking === undefined ? {} : { thinking: opts.thinking }),\n }\n const client = new LlmClient(clientOptions)\n\n return {\n transport: 'openai-compatible',\n ...(opts.defaultModel ? { defaultModel: opts.defaultModel } : {}),\n maximumAttempts: client.maximumAttempts,\n chat: async (req, callOpts) => {\n const resolved = resolveModel(req, opts.defaultModel)\n return client.call(resolved as LlmCallRequest, {\n ...(callOpts?.signal ? { signal: callOpts.signal } : {}),\n ...(callOpts?.idempotencyKey ? { idempotencyKey: callOpts.idempotencyKey } : {}),\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,SAAgB,iBAAiB,MAAwC;CACvE,QAAQ,KAAK,WAAb;EACE,KAAK,eACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,UACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,qBACH,OAAO,uBAAuB,IAAI;EACpC,KAAK,QACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB;GACjB,MAAM,OAAO,KAAK,aAAa,KAAK,QAAQ,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EAC5F;CACJ;AACF;AAEA,SAAS,aAAa,KAAkB,cAA+C;CACrF,IAAI,IAAI,OAAO,OAAO;C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AAA,IAC7B,CAAC,IACD,EAAE,qBAAqB,KAAK,oBAAoB;EACpD,GAAI,KAAK,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;EACjE,GAAI,KAAK,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,KAAK,QAAQ;EAC9D,GAAI,KAAK,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO;EAC3D,GAAI,KAAK,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,KAAK,SAAS;CAE1B,CAAC;CAE1C,OAAO;EACL,WAAW;EACX,GAAI,KAAK,eAAe,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;EAC/D,iBAAiB,OAAO;EACxB,MAAM,OAAO,KAAK,aAAa;GAC7B,MAAM,WAAW,aAAa,KAAK,KAAK,YAAY;GACpD,OAAO,OAAO,KAAK,UAA4B;IAC7C,GAAI,UAAU,SAAS,EAAE,QAAQ,SAAS,OAAO,IAAI,CAAC;IACtD,GAAI,UAAU,iBAAiB,EAAE,gBAAgB,SAAS,eAAe,IAAI,CAAC;GAChF,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"chat-client-B_ItsSBw.js","names":[],"sources":["../src/analyst/chat-client.ts"],"sourcesContent":["/**\n * Provider-neutral chat contract for every model call made by agent-eval.\n *\n * The caller owns model execution. Evaluation code receives canonical requests\n * and results without importing a provider SDK, and agent-eval reads no\n * environment variable to find a provider credential: every transport is bound\n * at the call site.\n *\n * Two ways to bind one. `custom` and `sandbox-sdk` take a `chat` function the\n * caller wrote. `openai-compatible` takes an endpoint and a credential the\n * caller passes as values, and agent-eval issues the HTTP request itself.\n *\n * WHY THE THIRD ONE EXISTS. Every consumer that wanted a plain OpenAI-style\n * endpoint had to hand-write the same fetch loop — retry on 429 and 5xx,\n * `json_schema` degrade, fenced-JSON stripping, and, load-bearing here, the\n * `servedModel` echo that `assertServedModel` and `assertCrossFamilyServed`\n * read. A hand-written transport that omits `servedModel` makes both identity\n * checks read `unreported`, so the two-vendor judge rule they enforce silently\n * measures nothing. Measured motive: agent-eval 0.172.1 exported no such\n * transport, so a two-model judge panel in discovery-lab reached\n * `createChatClient({ transport: 'custom', baseUrl, apiKey })` — fields that\n * exist on no transport option — and every call threw\n * `TypeError: opts.chat is not a function`, which surfaced as\n * `aggregateJudgeVerdicts: all 2 judges failed`.\n *\n * The credential still never comes from agent-eval's environment. `baseUrl`\n * and the bearer are required arguments with no default and no fallback, so a\n * misconfigured caller gets a refusal at construction, never a call to an\n * endpoint it did not name.\n */\n\nimport {\n type LlmCallRequest,\n type LlmCallResult,\n LlmClient,\n type LlmClientOptions,\n} from '../llm-client'\n\n/**\n * Unified chat interface using the package's canonical LLM request and result.\n */\nexport interface ChatClient {\n /** Display name of the bound transport, included in telemetry. */\n readonly transport: ChatTransport\n /** Default model when the caller omits one. */\n readonly defaultModel?: string\n /** Total provider attempts this transport can make for one chat call. */\n readonly maximumAttempts?: number\n\n /** Implementations must enforce `req.maxTokens` when it is present. */\n chat(req: ChatRequest, opts?: ChatCallOpts): Promise<ChatResponse>\n}\n\nexport type ChatTransport =\n | 'sandbox-sdk' // box.streamPrompt() — chat completion via sandbox SDK\n | 'custom' // caller-adapted SDK or transport\n | 'openai-compatible' // caller-named /v1 endpoint, driven by this package\n | 'mock' // test-time injection\n\nexport interface ChatRequest extends Omit<LlmCallRequest, 'model'> {\n /** Optional — falls back to ChatClient.defaultModel. */\n model?: string\n}\n\nexport type ChatResponse = LlmCallResult\n\nexport interface ChatCallOpts {\n /** Cancel the in-flight request. */\n signal?: AbortSignal\n /** Hard USD ceiling for this single call (informational; the underlying transport may not enforce). */\n maxCostUsd?: number\n /** Correlation tag carried into request headers when the transport allows. */\n correlationId?: string\n /** Stable provider idempotency key for retries/redrives of one paid call. */\n idempotencyKey?: string\n}\n\n// ── Factory ─────────────────────────────────────────────────────────\n\nexport type CreateChatClientOpts =\n | SandboxSdkTransportOpts\n | CustomTransportOpts\n | OpenAiCompatibleTransportOpts\n | MockTransportOpts\n\ninterface BaseTransportOpts {\n defaultModel?: string\n /** Total provider attempts. Required for opaque transports used in capped runs. */\n maximumAttempts?: number\n}\n\n/**\n * Sandbox-SDK transport. The caller supplies a canonical chat function for an\n * already-configured Sandbox handle, so agent-eval does not import the SDK.\n */\nexport interface SandboxSdkTransportOpts extends BaseTransportOpts {\n transport: 'sandbox-sdk'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/** Caller-adapted SDK or transport returning the canonical ChatResponse shape. */\nexport interface CustomTransportOpts extends BaseTransportOpts {\n transport: 'custom'\n chat: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * OpenAI-compatible HTTP transport: the caller names a `/v1` endpoint and\n * hands over a bearer, and this package drives `POST {baseUrl}/chat/completions`.\n *\n * Use this instead of hand-rolling a `custom` transport around `fetch`. The\n * result carries `servedModel` — the model id the provider echoed, verbatim —\n * which is the only field `assertServedModel` and `assertCrossFamilyServed`\n * can read to witness a gateway answering from a different model than the one\n * requested.\n *\n * `baseUrl` ends at the `/v1` prefix; the `/chat/completions` path is this\n * package's to append. A `baseUrl` that already carries the path is a\n * construction error, not a request to a doubled URL.\n *\n * Exactly one credential form is required — `apiKey`, `bearer`, or\n * `authHeader`. There is no environment fallback: agent-eval never goes\n * looking for a key.\n */\nexport interface OpenAiCompatibleTransportOpts\n extends BaseTransportOpts,\n Pick<\n LlmClientOptions,\n | 'assertServedModel'\n | 'customTokenPricing'\n | 'deadlineMs'\n | 'defaultTimeoutMs'\n | 'fetch'\n | 'jsonPayloadMode'\n | 'jsonSchemaTransport'\n | 'provider'\n | 'rawSink'\n | 'signal'\n | 'thinking'\n > {\n transport: 'openai-compatible'\n /** Endpoint ending at the `/v1` prefix. Required — there is no default endpoint. */\n baseUrl: string\n /** Bearer credential. One of `apiKey`, `bearer`, or `authHeader` is required. */\n apiKey?: string\n /** Bearer credential, alternate spelling. */\n bearer?: string\n /** Non-bearer authorization header, for endpoints that want their own scheme. */\n authHeader?: { name: string; value: string }\n}\n\n/**\n * Mock transport for tests. The handler receives the request and returns\n * whatever the test wants. No retries, no JSON-schema degrade.\n */\nexport interface MockTransportOpts extends BaseTransportOpts {\n transport: 'mock'\n handler: (req: ChatRequest, opts?: ChatCallOpts) => Promise<ChatResponse>\n}\n\n/**\n * Build a ChatClient bound to a specific transport. The returned client\n * is safe to share across analysts in a single registry run.\n */\nexport function createChatClient(opts: CreateChatClientOpts): ChatClient {\n switch (opts.transport) {\n case 'sandbox-sdk':\n return {\n transport: 'sandbox-sdk',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'custom':\n return {\n transport: 'custom',\n defaultModel: opts.defaultModel,\n maximumAttempts: opts.maximumAttempts,\n chat: async (req, callOpts) => opts.chat(resolveModel(req, opts.defaultModel), callOpts),\n }\n case 'openai-compatible':\n return openAiCompatibleClient(opts)\n case 'mock':\n return {\n transport: 'mock',\n defaultModel: opts.defaultModel,\n maximumAttempts: 1,\n chat: async (req, callOpts) => opts.handler(resolveModel(req, opts.defaultModel), callOpts),\n }\n }\n}\n\nfunction resolveModel(req: ChatRequest, defaultModel: string | undefined): ChatRequest {\n if (req.model) return req\n if (!defaultModel) {\n throw new Error(\n 'ChatClient.chat: no model on request and no defaultModel on the client. ' +\n 'Either pass req.model or bind defaultModel at createChatClient().',\n )\n }\n return { ...req, model: defaultModel }\n}\n\n/**\n * Build the OpenAI-compatible client, refusing a half-configured one first.\n *\n * Both refusals are construction-time on purpose. A missing credential or a\n * doubled path is a caller mistake that a request would turn into a 401 or a\n * 404 from an endpoint the caller did not intend to reach — the failure then\n * reads as a provider problem instead of a configuration one.\n */\nfunction openAiCompatibleClient(opts: OpenAiCompatibleTransportOpts): ChatClient {\n const baseUrl = opts.baseUrl?.trim().replace(/\\/+$/, '') ?? ''\n if (!baseUrl) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl is required and has no default.\",\n )\n }\n if (/\\/chat\\/completions$/.test(baseUrl)) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): baseUrl ends at the /v1 prefix; \" +\n `this package appends /chat/completions. Got ${baseUrl}`,\n )\n }\n if (!opts.apiKey?.trim() && !opts.bearer?.trim() && !opts.authHeader) {\n throw new Error(\n \"createChatClient({ transport: 'openai-compatible' }): one of apiKey, bearer, or authHeader \" +\n 'is required. agent-eval reads no environment variable for a credential.',\n )\n }\n\n const clientOptions: LlmClientOptions = {\n baseUrl,\n ...(opts.apiKey ? { apiKey: opts.apiKey } : {}),\n ...(opts.bearer ? { bearer: opts.bearer } : {}),\n ...(opts.authHeader ? { authHeader: opts.authHeader } : {}),\n ...(opts.maximumAttempts === undefined ? {} : { maximumAttempts: opts.maximumAttempts }),\n ...(opts.assertServedModel === undefined ? {} : { assertServedModel: opts.assertServedModel }),\n ...(opts.customTokenPricing === undefined\n ? {}\n : { customTokenPricing: opts.customTokenPricing }),\n ...(opts.deadlineMs === undefined ? {} : { deadlineMs: opts.deadlineMs }),\n ...(opts.defaultTimeoutMs === undefined ? {} : { defaultTimeoutMs: opts.defaultTimeoutMs }),\n ...(opts.fetch === undefined ? {} : { fetch: opts.fetch }),\n ...(opts.jsonPayloadMode === undefined ? {} : { jsonPayloadMode: opts.jsonPayloadMode }),\n ...(opts.jsonSchemaTransport === undefined\n ? {}\n : { jsonSchemaTransport: opts.jsonSchemaTransport }),\n ...(opts.provider === undefined ? {} : { provider: opts.provider }),\n ...(opts.rawSink === undefined ? {} : { rawSink: opts.rawSink }),\n ...(opts.signal === undefined ? {} : { signal: opts.signal }),\n ...(opts.thinking === undefined ? {} : { thinking: opts.thinking }),\n }\n const client = new LlmClient(clientOptions)\n\n return {\n transport: 'openai-compatible',\n ...(opts.defaultModel ? { defaultModel: opts.defaultModel } : {}),\n maximumAttempts: client.maximumAttempts,\n chat: async (req, callOpts) => {\n const resolved = resolveModel(req, opts.defaultModel)\n return client.call(resolved as LlmCallRequest, {\n ...(callOpts?.signal ? { signal: callOpts.signal } : {}),\n ...(callOpts?.idempotencyKey ? { idempotencyKey: callOpts.idempotencyKey } : {}),\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,SAAgB,iBAAiB,MAAwC;CACvE,QAAQ,KAAK,WAAb;EACE,KAAK,eACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,UACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB,KAAK;GACtB,MAAM,OAAO,KAAK,aAAa,KAAK,KAAK,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EACzF;EACF,KAAK,qBACH,OAAO,uBAAuB,IAAI;EACpC,KAAK,QACH,OAAO;GACL,WAAW;GACX,cAAc,KAAK;GACnB,iBAAiB;GACjB,MAAM,OAAO,KAAK,aAAa,KAAK,QAAQ,aAAa,KAAK,KAAK,YAAY,GAAG,QAAQ;EAC5F;CACJ;AACF;AAEA,SAAS,aAAa,KAAkB,cAA+C;CACrF,IAAI,IAAI,OAAO,OAAO;CACtB,IAAI,CAAC,cACH,MAAM,IAAI,MACR,2IAEF;CAEF,OAAO;EAAE,GAAG;EAAK,OAAO;CAAa;AACvC;;;;;;;;;AAUA,SAAS,uBAAuB,MAAiD;CAC/E,MAAM,UAAU,KAAK,SAAS,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE,KAAK;CAC5D,IAAI,CAAC,SACH,MAAM,IAAI,MACR,+FACF;CAEF,IAAI,uBAAuB,KAAK,OAAO,GACrC,MAAM,IAAI,MACR,qIACiD,SACnD;CAEF,IAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,CA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AO;EACL,WAAW;EACX,GAAI,KAAK,eAAe,EAAE,cAAc,KAAK,aAAa,IAAI,CAAC;EAC/D,iBAAiB,OAAO;EACxB,MAAM,OAAO,KAAK,aAAa;GAC7B,MAAM,WAAW,aAAa,KAAK,KAAK,YAAY;GACpD,OAAO,OAAO,KAAK,UAA4B;IAC7C,GAAI,UAAU,SAAS,EAAE,QAAQ,SAAS,OAAO,IAAI,CAAC;IACtD,GAAI,UAAU,iBAAiB,EAAE,gBAAgB,SAAS,eAAe,IAAI,CAAC;GAChF,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as extractJsonPayload, o as costReceiptFromLlm, s as costReceiptFromLlmError, u as maximumChargeForLlmRequest } from "./llm-client-
|
|
1
|
+
import { c as extractJsonPayload, o as costReceiptFromLlm, s as costReceiptFromLlmError, u as maximumChargeForLlmRequest } from "./llm-client-KYQBh9C8.js";
|
|
2
2
|
//#region src/chat-json-call.ts
|
|
3
3
|
/** Parse a JSON answer out of a model response. The transport may fence it. */
|
|
4
4
|
function parseJsonAnswer(response, actor) {
|
|
@@ -60,4 +60,4 @@ async function paidJsonChat(input) {
|
|
|
60
60
|
//#endregion
|
|
61
61
|
export { paidJsonChat as n, paidChat as t };
|
|
62
62
|
|
|
63
|
-
//# sourceMappingURL=chat-json-call-
|
|
63
|
+
//# sourceMappingURL=chat-json-call-CXHBvUz8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-json-call-
|
|
1
|
+
{"version":3,"file":"chat-json-call-CXHBvUz8.js","names":[],"sources":["../src/chat-json-call.ts"],"sourcesContent":["/**\n * One paid model call through a caller-owned `ChatClient`, metered by the\n * cost ledger.\n *\n * agent-eval executes no paid model: the transport is supplied by the caller\n * and the credential never enters this package. What stays here is the\n * accounting around the call — the priced maximum reserved before it runs, the\n * stable call id forwarded as the provider idempotency key, the receipt\n * settled from the response, and an honest unknown-usage receipt when the\n * transport failed.\n *\n * The judges, the wire judge endpoint, and the in-process trace-analysis\n * engine all make the same call in the same order; this is the one copy of\n * that sequence. `paidChat` is the sequence; `paidJsonChat` adds the JSON\n * answer parse that a structured caller needs.\n */\n\nimport type { ChatClient, ChatResponse } from './analyst/chat-client'\nimport type { CostChannel, CostLedgerHandle, CostReceipt, CustomTokenPricing } from './cost-ledger'\nimport {\n costReceiptFromLlm,\n costReceiptFromLlmError,\n extractJsonPayload,\n type LlmCallRequest,\n maximumChargeForLlmRequest,\n} from './llm-client'\n\nexport interface PaidChatInput {\n /** Caller-owned transport. One `chat()` call. */\n chat: ChatClient\n /** The exact canonical request, including its JSON-mode or schema fields. */\n request: LlmCallRequest\n ledger: CostLedgerHandle\n channel: CostChannel\n phase: string\n actor: string\n tags?: Record<string, string>\n signal?: AbortSignal\n /** Endpoint rates used when the transport reports no billed amount. */\n pricing?: CustomTokenPricing\n}\n\nexport type PaidJsonChatInput = PaidChatInput\n\nexport type PaidChatResult =\n | { succeeded: true; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\nexport type PaidJsonChatResult<T> =\n | { succeeded: true; value: T; response: ChatResponse; receipt: CostReceipt }\n | { succeeded: false; error: Error; receipt?: CostReceipt }\n\n/** Parse a JSON answer out of a model response. The transport may fence it. */\nfunction parseJsonAnswer<T>(response: ChatResponse, actor: string): T {\n try {\n return JSON.parse(extractJsonPayload(response.content)) as T\n } catch (error) {\n throw new Error(\n `${actor}: model answer was not JSON — ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n\n/** Reserve, execute, and settle one caller-owned chat call. */\nexport async function paidChat(input: PaidChatInput): Promise<PaidChatResult> {\n const paid = await input.ledger.runPaidCall({\n channel: input.channel,\n phase: input.phase,\n actor: input.actor,\n model: input.request.model,\n ...(input.tags && Object.keys(input.tags).length > 0 ? { tags: input.tags } : {}),\n maximumCharge: maximumChargeForLlmRequest(input.request, {\n ...(input.chat.maximumAttempts === undefined\n ? {}\n : { maximumAttempts: input.chat.maximumAttempts }),\n ...(input.pricing ? { customTokenPricing: input.pricing } : {}),\n }),\n ...(input.signal ? { signal: input.signal } : {}),\n execute: (signal, callId) => input.chat.chat(input.request, { signal, idempotencyKey: callId }),\n receipt: (response) => costReceiptFromLlm(response, input.pricing),\n receiptFromError: (error) => costReceiptFromLlmError(error, input.pricing),\n })\n if (!paid.succeeded) {\n return {\n succeeded: false,\n error: paid.error,\n ...(paid.receipt ? { receipt: paid.receipt } : {}),\n }\n }\n return { succeeded: true, response: paid.value, receipt: paid.receipt }\n}\n\nexport async function paidJsonChat<T>(input: PaidJsonChatInput): Promise<PaidJsonChatResult<T>> {\n const paid = await paidChat(input)\n if (!paid.succeeded) return paid\n // The call completed and was billed. A malformed answer is a contract\n // failure AFTER the money was spent, so it keeps the settled receipt instead\n // of reporting the spend as unknown.\n try {\n return {\n succeeded: true,\n value: parseJsonAnswer<T>(paid.response, input.actor),\n response: paid.response,\n receipt: paid.receipt,\n }\n } catch (error) {\n return {\n succeeded: false,\n error: error instanceof Error ? error : new Error(String(error)),\n receipt: paid.receipt,\n }\n }\n}\n"],"mappings":";;;AAqDA,SAAS,gBAAmB,UAAwB,OAAkB;CACpE,IAAI;EACF,OAAO,KAAK,MAAM,mBAAmB,SAAS,OAAO,CAAC;CACxD,SAAS,OAAO;EACd,MAAM,IAAI,MACR,GAAG,MAAM,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAChG;CACF;AACF;;AAGA,eAAsB,SAAS,OAA+C;CAC5E,MAAM,OAAO,MAAM,MAAM,OAAO,YAAY;EAC1C,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM,QAAQ;EACrB,GAAI,MAAM,QAAQ,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;EAC/E,eAAe,2BAA2B,MAAM,SAAS;GACvD,GAAI,MAAM,KAAK,oBAAoB,KAAA,IAC/B,CAAC,IACD,EAAE,iBAAiB,MAAM,KAAK,gBAAgB;GAClD,GAAI,MAAM,UAAU,EAAE,oBAAoB,MAAM,QAAQ,IAAI,CAAC;EAC/D,CAAC;EACD,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;EAC/C,UAAU,QAAQ,WAAW,MAAM,KAAK,KAAK,MAAM,SAAS;GAAE;GAAQ,gBAAgB;EAAO,CAAC;EAC9F,UAAU,aAAa,mBAAmB,UAAU,MAAM,OAAO;EACjE,mBAAmB,UAAU,wBAAwB,OAAO,MAAM,OAAO;CAC3E,CAAC;CACD,IAAI,CAAC,KAAK,WACR,OAAO;EACL,WAAW;EACX,OAAO,KAAK;EACZ,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;CAClD;CAEF,OAAO;EAAE,WAAW;EAAM,UAAU,KAAK;EAAO,SAAS,KAAK;CAAQ;AACxE;AAEA,eAAsB,aAAgB,OAA0D;CAC9F,MAAM,OAAO,MAAM,SAAS,KAAK;CACjC,IAAI,CAAC,KAAK,WAAW,OAAO;CAI5B,IAAI;EACF,OAAO;GACL,WAAW;GACX,OAAO,gBAAmB,KAAK,UAAU,MAAM,KAAK;GACpD,UAAU,KAAK;GACf,SAAS,KAAK;EAChB;CACF,SAAS,OAAO;EACd,OAAO;GACL,WAAW;GACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GAC/D,SAAS,KAAK;EAChB;CACF;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { s as ValidationError } from "./errors-Dngq5h35.js";
|
|
2
|
+
import { i as compareCodeUnits } from "./canonical-BsZVgBhW.js";
|
|
3
|
+
import { g as readField } from "./ast-CP9ae9B0.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/experiment/claim.ts
|
|
6
|
+
const nonEmpty = z.string().min(1).refine((value) => value.trim() === value);
|
|
7
|
+
/** The claim's schema, shared by every record that binds a claim. */
|
|
8
|
+
const evaluationClaimSchema = z.object({
|
|
9
|
+
use: z.enum([
|
|
10
|
+
"development",
|
|
11
|
+
"comparison",
|
|
12
|
+
"certification"
|
|
13
|
+
]),
|
|
14
|
+
population: z.object({
|
|
15
|
+
id: nonEmpty,
|
|
16
|
+
description: nonEmpty
|
|
17
|
+
}).strict(),
|
|
18
|
+
samplingFrame: nonEmpty,
|
|
19
|
+
independentUnit: nonEmpty,
|
|
20
|
+
generalization: z.enum(["fixed-roster", "new-units"]),
|
|
21
|
+
minimumEffect: z.number().finite().positive().optional()
|
|
22
|
+
}).strict();
|
|
23
|
+
/** Validate a claim before binding it to a sealed experiment or final evidence. */
|
|
24
|
+
function defineEvaluationClaim(input) {
|
|
25
|
+
const parsed = evaluationClaimSchema.safeParse(input);
|
|
26
|
+
if (!parsed.success) throw new ValidationError(`invalid evaluation claim: ${parsed.error.message}`);
|
|
27
|
+
return Object.freeze({
|
|
28
|
+
...parsed.data,
|
|
29
|
+
population: Object.freeze(parsed.data.population)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Repetitions retain their denominator without becoming additional independent units. */
|
|
33
|
+
function summarizeEvaluationUnits(claim, rows) {
|
|
34
|
+
const validated = defineEvaluationClaim(claim);
|
|
35
|
+
const counts = /* @__PURE__ */ new Map();
|
|
36
|
+
for (const [index, row] of rows.entries()) {
|
|
37
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) throw new ValidationError(`evaluation claim: row ${index} must be an object`);
|
|
38
|
+
const value = readField(row, validated.independentUnit);
|
|
39
|
+
if (typeof value !== "string" || !value.trim() || value.trim() !== value) throw new ValidationError(`evaluation claim: row ${index} needs a nonempty string at '${validated.independentUnit}'`);
|
|
40
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
observations: rows.length,
|
|
44
|
+
independentUnits: counts.size,
|
|
45
|
+
units: [...counts].sort(([left], [right]) => compareCodeUnits(left, right)).map(([id, observations]) => ({
|
|
46
|
+
id,
|
|
47
|
+
observations
|
|
48
|
+
}))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { evaluationClaimSchema as n, summarizeEvaluationUnits as r, defineEvaluationClaim as t };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=claim-V9Zqbq0J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim-V9Zqbq0J.js","names":[],"sources":["../src/experiment/claim.ts"],"sourcesContent":["import { z } from 'zod'\nimport { ValidationError } from '../errors'\nimport { compareCodeUnits } from '../ledger-core/canonical'\nimport { type EvidenceRecord, readField } from './ast'\n\nconst nonEmpty = z\n .string()\n .min(1)\n .refine((value) => value.trim() === value)\n\n/** The claim's schema, shared by every record that binds a claim. */\nexport const evaluationClaimSchema = z\n .object({\n use: z.enum(['development', 'comparison', 'certification']),\n population: z.object({ id: nonEmpty, description: nonEmpty }).strict(),\n samplingFrame: nonEmpty,\n independentUnit: nonEmpty,\n generalization: z.enum(['fixed-roster', 'new-units']),\n minimumEffect: z.number().finite().positive().optional(),\n })\n .strict()\n\n/** The population and independent observations a measured result can describe. */\nexport type EvaluationClaim = z.infer<typeof evaluationClaimSchema>\n\n/** Validate a claim before binding it to a sealed experiment or final evidence. */\nexport function defineEvaluationClaim(input: EvaluationClaim): EvaluationClaim {\n const parsed = evaluationClaimSchema.safeParse(input)\n if (!parsed.success)\n throw new ValidationError(`invalid evaluation claim: ${parsed.error.message}`)\n return Object.freeze({ ...parsed.data, population: Object.freeze(parsed.data.population) })\n}\n\nexport interface EvaluationUnitSummary {\n observations: number\n independentUnits: number\n units: Array<{ id: string; observations: number }>\n}\n\n/** Repetitions retain their denominator without becoming additional independent units. */\nexport function summarizeEvaluationUnits(\n claim: EvaluationClaim,\n rows: readonly object[],\n): EvaluationUnitSummary {\n const validated = defineEvaluationClaim(claim)\n const counts = new Map<string, number>()\n for (const [index, row] of rows.entries()) {\n if (row === null || typeof row !== 'object' || Array.isArray(row)) {\n throw new ValidationError(`evaluation claim: row ${index} must be an object`)\n }\n const value = readField(row as EvidenceRecord, validated.independentUnit)\n if (typeof value !== 'string' || !value.trim() || value.trim() !== value) {\n throw new ValidationError(\n `evaluation claim: row ${index} needs a nonempty string at '${validated.independentUnit}'`,\n )\n }\n counts.set(value, (counts.get(value) ?? 0) + 1)\n }\n return {\n observations: rows.length,\n independentUnits: counts.size,\n units: [...counts]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([id, observations]) => ({ id, observations })),\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,WAAW,EACd,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,QAAQ,UAAU,MAAM,KAAK,MAAM,KAAK;;AAG3C,MAAa,wBAAwB,EAClC,OAAO;CACN,KAAK,EAAE,KAAK;EAAC;EAAe;EAAc;CAAe,CAAC;CAC1D,YAAY,EAAE,OAAO;EAAE,IAAI;EAAU,aAAa;CAAS,CAAC,CAAC,CAAC,OAAO;CACrE,eAAe;CACf,iBAAiB;CACjB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,WAAW,CAAC;CACpD,eAAe,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS;AACzD,CAAC,CAAC,CACD,OAAO;;AAMV,SAAgB,sBAAsB,OAAyC;CAC7E,MAAM,SAAS,sBAAsB,UAAU,KAAK;CACpD,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,gBAAgB,6BAA6B,OAAO,MAAM,SAAS;CAC/E,OAAO,OAAO,OAAO;EAAE,GAAG,OAAO;EAAM,YAAY,OAAO,OAAO,OAAO,KAAK,UAAU;CAAE,CAAC;AAC5F;;AASA,SAAgB,yBACd,OACA,MACuB;CACvB,MAAM,YAAY,sBAAsB,KAAK;CAC7C,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,CAAC,OAAO,QAAQ,KAAK,QAAQ,GAAG;EACzC,IAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAC9D,MAAM,IAAI,gBAAgB,yBAAyB,MAAM,mBAAmB;EAE9E,MAAM,QAAQ,UAAU,KAAuB,UAAU,eAAe;EACxE,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,KAAK,MAAM,KAAK,MAAM,OACjE,MAAM,IAAI,gBACR,yBAAyB,MAAM,+BAA+B,UAAU,gBAAgB,EAC1F;EAEF,OAAO,IAAI,QAAQ,OAAO,IAAI,KAAK,KAAK,KAAK,CAAC;CAChD;CACA,OAAO;EACL,cAAc,KAAK;EACnB,kBAAkB,OAAO;EACzB,OAAO,CAAC,GAAG,MAAM,CAAC,CACf,MAAM,CAAC,OAAO,CAAC,WAAW,iBAAiB,MAAM,KAAK,CAAC,CAAC,CACxD,KAAK,CAAC,IAAI,mBAAmB;GAAE;GAAI;EAAa,EAAE;CACvD;AACF"}
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { c as hostedTenantFromEnv, g as SearchRunKindSchema, r as shipSearchLedger, t as SearchShipConflictError, u as SEARCH_LEDGER_BATCH_MAX_BYTES } from "./search-shipper-C55V7HE3.js";
|
|
2
3
|
import { i as runRolloutReleaseCli } from "./hf-dataset-CRqtSjnR.js";
|
|
3
|
-
import { t as createChatClient } from "./chat-client-
|
|
4
|
-
import { t as runAnalystBenchmarkCommand } from "./benchmark-command-
|
|
5
|
-
import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-
|
|
4
|
+
import { t as createChatClient } from "./chat-client-B_ItsSBw.js";
|
|
5
|
+
import { t as runAnalystBenchmarkCommand } from "./benchmark-command-3tZJnD82.js";
|
|
6
|
+
import { a as runRpcBatch, o as runRpcOnce, p as handleVersion, r as startServerAsync, s as buildOpenApi } from "./server-DtetGGoA.js";
|
|
6
7
|
import { t as runSupervisorRunCommand } from "./report-command-DKJ_yAIj.js";
|
|
7
8
|
import { writeFileSync } from "node:fs";
|
|
9
|
+
import { open } from "node:fs/promises";
|
|
8
10
|
//#region src/cli-config.ts
|
|
9
11
|
/**
|
|
10
12
|
* Provider configuration for the `agent-eval` binary.
|
|
@@ -74,6 +76,96 @@ function nonEmpty(value) {
|
|
|
74
76
|
return trimmed ? trimmed : void 0;
|
|
75
77
|
}
|
|
76
78
|
//#endregion
|
|
79
|
+
//#region src/search-command.ts
|
|
80
|
+
/**
|
|
81
|
+
* `agent-eval search <subcommand>`: work with a search ledger from a terminal.
|
|
82
|
+
*
|
|
83
|
+
* agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]
|
|
84
|
+
*
|
|
85
|
+
* `ship` sends the ledger to the hosted store named by `TANGLE_INGEST_URL`,
|
|
86
|
+
* `TANGLE_INGEST_API_KEY` and `TANGLE_TENANT_ID`, starting from the store's
|
|
87
|
+
* head, so it finishes or resumes a ship that a loop could not complete.
|
|
88
|
+
*/
|
|
89
|
+
const USAGE = `usage: agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]
|
|
90
|
+
|
|
91
|
+
Ships the ledger's entries, and the blobs they name, to the hosted store in
|
|
92
|
+
TANGLE_INGEST_URL (or TANGLE_ORCHESTRATOR_URL) as tenant TANGLE_TENANT_ID with
|
|
93
|
+
TANGLE_INGEST_API_KEY (or TANGLE_API_KEY). It starts from the store's head, so
|
|
94
|
+
running it again sends only what the store lacks. Prints the result as JSON.
|
|
95
|
+
Exits 1 when the store holds a different chain for the search.`;
|
|
96
|
+
async function runSearchCommand(argv) {
|
|
97
|
+
const [subcommand, ...rest] = argv;
|
|
98
|
+
if ([subcommand, ...rest].some((arg) => arg === void 0 || arg === "--help" || arg === "-h")) {
|
|
99
|
+
process.stdout.write(`${USAGE}\n`);
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
if (subcommand !== "ship") {
|
|
103
|
+
process.stderr.write(`unknown search subcommand: ${subcommand}\n${USAGE}\n`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
const { path, flags } = parseShipArgs(rest);
|
|
107
|
+
const runKind = SearchRunKindSchema.safeParse(flags["run-kind"]);
|
|
108
|
+
if (!runKind.success) throw new Error(`--run-kind must be optimization or eval\n${USAGE}`);
|
|
109
|
+
const content = flags.content ?? "full";
|
|
110
|
+
if (content !== "full" && content !== "digests") throw new Error(`--content must be full or digests\n${USAGE}`);
|
|
111
|
+
const tenant = hostedTenantFromEnv();
|
|
112
|
+
if (!tenant) throw new Error("set TANGLE_INGEST_URL, TANGLE_INGEST_API_KEY and TANGLE_TENANT_ID to name the store");
|
|
113
|
+
const searchId = await firstLineSearchId(path);
|
|
114
|
+
try {
|
|
115
|
+
const shipped = await shipSearchLedger({
|
|
116
|
+
tenant,
|
|
117
|
+
ledger: {
|
|
118
|
+
path,
|
|
119
|
+
searchId
|
|
120
|
+
},
|
|
121
|
+
runKind: runKind.data,
|
|
122
|
+
content
|
|
123
|
+
});
|
|
124
|
+
process.stdout.write(`${JSON.stringify(shipped, null, 2)}\n`);
|
|
125
|
+
return shipped.head.nextSequence === shipped.localLines ? 0 : 1;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (!(error instanceof SearchShipConflictError)) throw error;
|
|
128
|
+
process.stderr.write(`${error.message}\n`);
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function parseShipArgs(argv) {
|
|
133
|
+
const flags = {};
|
|
134
|
+
const positional = [];
|
|
135
|
+
for (let index = 0; index < argv.length; index++) {
|
|
136
|
+
const token = argv[index];
|
|
137
|
+
if (!token.startsWith("--")) {
|
|
138
|
+
positional.push(token);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const [name, inline] = token.slice(2).split("=", 2);
|
|
142
|
+
if (name !== "run-kind" && name !== "content") throw new Error(`unknown flag --${name}`);
|
|
143
|
+
const value = inline ?? argv[++index];
|
|
144
|
+
if (value === void 0) throw new Error(`--${name} needs a value`);
|
|
145
|
+
flags[name] = value;
|
|
146
|
+
}
|
|
147
|
+
if (positional.length !== 1) throw new Error(USAGE);
|
|
148
|
+
return {
|
|
149
|
+
path: positional[0],
|
|
150
|
+
flags
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** The ledger names its search on every line; read the first. */
|
|
154
|
+
async function firstLineSearchId(path) {
|
|
155
|
+
const handle = await open(path, "r");
|
|
156
|
+
try {
|
|
157
|
+
const bytes = Buffer.alloc(SEARCH_LEDGER_BATCH_MAX_BYTES + 1);
|
|
158
|
+
const { bytesRead } = await handle.read(bytes, 0, bytes.byteLength, 0);
|
|
159
|
+
const newline = bytes.subarray(0, bytesRead).indexOf(10);
|
|
160
|
+
if (newline < 0) throw new Error(`${path} holds no complete ledger line`);
|
|
161
|
+
const first = JSON.parse(bytes.toString("utf8", 0, newline));
|
|
162
|
+
if (typeof first.searchId !== "string") throw new Error(`${path} line 1 names no searchId`);
|
|
163
|
+
return first.searchId;
|
|
164
|
+
} finally {
|
|
165
|
+
await handle.close();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
77
169
|
//#region src/cli.ts
|
|
78
170
|
/**
|
|
79
171
|
* agent-eval CLI.
|
|
@@ -83,6 +175,7 @@ function nonEmpty(value) {
|
|
|
83
175
|
* agent-eval rpc-batch <method> # JSONL stdin → JSONL stdout
|
|
84
176
|
* agent-eval analyst-benchmark ... # benchmark a real-model trace analyst
|
|
85
177
|
* agent-eval supervisor-run report <runDir> [--format headline|markdown|json]
|
|
178
|
+
* agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval
|
|
86
179
|
* agent-eval openapi [--out path] # write OpenAPI spec
|
|
87
180
|
* agent-eval version
|
|
88
181
|
*
|
|
@@ -143,6 +236,9 @@ Commands:
|
|
|
143
236
|
Report one Runtime or loops supervisor run directory. The status comes
|
|
144
237
|
from Runtime's own result.json / failure.json; every missing measurement
|
|
145
238
|
stays named. Exits 1 when the directory cannot be read.
|
|
239
|
+
search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]
|
|
240
|
+
Ship a search ledger and its blobs to the hosted store in TANGLE_INGEST_URL,
|
|
241
|
+
starting from the store's head. Run with --help for the environment it reads.
|
|
146
242
|
version
|
|
147
243
|
Print server + wire-protocol version JSON.
|
|
148
244
|
|
|
@@ -157,6 +253,7 @@ async function main() {
|
|
|
157
253
|
const { command, positional, flags } = parseArgs(process.argv.slice(2));
|
|
158
254
|
assertKnownFlags(command, flags);
|
|
159
255
|
if (command === "analyst-benchmark" && flags.help === "true") return await runAnalystBenchmarkCommand(process.argv.slice(3));
|
|
256
|
+
if (command === "search") return await runSearchCommand(process.argv.slice(3));
|
|
160
257
|
if (flags.help === "true") {
|
|
161
258
|
process.stdout.write(`${HELP}\n`);
|
|
162
259
|
return 0;
|
|
@@ -242,7 +339,7 @@ const FLAGS_BY_COMMAND = {
|
|
|
242
339
|
"": /* @__PURE__ */ new Set()
|
|
243
340
|
};
|
|
244
341
|
function assertKnownFlags(command, flags) {
|
|
245
|
-
if (command === "rollout-release" || command === "analyst-benchmark" || command === "supervisor-run") return;
|
|
342
|
+
if (command === "rollout-release" || command === "analyst-benchmark" || command === "supervisor-run" || command === "search") return;
|
|
246
343
|
const allowed = FLAGS_BY_COMMAND[command];
|
|
247
344
|
if (!allowed) return;
|
|
248
345
|
const unknown = Object.keys(flags).filter((flag) => !allowed.has(flag));
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli-config.ts","../src/cli.ts"],"sourcesContent":["/**\n * Provider configuration for the `agent-eval` binary.\n *\n * The binary reads endpoint and credential values from its environment.\n * TypeScript library callers bind a transport explicitly. The maintained\n * HTTP transport accepts their credential and sends provider requests.\n */\n\nimport { type ChatClient, createChatClient } from './analyst/chat-client'\n\nexport interface CliLlmConfig {\n /** Judge transport for the wire handlers. Absent when no provider is configured. */\n chat?: ChatClient\n model?: string\n}\n\n/** The endpoint the binary resolved from its environment. */\nexport interface CliProviderRoute {\n baseUrl: string\n apiKey: string\n model?: string\n}\n\n/**\n * Environment precedence for the binary's provider route, with no client built.\n *\n * Both halves are required: a base URL without a key, or a key without an\n * endpoint, is a half-configured server. `/v1/judge` then refuses with\n * `llm_not_configured` instead of calling an unintended endpoint.\n */\nexport function resolveCliProviderRoute(\n env: NodeJS.ProcessEnv = process.env,\n): CliProviderRoute | undefined {\n const explicitBaseUrl = nonEmpty(env.AGENT_EVAL_LLM_BASE_URL)\n const explicitApiKey = nonEmpty(env.AGENT_EVAL_LLM_API_KEY)\n const openAiApiKey = nonEmpty(env.OPENAI_API_KEY)\n const tangleApiKey = nonEmpty(env.TANGLE_API_KEY)\n const baseUrl =\n explicitBaseUrl ??\n nonEmpty(env.OPENAI_BASE_URL) ??\n nonEmpty(env.TANGLE_ROUTER_URL) ??\n (openAiApiKey ? 'https://api.openai.com/v1' : undefined) ??\n (tangleApiKey ? 'https://router.tangle.tools/v1' : undefined)\n const apiKey = explicitApiKey ?? openAiApiKey ?? tangleApiKey\n const model =\n nonEmpty(env.AGENT_EVAL_LLM_MODEL) ?? nonEmpty(env.OPENAI_MODEL) ?? nonEmpty(env.TANGLE_MODEL)\n\n if (!baseUrl || !apiKey) return undefined\n return { baseUrl, apiKey, ...(model ? { model } : {}) }\n}\n\nexport function resolveCliLlmConfig(env: NodeJS.ProcessEnv = process.env): CliLlmConfig {\n const route = resolveCliProviderRoute(env)\n if (!route) return {}\n return {\n chat: cliChatClient({ baseUrl: route.baseUrl, apiKey: route.apiKey }, route.model),\n ...(route.model ? { model: route.model } : {}),\n }\n}\n\n/**\n * The binary's transport IS the published one — `createChatClient({ transport:\n * 'openai-compatible' })` — so the server and a library consumer cannot drift\n * onto two different clients for the same endpoint.\n *\n * The one thing kept local is the error text. A generic \"no model on the\n * request\" tells a server operator nothing; this names the variable to set.\n */\nfunction cliChatClient(\n route: { baseUrl: string; apiKey: string },\n defaultModel: string | undefined,\n): ChatClient {\n const client = createChatClient({\n transport: 'openai-compatible',\n baseUrl: route.baseUrl,\n apiKey: route.apiKey,\n ...(defaultModel ? { defaultModel } : {}),\n })\n return {\n ...client,\n chat: (req, callOpts) => {\n if (!req.model && !defaultModel) {\n throw new Error(\n 'agent-eval: no model on the request and no AGENT_EVAL_LLM_MODEL configured',\n )\n }\n return client.chat(req, callOpts)\n },\n }\n}\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n","#!/usr/bin/env node\n/**\n * agent-eval CLI.\n *\n * agent-eval serve [--port 5005] [--host 127.0.0.1]\n * agent-eval rpc <method> # one request from stdin → one response on stdout\n * agent-eval rpc-batch <method> # JSONL stdin → JSONL stdout\n * agent-eval analyst-benchmark ... # benchmark a real-model trace analyst\n * agent-eval supervisor-run report <runDir> [--format headline|markdown|json]\n * agent-eval openapi [--out path] # write OpenAPI spec\n * agent-eval version\n *\n * <method> is one of: judge, listRubrics, version. When omitted, the\n * stdin payload must be a full {method, params} envelope.\n */\nimport { writeFileSync } from 'node:fs'\nimport { runAnalystBenchmarkCommand } from './analyst/benchmark-command'\nimport { resolveCliLlmConfig } from './cli-config'\nimport { runRolloutReleaseCli } from './rollout/release/hf-dataset'\nimport { runSupervisorRunCommand } from './supervisor-run/report-command'\nimport { handleVersion } from './wire/handlers'\nimport { buildOpenApi } from './wire/openapi'\nimport { runRpcBatch, runRpcOnce } from './wire/rpc'\nimport { startServerAsync } from './wire/server'\n\ninterface Args {\n command: string\n positional: string[]\n flags: Record<string, string>\n}\n\nfunction parseArgs(argv: string[]): Args {\n const [command, ...rest] = argv\n const positional: string[] = []\n const flags: Record<string, string> = {}\n for (let i = 0; i < rest.length; i++) {\n const tok = rest[i]!\n if (tok.startsWith('--')) {\n const raw = tok.slice(2)\n const equalsAt = raw.indexOf('=')\n if (equalsAt >= 0) {\n flags[raw.slice(0, equalsAt)] = raw.slice(equalsAt + 1)\n continue\n }\n const key = raw\n if (key === 'help') {\n flags[key] = 'true'\n continue\n }\n const next = rest[i + 1]\n if (next != null && !next.startsWith('--')) {\n flags[key] = next\n i++\n } else {\n flags[key] = 'true'\n }\n } else if (tok === '-h') {\n flags.help = 'true'\n } else {\n positional.push(tok)\n }\n }\n return { command: command ?? 'help', positional, flags }\n}\n\nconst HELP = `agent-eval: evaluation RPC and HTTP server.\n\nCommands:\n serve [--port 5005] [--host 127.0.0.1]\n Start the HTTP server. POST /v1/judge, GET /v1/rubrics, GET /v1/version, GET /openapi.json.\n rpc <method>\n Read one JSON object from stdin (the params for <method>), write one\n JSON object to stdout. Methods: judge, listRubrics, version.\n rpc-batch <method>\n Like 'rpc' but JSONL in / JSONL out.\n openapi [--out openapi.json]\n Write the OpenAPI 3.1 spec.\n rollout-release <ledger.jsonl...> --out <dir> [--formats sft,verifiers,rft,raw] [--include-proposers] [--push <org/name>]\n Build a HuggingFace-ready dataset dir from tangle.rollout.v1 ledgers:\n validate, fail-closed split filter, scrub, export formats + card.\n analyst-benchmark --dataset <agentrx|codetracebench> --labels <path> --trace-dir <path> [--artifact-dir <path>] --out <dir> ...\n Compare an empty baseline with a real-model trace analyst on public labels.\n Run with --help for all required inputs and controls.\n supervisor-run report <runDir> [--format headline|markdown|json]\n Report one Runtime or loops supervisor run directory. The status comes\n from Runtime's own result.json / failure.json; every missing measurement\n stays named. Exits 1 when the directory cannot be read.\n version\n Print server + wire-protocol version JSON.\n\nJudge provider:\n Set AGENT_EVAL_LLM_BASE_URL, AGENT_EVAL_LLM_API_KEY, and AGENT_EVAL_LLM_MODEL.\n OPENAI_* and TANGLE_* equivalents are also accepted. This binary is the only\n place that reads a provider credential; the library never does. Without both\n a base URL and a key, /v1/judge refuses with llm_not_configured.\n\nWithout arguments, prints this help.`\n\nasync function main(): Promise<number> {\n const { command, positional, flags } = parseArgs(process.argv.slice(2))\n assertKnownFlags(command, flags)\n\n if (command === 'analyst-benchmark' && flags.help === 'true') {\n return await runAnalystBenchmarkCommand(process.argv.slice(3))\n }\n if (flags.help === 'true') {\n process.stdout.write(`${HELP}\\n`)\n return 0\n }\n\n switch (command) {\n case 'serve': {\n const port = parsePort(flags.port ?? '5005')\n const host = flags.host ?? '127.0.0.1'\n const llm = resolveCliLlmConfig()\n const { server } = await startServerAsync({\n port,\n host,\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n // Keep process alive on SIGINT/SIGTERM\n const shutdown = (sig: string) => {\n // eslint-disable-next-line no-console\n console.log(`[agent-eval] received ${sig}, shutting down`)\n server.close(() => process.exit(0))\n // Force exit after 5s if close hangs\n setTimeout(() => process.exit(1), 5000).unref()\n }\n process.on('SIGINT', () => shutdown('SIGINT'))\n process.on('SIGTERM', () => shutdown('SIGTERM'))\n // Block forever\n await new Promise(() => {})\n return 0\n }\n case 'rpc': {\n const [method] = positional\n const llm = resolveCliLlmConfig()\n return await runRpcOnce(method, {\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n }\n case 'rpc-batch': {\n const [method] = positional\n const llm = resolveCliLlmConfig()\n return await runRpcBatch(method, {\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n }\n case 'openapi': {\n const out = flags.out ?? 'openapi.json'\n const spec = buildOpenApi(handleVersion().version)\n writeFileSync(out, `${JSON.stringify(spec, null, 2)}\\n`, 'utf-8')\n // eslint-disable-next-line no-console\n console.log(`[agent-eval] wrote OpenAPI 3.1 spec to ${out}`)\n return 0\n }\n case 'rollout-release': {\n // The subcommand owns its own flag grammar (multi-value --formats,\n // boolean --include-proposers) — pass raw argv through untouched.\n return await runRolloutReleaseCli(process.argv.slice(3))\n }\n case 'analyst-benchmark': {\n return await runAnalystBenchmarkCommand(process.argv.slice(3))\n }\n case 'supervisor-run': {\n // The subcommand owns its own flag grammar; pass raw argv through.\n return await runSupervisorRunCommand(process.argv.slice(3))\n }\n case 'version': {\n process.stdout.write(`${JSON.stringify(handleVersion(), null, 2)}\\n`)\n return 0\n }\n case '--version': {\n process.stdout.write(`${handleVersion().version}\\n`)\n return 0\n }\n case 'help':\n case '--help':\n case '-h':\n case '':\n process.stdout.write(`${HELP}\\n`)\n return 0\n default:\n process.stderr.write(`unknown command: ${command}\\n${HELP}\\n`)\n return 1\n }\n}\n\nconst FLAGS_BY_COMMAND: Record<string, ReadonlySet<string>> = {\n serve: new Set(['help', 'host', 'port']),\n rpc: new Set(['help']),\n 'rpc-batch': new Set(['help']),\n openapi: new Set(['help', 'out']),\n version: new Set(['help']),\n help: new Set(),\n '--help': new Set(),\n '-h': new Set(),\n '--version': new Set(),\n '': new Set(),\n}\n\nfunction assertKnownFlags(command: string, flags: Record<string, string>): void {\n // These subcommands parse their own argv.\n if (\n command === 'rollout-release' ||\n command === 'analyst-benchmark' ||\n command === 'supervisor-run'\n ) {\n return\n }\n const allowed = FLAGS_BY_COMMAND[command]\n if (!allowed) return\n const unknown = Object.keys(flags).filter((flag) => !allowed.has(flag))\n if (unknown.length > 0) {\n throw new Error(`unknown flag for ${command || 'help'}: --${unknown[0]}`)\n }\n}\n\nfunction parsePort(raw: string): number {\n const port = Number(raw)\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new Error(`--port must be an integer from 0 to 65535; received ${JSON.stringify(raw)}`)\n }\n return port\n}\n\nmain()\n .then((code) => process.exit(code))\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error('[agent-eval] cli error:', err)\n process.exit(1)\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,wBACd,MAAyB,QAAQ,KACH;CAC9B,MAAM,kBAAkB,SAAS,IAAI,uBAAuB;CAC5D,MAAM,iBAAiB,SAAS,IAAI,sBAAsB;CAC1D,MAAM,eAAe,SAAS,IAAI,cAAc;CAChD,MAAM,eAAe,S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AI,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,OAChD,MAAM,IAAI,MAAM,uDAAuD,KAAK,UAAU,GAAG,GAAG;CAE9F,OAAO;AACT;AAEA,KAAK,CAAC,CACH,MAAM,SAAS,QAAQ,KAAK,IAAI,CAAC,CAAC,CAClC,OAAO,QAAQ;CAEd,QAAQ,MAAM,2BAA2B,GAAG;CAC5C,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli-config.ts","../src/search-command.ts","../src/cli.ts"],"sourcesContent":["/**\n * Provider configuration for the `agent-eval` binary.\n *\n * The binary reads endpoint and credential values from its environment.\n * TypeScript library callers bind a transport explicitly. The maintained\n * HTTP transport accepts their credential and sends provider requests.\n */\n\nimport { type ChatClient, createChatClient } from './analyst/chat-client'\n\nexport interface CliLlmConfig {\n /** Judge transport for the wire handlers. Absent when no provider is configured. */\n chat?: ChatClient\n model?: string\n}\n\n/** The endpoint the binary resolved from its environment. */\nexport interface CliProviderRoute {\n baseUrl: string\n apiKey: string\n model?: string\n}\n\n/**\n * Environment precedence for the binary's provider route, with no client built.\n *\n * Both halves are required: a base URL without a key, or a key without an\n * endpoint, is a half-configured server. `/v1/judge` then refuses with\n * `llm_not_configured` instead of calling an unintended endpoint.\n */\nexport function resolveCliProviderRoute(\n env: NodeJS.ProcessEnv = process.env,\n): CliProviderRoute | undefined {\n const explicitBaseUrl = nonEmpty(env.AGENT_EVAL_LLM_BASE_URL)\n const explicitApiKey = nonEmpty(env.AGENT_EVAL_LLM_API_KEY)\n const openAiApiKey = nonEmpty(env.OPENAI_API_KEY)\n const tangleApiKey = nonEmpty(env.TANGLE_API_KEY)\n const baseUrl =\n explicitBaseUrl ??\n nonEmpty(env.OPENAI_BASE_URL) ??\n nonEmpty(env.TANGLE_ROUTER_URL) ??\n (openAiApiKey ? 'https://api.openai.com/v1' : undefined) ??\n (tangleApiKey ? 'https://router.tangle.tools/v1' : undefined)\n const apiKey = explicitApiKey ?? openAiApiKey ?? tangleApiKey\n const model =\n nonEmpty(env.AGENT_EVAL_LLM_MODEL) ?? nonEmpty(env.OPENAI_MODEL) ?? nonEmpty(env.TANGLE_MODEL)\n\n if (!baseUrl || !apiKey) return undefined\n return { baseUrl, apiKey, ...(model ? { model } : {}) }\n}\n\nexport function resolveCliLlmConfig(env: NodeJS.ProcessEnv = process.env): CliLlmConfig {\n const route = resolveCliProviderRoute(env)\n if (!route) return {}\n return {\n chat: cliChatClient({ baseUrl: route.baseUrl, apiKey: route.apiKey }, route.model),\n ...(route.model ? { model: route.model } : {}),\n }\n}\n\n/**\n * The binary's transport IS the published one — `createChatClient({ transport:\n * 'openai-compatible' })` — so the server and a library consumer cannot drift\n * onto two different clients for the same endpoint.\n *\n * The one thing kept local is the error text. A generic \"no model on the\n * request\" tells a server operator nothing; this names the variable to set.\n */\nfunction cliChatClient(\n route: { baseUrl: string; apiKey: string },\n defaultModel: string | undefined,\n): ChatClient {\n const client = createChatClient({\n transport: 'openai-compatible',\n baseUrl: route.baseUrl,\n apiKey: route.apiKey,\n ...(defaultModel ? { defaultModel } : {}),\n })\n return {\n ...client,\n chat: (req, callOpts) => {\n if (!req.model && !defaultModel) {\n throw new Error(\n 'agent-eval: no model on the request and no AGENT_EVAL_LLM_MODEL configured',\n )\n }\n return client.chat(req, callOpts)\n },\n }\n}\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n","/**\n * `agent-eval search <subcommand>`: work with a search ledger from a terminal.\n *\n * agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]\n *\n * `ship` sends the ledger to the hosted store named by `TANGLE_INGEST_URL`,\n * `TANGLE_INGEST_API_KEY` and `TANGLE_TENANT_ID`, starting from the store's\n * head, so it finishes or resumes a ship that a loop could not complete.\n */\n\nimport { open } from 'node:fs/promises'\nimport { hostedTenantFromEnv } from './hosted/client'\nimport { SEARCH_LEDGER_BATCH_MAX_BYTES, SearchRunKindSchema } from './hosted/search-ledger-wire'\nimport { SearchShipConflictError, shipSearchLedger } from './hosted/search-shipper'\n\nconst USAGE = `usage: agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]\n\nShips the ledger's entries, and the blobs they name, to the hosted store in\nTANGLE_INGEST_URL (or TANGLE_ORCHESTRATOR_URL) as tenant TANGLE_TENANT_ID with\nTANGLE_INGEST_API_KEY (or TANGLE_API_KEY). It starts from the store's head, so\nrunning it again sends only what the store lacks. Prints the result as JSON.\nExits 1 when the store holds a different chain for the search.`\n\nexport async function runSearchCommand(argv: string[]): Promise<number> {\n const [subcommand, ...rest] = argv\n if ([subcommand, ...rest].some((arg) => arg === undefined || arg === '--help' || arg === '-h')) {\n process.stdout.write(`${USAGE}\\n`)\n return 0\n }\n if (subcommand !== 'ship') {\n process.stderr.write(`unknown search subcommand: ${subcommand}\\n${USAGE}\\n`)\n return 1\n }\n const { path, flags } = parseShipArgs(rest)\n const runKind = SearchRunKindSchema.safeParse(flags['run-kind'])\n if (!runKind.success) throw new Error(`--run-kind must be optimization or eval\\n${USAGE}`)\n const content = flags.content ?? 'full'\n if (content !== 'full' && content !== 'digests') {\n throw new Error(`--content must be full or digests\\n${USAGE}`)\n }\n const tenant = hostedTenantFromEnv()\n if (!tenant) {\n throw new Error(\n 'set TANGLE_INGEST_URL, TANGLE_INGEST_API_KEY and TANGLE_TENANT_ID to name the store',\n )\n }\n const searchId = await firstLineSearchId(path)\n try {\n const shipped = await shipSearchLedger({\n tenant,\n ledger: { path, searchId },\n runKind: runKind.data,\n content,\n })\n process.stdout.write(`${JSON.stringify(shipped, null, 2)}\\n`)\n return shipped.head.nextSequence === shipped.localLines ? 0 : 1\n } catch (error) {\n if (!(error instanceof SearchShipConflictError)) throw error\n process.stderr.write(`${error.message}\\n`)\n return 1\n }\n}\n\nfunction parseShipArgs(argv: string[]): { path: string; flags: Record<string, string> } {\n const flags: Record<string, string> = {}\n const positional: string[] = []\n for (let index = 0; index < argv.length; index++) {\n const token = argv[index]!\n if (!token.startsWith('--')) {\n positional.push(token)\n continue\n }\n const [name, inline] = token.slice(2).split('=', 2) as [string, string | undefined]\n if (name !== 'run-kind' && name !== 'content') throw new Error(`unknown flag --${name}`)\n const value = inline ?? argv[++index]\n if (value === undefined) throw new Error(`--${name} needs a value`)\n flags[name] = value\n }\n if (positional.length !== 1) throw new Error(USAGE)\n return { path: positional[0]!, flags }\n}\n\n/** The ledger names its search on every line; read the first. */\nasync function firstLineSearchId(path: string): Promise<string> {\n const handle = await open(path, 'r')\n try {\n // A line longer than one request's limit cannot ship anyway.\n const bytes = Buffer.alloc(SEARCH_LEDGER_BATCH_MAX_BYTES + 1)\n const { bytesRead } = await handle.read(bytes, 0, bytes.byteLength, 0)\n const newline = bytes.subarray(0, bytesRead).indexOf(0x0a)\n if (newline < 0) throw new Error(`${path} holds no complete ledger line`)\n const first = JSON.parse(bytes.toString('utf8', 0, newline)) as { searchId?: unknown }\n if (typeof first.searchId !== 'string') throw new Error(`${path} line 1 names no searchId`)\n return first.searchId\n } finally {\n await handle.close()\n }\n}\n","#!/usr/bin/env node\n/**\n * agent-eval CLI.\n *\n * agent-eval serve [--port 5005] [--host 127.0.0.1]\n * agent-eval rpc <method> # one request from stdin → one response on stdout\n * agent-eval rpc-batch <method> # JSONL stdin → JSONL stdout\n * agent-eval analyst-benchmark ... # benchmark a real-model trace analyst\n * agent-eval supervisor-run report <runDir> [--format headline|markdown|json]\n * agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval\n * agent-eval openapi [--out path] # write OpenAPI spec\n * agent-eval version\n *\n * <method> is one of: judge, listRubrics, version. When omitted, the\n * stdin payload must be a full {method, params} envelope.\n */\nimport { writeFileSync } from 'node:fs'\nimport { runAnalystBenchmarkCommand } from './analyst/benchmark-command'\nimport { resolveCliLlmConfig } from './cli-config'\nimport { runRolloutReleaseCli } from './rollout/release/hf-dataset'\nimport { runSearchCommand } from './search-command'\nimport { runSupervisorRunCommand } from './supervisor-run/report-command'\nimport { handleVersion } from './wire/handlers'\nimport { buildOpenApi } from './wire/openapi'\nimport { runRpcBatch, runRpcOnce } from './wire/rpc'\nimport { startServerAsync } from './wire/server'\n\ninterface Args {\n command: string\n positional: string[]\n flags: Record<string, string>\n}\n\nfunction parseArgs(argv: string[]): Args {\n const [command, ...rest] = argv\n const positional: string[] = []\n const flags: Record<string, string> = {}\n for (let i = 0; i < rest.length; i++) {\n const tok = rest[i]!\n if (tok.startsWith('--')) {\n const raw = tok.slice(2)\n const equalsAt = raw.indexOf('=')\n if (equalsAt >= 0) {\n flags[raw.slice(0, equalsAt)] = raw.slice(equalsAt + 1)\n continue\n }\n const key = raw\n if (key === 'help') {\n flags[key] = 'true'\n continue\n }\n const next = rest[i + 1]\n if (next != null && !next.startsWith('--')) {\n flags[key] = next\n i++\n } else {\n flags[key] = 'true'\n }\n } else if (tok === '-h') {\n flags.help = 'true'\n } else {\n positional.push(tok)\n }\n }\n return { command: command ?? 'help', positional, flags }\n}\n\nconst HELP = `agent-eval: evaluation RPC and HTTP server.\n\nCommands:\n serve [--port 5005] [--host 127.0.0.1]\n Start the HTTP server. POST /v1/judge, GET /v1/rubrics, GET /v1/version, GET /openapi.json.\n rpc <method>\n Read one JSON object from stdin (the params for <method>), write one\n JSON object to stdout. Methods: judge, listRubrics, version.\n rpc-batch <method>\n Like 'rpc' but JSONL in / JSONL out.\n openapi [--out openapi.json]\n Write the OpenAPI 3.1 spec.\n rollout-release <ledger.jsonl...> --out <dir> [--formats sft,verifiers,rft,raw] [--include-proposers] [--push <org/name>]\n Build a HuggingFace-ready dataset dir from tangle.rollout.v1 ledgers:\n validate, fail-closed split filter, scrub, export formats + card.\n analyst-benchmark --dataset <agentrx|codetracebench> --labels <path> --trace-dir <path> [--artifact-dir <path>] --out <dir> ...\n Compare an empty baseline with a real-model trace analyst on public labels.\n Run with --help for all required inputs and controls.\n supervisor-run report <runDir> [--format headline|markdown|json]\n Report one Runtime or loops supervisor run directory. The status comes\n from Runtime's own result.json / failure.json; every missing measurement\n stays named. Exits 1 when the directory cannot be read.\n search ship <search-ledger.jsonl> --run-kind optimization|eval [--content full|digests]\n Ship a search ledger and its blobs to the hosted store in TANGLE_INGEST_URL,\n starting from the store's head. Run with --help for the environment it reads.\n version\n Print server + wire-protocol version JSON.\n\nJudge provider:\n Set AGENT_EVAL_LLM_BASE_URL, AGENT_EVAL_LLM_API_KEY, and AGENT_EVAL_LLM_MODEL.\n OPENAI_* and TANGLE_* equivalents are also accepted. This binary is the only\n place that reads a provider credential; the library never does. Without both\n a base URL and a key, /v1/judge refuses with llm_not_configured.\n\nWithout arguments, prints this help.`\n\nasync function main(): Promise<number> {\n const { command, positional, flags } = parseArgs(process.argv.slice(2))\n assertKnownFlags(command, flags)\n\n if (command === 'analyst-benchmark' && flags.help === 'true') {\n return await runAnalystBenchmarkCommand(process.argv.slice(3))\n }\n if (command === 'search') return await runSearchCommand(process.argv.slice(3))\n if (flags.help === 'true') {\n process.stdout.write(`${HELP}\\n`)\n return 0\n }\n\n switch (command) {\n case 'serve': {\n const port = parsePort(flags.port ?? '5005')\n const host = flags.host ?? '127.0.0.1'\n const llm = resolveCliLlmConfig()\n const { server } = await startServerAsync({\n port,\n host,\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n // Keep process alive on SIGINT/SIGTERM\n const shutdown = (sig: string) => {\n // eslint-disable-next-line no-console\n console.log(`[agent-eval] received ${sig}, shutting down`)\n server.close(() => process.exit(0))\n // Force exit after 5s if close hangs\n setTimeout(() => process.exit(1), 5000).unref()\n }\n process.on('SIGINT', () => shutdown('SIGINT'))\n process.on('SIGTERM', () => shutdown('SIGTERM'))\n // Block forever\n await new Promise(() => {})\n return 0\n }\n case 'rpc': {\n const [method] = positional\n const llm = resolveCliLlmConfig()\n return await runRpcOnce(method, {\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n }\n case 'rpc-batch': {\n const [method] = positional\n const llm = resolveCliLlmConfig()\n return await runRpcBatch(method, {\n ...(llm.chat ? { chat: llm.chat } : {}),\n ...(llm.model ? { judgeModel: llm.model } : {}),\n })\n }\n case 'openapi': {\n const out = flags.out ?? 'openapi.json'\n const spec = buildOpenApi(handleVersion().version)\n writeFileSync(out, `${JSON.stringify(spec, null, 2)}\\n`, 'utf-8')\n // eslint-disable-next-line no-console\n console.log(`[agent-eval] wrote OpenAPI 3.1 spec to ${out}`)\n return 0\n }\n case 'rollout-release': {\n // The subcommand owns its own flag grammar (multi-value --formats,\n // boolean --include-proposers) — pass raw argv through untouched.\n return await runRolloutReleaseCli(process.argv.slice(3))\n }\n case 'analyst-benchmark': {\n return await runAnalystBenchmarkCommand(process.argv.slice(3))\n }\n case 'supervisor-run': {\n // The subcommand owns its own flag grammar; pass raw argv through.\n return await runSupervisorRunCommand(process.argv.slice(3))\n }\n case 'version': {\n process.stdout.write(`${JSON.stringify(handleVersion(), null, 2)}\\n`)\n return 0\n }\n case '--version': {\n process.stdout.write(`${handleVersion().version}\\n`)\n return 0\n }\n case 'help':\n case '--help':\n case '-h':\n case '':\n process.stdout.write(`${HELP}\\n`)\n return 0\n default:\n process.stderr.write(`unknown command: ${command}\\n${HELP}\\n`)\n return 1\n }\n}\n\nconst FLAGS_BY_COMMAND: Record<string, ReadonlySet<string>> = {\n serve: new Set(['help', 'host', 'port']),\n rpc: new Set(['help']),\n 'rpc-batch': new Set(['help']),\n openapi: new Set(['help', 'out']),\n version: new Set(['help']),\n help: new Set(),\n '--help': new Set(),\n '-h': new Set(),\n '--version': new Set(),\n '': new Set(),\n}\n\nfunction assertKnownFlags(command: string, flags: Record<string, string>): void {\n // These subcommands parse their own argv.\n if (\n command === 'rollout-release' ||\n command === 'analyst-benchmark' ||\n command === 'supervisor-run' ||\n command === 'search'\n ) {\n return\n }\n const allowed = FLAGS_BY_COMMAND[command]\n if (!allowed) return\n const unknown = Object.keys(flags).filter((flag) => !allowed.has(flag))\n if (unknown.length > 0) {\n throw new Error(`unknown flag for ${command || 'help'}: --${unknown[0]}`)\n }\n}\n\nfunction parsePort(raw: string): number {\n const port = Number(raw)\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new Error(`--port must be an integer from 0 to 65535; received ${JSON.stringify(raw)}`)\n }\n return port\n}\n\nmain()\n .then((code) => process.exit(code))\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error('[agent-eval] cli error:', err)\n process.exit(1)\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,wBACd,MAAyB,QAAQ,KACH;CAC9B,MAAM,kBAAkB,SAAS,IAAI,uBAAuB;CAC5D,MAAM,iBAAiB,SAAS,IAAI,sBAAsB;CAC1D,MAAM,eAAe,SAAS,IAAI,cAAc;CAChD,MAAM,eAAe,SAAS,IAAI,cAAc;CAChD,MAAM,UACJ,mBACA,SAAS,IAAI,eAAe,KAC5B,SAAS,IAAI,iBAAiB,MAC7B,eAAe,8BAA8B,KAAA,OAC7C,eAAe,mCAAmC,KAAA;CACrD,MAAM,SAAS,kBAAkB,gBAAgB;CACjD,MAAM,QACJ,SAAS,IAAI,oBAAoB,KAAK,SAAS,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY;CAE/F,IAAI,CAAC,WAAW,CAAC,QAAQ,OAAO,KAAA;CAChC,OAAO;EAAE;EAAS;EAAQ,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAAG;AACxD;AAEA,SAAgB,oBAAoB,MAAyB,QAAQ,KAAmB;CACtF,MAAM,QAAQ,wBAAwB,GAAG;CACzC,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,OAAO;EACL,MAAM,cAAc;GAAE,SAAS,MAAM;GAAS,QAAQ,MAAM;EAAO,GAAG,MAAM,KAAK;EACjF,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;CAC9C;AACF;;;;;;;;;AAUA,S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