carthagent 0.0.0-stage → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +219 -2
- package/bin/ctg.mjs +736 -0
- package/docs/budgets.md +72 -0
- package/docs/compaction.md +34 -0
- package/docs/context-efficiency-plan.md +24 -0
- package/docs/context-efficiency-review.md +27 -0
- package/docs/context-efficiency.md +49 -0
- package/docs/deepseek-jev-benchmark-plan.md +70 -0
- package/docs/deepseek-jev-benchmark-repair-plan.md +20 -0
- package/docs/deepseek-jev-benchmark-restart.md +9 -0
- package/docs/deepseek-jev-benchmark-results.md +77 -0
- package/docs/deepseek-jev-benchmark-running.md +60 -0
- package/docs/deepseek-jev-benchmark-v3-results.md +41 -0
- package/docs/deepseek-jev-benchmark-v4-protocol.md +15 -0
- package/docs/deepseek-jev-benchmark-v4-results.md +119 -0
- package/docs/deepseek-jev-http400-diagnosis.md +45 -0
- package/docs/delivery-review-evidence.md +53 -0
- package/docs/delivery-timeout-repair-plan.md +51 -0
- package/docs/evaluation-readiness.md +31 -0
- package/docs/evaluation.md +70 -0
- package/docs/extending.md +354 -0
- package/docs/glm-pilot-execution.md +9 -0
- package/docs/glm-pilot-plan.md +15 -0
- package/docs/glm-pilot-results.md +71 -0
- package/docs/graph-context-optimization.md +15 -0
- package/docs/jev-repository-pilot-plan.md +25 -0
- package/docs/jev-repository-pilot-protocol.md +39 -0
- package/docs/jev-repository-pilot-restart.md +7 -0
- package/docs/jev-repository-pilot-results.md +79 -0
- package/docs/jev.md +32 -0
- package/docs/model-registry.md +25 -0
- package/docs/native-compatibility.md +117 -0
- package/docs/opencode-archive.md +9 -0
- package/docs/opencode-migration.md +115 -0
- package/docs/opencode-runtime.md +94 -0
- package/docs/opencode-workspace.md +31 -0
- package/docs/owned-runtime-workflow-registration.md +17 -0
- package/docs/plan-advisor-evaluation.md +38 -0
- package/docs/planning-startup-fix-plan.md +23 -0
- package/docs/planning-startup-fix-review.md +24 -0
- package/docs/planning.md +118 -0
- package/docs/production-merge-review.md +23 -0
- package/docs/quality.md +35 -0
- package/docs/repository-benchmark-design.md +111 -0
- package/docs/review-assurance.md +9 -0
- package/docs/review-experiment-results.md +59 -0
- package/docs/tested-planning-roadmap.md +58 -0
- package/docs/tested-planning.md +58 -0
- package/docs/tui-pickers.md +9 -0
- package/docs/webdriver.md +83 -0
- package/docs/workflow-modes.md +26 -0
- package/docs/workflow.d2 +17 -0
- package/docs/workflow.svg +149 -0
- package/docs/workspace-coordination.md +9 -0
- package/evaluate.mjs +249 -0
- package/extensions/codegraph.ts +36 -0
- package/extensions/delivery.ts +819 -0
- package/extensions/experiential.ts +21 -0
- package/extensions/subscriptions.ts +21 -0
- package/guidance/profiles/authenticated-web.json +24 -0
- package/guidance/profiles/data-visualization.json +25 -0
- package/guidance/profiles/database-change.json +24 -0
- package/guidance/profiles/external-api.json +24 -0
- package/guidance/profiles/transactional-data.json +25 -0
- package/guidance/profiles/web-application.json +26 -0
- package/lib/acceptance-review.mjs +4 -0
- package/lib/browser-bin.mjs +160 -0
- package/lib/browser-errors.mjs +54 -0
- package/lib/browser.mjs +219 -0
- package/lib/budget.mjs +37 -0
- package/lib/cdp.mjs +221 -0
- package/lib/cloud/client.mjs +275 -0
- package/lib/cloud/control-plane.mjs +350 -0
- package/lib/cloud/gateway.mjs +380 -0
- package/lib/cloud/http.mjs +135 -0
- package/lib/cloud/ledger.mjs +215 -0
- package/lib/codegraph-query.mjs +60 -0
- package/lib/codegraph.mjs +378 -0
- package/lib/context-archive.mjs +18 -0
- package/lib/delivery-context.mjs +132 -0
- package/lib/delivery-guidance.mjs +9 -0
- package/lib/delivery-review.mjs +94 -0
- package/lib/delivery.mjs +610 -0
- package/lib/engine.mjs +137 -0
- package/lib/guidance.mjs +71 -0
- package/lib/jev-advisor.mjs +47 -0
- package/lib/opencode/archive.mjs +122 -0
- package/lib/opencode/compatibility.mjs +19 -0
- package/lib/opencode/credentials.mjs +205 -0
- package/lib/opencode/evaluation-budget-plugin/index.ts +147 -0
- package/lib/opencode/evaluation.mjs +242 -0
- package/lib/opencode/file-lock.mjs +86 -0
- package/lib/opencode/headless.mjs +200 -0
- package/lib/opencode/review.mjs +213 -0
- package/lib/opencode/runtime.mjs +246 -0
- package/lib/opencode/service.mjs +249 -0
- package/lib/opencode/session-options.mjs +60 -0
- package/lib/opencode/workspace.mjs +133 -0
- package/lib/openrouter-jev.mjs +37 -0
- package/lib/outcome-contract.mjs +21 -0
- package/lib/plan-advisor.mjs +38 -0
- package/lib/planning-access.mjs +7 -0
- package/lib/planning-advice.mjs +28 -0
- package/lib/planning-discovery.mjs +14 -0
- package/lib/planning-guide.mjs +34 -0
- package/lib/planning-view.mjs +57 -0
- package/lib/planning.mjs +155 -0
- package/lib/probe-diagnostics.mjs +13 -0
- package/lib/providers/experiential.mjs +292 -0
- package/lib/providers/model-catalog.json +700 -0
- package/lib/providers/model-catalog.mjs +7 -0
- package/lib/providers/names.mjs +13 -0
- package/lib/providers/subscription-models.mjs +483 -0
- package/lib/reports.mjs +80 -0
- package/lib/review-state.mjs +49 -0
- package/lib/review.mjs +114 -0
- package/lib/scenarios.mjs +99 -0
- package/lib/ship-auth.mjs +44 -0
- package/lib/ship-jev.mjs +59 -0
- package/lib/ship-telemetry.mjs +183 -0
- package/lib/tui/ansi.mjs +255 -0
- package/lib/tui/app.mjs +2445 -0
- package/lib/tui/auth.mjs +249 -0
- package/lib/tui/carthage.mjs +109 -0
- package/lib/tui/clipboard.mjs +122 -0
- package/lib/tui/d2.mjs +431 -0
- package/lib/tui/feed.mjs +467 -0
- package/lib/tui/framing.mjs +80 -0
- package/lib/tui/glyphs.mjs +172 -0
- package/lib/tui/hash-worker.mjs +11 -0
- package/lib/tui/mock-engine.mjs +222 -0
- package/lib/tui/models.mjs +73 -0
- package/lib/tui/picker.mjs +18 -0
- package/lib/tui/theme.mjs +663 -0
- package/lib/tui/title.mjs +7 -0
- package/lib/update-channel.mjs +62 -0
- package/lib/update.mjs +230 -0
- package/lib/webdriver.mjs +82 -0
- package/lib/workflow.mjs +88 -0
- package/lib/workspace.mjs +39 -0
- package/metadata.json +8 -0
- package/package.json +94 -4
- package/plugins/carthagent/index.ts +3 -0
- package/plugins/carthagent/package.json +28 -0
- package/plugins/carthagent/src/archive-rpc.ts +46 -0
- package/plugins/carthagent/src/bootstrap.ts +38 -0
- package/plugins/carthagent/src/index.ts +62 -0
- package/plugins/carthagent/src/pull-request-rpc.ts +54 -0
- package/plugins/carthagent/src/rpc.ts +76 -0
- package/plugins/carthagent/src/server/archive-rpc.ts +327 -0
- package/plugins/carthagent/src/server/budgets.ts +21 -0
- package/plugins/carthagent/src/server/codegraph.ts +46 -0
- package/plugins/carthagent/src/server/delivery.ts +488 -0
- package/plugins/carthagent/src/server/device-auth.ts +91 -0
- package/plugins/carthagent/src/server/native-delivery.ts +26 -0
- package/plugins/carthagent/src/server/orchestration.ts +56 -0
- package/plugins/carthagent/src/server/policy.ts +24 -0
- package/plugins/carthagent/src/server/providers.ts +424 -0
- package/plugins/carthagent/src/server/pull-request-rpc.ts +387 -0
- package/plugins/carthagent/src/server/session-controls.ts +82 -0
- package/plugins/carthagent/src/server/telemetry.ts +92 -0
- package/plugins/carthagent/src/server/workspace-rpc.ts +349 -0
- package/plugins/carthagent/src/session-rpc.ts +31 -0
- package/plugins/carthagent/src/testing.ts +85 -0
- package/plugins/carthagent/src/workspace-rpc.ts +133 -0
- package/plugins/carthagent/test-plugin/index.ts +4 -0
- package/plugins/carthagent/test-plugin/package.json +1 -0
- package/plugins/carthagent/tsconfig.json +19 -0
- package/plugins/carthagent/tui.ts +1 -0
- package/prompts/delivery.md +7 -0
- package/public/index.html +983 -0
- package/scenarios/cli/grade_cli.py +69 -0
- package/scenarios/cli/scenario.json +21 -0
- package/scenarios/game/baseline/minecraft.py +193 -0
- package/scenarios/game/context.md +1 -0
- package/scenarios/game/grade_minecraft_clone.py +603 -0
- package/scenarios/game/requirements.txt +2 -0
- package/scenarios/game/scenario.json +33 -0
- package/server.mjs +341 -0
- package/skills/game-development/SKILL.md +36 -0
- package/skills/game-development/assets/ursina_starter.py +98 -0
- package/skills/game-development/scripts/verify_ursina.py +80 -0
- package/skills/software-delivery/SKILL.md +50 -0
- package/skills/typescript-delivery/SKILL.md +69 -0
- package/tests/acceptance-review.test.mjs +13 -0
- package/tests/auth.test.mjs +234 -0
- package/tests/bounded-summary.test.mjs +68 -0
- package/tests/browser-bin.test.mjs +91 -0
- package/tests/browser.test.mjs +96 -0
- package/tests/budget-engine.test.mjs +110 -0
- package/tests/budget.test.mjs +23 -0
- package/tests/cli.test.mjs +245 -0
- package/tests/clipboard.test.mjs +79 -0
- package/tests/cloud-client.test.mjs +129 -0
- package/tests/cloud-control-plane.test.mjs +144 -0
- package/tests/cloud-gateway.test.mjs +147 -0
- package/tests/cloud-http.test.mjs +102 -0
- package/tests/cloud-ledger.test.mjs +75 -0
- package/tests/codegraph-query.test.mjs +66 -0
- package/tests/codegraph.test.mjs +142 -0
- package/tests/delivery-context.test.mjs +66 -0
- package/tests/delivery-review.test.mjs +139 -0
- package/tests/delivery.test.mjs +343 -0
- package/tests/engine-api.mjs +24 -0
- package/tests/experiential-extension.test.mjs +37 -0
- package/tests/experiential.test.mjs +300 -0
- package/tests/extension.test.mjs +921 -0
- package/tests/fixtures/archive-plugin/index.ts +10 -0
- package/tests/guidance.test.mjs +78 -0
- package/tests/model-registry.test.mjs +68 -0
- package/tests/models.test.mjs +70 -0
- package/tests/openai-idempotency.test.mjs +99 -0
- package/tests/opencode-archive-rpc.test.mjs +82 -0
- package/tests/opencode-delivery.test.mjs +231 -0
- package/tests/opencode-providers.test.mjs +414 -0
- package/tests/opencode-runtime.test.mjs +455 -0
- package/tests/opencode-session-controls.test.mjs +115 -0
- package/tests/opencode-session-options.test.mjs +26 -0
- package/tests/opencode-workspace.test.mjs +339 -0
- package/tests/outcome-contract.test.mjs +17 -0
- package/tests/picker.test.mjs +34 -0
- package/tests/plan-advisor.test.mjs +88 -0
- package/tests/plan-review-loop.test.mjs +53 -0
- package/tests/planning-advice.test.mjs +27 -0
- package/tests/planning-contract.test.mjs +65 -0
- package/tests/planning-startup.test.mjs +38 -0
- package/tests/planning-view.test.mjs +33 -0
- package/tests/planning.test.mjs +223 -0
- package/tests/probe-diagnostics.test.mjs +21 -0
- package/tests/pull-request-rpc.test.mjs +366 -0
- package/tests/review-state.test.mjs +32 -0
- package/tests/review.test.mjs +127 -0
- package/tests/server.test.mjs +252 -0
- package/tests/ship-jev.test.mjs +77 -0
- package/tests/ship-telemetry.test.mjs +333 -0
- package/tests/standard-workflow.test.mjs +28 -0
- package/tests/subscription-models.test.mjs +416 -0
- package/tests/subscriptions-extension.test.mjs +27 -0
- package/tests/terminal-title.test.mjs +13 -0
- package/tests/test_grade_minecraft_clone.py +199 -0
- package/tests/test_starter.py +78 -0
- package/tests/theme.test.mjs +175 -0
- package/tests/tui-copy-paste.test.mjs +54 -0
- package/tests/tui.test.mjs +808 -0
- package/tests/update-channels.test.mjs +129 -0
- package/tests/update.test.mjs +175 -0
- package/tests/webdriver.test.mjs +31 -0
- package/tests/workflow.test.mjs +47 -0
- package/tests/workspace-rpc.test.mjs +236 -0
- package/tests/workspace.test.mjs +24 -0
- package/tools/benchmark/advisor.test.mjs +7 -0
- package/tools/benchmark/advisor.ts +27 -0
- package/tools/benchmark/campaign.mjs +45 -0
- package/tools/benchmark/diagnose-request.mjs +40 -0
- package/tools/benchmark/eval-common.mjs +32 -0
- package/tools/benchmark/eval-ledger.mjs +22 -0
- package/tools/benchmark/eval-shop.mjs +26 -0
- package/tools/benchmark/eval-voxel.mjs +20 -0
- package/tools/benchmark/evaluate.mjs +24 -0
- package/tools/benchmark/evaluators.test.mjs +13 -0
- package/tools/benchmark/fixtures/shop/server.mjs +18 -0
- package/tools/benchmark/fixtures/shop/ui.html +8 -0
- package/tools/benchmark/freeze.mjs +30 -0
- package/tools/benchmark/gateway.mjs +91 -0
- package/tools/benchmark/gateway.test.mjs +38 -0
- package/tools/benchmark/generator.mjs +11 -0
- package/tools/benchmark/generator.test.mjs +26 -0
- package/tools/benchmark/guard.test.mjs +133 -0
- package/tools/benchmark/guard.ts +136 -0
- package/tools/benchmark/native-plugin/index.ts +24 -0
- package/tools/benchmark/planning-startup.test.mjs +47 -0
- package/tools/benchmark/preflight-live.mjs +31 -0
- package/tools/benchmark/preflight.mjs +22 -0
- package/tools/benchmark/replay-diagnostic.mjs +23 -0
- package/tools/benchmark/runner.mjs +141 -0
- package/tools/benchmark/runner.test.mjs +93 -0
- package/tools/benchmark/runtime.mjs +23 -0
- package/tools/benchmark/selftest.mjs +47 -0
- package/tools/benchmark/smoke-jev.mjs +5 -0
- package/tools/benchmark/tasks.mjs +20 -0
- package/tools/benchmark/transport.mjs +65 -0
- package/tools/benchmark/transport.test.mjs +44 -0
- package/tools/benchmark/upstream-error.mjs +18 -0
- package/tools/benchmark/upstream-error.test.mjs +10 -0
- package/tools/browser-check.mjs +109 -0
- package/tools/check-syntax.mjs +27 -0
- package/tools/evaluate-plan-advisor.mjs +20 -0
- package/tools/native-fixture.mjs +194 -0
- package/tools/native-pty-smoke.py +108 -0
- package/tools/native-report-plugin/index.ts +50 -0
- package/tools/native-report-plugin/package.json +7 -0
- package/tools/patch-compaction.mjs +24 -0
- package/tools/patch-model-catalog.mjs +12 -0
- package/tools/patch-print-shutdown.mjs +39 -0
- package/tools/repo-pilot/evaluator.cjs +32 -0
- package/tools/repo-pilot/reference.mjs +43 -0
- package/tools/repo-pilot/runner.mjs +85 -0
- package/tools/repo-pilot/sandbox-entry.mjs +12 -0
- package/tools/repo-pilot/tasks.mjs +20 -0
- package/tools/repo-pilot/type-evaluator.cjs +6 -0
- package/tools/test-native-controls.mjs +84 -0
- package/tools/test-native-delivery-host.mjs +307 -0
- package/tools/test-native-evaluation.mjs +46 -0
- package/tools/test-native-host.mjs +385 -0
- package/tools/test-native-outcomes.mjs +73 -0
- package/tools/test-native-package.mjs +70 -0
- package/tools/test-native-pty.mjs +20 -0
- package/tools/test-native-report.mjs +88 -0
- package/tools/test-native-swe-host.mjs +132 -0
- package/tools/test-native-swe.mjs +122 -0
- package/tools/test-picker-pty.py +45 -0
- package/tools/test-python.mjs +29 -0
- package/tools/test-webdriver.mjs +54 -0
- package/tools/verify-release-version.mjs +37 -0
- package/tools/webdriver-check.mjs +52 -0
- package/vendor/agent/bounded-summary.mjs +88 -0
- package/vendor/agent/chunks/anthropic-messages-VWZZOSJQ.js +6 -0
- package/vendor/agent/chunks/anthropic.js +75 -0
- package/vendor/agent/chunks/azure-openai-responses-BJLAM6CD.js +2 -0
- package/vendor/agent/chunks/bedrock-converse-stream.js +74 -0
- package/vendor/agent/chunks/chord-context.js +96 -0
- package/vendor/agent/chunks/chunk-4L3WN2XY.js +2 -0
- package/vendor/agent/chunks/chunk-6CYCI3EJ.js +12 -0
- package/vendor/agent/chunks/chunk-6R7UI4IY.js +2 -0
- package/vendor/agent/chunks/chunk-7ZC4UXSL.js +2 -0
- package/vendor/agent/chunks/chunk-AXIIZGTV.js +2 -0
- package/vendor/agent/chunks/chunk-CLNPYIDP.js +42 -0
- package/vendor/agent/chunks/chunk-DRQDKNXA.js +2 -0
- package/vendor/agent/chunks/chunk-GMWCTUPB.js +2 -0
- package/vendor/agent/chunks/chunk-IDDQWTHI.js +2 -0
- package/vendor/agent/chunks/chunk-JVUZSMYM.js +1548 -0
- package/vendor/agent/chunks/chunk-L2ZPNLYD.js +2 -0
- package/vendor/agent/chunks/chunk-NUHFSC37.js +25 -0
- package/vendor/agent/chunks/chunk-OUXLLA64.js +11 -0
- package/vendor/agent/chunks/chunk-PGXDEOVV.js +2 -0
- package/vendor/agent/chunks/chunk-PJACZCIR.js +2 -0
- package/vendor/agent/chunks/chunk-PRRNXB7S.js +2 -0
- package/vendor/agent/chunks/chunk-TEPMHNKQ.js +2 -0
- package/vendor/agent/chunks/chunk-TRDNDS6A.js +4 -0
- package/vendor/agent/chunks/chunk-U6ZMQKGD.js +50 -0
- package/vendor/agent/chunks/chunk-UAQELI3K.js +2 -0
- package/vendor/agent/chunks/chunk-USJZMAIR.js +2 -0
- package/vendor/agent/chunks/chunk-XDUWOHPL.js +6 -0
- package/vendor/agent/chunks/chunk-XNGRGP62.js +2 -0
- package/vendor/agent/chunks/github-copilot.js +2 -0
- package/vendor/agent/chunks/google-generative-ai-Q2K7FBDI.js +2 -0
- package/vendor/agent/chunks/google-vertex-7UJBF4S7.js +2 -0
- package/vendor/agent/chunks/https-proxy-agent-2VXB7436.js +13 -0
- package/vendor/agent/chunks/image-resize-worker.js +2 -0
- package/vendor/agent/chunks/kimi-coding.js +2 -0
- package/vendor/agent/chunks/lib-HGQMNYVT.js +9 -0
- package/vendor/agent/chunks/mistral-conversations-4M6BZBX6.js +5 -0
- package/vendor/agent/chunks/multipart-parser-SQ6GDJL7.js +3 -0
- package/vendor/agent/chunks/node-KG362ECQ.js +16 -0
- package/vendor/agent/chunks/node-TWVVAGPO.js +2 -0
- package/vendor/agent/chunks/openai-codex-responses-R6VYZTVY.js +10 -0
- package/vendor/agent/chunks/openai-codex.js +75 -0
- package/vendor/agent/chunks/openai-completions-EKZT2IH2.js +7 -0
- package/vendor/agent/chunks/openai-responses-TFDINO6W.js +2 -0
- package/vendor/agent/chunks/openrouter-images-N4XVVFSD.js +2 -0
- package/vendor/agent/chunks/openrouter.js +75 -0
- package/vendor/agent/chunks/pi-messages-PML4SPVJ.js +8 -0
- package/vendor/agent/chunks/radius.js +75 -0
- package/vendor/agent/chunks/src-UK77SYZE.js +4 -0
- package/vendor/agent/chunks/xai.js +2 -0
- package/vendor/agent/cli.js +3 -0
- package/vendor/agent/dist/modes/interactive/theme/dark.json +91 -0
- package/vendor/agent/dist/modes/interactive/theme/light.json +90 -0
- package/vendor/agent/dist/modes/interactive/theme/theme-schema.json +356 -0
- package/vendor/agent/index.js +2 -0
- package/vendor/agent/modes/interactive/theme/dark.json +91 -0
- package/vendor/agent/modes/interactive/theme/light.json +90 -0
- package/vendor/agent/modes/interactive/theme/theme-schema.json +356 -0
- package/vendor/agent/package.json +14 -0
- package/vendor/agent/rpc-entry.js +3 -0
- package/vendor/agent/theme/dark.json +91 -0
- package/vendor/agent/theme/light.json +90 -0
- package/vendor/agent/theme/theme-schema.json +356 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
const server = http.createServer((req,res) => {
|
|
4
|
+
const upstream = http.request({socketPath:'/broker.sock',method:req.method,path:req.url,headers:{'content-type':'application/json'}}, response=>{res.writeHead(response.statusCode,response.headers);response.pipe(res);});
|
|
5
|
+
upstream.on('error',()=>{if(!res.headersSent)res.writeHead(502);res.end();});
|
|
6
|
+
res.on('close',()=>upstream.destroy());req.pipe(upstream);
|
|
7
|
+
});
|
|
8
|
+
server.listen(12345,'127.0.0.1',()=>{
|
|
9
|
+
const child=spawn(process.execPath,process.argv.slice(2),{stdio:'inherit',env:process.env});
|
|
10
|
+
child.on('exit',(code)=>{server.closeAllConnections();server.close(()=>process.exit(code??1));});
|
|
11
|
+
process.on('SIGTERM',()=>{child.kill();server.closeAllConnections();server.close();});
|
|
12
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const BASE = 'f15d4eaba03d86786bec2de7aed1236718c813f9';
|
|
2
|
+
export const TASKS = {
|
|
3
|
+
append: `Implement a new chainable Fastify reply.appendHeader(name, value) API in this existing Fastify v5.6.2 repository, not a plugin or new application.
|
|
4
|
+
Acceptance:
|
|
5
|
+
1. name is a valid HTTP header-name string; value is string|number|readonly (string|number)[]; reject invalid names, undefined/null/objects/nonfinite numbers and CR/LF or Node-invalid header values synchronously with TypeError BEFORE changing any header. Empty arrays are no-op but names still validate. Validate all array members before mutation.
|
|
6
|
+
2. Names are case-insensitive. Append without overwriting existing Fastify or raw Node response header values; Fastify values take precedence over raw when both exist (same as getHeader). Preserve order, duplicates and each value including empty string/zero. Normalize newly supplied numbers to strings; do not split strings on commas. Array output is acceptable for all nonempty operations. Copy caller arrays; do not mutate a raw/header array obtained before this operation.
|
|
7
|
+
3. set-cookie values append exactly once (do not duplicate old values through existing header special handling). Ordinary reply.header/headers behavior must remain unchanged.
|
|
8
|
+
4. Method returns this, works inside an encapsulated plugin and onSend, and values appear over real HTTP. Requests must not share mutable header state.
|
|
9
|
+
5. Declare correct chainable TypeScript types accepting readonly arrays and rejecting objects/undefined, document behavior with examples in docs/Reference/Reply.md, and add meaningful regression tests under test/. No new runtime dependency; do not delete/disable existing tests.
|
|
10
|
+
Consult the official Node HTTP reference supplied at /reference/node-http.md (frozen online source, URL/hash in /reference/provenance.json) and cite the relevant source in your final answer. Repository baseline command: node --test test/internals/reply.test.js test/internals/request.test.js. Dependencies already installed. Run relevant tests, typecheck where appropriate, and finish with concise change/test/limitation summary. Do not access evaluator files, other candidate runs or real credentials. Budget 900 seconds/120 tool calls; implement a small runnable patch early.`,
|
|
11
|
+
vary: `Implement a new chainable Fastify reply.vary(fields) API in this existing Fastify v5.6.2 repository, not a plugin or new application.
|
|
12
|
+
Acceptance:
|
|
13
|
+
1. fields accepts a comma-separated string or readonly string[] (each element may itself contain commas). Trim optional ASCII space/tab around tokens; ignore empty tokens. Reject nonstrings, nested arrays and any nonempty invalid HTTP field-name token synchronously with TypeError BEFORE changing headers. CR/LF is invalid even at token edges; validate the whole input even if '*' is present. Empty input leaves the original header untouched.
|
|
14
|
+
2. Merge with the currently effective Vary header from Fastify or raw Node (Fastify precedence), supporting string/string[] existing values. Preserve first-seen spelling/order, deduplicate case-insensitively, and serialize using ', '. Existing duplicates must normalize on a nonempty call. '*' in existing/new values dominates and results in exactly '*'. No input array mutation.
|
|
15
|
+
3. Each call returns this, repeated calls accumulate, header casing does not matter, and other headers/reply.header semantics remain unchanged. Invalid calls leave both Fastify and raw header state unchanged.
|
|
16
|
+
4. Works in encapsulated plugin handlers and onSend; actual HTTP responses contain the merged Vary header. Independent requests must not share state.
|
|
17
|
+
5. Declare chainable TypeScript types accepting readonly string arrays and rejecting numbers/objects, document in docs/Reference/Reply.md with cache-negotiation example, and add meaningful regression tests under test/. No new runtime dependency; do not delete/disable existing tests.
|
|
18
|
+
Consult the supplied official HTTP Vary reference at /reference/rfc9110.txt (frozen online source, URL/hash in /reference/provenance.json) and cite it in the final answer. Repository baseline command: node --test test/internals/reply.test.js test/internals/request.test.js. Dependencies already installed. Run relevant tests and typechecks and finish with concise change/test/limitation summary. Do not access evaluator files, other candidate runs or real credentials. Budget 900 seconds/120 tool calls; implement a small runnable patch early.`
|
|
19
|
+
};
|
|
20
|
+
export const MATRIX = [['append','plain'],['append','harness'],['append','jev'],['vary','jev'],['vary','harness'],['vary','plain']];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const {writeFileSync}=require('node:fs');const {spawnSync}=require('node:child_process');
|
|
2
|
+
const task=process.argv[2];const lines=task==='append'?[
|
|
3
|
+
"reply.appendHeader('x', 'a').code(200)","reply.appendHeader('x', 0)","reply.appendHeader('x', ['a', 2] as const)","// @ts-expect-error object values invalid","reply.appendHeader('x', {})","// @ts-expect-error undefined invalid","reply.appendHeader('x', undefined)","// @ts-expect-error nonstring name invalid","reply.appendHeader(7, 'x')"
|
|
4
|
+
]:["reply.vary('Accept').code(200)","reply.vary(['Origin', 'Accept'] as const)","// @ts-expect-error numeric values invalid","reply.vary(7)","// @ts-expect-error object values invalid","reply.vary({})","// @ts-expect-error undefined invalid","reply.vary(undefined)"];
|
|
5
|
+
writeFileSync('/tmp/pilot-contract.ts',"import type { FastifyReply } from '/work/fastify'\ndeclare const reply: FastifyReply\n"+lines.join('\n'));
|
|
6
|
+
const r=spawnSync(process.execPath,['/work/node_modules/typescript/bin/tsc','/tmp/pilot-contract.ts','--noEmit','--strict','--skipLibCheck','--target','es2022','--module','node16','--moduleResolution','node16'],{encoding:'utf8',timeout:30000});process.stdout.write(r.stdout||'');process.stderr.write(r.stderr||'');process.exitCode=r.status??2;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Real host, local provider only. Verifies admission, framing and compaction. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { mkdir } from 'node:fs/promises';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { nativeFixture } from './native-fixture.mjs';
|
|
7
|
+
|
|
8
|
+
const host = await nativeFixture({ plugin: process.argv[2] });
|
|
9
|
+
try {
|
|
10
|
+
let { client } = host;
|
|
11
|
+
const { location, request, model, requests } = host;
|
|
12
|
+
const a = await client.session.create({ location, title: 'Framed', model }, request());
|
|
13
|
+
const b = await client.session.create({ location, title: 'Raw', model }, request());
|
|
14
|
+
const rpc = (method, input, at = location) => host.client.rpc.call({ rpcID: 'carthagent.session', method, input, location: at }, request());
|
|
15
|
+
await host.active();
|
|
16
|
+
assert.deepEqual((await rpc('framing', { sessionID: a.id, enabled: true })).output, { enabled: true });
|
|
17
|
+
await Promise.all([
|
|
18
|
+
client.session.prompt({ sessionID: a.id, text: 'Implement a parser' }, request()),
|
|
19
|
+
client.session.prompt({ sessionID: b.id, text: 'Implement a parser', metadata: { 'ctg.raw': true } }, request()),
|
|
20
|
+
]);
|
|
21
|
+
await Promise.all([client.session.wait({ sessionID: a.id }, request()), client.session.wait({ sessionID: b.id }, request())]);
|
|
22
|
+
const aMessages = await client.session.context({ sessionID: a.id }, request());
|
|
23
|
+
const bMessages = await client.session.context({ sessionID: b.id }, request());
|
|
24
|
+
assert.notEqual(aMessages.find(m => m.type === 'user')?.text, 'Implement a parser');
|
|
25
|
+
assert.equal(bMessages.find(m => m.type === 'user')?.text, 'Implement a parser');
|
|
26
|
+
assert.ok(aMessages.some(m => m.type === 'assistant'), JSON.stringify(aMessages));
|
|
27
|
+
assert.ok(bMessages.some(m => m.type === 'assistant'), JSON.stringify(bMessages));
|
|
28
|
+
assert.equal(aMessages.at(-1).outcome, 'succeeded');
|
|
29
|
+
assert.equal(bMessages.at(-1).outcome, 'succeeded');
|
|
30
|
+
await client.session.update({ sessionID: b.id, metadata: { 'carthagent.options': { guide: false } } }, request());
|
|
31
|
+
await client.session.prompt({ sessionID: b.id, text: 'Implement a second parser' }, request());
|
|
32
|
+
await client.session.wait({ sessionID: b.id }, request());
|
|
33
|
+
const disabled = await client.session.context({ sessionID: b.id }, request());
|
|
34
|
+
assert.equal(disabled.filter(m => m.type === 'user').at(-1).text, 'Implement a second parser');
|
|
35
|
+
assert.deepEqual((await rpc('framing', { sessionID: b.id })).output, { enabled: true });
|
|
36
|
+
await client.session.prompt({ sessionID: b.id, text: 'Implement a third parser' }, request());
|
|
37
|
+
await client.session.wait({ sessionID: b.id }, request());
|
|
38
|
+
const enabled = await client.session.context({ sessionID: b.id }, request());
|
|
39
|
+
assert.notEqual(enabled.filter(m => m.type === 'user').at(-1).text, 'Implement a third parser');
|
|
40
|
+
const marker = 'Preserve fixture decision 3e7b9';
|
|
41
|
+
await rpc('compact', { sessionID: a.id, notes: marker });
|
|
42
|
+
await client.session.wait({ sessionID: a.id }, request());
|
|
43
|
+
const compacted = await client.session.context({ sessionID: a.id }, request());
|
|
44
|
+
assert.ok(compacted.some(m => m.type === 'compaction'), JSON.stringify(compacted));
|
|
45
|
+
assert.ok(requests.some(body =>
|
|
46
|
+
JSON.stringify(body.messages).includes(marker)
|
|
47
|
+
&& JSON.stringify(body.messages.at(-1)).includes('structured summary')
|
|
48
|
+
), 'User notes reached the actual native summary request');
|
|
49
|
+
|
|
50
|
+
// Exercise real RPC location ownership, rather than relying on stubbed context.
|
|
51
|
+
const other = { directory: join(host.temp, 'other') };
|
|
52
|
+
await mkdir(other.directory);
|
|
53
|
+
await host.active(other);
|
|
54
|
+
const wrongWorkspace = error => error.message.includes('another workspace') && JSON.stringify(error).includes('wrong_workspace');
|
|
55
|
+
await assert.rejects(rpc('framing', { sessionID: a.id, enabled: false }, other), wrongWorkspace);
|
|
56
|
+
await assert.rejects(rpc('compact', { sessionID: a.id, notes: 'Must not be admitted' }, other), wrongWorkspace);
|
|
57
|
+
assert.deepEqual(await client.session.context({ sessionID: a.id }, request()), compacted);
|
|
58
|
+
|
|
59
|
+
// Persisted controls and launcher metadata must survive losing the whole service.
|
|
60
|
+
await rpc('framing', { sessionID: a.id, enabled: false });
|
|
61
|
+
await host.stop();
|
|
62
|
+
client = await host.start();
|
|
63
|
+
await host.active();
|
|
64
|
+
await Promise.all([
|
|
65
|
+
client.session.prompt({ sessionID: a.id, text: 'Implement after reconnect A' }, request()),
|
|
66
|
+
client.session.prompt({ sessionID: b.id, text: 'Implement after reconnect B' }, request()),
|
|
67
|
+
]);
|
|
68
|
+
await Promise.all([client.session.wait({ sessionID: a.id }, request()), client.session.wait({ sessionID: b.id }, request())]);
|
|
69
|
+
const afterA = await client.session.context({ sessionID: a.id }, request());
|
|
70
|
+
const afterB = await client.session.context({ sessionID: b.id }, request());
|
|
71
|
+
assert.equal(afterA.filter(m => m.type === 'user').at(-1).text, 'Implement after reconnect A');
|
|
72
|
+
assert.notEqual(afterB.filter(m => m.type === 'user').at(-1).text, 'Implement after reconnect B');
|
|
73
|
+
assert.equal((await client.session.get({ sessionID: b.id }, request())).metadata['carthagent.options'].guide, false);
|
|
74
|
+
assert.equal(afterA.at(-1).outcome, 'succeeded');
|
|
75
|
+
assert.equal(afterB.at(-1).outcome, 'succeeded');
|
|
76
|
+
assert.deepEqual(host.providerErrors, []);
|
|
77
|
+
console.log(JSON.stringify({ host: '2.0.32', sessions: 2, providerRequests: requests.length,
|
|
78
|
+
framing: 'passed', raw: 'passed', compaction: 'passed', locationOwnership: 'passed', serviceRestart: 'passed' }));
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(host.output);
|
|
81
|
+
throw error;
|
|
82
|
+
} finally {
|
|
83
|
+
await host.close();
|
|
84
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Offline real-host test. Uses a disposable HOME and never discovers the user's service. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { mkdtemp, mkdir, writeFile, rm, readFile } from 'node:fs/promises';
|
|
5
|
+
import { join, resolve } from 'node:path';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { once } from 'node:events';
|
|
9
|
+
import { randomBytes } from 'node:crypto';
|
|
10
|
+
import { OpenCode } from '@opencode/client';
|
|
11
|
+
import { createNativeFixture, toolCall, assistantText } from './native-fixture.mjs';
|
|
12
|
+
|
|
13
|
+
const root = resolve(import.meta.dirname, '..');
|
|
14
|
+
const plugin = resolve(process.argv[2] ?? join(root, 'plugins/carthagent'));
|
|
15
|
+
const productionPlugin = plugin.endsWith('/.ctg-production-plugin') ? resolve(plugin, '../plugins/carthagent/src/index.ts') : plugin.endsWith('/plugins/carthagent') ? resolve(plugin, 'src/index.ts') : plugin;
|
|
16
|
+
const archiveFixture = resolve(root, 'tests/fixtures/archive-plugin');
|
|
17
|
+
const binary = process.env.CTG_OPENCODE_BIN ?? join(root, 'node_modules/@opencode/cli/bin/opencode.exe');
|
|
18
|
+
const temp = await mkdtemp(join(tmpdir(), 'ctg-host-smoke-'));
|
|
19
|
+
const password = randomBytes(24).toString('hex');
|
|
20
|
+
let child;
|
|
21
|
+
let output = '';
|
|
22
|
+
let fixture;
|
|
23
|
+
const observed = [];
|
|
24
|
+
try {
|
|
25
|
+
const cwd = join(temp, 'project');
|
|
26
|
+
const config = join(temp, 'config/opencode');
|
|
27
|
+
const scenario = process.env.CTG_NATIVE_SCENARIO ?? 'standard';
|
|
28
|
+
const maxTools = ['budget', 'raw'].includes(scenario) ? 6 : scenario === 'concurrent' ? 10 : 0;
|
|
29
|
+
const workflow = scenario === 'strict' ? 'strict' : 'standard';
|
|
30
|
+
await Promise.all([mkdir(cwd), mkdir(config, { recursive: true }), mkdir(join(temp, 'home'))]);
|
|
31
|
+
const legacy = join(temp, 'home/.carthagent/agent/sessions');
|
|
32
|
+
await mkdir(legacy, { recursive: true });
|
|
33
|
+
await writeFile(join(legacy, 'legacy.jsonl'), '{"type":"session","id":"legacy-fixture"}\n{"type":"message","message":{"role":"user","content":"fixture needle"}}\nmalformed\n');
|
|
34
|
+
const composedPlugin = join(temp, 'production-composition');
|
|
35
|
+
await mkdir(composedPlugin);
|
|
36
|
+
await writeFile(join(composedPlugin, 'index.ts'), `
|
|
37
|
+
import { setupCarthagent } from ${JSON.stringify(productionPlugin)};
|
|
38
|
+
const invocations = [];
|
|
39
|
+
const interrupts = [];
|
|
40
|
+
const duplicateInvocations = [];
|
|
41
|
+
const Observer = { id: 'carthagent-delivery-observer', methods: { state: {
|
|
42
|
+
input: { type: 'object', properties: { sessionID: { type: 'string' } }, required: ['sessionID'], additionalProperties: false },
|
|
43
|
+
output: { type: 'object', properties: { budget: { type: ['object', 'null'], additionalProperties: true }, delivery: { type: ['object', 'null'], additionalProperties: true }, invocations: { type: 'array', items: { type: 'object', additionalProperties: true } }, duplicateInvocations: { type: 'array', items: { type: 'object', additionalProperties: true } }, interrupts: { type: 'array', items: { type: 'object', additionalProperties: true } }, tools: { type: 'array', items: { type: 'string' } } }, required: ['budget', 'delivery', 'invocations', 'duplicateInvocations', 'interrupts', 'tools'], additionalProperties: false },
|
|
44
|
+
} }, events: {} };
|
|
45
|
+
export default { id: 'carthagent', async setup(context) {
|
|
46
|
+
const monitored = { ...context,
|
|
47
|
+
tool: { ...context.tool, hook: async (name, callback) => context.tool.hook(name, async event => { if (name === 'execute.before') { const entry = { hook: name, sessionID: event.sessionID, tool: event.tool, id: event.id, messageID: event.messageID }; if (invocations.some(previous => previous.sessionID === entry.sessionID && previous.tool === entry.tool && previous.id === entry.id && previous.messageID === entry.messageID)) duplicateInvocations.push(entry); invocations.push(entry); } await callback(event); }) },
|
|
48
|
+
shell: { ...context.shell, hook: async (name, callback) => context.shell.hook(name, async event => { if (name === 'create.before') invocations.push({ hook: 'shell.' + name, command: event.command }); await callback(event); }) },
|
|
49
|
+
session: { ...context.session, interrupt: async input => { interrupts.push(input); return context.session.interrupt(input); } },
|
|
50
|
+
};
|
|
51
|
+
const cleanups = [];
|
|
52
|
+
try {
|
|
53
|
+
const scenarioOptions = JSON.parse(process.env.CTG_NATIVE_DELIVERY_OPTIONS || '{}');
|
|
54
|
+
if (process.env.CTG_NATIVE_SCENARIO === 'strict') scenarioOptions.workflow = 'strict';
|
|
55
|
+
cleanups.push(await setupCarthagent(monitored, { delivery: true, deliveryOptions: scenarioOptions }));
|
|
56
|
+
const observer = await context.rpc.register(Observer, { state: async input => {
|
|
57
|
+
const stored = await context.storage.get('session/' + input.sessionID);
|
|
58
|
+
return { budget: stored && stored.budget ? { tools: stored.budget.tools, limits: stored.budget.limits, stopped: stored.budget.stopped } : null, delivery: stored && stored.state ? stored.state : null, invocations: invocations.filter(call => call.sessionID === input.sessionID), duplicateInvocations: duplicateInvocations.filter(call => call.sessionID === input.sessionID), interrupts: interrupts.filter(call => call.sessionID === input.sessionID), tools: (await context.tool.list()).map(tool => tool.id) };
|
|
59
|
+
} });
|
|
60
|
+
cleanups.push(() => observer.dispose());
|
|
61
|
+
return async () => { for (const cleanup of cleanups.reverse()) await cleanup?.(); };
|
|
62
|
+
} catch (error) { for (const cleanup of cleanups.reverse()) await cleanup?.(); throw error; }
|
|
63
|
+
} };
|
|
64
|
+
`);
|
|
65
|
+
await writeFile(join(config, 'opencode.json'), JSON.stringify({ plugins: [composedPlugin, archiveFixture], update: 'disable' }));
|
|
66
|
+
fixture = createNativeFixture({ inspect: ({ body }) => observed.push({ tools: (body.tools ?? []).map(tool => tool.function?.name), messages: body.messages ?? [] }), respond: ({ body, response }) => {
|
|
67
|
+
const messages = body.messages ?? [];
|
|
68
|
+
const tools = (body.tools ?? []).map(tool => tool.function?.name);
|
|
69
|
+
const toolResults = messages.filter(message => message.role === 'tool').length;
|
|
70
|
+
const latestUser = [...messages].reverse().find(message => message.role === 'user');
|
|
71
|
+
if (JSON.stringify(latestUser).includes('CONCURRENT_IDENTICAL')) {
|
|
72
|
+
if (tools.includes('shell') && toolResults === 0) toolCall(response, { name: 'shell', arguments: { command: 'printf concurrent > identical.txt' } });
|
|
73
|
+
else assistantText(response, 'CONCURRENT_IDENTICAL_SHELL_OK');
|
|
74
|
+
} else if (JSON.stringify(latestUser).includes('MIXED_DISABLED')) {
|
|
75
|
+
if (tools.includes('shell') && toolResults === 0) toolCall(response, { name: 'shell', arguments: { command: "printf disabled-session > mixed-disabled.txt" } });
|
|
76
|
+
else assistantText(response, 'DISABLED_SESSION_SHELL_OK');
|
|
77
|
+
} else if (scenario === 'budget' && toolResults >= 6) {
|
|
78
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_status"]({})' } });
|
|
79
|
+
} else if (tools.includes('execute') && toolResults === 0) {
|
|
80
|
+
toolCall(response, { name: 'execute', arguments: { code: 'const result = await search({ query: "carthagent delivery tools", namespace: "carthagent", limit: 10 }); return result' } });
|
|
81
|
+
} else if (scenario === 'raw' && tools.includes('shell') && toolResults === 1) {
|
|
82
|
+
toolCall(response, { name: 'shell', arguments: { command: "printf 'fixture output\\n' > fixture.txt" } });
|
|
83
|
+
} else if (scenario === 'raw' && toolResults >= 2) {
|
|
84
|
+
assistantText(response, 'DISABLED_SESSION_SHELL_OK');
|
|
85
|
+
} else if (tools.includes('execute') && toolResults === 1) {
|
|
86
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_plan"]({ goal: "Add fixture output", assumptions: [], artifacts: ["fixture.txt"], outputs: ["fixture.txt"], steps: [{ id: "create-fixture", title: "Create fixture file" }], acceptance: [{ requirement: "fixture exists", checks: ["fixture-check"] }], checks: [{ id: "fixture-check", kind: "test", argv: ["node", "-e", "require(\\\"node:fs\\\").accessSync(\\\"fixture.txt\\\")"], timeoutSeconds: 5 }] })' } });
|
|
87
|
+
} else if (scenario === 'strict' && tools.includes('execute') && toolResults === 2) {
|
|
88
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_design"]({ action: "validate" })' } });
|
|
89
|
+
} else if (scenario === 'strict' && tools.includes('execute') && toolResults === 3) {
|
|
90
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_revise"]({ reason: "Add valid design evidence", patch: { design: { components: [{ id: "fixture", responsibility: "Create fixture output", excludes: ["verification"], layer: "core", dependencies: [], externalDependencies: [], requirements: ["fixture exists"] }], ports: [], risks: [], scenarios: [{ id: "positive", requirement: "fixture exists", kind: "positive", path: ["fixture"], input: "create file", expected: "file exists", assertion: "accessSync succeeds", checks: ["fixture-check"] }, { id: "negative", requirement: "fixture exists", kind: "failure", path: ["fixture"], input: "missing file", expected: "ENOENT", assertion: "accessSync throws ENOENT", checks: ["fixture-check"] }] } } })' } });
|
|
91
|
+
} else if (scenario === 'strict' && tools.includes('execute') && toolResults === 4) {
|
|
92
|
+
toolCall(response, { name: 'execute', arguments: { code: 'await tools.carthagent["delivery_design"]({ action: "validate" }); const inspected = await tools.carthagent["delivery_design"]({ action: "inspect" }); const captureId = String(inspected).match(/"captureId"\\s*:\\s*"([^"]+)"/)?.[1]; if (!captureId) throw Error("inspect did not expose a capture ID"); await tools.carthagent["delivery_design"]({ action: "review", captureId, review: { captureId, challenges: ["Could a missing output be accepted?"], findings: [], walkthroughs: [{ scenario: "positive", trace: "fixture -> exists", assertion: "accessSync succeeds" }, { scenario: "negative", trace: "missing -> ENOENT", assertion: "accessSync throws ENOENT" }], limitations: ["Model-authored review is not independent proof."] } }); return await tools.carthagent["delivery_design"]({ action: "approve" })' } });
|
|
93
|
+
} else if (scenario === 'strict' && tools.includes('execute') && toolResults === 5) {
|
|
94
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_finish"]({ status: "verified", review: "dishonest strict fixture attempt", launch: "not run", limitations: [] })' } });
|
|
95
|
+
} else if (tools.includes('shell') && toolResults === 2) {
|
|
96
|
+
toolCall(response, { name: 'shell', arguments: { command: "printf 'fixture output\\n' > fixture.txt" } });
|
|
97
|
+
} else if (tools.includes('execute') && toolResults === 3) {
|
|
98
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_progress"]({ step: "create-fixture", status: "done" })' } });
|
|
99
|
+
} else if (tools.includes('execute') && toolResults === 4) {
|
|
100
|
+
toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_check"]({ id: "all" })' } });
|
|
101
|
+
} else if (tools.includes('execute') && toolResults === 5) {
|
|
102
|
+
if (scenario === 'budget') toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_status"]({})' } });
|
|
103
|
+
else toolCall(response, { name: 'execute', arguments: { code: 'return await tools.carthagent["delivery_finish"]({ status: "verified", review: "dishonest fixture attempt", launch: "not run", limitations: [] })' } });
|
|
104
|
+
} else {
|
|
105
|
+
assistantText(response, 'Fixture completed its offline workflow; no verification claim is made.');
|
|
106
|
+
}
|
|
107
|
+
} });
|
|
108
|
+
const fixtureURL = await fixture.listen();
|
|
109
|
+
const fixtureConfig = join(config, 'opencode.json');
|
|
110
|
+
const cfg = JSON.parse(await (await import('node:fs/promises')).readFile(fixtureConfig, 'utf8'));
|
|
111
|
+
cfg.providers = { fixture: { name: 'Offline fixture', package: '@opencode/ai/providers/openai-compatible', settings: { baseURL: fixtureURL, apiKey: 'offline-test' }, models: { fixture: { name: 'Offline fixture', capabilities: { tools: true }, limit: { context: 64000, output: 1024 }, settings: { baseURL: fixtureURL, apiKey: 'offline-test' } } } } };
|
|
112
|
+
await writeFile(fixtureConfig, JSON.stringify(cfg));
|
|
113
|
+
const env = Object.fromEntries(['PATH', 'SystemRoot', 'WINDIR', 'ComSpec', 'PATHEXT', 'USERPROFILE']
|
|
114
|
+
.filter(key => process.env[key]).map(key => [key, process.env[key]]));
|
|
115
|
+
Object.assign(env, {
|
|
116
|
+
HOME: join(temp, 'home'),
|
|
117
|
+
USERPROFILE: join(temp, 'home'),
|
|
118
|
+
APPDATA: join(temp, 'appdata'),
|
|
119
|
+
LOCALAPPDATA: join(temp, 'localappdata'),
|
|
120
|
+
XDG_CONFIG_HOME: join(temp, 'config'),
|
|
121
|
+
XDG_DATA_HOME: join(temp, 'data'),
|
|
122
|
+
XDG_STATE_HOME: join(temp, 'state'),
|
|
123
|
+
XDG_CACHE_HOME: join(temp, 'cache'),
|
|
124
|
+
OPENCODE_DB: join(temp, 'database.sqlite'),
|
|
125
|
+
OPENCODE_SERVER_PASSWORD: password,
|
|
126
|
+
});
|
|
127
|
+
await Promise.all([mkdir(join(temp, 'appdata'), { recursive: true }), mkdir(join(temp, 'localappdata'), { recursive: true })]);
|
|
128
|
+
child = spawn(binary, [
|
|
129
|
+
'serve', '--hostname', '127.0.0.1', '--port', '0', '--print-logs', '--log-level', 'debug',
|
|
130
|
+
], { cwd, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
131
|
+
const endpoint = await new Promise((resolveEndpoint, reject) => {
|
|
132
|
+
const timer = setTimeout(() => reject(new Error(`Host startup timed out: ${output}`)), 30_000);
|
|
133
|
+
const collect = (chunk) => {
|
|
134
|
+
output = (output + chunk.toString()).slice(-16_384);
|
|
135
|
+
const address = output.match(/http:\/\/127\.0\.0\.1:\d+/)?.[0];
|
|
136
|
+
if (address) { clearTimeout(timer); resolveEndpoint(address); }
|
|
137
|
+
};
|
|
138
|
+
child.stdout.on('data', collect);
|
|
139
|
+
child.stderr.on('data', collect);
|
|
140
|
+
child.once('error', (error) => { clearTimeout(timer); reject(error); });
|
|
141
|
+
child.once('exit', (code) => { clearTimeout(timer); reject(new Error(`Host exited ${code}: ${output}`)); });
|
|
142
|
+
});
|
|
143
|
+
const client = OpenCode.make({
|
|
144
|
+
baseUrl: endpoint,
|
|
145
|
+
headers: { authorization: `Basic ${Buffer.from(`opencode:${password}`).toString('base64')}` },
|
|
146
|
+
});
|
|
147
|
+
// Reused request objects must not carry a deadline that expires during the
|
|
148
|
+
// multi-turn offline workflow; give each host call its own bounded signal.
|
|
149
|
+
const request = { signal: AbortSignal.timeout(120_000) };
|
|
150
|
+
const info = await client.server.info(request);
|
|
151
|
+
assert.equal(info.version, '2.0.32');
|
|
152
|
+
const unauthorized = await fetch(`${endpoint}/api/info`, { signal: request.signal });
|
|
153
|
+
assert.equal(unauthorized.status, 401);
|
|
154
|
+
await client.session.create({ location: { directory: cwd }, title: 'CTG host smoke' }, request);
|
|
155
|
+
let plugins;
|
|
156
|
+
const deadline = Date.now() + 15_000;
|
|
157
|
+
do {
|
|
158
|
+
plugins = await client.plugin.list({ location: { directory: cwd } }, request);
|
|
159
|
+
if (plugins.data.some((entry) => entry.id === 'carthagent')) break;
|
|
160
|
+
await new Promise((done) => setTimeout(done, 200));
|
|
161
|
+
} while (Date.now() < deadline);
|
|
162
|
+
const nativePlugin = plugins.data.find((entry) => entry.id === 'carthagent');
|
|
163
|
+
const archivePlugin = plugins.data.find((entry) => entry.id === 'ctg-archive-fixture');
|
|
164
|
+
assert.ok(nativePlugin, 'Carthagent plugin must become visible');
|
|
165
|
+
assert.equal(nativePlugin.state.status, 'active');
|
|
166
|
+
assert.equal(archivePlugin?.state.status, 'active', 'archive registration fixture must become visible');
|
|
167
|
+
const health = await client.rpc.call({
|
|
168
|
+
rpcID: 'carthagent', method: 'health', input: {}, location: { directory: cwd },
|
|
169
|
+
}, request);
|
|
170
|
+
console.log(JSON.stringify({ version: info.version, plugin: nativePlugin, health }, null, 2));
|
|
171
|
+
assert.equal(health.output.directory, cwd);
|
|
172
|
+
assert.equal(health.output.protocol, 1);
|
|
173
|
+
await assert.rejects(client.rpc.call({
|
|
174
|
+
rpcID: 'carthagent', method: 'health', input: { unexpected: true }, location: { directory: cwd },
|
|
175
|
+
}, request));
|
|
176
|
+
const archiveCall = (method, input) => client.rpc.call({
|
|
177
|
+
rpcID: 'carthagent.archive', method, input, location: { directory: cwd },
|
|
178
|
+
}, request);
|
|
179
|
+
const listed = await archiveCall('list', {});
|
|
180
|
+
assert.equal(listed.output.total, 1);
|
|
181
|
+
const archiveID = listed.output.items[0].id;
|
|
182
|
+
assert.match(archiveID, /^[a-f0-9]{64}$/);
|
|
183
|
+
assert.equal('path' in listed.output.items[0], false);
|
|
184
|
+
const searched = await archiveCall('search', { query: 'needle' });
|
|
185
|
+
assert.equal(searched.output.items[0].id, archiveID);
|
|
186
|
+
const transcript = await archiveCall('read', { id: archiveID });
|
|
187
|
+
assert.equal(transcript.output.archiveOnly, true);
|
|
188
|
+
assert.equal(transcript.output.records.length, 2);
|
|
189
|
+
assert.deepEqual(transcript.output.malformedLines, [{ line: 3 }]);
|
|
190
|
+
const exported = await archiveCall('export', { id: archiveID, format: 'jsonl' });
|
|
191
|
+
assert.match(exported.output.content, /legacy-fixture/);
|
|
192
|
+
await assert.rejects(archiveCall('read', { id: join(temp, 'outside.jsonl') }), error => error.type === 'archive_error');
|
|
193
|
+
await assert.rejects(archiveCall('search', { query: ' ' }), error => error.type === 'archive_error');
|
|
194
|
+
await assert.rejects(archiveCall('list', { limit: 101 }), error => error.type === 'rpc.invalid_input');
|
|
195
|
+
assert.equal(await readFile(join(legacy, 'legacy.jsonl'), 'utf8'), '{"type":"session","id":"legacy-fixture"}\n{"type":"message","message":{"role":"user","content":"fixture needle"}}\nmalformed\n');
|
|
196
|
+
const session = await client.session.create({
|
|
197
|
+
location: { directory: cwd }, title: 'CTG delivery host',
|
|
198
|
+
metadata: { 'carthagent.options': { workflow, maxTools, ...(['raw', 'concurrent'].includes(scenario) ? { delivery: false } : {}) } },
|
|
199
|
+
}, request);
|
|
200
|
+
await client.session.switchModel({ sessionID: session.id, model: { providerID: 'fixture', id: 'fixture' } }, request);
|
|
201
|
+
if (scenario === 'concurrent') {
|
|
202
|
+
const sibling = await client.session.create({ location: { directory: cwd }, title: 'CTG identical concurrent shell sibling', metadata: { 'carthagent.options': { delivery: false, maxTools: 10 } } }, request);
|
|
203
|
+
await client.session.switchModel({ sessionID: sibling.id, model: { providerID: 'fixture', id: 'fixture' } }, request);
|
|
204
|
+
const prompts = await Promise.all([
|
|
205
|
+
client.session.prompt({ sessionID: session.id, text: 'CONCURRENT_IDENTICAL session one, run identical shell now.' }, request),
|
|
206
|
+
client.session.prompt({ sessionID: sibling.id, text: 'CONCURRENT_IDENTICAL session two, run identical shell now.' }, request),
|
|
207
|
+
]);
|
|
208
|
+
assert.ok(prompts.every(turn => turn.type === 'user'));
|
|
209
|
+
await Promise.all([session.id, sibling.id].map(sessionID => client.session.wait({ sessionID }, { signal: AbortSignal.timeout(45_000) })));
|
|
210
|
+
for (const sessionID of [session.id, sibling.id]) {
|
|
211
|
+
const diagnostics = await client.rpc.call({ rpcID: 'carthagent-delivery-observer', method: 'state', input: { sessionID }, location: { directory: cwd } }, request);
|
|
212
|
+
assert.equal(diagnostics.output.budget.tools, 1, 'identical same-worktree shell command is charged only to its invoking session');
|
|
213
|
+
assert.equal(diagnostics.output.invocations.filter(entry => ['bash', 'shell', 'powershell'].includes(entry.tool)).length, 1);
|
|
214
|
+
}
|
|
215
|
+
assert.match(await readFile(join(cwd, 'identical.txt'), 'utf8'), /concurrent/);
|
|
216
|
+
console.log(JSON.stringify({ scenario, identicalShellCalls: 2, independentSessionBudgets: true }, null, 2));
|
|
217
|
+
} else {
|
|
218
|
+
const promptText = scenario === 'raw' ? 'Run this shell command exactly: printf raw bypass > raw.txt' : 'Create and verify a tiny fixture file.';
|
|
219
|
+
const turn = await client.session.prompt({ sessionID: session.id, text: promptText, ...(scenario === 'raw' ? { metadata: { 'ctg.raw': true } } : {}) }, request);
|
|
220
|
+
await client.session.wait({ sessionID: session.id }, { signal: AbortSignal.timeout(45_000) });
|
|
221
|
+
assert.equal(turn.type, 'user', 'model request was admitted');
|
|
222
|
+
const history = await client.message.list({ sessionID: session.id }, { signal: AbortSignal.timeout(10_000) });
|
|
223
|
+
const serialized = JSON.stringify(history.data);
|
|
224
|
+
if (scenario !== 'raw') assert.match(serialized, /delivery_plan/, 'the offline provider must call the registered delivery tool');
|
|
225
|
+
if (scenario === 'raw') {
|
|
226
|
+
assert.match(serialized, /DISABLED_SESSION_SHELL_OK/, 'delivery:false leaves native shell available');
|
|
227
|
+
}
|
|
228
|
+
if (scenario !== 'raw') assert.match(serialized, /fixture-check/, 'the host run must persist the declared check');
|
|
229
|
+
if (scenario !== 'strict' && scenario !== 'raw') {
|
|
230
|
+
assert.match(serialized, /fixture output/, 'the host must execute the implementation shell command');
|
|
231
|
+
if (scenario !== 'budget') assert.match(serialized, /passed.{0,40}true/, 'the declared validator must produce real passing evidence');
|
|
232
|
+
}
|
|
233
|
+
if (scenario !== 'budget' && scenario !== 'raw') assert.match(serialized, /Cannot verify:/, 'the host must reject a dishonest verified finish');
|
|
234
|
+
assert.ok(observed.some(request => request.tools.includes('execute')), 'the provider request must use the native Code Mode dispatcher');
|
|
235
|
+
if (scenario === 'strict') {
|
|
236
|
+
const strictCalls = observed.filter(request => request.messages.some(message =>
|
|
237
|
+
message.role === 'tool' && String(message.content ?? '').includes('planningStatus'),
|
|
238
|
+
));
|
|
239
|
+
assert.ok(strictCalls.length > 0, 'strict host transcript includes persisted design-gate responses');
|
|
240
|
+
assert.ok(strictCalls.some(request => !request.tools.includes('shell')), 'strict workflow hides shell while the design gate is active');
|
|
241
|
+
}
|
|
242
|
+
if (scenario !== 'budget' && scenario !== 'raw') assert.match(serialized, /carthagent\.delivery_finish.{0,180}status.{0,40}error/s, 'dishonest finish must remain an error, not successful evidence');
|
|
243
|
+
assert.ok(fixture.calls >= 2, 'host made real SSE requests to the local fixture');
|
|
244
|
+
const diagnostics = await client.rpc.call({ rpcID: 'carthagent-delivery-observer', method: 'state', input: { sessionID: session.id }, location: { directory: cwd } }, request);
|
|
245
|
+
if (scenario !== 'raw') {
|
|
246
|
+
assert.ok(diagnostics.output.tools.some(name => name.includes('delivery_plan')), 'production setup exposes optional delivery tools when composition enables delivery');
|
|
247
|
+
assert.ok(diagnostics.output.tools.some(name => name.includes('code_nav')), 'production setup composes codegraph registration with delivery');
|
|
248
|
+
}
|
|
249
|
+
const budget = diagnostics.output.budget;
|
|
250
|
+
if (scenario === 'strict') {
|
|
251
|
+
assert.equal(diagnostics.output.delivery?.workflowMode, 'strict');
|
|
252
|
+
assert.ok(diagnostics.output.delivery.planning.validation?.findings.length === 0, 'strict design validates with no blocking findings');
|
|
253
|
+
assert.equal(diagnostics.output.delivery.planning.review?.provenance, 'model-authored; not independent assurance', `${JSON.stringify(diagnostics.output.delivery.planning)}\n${serialized}`);
|
|
254
|
+
assert.ok(diagnostics.output.delivery.planning.approval, `strict workflow persisted explicit design approval\n${serialized}`);
|
|
255
|
+
assert.equal(diagnostics.output.delivery.planning.started, undefined, 'approval does not silently start implementation');
|
|
256
|
+
}
|
|
257
|
+
assert.ok(budget, 'native tool hook persisted a session budget');
|
|
258
|
+
const chargedToolInvocations = diagnostics.output.invocations.filter(entry => entry.hook === 'execute.before').length;
|
|
259
|
+
if (scenario === 'strict') {
|
|
260
|
+
assert.equal(diagnostics.output.invocations.some(entry => ['bash', 'shell', 'powershell'].includes(entry.tool)), false, 'strict design scenario never invokes shell');
|
|
261
|
+
assert.equal(budget.tools, chargedToolInvocations - diagnostics.output.duplicateInvocations.length, 'strict Code Mode calls charge once; hook re-entry is deduplicated');
|
|
262
|
+
assert.ok(diagnostics.output.delivery.planning.approval, 'strict workflow persisted explicit design approval');
|
|
263
|
+
} else if (scenario === 'budget') {
|
|
264
|
+
assert.equal(budget.tools, maxTools, 'native budget stops at its per-session configured tool limit');
|
|
265
|
+
assert.ok(diagnostics.output.invocations.some(entry => entry.hook === 'execute.before' && entry.tool === 'execute'), 'execution hook persisted the admission that reached the cap');
|
|
266
|
+
assert.ok(diagnostics.output.budget.stopped, 'the host budget persists its stopped reason');
|
|
267
|
+
assert.ok(diagnostics.output.interrupts.some(call => call.resume === false), 'budget exhaustion interrupts the host turn without resuming it');
|
|
268
|
+
} else if (scenario === 'raw') {
|
|
269
|
+
assert.ok(diagnostics.output.invocations.some(entry => entry.hook === 'execute.before' && ['bash', 'shell', 'powershell'].includes(entry.tool)), 'delivery:false permits explicitly requested native shell execution');
|
|
270
|
+
assert.equal(budget.tools, chargedToolInvocations, 'delivery:false session charges every admitted host tool call exactly once');
|
|
271
|
+
assert.equal(diagnostics.output.invocations.some(entry => entry.tool?.startsWith('carthagent_delivery_')), false, 'disabled session never executes a delivery workflow tool');
|
|
272
|
+
} else {
|
|
273
|
+
assert.ok(diagnostics.output.invocations.some(entry => entry.hook === 'execute.before' && ['bash', 'shell', 'powershell'].includes(entry.tool)), 'the real host reports native shell at the session-scoped execution hook');
|
|
274
|
+
assert.equal(budget.tools, chargedToolInvocations - diagnostics.output.duplicateInvocations.length, 'Code Mode dispatches and shell calls each charge once at execute.before');
|
|
275
|
+
}
|
|
276
|
+
console.log(JSON.stringify({ fixtureCalls: fixture.calls, planToolObserved: true, scenario, budget: budget.tools }, null, 2));
|
|
277
|
+
if (scenario === 'mixed') {
|
|
278
|
+
const disabledSession = await client.session.create({
|
|
279
|
+
location: { directory: cwd }, title: 'CTG disabled session in shared worktree',
|
|
280
|
+
metadata: { 'carthagent.options': { delivery: false, maxTools: 10 } },
|
|
281
|
+
}, request);
|
|
282
|
+
await client.session.switchModel({ sessionID: disabledSession.id, model: { providerID: 'fixture', id: 'fixture' } }, request);
|
|
283
|
+
await client.session.prompt({ sessionID: disabledSession.id, text: 'MIXED_DISABLED run the native shell command once.' }, request);
|
|
284
|
+
await client.session.wait({ sessionID: disabledSession.id }, { signal: AbortSignal.timeout(45_000) });
|
|
285
|
+
const disabledHistory = await client.message.list({ sessionID: disabledSession.id }, { signal: AbortSignal.timeout(10_000) });
|
|
286
|
+
assert.match(JSON.stringify(disabledHistory.data), /DISABLED_SESSION_SHELL_OK/);
|
|
287
|
+
const disabledDiagnostics = await client.rpc.call({ rpcID: 'carthagent-delivery-observer', method: 'state', input: { sessionID: disabledSession.id }, location: { directory: cwd } }, request);
|
|
288
|
+
const disabledCount = disabledDiagnostics.output.invocations.filter(entry => entry.hook === 'execute.before').length;
|
|
289
|
+
assert.equal(disabledDiagnostics.output.budget.tools, disabledCount, 'disabled sibling session counts its own distinct shell call exactly once');
|
|
290
|
+
assert.ok(disabledDiagnostics.output.budget.limits.tools === 10);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
console.log('Native plugin and validated RPC passed against OpenCode 2.0.32.');
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.error(output.replaceAll(password, '[redacted]'));
|
|
296
|
+
throw error;
|
|
297
|
+
} finally {
|
|
298
|
+
await fixture?.close().catch(() => {});
|
|
299
|
+
if (child && child.exitCode === null && child.signalCode === null) {
|
|
300
|
+
const exited = once(child, 'exit');
|
|
301
|
+
child.kill('SIGTERM');
|
|
302
|
+
const timer = setTimeout(() => child.kill('SIGKILL'), 5_000);
|
|
303
|
+
await exited;
|
|
304
|
+
clearTimeout(timer);
|
|
305
|
+
}
|
|
306
|
+
await rm(temp, { recursive: true, force: true });
|
|
307
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Real isolated OpenCode 2 host + local provider; no provider spend. */
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { nativeFixture, streamText } from './native-fixture.mjs';
|
|
6
|
+
import { runNativeEvaluation } from '../lib/opencode/evaluation.mjs';
|
|
7
|
+
|
|
8
|
+
const host = await nativeFixture({ plugin:resolve(import.meta.dirname,'../lib/opencode/evaluation-budget-plugin'), env:{CTG_EVALUATION_MAX_TURNS:'4',CTG_EVALUATION_MAX_COST:'1'}, respond(body,res) {
|
|
9
|
+
if (body.messages.at(-1)?.content === 'CTG_FIXTURE_FAILURE') {
|
|
10
|
+
res.writeHead(400,{'content-type':'application/json'});
|
|
11
|
+
res.end(JSON.stringify({error:{message:'Deterministic provider rejection',type:'invalid_request_error'}}));
|
|
12
|
+
} else streamText(res);
|
|
13
|
+
} });
|
|
14
|
+
try {
|
|
15
|
+
const { client, cwd: directory, location, model, request } = host;
|
|
16
|
+
await host.active('ctg.evaluation-budget',location);
|
|
17
|
+
const unrelated = await client.session.create({ location, model, title:'unrelated session' }, request());
|
|
18
|
+
await client.session.prompt({ sessionID:unrelated.id, text:'Generate unrelated fixture usage' }, request());
|
|
19
|
+
await host.outcome(unrelated.id);
|
|
20
|
+
const result = await runNativeEvaluation({ client, directory, prompt:'Run bounded fixture task.', provider:model.providerID, model:model.id, timeoutSeconds:30, maxTurns:4, maxCost:1 });
|
|
21
|
+
assert.equal(result.runtime,'opencode-2');
|
|
22
|
+
assert.equal(result.exitCode,0,JSON.stringify(result));
|
|
23
|
+
assert.equal(result.outcome,'succeeded');
|
|
24
|
+
assert.equal(result.turns,1,JSON.stringify(result));
|
|
25
|
+
assert.equal(result.lastStop,'stop');
|
|
26
|
+
assert.notEqual(result.sessionID,unrelated.id);
|
|
27
|
+
assert.ok(Number.isFinite(result.cost),JSON.stringify(result));
|
|
28
|
+
const own = await client.session.get({sessionID:result.sessionID},request());
|
|
29
|
+
assert.equal(result.cost,own.cost,'use exact session aggregate cost');
|
|
30
|
+
assert.equal(result.tokens,own.tokens.input+own.tokens.output+own.tokens.reasoning+own.tokens.cache.read+own.tokens.cache.write,'use exact session aggregate tokens');
|
|
31
|
+
assert.notEqual(result.sessionID,unrelated.id,'the evaluator uses only its own newly-created session');
|
|
32
|
+
const failed = await runNativeEvaluation({client,directory,prompt:'CTG_FIXTURE_FAILURE',provider:model.providerID,model:model.id,timeoutSeconds:30,maxTurns:4,maxCost:1});
|
|
33
|
+
assert.equal(failed.exitCode,1,JSON.stringify(failed));
|
|
34
|
+
assert.equal(failed.outcome,'failed',JSON.stringify(failed));
|
|
35
|
+
assert.equal(failed.budgetReason,'session failed');
|
|
36
|
+
assert.equal(failed.turns,1,JSON.stringify(failed));
|
|
37
|
+
assert.equal(failed.productiveTurns,0,JSON.stringify(failed));
|
|
38
|
+
assert.ok(failed.providerErrors >= 1,JSON.stringify(failed));
|
|
39
|
+
assert.equal(host.requests.length,2);
|
|
40
|
+
const mismatched = await runNativeEvaluation({client,directory,prompt:'This must fail the budget handshake.',provider:model.providerID,model:model.id,timeoutSeconds:30,maxTurns:5,maxCost:1});
|
|
41
|
+
assert.equal(mismatched.exitCode,1,JSON.stringify(mismatched));
|
|
42
|
+
assert.equal(mismatched.outcome,'failed',JSON.stringify(mismatched));
|
|
43
|
+
assert.ok(mismatched.errors.some(error=>/budget handshake/i.test(error)),JSON.stringify(mismatched));
|
|
44
|
+
assert.equal(host.requests.length,2,'mismatched turn limit must be rejected before provider admission');
|
|
45
|
+
console.log(JSON.stringify({host:'2.0.32',outcome:result.outcome,failureOutcome:failed.outcome,turns:result.turns,cost:result.cost,isolatedFromConcurrentSession:true}));
|
|
46
|
+
} finally { await host.close(); }
|