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,300 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {
|
|
4
|
+
EXPERIENTIAL_API_KEY_ENV,
|
|
5
|
+
EXPERIENTIAL_PROVIDER_ID,
|
|
6
|
+
cloudGatewayUrl,
|
|
7
|
+
cloudOAuth,
|
|
8
|
+
createCloudOperationIdentity,
|
|
9
|
+
experientialBaseUrl,
|
|
10
|
+
isCloudAccessToken,
|
|
11
|
+
isManagedCloudNonRetryableError,
|
|
12
|
+
managedCloudRequestOptions,
|
|
13
|
+
experientialProviderConfig,
|
|
14
|
+
experientialModelDefinition,
|
|
15
|
+
parseExperientialModels,
|
|
16
|
+
registerExperientialProvider,
|
|
17
|
+
} from '../lib/providers/experiential.mjs';
|
|
18
|
+
|
|
19
|
+
test('Experiential provider uses the hosted gateway and canonical environment variable', () => {
|
|
20
|
+
assert.equal(EXPERIENTIAL_PROVIDER_ID, 'experiential-labs');
|
|
21
|
+
assert.equal(EXPERIENTIAL_API_KEY_ENV, 'EXPLABS_API_KEY');
|
|
22
|
+
assert.equal(experientialBaseUrl({}), 'https://api.experientiallabs.ai/v1');
|
|
23
|
+
assert.equal(experientialBaseUrl({ EXP_GATEWAY_URL: ' https://preview.test/v1/ ' }), 'https://preview.test/v1');
|
|
24
|
+
assert.equal(experientialBaseUrl({ CARTHAGENT_CLOUD_URL: ' https://control-plane.test/ ' }), 'https://api.experientiallabs.ai/v1');
|
|
25
|
+
assert.equal(cloudGatewayUrl({ CARTHAGENT_CLOUD_URL: ' https://control-plane.test/v1/ ' }), 'https://control-plane.test/v1');
|
|
26
|
+
const access = ['header', Buffer.from(JSON.stringify({ sub: 'account', sid: 'session', scope: 'models:read gateway:invoke' })).toString('base64url'), 'signature'].join('.');
|
|
27
|
+
assert.equal(isCloudAccessToken(access), true);
|
|
28
|
+
assert.equal(isCloudAccessToken('direct-test-key'), false);
|
|
29
|
+
const config = experientialProviderConfig({ env: {} });
|
|
30
|
+
assert.equal(config.apiKey, '$EXPLABS_API_KEY');
|
|
31
|
+
assert.equal(config.authHeader, true);
|
|
32
|
+
assert.equal(config.api, 'openai-completions');
|
|
33
|
+
assert.equal(typeof config.streamSimple, 'function');
|
|
34
|
+
assert.equal(config.oauth.name, 'Carthagent Ship account');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Managed Cloud operations share one identity and disable transport retries until replay exists', async () => {
|
|
38
|
+
let ids = 0;
|
|
39
|
+
const payloads = [];
|
|
40
|
+
const options = managedCloudRequestOptions({
|
|
41
|
+
maxRetries: 7,
|
|
42
|
+
requestHeaders: { 'X-Test': 'preserved' },
|
|
43
|
+
onPayload: async payload => {
|
|
44
|
+
payloads.push(payload);
|
|
45
|
+
return { ...payload, metadata: { inherited: 'yes' } };
|
|
46
|
+
},
|
|
47
|
+
}, () => `operation-${++ids}`);
|
|
48
|
+
|
|
49
|
+
assert.equal(ids, 1);
|
|
50
|
+
assert.equal(options.maxRetries, 0);
|
|
51
|
+
for (const [key, value] of Object.entries({
|
|
52
|
+
'X-Test': 'preserved',
|
|
53
|
+
'Idempotency-Key': 'operation-1',
|
|
54
|
+
'X-Client-Request-Id': 'operation-1',
|
|
55
|
+
})) assert.equal(options.requestHeaders[key], value);
|
|
56
|
+
const body = await options.onPayload({ model: 'carthagent-code', messages: [] }, { id: 'carthagent-code' });
|
|
57
|
+
assert.equal(payloads.length, 1);
|
|
58
|
+
assert.deepEqual(body.metadata, { inherited: 'yes', operation_key: 'operation-1' });
|
|
59
|
+
|
|
60
|
+
assert.equal(options.requestHeaders['Idempotency-Key'], 'operation-1');
|
|
61
|
+
assert.equal(createCloudOperationIdentity(() => `operation-${++ids}`), 'operation-2');
|
|
62
|
+
assert.throws(() => createCloudOperationIdentity(() => ''), /identity is invalid/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('Managed Cloud payloads drop disabled thinking only for always-reasoning models', async () => {
|
|
66
|
+
const options = managedCloudRequestOptions({}, () => 'operation-x');
|
|
67
|
+
const alwaysReasoning = { id: 'glm-5.3', thinkingLevelMap: { off: null, low: 'low' } };
|
|
68
|
+
const body = await options.onPayload({ thinking: { type: 'disabled' } }, alwaysReasoning);
|
|
69
|
+
assert.equal(body.thinking, undefined);
|
|
70
|
+
assert.equal(body.metadata.operation_key, 'operation-x');
|
|
71
|
+
|
|
72
|
+
const canDisable = { id: 'deepseek-v4.1-flash', thinkingLevelMap: { off: 'none', low: 'low' } };
|
|
73
|
+
const deepseekBody = await options.onPayload({ thinking: { type: 'disabled' } }, canDisable);
|
|
74
|
+
assert.deepEqual(deepseekBody.thinking, { type: 'disabled' });
|
|
75
|
+
|
|
76
|
+
const noMap = await options.onPayload({ thinking: { type: 'disabled' } }, { id: 'other' });
|
|
77
|
+
assert.deepEqual(noMap.thinking, { type: 'disabled' });
|
|
78
|
+
|
|
79
|
+
const enabled = await options.onPayload({ thinking: { type: 'enabled', clear_thinking: false } }, alwaysReasoning);
|
|
80
|
+
assert.deepEqual(enabled.thinking, { type: 'enabled', clear_thinking: false });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('Managed Cloud duplicate-operation errors are marked non-retryable', () => {
|
|
84
|
+
assert.equal(isManagedCloudNonRetryableError('idempotency_key_reused'), true);
|
|
85
|
+
assert.equal(isManagedCloudNonRetryableError('request_reconciliation_required'), true);
|
|
86
|
+
assert.equal(isManagedCloudNonRetryableError('500 server error'), false);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('Managed Cloud transport makes one attempt while direct Experiential preserves configured retries', async () => {
|
|
90
|
+
const managedAccess = ['header', Buffer.from(JSON.stringify({ sub: 'account', sid: 'session', scope: 'gateway:invoke' })).toString('base64url'), 'signature'].join('.');
|
|
91
|
+
const model = {
|
|
92
|
+
id: 'gpt-5.6-luna',
|
|
93
|
+
name: 'GPT-5.6 Luna',
|
|
94
|
+
provider: 'experiential-labs',
|
|
95
|
+
api: 'openai-completions',
|
|
96
|
+
baseUrl: 'https://direct.test/v1',
|
|
97
|
+
};
|
|
98
|
+
const context = { messages: [{ role: 'user', content: 'hello', timestamp: Date.now() }] };
|
|
99
|
+
const response = () => new Response(JSON.stringify({ error: { message: 'retryable test failure' } }), {
|
|
100
|
+
status: 500,
|
|
101
|
+
headers: { 'content-type': 'application/json' },
|
|
102
|
+
});
|
|
103
|
+
const config = experientialProviderConfig({ env: { CARTHAGENT_CLOUD_URL: 'https://cloud.test' } });
|
|
104
|
+
|
|
105
|
+
const managedCalls = [];
|
|
106
|
+
const managed = await config.streamSimple(model, context, {
|
|
107
|
+
apiKey: managedAccess,
|
|
108
|
+
maxRetries: 2,
|
|
109
|
+
maxRetryDelayMs: 1,
|
|
110
|
+
fetch: async (url, init) => { managedCalls.push({ url, init }); return response(); },
|
|
111
|
+
}).result();
|
|
112
|
+
assert.equal(managed.stopReason, 'error');
|
|
113
|
+
assert.equal(managedCalls.length, 1);
|
|
114
|
+
assert.equal(managedCalls[0].url.startsWith('https://cloud.test/v1/'), true);
|
|
115
|
+
assert.equal(managedCalls[0].init.headers.has('idempotency-key'), true);
|
|
116
|
+
|
|
117
|
+
const duplicateCalls = [];
|
|
118
|
+
const duplicate = await config.streamSimple(model, context, {
|
|
119
|
+
apiKey: managedAccess,
|
|
120
|
+
maxRetries: 2,
|
|
121
|
+
maxRetryDelayMs: 1,
|
|
122
|
+
fetch: async (url, init) => {
|
|
123
|
+
duplicateCalls.push({ url, init });
|
|
124
|
+
return new Response(JSON.stringify({ error: { message: 'request_reconciliation_required', code: 'request_reconciliation_required' } }), {
|
|
125
|
+
status: 400,
|
|
126
|
+
headers: { 'content-type': 'application/json' },
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
}).result();
|
|
130
|
+
assert.equal(duplicate.stopReason, 'error');
|
|
131
|
+
assert.equal(duplicateCalls.length, 1);
|
|
132
|
+
assert.match(duplicate.errorMessage, /cannot safely replay this operation yet/i);
|
|
133
|
+
assert.match(duplicate.errorMessage, /request_reconciliation_required/i);
|
|
134
|
+
|
|
135
|
+
const directCalls = [];
|
|
136
|
+
const direct = await config.streamSimple(model, context, {
|
|
137
|
+
apiKey: 'direct-test-key',
|
|
138
|
+
maxRetries: 1,
|
|
139
|
+
maxRetryDelayMs: 1,
|
|
140
|
+
fetch: async (url, init) => { directCalls.push({ url, init }); return response(); },
|
|
141
|
+
}).result();
|
|
142
|
+
assert.equal(direct.stopReason, 'error');
|
|
143
|
+
assert.equal(directCalls.length, 2);
|
|
144
|
+
assert.equal(directCalls[0].url.startsWith('https://direct.test/v1/'), true);
|
|
145
|
+
assert.equal(directCalls[0].init.headers.has('idempotency-key'), false);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('Experiential model parsing is sorted, deduplicated, and resolves reasoning capabilities', () => {
|
|
149
|
+
const models = parseExperientialModels({ data: [
|
|
150
|
+
{ id: 'z-model', name: 'Zed' },
|
|
151
|
+
{ id: 'gpt-6-luna' },
|
|
152
|
+
{ id: 'qwen3-max-thinking' },
|
|
153
|
+
{ id: 'z-model', name: 'Duplicate' },
|
|
154
|
+
{ nope: true },
|
|
155
|
+
] });
|
|
156
|
+
assert.deepEqual(models.map(model => model.id), ['gpt-6-luna', 'qwen3-max-thinking', 'z-model']);
|
|
157
|
+
assert.equal(models[0].name, 'GPT-6 Luna');
|
|
158
|
+
assert.equal(models[0].reasoning, true);
|
|
159
|
+
assert.deepEqual(models[0].thinkingLevelMap, {
|
|
160
|
+
off: 'none', minimal: null, low: 'low', medium: 'medium', high: 'high', xhigh: 'xhigh', max: 'max',
|
|
161
|
+
});
|
|
162
|
+
assert.equal(models[0].compat.supportsReasoningEffort, true);
|
|
163
|
+
assert.equal(models[1].reasoning, true);
|
|
164
|
+
assert.equal(models[1].thinkingLevelMap.medium, 'medium');
|
|
165
|
+
assert.equal(models[1].thinkingLevelMap.off, null);
|
|
166
|
+
assert.deepEqual(models[2], { id: 'z-model', name: 'Zed' });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('Experiential model definitions preserve supplied metadata and detect explicit thinking aliases', () => {
|
|
170
|
+
assert.deepEqual(experientialModelDefinition({ id: 'future-thinking', name: 'Future', reasoning: false, contextWindow: 42 }), {
|
|
171
|
+
id: 'future-thinking', name: 'Future', reasoning: false, contextWindow: 42,
|
|
172
|
+
});
|
|
173
|
+
const detected = experientialModelDefinition('future-reasoning-model');
|
|
174
|
+
assert.equal(detected.reasoning, true);
|
|
175
|
+
assert.equal(detected.thinkingLevelMap.medium, 'medium');
|
|
176
|
+
const managed = experientialModelDefinition('openai/gpt-6-luna');
|
|
177
|
+
assert.equal(managed.id, 'openai/gpt-6-luna');
|
|
178
|
+
assert.equal(managed.name, 'GPT-6 Luna');
|
|
179
|
+
assert.equal(managed.reasoning, true);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('Managed model caps published by the cloud catalog clamp to the model profile', () => {
|
|
183
|
+
// The gpt-6-luna profile declares contextWindow 1_050_000 / maxTokens 128_000.
|
|
184
|
+
// A managed alias publishing tighter operating caps wins on contextWindow
|
|
185
|
+
// while the profile wins on maxTokens — both bounds stay honest.
|
|
186
|
+
const managed = experientialModelDefinition({ id: 'openai/gpt-6-luna', contextWindow: 150_000, maxTokens: 156_000 });
|
|
187
|
+
assert.equal(managed.contextWindow, 150_000);
|
|
188
|
+
assert.equal(managed.maxTokens, 128_000);
|
|
189
|
+
// Without a matching profile the published caps stand alone.
|
|
190
|
+
const alias = experientialModelDefinition({ id: 'carthagent-code', contextWindow: 150_000, maxTokens: 156_000 });
|
|
191
|
+
assert.equal(alias.contextWindow, 150_000);
|
|
192
|
+
assert.equal(alias.maxTokens, 156_000);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('Experiential model discovery authenticates with API-key or OAuth credentials without logging them', async () => {
|
|
196
|
+
const requests = [];
|
|
197
|
+
const config = experientialProviderConfig({
|
|
198
|
+
env: { EXP_GATEWAY_URL: 'https://preview.test/v1' },
|
|
199
|
+
fetchImpl: async (url, options) => {
|
|
200
|
+
requests.push({ url, options });
|
|
201
|
+
return { ok: true, json: async () => ({ data: [{ id: 'coding' }] }) };
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
let published;
|
|
205
|
+
const models = await config.refreshModels({
|
|
206
|
+
allowNetwork: true,
|
|
207
|
+
credential: { type: 'api_key', key: 'test-secret' },
|
|
208
|
+
signal: new AbortController().signal,
|
|
209
|
+
publish: async value => { published = value; value.update?.(); return true; },
|
|
210
|
+
});
|
|
211
|
+
assert.deepEqual(models.map(model => model.id), ['coding']);
|
|
212
|
+
assert.equal(requests[0].url, 'https://preview.test/v1/models');
|
|
213
|
+
assert.equal(requests[0].options.headers.Authorization, 'Bearer test-secret');
|
|
214
|
+
assert.deepEqual(published.persist.models, [{ id: 'coding', name: 'coding' }]);
|
|
215
|
+
assert.deepEqual(config.models, [{ id: 'coding', name: 'coding' }]);
|
|
216
|
+
assert.doesNotMatch(JSON.stringify(config), /test-secret/);
|
|
217
|
+
await config.refreshModels({ allowNetwork: true, credential: { type: 'oauth', access: 'managed-test-access' }, signal: new AbortController().signal });
|
|
218
|
+
assert.equal(requests[1].url, 'https://api.carthagent.xyz/v1/models');
|
|
219
|
+
assert.equal(requests[1].options.headers.Authorization, 'Bearer managed-test-access');
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('Carthagent Ship OAuth uses device authorization and rotating refresh tokens', async () => {
|
|
223
|
+
const calls = [];
|
|
224
|
+
let polls = 0;
|
|
225
|
+
const opened = [];
|
|
226
|
+
const oauth = cloudOAuth({
|
|
227
|
+
env: { CARTHAGENT_CLOUD_URL: 'https://cloud.test' }, now: () => 1_000, sleep: async () => {}, openBrowserImpl: async url => { opened.push(url); return true; },
|
|
228
|
+
fetchImpl: async (url, options) => {
|
|
229
|
+
calls.push({ url, options });
|
|
230
|
+
if (url.endsWith('/v1/device/authorizations')) return new Response(JSON.stringify({ deviceCode: 'd', userCode: 'CODE', verificationUri: 'https://verify', expiresIn: 600, interval: 1 }), { status: 201 });
|
|
231
|
+
if (url.endsWith('/v1/device/token')) {
|
|
232
|
+
polls++;
|
|
233
|
+
return polls === 1 ? new Response(JSON.stringify({ error: 'authorization_pending' }), { status: 428 })
|
|
234
|
+
: new Response(JSON.stringify({ accessToken: 'access', refreshToken: 'refresh', expiresIn: 900 }), { status: 200 });
|
|
235
|
+
}
|
|
236
|
+
return new Response(JSON.stringify({ accessToken: 'next-access', refreshToken: 'next-refresh', expiresIn: 900 }), { status: 200 });
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
const codes = [];
|
|
240
|
+
const credential = await oauth.login({ signal: new AbortController().signal, onDeviceCode: value => codes.push(value), onAuth: () => {}, onProgress: () => {} });
|
|
241
|
+
assert.deepEqual(credential, { access: 'access', refresh: 'refresh', expires: 901_000 });
|
|
242
|
+
assert.equal(codes[0].userCode, 'CODE');
|
|
243
|
+
assert.deepEqual(opened, ['https://verify']);
|
|
244
|
+
const refreshed = await oauth.refreshToken(credential, new AbortController().signal);
|
|
245
|
+
assert.deepEqual(refreshed, { access: 'next-access', refresh: 'next-refresh', expires: 901_000 });
|
|
246
|
+
assert.equal(oauth.getApiKey(refreshed), 'next-access');
|
|
247
|
+
assert.ok(calls.some(call => call.url === 'https://cloud.test/v1/token/refresh'));
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test('Experiential discovery reuses stored identities offline and fails clearly online', async () => {
|
|
251
|
+
const stored = [{ id: 'stored-model' }];
|
|
252
|
+
const offline = experientialProviderConfig({ fetchImpl: () => { throw new Error('network called'); } });
|
|
253
|
+
let restored = false;
|
|
254
|
+
assert.equal((await offline.refreshModels({
|
|
255
|
+
allowNetwork: false,
|
|
256
|
+
stored,
|
|
257
|
+
publish: async value => { restored = true; value.update?.(); return true; },
|
|
258
|
+
})).at(0).id, 'stored-model');
|
|
259
|
+
assert.equal(restored, true);
|
|
260
|
+
assert.deepEqual(offline.models, [{ id: 'stored-model', name: 'stored-model' }]);
|
|
261
|
+
|
|
262
|
+
const failing = experientialProviderConfig({ fetchImpl: async () => ({ ok: false, status: 401, text: async () => 'unauthorized' }) });
|
|
263
|
+
await assert.rejects(
|
|
264
|
+
failing.refreshModels({ allowNetwork: true, credential: { type: 'api_key', key: 'xpl_bad' }, signal: new AbortController().signal }),
|
|
265
|
+
/failed \(401\): unauthorized/
|
|
266
|
+
);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test('registerExperientialProvider registers one shared provider definition', () => {
|
|
270
|
+
const calls = [];
|
|
271
|
+
const runtime = { registerProvider: (id, config) => calls.push({ id, config }) };
|
|
272
|
+
assert.equal(registerExperientialProvider(runtime), runtime);
|
|
273
|
+
assert.equal(calls.length, 1);
|
|
274
|
+
assert.equal(calls[0].id, 'experiential-labs');
|
|
275
|
+
assert.equal(calls[0].config.name, 'Carthagent Ship');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('ModelRuntime resolves EXPLABS_API_KEY without copying it into provider config', async () => {
|
|
279
|
+
const previous = process.env.EXPLABS_API_KEY;
|
|
280
|
+
const previousCarthagentDir = process.env.CARTHAGENT_CODING_AGENT_DIR;
|
|
281
|
+
const previousPiDir = process.env.PI_CODING_AGENT_DIR;
|
|
282
|
+
try {
|
|
283
|
+
process.env.EXPLABS_API_KEY = 'environment-only-test-key';
|
|
284
|
+
process.env.CARTHAGENT_CODING_AGENT_DIR = '/tmp/carthagent-experiential-env-test';
|
|
285
|
+
process.env.PI_CODING_AGENT_DIR = process.env.CARTHAGENT_CODING_AGENT_DIR;
|
|
286
|
+
const { ModelRuntime } = await import('../vendor/agent/index.js');
|
|
287
|
+
const runtime = await ModelRuntime.create({ allowModelNetwork: false });
|
|
288
|
+
registerExperientialProvider(runtime, { env: process.env });
|
|
289
|
+
assert.deepEqual(runtime.getProviderAuthStatus('experiential-labs'), {
|
|
290
|
+
configured: true,
|
|
291
|
+
source: 'environment',
|
|
292
|
+
label: 'EXPLABS_API_KEY',
|
|
293
|
+
});
|
|
294
|
+
assert.equal(runtime.getRegisteredProviderConfig('experiential-labs').apiKey, '$EXPLABS_API_KEY');
|
|
295
|
+
} finally {
|
|
296
|
+
if (previous === undefined) delete process.env.EXPLABS_API_KEY; else process.env.EXPLABS_API_KEY = previous;
|
|
297
|
+
if (previousCarthagentDir === undefined) delete process.env.CARTHAGENT_CODING_AGENT_DIR; else process.env.CARTHAGENT_CODING_AGENT_DIR = previousCarthagentDir;
|
|
298
|
+
if (previousPiDir === undefined) delete process.env.PI_CODING_AGENT_DIR; else process.env.PI_CODING_AGENT_DIR = previousPiDir;
|
|
299
|
+
}
|
|
300
|
+
});
|