From 15fb4f8c23f039ac4a4186c13d1ab6c91d853b8f Mon Sep 17 00:00:00 2001 From: Homen Shum Date: Wed, 14 Oct 2026 12:02:06 -0700 Subject: [PATCH 01/25] chore(models): refresh stale model defaults (NodeSlide) Gemini 3.5 Flash was deprecated by Google on 2026-10-08 (auto-routed to 3.6) and openai/gpt-oss-20b:free is unlisted on OpenRouter (2026-10-10). Move the routed executor to google/gemini-3.8-flash, add Claude Sonnet 5.5 / Opus 5.5 and GPT-6.1 Sol rows (add-only; old literals stay valid for persisted rows), bump pi-ai to 1.1.0, refresh the price table from the OpenRouter catalog, and add the budget controls the spec requires before any keyed campaign. - catalog/validators/pricing/probe profiles/fleet receipt/capability ledger rows - structuredOutputMode catalog flag replaces the gemini-3.5 literal at the json_object workaround - NODESLIDE_KIMI_K3 cost agrees with the price table (agreement test) - Claude rows pinned to OpenRouter chat-completions under pi-ai 1.1.0 - request-shape tests (fake transport) for every new/changed role - nodeslideModelProbe:runExecutorSplit + executor-split-probe/v1 receipt validator - deck-gym:run --max-total-cost-micro-usd; node-gym ledger-charged campaign accounting - node-gym execution.disabled mechanism (600 selected / 120 skipped) Spec: model-defaults SPEC Part A section A.2.8 (NodeSlide) Co-Authored-By: Claude Sonnet 5.5 --- .../workflows/nightly-production-probe.yml | 16 +- .../claude-opus-5-5/benchmark-summary.md | 13 + .../claude-opus-5-5/capability-card.yaml | 37 + .qa/models/claude-opus-5-5/findings.jsonl | 1 + .../claude-sonnet-5-5/benchmark-summary.md | 13 + .../claude-sonnet-5-5/capability-card.yaml | 37 + .qa/models/claude-sonnet-5-5/findings.jsonl | 1 + .../gemini-3-8-flash/benchmark-summary.md | 13 + .../gemini-3-8-flash/capability-card.yaml | 37 + .qa/models/gemini-3-8-flash/findings.jsonl | 1 + .qa/models/gpt-6-1-sol/benchmark-summary.md | 13 + .qa/models/gpt-6-1-sol/capability-card.yaml | 37 + .qa/models/gpt-6-1-sol/findings.jsonl | 1 + .tours/02-agent-execution.tour | 6 +- .../configuration-validation.json | 2 +- .../nodeslide-deck-gym-v2/matrix.json | 842 +++++++++++++++--- benchmarks/deck-gym/v2/gym.json | 7 +- convex/lib/nodeslideAutoRoutingPolicy.test.ts | 16 +- convex/lib/nodeslideEditPlanner.test.ts | 8 +- convex/lib/nodeslideEditVerifyAction.test.ts | 5 +- convex/lib/nodeslideExecutorSplitProbe.ts | 195 ++++ .../nodeslideProvider.requestShape.test.ts | 254 ++++++ convex/lib/nodeslideProvider.test.ts | 21 +- convex/lib/nodeslideProvider.ts | 52 +- convex/lib/nodeslideReviewUi.test.tsx | 7 +- convex/lib/nodeslideRoutedProposeEdit.test.ts | 2 +- convex/lib/nodeslideRoutingPolicy.test.ts | 5 + convex/lib/nodeslideRoutingPolicy.ts | 5 +- convex/lib/nodeslideValidators.ts | 4 + convex/nodeslideBudgetEnforcement.test.ts | 11 +- convex/nodeslideBudgetWiring.test.ts | 74 +- convex/nodeslideBudgets.ts | 40 + convex/nodeslideModelPricing.test.ts | 107 ++- convex/nodeslideModelProbe.ts | 32 + docs/codebase/INTEGRATIONS.md | 2 +- mcp/package.json | 2 +- mcp/src/lib/nodeslideTools.ts | 14 +- package-lock.json | 731 +++++++-------- package.json | 2 +- packages/cli/src/cli.ts | 5 +- scripts/build-model-capability-ledger.mjs | 27 + scripts/capture-model-fleet-probe.mjs | 29 +- scripts/lib/deck-gym-campaign.mjs | 132 +++ scripts/lib/model-fleet-receipt-core.mjs | 43 +- scripts/lib/node-gym-config-core.mjs | 58 ++ scripts/lib/node-gym-runner-core.mjs | 242 ++++- scripts/lib/node-gym-selection-core.mjs | 46 + scripts/lib/nodeslide-backend-runs.mjs | 80 ++ scripts/node-gym-runner-core.test.mjs | 4 + scripts/node-gym-ui-executor.mjs | 18 + scripts/run-deck-gym.mjs | 96 +- scripts/run-node-gym.mjs | 120 ++- .../tests/deck-gym-campaign-budget.test.mjs | 235 +++++ scripts/tests/executor-split-probe.test.mjs | 178 ++++ .../tests/node-gym-campaign-budget.test.mjs | 440 +++++++++ .../tests/node-gym-disabled-model.test.mjs | 88 ++ shared/nodeslide.ts | 89 +- shared/nodeslideRunBudget.ts | 74 +- .../components/NodeSlideConnectionsDialog.tsx | 12 +- src/lib/sessionByok.ts | 6 +- 60 files changed, 4018 insertions(+), 670 deletions(-) create mode 100644 .qa/models/claude-opus-5-5/benchmark-summary.md create mode 100644 .qa/models/claude-opus-5-5/capability-card.yaml create mode 100644 .qa/models/claude-opus-5-5/findings.jsonl create mode 100644 .qa/models/claude-sonnet-5-5/benchmark-summary.md create mode 100644 .qa/models/claude-sonnet-5-5/capability-card.yaml create mode 100644 .qa/models/claude-sonnet-5-5/findings.jsonl create mode 100644 .qa/models/gemini-3-8-flash/benchmark-summary.md create mode 100644 .qa/models/gemini-3-8-flash/capability-card.yaml create mode 100644 .qa/models/gemini-3-8-flash/findings.jsonl create mode 100644 .qa/models/gpt-6-1-sol/benchmark-summary.md create mode 100644 .qa/models/gpt-6-1-sol/capability-card.yaml create mode 100644 .qa/models/gpt-6-1-sol/findings.jsonl create mode 100644 convex/lib/nodeslideExecutorSplitProbe.ts create mode 100644 convex/lib/nodeslideProvider.requestShape.test.ts create mode 100644 scripts/lib/deck-gym-campaign.mjs create mode 100644 scripts/lib/node-gym-selection-core.mjs create mode 100644 scripts/lib/nodeslide-backend-runs.mjs create mode 100644 scripts/tests/deck-gym-campaign-budget.test.mjs create mode 100644 scripts/tests/executor-split-probe.test.mjs create mode 100644 scripts/tests/node-gym-campaign-budget.test.mjs create mode 100644 scripts/tests/node-gym-disabled-model.test.mjs diff --git a/.github/workflows/nightly-production-probe.yml b/.github/workflows/nightly-production-probe.yml index 1b26be02..71bea34b 100644 --- a/.github/workflows/nightly-production-probe.yml +++ b/.github/workflows/nightly-production-probe.yml @@ -68,6 +68,7 @@ jobs: rm -f artifacts/model-fleet/model-fleet-probe.json rm -f artifacts/model-fleet/free-router-fleet-probe.json rm -f artifacts/model-fleet/free-router-structured-probe.json + rm -f artifacts/model-fleet/receipt-*.json rm -rf artifacts/close-all-gaps-20260722/acceptance/ui-qa - name: Set up Node.js uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 @@ -121,6 +122,17 @@ jobs: MODEL_FLEET_PROBE_URL: https://nodeslide.vercel.app/ MODEL_FLEET_PROBE_WORKFLOW_RUN_URL: ${{ steps.deployed.outputs.url }} run: npm run capture:free-router:structured:prod + - name: Capture the routed-executor split receipt for a manual operator probe + id: executor_split + if: always() && github.event_name == 'workflow_dispatch' + continue-on-error: true + env: + CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }} + GITHUB_TOKEN: ${{ github.token }} + MODEL_FLEET_PROBE_COMMIT_SHA: ${{ steps.deployed.outputs.sha }} + MODEL_FLEET_PROBE_URL: https://nodeslide.vercel.app/ + MODEL_FLEET_PROBE_WORKFLOW_RUN_URL: ${{ steps.deployed.outputs.url }} + run: node scripts/capture-model-fleet-probe.mjs --function runExecutorSplit --schema nodeslide.executor-split-probe/v1 --output artifacts/model-fleet/receipt-${{ steps.deployed.outputs.sha }}.json - name: Capture the production UI QA matrix id: ui_qa if: always() && github.event_name == 'workflow_dispatch' @@ -153,6 +165,7 @@ jobs: artifacts/model-fleet/model-fleet-probe.json artifacts/model-fleet/free-router-fleet-probe.json artifacts/model-fleet/free-router-structured-probe.json + artifacts/model-fleet/receipt-*.json artifacts/close-all-gaps-20260722/acceptance/ui-qa if-no-files-found: warn include-hidden-files: false @@ -163,10 +176,11 @@ jobs: OFFERED_FLEET: ${{ steps.offered_fleet.outcome }} FREE_TEXT_FLEET: ${{ steps.free_text_fleet.outcome }} FREE_STRUCTURED_FLEET: ${{ steps.free_structured_fleet.outcome }} + EXECUTOR_SPLIT: ${{ steps.executor_split.outcome }} UI_QA: ${{ steps.ui_qa.outcome }} shell: bash run: | - for outcome in "$OFFERED_FLEET" "$FREE_TEXT_FLEET" "$FREE_STRUCTURED_FLEET" "$UI_QA"; do + for outcome in "$OFFERED_FLEET" "$FREE_TEXT_FLEET" "$FREE_STRUCTURED_FLEET" "$EXECUTOR_SPLIT" "$UI_QA"; do if [[ "$outcome" != "success" ]]; then echo "::error::At least one bounded production evidence matrix is incomplete." exit 1 diff --git a/.qa/models/claude-opus-5-5/benchmark-summary.md b/.qa/models/claude-opus-5-5/benchmark-summary.md new file mode 100644 index 00000000..8ef46900 --- /dev/null +++ b/.qa/models/claude-opus-5-5/benchmark-summary.md @@ -0,0 +1,13 @@ +# Claude Opus 5.5 benchmark summary + +Evidence: 0/0 evaluated runs across 0 briefs and 0 directions on deck-gym-v1. + +- Live routes: 0 +- Degraded routes: 0 +- Live claim gate: 0/0 +- Mean claim coverage: 0 +- Qualified score: 0 +- Estimated text overflows: 0 +- Export success: 0 + +These findings describe observed behavior only. Cognitive and tool-orchestration claims remain low confidence until plan and tool traces are captured. diff --git a/.qa/models/claude-opus-5-5/capability-card.yaml b/.qa/models/claude-opus-5-5/capability-card.yaml new file mode 100644 index 00000000..6445a237 --- /dev/null +++ b/.qa/models/claude-opus-5-5/capability-card.yaml @@ -0,0 +1,37 @@ +schema_version: nodeslide.model-capability-card/v1 +profile_version: 1 +model: anthropic/claude-opus-5.5 +label: Claude Opus 5.5 +evidence_window: + attempted_runs: 0 + evaluated_runs: 0 + completed_exports: 0 + briefs: 0 + directions: 0 + harness_version: "deck-gym-v1" +observed_metrics: + live_routes: 0 + degraded_routes: 0 + live_claim_passes: 0 + mean_claim_coverage: 0 + mean_live_claim_coverage: 0 + mean_qualified_score: 0 + mean_raw_score: 0 + estimated_text_overflows: 0 + export_success_rate: 0 +failure_counts: +best_roles: + - "no full-deck role until a live-route ablation passes" +avoid_roles: + - "full-deck generator" + - "fallback authority" + - "final taste judge" +required_scaffolding: + - "no-generic-fallback" + - "independent route verification" +confidence: + cognitive_behavior: "low — no plan or reasoning traces captured" + tool_execution: "low — only browser creation and export were observed" + artifact_quality: "medium" + routing_recommendation: "low" +status: "provisional — requires skill-on versus skill-off ablation" diff --git a/.qa/models/claude-opus-5-5/findings.jsonl b/.qa/models/claude-opus-5-5/findings.jsonl new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.qa/models/claude-opus-5-5/findings.jsonl @@ -0,0 +1 @@ + diff --git a/.qa/models/claude-sonnet-5-5/benchmark-summary.md b/.qa/models/claude-sonnet-5-5/benchmark-summary.md new file mode 100644 index 00000000..ba4d4d60 --- /dev/null +++ b/.qa/models/claude-sonnet-5-5/benchmark-summary.md @@ -0,0 +1,13 @@ +# Claude Sonnet 5.5 benchmark summary + +Evidence: 0/0 evaluated runs across 0 briefs and 0 directions on deck-gym-v1. + +- Live routes: 0 +- Degraded routes: 0 +- Live claim gate: 0/0 +- Mean claim coverage: 0 +- Qualified score: 0 +- Estimated text overflows: 0 +- Export success: 0 + +These findings describe observed behavior only. Cognitive and tool-orchestration claims remain low confidence until plan and tool traces are captured. diff --git a/.qa/models/claude-sonnet-5-5/capability-card.yaml b/.qa/models/claude-sonnet-5-5/capability-card.yaml new file mode 100644 index 00000000..bb04d6bf --- /dev/null +++ b/.qa/models/claude-sonnet-5-5/capability-card.yaml @@ -0,0 +1,37 @@ +schema_version: nodeslide.model-capability-card/v1 +profile_version: 1 +model: anthropic/claude-sonnet-5.5 +label: Claude Sonnet 5.5 +evidence_window: + attempted_runs: 0 + evaluated_runs: 0 + completed_exports: 0 + briefs: 0 + directions: 0 + harness_version: "deck-gym-v1" +observed_metrics: + live_routes: 0 + degraded_routes: 0 + live_claim_passes: 0 + mean_claim_coverage: 0 + mean_live_claim_coverage: 0 + mean_qualified_score: 0 + mean_raw_score: 0 + estimated_text_overflows: 0 + export_success_rate: 0 +failure_counts: +best_roles: + - "no full-deck role until a live-route ablation passes" +avoid_roles: + - "full-deck generator" + - "fallback authority" + - "final taste judge" +required_scaffolding: + - "no-generic-fallback" + - "independent route verification" +confidence: + cognitive_behavior: "low — no plan or reasoning traces captured" + tool_execution: "low — only browser creation and export were observed" + artifact_quality: "medium" + routing_recommendation: "low" +status: "provisional — requires skill-on versus skill-off ablation" diff --git a/.qa/models/claude-sonnet-5-5/findings.jsonl b/.qa/models/claude-sonnet-5-5/findings.jsonl new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.qa/models/claude-sonnet-5-5/findings.jsonl @@ -0,0 +1 @@ + diff --git a/.qa/models/gemini-3-8-flash/benchmark-summary.md b/.qa/models/gemini-3-8-flash/benchmark-summary.md new file mode 100644 index 00000000..ded87857 --- /dev/null +++ b/.qa/models/gemini-3-8-flash/benchmark-summary.md @@ -0,0 +1,13 @@ +# Gemini 3.8 Flash benchmark summary + +Evidence: 0/0 evaluated runs across 0 briefs and 0 directions on deck-gym-v1. + +- Live routes: 0 +- Degraded routes: 0 +- Live claim gate: 0/0 +- Mean claim coverage: 0 +- Qualified score: 0 +- Estimated text overflows: 0 +- Export success: 0 + +These findings describe observed behavior only. Cognitive and tool-orchestration claims remain low confidence until plan and tool traces are captured. diff --git a/.qa/models/gemini-3-8-flash/capability-card.yaml b/.qa/models/gemini-3-8-flash/capability-card.yaml new file mode 100644 index 00000000..5e05caa2 --- /dev/null +++ b/.qa/models/gemini-3-8-flash/capability-card.yaml @@ -0,0 +1,37 @@ +schema_version: nodeslide.model-capability-card/v1 +profile_version: 1 +model: google/gemini-3.8-flash +label: Gemini 3.8 Flash +evidence_window: + attempted_runs: 0 + evaluated_runs: 0 + completed_exports: 0 + briefs: 0 + directions: 0 + harness_version: "deck-gym-v1" +observed_metrics: + live_routes: 0 + degraded_routes: 0 + live_claim_passes: 0 + mean_claim_coverage: 0 + mean_live_claim_coverage: 0 + mean_qualified_score: 0 + mean_raw_score: 0 + estimated_text_overflows: 0 + export_success_rate: 0 +failure_counts: +best_roles: + - "no full-deck role until a live-route ablation passes" +avoid_roles: + - "full-deck generator" + - "fallback authority" + - "final taste judge" +required_scaffolding: + - "no-generic-fallback" + - "independent route verification" +confidence: + cognitive_behavior: "low — no plan or reasoning traces captured" + tool_execution: "low — only browser creation and export were observed" + artifact_quality: "medium" + routing_recommendation: "low" +status: "provisional — requires skill-on versus skill-off ablation" diff --git a/.qa/models/gemini-3-8-flash/findings.jsonl b/.qa/models/gemini-3-8-flash/findings.jsonl new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.qa/models/gemini-3-8-flash/findings.jsonl @@ -0,0 +1 @@ + diff --git a/.qa/models/gpt-6-1-sol/benchmark-summary.md b/.qa/models/gpt-6-1-sol/benchmark-summary.md new file mode 100644 index 00000000..8c2067bf --- /dev/null +++ b/.qa/models/gpt-6-1-sol/benchmark-summary.md @@ -0,0 +1,13 @@ +# GPT-6.1 Sol benchmark summary + +Evidence: 0/0 evaluated runs across 0 briefs and 0 directions on deck-gym-v1. + +- Live routes: 0 +- Degraded routes: 0 +- Live claim gate: 0/0 +- Mean claim coverage: 0 +- Qualified score: 0 +- Estimated text overflows: 0 +- Export success: 0 + +These findings describe observed behavior only. Cognitive and tool-orchestration claims remain low confidence until plan and tool traces are captured. diff --git a/.qa/models/gpt-6-1-sol/capability-card.yaml b/.qa/models/gpt-6-1-sol/capability-card.yaml new file mode 100644 index 00000000..e76b9276 --- /dev/null +++ b/.qa/models/gpt-6-1-sol/capability-card.yaml @@ -0,0 +1,37 @@ +schema_version: nodeslide.model-capability-card/v1 +profile_version: 1 +model: openai/gpt-6.1-sol +label: GPT-6.1 Sol +evidence_window: + attempted_runs: 0 + evaluated_runs: 0 + completed_exports: 0 + briefs: 0 + directions: 0 + harness_version: "deck-gym-v1" +observed_metrics: + live_routes: 0 + degraded_routes: 0 + live_claim_passes: 0 + mean_claim_coverage: 0 + mean_live_claim_coverage: 0 + mean_qualified_score: 0 + mean_raw_score: 0 + estimated_text_overflows: 0 + export_success_rate: 0 +failure_counts: +best_roles: + - "no full-deck role until a live-route ablation passes" +avoid_roles: + - "full-deck generator" + - "fallback authority" + - "final taste judge" +required_scaffolding: + - "no-generic-fallback" + - "independent route verification" +confidence: + cognitive_behavior: "low — no plan or reasoning traces captured" + tool_execution: "low — only browser creation and export were observed" + artifact_quality: "medium" + routing_recommendation: "low" +status: "provisional — requires skill-on versus skill-off ablation" diff --git a/.qa/models/gpt-6-1-sol/findings.jsonl b/.qa/models/gpt-6-1-sol/findings.jsonl new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.qa/models/gpt-6-1-sol/findings.jsonl @@ -0,0 +1 @@ + diff --git a/.tours/02-agent-execution.tour b/.tours/02-agent-execution.tour index 2fe243c6..ecaef996 100644 --- a/.tours/02-agent-execution.tour +++ b/.tours/02-agent-execution.tour @@ -15,17 +15,17 @@ }, { "file": "mcp/src/lib/nodeslideTools.ts", - "line": 414, + "line": 417, "description": "**A coding agent is a first-class user.**\n\nThis is not a second backend. Each MCP tool validates its arguments with Zod and then calls the *same* Convex function the browser calls.\n\nOne write path means an agent cannot bypass the version check — which is the entire safety argument for letting an agent edit a deck at all." }, { "file": "mcp/src/lib/nodeslideTools.ts", - "line": 430, + "line": 433, "description": "**Read tools declare themselves read-only.**\n\n`readOnlyHint: true`, `destructiveHint: false`, `openWorldHint: false` — these annotations are how the calling agent's host decides whether to ask a human first.\n\nThe description also states what the tool will *not* do: it never returns the owner key." }, { "file": "mcp/src/lib/nodeslideTools.ts", - "line": 540, + "line": 543, "description": "**The write tool proposes; it does not commit.**\n\nIt returns an `unappliedProposalReceipt`. Committing is a *separate* tool — `nodeslide.accept_proposal`, a few lines below — which is described as an 'Explicit review action'.\n\nAn agent can produce a proposal; accepting it is its own deliberate call. That asymmetry is the product, not a limitation of the integration." }, { diff --git a/artifacts/node-gym/nodeslide-deck-gym-v2/configuration-validation.json b/artifacts/node-gym/nodeslide-deck-gym-v2/configuration-validation.json index 819370c9..237b9681 100644 --- a/artifacts/node-gym/nodeslide-deck-gym-v2/configuration-validation.json +++ b/artifacts/node-gym/nodeslide-deck-gym-v2/configuration-validation.json @@ -1,7 +1,7 @@ { "schemaVersion": "nodekit.gym-config-validation/v1", "gymVersion": "nodeslide-deck-gym-v2", - "configDigest": "sha256:e7aef1f13cccfbe86c11146d4c960ac8b29b2464ed1df2a0235cc77b478b3939", + "configDigest": "sha256:57379ad92e0c766a41718c76a4807cec9589ebb89d91d8c0cec89a7daff28903", "status": "passed", "matrixSize": 720, "failures": [] diff --git a/artifacts/node-gym/nodeslide-deck-gym-v2/matrix.json b/artifacts/node-gym/nodeslide-deck-gym-v2/matrix.json index bbba8c4d..e63a76a0 100644 --- a/artifacts/node-gym/nodeslide-deck-gym-v2/matrix.json +++ b/artifacts/node-gym/nodeslide-deck-gym-v2/matrix.json @@ -1,7 +1,7 @@ { "schemaVersion": "nodekit.gym-matrix/v1", "gymVersion": "nodeslide-deck-gym-v2", - "configDigest": "sha256:e7aef1f13cccfbe86c11146d4c960ac8b29b2464ed1df2a0235cc77b478b3939", + "configDigest": "sha256:57379ad92e0c766a41718c76a4807cec9589ebb89d91d8c0cec89a7daff28903", "runCount": 720, "pairedComparisonReady": true, "promotionAutoApply": false, @@ -1193,7 +1193,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -1232,7 +1237,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -1271,7 +1281,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -1310,7 +1325,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -1349,7 +1369,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -1388,7 +1413,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -1427,7 +1457,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -1466,7 +1501,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -1505,7 +1545,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -1544,7 +1589,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -1583,7 +1633,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -1622,7 +1677,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -1661,7 +1721,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -1700,7 +1765,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -1739,7 +1809,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -4703,7 +4778,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -4742,7 +4822,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -4781,7 +4866,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -4820,7 +4910,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -4859,7 +4954,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -4898,7 +4998,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -4937,7 +5042,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -4976,7 +5086,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -5015,7 +5130,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -5054,7 +5174,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -5093,7 +5218,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -5132,7 +5262,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -5171,7 +5306,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -5210,7 +5350,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -5249,7 +5394,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -8213,7 +8363,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -8252,7 +8407,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -8291,7 +8451,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -8330,7 +8495,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -8369,7 +8539,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -8408,7 +8583,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -8447,7 +8627,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -8486,7 +8671,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -8525,7 +8715,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -8564,7 +8759,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -8603,7 +8803,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -8642,7 +8847,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -8681,7 +8891,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -8720,7 +8935,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -8759,7 +8979,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -11723,7 +11948,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -11762,7 +11992,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -11801,7 +12036,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -11840,7 +12080,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -11879,7 +12124,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -11918,7 +12168,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -11957,7 +12212,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -11996,7 +12256,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -12035,7 +12300,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -12074,7 +12344,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -12113,7 +12388,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -12152,7 +12432,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -12191,7 +12476,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -12230,7 +12520,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -12269,7 +12564,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -15233,7 +15533,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -15272,7 +15577,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -15311,7 +15621,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -15350,7 +15665,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -15389,7 +15709,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -15428,7 +15753,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -15467,7 +15797,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -15506,7 +15841,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -15545,7 +15885,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -15584,7 +15929,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -15623,7 +15973,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -15662,7 +16017,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -15701,7 +16061,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -15740,7 +16105,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -15779,7 +16149,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -18743,7 +19118,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -18782,7 +19162,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -18821,7 +19206,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -18860,7 +19250,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -18899,7 +19294,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -18938,7 +19338,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -18977,7 +19382,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -19016,7 +19426,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -19055,7 +19470,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -19094,7 +19514,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -19133,7 +19558,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -19172,7 +19602,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -19211,7 +19646,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -19250,7 +19690,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -19289,7 +19734,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -22253,7 +22703,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -22292,7 +22747,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -22331,7 +22791,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -22370,7 +22835,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -22409,7 +22879,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -22448,7 +22923,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -22487,7 +22967,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -22526,7 +23011,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -22565,7 +23055,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -22604,7 +23099,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -22643,7 +23143,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -22682,7 +23187,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -22721,7 +23231,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -22760,7 +23275,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -22799,7 +23319,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -25763,7 +26288,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -25802,7 +26332,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -25841,7 +26376,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "light-director", @@ -25880,7 +26420,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -25919,7 +26464,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -25958,7 +26508,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "structured-planner", @@ -25997,7 +26552,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -26036,7 +26596,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -26075,7 +26640,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "bounded-executor", @@ -26114,7 +26684,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -26153,7 +26728,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -26192,7 +26772,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "repair-specialist", @@ -26231,7 +26816,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -26270,7 +26860,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", @@ -26309,7 +26904,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, "harness": { "id": "router-robustness", diff --git a/benchmarks/deck-gym/v2/gym.json b/benchmarks/deck-gym/v2/gym.json index f893e746..8581f043 100644 --- a/benchmarks/deck-gym/v2/gym.json +++ b/benchmarks/deck-gym/v2/gym.json @@ -298,7 +298,12 @@ "provider": "openrouter", "route": "openai/gpt-oss-20b:free", "returnedModelRequired": true, - "cohort": "small-legacy" + "cohort": "small-legacy", + "execution": { + "disabled": true, + "since": "2026-10-10", + "reason": "unlisted on OpenRouter (GET /api/v1/models, 2026-10-10)" + } }, { "id": "google/gemma-4-26b-a4b-it:free", diff --git a/convex/lib/nodeslideAutoRoutingPolicy.test.ts b/convex/lib/nodeslideAutoRoutingPolicy.test.ts index e37555db..6d434189 100644 --- a/convex/lib/nodeslideAutoRoutingPolicy.test.ts +++ b/convex/lib/nodeslideAutoRoutingPolicy.test.ts @@ -184,9 +184,13 @@ describe('NodeSlide fail-closed auto routing policy', () => { }); describe('per-request cost cap', () => { + // The estimate is derived from the installed pi-ai OpenRouter catalog, so it moves with the SDK. + // pi-ai 0.80.6 priced z-ai/glm-5.2 at 0.532 / 1.672 USD per million (1k in + 1k out = 2_204 + // micro-USD; caps 0.002203 / 0.002204). pi-ai 1.1.0 prices it at 0.171 / 7.2 (7_371 micro-USD). + // The one-micro-dollar boundary is preserved: below by 1, exactly equal, well above. it.each([ - { name: 'one micro-dollar below estimate', cap: 0.002203, kind: 'refused' }, - { name: 'exactly equal to estimate', cap: 0.002204, kind: 'selected' }, + { name: 'one micro-dollar below estimate', cap: 0.00737, kind: 'refused' }, + { name: 'exactly equal to estimate', cap: 0.007371, kind: 'selected' }, { name: 'well above estimate', cap: 1, kind: 'selected' }, ] as const)('$name is $kind', ({ cap, kind }) => { const decision = decideNodeSlideAutoRoute(input({ maxUsd: cap })); @@ -194,12 +198,12 @@ describe('NodeSlide fail-closed auto routing policy', () => { expect(decision.kind).toBe(kind); expect(decision.costEstimate).toMatchObject({ status: 'estimated', - totalMicroUsd: 2_204, - totalUsd: 0.002204, + totalMicroUsd: 7_371, + totalUsd: 0.007371, pricing: { source: 'pi-ai-openrouter-catalog', - inputUsdPerMillionTokens: 0.532, - outputUsdPerMillionTokens: 1.672, + inputUsdPerMillionTokens: 0.171, + outputUsdPerMillionTokens: 7.2, }, }); if (kind === 'refused') { diff --git a/convex/lib/nodeslideEditPlanner.test.ts b/convex/lib/nodeslideEditPlanner.test.ts index 0d602ed1..37ca29ac 100644 --- a/convex/lib/nodeslideEditPlanner.test.ts +++ b/convex/lib/nodeslideEditPlanner.test.ts @@ -323,7 +323,7 @@ describe('NodeSlide baseline edit planner extraction', () => { it('passes the user-selected catalog model to the pi-ai provider boundary', async () => { const { snapshot, target, scope } = fixture(); const planningInput = input(snapshot, target, scope); - planningInput.request.providerModel = 'google/gemini-3.5-flash'; + planningInput.request.providerModel = 'google/gemini-3.8-flash'; const provider = vi.fn(async () => ({ ok: true, value: { @@ -339,7 +339,7 @@ describe('NodeSlide baseline edit planner extraction', () => { }, telemetry: { provider: NODESLIDE_EDIT_PROVIDER, - model: 'google/gemini-3.5-flash', + model: 'google/gemini-3.8-flash', costMicroUsd: 900, inputTokens: 80, outputTokens: 20, @@ -349,9 +349,9 @@ describe('NodeSlide baseline edit planner extraction', () => { const result = await planNodeSlideEdit(planningInput, { callProvider: provider }); expect(result.ok).toBe(true); - expect(provider.mock.calls[0]?.[0].model).toBe('google/gemini-3.5-flash'); + expect(provider.mock.calls[0]?.[0].model).toBe('google/gemini-3.8-flash'); if (result.ok) { - expect(result.receipt.providerTelemetry?.model).toBe('google/gemini-3.5-flash'); + expect(result.receipt.providerTelemetry?.model).toBe('google/gemini-3.8-flash'); } }); diff --git a/convex/lib/nodeslideEditVerifyAction.test.ts b/convex/lib/nodeslideEditVerifyAction.test.ts index 4febd5ba..3148b2ff 100644 --- a/convex/lib/nodeslideEditVerifyAction.test.ts +++ b/convex/lib/nodeslideEditVerifyAction.test.ts @@ -272,7 +272,7 @@ describe('proposeEdit B4 tool loop messages', () => { }, telemetry: { provider: 'openrouter', - model: 'google/gemini-3.5-flash', + model: 'google/gemini-3.8-flash', inputTokens: 5, outputTokens: 3, costMicroUsd: 1, @@ -336,7 +336,8 @@ describe('proposeEdit B4 tool loop messages', () => { const executorStep = steps.find((step) => step.toolName === 'executor'); const verifyStep = steps.find((step) => step.toolName === 'verify'); expect(plannerStep?.spanModel).toBe('moonshotai/kimi-k3'); - expect(executorStep?.spanModel).toBe('google/gemini-3.5-flash'); + // Executor moved off Gemini 3.5 Flash: Google deprecated it on 2026-10-08 (auto-routed to 3.6). + expect(executorStep?.spanModel).toBe('google/gemini-3.8-flash'); expect(verifyStep?.message).toContain('shadow snapshot'); }); }); diff --git a/convex/lib/nodeslideExecutorSplitProbe.ts b/convex/lib/nodeslideExecutorSplitProbe.ts new file mode 100644 index 00000000..683113ac --- /dev/null +++ b/convex/lib/nodeslideExecutorSplitProbe.ts @@ -0,0 +1,195 @@ +import type { DeckSnapshot, PatchScope } from '../../shared/nodeslide'; +import { NODESLIDE_RUN_BUDGET_BOUNDS } from '../../shared/nodeslideRunBudget'; +import { + type NodeSlideBudgetLedgerClient, + createNodeSlideBudgetedEditDispatch, +} from './nodeslideBudgetedProvider'; +import { type NodeSlideEditPlanningRequest, planNodeSlideEditRouted } from './nodeslideEditPlanner'; +import { nodeslideStableId } from './nodeslideIds'; +import { type NodeSlideProviderTelemetry, callNodeSlideFreeJson } from './nodeslideProvider'; +import { buildGoldenNodeSlide } from './nodeslideSeed'; + +/** + * Candidate-bound executor receipt for the routed copy executor (SPEC Part A, section A.2.8). + * + * Situation: NodeSlide's edit planner is a premium model; when its plan rewrites two or more text + * elements it hands the wording to a cheap "executor" model. Google retired the executor + * (Gemini 3.5 Flash) on 2026-10-08, so the executor id changed. The only honest proof that the new + * executor really runs is one edit turn that is split exactly that way, through the same + * reserve-before-dispatch provider production uses, with the model name the provider echoed back + * (not the one we asked for) written into the receipt. Create-and-export journeys never reach the + * executor, so they cannot stand in for this. + * + * The receipt is data only. Whether it counts as evidence is decided by `validateExecutorSplitReceipt` + * (scripts/lib/model-fleet-receipt-core.mjs), which also compares the build identity with the tested + * commit, because only the caller knows which commit was tested. + */ +export const NODESLIDE_EXECUTOR_SPLIT_PROBE_SCHEMA = 'nodeslide.executor-split-probe/v1' as const; + +/** Premium per PREMIUM_PLANNER_PATTERNS (nodeslideRoutingPolicy.ts), so the split is granted. */ +export const NODESLIDE_EXECUTOR_SPLIT_PLANNER_MODEL = 'moonshotai/kimi-k3' as const; + +export const NODESLIDE_EXECUTOR_SPLIT_DEFAULT_BUDGET_USD = 0.25 as const; + +export interface NodeSlideExecutorSplitSpan { + toolName: 'planner' | 'executor'; + spanModel: string; + /** The model string the provider returned, never the one requested. */ + responseModel: string | null; + usage: { inputTokens: number; outputTokens: number }; + costMicroUsd: number; +} + +export interface NodeSlideExecutorSplitProbeReceipt { + schemaVersion: typeof NODESLIDE_EXECUTOR_SPLIT_PROBE_SCHEMA; + routing: { + plannerModel: string; + executorModel: string | null; + reason: string; + executorOutcome: string | null; + }; + spans: NodeSlideExecutorSplitSpan[]; + budget: { + maxCostUsd: number; + plannedOperations: number; + refusals: string[]; + }; + buildIdentity: { schemaVersion: string; commitSha: string | null } | null; +} + +export function executorSplitProbeBudgetUsd(env: Record): number { + const raw = env['NODESLIDE_PROBE_BUDGET_USD']; + if (raw === undefined || raw === '') return NODESLIDE_EXECUTOR_SPLIT_DEFAULT_BUDGET_USD; + const parsed = Number(raw); + // An unparsable or non-positive ceiling is refused, never silently replaced by a larger one. + if (!Number.isFinite(parsed) || parsed <= 0) { + throw new Error('NODESLIDE_PROBE_BUDGET_USD must be a positive number of US dollars.'); + } + return Math.min(NODESLIDE_RUN_BUDGET_BOUNDS.maxCostUsd.default, parsed); +} + +function probeFixture(): { snapshot: DeckSnapshot; scope: PatchScope; slideId: string } { + const snapshot = buildGoldenNodeSlide('executor-split-probe', 1_700_000_000_000).snapshot; + const bySlide = new Map(); + for (const element of snapshot.elements) { + if (element.kind !== 'text' || element.locked) continue; + bySlide.set(element.slideId, [...(bySlide.get(element.slideId) ?? []), element]); + } + const pair = [...bySlide.values()].find((elements) => elements.length >= 2); + if (!pair) throw new Error('The probe deck fixture needs a slide with two unlocked text blocks.'); + const targets = pair.slice(0, 2); + const slideId = targets[0]?.slideId as string; + return { + snapshot, + slideId, + scope: { + kind: 'elements', + deckId: snapshot.deck.id, + slideIds: [slideId], + elementIds: targets.map((element) => element.id), + operationMode: 'copy', + }, + }; +} + +export async function runNodeSlideExecutorSplitProbe(args: { + ledger: NodeSlideBudgetLedgerClient; + buildIdentity: { schemaVersion: string; commitSha: string | null } | null; + budgetUsd: number; + now?: () => number; +}): Promise { + const { snapshot, scope, slideId } = probeFixture(); + const slide = snapshot.slides.find((candidate) => candidate.id === slideId); + if (!slide) throw new Error('The probe deck fixture lost its slide.'); + const budget = { maxCostUsd: args.budgetUsd }; + // A fresh run id per invocation: a replayed id would return the recorded result without spending. + const runId = nodeslideStableId( + 'nsrun_probe_executor_split', + String((args.now ?? Date.now)()), + NODESLIDE_EXECUTOR_SPLIT_PLANNER_MODEL, + ); + const refusals: string[] = []; + const dispatch = createNodeSlideBudgetedEditDispatch({ + runId, + budget, + metered: true, + ledger: args.ledger, + dispatch: (request, dependencies) => + callNodeSlideFreeJson( + request, + ...(dependencies?.dispatchPolicy ? [{ dispatchPolicy: dependencies.dispatchPolicy }] : []), + ), + }); + const request: NodeSlideEditPlanningRequest = { + deckId: snapshot.deck.id, + instruction: + 'Rewrite both listed text elements as crisp one-sentence executive statements. Emit one replace_text per element and a copyBriefs entry for each.', + baseDeckVersion: snapshot.deck.version, + baseSlideVersions: { [slideId]: slide.version }, + baseElementVersions: Object.fromEntries( + snapshot.elements + .filter((element) => element.slideId === slideId) + .map((element) => [element.id, element.version]), + ), + scope, + designBehavior: 'preserve', + referenceUse: 'context_only', + providerMode: 'openrouter_free', + providerModel: NODESLIDE_EXECUTOR_SPLIT_PLANNER_MODEL, + providerEffort: 'low', + }; + const outcome = await planNodeSlideEditRouted( + { snapshot, scopedComment: null, request }, + { + callProvider: async (providerRequest) => { + const result = await dispatch(providerRequest); + if (!result.ok) refusals.push(result.reason); + return result; + }, + }, + ); + if (!outcome.ok) { + return { + schemaVersion: NODESLIDE_EXECUTOR_SPLIT_PROBE_SCHEMA, + routing: { + plannerModel: NODESLIDE_EXECUTOR_SPLIT_PLANNER_MODEL, + executorModel: null, + reason: 'planner_failed', + executorOutcome: null, + }, + spans: [], + budget: { maxCostUsd: args.budgetUsd, plannedOperations: 0, refusals }, + buildIdentity: args.buildIdentity, + }; + } + const routing = outcome.routing; + const spans: NodeSlideExecutorSplitSpan[] = []; + const plannerTelemetry = outcome.receipt.providerTelemetry; + if (plannerTelemetry) spans.push(span('planner', plannerTelemetry)); + if (routing?.executorTelemetry) spans.push(span('executor', routing.executorTelemetry)); + return { + schemaVersion: NODESLIDE_EXECUTOR_SPLIT_PROBE_SCHEMA, + routing: { + plannerModel: routing?.plannerModel ?? NODESLIDE_EXECUTOR_SPLIT_PLANNER_MODEL, + executorModel: routing?.executorModel ?? null, + reason: routing?.reason ?? 'not_routed', + executorOutcome: routing?.executorOutcome ?? null, + }, + spans, + budget: { maxCostUsd: args.budgetUsd, plannedOperations: outcome.operations.length, refusals }, + buildIdentity: args.buildIdentity, + }; +} + +function span( + toolName: 'planner' | 'executor', + telemetry: NodeSlideProviderTelemetry, +): NodeSlideExecutorSplitSpan { + return { + toolName, + spanModel: telemetry.requestedModel ?? telemetry.model, + responseModel: telemetry.actualModel ?? null, + usage: { inputTokens: telemetry.inputTokens, outputTokens: telemetry.outputTokens }, + costMicroUsd: telemetry.costMicroUsd, + }; +} diff --git a/convex/lib/nodeslideProvider.requestShape.test.ts b/convex/lib/nodeslideProvider.requestShape.test.ts new file mode 100644 index 00000000..96fc1d40 --- /dev/null +++ b/convex/lib/nodeslideProvider.requestShape.test.ts @@ -0,0 +1,254 @@ +/** + * Request-shape proof for the 2026-10 model refresh (SPEC Part A rule 6, section A.2.8). + * + * Situation: a user picks Claude Sonnet 5.5, Claude Opus 5.5, Gemini 3.8 Flash or GPT-6.1 Sol in + * the NodeSlide model picker, or the edit planner hands bulk copy work to the routed executor. + * Those vendors reject some parameters outright (a 400, not a warning): sampling parameters on + * Claude 5.5 and GPT-6, a disabled thinking block on Opus 5.5, Gemini's deprecated sampling. The + * wrong wire id is just as fatal. Nothing here calls a provider: the real request is built by this + * repo's own provider code (pi-ai plus `nodeSlideProviderPayload`) and the HTTP transport is a fake + * `fetch` that records what would have been sent. + * + * Wire ids are SPEC section 1.2, `openrouter` column, and nothing else. + */ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { + NODESLIDE_AGENT_MODELS, + NODESLIDE_OFFERED_AGENT_MODELS, + type NodeSlideAgentModelId, + nodeSlideAgentModel, +} from '../../shared/nodeslide'; +import { + callNodeSlideFreeJson, + nodeSlideModelProbeProfile, + openrouterProviderWithOverrides, + probeNodeSlideModelOnce, +} from './nodeslideProvider'; +import { + NODESLIDE_ROUTING_EXECUTOR_MODEL, + resolveNodeSlideRouting, +} from './nodeslideRoutingPolicy'; + +/** SPEC section 1.2, `openrouter` column. */ +const WIRE_ID = { + sonnet55: 'anthropic/claude-sonnet-5.5', + opus55: 'anthropic/claude-opus-5.5', + gemini38Flash: 'google/gemini-3.8-flash', + gpt61Sol: 'openai/gpt-6.1-sol', +} as const satisfies Record; + +/** Keys a Claude 5.5 / GPT-6 / Gemini 3.6+ request must never carry (SPEC section 1.3). */ +const FORBIDDEN_SAMPLING_KEYS = ['temperature', 'top_p', 'top_k'] as const; +const FORBIDDEN_LEGACY_KEYS = [ + 'thinking', + 'budget_tokens', + 'thinking_budget', + 'candidate_count', + 'logprobs', + 'top_logprobs', + 'prefill', +] as const; + +interface CapturedRequest { + url: string; + body: Record; +} + +const sseDone = [ + 'data: {"id":"gen-fake","model":"fake/echo","choices":[{"index":0,"delta":{"role":"assistant","content":"{\\"ok\\":true}"},"finish_reason":null}]}\n\n', + 'data: {"id":"gen-fake","model":"fake/echo","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":2,"total_tokens":5}}\n\n', + 'data: [DONE]\n\n', +].join(''); + +const originalKey = process.env['OPENROUTER_API_KEY']; +let captured: CapturedRequest[] = []; + +beforeEach(() => { + captured = []; + // A fake key so pi-ai builds the request; the transport below never leaves the process. + process.env['OPENROUTER_API_KEY'] = 'sk-or-test-fake-not-a-credential'; + vi.stubGlobal('fetch', async (input: unknown, init?: { body?: unknown }) => { + const url = + typeof input === 'string' ? input : ((input as { url?: string }).url ?? String(input)); + captured.push({ url, body: JSON.parse(String(init?.body ?? '{}')) as Record }); + return new Response(sseDone, { status: 200, headers: { 'content-type': 'text/event-stream' } }); + }); +}); + +afterEach(() => { + vi.unstubAllGlobals(); + if (originalKey === undefined) Reflect.deleteProperty(process.env, 'OPENROUTER_API_KEY'); + else process.env['OPENROUTER_API_KEY'] = originalKey; +}); + +function expectNoForbiddenKeys(body: Record) { + for (const key of [...FORBIDDEN_SAMPLING_KEYS, ...FORBIDDEN_LEGACY_KEYS]) { + expect(Object.keys(body), `request must not carry "${key}"`).not.toContain(key); + } + // A disabled reasoning block is a 400 on Opus 5.5 and Sonnet 5.5; effort must be explicit. + const reasoning = body['reasoning'] as { enabled?: boolean; effort?: string } | undefined; + expect(reasoning?.enabled).toBeUndefined(); + expect(typeof reasoning?.effort).toBe('string'); +} + +describe('the new catalog rows build refresh-safe requests', () => { + for (const [label, modelId] of Object.entries(WIRE_ID) as [string, NodeSlideAgentModelId][]) { + it(`${label}: probe request carries the SPEC 1.2 wire id and none of the forbidden keys`, async () => { + const route = nodeSlideAgentModel(modelId); + // The row must exist (an unknown id silently falls back to the first catalog row). + expect(route.id).toBe(modelId); + expect(route.upstreamId).toBe(modelId); + expect(route.provider).toBe('openrouter'); + expect(route.supportsTemperature).toBe(false); + expect(route.productionEnabled).toBe(true); + + await probeNodeSlideModelOnce(modelId); + + expect(captured).toHaveLength(1); + const [request] = captured; + expect(request?.url).toBe('https://openrouter.ai/api/v1/chat/completions'); + expect(request?.body['model']).toBe(modelId); + expectNoForbiddenKeys(request?.body ?? {}); + const budgetKey = ['max_tokens', 'max_completion_tokens'].find( + (key) => key in (request?.body ?? {}), + ); + expect(budgetKey).toBeDefined(); + expect(request?.body[budgetKey as string]).toBe( + nodeSlideModelProbeProfile(modelId).maxTokens, + ); + }); + } + + it('Opus 5.5 never relies on the vendor default effort: every request names one', async () => { + // Opus 5.5 defaults to medium on the vendor side (Opus 5 was high). NodeSlide's own default + // is 'high' and it is always sent, so the vendor default can never apply. + await callNodeSlideFreeJson({ + systemPrompt: 'Return JSON.', + userText: '{}', + maxTokens: 500, + model: WIRE_ID.opus55, + }); + expect(captured.length).toBeGreaterThan(0); + for (const request of captured) { + expect(request.body['model']).toBe(WIRE_ID.opus55); + expect((request.body['reasoning'] as { effort: string }).effort).toBe('high'); + expectNoForbiddenKeys(request.body); + } + }); + + it('every offered row is a priced, temperature-free-or-declared route', () => { + for (const row of NODESLIDE_OFFERED_AGENT_MODELS) { + const id = row.id as NodeSlideAgentModelId; + if ( + id.startsWith('anthropic/claude-') || + id === WIRE_ID.gpt61Sol || + id === WIRE_ID.gemini38Flash + ) { + expect(row.supportsTemperature, `${id} rejects sampling parameters`).toBe(false); + } + } + }); +}); + +describe('Claude rows keep the OpenRouter chat-completions endpoint under pi-ai 1.1.0', () => { + it('pins every bundled anthropic-messages OpenRouter row to /api/v1 chat-completions', () => { + // pi-ai 1.1.0 ships these as api "anthropic-messages" at https://openrouter.ai/api; sent through + // this provider's chat-completions client that is POST /api/chat/completions, not an OpenRouter + // endpoint. The override must normalize them. + const claudeRows = openrouterProviderWithOverrides() + .getModels() + .filter((model) => model.id.startsWith('anthropic/claude-')); + expect(claudeRows.length).toBeGreaterThan(0); + for (const model of claudeRows) { + expect(model.api, model.id).toBe('openai-completions'); + expect(model.baseUrl, model.id).toBe('https://openrouter.ai/api/v1'); + } + }); + + it('keeps the pre-existing Claude rows (sonnet-5, fable-5) on a valid endpoint too', async () => { + for (const modelId of ['anthropic/claude-sonnet-5', 'anthropic/claude-fable-5'] as const) { + captured = []; + await probeNodeSlideModelOnce(modelId); + expect(captured[0]?.url, modelId).toBe('https://openrouter.ai/api/v1/chat/completions'); + expect(captured[0]?.body['model']).toBe(modelId); + expect(Object.keys(captured[0]?.body ?? {})).not.toContain('temperature'); + } + }); +}); + +describe('the routed executor (SPEC 2026-10-08 Gemini 3.5 Flash deprecation)', () => { + it('routes bulk copy to Gemini 3.8 Flash and the request names exactly that id', async () => { + const decision = resolveNodeSlideRouting({ + task: 'edit_plan', + requestedModel: 'moonshotai/kimi-k3', + replaceTextOps: 3, + }); + expect(decision.reason).toBe('split_premium_planner_bulk_copy'); + expect(decision.executorModel).toBe(WIRE_ID.gemini38Flash); + expect(NODESLIDE_ROUTING_EXECUTOR_MODEL).toBe(WIRE_ID.gemini38Flash); + + await callNodeSlideFreeJson({ + systemPrompt: 'Rewrite the copy.', + userText: '{}', + maxTokens: 500, + model: decision.executorModel as NodeSlideAgentModelId, + reasoningEffort: 'low', + }); + expect(captured.length).toBeGreaterThan(0); + for (const request of captured) { + expect(request.body['model']).toBe('google/gemini-3.8-flash'); + expect(request.body['model']).not.toBe('google/gemini-3.5-flash'); + expectNoForbiddenKeys(request.body); + } + }); + + it('sends the edit patch to Gemini 3.8 Flash as json_object, decided by the catalog flag', async () => { + const editPatchSchema = { + name: 'nodeslide_edit_patch', + schema: { type: 'object', properties: { operations: { type: 'array' } } }, + }; + await callNodeSlideFreeJson({ + systemPrompt: 'Return a patch.', + userText: '{}', + maxTokens: 500, + model: WIRE_ID.gemini38Flash, + reasoningEffort: 'low', + jsonSchema: editPatchSchema, + }); + const first = captured[0]; + expect(first?.body['model']).toBe(WIRE_ID.gemini38Flash); + expect(first?.body['response_format']).toEqual({ type: 'json_object' }); + expectNoForbiddenKeys(first?.body ?? {}); + + // A different schema on the same row still uses native json_schema. + captured = []; + await callNodeSlideFreeJson({ + systemPrompt: 'Return JSON.', + userText: '{}', + maxTokens: 500, + model: WIRE_ID.gemini38Flash, + reasoningEffort: 'low', + jsonSchema: { name: 'other_schema', schema: { type: 'object' } }, + }); + expect((captured[0]?.body['response_format'] as { type: string }).type).toBe('json_schema'); + }); + + it('retires the deprecated Gemini 3.5 Flash row from the offered picker but keeps it resolvable', () => { + const retired = nodeSlideAgentModel('google/gemini-3.5-flash'); + expect(retired.id).toBe('google/gemini-3.5-flash'); + expect(retired.productionEnabled).toBe(false); + expect(NODESLIDE_OFFERED_AGENT_MODELS.map((row) => row.id)).not.toContain( + 'google/gemini-3.5-flash', + ); + }); + + it('removes gpt-oss-20b:free from the free-router candidates but keeps the row', () => { + const row = nodeSlideAgentModel('openai/gpt-oss-20b:free'); + expect(row.id).toBe('openai/gpt-oss-20b:free'); + expect(row.productionEnabled).toBe(false); + expect('freeRouterCandidate' in row).toBe(false); + expect(NODESLIDE_AGENT_MODELS.some((model) => model.id === 'openai/gpt-oss-20b:free')).toBe( + true, + ); + }); +}); diff --git a/convex/lib/nodeslideProvider.test.ts b/convex/lib/nodeslideProvider.test.ts index bdd7732e..54b34502 100644 --- a/convex/lib/nodeslideProvider.test.ts +++ b/convex/lib/nodeslideProvider.test.ts @@ -141,7 +141,9 @@ describe('NodeSlide named pi-ai JSON provider', () => { expect(matches).toHaveLength(1); expect(matches[0]).toMatchObject({ reasoning: true, - cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, + // USD per million tokens; was { input: 3, output: 15, cacheRead: 0.3 } on 2026-07-28. + // Equals nodeSlideModelPricing('moonshotai/kimi-k3') (convex/nodeslideModelPricing.test.ts). + cost: { input: 0.7, output: 15, cacheRead: 0.32, cacheWrite: 0 }, contextWindow: 1_048_576, compat: { supportsReasoningEffort: true, @@ -156,8 +158,12 @@ describe('NodeSlide named pi-ai JSON provider', () => { const models = openrouterProviderWithOverrides().getModels(); for (const id of [ 'anthropic/claude-fable-5', + 'anthropic/claude-sonnet-5.5', + 'anthropic/claude-opus-5.5', 'google/gemini-3.5-flash', + 'google/gemini-3.8-flash', 'google/gemini-3.1-pro-preview', + 'openai/gpt-6.1-sol', ]) { expect(models.find((model) => model.id === id)).toMatchObject({ reasoning: true }); } @@ -625,6 +631,19 @@ describe('NodeSlide named pi-ai JSON provider', () => { reasoningEffort: 'low', maxTokens: 256, }); + // The 2026-10 additions: adaptive thinking counts toward max_tokens, so the Claude 5.5 and + // GPT-6.1 probes get Fable's headroom instead of the 64-token default that starves them. + for (const id of [ + 'anthropic/claude-sonnet-5.5', + 'anthropic/claude-opus-5.5', + 'openai/gpt-6.1-sol', + ] as const) { + expect(nodeSlideModelProbeProfile(id)).toEqual({ reasoningEffort: 'low', maxTokens: 2_048 }); + } + expect(nodeSlideModelProbeProfile('google/gemini-3.8-flash')).toEqual({ + reasoningEffort: 'low', + maxTokens: 256, + }); }); it('returns a sanitized failed receipt when a fleet route times out', async () => { diff --git a/convex/lib/nodeslideProvider.ts b/convex/lib/nodeslideProvider.ts index ca72c245..3cdba6ce 100644 --- a/convex/lib/nodeslideProvider.ts +++ b/convex/lib/nodeslideProvider.ts @@ -17,6 +17,7 @@ import { type NodeSlideReasoningEffort, isNodeSlideAgentModelId, nodeSlideAgentModel, + nodeSlideEditPatchStructuredOutputMode, nodeSlideModelSupportsReasoningEffort, } from '../../shared/nodeslide'; @@ -66,10 +67,11 @@ function nebiusProvider() { }); } -// Kimi K3 is newer than pi-ai's bundled OpenRouter catalog, so we register the -// current OpenRouter contract explicitly instead of inheriting Moonshot-direct -// compatibility defaults. -const NODESLIDE_KIMI_K3: Model<'openai-completions'> = { +// Kimi K3 is registered explicitly so OpenRouter's normalized reasoning contract and our +// price (pricingAsOf = NODESLIDE_MODEL_PRICING_VERIFIED_AT) win over bundled metadata instead of +// inheriting Moonshot-direct compatibility defaults. USD per million tokens; the agreement test in +// convex/nodeslideModelPricing.test.ts asserts these equal nodeSlideModelPricing('moonshotai/kimi-k3'). +export const NODESLIDE_KIMI_K3: Model<'openai-completions'> = { id: 'moonshotai/kimi-k3', name: 'MoonshotAI: Kimi K3', api: 'openai-completions', @@ -77,7 +79,7 @@ const NODESLIDE_KIMI_K3: Model<'openai-completions'> = { baseUrl: 'https://openrouter.ai/api/v1', reasoning: true, input: ['text'], - cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 }, + cost: { input: 0.7, output: 15, cacheRead: 0.32, cacheWrite: 0 }, contextWindow: 1_048_576, maxTokens: 100_352, compat: { @@ -97,12 +99,37 @@ export const NODESLIDE_OPENROUTER_MODEL_OVERRIDES: readonly Model<'openai-comple NODESLIDE_KIMI_K3, ]; +const OPENROUTER_CHAT_COMPLETIONS_BASE_URL = 'https://openrouter.ai/api/v1'; + +/** + * pi-ai 1.1.0 ships OpenRouter's Claude rows as `anthropic-messages` with base URL + * `https://openrouter.ai/api`. This provider speaks OpenRouter's normalized chat-completions + * contract for every route (reasoning.effort, max_price, response_format ride in that payload), so a + * Claude row left as the bundled catalog has it would be POSTed to `/api/chat/completions`, which is + * not an OpenRouter endpoint. Pin such rows to the chat-completions API and `/api/v1`, with the same + * compat pi-ai 0.80.6 carried for them (Anthropic cache_control on OpenRouter's reasoning format). + */ +function asOpenRouterChatCompletionsRoute( + model: ReturnType['getModels']>[number], +): ReturnType['getModels']>[number] { + if (model.api === 'openai-completions') return model; + return { + ...model, + api: 'openai-completions', + baseUrl: OPENROUTER_CHAT_COMPLETIONS_BASE_URL, + compat: { thinkingFormat: 'openrouter', cacheControlFormat: 'anthropic' }, + } as typeof model; +} + export function openrouterProviderWithOverrides() { const builtin = openrouterProvider(); const overridden = new Map( NODESLIDE_OPENROUTER_MODEL_OVERRIDES.map((model) => [model.id, model] as const), ); - const models = builtin.getModels().filter((model) => !overridden.has(model.id)); + const models = builtin + .getModels() + .filter((model) => !overridden.has(model.id)) + .map(asOpenRouterChatCompletionsRoute); return createProvider({ id: 'openrouter', name: 'OpenRouter', @@ -377,8 +404,13 @@ export function nodeSlideModelProbeProfile(modelId: NodeSlideAgentModelId): { case 'z-ai/glm-5.2': return { reasoningEffort: 'high', maxTokens: 512 }; case 'anthropic/claude-fable-5': + case 'anthropic/claude-sonnet-5.5': + case 'anthropic/claude-opus-5.5': + case 'openai/gpt-6.1-sol': + // Adaptive thinking counts toward max_tokens; a one-character reply must survive it. return { reasoningEffort: 'low', maxTokens: 2_048 }; case 'google/gemini-3.5-flash': + case 'google/gemini-3.8-flash': case 'google/gemini-3.1-pro-preview': return { reasoningEffort: 'low', maxTokens: 256 }; default: @@ -642,8 +674,12 @@ function preferredStructuredOutputMode( // OpenRouter's Gemini route accepts ordinary JSON schemas, but the edit planner's // dynamically scoped union is large enough to be rejected before token generation. // Keep the exact schema in the prompt and validate it locally; json_object only - // changes provider transport, never the accepted NodeSlide contract. - if (model === 'google/gemini-3.5-flash' && jsonSchema.name === 'nodeslide_edit_patch') { + // changes provider transport, never the accepted NodeSlide contract. The decision is a + // catalog flag (`structuredOutputMode`), stated per row, not a model-id literal. + if ( + jsonSchema.name === 'nodeslide_edit_patch' && + nodeSlideEditPatchStructuredOutputMode(model) === 'json_object' + ) { return 'json_object'; } return 'json_schema'; diff --git a/convex/lib/nodeslideReviewUi.test.tsx b/convex/lib/nodeslideReviewUi.test.tsx index 06716af4..20554a1e 100644 --- a/convex/lib/nodeslideReviewUi.test.tsx +++ b/convex/lib/nodeslideReviewUi.test.tsx @@ -147,12 +147,17 @@ describe('NodeSlide AI review inspector', () => { expect.arrayContaining([ 'Claude Sonnet 5 · Anthropic', 'Claude Fable 5 · Anthropic', - 'Gemini 3.5 Flash · Google', + 'Claude Sonnet 5.5 · Anthropic', + 'Claude Opus 5.5 · Anthropic', + // Gemini 3.5 Flash left the offered set: Google deprecated it on 2026-10-08. + 'Gemini 3.8 Flash · Google', 'Gemini 3.1 Pro · Google', 'GPT-5.6 Sol · OpenAI', 'GPT-5.6 Terra · OpenAI', + 'GPT-6.1 Sol · OpenAI', ]), ); + expect(modelLabels).not.toContain('Gemini 3.5 Flash · Google'); expect(markup).not.toMatch(/ai-provider-consent/); expect(createAiProviderRequest('nebius', false)).toBeNull(); diff --git a/convex/lib/nodeslideRoutedProposeEdit.test.ts b/convex/lib/nodeslideRoutedProposeEdit.test.ts index 8a20e23b..7bfade0d 100644 --- a/convex/lib/nodeslideRoutedProposeEdit.test.ts +++ b/convex/lib/nodeslideRoutedProposeEdit.test.ts @@ -176,7 +176,7 @@ describe('proposeEdit routed attribution (B2)', () => { spanModel: NODESLIDE_ROUTING_EXECUTOR_MODEL, role: 'tool', }); - expect(String(executorRow?.['message'])).toContain('Executor · Gemini 3.5 Flash'); + expect(String(executorRow?.['message'])).toContain('Executor · Gemini 3.8 Flash'); const proposal = mutations.find((args) => 'operations' in args && 'traceContext' in args); expect(proposal).toBeDefined(); diff --git a/convex/lib/nodeslideRoutingPolicy.test.ts b/convex/lib/nodeslideRoutingPolicy.test.ts index aa548dfb..e26ab435 100644 --- a/convex/lib/nodeslideRoutingPolicy.test.ts +++ b/convex/lib/nodeslideRoutingPolicy.test.ts @@ -84,7 +84,12 @@ describe('NodeSlide routing policy (B2 orchestrator/worker split)', () => { expect(isPremiumNodeSlidePlannerModel('moonshotai/kimi-k3')).toBe(true); expect(isPremiumNodeSlidePlannerModel('anthropic/claude-fable-5')).toBe(true); expect(isPremiumNodeSlidePlannerModel('openai/gpt-5.6-sol')).toBe(true); + // Gemini 3.5 Flash was the executor until Google deprecated it on 2026-10-08; 3.8 replaces it. + expect(isPremiumNodeSlidePlannerModel('google/gemini-3.8-flash')).toBe(false); expect(isPremiumNodeSlidePlannerModel('google/gemini-3.5-flash')).toBe(false); + expect(isPremiumNodeSlidePlannerModel('anthropic/claude-sonnet-5.5')).toBe(true); + expect(isPremiumNodeSlidePlannerModel('anthropic/claude-opus-5.5')).toBe(true); + expect(isPremiumNodeSlidePlannerModel('openai/gpt-6.1-sol')).toBe(true); expect(isPremiumNodeSlidePlannerModel('z-ai/glm-5.2')).toBe(false); }); }); diff --git a/convex/lib/nodeslideRoutingPolicy.ts b/convex/lib/nodeslideRoutingPolicy.ts index fc427c36..d29984b3 100644 --- a/convex/lib/nodeslideRoutingPolicy.ts +++ b/convex/lib/nodeslideRoutingPolicy.ts @@ -7,7 +7,7 @@ * contract unchanged. Keep this file dependency-free. * * Default policy: the planner is always the requested model. A cheap executor - * (Gemini 3.5 Flash) is granted ONLY when the planner is a premium model + * (Gemini 3.8 Flash) is granted ONLY when the planner is a premium model * (Kimi / Claude / GPT) AND the plan contains at least two replace_text * operations worth of copy work. Everything else runs single-model. * The executor is always advisory: on failure or timeout the planner's own @@ -16,7 +16,8 @@ export const NODESLIDE_ROUTING_POLICY_VERSION = 'nodeslide.model-routing/v1' as const; -export const NODESLIDE_ROUTING_EXECUTOR_MODEL = 'google/gemini-3.5-flash' as const; +// Gemini 3.5 Flash was deprecated by Google on 2026-10-08 (requests auto-route to 3.6). +export const NODESLIDE_ROUTING_EXECUTOR_MODEL = 'google/gemini-3.8-flash' as const; /** Minimum replace_text operations before splitting copy work to an executor. */ export const NODESLIDE_ROUTING_MIN_REPLACE_TEXT_OPS = 2 as const; diff --git a/convex/lib/nodeslideValidators.ts b/convex/lib/nodeslideValidators.ts index d88c260a..f2d7b26c 100644 --- a/convex/lib/nodeslideValidators.ts +++ b/convex/lib/nodeslideValidators.ts @@ -718,10 +718,14 @@ export const nodeslideAgentModelValidator = v.union( v.literal('z-ai/glm-5.2'), v.literal('anthropic/claude-sonnet-5'), v.literal('anthropic/claude-fable-5'), + v.literal('anthropic/claude-sonnet-5.5'), + v.literal('anthropic/claude-opus-5.5'), v.literal('google/gemini-3.5-flash'), + v.literal('google/gemini-3.8-flash'), v.literal('google/gemini-3.1-pro-preview'), v.literal('openai/gpt-5.6-sol'), v.literal('openai/gpt-5.6-terra'), + v.literal('openai/gpt-6.1-sol'), v.literal('openrouter/free'), v.literal('google/gemma-4-26b-a4b-it:free'), v.literal('google/gemma-4-31b-it:free'), diff --git a/convex/nodeslideBudgetEnforcement.test.ts b/convex/nodeslideBudgetEnforcement.test.ts index dcbaf74c..4491dcdf 100644 --- a/convex/nodeslideBudgetEnforcement.test.ts +++ b/convex/nodeslideBudgetEnforcement.test.ts @@ -222,9 +222,10 @@ describe('a metered dispatch is reserved before it is issued', () => { Math.floor((call.providerSafeOutputTokenCeiling as number) / 2), ); // The paired OpenRouter price ceiling is the table's own price for the route: - // $3/M prompt and $15/M completion, expressed in the provider's USD-per- - // million unit. A wrong table would show up here as a wrong routing ceiling. - expect(complete.mock.calls[0]?.[0].providerMaxPrice).toEqual({ prompt: 3, completion: 15 }); + // $0.70/M prompt and $15/M completion (OpenRouter catalog, 2026-10-14; was $3/$15 on + // 2026-07-28), expressed in the provider's USD-per-million unit. A wrong table would show up + // here as a wrong routing ceiling. + expect(complete.mock.calls[0]?.[0].providerMaxPrice).toEqual({ prompt: 0.7, completion: 15 }); }); it('tightens the wire ceiling when the cap, not the caller, is the binding limit', async () => { @@ -232,7 +233,7 @@ describe('a metered dispatch is reserved before it is issued', () => { const ledger = realLedgerClient(database); const complete = completionStub(); - // Enough for the conservative input estimate at $3/M, plus 3_000 micro-USD + // Enough for the conservative input estimate at $0.70/M, plus 3_000 micro-USD // of output headroom — which at $15/M buys 200 output tokens, far below the // 500 the caller asked for. Derived from the estimator rather than guessed, // so the case does not silently stop biting when the estimator changes. @@ -240,7 +241,7 @@ describe('a metered dispatch is reserved before it is issued', () => { './lib/nodeslideBudgetedProvider' ); const estimatedInputTokens = estimateNodeSlideProviderInputTokens(PROVIDER_REQUEST); - const capMicroUsd = estimatedInputTokens * 3 + 3_000; + const capMicroUsd = Math.ceil(estimatedInputTokens * 0.7) + 3_000; const result = await callNodeSlideBudgetedJson( { diff --git a/convex/nodeslideBudgetWiring.test.ts b/convex/nodeslideBudgetWiring.test.ts index dc419ca8..62a38081 100644 --- a/convex/nodeslideBudgetWiring.test.ts +++ b/convex/nodeslideBudgetWiring.test.ts @@ -471,11 +471,14 @@ describe('the price table landed, so the withholding is over', () => { }); it('exports the complete ledger lifecycle and nothing beyond it', () => { + // `receiptForRun` is the one read-only addition (SPEC Part A section A.2.8): the public meter a + // campaign runner charges a run from. Every other export is an internal mutation or query. expect(Object.keys(budgets).sort()).toEqual([ 'captureTimeout', 'create', 'finalize', 'finalizeForJob', + 'receiptForRun', 'release', 'replay', 'reserve', @@ -534,11 +537,12 @@ describe('the price table landed, so the withholding is over', () => { }); const call = database.rows('nodeslide_billable_calls')[0] as Record; - // 10_000 input tokens at $3/M = 30_000 micro-USD; 2_000 output at $15/M = + // 10_000 input tokens at $0.70/M = 7_000 micro-USD; 2_000 output at $15/M = // 30_000. The quote is the WORST case, computed before dispatch. - expect(call).toMatchObject({ status: 'reserved', quoteMicroUsd: 60_000 }); + // (Was $3/M input and 60_000 total on the 2026-07-28 catalog; refreshed 2026-10-14.) + expect(call).toMatchObject({ status: 'reserved', quoteMicroUsd: 37_000 }); expect(database.rows('nodeslide_run_budgets')[0]).toMatchObject({ - reservedMicroUsd: 60_000, + reservedMicroUsd: 37_000, actualMicroUsd: 0, }); }); @@ -567,3 +571,67 @@ describe('the price table landed, so the withholding is over', () => { expect(database.rows('nodeslide_billable_calls')).toEqual([]); }); }); + +describe('receiptForRun is the campaign meter for one run', () => { + const RUN_ID = 'nsrun-campaign-meter-1'; + + it('uses the same budget id the provider binds for that run id', async () => { + const { nodeSlideProviderBudgetId } = await import('./lib/nodeslideBudgetedProvider'); + const database = new MemoryDatabase(); + const { ctx } = recordingContext(database); + await rawHandler(budgets.create)(ctx, { + budgetId: nodeSlideProviderBudgetId(RUN_ID), + budget: { maxCostUsd: 2 }, + }); + + const receipt = await rawHandler(budgets.receiptForRun)(readContext(database), { + runId: RUN_ID, + }); + + expect(receipt).toMatchObject({ + version: 'nodeslide.run-budget-ledger-receipt/v1', + budgetId: nodeSlideProviderBudgetId(RUN_ID), + status: 'open', + cap: { maxCostMicroUsd: 2_000_000 }, + spend: { actualMicroUsd: 0, reservedMicroUsd: 0, unreconciledMicroUsd: 0 }, + }); + }); + + it('reports held reservations as spend exposure rather than hiding them', async () => { + const { nodeSlideProviderBudgetId } = await import('./lib/nodeslideBudgetedProvider'); + const database = new MemoryDatabase(); + const { ctx } = recordingContext(database); + const budgetId = nodeSlideProviderBudgetId(RUN_ID); + await rawHandler(budgets.create)(ctx, { budgetId, budget: { maxCostUsd: 2 } }); + const opened = database.rows('nodeslide_run_budgets')[0] as Record; + await rawHandler(budgets.reserve)(ctx, { + budgetId, + callId: 'call-meter-1', + model: 'moonshotai/kimi-k3', + estimatedInputTokens: 10_000, + requestedMaxOutputTokens: 2_000, + expectedRevision: opened.revision, + expectedStateDigest: opened.stateDigest, + }); + + const receipt = (await rawHandler(budgets.receiptForRun)(readContext(database), { + runId: RUN_ID, + })) as { spend: Record }; + + expect(receipt.spend).toEqual({ + actualMicroUsd: 0, + reservedMicroUsd: 37_000, + unreconciledMicroUsd: 0, + }); + }); + + it('answers null for a run that never opened a ledger row, and for a malformed id', async () => { + const database = new MemoryDatabase(); + await expect( + rawHandler(budgets.receiptForRun)(readContext(database), { runId: 'never-ran' }), + ).resolves.toBeNull(); + await expect( + rawHandler(budgets.receiptForRun)(readContext(database), { runId: '' }), + ).resolves.toBeNull(); + }); +}); diff --git a/convex/nodeslideBudgets.ts b/convex/nodeslideBudgets.ts index cf98eb6e..bd28b496 100644 --- a/convex/nodeslideBudgets.ts +++ b/convex/nodeslideBudgets.ts @@ -22,6 +22,7 @@ */ import { v } from 'convex/values'; import { + NODESLIDE_RUN_BUDGET_LEDGER_RECEIPT_VERSION, NODESLIDE_RUN_BUDGET_RECEIPT_VERSION, type NodeSlideRunBudget, type NodeSlideRunBudgetPreflightDenialReason, @@ -35,6 +36,7 @@ import { type QueryCtx, internalMutation, internalQuery, + query, } from './_generated/server'; import { NODESLIDE_BILLABLE_CALL_VERSION, @@ -64,6 +66,7 @@ import { reserveNodeSlideBudgetCost, settleNodeSlideBudgetCost, } from './lib/nodeslideBudgetLedger'; +import { nodeslideStableId } from './lib/nodeslideIds'; import { accountNodeSlideRunBudgetReceipt, nodeSlideRunBudgetReceiptDigest, @@ -509,6 +512,43 @@ export const replay = internalQuery({ }, }); +/** + * What one run cost, read from the hard-budget ledger: the only reservation path + * (`convex/lib/nodeslideBudgetedProvider.ts` is the only caller of `reserve`), so + * this is the meter a campaign runner can trust, unlike the Trace inspector text, + * which is attribution. Keyed by the same opaque id the provider binds, + * `nodeSlideProviderBudgetId(runId)` = `nodeslideStableId('nsbudget', runId)` (a + * test pins the equality; the provider module is not imported here because it + * drags the model SDK into a query bundle). + * + * Public on purpose: the campaign runner has no owner credential for a run it did + * not create. The budget id is a hash of an unguessable run id, and the result is + * counters only (no prompt, no deck, no key). `reserved` and `unreconciled` + * exposure are returned separately: a dispatch whose outcome never came back may + * still have been billed, and the caller must count it. + */ +export const receiptForRun = query({ + args: { runId: v.string() }, + handler: async (ctx, args) => { + if (args.runId.length < 1 || args.runId.length > 512) return null; + const budget = await findBudget(ctx, nodeslideStableId('nsbudget', args.runId)); + if (!budget) return null; + return { + version: NODESLIDE_RUN_BUDGET_LEDGER_RECEIPT_VERSION, + budgetId: budget.id, + status: budget.status, + cap: { maxCostMicroUsd: budget.budget.maxCostMicroUsd }, + spend: { + actualMicroUsd: budget.actualMicroUsd, + reservedMicroUsd: budget.reservedMicroUsd, + unreconciledMicroUsd: budget.unreconciledMicroUsd, + }, + revision: budget.revision, + stateDigest: budget.stateDigest, + }; + }, +}); + const zeroCostDeltas = { actualDeltaMicroUsd: 0, reservedDeltaMicroUsd: 0, diff --git a/convex/nodeslideModelPricing.test.ts b/convex/nodeslideModelPricing.test.ts index 1b0d53a2..0715661e 100644 --- a/convex/nodeslideModelPricing.test.ts +++ b/convex/nodeslideModelPricing.test.ts @@ -7,7 +7,7 @@ * table transcribed by hand between them can be wrong by three orders of * magnitude without looking wrong. So the catalog values are restated here, in * the provider's own units and exactly as the catalog printed them on - * 2026-07-28, and the test does the conversion itself. + * 2026-10-14, and the test does the conversion itself. * * That is deliberately a SECOND transcription, not an import. Importing the * table and asserting it equals itself would pass on any value at all. If these @@ -20,7 +20,11 @@ * both transcriptions together when the recorded date gets old. */ import { describe, expect, it } from 'vitest'; -import { NODESLIDE_AGENT_MODELS, type NodeSlideAgentModelId } from '../shared/nodeslide'; +import { + NODESLIDE_AGENT_MODELS, + type NodeSlideAgentModelId, + nodeSlideAgentModel, +} from '../shared/nodeslide'; import { NODESLIDE_MODEL_PRICING, NODESLIDE_MODEL_PRICING_SOURCE_URL, @@ -31,24 +35,27 @@ import { nodeSlidePricingRefusalReason, scoreNodeSlideWorstCaseCost, } from '../shared/nodeslideRunBudget'; +import { NODESLIDE_KIMI_K3, NODESLIDE_OPENROUTER_MODEL_OVERRIDES } from './lib/nodeslideProvider'; /** - * Read out of the `data[]` entry for each id on 2026-07-28: `pricing.prompt`, + * Read out of the `data[]` entry for each id on 2026-10-14: `pricing.prompt`, * `pricing.completion` (USD per token, as strings), `context_length`, and * `top_provider.max_completion_tokens`. `null` is recorded as null, not guessed. */ -const OPENROUTER_CATALOG_2026_07_28 = { +const OPENROUTER_CATALOG_2026_10_14 = { + // Was 0.000003 / 0.000015 (and maxCompletionTokens null) on 2026-07-28. 'moonshotai/kimi-k3': { - prompt: '0.000003', + prompt: '0.0000007', completion: '0.000015', contextLength: 1_048_576, - maxCompletionTokens: null, + maxCompletionTokens: 943_718, }, + // Was 0.0000007686 / 0.0000024156 and 131_072 on 2026-07-28. 'z-ai/glm-5.2': { - prompt: '0.0000007686', - completion: '0.0000024156', + prompt: '0.00000005', + completion: '0.000007', contextLength: 1_048_576, - maxCompletionTokens: 131_072, + maxCompletionTokens: 943_718, }, 'anthropic/claude-sonnet-5': { prompt: '0.000002', @@ -62,27 +69,53 @@ const OPENROUTER_CATALOG_2026_07_28 = { contextLength: 1_000_000, maxCompletionTokens: 128_000, }, + 'anthropic/claude-sonnet-5.5': { + prompt: '0.000002', + completion: '0.00001', + contextLength: 1_000_000, + maxCompletionTokens: 128_000, + }, + 'anthropic/claude-opus-5.5': { + prompt: '0.000004', + completion: '0.00002', + contextLength: 1_000_000, + maxCompletionTokens: 128_000, + }, 'google/gemini-3.5-flash': { prompt: '0.0000015', completion: '0.000009', contextLength: 1_048_576, maxCompletionTokens: 65_536, }, + 'google/gemini-3.8-flash': { + prompt: '0.00000075', + completion: '0.00000375', + contextLength: 1_048_576, + maxCompletionTokens: 65_536, + }, 'google/gemini-3.1-pro-preview': { prompt: '0.000002', completion: '0.000012', contextLength: 1_048_576, maxCompletionTokens: 65_536, }, + // Was 0.000005 / 0.00003 on 2026-07-28. 'openai/gpt-5.6-sol': { - prompt: '0.000005', - completion: '0.00003', + prompt: '0.000002', + completion: '0.00001', contextLength: 1_050_000, maxCompletionTokens: 128_000, }, + // Was 0.00000125 / 0.0000075 on 2026-07-28. 'openai/gpt-5.6-terra': { - prompt: '0.00000125', - completion: '0.0000075', + prompt: '0.000002', + completion: '0.000012', + contextLength: 1_050_000, + maxCompletionTokens: 128_000, + }, + 'openai/gpt-6.1-sol': { + prompt: '0.000002', + completion: '0.00001', contextLength: 1_050_000, maxCompletionTokens: 128_000, }, @@ -122,19 +155,20 @@ function microUsdPerMillionTokens(usdPerToken: string): number { describe('the recorded catalog observation', () => { it('names the endpoint and the date it was read', () => { expect(NODESLIDE_MODEL_PRICING_SOURCE_URL).toBe('https://openrouter.ai/api/v1/models'); - expect(NODESLIDE_MODEL_PRICING_VERIFIED_AT).toBe('2026-07-28T00:00:00Z'); + expect(NODESLIDE_MODEL_PRICING_VERIFIED_AT).toBe('2026-10-14T16:03:00Z'); }); it('converts the provider unit to the ledger unit without floating-point drift', () => { // The route that would have silently lost a micro-USD to `* 1e12`. expect(microUsdPerMillionTokens('0.0000007686')).toBe(768_600); + expect(microUsdPerMillionTokens('0.0000007')).toBe(700_000); expect(microUsdPerMillionTokens('0.000003')).toBe(3_000_000); expect(microUsdPerMillionTokens('0.00005')).toBe(50_000_000); }); }); describe('every priced row matches the catalog it claims to come from', () => { - for (const [modelId, catalog] of Object.entries(OPENROUTER_CATALOG_2026_07_28)) { + for (const [modelId, catalog] of Object.entries(OPENROUTER_CATALOG_2026_10_14)) { it(`prices ${modelId} exactly as the catalog published it`, () => { const pricing = nodeSlideModelPricing(modelId); expect(pricing.kind).toBe('priced'); @@ -260,3 +294,46 @@ describe('worst-case scoring rounds against the run, never in its favour', () => expect(scored.totalCostMicroUsd).toBe(60_000_000); }); }); + +describe('every pricing source in this repo agrees (Part A rule 6)', () => { + it('the hand-typed Kimi K3 Model<> override costs what the price table charges', () => { + // Two pricing sources exist for moonshotai/kimi-k3: the ledger table above and the + // pi-ai Model<> override that pi-ai uses to price a response (cost.total -> costMicroUsd). + // Same transport (OpenRouter), same pricingAsOf (NODESLIDE_MODEL_PRICING_VERIFIED_AT). + // Model<> cost is USD per million tokens; the ledger is micro-USD per million tokens. + const pricing = nodeSlideModelPricing('moonshotai/kimi-k3'); + expect(pricing.kind).toBe('priced'); + if (pricing.kind !== 'priced') return; + expect(NODESLIDE_KIMI_K3.provider).toBe('openrouter'); + expect(Math.round(NODESLIDE_KIMI_K3.cost.input * 1_000_000)).toBe( + pricing.inputMicroUsdPerMillionTokens, + ); + expect(Math.round(NODESLIDE_KIMI_K3.cost.output * 1_000_000)).toBe( + pricing.outputMicroUsdPerMillionTokens, + ); + expect(NODESLIDE_KIMI_K3.contextWindow).toBe(pricing.providerContextWindowTokens); + }); + + it('every OpenRouter model override is a priced row that agrees with the table', () => { + for (const override of NODESLIDE_OPENROUTER_MODEL_OVERRIDES) { + const pricing = nodeSlideModelPricing(override.id); + expect(pricing.kind).toBe('priced'); + if (pricing.kind !== 'priced') continue; + expect(Math.round(override.cost.input * 1_000_000)).toBe( + pricing.inputMicroUsdPerMillionTokens, + ); + expect(Math.round(override.cost.output * 1_000_000)).toBe( + pricing.outputMicroUsdPerMillionTokens, + ); + } + }); + + it('keeps the Nebius GLM-5.2 hand-typed cost out of every reservation path', () => { + // NODESLIDE_NEBIUS_GLM carries a hand-typed 1.4 / 4.4 (not in frontier.json, not on OpenRouter). + // The route is productionEnabled:false and its ledger row is 'unknown' (denied), so the + // figure cannot reach a reservation. It is verified against the Nebius price list when the + // route is enabled (SPEC Part A section A.2.8, R row convex/lib/nodeslideProvider.ts:27). + expect(nodeSlideAgentModel('nebius/zai-org/GLM-5.2').productionEnabled).toBe(false); + expect(nodeSlideModelPricing('nebius/zai-org/GLM-5.2').kind).toBe('unknown'); + }); +}); diff --git a/convex/nodeslideModelProbe.ts b/convex/nodeslideModelProbe.ts index 07a835cf..e647f624 100644 --- a/convex/nodeslideModelProbe.ts +++ b/convex/nodeslideModelProbe.ts @@ -1,6 +1,13 @@ 'use node'; +import { api, internal } from './_generated/api'; import { internalAction } from './_generated/server'; +import { bindNodeSlideBudgetLedgerClient } from './lib/nodeslideBudgetedProvider'; +import { + type NodeSlideExecutorSplitProbeReceipt, + executorSplitProbeBudgetUsd, + runNodeSlideExecutorSplitProbe, +} from './lib/nodeslideExecutorSplitProbe'; import { runNodeSlideFreeRouterProbe, runNodeSlideFreeRouterStructuredProbe, @@ -24,3 +31,28 @@ export const runFreeRouterStructured = internalAction({ args: {}, handler: async () => runNodeSlideFreeRouterStructuredProbe(), }); + +// Convex's generated API makes this action's own file part of the reference types it calls through, +// which TypeScript reads as a self-reference. Same confined escape hatch as convex/nodeslideAgent.ts. +// biome-ignore lint/suspicious/noExplicitAny: generated Convex self-reference described above +const generatedApi: any = api; +// biome-ignore lint/suspicious/noExplicitAny: generated Convex self-reference described above +const generatedInternal: any = internal; + +/** + * Candidate-bound executor receipt (SPEC Part A, section A.2.8): one premium-planner edit turn split + * to the routed copy executor through the reserve-before-dispatch provider. Spends real provider + * money, capped by NODESLIDE_PROBE_BUDGET_USD (default 0.25 USD, planner and executor together). + * Invoke with `npx convex run nodeslideModelProbe:runExecutorSplit`. + */ +export const runExecutorSplit = internalAction({ + args: {}, + handler: async (ctx): Promise => { + const buildIdentity = await ctx.runQuery(generatedApi.nodeslideBuildIdentity.get, {}); + return runNodeSlideExecutorSplitProbe({ + ledger: bindNodeSlideBudgetLedgerClient(ctx, generatedInternal.nodeslideBudgets), + buildIdentity, + budgetUsd: executorSplitProbeBudgetUsd(process.env), + }); + }, +}); diff --git a/docs/codebase/INTEGRATIONS.md b/docs/codebase/INTEGRATIONS.md index f2f10d69..9cf1fb38 100644 --- a/docs/codebase/INTEGRATIONS.md +++ b/docs/codebase/INTEGRATIONS.md @@ -79,7 +79,7 @@ receipt. Note these live in the **Convex** environment, not in `.env.local`; ## MCP — NodeSlide for coding agents (optional) -- **Where:** `mcp/`, tools registered in `mcp/src/lib/nodeslideTools.ts:414` (`registerNodeSlideTools`). +- **Where:** `mcp/`, tools registered in `mcp/src/lib/nodeslideTools.ts:417` (`registerNodeSlideTools`). - **How it connects:** stdio MCP server that calls the same Convex functions the browser calls. Provider keys stay in the MCP process — `nodeslide.byok_status` reports presence and never returns a value. diff --git a/mcp/package.json b/mcp/package.json index d54013e4..ce95ef5d 100644 --- a/mcp/package.json +++ b/mcp/package.json @@ -17,7 +17,7 @@ "test": "vitest run --passWithNoTests" }, "dependencies": { - "@earendil-works/pi-ai": "0.80.6", + "@earendil-works/pi-ai": "1.1.0", "@modelcontextprotocol/sdk": "^1.30.0", "@nodeslide/recipelang": "0.2.2", "convex": "^1.31.7", diff --git a/mcp/src/lib/nodeslideTools.ts b/mcp/src/lib/nodeslideTools.ts index 93bc951b..8b43cd4c 100644 --- a/mcp/src/lib/nodeslideTools.ts +++ b/mcp/src/lib/nodeslideTools.ts @@ -3,7 +3,10 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { buildNodeSlideStoryContext } from '../../../convex/lib/nodeslideStoryContext.js'; import { writeDeckArtifacts } from '../../../packages/cli/src/generate.js'; -import type { NodeSlideWorkspace as CanonicalNodeSlideWorkspace } from '../../../shared/nodeslide.js'; +import { + type NodeSlideWorkspace as CanonicalNodeSlideWorkspace, + NODESLIDE_DEFAULT_AGENT_MODEL, +} from '../../../shared/nodeslide.js'; import { localByokStatus, requireLocalKeys } from './byok.js'; import { type CallResult, callByModel } from './llmClient.js'; @@ -12,7 +15,7 @@ const REVIEW_CONSENT = 'openrouter_nodeslide_review_context_v1'; const BRIEF_CONSENT = 'openrouter_full_brief_v1'; const WEB_CONSENT = 'nodeslide_web_research_v1'; const LOCAL_BYOK_CONSENT = 'nodeslide_local_byok_edit_v1'; -const DEFAULT_BYOK_MODEL = process.env.NODESLIDE_BYOK_MODEL ?? 'moonshotai/kimi-k3'; +const DEFAULT_BYOK_MODEL = process.env.NODESLIDE_BYOK_MODEL ?? NODESLIDE_DEFAULT_AGENT_MODEL; const NODE_SLIDE_EXTERNAL_OPERATION_MAX = 8; const NODE_SLIDE_PAGE_DEFAULT = 25; const NODE_SLIDE_PAGE_MAX = 100; @@ -604,7 +607,10 @@ export function registerNodeSlideTools(server: McpServer, convexCall: ConvexCall scope, providerMode: args.execution === 'hosted' ? 'openrouter_free' : 'deterministic', ...(args.execution === 'hosted' - ? { providerModel: args.model ?? 'moonshotai/kimi-k3', providerConsent: REVIEW_CONSENT } + ? { + providerModel: args.model ?? NODESLIDE_DEFAULT_AGENT_MODEL, + providerConsent: REVIEW_CONSENT, + } : {}), ...(args.idempotencyKey ? { idempotencyKey: args.idempotencyKey } : {}), }); @@ -739,7 +745,7 @@ export function registerNodeSlideTools(server: McpServer, convexCall: ConvexCall clientSessionId: z.string().min(8).max(256), accessCode: z.string().optional(), execution: z.enum(['hosted', 'deterministic']).default('hosted'), - model: z.string().default('moonshotai/kimi-k3'), + model: z.string().default(NODESLIDE_DEFAULT_AGENT_MODEL), effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).default('low'), consent: z.boolean().default(false), outputDirectory: z.string().min(1).default('nodeslide-output'), diff --git a/package-lock.json b/package-lock.json index 56baa57f..01aeb510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@assistant-ui/store": "0.2.19", "@convex-dev/persistent-text-streaming": "^0.3.3", "@convex-dev/workflow": "^0.3.0", - "@earendil-works/pi-ai": "0.80.6", + "@earendil-works/pi-ai": "1.1.0", "@fontsource-variable/fraunces": "^5.2.9", "@fontsource-variable/geist": "^5.2.8", "@fontsource-variable/jetbrains-mono": "^5.2.8", @@ -75,7 +75,7 @@ "version": "0.2.2", "license": "UNLICENSED", "dependencies": { - "@earendil-works/pi-ai": "0.80.6", + "@earendil-works/pi-ai": "1.1.0", "@modelcontextprotocol/sdk": "^1.30.0", "@nodeslide/recipelang": "0.2.2", "convex": "^1.31.7", @@ -222,12 +222,13 @@ } }, "node_modules/@anthropic-ai/sdk": { - "version": "0.91.1", - "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.91.1.tgz", - "integrity": "sha512-LAmu761tSN9r66ixvmciswUj/ZC+1Q4iAfpedTfSVLeswRwnY3n2Nb6Tsk+cLPP28aLOPWeMgIuTuCcMC6W/iw==", + "version": "0.129.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.129.0.tgz", + "integrity": "sha512-MH7LB20kNpGLUpPTe2OG5XvL/KhX8HUO9XyBaFjgFk6TLS4Xjt0VPIuMKywe7POKKPslX+QxSlVok9e+8kG5Nw==", "license": "MIT", "dependencies": { - "json-schema-to-ts": "^3.1.1" + "json-schema-to-ts": "^3.1.1", + "standardwebhooks": "^1.0.0" }, "bin": { "anthropic-ai-sdk": "bin/cli" @@ -362,74 +363,23 @@ } } }, - "node_modules/@aws-crypto/sha256-browser": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-browser/-/sha256-browser-5.2.0.tgz", - "integrity": "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw==", - "license": "Apache-2.0", - "dependencies": { - "@aws-crypto/sha256-js": "^5.2.0", - "@aws-crypto/supports-web-crypto": "^5.2.0", - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "@aws-sdk/util-locate-window": "^3.0.0", - "@smithy/util-utf8": "^2.0.0", - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-crypto/sha256-js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", - "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", - "license": "Apache-2.0", - "dependencies": { - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@aws-crypto/supports-web-crypto": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/supports-web-crypto/-/supports-web-crypto-5.2.0.tgz", - "integrity": "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.6.2" - } - }, - "node_modules/@aws-crypto/util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", - "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", - "license": "Apache-2.0", - "dependencies": { - "@aws-sdk/types": "^3.222.0", - "@smithy/util-utf8": "^2.0.0", - "tslib": "^2.6.2" - } - }, "node_modules/@aws-sdk/client-bedrock-runtime": { - "version": "3.1048.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-runtime/-/client-bedrock-runtime-3.1048.0.tgz", - "integrity": "sha512-u+NT61JZEkRFtpL0CAw1N1dwxnaLgwVXQl/zjJxTGgLyS/jTIdg2SdoEoCTHxgDyCnqa1HEi9QOoE9/pYRNpOQ==", + "version": "3.1127.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-runtime/-/client-bedrock-runtime-3.1127.0.tgz", + "integrity": "sha512-IDl/lrPb90aH+pZFHGNDmgH9nAUQj5PlZH1sJ3w7RikctyjHSnY3oNjZhrLoaBoQn/rNK0zsP6OHEqEhj2tdLA==", "license": "Apache-2.0", "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "^3.974.11", - "@aws-sdk/credential-provider-node": "^3.972.42", - "@aws-sdk/eventstream-handler-node": "^3.972.16", - "@aws-sdk/middleware-eventstream": "^3.972.12", - "@aws-sdk/middleware-websocket": "^3.972.19", - "@aws-sdk/token-providers": "3.1048.0", - "@aws-sdk/types": "^3.973.8", - "@smithy/core": "^3.24.2", - "@smithy/fetch-http-handler": "^5.4.2", - "@smithy/node-http-handler": "^4.7.2", - "@smithy/types": "^4.14.1", + "@aws-sdk/core": "^3.977.9", + "@aws-sdk/credential-provider-node": "^3.972.82", + "@aws-sdk/eventstream-handler-node": "^3.972.34", + "@aws-sdk/middleware-eventstream": "^3.972.29", + "@aws-sdk/middleware-websocket": "^3.972.52", + "@aws-sdk/token-providers": "3.1127.0", + "@aws-sdk/types": "^3.974.5", + "@smithy/core": "^3.33.3", + "@smithy/fetch-http-handler": "^5.7.2", + "@smithy/node-http-handler": "^4.11.3", + "@smithy/types": "^4.17.2", "tslib": "^2.6.2" }, "engines": { @@ -437,17 +387,17 @@ } }, "node_modules/@aws-sdk/core": { - "version": "3.975.1", - "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.975.1.tgz", - "integrity": "sha512-8qh/6EYb7hl/ZwVfQufhbMEZs1gQIc7GbdrIf4eprQJ7cv042+74nE6l3YDfyWNzb9iPXb8fRyYSHkNIk5eE6Q==", + "version": "3.978.3", + "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.978.3.tgz", + "integrity": "sha512-nslpzUCTI9b2IQMWSd6mSAXldBexPc8rr0d3dXUutXYFLFaTdsHa2GD7sJdsn3PhyjK0O5K8ypd6zi+RXXPVlg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.974.0", - "@aws-sdk/xml-builder": "^3.972.34", + "@aws-sdk/types": "^3.974.6", + "@aws-sdk/xml-builder": "^3.972.41", "@aws/lambda-invoke-store": "^0.3.0", - "@smithy/core": "^3.29.2", - "@smithy/signature-v4": "^5.6.3", - "@smithy/types": "^4.16.0", + "@smithy/core": "^3.35.2", + "@smithy/signature-v4": "^5.7.4", + "@smithy/types": "^4.19.0", "bowser": "^2.11.0", "tslib": "^2.6.2" }, @@ -456,15 +406,15 @@ } }, "node_modules/@aws-sdk/credential-provider-env": { - "version": "3.972.57", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.57.tgz", - "integrity": "sha512-1RfJaF7SW1TOnvNGU7kaYjwUf5H3sfm+synGH1bHhRlqcnxCt3szebH3dmKEyY4tuGcbQ6ffzUT89cRitBV8OQ==", + "version": "3.972.74", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.74.tgz", + "integrity": "sha512-rsRJcW2iFUhCgclyD6OSbMEaPl8Eu0qSeRZb2uuCK1ViZ66hl5wOe/p6Vr6MO3b+ydyKgFeqza2p6tZThvILlw==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -472,55 +422,41 @@ } }, "node_modules/@aws-sdk/credential-provider-http": { - "version": "3.972.59", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.59.tgz", - "integrity": "sha512-sRCkpTiFnCdQvuaRVjQ6SVoHu6i7RUpurVo1c4F81HWhPvUJ7Wdp5MNtSdX1O29CNXc8em3O5m52hCjVtAD9SA==", + "version": "3.972.76", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.76.tgz", + "integrity": "sha512-pnKdh0Br7OJPj+7qKjzgTfDTFW0RhEMKXNDR2jv9CAM4oHuG/4z3hRh8KtutLfpmItuRtDbKBmwWkDqHwwAWXw==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/fetch-http-handler": "^5.6.4", - "@smithy/node-http-handler": "^4.9.4", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/fetch-http-handler": "^5.8.0", + "@smithy/node-http-handler": "^4.12.1", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { "node": ">=20.0.0" } }, - "node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.9.5.tgz", - "integrity": "sha512-bNqdxTQTxmLbomSmlkZFz8L6B/feQ2HHzw4L2zY7Ecp2XffYAZq2uzdWDdxJHJFbEvqd+SRuluJso0P8+xPdbw==", - "license": "Apache-2.0", - "dependencies": { - "@smithy/core": "^3.29.3", - "@smithy/types": "^4.16.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@aws-sdk/credential-provider-ini": { - "version": "3.973.1", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.1.tgz", - "integrity": "sha512-6d8H6ZAh3ZPKZ6fe1nG2OWeZEZPtt9ravoD1dezPdPtsSkJRoxGAnFSHwKT3E/Te6fHE30zRzjV6TD12rvF6yQ==", + "version": "3.973.19", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.19.tgz", + "integrity": "sha512-kcjvAxqQEV8yuwkX58RelNn3ne65o7JgRWf3Z/gVvbi7Xuw1qSDLJlatrLD76+40cmRxmNkLxBoyp/vAQChQ5g==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/credential-provider-env": "^3.972.57", - "@aws-sdk/credential-provider-http": "^3.972.59", - "@aws-sdk/credential-provider-login": "^3.972.63", - "@aws-sdk/credential-provider-process": "^3.972.57", - "@aws-sdk/credential-provider-sso": "^3.973.1", - "@aws-sdk/credential-provider-web-identity": "^3.972.63", - "@aws-sdk/nested-clients": "^3.997.31", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/credential-provider-imds": "^4.4.7", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/credential-provider-env": "^3.972.74", + "@aws-sdk/credential-provider-http": "^3.972.76", + "@aws-sdk/credential-provider-login": "^3.972.81", + "@aws-sdk/credential-provider-process": "^3.972.74", + "@aws-sdk/credential-provider-sso": "^3.973.18", + "@aws-sdk/credential-provider-web-identity": "^3.972.80", + "@aws-sdk/nested-clients": "^3.997.48", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -528,16 +464,16 @@ } }, "node_modules/@aws-sdk/credential-provider-login": { - "version": "3.972.63", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.63.tgz", - "integrity": "sha512-GREWRrMj0XnNKMaVa/Mauoaui26qBEHu71WWqXbwZOu/jFQOnPZjTf7u0KtGKC8VGa6VUs9kDWGgocrKNLS9vw==", + "version": "3.972.81", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.81.tgz", + "integrity": "sha512-CeQHSbE2CnVdaHIJ/NayRaCecIER+Pm9faUPkmRATO54rCoMTEPSbVieGHzEwvm1dZM2HIs6qQZCznhayNTWJQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/nested-clients": "^3.997.31", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/nested-clients": "^3.997.48", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -545,21 +481,21 @@ } }, "node_modules/@aws-sdk/credential-provider-node": { - "version": "3.972.67", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.67.tgz", - "integrity": "sha512-oYlzWst56rlhhjbYnexwv5hVLYe1cW4liLObhDfxDLI4RAQzleMVHQgQgx7XsC4HKj4e3kjT8v9DId+Pi/dndw==", + "version": "3.972.86", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.86.tgz", + "integrity": "sha512-WNttSyr6e8innPtBSty//CdnqJcgZN6eAbtw3v/CR2IObz6MYZEo8eusdtuCHJ2ujwFqC2bSPHVyhXGHx8HruQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/credential-provider-env": "^3.972.57", - "@aws-sdk/credential-provider-http": "^3.972.59", - "@aws-sdk/credential-provider-ini": "^3.973.1", - "@aws-sdk/credential-provider-process": "^3.972.57", - "@aws-sdk/credential-provider-sso": "^3.973.1", - "@aws-sdk/credential-provider-web-identity": "^3.972.63", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/credential-provider-imds": "^4.4.7", - "@smithy/types": "^4.16.0", + "@aws-sdk/credential-provider-env": "^3.972.74", + "@aws-sdk/credential-provider-http": "^3.972.76", + "@aws-sdk/credential-provider-ini": "^3.973.19", + "@aws-sdk/credential-provider-process": "^3.972.74", + "@aws-sdk/credential-provider-sso": "^3.973.18", + "@aws-sdk/credential-provider-web-identity": "^3.972.80", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/credential-provider-imds": "^4.5.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -567,15 +503,15 @@ } }, "node_modules/@aws-sdk/credential-provider-process": { - "version": "3.972.57", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.57.tgz", - "integrity": "sha512-TiVQhuU0pbhIZAUZacbPHMyzrIdiH+lnx+PMY/Pu/b93dJrq3wdZwzUJ0TPpvNxaqbHsxJvQZW3/h/beLiKq7Q==", + "version": "3.972.74", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.74.tgz", + "integrity": "sha512-Yj6kZFJQdbR+PygTkqdVLPHHpdDpOS9GCYVcDCuweCRRig9LF24ELQBMfyUw1vspvrZJUfnOGVyMjhaL094ahw==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -583,17 +519,17 @@ } }, "node_modules/@aws-sdk/credential-provider-sso": { - "version": "3.973.1", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.1.tgz", - "integrity": "sha512-3foTZUJ4821Ij60X7K3NJroygiZLnbBmarN+T//O2cjkISan90zElN3NBmgSlDrTQ7Gs6z/yO8V7h60QNcDZHQ==", + "version": "3.973.18", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.18.tgz", + "integrity": "sha512-FnpPhdY4qUGtX/8X6eKxh+uD+9Y19i9FYibgk4SBe0M935s9vocHkHzaxaMNk+YkHmvzgdu8cHA5SCoeU+kkew==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/nested-clients": "^3.997.31", - "@aws-sdk/token-providers": "3.1083.0", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/nested-clients": "^3.997.48", + "@aws-sdk/token-providers": "3.1150.0", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -601,16 +537,16 @@ } }, "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers": { - "version": "3.1083.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1083.0.tgz", - "integrity": "sha512-s0woKnxuHrExLc5L2ArIH5BMkbonHPtt+5hSBM8oknp9M6QTuUmmAmJ2E0EdzCGONrO+8+ADPqvv6UX0nNcc7A==", + "version": "3.1150.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1150.0.tgz", + "integrity": "sha512-wDU36ofhabZYu+d2KSriyDbwzxNoaOp+4dG0p3qkabk7HeALR5nIWyQbjoyJZLn3iqWkv/xNdyUfbfevDVDzzg==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/nested-clients": "^3.997.31", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/nested-clients": "^3.997.48", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -618,16 +554,16 @@ } }, "node_modules/@aws-sdk/credential-provider-web-identity": { - "version": "3.972.63", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.63.tgz", - "integrity": "sha512-8qZLFhM69eKcS37m459ctPR05Qimycm/74OPVioe6wNZabMT54GYhwBju0+J656RkMasNSawWQu+c8CmBe3TUQ==", + "version": "3.972.80", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.80.tgz", + "integrity": "sha512-TJF25Ndwy2HxcVj6oxMgp8qVlJAawlExHYBXqhuC6Zt2m+A7WpdkjBD6QglNbiArlteYljZHEY3R7KKmno6ISA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/nested-clients": "^3.997.31", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/nested-clients": "^3.997.48", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -635,14 +571,14 @@ } }, "node_modules/@aws-sdk/eventstream-handler-node": { - "version": "3.972.26", - "resolved": "https://registry.npmjs.org/@aws-sdk/eventstream-handler-node/-/eventstream-handler-node-3.972.26.tgz", - "integrity": "sha512-RE1fu7Nn05vG0EUJM+8Sde2GFecC658WGaC/asPzLF6K4x3H5ZaDBcQtHRE67Gdgb1VZpyUUliYejHFK1qt0Uw==", + "version": "3.972.36", + "resolved": "https://registry.npmjs.org/@aws-sdk/eventstream-handler-node/-/eventstream-handler-node-3.972.36.tgz", + "integrity": "sha512-HFaKXA6ugPVvpR7W/3UT3hylWIPndqGMwduwNVrmGsRT5+OESHN8/ven4eeofraQF5Kxp8A8QgGVrv7iQsTRKQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -650,14 +586,14 @@ } }, "node_modules/@aws-sdk/middleware-eventstream": { - "version": "3.972.22", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-eventstream/-/middleware-eventstream-3.972.22.tgz", - "integrity": "sha512-jtkgmhevnpzC1WeS+Y/sgymYbaQ6qg7pVOUl5cUT/8MiLptqrtnXQlNV80m+j2WIx5MIL7kVHIZNxxcK2tfUEQ==", + "version": "3.972.31", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-eventstream/-/middleware-eventstream-3.972.31.tgz", + "integrity": "sha512-4yvdTVwPGKCnrwuwlYEmwLqQXKwk0unx3f/FvBi4FA9ruK/WGoPJyqfK7hOYurheIyQL44FR0ovgOHqvkfdpAQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/types": "^4.16.0", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -665,17 +601,17 @@ } }, "node_modules/@aws-sdk/middleware-websocket": { - "version": "3.972.39", - "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-websocket/-/middleware-websocket-3.972.39.tgz", - "integrity": "sha512-CS1spxRSezmTmI3PD+3Xrnp6KryTSEz0EefA8u6uGd0s2I0uXseWHALDI/03Wi0IUczXNWo2QrZEaHDuJNby/Q==", + "version": "3.972.56", + "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-websocket/-/middleware-websocket-3.972.56.tgz", + "integrity": "sha512-32d9EnnNM5UMwjVp/qnL0K4XYiZv+YlSbULI3BaoBdJvebAS6cD0bKfPJ7lzovN0qrelvmSh5jo/3tk0KoTuGQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/fetch-http-handler": "^5.6.4", - "@smithy/signature-v4": "^5.6.3", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/fetch-http-handler": "^5.8.0", + "@smithy/signature-v4": "^5.7.4", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -683,47 +619,33 @@ } }, "node_modules/@aws-sdk/nested-clients": { - "version": "3.997.31", - "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.31.tgz", - "integrity": "sha512-BDHTpwcsZHEBNEJzOg/B1BkFYJxAXY50dau/NyVWs3d51F0WgIUGSWZot/Os+N3KpDhXeaXnz37mWffAvduREw==", + "version": "3.997.48", + "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.48.tgz", + "integrity": "sha512-B01jdXJtAW/XOiUzGdI2mz67WyEHbGEc9X6Euzw3bjLAa+txTqdZDER4X2FsIEcXzV2ABqudVZ5thali8tCCzQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.975.1", - "@aws-sdk/signature-v4-multi-region": "^3.996.39", - "@aws-sdk/types": "^3.974.0", - "@smithy/core": "^3.29.2", - "@smithy/fetch-http-handler": "^5.6.4", - "@smithy/node-http-handler": "^4.9.4", - "@smithy/types": "^4.16.0", + "@aws-sdk/core": "^3.978.3", + "@aws-sdk/signature-v4-multi-region": "^3.996.48", + "@aws-sdk/types": "^3.974.6", + "@smithy/core": "^3.35.2", + "@smithy/fetch-http-handler": "^5.8.0", + "@smithy/node-http-handler": "^4.12.1", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { "node": ">=20.0.0" } }, - "node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.9.5.tgz", - "integrity": "sha512-bNqdxTQTxmLbomSmlkZFz8L6B/feQ2HHzw4L2zY7Ecp2XffYAZq2uzdWDdxJHJFbEvqd+SRuluJso0P8+xPdbw==", - "license": "Apache-2.0", - "dependencies": { - "@smithy/core": "^3.29.3", - "@smithy/types": "^4.16.1", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/@aws-sdk/signature-v4-multi-region": { - "version": "3.996.39", - "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.39.tgz", - "integrity": "sha512-8+srXqYIF8KYMLC4FxMLEM5Ek7kUNibJu1R4m8/fUhhNYIZZz26oGtKkCr8I/HiG2fFQxBvaGgQZT4/mqRCSnA==", + "version": "3.996.48", + "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.48.tgz", + "integrity": "sha512-cFDXfEbXaGwbnpvR/DyqfxfjxpjXVRVthQLgkwvcfDS5u3+8G9WSj1X1Ag/pTRg/QOeOno1Tq3ycEdrKsCUcOA==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/types": "^3.974.0", - "@smithy/signature-v4": "^5.6.3", - "@smithy/types": "^4.16.0", + "@aws-sdk/types": "^3.974.6", + "@smithy/signature-v4": "^5.7.4", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -731,16 +653,16 @@ } }, "node_modules/@aws-sdk/token-providers": { - "version": "3.1048.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1048.0.tgz", - "integrity": "sha512-k0y/GcuesuSfWyUM0WamrGyeZmltRYaPbHO82UDA6mZ/doB+FOHKutikPAtSXMn/hDz970cF+iRuuiYO9VEbAA==", + "version": "3.1127.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1127.0.tgz", + "integrity": "sha512-Dv2TMWBshJ+tF6ahs2Sy5bh4Iabsd4GAQqVvE9XZmYmnoaVbpS2QKIKE/HRacc7bTtbjEEvP+laGzHvHlf1CiQ==", "license": "Apache-2.0", "dependencies": { - "@aws-sdk/core": "^3.974.11", - "@aws-sdk/nested-clients": "^3.997.9", - "@aws-sdk/types": "^3.973.8", - "@smithy/core": "^3.24.2", - "@smithy/types": "^4.14.1", + "@aws-sdk/core": "^3.977.9", + "@aws-sdk/nested-clients": "^3.997.44", + "@aws-sdk/types": "^3.974.5", + "@smithy/core": "^3.33.3", + "@smithy/types": "^4.17.2", "tslib": "^2.6.2" }, "engines": { @@ -748,24 +670,12 @@ } }, "node_modules/@aws-sdk/types": { - "version": "3.974.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.974.0.tgz", - "integrity": "sha512-QIBrw90CDm4O0UaIIzkU6DrFdeJzEb2Va5EPEVpyldj6sHJxB6cshhStJuhZxk3wR3PmjJlYsjPmY1kNb+KGBg==", - "license": "Apache-2.0", - "dependencies": { - "@smithy/types": "^4.16.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/@aws-sdk/util-locate-window": { - "version": "3.965.8", - "resolved": "https://registry.npmjs.org/@aws-sdk/util-locate-window/-/util-locate-window-3.965.8.tgz", - "integrity": "sha512-uUbMs1cBZPafD0ohUj6EwNf0fPZ534NvBxHox4hjX+0Rxq5paSYUem7+hi833pYrzrcnBATKIYpR02MDXT5M9g==", + "version": "3.974.6", + "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.974.6.tgz", + "integrity": "sha512-v/clNZzZnDxGyvpHMOGpJKVXFAExJzUNAAjaWGdcx8QAcXLGwTaOkw33p5SHAi0YAioK32xB3hWwOekRVfmfKg==", "license": "Apache-2.0", "dependencies": { + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -773,12 +683,12 @@ } }, "node_modules/@aws-sdk/xml-builder": { - "version": "3.972.34", - "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.34.tgz", - "integrity": "sha512-wHhWL1y7sN3enBA8POrPpQM5jCcmu2ozyhbRei4c8OjVcEaEs6yLucLa/pla457ggS/ysuy7bosagz3HaJkZXA==", + "version": "3.972.41", + "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.41.tgz", + "integrity": "sha512-ctjVSyCMegrWfXlx6VqzSBFI6UqmQ5ZlnfMhdLIiWmhoH8UAQxSCP5N3OpG7X3k4LnS7ou74C4mt20+bfTW2aQ==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.16.0", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -1453,22 +1363,21 @@ } }, "node_modules/@earendil-works/pi-ai": { - "version": "0.80.6", - "resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-0.80.6.tgz", - "integrity": "sha512-7xfLk8sANBp+bpPEbjoOZTbPxsa+++b1JXAoSJsNa3vbs9AHHEclmvg54XLQcxH+fuwaeti/g2jeIfJ+mVYLpA==", - "license": "MIT", - "dependencies": { - "@anthropic-ai/sdk": "0.91.1", - "@aws-sdk/client-bedrock-runtime": "3.1048.0", - "@google/genai": "1.52.0", - "@mistralai/mistralai": "2.2.6", - "@opentelemetry/api": "1.9.0", - "@smithy/node-http-handler": "4.7.3", - "http-proxy-agent": "7.0.2", - "https-proxy-agent": "7.0.6", - "openai": "6.26.0", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.1.0.tgz", + "integrity": "sha512-1T7LAkc/5Bvc0v6w4vAGVdCrli0o/E0pEmYKTnixu95vSFArBjvbhS/G4ZwI0RUePgf0Imcu0VyqlM4EcXxqfw==", + "license": "MIT", + "dependencies": { + "@anthropic-ai/sdk": "0.129.0", + "@aws-sdk/client-bedrock-runtime": "3.1127.0", + "@earendil-works/pi-telemetry": "^1.1.0", + "@google/genai": "2.21.0", + "@smithy/node-http-handler": "4.12.1", + "http-proxy-agent": "9.1.0", + "https-proxy-agent": "9.1.0", + "openai": "7.19.0", "partial-json": "0.1.7", - "typebox": "1.1.38" + "typebox": "1.3.27" }, "bin": { "pi-ai": "dist/cli.js" @@ -1477,6 +1386,15 @@ "node": ">=22.19.0" } }, + "node_modules/@earendil-works/pi-telemetry": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.2.0.tgz", + "integrity": "sha512-NZ3aJE6dr7aTgzzXDe53OW7BsAsF8ZUKHPJTtnjaQcxtlagkUT0Ew8Qas0EvYQsZqR/KpF1lB+z209XBzIC7xg==", + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.0.tgz", @@ -1977,9 +1895,9 @@ } }, "node_modules/@google/genai": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/@google/genai/-/genai-1.52.0.tgz", - "integrity": "sha512-gwSvbpiN/17O9TbsqSsE/OzZcpv5Fo4RQjdngGgogtuB9RsyJ8ZHhX5KjHj1bp5N9snN2eK8LDGXSaWW2hof8Q==", + "version": "2.21.0", + "resolved": "https://registry.npmjs.org/@google/genai/-/genai-2.21.0.tgz", + "integrity": "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -2121,26 +2039,6 @@ "@chevrotain/types": "~11.1.2" } }, - "node_modules/@mistralai/mistralai": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-2.2.6.tgz", - "integrity": "sha512-W8pX7zHxjJvMIpw8JMxeJEleapXX0Q9NPszdNzqkM3MIEoIGPObdodujj+WHteXEvGfaP/AMwlNyRfEzSY6dQQ==", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/semantic-conventions": "^1.40.0", - "ws": "^8.18.0", - "zod": "^3.25.0 || ^4.0.0", - "zod-to-json-schema": "^3.25.0" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.9.0" - }, - "peerDependenciesMeta": { - "@opentelemetry/api": { - "optional": true - } - } - }, "node_modules/@napi-rs/canvas": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-1.0.2.tgz", @@ -2516,20 +2414,14 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz", "integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==", + "dev": true, "license": "Apache-2.0", + "optional": true, + "peer": true, "engines": { "node": ">=8.0.0" } }, - "node_modules/@opentelemetry/semantic-conventions": { - "version": "1.43.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.43.0.tgz", - "integrity": "sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg==", - "license": "Apache-2.0", - "engines": { - "node": ">=14" - } - }, "node_modules/@openuidev/lang-core": { "version": "0.2.10", "resolved": "https://registry.npmjs.org/@openuidev/lang-core/-/lang-core-0.2.10.tgz", @@ -4473,12 +4365,12 @@ ] }, "node_modules/@smithy/core": { - "version": "3.29.3", - "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.29.3.tgz", - "integrity": "sha512-L+Ys6ecjk5vwPMAKHBpPKlJ3DkqwNcnfEISXBZIsVvWG/XKXfsAP8mwIYlTeLcd2ElHdesPI8OuOmJSFAPhm6A==", + "version": "3.36.0", + "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.36.0.tgz", + "integrity": "sha512-3hJiwG1F5t1SoXqp/yOCmYXziyx7ZVqF63S5W6YU201e/qwVaHPex+E/3vvyY9a3ORq/b+BydeNZpP2saQ9X2g==", "license": "Apache-2.0", "dependencies": { - "@smithy/types": "^4.16.1", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -4486,13 +4378,13 @@ } }, "node_modules/@smithy/credential-provider-imds": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.4.8.tgz", - "integrity": "sha512-q9J7JTiXrAhB8sDp4px97uEPT7CwKH61Co78grdNQvU8QZAdiuaSRhP0tUVf2ogy36RZTrlMU1rBmDEH+cnkiA==", + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz", + "integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.29.3", - "@smithy/types": "^4.16.1", + "@smithy/core": "^3.33.2", + "@smithy/types": "^4.17.2", "tslib": "^2.6.2" }, "engines": { @@ -4500,39 +4392,27 @@ } }, "node_modules/@smithy/fetch-http-handler": { - "version": "5.6.5", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.6.5.tgz", - "integrity": "sha512-SuqeisTyPoiIPtIYru/sGxGyXzmZ+8nnFOhC+qRPglt06Ebd1yH//CDltZB2J/3WBNVhwfUaZ0EtHB3cm2X32g==", + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.0.tgz", + "integrity": "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.29.3", - "@smithy/types": "^4.16.1", + "@smithy/core": "^3.33.3", + "@smithy/types": "^4.18.0", "tslib": "^2.6.2" }, "engines": { "node": ">=18.0.0" } }, - "node_modules/@smithy/is-array-buffer": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/is-array-buffer/-/is-array-buffer-2.2.0.tgz", - "integrity": "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA==", - "license": "Apache-2.0", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@smithy/node-http-handler": { - "version": "4.7.3", - "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.7.3.tgz", - "integrity": "sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.12.1.tgz", + "integrity": "sha512-ThMkboGeONWXAelq9FvGsuJC4rOi+qyC4/zhUF58xYpxUg5sQKx2VXZYJmtNjr4dSuBJ1HeJXETQILCz3wOHvw==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.24.3", - "@smithy/types": "^4.14.2", + "@smithy/core": "^3.33.3", + "@smithy/types": "^4.18.0", "tslib": "^2.6.2" }, "engines": { @@ -4540,13 +4420,13 @@ } }, "node_modules/@smithy/signature-v4": { - "version": "5.6.4", - "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.6.4.tgz", - "integrity": "sha512-B89bpf2t/y/wia6LZ+4JfHXYQT9PnVftsH05rgJKKIStS7r/4XSs9HOjtPoLtgcA6HCW9jVqX5DBbq7E0PAkiQ==", + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.4.tgz", + "integrity": "sha512-tHy0K0VtqNd5Y7Y41h0a0Lhh0L1GzC08dTWg0F7vRJWFtTENg7IZikf3wQkanYIRdb7ngoIPMTmqgUi401fEeQ==", "license": "Apache-2.0", "dependencies": { - "@smithy/core": "^3.29.3", - "@smithy/types": "^4.16.1", + "@smithy/core": "^3.35.0", + "@smithy/types": "^4.19.0", "tslib": "^2.6.2" }, "engines": { @@ -4554,9 +4434,9 @@ } }, "node_modules/@smithy/types": { - "version": "4.16.1", - "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.16.1.tgz", - "integrity": "sha512-0JFs3V2y2M9tKW5na/qxe69Zv+uxLMO7QBbhxF/FHu/Gp2NFZAAL9tWl9PU02xxo07pb3G9FTyjNc6D5uZrJIg==", + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.19.0.tgz", + "integrity": "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q==", "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" @@ -4565,31 +4445,11 @@ "node": ">=18.0.0" } }, - "node_modules/@smithy/util-buffer-from": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@smithy/util-buffer-from/-/util-buffer-from-2.2.0.tgz", - "integrity": "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA==", - "license": "Apache-2.0", - "dependencies": { - "@smithy/is-array-buffer": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@smithy/util-utf8": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@smithy/util-utf8/-/util-utf8-2.3.0.tgz", - "integrity": "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A==", - "license": "Apache-2.0", - "dependencies": { - "@smithy/util-buffer-from": "^2.2.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=14.0.0" - } + "node_modules/@stablelib/base64": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz", + "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==", + "license": "MIT" }, "node_modules/@standard-schema/spec": { "version": "1.1.0", @@ -5593,12 +5453,12 @@ } }, "node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz", + "integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==", "license": "MIT", "engines": { - "node": ">= 14" + "node": ">= 20" } }, "node_modules/ai": { @@ -7278,6 +7138,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, + "node_modules/fast-sha256": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", + "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", + "license": "Unlicense" + }, "node_modules/fast-uri": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.6.tgz", @@ -7423,9 +7289,9 @@ } }, "node_modules/gaxios": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.2.0.tgz", - "integrity": "sha512-CUVb4wcYe+771XevyH6HtGmXFAGGKkIC3kswAP8Z1JCe0j80JMaTPZH930DWFrvo0atjh18Arc0pEyUCWa5bfg==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.3.1.tgz", + "integrity": "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ==", "license": "Apache-2.0", "dependencies": { "extend": "^3.0.2", @@ -7436,6 +7302,28 @@ "node": ">=18" } }, + "node_modules/gaxios/node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/gaxios/node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/gcp-metadata": { "version": "8.1.2", "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-8.1.2.tgz", @@ -7528,9 +7416,9 @@ } }, "node_modules/google-auth-library": { - "version": "10.9.0", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.9.0.tgz", - "integrity": "sha512-xtvUqvINPhTaBm7nXqlYPcrMHJPm1lCNdSovxnKKhTm+4JsvQ+KGVYJViLoH9Yxu8w+T0Qv5HubzYT9BLrppJg==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.9.1.tgz", + "integrity": "sha512-i1ydyHrqcIxXkWh/uBmVkzCvIuq5yiK2ATndIe5XxKholrG/MTYP9xGYka4sQhrbIAgGjL2B6NOE7rFaiF3fXw==", "license": "Apache-2.0", "dependencies": { "base64-js": "^1.3.0", @@ -7655,16 +7543,17 @@ } }, "node_modules/http-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", - "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-9.1.0.tgz", + "integrity": "sha512-2NxoveTT58mjYT4n3RPTEfCZGLMbidoO8XEieXfpSYxu+PQJ1qpx4ypwH6N+uF9twBPIvRRgvkvW5HUTYWENig==", "license": "MIT", "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" + "agent-base": "9.0.0", + "debug": "^4.3.4", + "proxy-agent-negotiate": "1.1.0" }, "engines": { - "node": ">= 14" + "node": ">= 20" } }, "node_modules/https": { @@ -7674,16 +7563,17 @@ "license": "ISC" }, "node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.1.0.tgz", + "integrity": "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA==", "license": "MIT", "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" + "agent-base": "9.0.0", + "debug": "^4.3.4", + "proxy-agent-negotiate": "1.1.0" }, "engines": { - "node": ">= 14" + "node": ">= 20" } }, "node_modules/iconv-lite": { @@ -8661,18 +8551,34 @@ } }, "node_modules/openai": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/openai/-/openai-6.26.0.tgz", - "integrity": "sha512-zd23dbWTjiJ6sSAX6s0HrCZi41JwTA1bQVs0wLQPZ2/5o2gxOJA5wh7yOAUgwYybfhDXyhwlpeQf7Mlgx8EOCA==", + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-7.19.0.tgz", + "integrity": "sha512-MX2s3u2L5racTO0CC/SWpCOasJQBCJrqLKXK+l82cAhdeF8mPMBEe/gxMm0ZFa2xpKpOFLRjxv5afYEZbBXmbQ==", "license": "Apache-2.0", - "bin": { - "openai": "bin/cli" + "engines": { + "node": ">=22.0.0" }, "peerDependencies": { - "ws": "^8.18.0", + "@aws-sdk/credential-provider-node": ">=3.972.0 <4", + "@smithy/hash-node": ">=4.3.0 <5", + "@smithy/signature-v4": ">=5.4.0 <6", + "undici": ">=5 <9", + "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "peerDependenciesMeta": { + "@aws-sdk/credential-provider-node": { + "optional": true + }, + "@smithy/hash-node": { + "optional": true + }, + "@smithy/signature-v4": { + "optional": true + }, + "undici": { + "optional": true + }, "ws": { "optional": true }, @@ -9088,6 +8994,23 @@ "node": ">= 0.10" } }, + "node_modules/proxy-agent-negotiate": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-agent-negotiate/-/proxy-agent-negotiate-1.1.0.tgz", + "integrity": "sha512-N8IBcM3UgCVzz2L2Lqv8DVntDnnC8/hiV4nEDUPkqq72TPUgYWjQc+bdZlBPZK9LzPAvOY//gAt0S0DApoOXWQ==", + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "kerberos": "^2.0.0" + }, + "peerDependenciesMeta": { + "kerberos": { + "optional": true + } + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -9760,6 +9683,16 @@ "dev": true, "license": "MIT" }, + "node_modules/standardwebhooks": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz", + "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", + "license": "MIT", + "dependencies": { + "@stablelib/base64": "^1.0.0", + "fast-sha256": "^1.3.0" + } + }, "node_modules/statuses": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", @@ -10187,9 +10120,9 @@ } }, "node_modules/typebox": { - "version": "1.1.38", - "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.1.38.tgz", - "integrity": "sha512-pZ0aQPmMmXoUvSbeuWf/Hzsc+avNw/Zd6VeE8CFgkVGWyuHPJvqeJJDeJqLve+K70LvjYIoleGcoJHPT17cWoA==", + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.27.tgz", + "integrity": "sha512-zu+jc1pcy4UiNThxikUr36f0Rybk9PEeCg/NE6adeWr/SKsdNO4EzZHYRDlv2YCVAfj3Odq3dESSo/jNyoBXzA==", "license": "MIT" }, "node_modules/typescript": { @@ -10217,7 +10150,7 @@ "version": "7.29.0", "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.0.tgz", "integrity": "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==", - "dev": true, + "devOptional": true, "license": "MIT", "engines": { "node": ">=20.18.1" diff --git a/package.json b/package.json index a242cd70..f7dce953 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "@assistant-ui/store": "0.2.19", "@convex-dev/persistent-text-streaming": "^0.3.3", "@convex-dev/workflow": "^0.3.0", - "@earendil-works/pi-ai": "0.80.6", + "@earendil-works/pi-ai": "1.1.0", "@fontsource-variable/fraunces": "^5.2.9", "@fontsource-variable/geist": "^5.2.8", "@fontsource-variable/jetbrains-mono": "^5.2.8", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 2661881a..ed7ece77 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -6,6 +6,7 @@ import type { NodeSlideInstallProfile, NodeSlideUiMode, } from '@nodeslide/registry'; +import { NODESLIDE_DEFAULT_AGENT_MODEL } from '../../../shared/nodeslide'; import { generateDeck, resolveGenerateEffort } from './generate'; import { type NodeSlideInitOptions, runNodeSlideInit, runNodeSlideUpgrade } from './index'; @@ -53,8 +54,8 @@ try { outputDirectory: pathValue(flags, 'output') ?? process.cwd(), clientSessionId: pathValue(flags, 'session') ?? `cli-${Date.now()}-${crypto.randomUUID().slice(0, 12)}`, - model: pathValue(flags, 'model') ?? 'moonshotai/kimi-k3', - effort: effortValue(flags, pathValue(flags, 'model') ?? 'moonshotai/kimi-k3'), + model: pathValue(flags, 'model') ?? NODESLIDE_DEFAULT_AGENT_MODEL, + effort: effortValue(flags, pathValue(flags, 'model') ?? NODESLIDE_DEFAULT_AGENT_MODEL), ...((pathValue(flags, 'access-code') ?? process.env['NODESLIDE_PREVIEW_ACCESS_CODE']) ? { accessCode: diff --git a/scripts/build-model-capability-ledger.mjs b/scripts/build-model-capability-ledger.mjs index 3df8dbbb..9c93d09d 100644 --- a/scripts/build-model-capability-ledger.mjs +++ b/scripts/build-model-capability-ledger.mjs @@ -51,6 +51,33 @@ const MODEL_POLICIES = { }, }; +// Rows added by the 2026-10 model refresh. None has a Deck Gym run yet (the frozen v1 matrix +// carries only kimi-k3, claude-sonnet-5 and gemini-3.5-flash), so each policy states that no role +// is claimed until a live-route ablation passes; the card reports 0 attempted runs, not a guess. +function unmeasuredPolicy(slug, label) { + return { + slug, + label, + bestRoles: ['no full-deck role until a live-route ablation passes'], + avoidRoles: ['full-deck generator', 'fallback authority', 'final taste judge'], + scaffolding: ['no-generic-fallback', 'independent route verification'], + }; +} + +MODEL_POLICIES['anthropic/claude-sonnet-5.5'] = unmeasuredPolicy( + 'claude-sonnet-5-5', + 'Claude Sonnet 5.5', +); +MODEL_POLICIES['anthropic/claude-opus-5.5'] = unmeasuredPolicy( + 'claude-opus-5-5', + 'Claude Opus 5.5', +); +MODEL_POLICIES['google/gemini-3.8-flash'] = unmeasuredPolicy( + 'gemini-3-8-flash', + 'Gemini 3.8 Flash', +); +MODEL_POLICIES['openai/gpt-6.1-sol'] = unmeasuredPolicy('gpt-6-1-sol', 'GPT-6.1 Sol'); + export async function buildModelCapabilityLedger({ artifactDir, outputDir }) { const matrix = await readJson(path.join(artifactDir, 'matrix.json')); const runDirs = await discoverRunDirs(path.join(artifactDir, 'runs')); diff --git a/scripts/capture-model-fleet-probe.mjs b/scripts/capture-model-fleet-probe.mjs index 2bacf12c..9f1d019b 100644 --- a/scripts/capture-model-fleet-probe.mjs +++ b/scripts/capture-model-fleet-probe.mjs @@ -5,7 +5,11 @@ import path from 'node:path'; import process from 'node:process'; import { ConvexHttpClient } from 'convex/browser'; import { api } from '../convex/_generated/api.js'; -import { validateModelFleetReceipt } from './lib/model-fleet-receipt-core.mjs'; +import { + EXECUTOR_SPLIT_RECEIPT_SCHEMA, + executorSplitReceiptFailures, + validateModelFleetReceipt, +} from './lib/model-fleet-receipt-core.mjs'; import { assertNodeSlideProductionDeployKey, captureNodeSlideConvexBuildIdentity, @@ -29,6 +33,7 @@ const allowedProbeFunctions = new Map([ ['runFleet', 'nodeslide.model-fleet-probe/v1'], ['runFreeRouterFleet', 'nodeslide.free-router-fleet-probe/v1'], ['runFreeRouterStructured', 'nodeslide.free-router-structured-probe/v1'], + ['runExecutorSplit', 'nodeslide.executor-split-probe/v1'], ]); if (allowedProbeFunctions.get(probeFunction) !== expectedSchema) { fail('Probe function and expected schema are not an allowed pair'); @@ -95,10 +100,20 @@ const exitCode = await new Promise((resolve, reject) => { if (exitCode !== 0) fail(`Convex fleet action failed (${safeDiagnostic(stderr)})`); const receipt = parseReceipt(stdout); -try { - validateModelFleetReceipt(receipt, expectedSchema); -} catch (error) { - fail(error instanceof Error ? error.message : 'Convex fleet action returned an invalid receipt'); +const isExecutorSplit = expectedSchema === EXECUTOR_SPLIT_RECEIPT_SCHEMA; +if (isExecutorSplit) { + // The deployed backend must be the merge commit this workflow run stamped (sourceCommit). + const failures = executorSplitReceiptFailures(receipt, sourceCommit); + receipt.passed = failures.length === 0; + receipt.failures = failures; +} else { + try { + validateModelFleetReceipt(receipt, expectedSchema); + } catch (error) { + fail( + error instanceof Error ? error.message : 'Convex fleet action returned an invalid receipt', + ); + } } const exactMainSourceAfter = await verifyNodeSlideExactMainSource( sourceCommit, @@ -121,7 +136,9 @@ const artifact = { await mkdir(path.dirname(outputPath), { recursive: true }); await writeFile(outputPath, `${JSON.stringify(artifact, null, 2)}\n`, { mode: 0o600 }); console.log( - `[model-fleet] ${receipt.passed ? 'PASS' : 'FAIL'} ${receipt.probedModelCount - receipt.failedModelCount}/${receipt.probedModelCount} offered routes returned assistant text`, + isExecutorSplit + ? `[model-fleet] ${receipt.passed ? 'PASS' : 'FAIL'} executor split${receipt.passed ? '' : `: ${receipt.failures.join('; ')}`}` + : `[model-fleet] ${receipt.passed ? 'PASS' : 'FAIL'} ${receipt.probedModelCount - receipt.failedModelCount}/${receipt.probedModelCount} offered routes returned assistant text`, ); console.log(`[model-fleet] artifact: ${path.relative(process.cwd(), outputPath)}`); if (!receipt.passed) process.exit(1); diff --git a/scripts/lib/deck-gym-campaign.mjs b/scripts/lib/deck-gym-campaign.mjs new file mode 100644 index 00000000..38ee611e --- /dev/null +++ b/scripts/lib/deck-gym-campaign.mjs @@ -0,0 +1,132 @@ +/** + * Campaign cost control for `scripts/run-deck-gym.mjs`. + * + * Situation: a person starts a keyed Deck Gym campaign of dozens of production runs and walks away. + * Nothing in the runner used to count dollars, so the only brake was how long it took. This module + * is that brake. Before a worker dequeues a run it asks `shouldStopCampaign` whether the money + * already spent, plus a worst-case reservation for this run and for every run still in flight, + * would cross the campaign cap. After a run it charges the backend budget ledger's figure (never the + * Trace inspector text, which is attribution), or the full reservation when that figure cannot be + * read. It is a separate module so the production worker and its test are the same function. + */ +import { + combineNodeGymLedgerReceipts, + nodeGymRunCharge, + shouldStopCampaign, +} from './node-gym-runner-core.mjs'; + +export const DECK_GYM_DEFAULT_LIMIT_FOR_UNCAPPED = 12; + +/** + * The campaign cap. An explicit value always wins. Without one the run count itself must bound the + * spend: a campaign of at most 12 runs is capped at its own worst case (limit x per-run cap), the + * same shape as node-gym's default cap for a bounded subset; a larger campaign must say how much it + * may spend. + */ +export function resolveDeckGymMaxTotalCostMicroUsd({ explicit, limit, perRunMaxCostMicroUsd }) { + if (explicit !== undefined) { + const parsed = Number(explicit); + if (!Number.isSafeInteger(parsed) || parsed < 0) + throw new Error('--max-total-cost-micro-usd must be a non-negative integer.'); + return parsed; + } + if (Number.isSafeInteger(limit) && limit >= 1 && limit <= DECK_GYM_DEFAULT_LIMIT_FOR_UNCAPPED) + return limit * perRunMaxCostMicroUsd; + throw new Error( + `--max-total-cost-micro-usd is required unless --limit is at most ${DECK_GYM_DEFAULT_LIMIT_FOR_UNCAPPED}.`, + ); +} + +export function createDeckGymCampaignBudget({ maxTotalCostMicroUsd, perRunMaxCostMicroUsd }) { + if (!Number.isSafeInteger(maxTotalCostMicroUsd) || maxTotalCostMicroUsd < 0) + throw new Error('Deck Gym campaign cap must be a non-negative integer.'); + if (!Number.isSafeInteger(perRunMaxCostMicroUsd) || perRunMaxCostMicroUsd < 0) + throw new Error('Deck Gym per-run cap must be a non-negative integer.'); + return { + maxTotalCostMicroUsd, + perRunMaxCostMicroUsd, + spentCostMicroUsd: 0, + inFlight: 0, + stoppedBy: null, + }; +} + +export function deckGymBudgetSummary(budget) { + return { + maxTotalCostMicroUsd: budget.maxTotalCostMicroUsd, + spentCostMicroUsd: budget.spentCostMicroUsd, + reservedInFlightMicroUsd: budget.inFlight * budget.perRunMaxCostMicroUsd, + stoppedBy: budget.stoppedBy, + }; +} + +/** + * One worker. `executeRun(run)` drives the browser and resolves to a receipt that may carry + * `backendRunIds`; `readLedger(ids)` resolves to a Map of run id -> backend ledger receipt (null when + * unreadable). Both are injected so a test drives this exact loop with a fake page and ledger. + */ +export async function deckGymWorker({ + queue, + budget, + receipts, + isResumable, + executeRun, + readLedger, + onSkip = () => undefined, + onStop = () => undefined, +}) { + while (queue.length && budget.stoppedBy === null) { + const run = queue.shift(); + if (!run) return; + if (await isResumable(run)) { + receipts.push({ runId: run.runId, status: 'skipped', reason: 'resume_artifact_exists' }); + onSkip(run); + continue; + } + // Check and reserve with no await in between: two workers must not both see the same headroom. + const decision = shouldStopCampaign({ + spentCostMicroUsd: budget.spentCostMicroUsd, + maxTotalCostMicroUsd: budget.maxTotalCostMicroUsd, + failures: 0, + maxFailures: Number.POSITIVE_INFINITY, + nextRunMaxCostMicroUsd: (budget.inFlight + 1) * budget.perRunMaxCostMicroUsd, + }); + if (decision.stop) { + queue.unshift(run); + budget.stoppedBy = decision.issueCode; + onStop(decision.issueCode, run); + return; + } + budget.inFlight += 1; + let receipt; + try { + receipt = await executeRun(run); + } catch (error) { + receipt = { + runId: run.runId, + status: 'failed', + failure: String(error instanceof Error ? error.message : error).slice(0, 300), + }; + } + let ledgerReceipt = null; + try { + const ids = Array.isArray(receipt?.backendRunIds) ? receipt.backendRunIds : []; + ledgerReceipt = combineNodeGymLedgerReceipts(ids, await readLedger(ids)); + } catch { + ledgerReceipt = null; + } + const charge = nodeGymRunCharge({ + reservationMicroUsd: budget.perRunMaxCostMicroUsd, + ledgerReceipt, + }); + budget.spentCostMicroUsd += charge.chargedMicroUsd; + budget.inFlight -= 1; + // Backend run ids are working data for the ledger lookup, not part of the published summary. + const { backendRunIds, ...publicReceipt } = receipt ?? {}; + receipts.push({ + ...publicReceipt, + backendRunCount: Array.isArray(backendRunIds) ? backendRunIds.length : 0, + budget: charge, + }); + } +} diff --git a/scripts/lib/model-fleet-receipt-core.mjs b/scripts/lib/model-fleet-receipt-core.mjs index 9cdee5c4..b2f25051 100644 --- a/scripts/lib/model-fleet-receipt-core.mjs +++ b/scripts/lib/model-fleet-receipt-core.mjs @@ -3,10 +3,14 @@ export const NODE_SLIDE_OFFERED_ROUTE_CATALOG = [ ['z-ai/glm-5.2', 'openrouter', 'z-ai/glm-5.2'], ['anthropic/claude-sonnet-5', 'openrouter', 'anthropic/claude-sonnet-5'], ['anthropic/claude-fable-5', 'openrouter', 'anthropic/claude-fable-5'], - ['google/gemini-3.5-flash', 'openrouter', 'google/gemini-3.5-flash'], + ['anthropic/claude-sonnet-5.5', 'openrouter', 'anthropic/claude-sonnet-5.5'], + ['anthropic/claude-opus-5.5', 'openrouter', 'anthropic/claude-opus-5.5'], + // google/gemini-3.5-flash left the offered set: Google deprecated it on 2026-10-08. + ['google/gemini-3.8-flash', 'openrouter', 'google/gemini-3.8-flash'], ['google/gemini-3.1-pro-preview', 'openrouter', 'google/gemini-3.1-pro-preview'], ['openai/gpt-5.6-sol', 'openrouter', 'openai/gpt-5.6-sol'], ['openai/gpt-5.6-terra', 'openrouter', 'openai/gpt-5.6-terra'], + ['openai/gpt-6.1-sol', 'openrouter', 'openai/gpt-6.1-sol'], ].map(([id, provider, upstreamId]) => ({ id, provider, upstreamId })); export const NODE_SLIDE_FREE_ROUTE_CATALOG = [ @@ -18,9 +22,12 @@ export const NODE_SLIDE_FREE_ROUTE_CATALOG = [ 'openrouter', 'nvidia/nemotron-3-super-120b-a12b:free', ], - ['openai/gpt-oss-20b:free', 'openrouter', 'openai/gpt-oss-20b:free'], + // openai/gpt-oss-20b:free dropped: absent from the OpenRouter catalog (GET /api/v1/models, 2026-10-10). ].map(([id, provider, upstreamId]) => ({ id, provider, upstreamId })); +export const EXECUTOR_SPLIT_RECEIPT_SCHEMA = 'nodeslide.executor-split-probe/v1'; +const EXECUTOR_SPLIT_EXECUTOR_MODEL = 'google/gemini-3.8-flash'; + const CATALOG_BY_SCHEMA = new Map([ ['nodeslide.model-fleet-probe/v1', NODE_SLIDE_OFFERED_ROUTE_CATALOG], ['nodeslide.free-router-fleet-probe/v1', NODE_SLIDE_FREE_ROUTE_CATALOG], @@ -127,3 +134,35 @@ function isNormalizedModelIdentity(value) { /^[A-Za-z0-9._-]+\/[A-Za-z0-9._:-]+$/u.test(value) ); } + +/** + * Acceptance rule for the routed-executor receipt (SPEC Part A, section A.2.8). Accepted only when + * the turn really split to the new executor, the provider echoed that exact model with non-zero + * usage, the executor's copy was applied, no budget refusal occurred and the deployment names the + * tested commit. Returns the failures; an empty list means accepted. Never throws on a bad receipt. + */ +export function executorSplitReceiptFailures(receipt, testedCommit) { + const failures = []; + if (!receipt || receipt.schemaVersion !== EXECUTOR_SPLIT_RECEIPT_SCHEMA) + return ['receipt schema is not nodeslide.executor-split-probe/v1']; + const routing = receipt.routing ?? {}; + if (routing.reason !== 'split_premium_planner_bulk_copy') + failures.push(`routing.reason is ${routing.reason}`); + if (routing.executorModel !== EXECUTOR_SPLIT_EXECUTOR_MODEL) + failures.push(`routing.executorModel is ${routing.executorModel}`); + if (routing.executorOutcome !== 'applied') + failures.push(`routing.executorOutcome is ${routing.executorOutcome}`); + const executor = (receipt.spans ?? []).find((entry) => entry?.toolName === 'executor'); + if (!executor) failures.push('no executor span'); + else { + if (executor.responseModel !== EXECUTOR_SPLIT_EXECUTOR_MODEL) + failures.push(`executor responseModel is ${executor.responseModel}`); + const { inputTokens, outputTokens } = executor.usage ?? {}; + if (!(inputTokens > 0 || outputTokens > 0)) failures.push('executor usage is zero'); + } + if ((receipt.budget?.refusals ?? ['missing']).length > 0) + failures.push('the budget refused a dispatch or is missing'); + if (!testedCommit || receipt.buildIdentity?.commitSha !== testedCommit) + failures.push(`buildIdentity.commitSha is ${receipt.buildIdentity?.commitSha ?? null}`); + return failures; +} diff --git a/scripts/lib/node-gym-config-core.mjs b/scripts/lib/node-gym-config-core.mjs index 370ac60e..1025e610 100644 --- a/scripts/lib/node-gym-config-core.mjs +++ b/scripts/lib/node-gym-config-core.mjs @@ -69,6 +69,10 @@ export function validateNodeGymConfig(value) { failures.push(`${model.id} must record the returned model.`); if (model.cohort === 'pinned-free' && !model.route.endsWith(':free')) failures.push(`${model.id} is not a pinned free route.`); + if (model.execution !== undefined) { + const reason = nodeGymExecutionShapeFailure(model.execution); + if (reason) failures.push(`${model?.id ?? ''} execution is invalid: ${reason}.`); + } } const harnesses = Array.isArray(value?.harnesses) ? value.harnesses : []; @@ -92,6 +96,60 @@ export function validateNodeGymConfig(value) { return { failures: [...new Set(failures)], matrixSize }; } +const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/u; + +/** + * `model.execution` is the one switch that stops a model from being run without removing its row + * (its `runId`, `comparisonKey` and `harnessPairingKey` key on `model.id`, so deleting the row would + * renumber the benchmark's identity). It accepts exactly `{ disabled: true, since, reason }`. + */ +function nodeGymExecutionShapeFailure(execution) { + if (!execution || typeof execution !== 'object' || Array.isArray(execution)) + return 'expected an object'; + const keys = Object.keys(execution).sort().join(','); + if (keys !== 'disabled,reason,since') return 'only disabled, since and reason are allowed'; + if (execution.disabled !== true) return 'disabled must be true'; + if (typeof execution.since !== 'string' || !ISO_DATE.test(execution.since)) + return 'since must be an ISO date (YYYY-MM-DD)'; + if (Number.isNaN(Date.parse(`${execution.since}T00:00:00Z`))) return 'since is not a real date'; + if (typeof execution.reason !== 'string' || !execution.reason.trim()) + return 'reason must be a non-empty string'; + return null; +} + +/** + * Splits matrix runs into those the runner may execute and those whose model row is disabled. + * Runs before runtime filtering and subset selection (`selectNodeGymSubset` derives its model list + * from the runs it receives, so a disabled model then yields no pair). A model named explicitly + * while disabled is an error, never a silent empty match. + */ +export function partitionDisabledNodeGymRuns({ runs, includeDisabled, requestedModels = [] }) { + const isDisabled = (run) => run.model?.execution?.disabled === true; + if (includeDisabled) return { runnable: [...runs], skippedDisabled: [] }; + for (const modelId of requestedModels) { + const run = runs.find((candidate) => candidate.model.id === modelId && isDisabled(candidate)); + if (run) { + const { since, reason } = run.model.execution; + throw new Error( + `Model ${modelId} is disabled since ${since}: ${reason}; pass --include-disabled to run it.`, + ); + } + } + const runnable = []; + const skippedDisabled = []; + for (const run of runs) { + if (isDisabled(run)) { + skippedDisabled.push({ + runId: run.runId, + modelId: run.model.id, + since: run.model.execution.since, + reason: run.model.execution.reason, + }); + } else runnable.push(run); + } + return { runnable, skippedDisabled }; +} + export function buildNodeGymMatrixInput(config) { return { tasks: config.tasks.map((task) => ({ diff --git a/scripts/lib/node-gym-runner-core.mjs b/scripts/lib/node-gym-runner-core.mjs index 4b50b4ad..f3acfdc4 100644 --- a/scripts/lib/node-gym-runner-core.mjs +++ b/scripts/lib/node-gym-runner-core.mjs @@ -1,5 +1,15 @@ import { createHash, randomUUID } from 'node:crypto'; -import { link, lstat, mkdir, realpath, rename, rm, writeFile } from 'node:fs/promises'; +import { + link, + lstat, + mkdir, + readFile, + readdir, + realpath, + rename, + rm, + writeFile, +} from 'node:fs/promises'; import path from 'node:path'; import { validateNodeGymConfig } from './node-gym-config-core.mjs'; @@ -85,7 +95,13 @@ export function assertNodeGymMatrixBoundToConfig({ configBytes, config, matrix, * Validates and accounts every immutable attempt receipt for one bound run. * Costs and failures are returned once for campaign-wide pre-scheduling sums. */ -export function summarizeNodeGymAttemptHistory({ plan, receipts, executor }) { +export function summarizeNodeGymAttemptHistory({ + plan, + receipts, + executor, + reservationMicroUsd = nodeGymRunReservationMicroUsd(plan), + orphanCharges = [], +}) { if (!plan?.runId) throw new Error('NodeGym history requires a bound run plan.'); if (!Array.isArray(receipts)) throw new Error(`NodeGym attempt history is invalid for ${plan.runId}.`); @@ -94,6 +110,7 @@ export function summarizeNodeGymAttemptHistory({ plan, receipts, executor }) { ); const planDigest = digestJson(plan); let spentCostMicroUsd = 0; + let reservedUnknownMicroUsd = 0; let failures = 0; let passedReceipt = null; @@ -125,9 +142,14 @@ export function summarizeNodeGymAttemptHistory({ plan, receipts, executor }) { if (nonNegativeNumber(receipt.usage?.[field]) === null) throw new Error(`${prefix} has invalid ${field} usage.`); } - const cost = Number(receipt.usage?.costMicroUsd); - if (!Number.isSafeInteger(cost) || cost < 0) + const usageCost = Number(receipt.usage?.costMicroUsd); + if (!Number.isSafeInteger(usageCost) || usageCost < 0) throw new Error(`${prefix} has invalid costMicroUsd usage.`); + // The campaign meter is the recorded charge, never the executor's own usage figure. A receipt + // written before charges were recorded has no `budget` and is charged the run's full reservation. + const charge = nodeGymReceiptCharge(receipt, reservationMicroUsd, prefix); + const cost = charge.chargedMicroUsd; + if (charge.source === 'reservation') reservedUnknownMicroUsd += cost; if (receipt.status === 'passed') { if ( receipt.automatedHardGatesPassed !== true || @@ -147,9 +169,19 @@ export function summarizeNodeGymAttemptHistory({ plan, receipts, executor }) { if (receipt.status !== 'passed') failures += 1; } + // An attempt directory found without its receipt (the runner itself died mid-attempt) was charged + // its reservation when it was set aside; those durable charges belong to the run's spend. + for (const orphan of orphanCharges) { + spentCostMicroUsd += orphan.budget.chargedMicroUsd; + reservedUnknownMicroUsd += orphan.budget.chargedMicroUsd; + } + if (!Number.isSafeInteger(spentCostMicroUsd)) + throw new Error(`NodeGym cumulative cost is unsafe for ${plan.runId}.`); + return { receipts: ordered, spentCostMicroUsd, + reservedUnknownMicroUsd, failures, latestAttempt: ordered.length, latestReceipt: ordered.at(-1) ?? null, @@ -507,6 +539,208 @@ export function validateNodeGymExecutorResult(plan, result, options = {}) { }; } +/** + * The most a single gym run can cost the backend ledger, in micro-USD. This is the per-run hard cap + * the production backend binds to every run it meters (`normalizeNodeSlideRunBudget({})` -> + * `maxCostMicroUsd`, `shared/nodeslideRunBudget.ts`), mirrored here because this module runs under + * plain `node`, which cannot load that TypeScript. `scripts/tests/node-gym-campaign-budget.test.mjs` + * fails when the two differ. + */ +export const NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD = 1_000_000; +export const NODE_GYM_LEDGER_RECEIPT_VERSION = 'nodeslide.run-budget-ledger-receipt/v1'; +export const NODE_GYM_ORPHAN_CHARGE_SCHEMA = 'nodekit.gym-orphan-attempt-charge/v1'; + +/** + * What one run reserves against the campaign before it is dispatched: the backend ledger cap that + * binds it, not the gym plan's own `budget.maxCostMicroUsd` (which the UI executor never hands to the + * backend). Local, `:free` and `openrouter/free` routes issue no metered request and reserve 0. + */ +export function nodeGymRunReservationMicroUsd( + plan, + perRunMaxCostMicroUsd = NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD, +) { + if (!Number.isSafeInteger(perRunMaxCostMicroUsd) || perRunMaxCostMicroUsd < 0) + throw new Error('NodeGym per-run reservation must be a non-negative integer.'); + const model = plan?.model; + if ( + model?.provider === 'local' || + model?.route === 'openrouter/free' || + String(model?.route ?? '').endsWith(':free') + ) + return 0; + return perRunMaxCostMicroUsd; +} + +/** + * Micro-USD one backend ledger receipt (`nodeslideBudgets.receiptForRun`) says a run cost. Exposure + * that is reserved or unreconciled (a dispatch whose outcome never came back) counts: it may still + * have been billed, and the ledger itself keeps it inside the cap. Returns null when the receipt is + * not a readable ledger receipt. + */ +export function nodeGymLedgerReceiptMicroUsd(receipt) { + if (receipt?.version !== NODE_GYM_LEDGER_RECEIPT_VERSION) return null; + const spend = receipt.spend; + const parts = [spend?.actualMicroUsd, spend?.reservedMicroUsd, spend?.unreconciledMicroUsd]; + if (!parts.every((part) => Number.isSafeInteger(part) && part >= 0)) return null; + const total = parts[0] + parts[1] + parts[2]; + return Number.isSafeInteger(total) ? total : null; +} + +/** + * Combines the ledger receipts of every backend run one gym attempt caused. Any run that is named but + * unreadable (or no run named at all) makes the whole attempt's usage unknown: returns null. + */ +export function combineNodeGymLedgerReceipts(backendRunIds, receiptsByRunId) { + if (!Array.isArray(backendRunIds) || backendRunIds.length === 0) return null; + let total = 0; + for (const runId of new Set(backendRunIds)) { + const charged = nodeGymLedgerReceiptMicroUsd(receiptsByRunId?.get?.(runId) ?? null); + if (charged === null) return null; + total += charged; + } + return Number.isSafeInteger(total) ? { chargedMicroUsd: total } : null; +} + +/** + * The one charge rule for a finished run. A readable backend ledger receipt is the charge. Anything + * else — a crash, a timeout, a failure result, a missing or invalid result, no backend run ids, an + * unreadable receipt — keeps the run's full reservation: an unknown spend is never a zero. + */ +export function nodeGymRunCharge({ reservationMicroUsd, ledgerReceipt }) { + if (!Number.isSafeInteger(reservationMicroUsd) || reservationMicroUsd < 0) + throw new Error('NodeGym run charge requires a non-negative integer reservation.'); + const ledger = ledgerReceipt?.chargedMicroUsd; + if (Number.isSafeInteger(ledger) && ledger >= 0) + return { chargedMicroUsd: ledger, source: 'ledger' }; + return { chargedMicroUsd: reservationMicroUsd, source: 'reservation' }; +} + +/** + * Charges one finished attempt. The backend ledger is the meter: a completed executor result names + * the backend runs it caused (`backendRunIds`) and `readLedger(ids)` resolves their ledger receipts + * (Map of run id -> receipt). A crash, timeout, missing or invalid result, no run ids or any + * unreadable receipt keeps the full reservation; a failure result is charged the ledger only when it + * names the backend runs the executor had already started. The executor's own `usage.costMicroUsd` and + * the Trace inspector text are attribution and never reach this function. + */ +export async function chargeNodeGymAttempt({ reservationMicroUsd, result, readLedger }) { + const ids = result?.backendRunIds; + const named = + Array.isArray(ids) && + ids.length > 0 && + ids.length <= 64 && + ids.every((id) => typeof id === 'string' && id.length > 0 && id.length <= 512); + let ledgerReceipt = null; + if (reservationMicroUsd > 0 && named) { + try { + ledgerReceipt = combineNodeGymLedgerReceipts(ids, await readLedger(ids)); + } catch { + ledgerReceipt = null; + } + } + return nodeGymRunCharge({ reservationMicroUsd, ledgerReceipt }); +} + +/** The charge a stored attempt receipt carries; a receipt from before charges were recorded owes the reservation. */ +export function nodeGymReceiptCharge(receipt, reservationMicroUsd, label = 'NodeGym receipt') { + const budget = receipt?.budget; + if (budget === undefined) return { chargedMicroUsd: reservationMicroUsd, source: 'reservation' }; + if ( + !budget || + !Number.isSafeInteger(budget.chargedMicroUsd) || + budget.chargedMicroUsd < 0 || + !['ledger', 'reservation'].includes(budget.source) + ) + throw new Error(`${label} has an invalid budget charge.`); + return { chargedMicroUsd: budget.chargedMicroUsd, source: budget.source }; +} + +/** Durable record for an attempt directory that never produced a receipt: it is charged its reservation. */ +export function nodeGymOrphanAttemptCharge({ runId, attempt, reservationMicroUsd }) { + return { + schemaVersion: NODE_GYM_ORPHAN_CHARGE_SCHEMA, + runId, + attempt, + budget: { chargedMicroUsd: reservationMicroUsd, source: 'reservation' }, + }; +} + +export function assertNodeGymOrphanCharge(value, runId, label = 'NodeGym orphan charge') { + if ( + value?.schemaVersion !== NODE_GYM_ORPHAN_CHARGE_SCHEMA || + value.runId !== runId || + !Number.isSafeInteger(value.attempt) || + value.attempt < 1 || + value.budget?.source !== 'reservation' || + !Number.isSafeInteger(value.budget?.chargedMicroUsd) || + value.budget.chargedMicroUsd < 0 + ) + throw new Error(`${label} is invalid for ${runId}.`); + return value; +} + +const ORPHAN_ATTEMPT_DIR = /^orphaned-attempt-(\d{3,})-(\d+)$/u; +const ORPHAN_CHARGE_FILE = /^orphaned-attempt-(\d{3,})-(\d+)\.charge\.json$/u; + +/** + * The runner itself died mid-attempt: `attempts/attempt-NNN/` exists but no `attempt-NNN.json` + * receipt was ever written, so what that attempt spent is unknown. Each such directory is charged the + * run's full reservation, durably, and set aside so the attempt number can be re-issued. The charge + * file is written first (a crash between the two steps over-charges once, never under-charges) and + * a pending charge whose directory has not been renamed yet is reused, so a repeated resume does not + * charge the same directory twice. + */ +export async function setAsideNodeGymOrphanAttempts({ + campaignRoot, + attemptsDir, + runId, + orphanAttempts, + reservationMicroUsd, +}) { + for (const attempt of [...orphanAttempts].sort((left, right) => left - right)) { + const stem = String(attempt).padStart(3, '0'); + const names = await readdir(attemptsDir); + const pending = names + .map((name) => ORPHAN_CHARGE_FILE.exec(name)) + .filter((match) => match && match[1] === stem) + .map((match) => Number(match[2])) + .find((k) => !names.includes(`orphaned-attempt-${stem}-${k}`)); + const used = names + .flatMap((name) => [ORPHAN_CHARGE_FILE.exec(name), ORPHAN_ATTEMPT_DIR.exec(name)]) + .filter((match) => match && match[1] === stem) + .map((match) => Number(match[2])); + const k = pending ?? Math.max(0, ...used) + 1; + const chargePath = path.join(attemptsDir, `orphaned-attempt-${stem}-${k}.charge.json`); + if (pending === undefined) { + const charge = nodeGymOrphanAttemptCharge({ runId, attempt, reservationMicroUsd }); + await writeNodeGymFileAtomic( + campaignRoot, + chargePath, + `${JSON.stringify(charge, null, 2)}\n`, + { + exclusive: true, + label: 'orphaned attempt charge', + }, + ); + } + await rename( + path.join(attemptsDir, `attempt-${stem}`), + path.join(attemptsDir, `orphaned-attempt-${stem}-${k}`), + ); + } +} + +/** Every durable orphan charge recorded for one run, validated. */ +export async function loadNodeGymOrphanCharges({ attemptsDir, runId }) { + const charges = []; + for (const name of await readdir(attemptsDir)) { + if (!ORPHAN_CHARGE_FILE.test(name)) continue; + const raw = JSON.parse(await readFile(path.join(attemptsDir, name), 'utf8')); + charges.push(assertNodeGymOrphanCharge(raw, runId, `NodeGym orphan charge ${name}`)); + } + return charges; +} + export function shouldStopCampaign(input) { // Equality is allowed so zero-cost controls/free routes can run under a zero // aggregate cap. Any positive metered cost then trips the next boundary. diff --git a/scripts/lib/node-gym-selection-core.mjs b/scripts/lib/node-gym-selection-core.mjs new file mode 100644 index 00000000..a7a0090b --- /dev/null +++ b/scripts/lib/node-gym-selection-core.mjs @@ -0,0 +1,46 @@ +import { partitionDisabledNodeGymRuns } from './node-gym-config-core.mjs'; +import { applyPairSafeLimit, selectNodeGymSubset } from './node-gym-runner-core.mjs'; +import { filterNodeGymRunsForRuntime } from './node-gym-task-core.mjs'; + +/** + * Which matrix runs a campaign executes. The order is load-bearing: explicit filters first, then the + * disabled-model partition, and only THEN runtime filtering and subset selection, because + * `selectNodeGymSubset` derives its model list from the runs it receives, so a disabled model that + * is partitioned out first yields no pair and `--subset all` drops exactly its runs. + */ +export function selectNodeGymCampaignRuns({ + matrix, + config, + filters, + subset, + limit = Number.POSITIVE_INFINITY, + includeDisabled = false, + runtime = process.env, +}) { + const explicitlyFilteredRuns = matrix.runs.filter( + (run) => + (!filters.tasks.length || filters.tasks.includes(run.task.id)) && + (!filters.models.length || filters.models.includes(run.model.id)) && + (!filters.harnesses.length || filters.harnesses.includes(run.harness.id)) && + (!filters.repetitions.length || filters.repetitions.includes(run.repetition)), + ); + const { runnable, skippedDisabled } = partitionDisabledNodeGymRuns({ + runs: explicitlyFilteredRuns, + includeDisabled, + requestedModels: filters.models, + }); + const filteredRuns = filterNodeGymRunsForRuntime({ + runs: runnable, + tasks: config.tasks, + runtime, + explicitTaskIds: filters.tasks, + }); + if (!filteredRuns.length) throw new Error('Explicit NodeGym selection matched no matrix runs.'); + return { + selectedRuns: applyPairSafeLimit( + selectNodeGymSubset({ ...matrix, runs: filteredRuns }, subset), + limit, + ), + skippedDisabled, + }; +} diff --git a/scripts/lib/nodeslide-backend-runs.mjs b/scripts/lib/nodeslide-backend-runs.mjs new file mode 100644 index 00000000..66a7046c --- /dev/null +++ b/scripts/lib/nodeslide-backend-runs.mjs @@ -0,0 +1,80 @@ +/** + * Which backend runs did one browser session cause, and what did the budget ledger charge for them? + * + * The campaign runners (`run-deck-gym.mjs`, `run-node-gym.mjs` via the UI executor) drive the + * production site in a fresh browser context per run, so every backend job in that context's client + * session belongs to that run. The ledger (`nodeslideBudgets.receiptForRun`) is the meter; this + * module only finds the run ids and reads the receipts. It never reads cost from the Trace inspector. + */ + +export const NODESLIDE_SESSION_ID_STORAGE_KEY = 'parity.studio.sessionId'; +const MAX_BACKEND_RUN_IDS = 64; + +export function productionConvexUrl(value) { + const url = new URL(value); + if ( + url.protocol !== 'https:' || + url.username || + url.password || + url.hash || + !url.hostname.endsWith('.convex.cloud') + ) + throw new Error('Convex URL must be a clean production Convex HTTPS URL.'); + return url; +} + +/** The two Convex reads the runners need, bound to a production deployment. */ +export async function createNodeSlideBackendClient(convexUrl) { + const [{ ConvexHttpClient }, { api }] = await Promise.all([ + import('convex/browser'), + import('../../convex/_generated/api.js'), + ]); + const client = new ConvexHttpClient(productionConvexUrl(convexUrl).origin); + return { + listSessionJobs: (clientSessionId) => + client.query(api.nodeslideJobs.listSessionJobs, { clientSessionId }), + receiptForRun: (runId) => client.query(api.nodeslideBudgets.receiptForRun, { runId }), + }; +} + +/** + * Backend run ids (job ids) the page's client session caused. Returns [] when the session id cannot + * be read or the list cannot be fetched: the caller then treats usage as unknown and keeps the + * run's full reservation. + */ +export async function readBackendRunIds({ page, backend }) { + try { + const clientSessionId = await page.evaluate((key) => { + try { + return window.localStorage.getItem(key) ?? window.sessionStorage.getItem(key) ?? ''; + } catch { + return ''; + } + }, NODESLIDE_SESSION_ID_STORAGE_KEY); + if (typeof clientSessionId !== 'string' || !clientSessionId) return []; + const jobs = await backend.listSessionJobs(clientSessionId); + if (!Array.isArray(jobs)) return []; + return [ + ...new Set( + jobs + .map((job) => job?.jobId) + .filter((jobId) => typeof jobId === 'string' && jobId.length > 0 && jobId.length <= 512), + ), + ].slice(0, MAX_BACKEND_RUN_IDS); + } catch { + return []; + } +} + +/** Ledger receipts keyed by run id; a read that fails or finds no row is stored as null (unknown). */ +export async function readLedgerReceipts({ backend, runIds }) { + const receipts = new Map(); + for (const runId of runIds ?? []) { + try { + receipts.set(runId, (await backend.receiptForRun(runId)) ?? null); + } catch { + receipts.set(runId, null); + } + } + return receipts; +} diff --git a/scripts/node-gym-runner-core.test.mjs b/scripts/node-gym-runner-core.test.mjs index bc1b3e73..552b8136 100644 --- a/scripts/node-gym-runner-core.test.mjs +++ b/scripts/node-gym-runner-core.test.mjs @@ -125,6 +125,10 @@ function immutableReceipt(plan, attempt, status, costMicroUsd) { automatedHardGatesPassed: status === 'passed', issueCodes: status === 'passed' ? [] : ['provider_error'], usage: { ...passed.usage, costMicroUsd }, + // Receipts now record what the campaign was charged (backend ledger figure); the figures these + // tests assert are unchanged. A receipt without `budget` is covered in + // scripts/tests/node-gym-campaign-budget.test.mjs. + budget: { chargedMicroUsd: costMicroUsd, source: 'ledger' }, attempt, recordedAt: `2026-07-22T00:00:0${attempt}.000Z`, }; diff --git a/scripts/node-gym-ui-executor.mjs b/scripts/node-gym-ui-executor.mjs index 2aac170c..8be3f4be 100644 --- a/scripts/node-gym-ui-executor.mjs +++ b/scripts/node-gym-ui-executor.mjs @@ -24,6 +24,7 @@ import { } from './lib/node-gym-task-core.mjs'; import { buildNodeGymUiEvidenceEnvelope } from './lib/node-gym-ui-evidence-core.mjs'; import { sanitizeNodeGymArtifactShadowReceipt } from './lib/node-gym-ui-shadow-core.mjs'; +import { createNodeSlideBackendClient, readBackendRunIds } from './lib/nodeslide-backend-runs.mjs'; import { cleanupNodeSlideProductionFixture, productionFixtureCleanupDisposition, @@ -55,6 +56,7 @@ let capturedTrace = null; let createdDeckId = ''; let ownerAccessKey = ''; let creationSubmitted = false; +let backendRunIds = []; let uiEvidenceInput = null; try { if (plan.model.provider === 'local') throw new Error('UI executor does not accept local models.'); @@ -140,6 +142,12 @@ try { await page.screenshot({ path: browserPath, fullPage: true }); const trace = await captureTrace(page, plan.model.route); capturedTrace = trace; + // The backend runs this browser session caused. The runner (not this executor) reads their + // budget-ledger receipts to charge the campaign; a failure result deliberately omits them. + backendRunIds = await readBackendRunIds({ + page, + backend: await createNodeSlideBackendClient(convexUrl.href), + }).catch(() => []); await writeFile(path.join(runDir, 'trace.json'), `${JSON.stringify(trace, null, 2)}\n`, { mode: 0o600, }); @@ -283,6 +291,7 @@ try { runId: plan.runId, pairingKey: plan.pairingKey, status: 'completed', + backendRunIds, route: { mode: routeMode, requestedRoute: plan.model.route, @@ -336,6 +345,14 @@ try { }; } } catch (error) { + if (creationSubmitted && page && backendRunIds.length === 0) { + // Creation was submitted before the failure: name the backend runs it started so the runner + // charges the ledger's figure instead of the whole reservation. + backendRunIds = await readBackendRunIds({ + page, + backend: await createNodeSlideBackendClient(convexUrl.href), + }).catch(() => []); + } result = failureResult( exportTimedOut ? 'artifact-failure' : 'failed', [exportTimedOut ? 'pptx_export_timeout' : 'ui_executor_failed'], @@ -411,6 +428,7 @@ function failureResult(status, issueCodes, failure = null) { costMicroUsd: 0, repairCount: 0, }, + ...(backendRunIds.length ? { backendRunIds } : {}), artifacts: {}, diagnostics: { estimatedTextOverflowCount: 0, diff --git a/scripts/run-deck-gym.mjs b/scripts/run-deck-gym.mjs index 04facfe2..bf80cbc7 100644 --- a/scripts/run-deck-gym.mjs +++ b/scripts/run-deck-gym.mjs @@ -3,12 +3,44 @@ import { mkdir, readFile, stat, writeFile } from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; import { chromium } from 'playwright'; +import { + createDeckGymCampaignBudget, + deckGymBudgetSummary, + deckGymWorker, + resolveDeckGymMaxTotalCostMicroUsd, +} from './lib/deck-gym-campaign.mjs'; +import { NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD } from './lib/node-gym-runner-core.mjs'; +import { + createNodeSlideBackendClient, + readBackendRunIds, + readLedgerReceipts, +} from './lib/nodeslide-backend-runs.mjs'; const matrixPath = path.resolve(option('matrix') ?? 'artifacts/deck-gym/deck-gym-v1/matrix.json'); const runsDir = path.resolve(option('runs-dir') ?? path.join(path.dirname(matrixPath), 'runs')); const baseUrl = productionUrl(option('url') ?? 'https://nodeslide.vercel.app/'); const requestedConcurrency = positiveInteger(option('concurrency'), 2); const limit = positiveInteger(option('limit'), Number.MAX_SAFE_INTEGER); +// What one run can cost the backend ledger at most (its hard per-run cap, 1 USD by default); every +// in-flight run is reserved at this worst case. Raise it only for a campaign of long-form decks, +// whose create budget is higher (`convex/lib/nodeslideCreateScale.ts`). +const perRunMaxCostMicroUsd = nonNegativeInteger( + option('per-run-max-cost-micro-usd'), + NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD, +); +const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: resolveDeckGymMaxTotalCostMicroUsd({ + explicit: option('max-total-cost-micro-usd'), + limit: option('limit') === undefined ? undefined : limit, + perRunMaxCostMicroUsd, + }), + perRunMaxCostMicroUsd, +}); +const backend = await createNodeSlideBackendClient( + option('convex-url') ?? + process.env.NODE_GYM_PROD_CONVEX_URL ?? + 'https://agile-stoat-411.convex.cloud', +); const resume = !process.argv.includes('--no-resume'); const matrix = JSON.parse(await readFile(matrixPath, 'utf8')); if (matrix?.schemaVersion !== 'nodeslide.deck-gym-matrix/v1' || !Array.isArray(matrix.runs)) { @@ -41,6 +73,7 @@ const summary = { completed: receipts.filter((entry) => entry.status === 'completed').length, failed: receipts.filter((entry) => entry.status === 'failed').length, skipped: receipts.filter((entry) => entry.status === 'skipped').length, + budget: deckGymBudgetSummary(budget), concurrency: maxConcurrency, productionOrigin: baseUrl.origin, receipts, @@ -49,23 +82,33 @@ await writeJson(path.join(path.dirname(runsDir), 'generation-summary.json'), sum console.log( `[deck-gym] generation complete: ${summary.completed} completed, ${summary.failed} failed, ${summary.skipped} skipped`, ); -if (summary.failed) process.exitCode = 1; +if (budget.stoppedBy) { + console.error( + `[deck-gym] campaign stopped by ${budget.stoppedBy}: ${queue.length} run(s) not started (spent ${budget.spentCostMicroUsd} of ${budget.maxTotalCostMicroUsd} micro-USD).`, + ); +} +if (summary.failed || budget.stoppedBy) process.exitCode = 1; -async function worker(workerId) { - while (queue.length) { - const run = queue.shift(); - if (!run) return; - const runDir = path.join(runsDir, run.runId); - const pptxPath = path.join(runDir, 'deck.pptx'); - const existing = await readJson(path.join(runDir, 'run.json')).catch(() => null); - if (resume && (await exists(pptxPath)) && existing?.execution?.status === 'completed') { - receipts.push({ runId: run.runId, status: 'skipped', reason: 'resume_artifact_exists' }); - console.log(`[deck-gym:${workerId}] SKIP ${run.runId}`); - continue; - } - const receipt = await executeRun(workerId, run, runDir); - receipts.push(receipt); - } +function worker(workerId) { + return deckGymWorker({ + queue, + budget, + receipts, + isResumable: async (run) => { + const runDir = path.join(runsDir, run.runId); + const existing = await readJson(path.join(runDir, 'run.json')).catch(() => null); + return ( + resume && + (await exists(path.join(runDir, 'deck.pptx'))) && + existing?.execution?.status === 'completed' + ); + }, + executeRun: (run) => executeRun(workerId, run, path.join(runsDir, run.runId)), + readLedger: (runIds) => readLedgerReceipts({ backend, runIds }), + onSkip: (run) => console.log(`[deck-gym:${workerId}] SKIP ${run.runId}`), + onStop: (issueCode, run) => + console.error(`[deck-gym:${workerId}] STOP before ${run.runId}: ${issueCode}`), + }); } async function executeRun(workerId, run, runDir) { @@ -87,6 +130,7 @@ async function executeRun(workerId, run, runDir) { serviceWorkers: 'block', }); const page = await context.newPage(); + let backendRunIds = []; page.on('pageerror', (error) => runtimeErrors.push(`pageerror: ${safeError(error.message)}`)); page.on('console', (message) => { if (message.type() === 'error') @@ -120,6 +164,7 @@ async function executeRun(workerId, run, runDir) { await page.getByTestId('slide-canvas').waitFor({ timeout: 45_000 }); await page.screenshot({ path: path.join(runDir, 'editor.png'), fullPage: true }); const trace = await captureTrace(page); + backendRunIds = await readBackendRunIds({ page, backend }); await page.getByLabel('Export deck').click(); await page.getByTestId('export-pptx').waitFor({ timeout: 30_000 }); @@ -148,7 +193,12 @@ async function executeRun(workerId, run, runDir) { console.log( `[deck-gym:${workerId}] PASS ${run.runId} (${Math.round(execution.durationMs / 1000)}s; ${trace.classification})`, ); - return { runId: run.runId, status: 'completed', durationMs: execution.durationMs }; + return { + runId: run.runId, + status: 'completed', + durationMs: execution.durationMs, + backendRunIds, + }; } catch (error) { const failure = safeError(error); await page @@ -166,7 +216,9 @@ async function executeRun(workerId, run, runDir) { }, }); console.error(`[deck-gym:${workerId}] FAIL ${run.runId}: ${failure}`); - return { runId: run.runId, status: 'failed', failure }; + // The page may already have started a metered job before it failed; ask the ledger anyway. + if (!backendRunIds.length) backendRunIds = await readBackendRunIds({ page, backend }); + return { runId: run.runId, status: 'failed', failure, backendRunIds }; } finally { await context.close(); } @@ -211,6 +263,14 @@ function option(name) { return index >= 0 ? process.argv[index + 1] : undefined; } +function nonNegativeInteger(value, fallback) { + if (value === undefined) return fallback; + const parsed = Number(value); + if (!Number.isSafeInteger(parsed) || parsed < 0) + throw new Error('--per-run-max-cost-micro-usd must be a non-negative integer.'); + return parsed; +} + function positiveInteger(value, fallback) { const parsed = Number(value); return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : fallback; diff --git a/scripts/run-node-gym.mjs b/scripts/run-node-gym.mjs index 303d5f4e..04d73686 100644 --- a/scripts/run-node-gym.mjs +++ b/scripts/run-node-gym.mjs @@ -12,6 +12,7 @@ import { import { buildNodeGymMatrix } from './lib/node-gym-matrix-core.mjs'; import { redactNodeGymDiagnostic } from './lib/node-gym-redaction-core.mjs'; import { + NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD, NODE_GYM_EXECUTOR_RESULT_SCHEMA, applyPairSafeLimit, assertNodeGymAttemptEvidence, @@ -21,14 +22,19 @@ import { assertNodeGymPassedSemanticEvaluation, assertNodeGymRealPathContained, assertNodeGymSafePathSyntax, + chargeNodeGymAttempt, digestJson, + loadNodeGymOrphanCharges, nodeGymReceiptArtifactBindings, + nodeGymRunReservationMicroUsd, selectNodeGymSubset, + setAsideNodeGymOrphanAttempts, shouldStopCampaign, summarizeNodeGymAttemptHistory, validateNodeGymExecutorResult, writeNodeGymFileAtomic, } from './lib/node-gym-runner-core.mjs'; +import { selectNodeGymCampaignRuns } from './lib/node-gym-selection-core.mjs'; import { assertNoProtectedFixtureLeakage, bindNodeGymRunPlanToFixture, @@ -38,6 +44,7 @@ import { loadNodeGymTaskFixture, projectNodeGymProtectedFixtureForEgress, } from './lib/node-gym-task-core.mjs'; +import { createNodeSlideBackendClient, readLedgerReceipts } from './lib/nodeslide-backend-runs.mjs'; if (process.argv.includes('--help') || process.argv.includes('-h')) { console.log(`Usage: node scripts/run-node-gym.mjs [options] @@ -55,6 +62,9 @@ Execution: --allow-live Required by the production UI executor --campaign-id --max-total-cost-micro-usd + --per-run-max-cost-micro-usd Backend ledger cap each run reserves (default 1000000) + --convex-url Production Convex deployment the ledger is read from + --include-disabled Run models whose gym.json row sets execution.disabled --max-failures --max-attempts --source-campaign Required by recovery executor @@ -94,24 +104,18 @@ const filters = { harnesses: csvOption('harness'), repetitions: csvOption('repetition').map(Number), }; -const explicitlyFilteredRuns = matrix.runs.filter( - (run) => - (!filters.tasks.length || filters.tasks.includes(run.task.id)) && - (!filters.models.length || filters.models.includes(run.model.id)) && - (!filters.harnesses.length || filters.harnesses.includes(run.harness.id)) && - (!filters.repetitions.length || filters.repetitions.includes(run.repetition)), -); -const filteredRuns = filterNodeGymRunsForRuntime({ - runs: explicitlyFilteredRuns, - tasks: config.tasks, +// A model row marked `execution.disabled` stays in the matrix (its identity keys on model.id) but is +// partitioned out inside the selection, before runtime filtering and subset selection. +const { selectedRuns, skippedDisabled } = selectNodeGymCampaignRuns({ + matrix, + config, + filters, + subset, + limit: positiveInteger(option('limit'), Number.POSITIVE_INFINITY), + includeDisabled: process.argv.includes('--include-disabled'), runtime: process.env, - explicitTaskIds: filters.tasks, }); -if (!filteredRuns.length) throw new Error('Explicit NodeGym selection matched no matrix runs.'); -const selectedEntries = applyPairSafeLimit( - selectNodeGymSubset({ ...matrix, runs: filteredRuns }, subset), - positiveInteger(option('limit'), Number.POSITIVE_INFINITY), -).map((run) => { +const selectedEntries = selectedRuns.map((run) => { const task = config.tasks.find((entry) => entry.id === run.task.id); if (!task) throw new Error(`Matrix task ${run.task.id} is absent from the gym config.`); const loadedFixture = loadNodeGymTaskFixture({ task }); @@ -147,6 +151,21 @@ const maxTotalCostMicroUsd = nonNegativeInteger( ); if (maxTotalCostMicroUsd === null) throw new Error('An explicit --max-total-cost-micro-usd is required for full execution.'); +const perRunMaxCostMicroUsd = nonNegativeInteger( + option('per-run-max-cost-micro-usd'), + NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD, +); +// The deterministic and recovery executors issue no metered backend request (recovery re-reads a +// finished campaign's artifacts), so they reserve nothing; the UI executor and any custom script do. +const reservationFor = (plan) => + ['deterministic', 'recovery'].includes(executor) + ? 0 + : nodeGymRunReservationMicroUsd(plan, perRunMaxCostMicroUsd); +const convexUrl = + option('convex-url') ?? + process.env.NODE_GYM_PROD_CONVEX_URL ?? + 'https://agile-stoat-411.convex.cloud'; +let backendClient = null; const maxFailures = positiveInteger(option('max-failures'), subset === 'all' ? 6 : 2); const maxAttempts = positiveInteger(option('max-attempts'), 2); await assertNodeGymRealPathContained(root, artifactRoot, 'NodeGym artifact root'); @@ -166,6 +185,7 @@ const campaignPlan = { selectedRunIds: selected.map((run) => run.runId), filters, maxTotalCostMicroUsd, + perRunMaxCostMicroUsd, maxFailures, maxAttempts, fullMatrixExplicitlyConfirmed: subset === 'all' && fullConfirmed, @@ -182,6 +202,7 @@ for (const entry of selectedEntries) assertProtectedOutput(campaignPlan, entry.l await writeImmutableJson(path.join(campaignRoot, 'campaign-plan.json'), campaignPlan); let spentCostMicroUsd = 0; +let reservedUnknownMicroUsd = 0; let failures = 0; const summaryRuns = []; const semanticEvaluations = new Map(); @@ -201,8 +222,15 @@ for (const entry of selectedEntries) { await assertNodeGymRealPathContained(campaignRoot, attemptsDir, 'run artifact directory'); assertProtectedOutput(plan, entry.loadedFixture); await writeImmutableJson(path.join(runDir, 'plan.json'), plan); - const history = await loadNodeGymAttemptHistory({ plan, runDir, attemptsDir, executor }); + const history = await loadNodeGymAttemptHistory({ + plan, + runDir, + attemptsDir, + executor, + reservationMicroUsd: reservationFor(plan), + }); spentCostMicroUsd += history.spentCostMicroUsd; + reservedUnknownMicroUsd += history.reservedUnknownMicroUsd; failures += history.failures; if (!Number.isSafeInteger(spentCostMicroUsd)) throw new Error('NodeGym campaign cumulative cost exceeds the safe integer range.'); @@ -259,7 +287,7 @@ for (const plan of selected) { maxTotalCostMicroUsd, failures, maxFailures, - nextRunMaxCostMicroUsd: projectedRunCostMicroUsd(plan), + nextRunMaxCostMicroUsd: reservationFor(plan), }); if (circuit.stop) { stoppedBy = circuit.issueCode; @@ -308,6 +336,7 @@ for (const plan of selected) { })); const result = await bindArtifacts(rawResult, attemptWorkspace); assertProtectedOutput(result, entry.loadedFixture); + const charge = await chargeAttempt(plan, result); await writeImmutableJson(resultPath, result); const semanticEvaluation = evaluateEvidenceBoundNodeGymRun({ plan, @@ -336,6 +365,9 @@ for (const plan of selected) { semanticEvaluation, }), attempt, + // What this attempt cost the campaign: the backend ledger's figure, or the full reservation + // when that figure could not be read. `usage.costMicroUsd` stays above as attribution only. + budget: charge, attemptEvidence: { schemaVersion: 'nodekit.gym-attempt-evidence/v1', artifactRoot: path.relative(runDir, attemptWorkspace).replaceAll('\\', '/'), @@ -358,7 +390,8 @@ for (const plan of selected) { await writeImmutableJson(attemptPath, receipt); await writeJson(path.join(runDir, 'latest.json'), receipt); attemptReceiptCount += 1; - spentCostMicroUsd += receipt.usage.costMicroUsd; + spentCostMicroUsd += charge.chargedMicroUsd; + if (charge.source === 'reservation') reservedUnknownMicroUsd += charge.chargedMicroUsd; if (receipt.status !== 'passed') failures += 1; summaryRuns.push({ runId: plan.runId, @@ -420,6 +453,14 @@ const summary = { .length, unrun: selected.filter((run) => !completedRunIds.has(run.runId)).map((run) => run.runId), spentCostMicroUsd, + budget: { + maxTotalCostMicroUsd, + spentCostMicroUsd, + reservedUnknownMicroUsd, + stoppedBy, + }, + skippedDisabled, + skippedDisabledCount: skippedDisabled.length, failureAttempts: failures, attemptReceiptCount, historicSpentCostMicroUsd, @@ -620,6 +661,7 @@ async function loadNodeGymAttemptHistory({ runDir, attemptsDir, executor: selectedExecutor, + reservationMicroUsd, }) { const entries = await readdir(attemptsDir, { withFileTypes: true }); const receipts = []; @@ -650,17 +692,31 @@ async function loadNodeGymAttemptHistory({ receipts.push(receipt); } const receiptAttempts = new Set(receipts.map((receipt) => receipt.attempt)); - if ( - workspaceAttempts.size !== receiptAttempts.size || - [...workspaceAttempts].some((attempt) => !receiptAttempts.has(attempt)) - ) + // A receipt without its workspace is corruption. A workspace without its receipt is the runner + // having died mid-attempt: its spend is unknown, so it is charged its reservation and set aside. + if ([...receiptAttempts].some((attempt) => !workspaceAttempts.has(attempt))) throw new Error( `NodeGym immutable attempt workspaces do not match receipts for ${plan.runId}.`, ); + const orphanAttempts = [...workspaceAttempts].filter((attempt) => !receiptAttempts.has(attempt)); + if (orphanAttempts.length) { + await setAsideNodeGymOrphanAttempts({ + campaignRoot, + attemptsDir, + runId: plan.runId, + orphanAttempts, + reservationMicroUsd, + }); + console.warn( + `[node-gym] ${plan.runId}: attempt(s) ${orphanAttempts.join(', ')} had no receipt; charged ${reservationMicroUsd} micro-USD each and set aside`, + ); + } const history = summarizeNodeGymAttemptHistory({ plan, receipts, executor: selectedExecutor, + reservationMicroUsd, + orphanCharges: await loadNodeGymOrphanCharges({ attemptsDir, runId: plan.runId }), }); const latest = await readOptionalJson(path.join(runDir, 'latest.json')); assertNodeGymLatestReceipt(history, latest); @@ -785,14 +841,16 @@ function executorEnvironment(gymConfig, evaluationFixture, protectedFixture) { return environment; } -function projectedRunCostMicroUsd(plan) { - if ( - plan.model.provider === 'local' || - plan.model.route === 'openrouter/free' || - plan.model.route.endsWith(':free') - ) - return 0; - return plan.budget.maxCostMicroUsd; +/** Charges one finished attempt to the campaign; the rule lives in node-gym-runner-core.mjs. */ +async function chargeAttempt(plan, result) { + return await chargeNodeGymAttempt({ + reservationMicroUsd: reservationFor(plan), + result, + readLedger: async (runIds) => { + backendClient ??= await createNodeSlideBackendClient(convexUrl); + return await readLedgerReceipts({ backend: backendClient, runIds }); + }, + }); } function assertProtectedOutput(value, loadedFixture) { diff --git a/scripts/tests/deck-gym-campaign-budget.test.mjs b/scripts/tests/deck-gym-campaign-budget.test.mjs new file mode 100644 index 00000000..afa42059 --- /dev/null +++ b/scripts/tests/deck-gym-campaign-budget.test.mjs @@ -0,0 +1,235 @@ +/** + * Deck Gym campaign budget (SPEC Part A section A.2.8; Codex N1). + * + * Situation: someone points `npm run deck-gym:run` at production with two concurrent browsers and + * leaves. Before this change nothing counted dollars. These tests drive the REAL worker loop + * (`deckGymWorker`, the same function `scripts/run-deck-gym.mjs` runs) with fake runs standing in for + * the browser page and a fake backend budget ledger, and assert the queue stops before the cap even + * when two runs are in flight, each reserved at its worst case. + */ +import { describe, expect, it } from 'vitest'; +import { + createDeckGymCampaignBudget, + deckGymBudgetSummary, + deckGymWorker, + resolveDeckGymMaxTotalCostMicroUsd, +} from '../lib/deck-gym-campaign.mjs'; +import { NODE_GYM_LEDGER_RECEIPT_VERSION } from '../lib/node-gym-runner-core.mjs'; + +const ledger = (actual) => ({ + version: NODE_GYM_LEDGER_RECEIPT_VERSION, + spend: { actualMicroUsd: actual, reservedMicroUsd: 0, unreconciledMicroUsd: 0 }, +}); + +/** A gate the test opens by hand, so runs stay "in flight" for as long as the scenario needs. */ +function gate() { + let open; + const promise = new Promise((resolve) => { + open = resolve; + }); + return { promise, open }; +} + +describe('deck-gym campaign cap', () => { + it('stops the queue before the cap with two in-flight runs reserved at their worst case', async () => { + const PER_RUN = 1_000_000; + const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: 2_500_000, + perRunMaxCostMicroUsd: PER_RUN, + }); + const queue = Array.from({ length: 6 }, (_, index) => ({ runId: `run-${index + 1}` })); + const receipts = []; + const gates = new Map(queue.map((run) => [run.runId, gate()])); + const exposureAtDispatch = []; + const started = []; + const outcomes = new Map([ + ['run-1', { status: 'completed', backendRunIds: ['job-1'] }], + ['run-2', { status: 'failed' }], // crash: names no backend run + ['run-3', { status: 'completed', backendRunIds: ['job-3'] }], + ]); + const ledgerByJob = new Map([ + ['job-1', ledger(300_000)], + ['job-3', ledger(200_000)], + ]); + const common = { + queue, + budget, + receipts, + isResumable: async () => false, + executeRun: async (run) => { + // What the campaign has already committed, plus every run now in flight at its worst case. + exposureAtDispatch.push(budget.spentCostMicroUsd + budget.inFlight * PER_RUN); + started.push(run.runId); + await gates.get(run.runId).promise; + return { runId: run.runId, ...outcomes.get(run.runId) }; + }, + readLedger: async (ids) => new Map(ids.map((id) => [id, ledgerByJob.get(id) ?? null])), + }; + + const workers = [deckGymWorker(common), deckGymWorker(common)]; + await Promise.resolve(); + await new Promise((resolve) => setTimeout(resolve, 0)); + // Two runs are in flight, each reserved at 1,000,000. + expect(started).toEqual(['run-1', 'run-2']); + expect(budget.inFlight).toBe(2); + expect(deckGymBudgetSummary(budget).reservedInFlightMicroUsd).toBe(2_000_000); + + // run-1 finishes with a readable ledger receipt: 300,000 charged, headroom for one more. + gates.get('run-1').open(); + await new Promise((resolve) => setTimeout(resolve, 0)); + expect(budget.spentCostMicroUsd).toBe(300_000); + expect(started).toEqual(['run-1', 'run-2', 'run-3']); + + // run-2 crashes with no readable receipt: its full 1,000,000 reservation is charged. Spent + // 1,300,000 + (1 in flight + 1 new) x 1,000,000 = 3,300,000 > 2,500,000, so the queue stops. + gates.get('run-2').open(); + await new Promise((resolve) => setTimeout(resolve, 0)); + expect(budget.spentCostMicroUsd).toBe(1_300_000); + expect(budget.stoppedBy).toBe('campaign_projected_cost_limit_reached'); + + gates.get('run-3').open(); + await Promise.all(workers); + + expect(started).toEqual(['run-1', 'run-2', 'run-3']); + expect(queue.map((run) => run.runId)).toEqual(['run-4', 'run-5', 'run-6']); + expect(budget.spentCostMicroUsd).toBe(1_500_000); + expect(budget.inFlight).toBe(0); + // The invariant the cap exists for: committed spend plus in-flight worst cases never crossed it. + expect(Math.max(...exposureAtDispatch)).toBeLessThanOrEqual(2_500_000); + expect(receipts.map((entry) => [entry.runId, entry.budget])).toEqual([ + ['run-1', { chargedMicroUsd: 300_000, source: 'ledger' }], + ['run-2', { chargedMicroUsd: 1_000_000, source: 'reservation' }], + ['run-3', { chargedMicroUsd: 200_000, source: 'ledger' }], + ]); + expect(deckGymBudgetSummary(budget)).toEqual({ + maxTotalCostMicroUsd: 2_500_000, + spentCostMicroUsd: 1_500_000, + reservedInFlightMicroUsd: 0, + stoppedBy: 'campaign_projected_cost_limit_reached', + }); + }); + + it('keeps the full reservation when the ledger lookup itself throws', async () => { + const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: 5_000_000, + perRunMaxCostMicroUsd: 1_000_000, + }); + const receipts = []; + await deckGymWorker({ + queue: [{ runId: 'run-1' }], + budget, + receipts, + isResumable: async () => false, + executeRun: async () => ({ runId: 'run-1', status: 'completed', backendRunIds: ['job-1'] }), + readLedger: async () => { + throw new Error('convex unreachable'); + }, + }); + expect(budget.spentCostMicroUsd).toBe(1_000_000); + expect(receipts[0].budget.source).toBe('reservation'); + }); + + it('charges a run whose execution throws outright its full reservation', async () => { + const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: 5_000_000, + perRunMaxCostMicroUsd: 1_000_000, + }); + const receipts = []; + await deckGymWorker({ + queue: [{ runId: 'run-1' }], + budget, + receipts, + isResumable: async () => false, + executeRun: async () => { + throw new Error('browser crashed'); + }, + readLedger: async () => new Map(), + }); + expect(budget.spentCostMicroUsd).toBe(1_000_000); + expect(receipts[0]).toMatchObject({ runId: 'run-1', status: 'failed' }); + }); + + it('never charges a resumed (skipped) run and never reserves for it', async () => { + const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: 1_000_000, + perRunMaxCostMicroUsd: 1_000_000, + }); + const receipts = []; + const executed = []; + await deckGymWorker({ + queue: [{ runId: 'done-1' }, { runId: 'done-2' }, { runId: 'fresh' }], + budget, + receipts, + isResumable: async (run) => run.runId.startsWith('done'), + executeRun: async (run) => { + executed.push(run.runId); + return { runId: run.runId, status: 'completed', backendRunIds: ['job'] }; + }, + readLedger: async () => new Map([['job', ledger(10)]]), + }); + expect(executed).toEqual(['fresh']); + expect(receipts.filter((entry) => entry.status === 'skipped')).toHaveLength(2); + expect(budget.spentCostMicroUsd).toBe(10); + expect(budget.stoppedBy).toBeNull(); + }); + + it('refuses to start any run when even one worst case exceeds the cap', async () => { + const budget = createDeckGymCampaignBudget({ + maxTotalCostMicroUsd: 999_999, + perRunMaxCostMicroUsd: 1_000_000, + }); + const queue = [{ runId: 'run-1' }]; + await deckGymWorker({ + queue, + budget, + receipts: [], + isResumable: async () => false, + executeRun: async () => { + throw new Error('must not dispatch'); + }, + readLedger: async () => new Map(), + }); + expect(budget.stoppedBy).toBe('campaign_projected_cost_limit_reached'); + expect(queue).toHaveLength(1); + }); +}); + +describe('deck-gym cap resolution mirrors node-gym', () => { + it('requires an explicit cap unless the run count itself bounds the spend', () => { + expect( + resolveDeckGymMaxTotalCostMicroUsd({ + explicit: undefined, + limit: 12, + perRunMaxCostMicroUsd: 1_000_000, + }), + ).toBe(12_000_000); + expect(() => + resolveDeckGymMaxTotalCostMicroUsd({ + explicit: undefined, + limit: 13, + perRunMaxCostMicroUsd: 1_000_000, + }), + ).toThrow(/--max-total-cost-micro-usd is required/u); + expect(() => + resolveDeckGymMaxTotalCostMicroUsd({ + explicit: undefined, + limit: undefined, + perRunMaxCostMicroUsd: 1_000_000, + }), + ).toThrow(/required/u); + expect( + resolveDeckGymMaxTotalCostMicroUsd({ + explicit: '2500000', + limit: 72, + perRunMaxCostMicroUsd: 1_000_000, + }), + ).toBe(2_500_000); + expect(() => + resolveDeckGymMaxTotalCostMicroUsd({ + explicit: '-1', + limit: 1, + perRunMaxCostMicroUsd: 1_000_000, + }), + ).toThrow(/non-negative integer/u); + }); +}); diff --git a/scripts/tests/executor-split-probe.test.mjs b/scripts/tests/executor-split-probe.test.mjs new file mode 100644 index 00000000..f137f2ba --- /dev/null +++ b/scripts/tests/executor-split-probe.test.mjs @@ -0,0 +1,178 @@ +/** + * Candidate-bound executor receipt (SPEC Part A section A.2.8, Codex N1). + * + * Situation: an operator wants proof that, after Google retired Gemini 3.5 Flash, NodeSlide's routed + * copy executor really runs Gemini 3.8 Flash. The probe runs one premium-planner edit turn through + * the real planner, router and reserve-before-dispatch provider. Only the HTTP call is faked here + * (no provider is contacted, nothing is spent), so these tests prove the plumbing and the + * acceptance rule; the paid run itself is the operator's. + */ +import { nodeSlideBudgetLedgerStubResponse } from '@nodeslide/testing'; +import { describe, expect, it, vi } from 'vitest'; +import { bindNodeSlideBudgetLedgerClient } from '../../convex/lib/nodeslideBudgetedProvider.ts'; +import { + executorSplitProbeBudgetUsd, + runNodeSlideExecutorSplitProbe, +} from '../../convex/lib/nodeslideExecutorSplitProbe.ts'; +import { buildGoldenNodeSlide } from '../../convex/lib/nodeslideSeed.ts'; +import { executorSplitReceiptFailures } from '../lib/model-fleet-receipt-core.mjs'; + +const COMMIT = 'a'.repeat(40); +const attempts = [ + { + attempt: 'initial', + attempted: true, + settled: true, + ambiguous: false, + unreconciled: false, + elapsedMs: 1, + }, +]; +const calls = []; +let executorEchoes = 'google/gemini-3.8-flash'; +let plannerValue; + +vi.mock('../../convex/lib/nodeslideProvider.ts', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + callNodeSlideFreeJson: vi.fn(async (request) => { + calls.push(request.model); + const isExecutor = request.jsonSchema?.name === 'nodeslide_copy_execution'; + return { + ok: true, + value: isExecutor + ? { + copy: plannerValue.operations.map((operation) => ({ + elementId: operation.elementId, + text: 'Executor copy', + })), + } + : plannerValue, + telemetry: { + provider: 'openrouter', + requestedModel: request.model, + model: request.model, + actualProvider: 'openrouter', + actualModel: isExecutor ? executorEchoes : 'moonshotai/kimi-k3', + costMicroUsd: isExecutor ? 1_000 : 20_000, + inputTokens: 120, + outputTokens: 40, + attempts, + }, + }; + }), + }; +}); + +function fakeLedger() { + const ctx = { + runMutation: async (_reference, args) => nodeSlideBudgetLedgerStubResponse(args), + // replay: a fresh call id has no prior record + runQuery: async () => null, + }; + const names = ['create', 'reserve', 'settle', 'captureTimeout', 'release', 'replay']; + return bindNodeSlideBudgetLedgerClient( + ctx, + Object.fromEntries(names.map((name) => [name, name])), + ); +} + +async function run() { + calls.length = 0; + // The planner reply must name real element ids of the probe deck; the probe builds the same deck. + const snapshot = buildGoldenNodeSlide('executor-split-probe', 1_700_000_000_000).snapshot; + const bySlide = new Map(); + for (const element of snapshot.elements) { + if (element.kind !== 'text' || element.locked) continue; + bySlide.set(element.slideId, [...(bySlide.get(element.slideId) ?? []), element]); + } + const [a, b] = [...bySlide.values()].find((elements) => elements.length >= 2); + plannerValue = { + summary: 'Rewrite two blocks.', + operations: [ + { op: 'replace_text', slideId: a.slideId, elementId: a.id, text: 'Planner one' }, + { op: 'replace_text', slideId: b.slideId, elementId: b.id, text: 'Planner two' }, + ], + copyBriefs: [ + { slideId: a.slideId, elementId: a.id, brief: 'Opening statement.' }, + { slideId: b.slideId, elementId: b.id, brief: 'Proof point.' }, + ], + }; + return await runNodeSlideExecutorSplitProbe({ + ledger: fakeLedger(), + buildIdentity: { schemaVersion: 'nodeslide.convex-build-identity/v1', commitSha: COMMIT }, + budgetUsd: 0.25, + }); +} + +describe('runNodeSlideExecutorSplitProbe', () => { + it('splits a kimi-k3 plan to gemini-3.8-flash and records what each provider echoed', async () => { + executorEchoes = 'google/gemini-3.8-flash'; + const receipt = await run(); + expect(calls).toEqual(['moonshotai/kimi-k3', 'google/gemini-3.8-flash']); + expect(receipt.routing).toMatchObject({ + plannerModel: 'moonshotai/kimi-k3', + executorModel: 'google/gemini-3.8-flash', + reason: 'split_premium_planner_bulk_copy', + executorOutcome: 'applied', + }); + expect(receipt.spans.map((span) => [span.toolName, span.responseModel])).toEqual([ + ['planner', 'moonshotai/kimi-k3'], + ['executor', 'google/gemini-3.8-flash'], + ]); + expect(receipt.budget.refusals).toEqual([]); + expect(executorSplitReceiptFailures(receipt, COMMIT)).toEqual([]); + }); + + it('is rejected when the provider echoed a different executor than the one requested', async () => { + executorEchoes = 'google/gemini-3.6-flash'; + const receipt = await run(); + expect(executorSplitReceiptFailures(receipt, COMMIT)).toEqual([ + 'executor responseModel is google/gemini-3.6-flash', + ]); + }); + + it('is rejected when the deployment is not the tested commit', async () => { + executorEchoes = 'google/gemini-3.8-flash'; + const receipt = await run(); + expect(executorSplitReceiptFailures(receipt, 'b'.repeat(40))).toEqual([ + `buildIdentity.commitSha is ${COMMIT}`, + ]); + expect(executorSplitReceiptFailures({ ...receipt, buildIdentity: null }, COMMIT)).toEqual([ + 'buildIdentity.commitSha is null', + ]); + }); + + it('is rejected when the turn did not split (a single-model turn is not executor evidence)', () => { + const failures = executorSplitReceiptFailures( + { + schemaVersion: 'nodeslide.executor-split-probe/v1', + routing: { + plannerModel: 'moonshotai/kimi-k3', + executorModel: null, + reason: 'single_model', + executorOutcome: null, + }, + spans: [], + budget: { refusals: [] }, + buildIdentity: { commitSha: COMMIT }, + }, + COMMIT, + ); + expect(failures).toEqual( + expect.arrayContaining(['routing.reason is single_model', 'no executor span']), + ); + }); +}); + +describe('executorSplitProbeBudgetUsd', () => { + it('defaults to 0.25 USD and honours NODESLIDE_PROBE_BUDGET_USD', () => { + expect(executorSplitProbeBudgetUsd({})).toBe(0.25); + expect(executorSplitProbeBudgetUsd({ NODESLIDE_PROBE_BUDGET_USD: '0.1' })).toBe(0.1); + }); + it('refuses an unreadable or non-positive ceiling instead of substituting a larger one', () => { + expect(() => executorSplitProbeBudgetUsd({ NODESLIDE_PROBE_BUDGET_USD: 'abc' })).toThrow(); + expect(() => executorSplitProbeBudgetUsd({ NODESLIDE_PROBE_BUDGET_USD: '0' })).toThrow(); + }); +}); diff --git a/scripts/tests/node-gym-campaign-budget.test.mjs b/scripts/tests/node-gym-campaign-budget.test.mjs new file mode 100644 index 00000000..979a8e11 --- /dev/null +++ b/scripts/tests/node-gym-campaign-budget.test.mjs @@ -0,0 +1,440 @@ +/** + * Node-gym campaign accounting (SPEC Part A section A.2.8, Codex v4-new-1). + * + * Situation: someone starts a keyed node-gym campaign with a 100,000 micro-USD cap and walks away. + * The old runner checked the cap against the gym plan's own projection (200,000) but charged the + * executor's self-reported figure afterwards: 0 when the executor crashed or timed out, 0 in its + * failure result, and a number scraped from the Trace inspector text otherwise. Codex replayed it: + * cap 100,000, 180,000 really charged by the backend before a crash, meter 0, second run admitted. + * + * These tests run the REAL charge rule (`chargeNodeGymAttempt`, `nodeGymRunCharge`) and the REAL + * stop rule (`shouldStopCampaign`) in campaign order against a fake backend ledger. + */ +import { mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises'; +import os from 'node:os'; +import path from 'node:path'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { + NODESLIDE_RUN_BUDGET_LEDGER_RECEIPT_VERSION, + normalizeNodeSlideRunBudget, +} from '../../shared/nodeslideRunBudget.ts'; +import { + NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD, + NODE_GYM_LEDGER_RECEIPT_VERSION, + chargeNodeGymAttempt, + loadNodeGymOrphanCharges, + nodeGymRunReservationMicroUsd, + setAsideNodeGymOrphanAttempts, + shouldStopCampaign, + summarizeNodeGymAttemptHistory, +} from '../lib/node-gym-runner-core.mjs'; + +const paidPlan = (runId) => ({ + runId, + comparisonKey: 'c', + harnessPairingKey: 'p', + pairingKey: 'p', + repetition: 1, + model: { id: 'moonshotai/kimi-k3', route: 'moonshotai/kimi-k3', provider: 'openrouter' }, + // The gym plan's own cap: what the old runner reserved, and which the backend never sees. + budget: { maxCostMicroUsd: 200_000 }, +}); + +function ledgerReceipt(actual, { reserved = 0, unreconciled = 0 } = {}) { + return { + version: NODE_GYM_LEDGER_RECEIPT_VERSION, + budgetId: 'nsbudget_x', + status: 'finalized', + spend: { + actualMicroUsd: actual, + reservedMicroUsd: reserved, + unreconciledMicroUsd: unreconciled, + }, + }; +} + +/** The campaign loop of `scripts/run-node-gym.mjs`, with a fake executor and a fake backend ledger. */ +async function runCampaign({ + plans, + perRunMaxCostMicroUsd, + maxTotalCostMicroUsd, + execute, + ledger, +}) { + let spentCostMicroUsd = 0; + let reservedUnknownMicroUsd = 0; + let stoppedBy = null; + const dispatched = []; + for (const plan of plans) { + const reservationMicroUsd = nodeGymRunReservationMicroUsd(plan, perRunMaxCostMicroUsd); + const circuit = shouldStopCampaign({ + spentCostMicroUsd, + maxTotalCostMicroUsd, + failures: 0, + maxFailures: 2, + nextRunMaxCostMicroUsd: reservationMicroUsd, + }); + if (circuit.stop) { + stoppedBy = circuit.issueCode; + break; + } + dispatched.push(plan.runId); + const result = await execute(plan).catch(() => ({ + status: 'failed', + issueCodes: ['executor_process_failed'], + })); + const charge = await chargeNodeGymAttempt({ + reservationMicroUsd, + result, + readLedger: async (ids) => new Map(ids.map((id) => [id, ledger.get(id) ?? null])), + }); + spentCostMicroUsd += charge.chargedMicroUsd; + if (charge.source === 'reservation') reservedUnknownMicroUsd += charge.chargedMicroUsd; + } + return { spentCostMicroUsd, reservedUnknownMicroUsd, stoppedBy, dispatched }; +} + +describe('the mirrored backend per-run cap cannot drift from the backend', () => { + it('reserves exactly what the ledger binds to a default run', () => { + expect(NODE_GYM_BACKEND_RUN_RESERVATION_MICRO_USD).toBe( + normalizeNodeSlideRunBudget({}).maxCostMicroUsd, + ); + expect(NODE_GYM_LEDGER_RECEIPT_VERSION).toBe(NODESLIDE_RUN_BUDGET_LEDGER_RECEIPT_VERSION); + }); + + it('keeps local, :free and openrouter/free routes at a zero reservation, and charges paid routes the backend cap', () => { + const free = (route, provider = 'openrouter') => ({ model: { route, provider } }); + expect(nodeGymRunReservationMicroUsd(free('google/gemma:free'))).toBe(0); + expect(nodeGymRunReservationMicroUsd(free('openrouter/free'))).toBe(0); + expect(nodeGymRunReservationMicroUsd(free('deterministic', 'local'))).toBe(0); + expect(nodeGymRunReservationMicroUsd(paidPlan('r'))).toBe(1_000_000); + expect(nodeGymRunReservationMicroUsd(paidPlan('r'), 180_000)).toBe(180_000); + }); +}); + +describe('a run is charged what the backend ledger recorded, or its full reservation', () => { + it('(a) a crashed run with no readable receipt leaves its full reservation in the meter', async () => { + const outcome = await runCampaign({ + plans: [paidPlan('run-crash')], + perRunMaxCostMicroUsd: 180_000, + maxTotalCostMicroUsd: 1_000_000, + execute: async () => { + throw new Error('executor process killed at its timeout'); + }, + ledger: new Map(), + }); + expect(outcome.spentCostMicroUsd).toBe(180_000); + expect(outcome.reservedUnknownMicroUsd).toBe(180_000); + }); + + it('(b) the same failure with a readable ledger receipt is charged the ledger figure', async () => { + // The page started two backend jobs and then the export failed: the failure result names the + // runs it had already started, so the ledger (not the whole reservation) is the charge. + const outcome = await runCampaign({ + plans: [paidPlan('run-ledger')], + perRunMaxCostMicroUsd: 180_000, + maxTotalCostMicroUsd: 1_000_000, + execute: async () => ({ status: 'failed', backendRunIds: ['job-1', 'job-2'] }), + ledger: new Map([ + ['job-1', ledgerReceipt(40_000)], + ['job-2', ledgerReceipt(25_000, { unreconciled: 5_000 })], + ]), + }); + expect(outcome.spentCostMicroUsd).toBe(70_000); + expect(outcome.reservedUnknownMicroUsd).toBe(0); + }); + + it.each([ + [ + 'an executor failure result that names no backend run', + { status: 'failed', issueCodes: ['ui_executor_failed'] }, + ], + ['a missing result', undefined], + ['a completed result naming no backend run', { status: 'completed', backendRunIds: [] }], + ['a completed result with malformed run ids', { status: 'completed', backendRunIds: [7] }], + [ + 'a completed result whose receipt is unreadable', + { status: 'completed', backendRunIds: ['ghost'] }, + ], + ])('keeps the full reservation for %s', async (_label, result) => { + const charge = await chargeNodeGymAttempt({ + reservationMicroUsd: 180_000, + result, + readLedger: async (ids) => new Map(ids.map((id) => [id, null])), + }); + expect(charge).toEqual({ chargedMicroUsd: 180_000, source: 'reservation' }); + }); + + it('never trusts the executor-reported cost: a cheap claim does not lower the charge', async () => { + const charge = await chargeNodeGymAttempt({ + reservationMicroUsd: 180_000, + result: { status: 'failed', usage: { costMicroUsd: 0 } }, + readLedger: async () => new Map(), + }); + expect(charge.chargedMicroUsd).toBe(180_000); + }); + + it('counts reserved and unreconciled exposure: a dispatch whose outcome never came back may be billed', async () => { + const charge = await chargeNodeGymAttempt({ + reservationMicroUsd: 1_000_000, + result: { status: 'completed', backendRunIds: ['job-1'] }, + readLedger: async () => + new Map([['job-1', ledgerReceipt(10_000, { reserved: 20_000, unreconciled: 30_000 })]]), + }); + expect(charge).toEqual({ chargedMicroUsd: 60_000, source: 'ledger' }); + }); + + it('charges a zero reservation for a free route even when its result is a failure', async () => { + const charge = await chargeNodeGymAttempt({ + reservationMicroUsd: 0, + result: { status: 'failed' }, + readLedger: async () => new Map(), + }); + expect(charge).toEqual({ chargedMicroUsd: 0, source: 'reservation' }); + }); +}); + +describe('(c) Codex figures: cap 100,000 micro-USD, binding backend cap 180,000', () => { + it('refuses the first run before dispatch, because its reservation alone exceeds the cap', async () => { + const outcome = await runCampaign({ + plans: [paidPlan('run-1'), paidPlan('run-2')], + perRunMaxCostMicroUsd: 180_000, + maxTotalCostMicroUsd: 100_000, + execute: async () => { + throw new Error('must never be dispatched'); + }, + ledger: new Map(), + }); + expect(outcome.stoppedBy).toBe('campaign_projected_cost_limit_reached'); + expect(outcome.dispatched).toEqual([]); + expect(outcome.spentCostMicroUsd).toBe(0); + }); + + it('the old runner admitted a second run (the defect): reservation 200,000 / meter 0 after a crash', () => { + // What the old campaign loop computed for the same inputs, kept as the knockout reference: + // a crash charged 0 and the gym plan's 200,000 projection was compared to a cap it never bound. + const oldMeterAfterCrash = 0; + expect( + shouldStopCampaign({ + spentCostMicroUsd: oldMeterAfterCrash, + maxTotalCostMicroUsd: 100_000, + failures: 1, + maxFailures: 2, + nextRunMaxCostMicroUsd: 0, + }).stop, + ).toBe(false); + // Under the new rule the crash is charged its 180,000 reservation and the campaign is over. + expect( + shouldStopCampaign({ + spentCostMicroUsd: 180_000, + maxTotalCostMicroUsd: 100_000, + failures: 1, + maxFailures: 2, + nextRunMaxCostMicroUsd: 180_000, + }), + ).toEqual({ stop: true, issueCode: 'campaign_cost_limit_reached' }); + }); + + it('a campaign that can afford one run admits it, charges the ledger, and refuses the next on projection', async () => { + const outcome = await runCampaign({ + plans: [paidPlan('run-1'), paidPlan('run-2'), paidPlan('run-3')], + perRunMaxCostMicroUsd: 180_000, + maxTotalCostMicroUsd: 400_000, + execute: async (plan) => ({ status: 'completed', backendRunIds: [`job-${plan.runId}`] }), + ledger: new Map([ + ['job-run-1', ledgerReceipt(150_000)], + ['job-run-2', ledgerReceipt(150_000)], + ]), + }); + expect(outcome.dispatched).toEqual(['run-1', 'run-2']); + expect(outcome.spentCostMicroUsd).toBe(300_000); + // 300,000 spent + 180,000 reserved for run-3 > 400,000. + expect(outcome.stoppedBy).toBe('campaign_projected_cost_limit_reached'); + }); +}); + +describe('attempt history: legacy receipts and orphaned attempts', () => { + let campaignRoot; + let attemptsDir; + beforeEach(async () => { + campaignRoot = await mkdtemp(path.join(os.tmpdir(), 'node-gym-budget-')); + attemptsDir = path.join(campaignRoot, 'runs', 'run-1', 'attempts'); + await mkdir(attemptsDir, { recursive: true }); + }); + afterEach(async () => { + await rm(campaignRoot, { recursive: true, force: true }); + }); + + const plan = paidPlan('run-1'); + + function receipt(attempt, overrides = {}) { + return { + schemaVersion: 'nodekit.gym-run-receipt/v2', + attempt, + runId: 'run-1', + comparisonKey: 'c', + harnessPairingKey: 'p', + pairingKey: 'p', + repetition: 1, + executor: 'ui', + status: 'failed', + automatedHardGatesPassed: false, + issueCodes: ['execution_failed'], + planDigest: undefined, + executorResultDigest: `sha256:${'1'.repeat(64)}`, + semanticEvaluationDigest: `sha256:${'2'.repeat(64)}`, + usage: { latencyMs: 1, inputTokens: 1, outputTokens: 1, repairCount: 0, costMicroUsd: 0 }, + ...overrides, + }; + } + + async function digestedPlan() { + const { digestJson } = await import('../lib/node-gym-runner-core.mjs'); + return { plan, planDigest: digestJson(plan) }; + } + + it('charges a receipt written before charges were recorded the run full reservation, not its own usage figure', async () => { + const { planDigest } = await digestedPlan(); + const legacy = receipt(1, { planDigest }); + expect(legacy.budget).toBeUndefined(); + const history = summarizeNodeGymAttemptHistory({ + plan, + receipts: [legacy], + executor: 'ui', + reservationMicroUsd: 180_000, + }); + expect(history.spentCostMicroUsd).toBe(180_000); + expect(history.reservedUnknownMicroUsd).toBe(180_000); + }); + + it('sums the recorded charge of a current receipt and ignores its usage figure', async () => { + const { planDigest } = await digestedPlan(); + const current = receipt(1, { + planDigest, + usage: { + latencyMs: 1, + inputTokens: 1, + outputTokens: 1, + repairCount: 0, + costMicroUsd: 999_999, + }, + budget: { chargedMicroUsd: 42_000, source: 'ledger' }, + }); + const history = summarizeNodeGymAttemptHistory({ + plan, + receipts: [current], + executor: 'ui', + reservationMicroUsd: 180_000, + }); + expect(history.spentCostMicroUsd).toBe(42_000); + expect(history.reservedUnknownMicroUsd).toBe(0); + }); + + it('rejects a malformed recorded charge instead of reading it as zero', async () => { + const { planDigest } = await digestedPlan(); + expect(() => + summarizeNodeGymAttemptHistory({ + plan, + receipts: [receipt(1, { planDigest, budget: { chargedMicroUsd: -1, source: 'ledger' } })], + executor: 'ui', + reservationMicroUsd: 180_000, + }), + ).toThrow(/invalid budget charge/u); + }); + + it('(d) a resume over an attempt directory without its receipt charges that reservation, once', async () => { + await mkdir(path.join(attemptsDir, 'attempt-001', 'work'), { recursive: true }); + await writeFile(path.join(attemptsDir, 'attempt-001', 'plan.json'), '{}\n'); + + // First resume: the directory has no attempt-001.json receipt (the runner died). + await setAsideNodeGymOrphanAttempts({ + campaignRoot, + attemptsDir, + runId: 'run-1', + orphanAttempts: [1], + reservationMicroUsd: 180_000, + }); + let charges = await loadNodeGymOrphanCharges({ attemptsDir, runId: 'run-1' }); + expect(charges).toHaveLength(1); + expect(charges[0].budget).toEqual({ chargedMicroUsd: 180_000, source: 'reservation' }); + // The evidence is kept, under a name the attempt scanner ignores, and attempt 1 can be re-issued. + const names = await readdir(attemptsDir); + expect(names).toContain('orphaned-attempt-001-1'); + expect(names).not.toContain('attempt-001'); + + const history = summarizeNodeGymAttemptHistory({ + plan, + receipts: [], + executor: 'ui', + reservationMicroUsd: 180_000, + orphanCharges: charges, + }); + expect(history).toMatchObject({ + spentCostMicroUsd: 180_000, + reservedUnknownMicroUsd: 180_000, + latestAttempt: 0, + }); + + // A second resume must not charge the same directory again. + charges = await loadNodeGymOrphanCharges({ attemptsDir, runId: 'run-1' }); + expect(charges).toHaveLength(1); + + // The re-issued attempt dies too: a second orphan, a second (distinct) charge. + await mkdir(path.join(attemptsDir, 'attempt-001'), { recursive: true }); + await setAsideNodeGymOrphanAttempts({ + campaignRoot, + attemptsDir, + runId: 'run-1', + orphanAttempts: [1], + reservationMicroUsd: 180_000, + }); + charges = await loadNodeGymOrphanCharges({ attemptsDir, runId: 'run-1' }); + expect(charges).toHaveLength(2); + expect((await readdir(attemptsDir)).sort()).toEqual( + [ + 'orphaned-attempt-001-1', + 'orphaned-attempt-001-1.charge.json', + 'orphaned-attempt-001-2', + 'orphaned-attempt-001-2.charge.json', + ].sort(), + ); + }); + + it('does not double-charge a directory whose charge was written but whose rename never ran', async () => { + await mkdir(path.join(attemptsDir, 'attempt-002'), { recursive: true }); + // The runner died between writing the charge and renaming the directory. + await writeFile( + path.join(attemptsDir, 'orphaned-attempt-002-1.charge.json'), + `${JSON.stringify({ + schemaVersion: 'nodekit.gym-orphan-attempt-charge/v1', + runId: 'run-1', + attempt: 2, + budget: { chargedMicroUsd: 180_000, source: 'reservation' }, + })}\n`, + ); + await setAsideNodeGymOrphanAttempts({ + campaignRoot, + attemptsDir, + runId: 'run-1', + orphanAttempts: [2], + reservationMicroUsd: 180_000, + }); + expect(await loadNodeGymOrphanCharges({ attemptsDir, runId: 'run-1' })).toHaveLength(1); + expect(await readdir(attemptsDir)).toContain('orphaned-attempt-002-1'); + }); + + it('rejects a tampered orphan charge', async () => { + await writeFile( + path.join(attemptsDir, 'orphaned-attempt-001-1.charge.json'), + `${JSON.stringify({ + schemaVersion: 'nodekit.gym-orphan-attempt-charge/v1', + runId: 'run-1', + attempt: 1, + budget: { chargedMicroUsd: 0, source: 'ledger' }, + })}\n`, + ); + await expect(loadNodeGymOrphanCharges({ attemptsDir, runId: 'run-1' })).rejects.toThrow( + /orphan charge/u, + ); + }); +}); diff --git a/scripts/tests/node-gym-disabled-model.test.mjs b/scripts/tests/node-gym-disabled-model.test.mjs new file mode 100644 index 00000000..8e533618 --- /dev/null +++ b/scripts/tests/node-gym-disabled-model.test.mjs @@ -0,0 +1,88 @@ +/** + * Disabled-model exclusion for the node-gym campaign (SPEC Part A section A.2.8, Codex v2-new-3). + * + * Situation: OpenRouter dropped `openai/gpt-oss-20b:free` from its catalog on 2026-10-10. Its row + * must stay in the benchmark (run ids and pairing keys hash `model.id`, so deleting it renumbers the + * whole matrix), yet a campaign must never try to run it. These tests load the COMMITTED config and + * matrix and drive the real selection path the runner uses. + */ +import { readFileSync } from 'node:fs'; +import { describe, expect, it } from 'vitest'; +import { validateNodeGymConfig } from '../lib/node-gym-config-core.mjs'; +import { selectNodeGymCampaignRuns } from '../lib/node-gym-selection-core.mjs'; + +const DISABLED_MODEL = 'openai/gpt-oss-20b:free'; +const config = JSON.parse(readFileSync('benchmarks/deck-gym/v2/gym.json', 'utf8')); +const matrix = JSON.parse( + readFileSync('artifacts/node-gym/nodeslide-deck-gym-v2/matrix.json', 'utf8'), +); +// Naming every task explicitly skips runtime filtering of protected-fixture tasks, which depends on +// the machine's environment; the disabled-model partition under test does not. +const noFilters = { + tasks: config.tasks.map((task) => task.id), + models: [], + harnesses: [], + repetitions: [], +}; +const select = (overrides = {}) => + selectNodeGymCampaignRuns({ + matrix, + config, + filters: noFilters, + subset: 'all', + runtime: {}, + ...overrides, + }); + +describe('execution.disabled on the committed v2 gym', () => { + it('keeps the row, so the matrix identity stays 720 runs', () => { + expect(matrix.runs).toHaveLength(720); + expect(matrix.runs.filter((run) => run.model.id === DISABLED_MODEL)).toHaveLength(120); + }); + + it('--subset all selects 600 runs and reports the 120 it skipped', () => { + const { selectedRuns, skippedDisabled } = select(); + expect(selectedRuns).toHaveLength(600); + expect(skippedDisabled).toHaveLength(120); + expect(selectedRuns.some((run) => run.model.id === DISABLED_MODEL)).toBe(false); + expect(skippedDisabled[0]).toMatchObject({ + modelId: DISABLED_MODEL, + since: '2026-10-10', + reason: expect.stringContaining('unlisted on OpenRouter'), + }); + }); + + it('--include-disabled is the only override and brings back all 720', () => { + const { selectedRuns, skippedDisabled } = select({ includeDisabled: true }); + expect(selectedRuns).toHaveLength(720); + expect(skippedDisabled).toHaveLength(0); + }); + + it('naming the disabled model without the override is an error, not an empty match', () => { + expect(() => select({ filters: { ...noFilters, models: [DISABLED_MODEL] } })).toThrow( + /disabled since 2026-10-10.*--include-disabled/u, + ); + }); +}); + +describe('validateNodeGymConfig accepts execution only as { disabled: true, since, reason }', () => { + const withExecution = (execution) => { + const copy = structuredClone(config); + copy.models.find((model) => model.id === DISABLED_MODEL).execution = execution; + return validateNodeGymConfig(copy).failures; + }; + + it('passes the committed config', () => { + expect(validateNodeGymConfig(config).failures).toEqual([]); + }); + + it.each([ + ['disabled false', { disabled: false, since: '2026-10-10', reason: 'x' }], + ['an extra key', { disabled: true, since: '2026-10-10', reason: 'x', note: 'y' }], + ['a non-ISO date', { disabled: true, since: 'yesterday', reason: 'x' }], + ['an empty reason', { disabled: true, since: '2026-10-10', reason: ' ' }], + ['a non-object', true], + ])('rejects %s', (_label, execution) => { + expect(withExecution(execution).some((failure) => failure.includes('execution'))).toBe(true); + }); +}); diff --git a/shared/nodeslide.ts b/shared/nodeslide.ts index 736a5a12..c5a8b8e8 100644 --- a/shared/nodeslide.ts +++ b/shared/nodeslide.ts @@ -88,18 +88,70 @@ export const NODESLIDE_AGENT_MODELS = [ supportsTemperature: false, supportedEfforts: ['low', 'medium', 'high', 'xhigh', 'max'], }, + { + id: 'anthropic/claude-sonnet-5.5', + upstreamId: 'anthropic/claude-sonnet-5.5', + provider: 'openrouter', + vendor: 'Anthropic', + label: 'Claude Sonnet 5.5', + description: 'Balanced Claude for agents and professional writing.', + costTier: 'premium', + bestFor: 'Executive writing and synthesis', + productionEnabled: true, + // Sampling parameters (temperature/top_p/top_k) are a 400 on Claude 5.5. + supportsTemperature: false, + supportedEfforts: ['low', 'medium', 'high', 'xhigh', 'max'], + }, + { + id: 'anthropic/claude-opus-5.5', + upstreamId: 'anthropic/claude-opus-5.5', + provider: 'openrouter', + vendor: 'Anthropic', + label: 'Claude Opus 5.5', + description: 'Most capable Claude for long-running, high-stakes agent work.', + costTier: 'premium', + bestFor: 'Complex planning and review', + productionEnabled: true, + // Sampling parameters are a 400 on Claude 5.5. Opus 5.5 defaults to medium effort on the + // vendor side (Opus 5 defaulted to high); NodeSlide never relies on a vendor default because + // every request carries an explicit reasoning.effort (NODESLIDE_DEFAULT_REASONING_EFFORT). + supportsTemperature: false, + supportedEfforts: ['low', 'medium', 'high', 'xhigh', 'max'], + }, { id: 'google/gemini-3.5-flash', upstreamId: 'google/gemini-3.5-flash', provider: 'openrouter', vendor: 'Google', label: 'Gemini 3.5 Flash', - description: 'Latest stable Gemini for sustained agentic and coding tasks.', + description: 'Previous Gemini Flash generation; kept so persisted job requests still resolve.', costTier: 'fast', bestFor: 'Fast iteration and large context', - productionEnabled: true, + // Google deprecated gemini-3.5-flash on 2026-10-08 and auto-routes requests to 3.6, so it is no + // longer offered. The row stays because persisted job requests name it (convex validators and + // the price table keep the literal). + productionEnabled: false, supportsTemperature: true, supportedEfforts: ['low', 'medium', 'high'], + structuredOutputMode: 'json_object', + }, + { + id: 'google/gemini-3.8-flash', + upstreamId: 'google/gemini-3.8-flash', + provider: 'openrouter', + vendor: 'Google', + label: 'Gemini 3.8 Flash', + description: 'Current Gemini Flash for sustained agentic and coding tasks.', + costTier: 'fast', + bestFor: 'Fast iteration and large context', + productionEnabled: true, + // Gemini 3.6+ deprecates sampling parameters (ignored today, a future 400): never send temperature. + supportsTemperature: false, + // thinking_level is low/medium/high on Gemini 3.x Flash; xhigh and max are unsupported. + supportedEfforts: ['low', 'medium', 'high'], + // Same OpenRouter Gemini route as 3.5: the edit planner's scoped union schema is rejected + // before generation, so the edit patch uses json_object transport and is validated locally. + structuredOutputMode: 'json_object', }, { id: 'google/gemini-3.1-pro-preview', @@ -140,6 +192,20 @@ export const NODESLIDE_AGENT_MODELS = [ supportsTemperature: false, supportedEfforts: ['low', 'medium', 'high', 'xhigh', 'max'], }, + { + id: 'openai/gpt-6.1-sol', + upstreamId: 'openai/gpt-6.1-sol', + provider: 'openrouter', + vendor: 'OpenAI', + label: 'GPT-6.1 Sol', + description: 'OpenAI flagship for highest-capability production workflows.', + costTier: 'premium', + bestFor: 'Highest-capability production work', + productionEnabled: true, + // Sampling parameters are removed (400) on GPT-6. + supportsTemperature: false, + supportedEfforts: ['low', 'medium', 'high', 'xhigh', 'max'], + }, { id: 'openrouter/free', upstreamId: 'openrouter/free', @@ -206,8 +272,9 @@ export const NODESLIDE_AGENT_MODELS = [ description: 'Zero-priced OpenRouter route with native structured-output support.', costTier: 'free', bestFor: 'Free fast iteration and repair', + // Absent from the OpenRouter catalog (GET /api/v1/models, 2026-10-10): not a free-router + // candidate any more. The row stays for persisted requests and the node-gym matrix identity. productionEnabled: false, - freeRouterCandidate: true, supportsTemperature: true, supportedEfforts: ['low', 'medium', 'high'], }, @@ -225,6 +292,8 @@ export type NodeSlideExternalProvider = (typeof NODESLIDE_AGENT_MODELS)[number][ export const NODESLIDE_DEFAULT_AGENT_MODEL: NodeSlideAgentModelId = 'moonshotai/kimi-k3'; export const NODESLIDE_DEFAULT_OPENROUTER_AGENT_MODEL: NodeSlideAgentModelId = 'moonshotai/kimi-k3'; export const NODESLIDE_NEBIUS_AGENT_MODEL: NodeSlideAgentModelId = 'nebius/zai-org/GLM-5.2'; +/** Default route shown in the bring-your-own-key UI (session BYOK store and Connections dialog). */ +export const NODESLIDE_BYOK_DEFAULT_MODEL: NodeSlideAgentModelId = 'z-ai/glm-5.2'; export const NODESLIDE_REASONING_EFFORTS = [ { id: 'low', label: 'Light', description: 'Faster responses for straightforward work.' }, @@ -247,6 +316,20 @@ export function nodeSlideReasoningEffort(effortId: NodeSlideReasoningEffort) { ); } +/** + * Catalog flag for the edit-patch transport. A row that sets `structuredOutputMode: 'json_object'` + * sends the `nodeslide_edit_patch` schema in the prompt and asks the provider only for strict JSON, + * because that route rejects the planner's large scoped union before generating a token. Every other + * schema, and every row without the flag, keeps native `json_schema`. The result is validated + * locally against the same schema either way. + */ +export function nodeSlideEditPatchStructuredOutputMode( + modelId: NodeSlideAgentModelId, +): 'json_object' | undefined { + const route = nodeSlideAgentModel(modelId); + return 'structuredOutputMode' in route ? route.structuredOutputMode : undefined; +} + export function isNodeSlideAgentModelId(value: unknown): value is NodeSlideAgentModelId { return NODESLIDE_AGENT_MODELS.some((model) => model.id === value); } diff --git a/shared/nodeslideRunBudget.ts b/shared/nodeslideRunBudget.ts index 54bb7712..125d729a 100644 --- a/shared/nodeslideRunBudget.ts +++ b/shared/nodeslideRunBudget.ts @@ -25,6 +25,9 @@ import type { NodeSlideAgentModelId } from './nodeslide'; export const NODESLIDE_RUN_BUDGET_VERSION = 'nodeslide.run-budget/v1' as const; export const NODESLIDE_RUN_BUDGET_STATE_VERSION = 'nodeslide.run-budget-state/v1' as const; export const NODESLIDE_RUN_BUDGET_RECEIPT_VERSION = 'nodeslide.run-budget-receipt/v1' as const; +/** Run-level read model of one budget ledger row (`nodeslideBudgets.receiptForRun`). */ +export const NODESLIDE_RUN_BUDGET_LEDGER_RECEIPT_VERSION = + 'nodeslide.run-budget-ledger-receipt/v1' as const; export const NODESLIDE_MODEL_PRICING_VERSION = 'nodeslide.model-pricing/v1' as const; export const NODESLIDE_PRIVATE_DETERMINISTIC_MODEL = 'nodeslide/private-deterministic' as const; export const NODESLIDE_MICRO_USD_PER_USD = 1_000_000 as const; @@ -475,7 +478,16 @@ export type NodeSlideRunBudgetPostflightResult = * SOURCE: https://openrouter.ai/api/v1/models — the provider's own machine * catalog, not a docs page, not a pricing page, not a paste from a * conversation. Every row below was read out of one response body. - * FETCHED: 2026-07-28T00:00:00Z (see NODESLIDE_MODEL_PRICING_VERIFIED_AT). + * FETCHED: 2026-10-14T16:03:00Z (see NODESLIDE_MODEL_PRICING_VERIFIED_AT). Every priced row, + * including the four added by the model refresh, was re-read from that one + * response; the rows that moved are kimi-k3, glm-5.2, gpt-5.6-sol and + * gpt-5.6-terra. The price below is the catalog's listed (cheapest healthy + * endpoint) price and is ALSO the `max_price` routing ceiling sent to + * OpenRouter (`nodeslideBudgetedProvider.ts`), so it bounds both the + * reservation and the bill; a ceiling below every live endpoint would make a + * route unroutable, which is why it is refreshed from the live catalog and + * never typed from memory. GET /api/v1/models/{id}/endpoints, read in the same + * minute, was used to confirm that endpoints exist at or below each ceiling. * UNIT: `pricing.prompt` / `pricing.completion` are USD per single token. * This table stores integer micro-USD per MILLION tokens, so every * value is the catalog string multiplied by 1e12. Integers only: the @@ -483,10 +495,10 @@ export type NodeSlideRunBudgetPostflightResult = * reservation, which is the one place rounding down is a loan. * WINDOWS: `providerContextWindowTokens` is `context_length`; * `providerMaxOutputTokens` is `top_provider.max_completion_tokens`. - * Where the catalog reports `null` for the completion cap — currently - * `moonshotai/kimi-k3` only — the context window is the binding - * provider limit and is recorded as such. That is read from the same - * response, not assumed. + * Where the catalog reports `null` for the completion cap (no row does + * in the 2026-10-14 response; `moonshotai/kimi-k3` did on 2026-07-28) the + * context window is the binding provider limit and is recorded as such. + * That is read from the same response, not assumed. * * TO RE-VERIFY: fetch the URL, and for each row assert * `pricing.prompt * 1e12 === inputMicroUsdPerMillionTokens` and the same for @@ -509,7 +521,7 @@ export type NodeSlideRunBudgetPostflightResult = * fallback rather than billing against an unchecked price. */ export const NODESLIDE_MODEL_PRICING_SOURCE_URL = 'https://openrouter.ai/api/v1/models' as const; -export const NODESLIDE_MODEL_PRICING_VERIFIED_AT = '2026-07-28T00:00:00Z' as const; +export const NODESLIDE_MODEL_PRICING_VERIFIED_AT = '2026-10-14T16:03:00Z' as const; type NodeSlideCatalogPricingMetadata = | NodeSlidePricedModelMetadata @@ -567,19 +579,17 @@ export const NODESLIDE_MODEL_PRICING = { }, 'moonshotai/kimi-k3': pricedRoute({ modelId: 'moonshotai/kimi-k3', - inputMicroUsdPerMillionTokens: 3_000_000, + inputMicroUsdPerMillionTokens: 700_000, outputMicroUsdPerMillionTokens: 15_000_000, providerContextWindowTokens: 1_048_576, - // The catalog reports `top_provider.max_completion_tokens: null` for this - // route, so the context window is the provider's binding output limit. - providerMaxOutputTokens: 1_048_576, + providerMaxOutputTokens: 943_718, }), 'z-ai/glm-5.2': pricedRoute({ modelId: 'z-ai/glm-5.2', - inputMicroUsdPerMillionTokens: 768_600, - outputMicroUsdPerMillionTokens: 2_415_600, + inputMicroUsdPerMillionTokens: 50_000, + outputMicroUsdPerMillionTokens: 7_000_000, providerContextWindowTokens: 1_048_576, - providerMaxOutputTokens: 131_072, + providerMaxOutputTokens: 943_718, }), 'anthropic/claude-sonnet-5': pricedRoute({ modelId: 'anthropic/claude-sonnet-5', @@ -595,6 +605,20 @@ export const NODESLIDE_MODEL_PRICING = { providerContextWindowTokens: 1_000_000, providerMaxOutputTokens: 128_000, }), + 'anthropic/claude-sonnet-5.5': pricedRoute({ + modelId: 'anthropic/claude-sonnet-5.5', + inputMicroUsdPerMillionTokens: 2_000_000, + outputMicroUsdPerMillionTokens: 10_000_000, + providerContextWindowTokens: 1_000_000, + providerMaxOutputTokens: 128_000, + }), + 'anthropic/claude-opus-5.5': pricedRoute({ + modelId: 'anthropic/claude-opus-5.5', + inputMicroUsdPerMillionTokens: 4_000_000, + outputMicroUsdPerMillionTokens: 20_000_000, + providerContextWindowTokens: 1_000_000, + providerMaxOutputTokens: 128_000, + }), 'google/gemini-3.5-flash': pricedRoute({ modelId: 'google/gemini-3.5-flash', inputMicroUsdPerMillionTokens: 1_500_000, @@ -602,6 +626,13 @@ export const NODESLIDE_MODEL_PRICING = { providerContextWindowTokens: 1_048_576, providerMaxOutputTokens: 65_536, }), + 'google/gemini-3.8-flash': pricedRoute({ + modelId: 'google/gemini-3.8-flash', + inputMicroUsdPerMillionTokens: 750_000, + outputMicroUsdPerMillionTokens: 3_750_000, + providerContextWindowTokens: 1_048_576, + providerMaxOutputTokens: 65_536, + }), 'google/gemini-3.1-pro-preview': pricedRoute({ modelId: 'google/gemini-3.1-pro-preview', inputMicroUsdPerMillionTokens: 2_000_000, @@ -611,15 +642,24 @@ export const NODESLIDE_MODEL_PRICING = { }), 'openai/gpt-5.6-sol': pricedRoute({ modelId: 'openai/gpt-5.6-sol', - inputMicroUsdPerMillionTokens: 5_000_000, - outputMicroUsdPerMillionTokens: 30_000_000, + inputMicroUsdPerMillionTokens: 2_000_000, + outputMicroUsdPerMillionTokens: 10_000_000, providerContextWindowTokens: 1_050_000, providerMaxOutputTokens: 128_000, }), 'openai/gpt-5.6-terra': pricedRoute({ modelId: 'openai/gpt-5.6-terra', - inputMicroUsdPerMillionTokens: 1_250_000, - outputMicroUsdPerMillionTokens: 7_500_000, + inputMicroUsdPerMillionTokens: 2_000_000, + outputMicroUsdPerMillionTokens: 12_000_000, + providerContextWindowTokens: 1_050_000, + providerMaxOutputTokens: 128_000, + }), + // Priced at the flat tier. OpenRouter lists a higher tier above 272K prompt tokens + // (2x input); a NodeSlide prompt is bounded far below that by the read-context limit. + 'openai/gpt-6.1-sol': pricedRoute({ + modelId: 'openai/gpt-6.1-sol', + inputMicroUsdPerMillionTokens: 2_000_000, + outputMicroUsdPerMillionTokens: 10_000_000, providerContextWindowTokens: 1_050_000, providerMaxOutputTokens: 128_000, }), diff --git a/src/domains/nodeslide/components/NodeSlideConnectionsDialog.tsx b/src/domains/nodeslide/components/NodeSlideConnectionsDialog.tsx index 93f70d62..bacf3646 100644 --- a/src/domains/nodeslide/components/NodeSlideConnectionsDialog.tsx +++ b/src/domains/nodeslide/components/NodeSlideConnectionsDialog.tsx @@ -17,6 +17,7 @@ import { } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; import { api } from '../../../../convex/_generated/api'; +import { NODESLIDE_BYOK_DEFAULT_MODEL } from '../../../../shared/nodeslide'; import { SESSION_BYOK_KEYS, clearSessionByok, @@ -88,7 +89,10 @@ function NodeSlideConnectionsDialogContent({ initialFocusRef: firstInputRef, }); const [keys, setKeys] = useState>({}); - const [routing, setRouting] = useState({ model: 'z-ai/glm-5.2', baseUrl: '' }); + const [routing, setRouting] = useState<{ model: string; baseUrl: string }>({ + model: NODESLIDE_BYOK_DEFAULT_MODEL, + baseUrl: '', + }); const [client, setClient] = useState('claude'); const [notice, setNotice] = useState(null); const [googleBusy, setGoogleBusy] = useState<'connect' | 'disconnect' | null>(null); @@ -144,7 +148,7 @@ function NodeSlideConnectionsDialogContent({ const revoke = () => { clearSessionByok(); setKeys({}); - setRouting({ model: 'z-ai/glm-5.2', baseUrl: '' }); + setRouting({ model: NODESLIDE_BYOK_DEFAULT_MODEL, baseUrl: '' }); setNotice('Local connection values revoked from this tab.'); }; @@ -222,7 +226,7 @@ function NodeSlideConnectionsDialogContent({ ...env, PARITY_CONVEX_URL: NODESLIDE_CONVEX_URL, PARITY_DASHBOARD: 'disabled', - NODESLIDE_BYOK_MODEL: routing.model.trim() || 'z-ai/glm-5.2', + NODESLIDE_BYOK_MODEL: routing.model.trim() || NODESLIDE_BYOK_DEFAULT_MODEL, ...(routing.baseUrl.trim() ? { NODESLIDE_BYOK_BASE_URL: routing.baseUrl.trim() } : {}), ...(ownerAccessKey ? { NODESLIDE_OWNER_ACCESS_KEY: ownerAccessKey } : {}), }; @@ -584,7 +588,7 @@ function NodeSlideConnectionsDialogContent({ onChange={(event) => setRouting((current) => ({ ...current, model: event.target.value })) } - placeholder="z-ai/glm-5.2" + placeholder={NODESLIDE_BYOK_DEFAULT_MODEL} />