visionclaw 0.1.206-beta.14 → 0.1.206-beta.16
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/dist/agent/applied-credential-signature.d.ts +53 -0
- package/dist/agent/applied-credential-signature.d.ts.map +1 -0
- package/dist/agent/applied-credential-signature.js +137 -0
- package/dist/agent/applied-credential-signature.js.map +1 -0
- package/dist/agent/engine-switch-handler.d.ts +4 -11
- package/dist/agent/engine-switch-handler.d.ts.map +1 -1
- package/dist/agent/engine-switch-handler.js +39 -32
- package/dist/agent/engine-switch-handler.js.map +1 -1
- package/dist/agent/engine-switch-target.d.ts +33 -0
- package/dist/agent/engine-switch-target.d.ts.map +1 -0
- package/dist/agent/engine-switch-target.js +72 -0
- package/dist/agent/engine-switch-target.js.map +1 -0
- package/dist/agent/engines/client-factory.d.ts +63 -0
- package/dist/agent/engines/client-factory.d.ts.map +1 -0
- package/dist/agent/engines/client-factory.js +382 -0
- package/dist/agent/engines/client-factory.js.map +1 -0
- package/dist/agent/engines/engine-factory.d.ts +1 -0
- package/dist/agent/engines/engine-factory.d.ts.map +1 -1
- package/dist/agent/engines/engine-factory.js +3 -1
- package/dist/agent/engines/engine-factory.js.map +1 -1
- package/dist/agent/engines/engine.d.ts +8 -0
- package/dist/agent/engines/engine.d.ts.map +1 -0
- package/dist/agent/engines/engine.js +15 -0
- package/dist/agent/engines/engine.js.map +1 -0
- package/dist/agent/engines/openai/file-session.d.ts +19 -0
- package/dist/agent/engines/openai/file-session.d.ts.map +1 -0
- package/dist/agent/engines/openai/file-session.js +78 -0
- package/dist/agent/engines/openai/file-session.js.map +1 -0
- package/dist/agent/engines/openai/file-tools.d.ts +35 -0
- package/dist/agent/engines/openai/file-tools.d.ts.map +1 -0
- package/dist/agent/engines/openai/file-tools.js +194 -0
- package/dist/agent/engines/openai/file-tools.js.map +1 -0
- package/dist/agent/engines/openai/session.d.ts +55 -0
- package/dist/agent/engines/openai/session.d.ts.map +1 -0
- package/dist/agent/engines/openai/session.js +447 -0
- package/dist/agent/engines/openai/session.js.map +1 -0
- package/dist/agent/engines/openai/tools.d.ts +15 -0
- package/dist/agent/engines/openai/tools.d.ts.map +1 -0
- package/dist/agent/engines/openai/tools.js +221 -0
- package/dist/agent/engines/openai/tools.js.map +1 -0
- package/dist/agent/engines/pi/session.d.ts +49 -0
- package/dist/agent/engines/pi/session.d.ts.map +1 -0
- package/dist/agent/engines/pi/session.js +309 -0
- package/dist/agent/engines/pi/session.js.map +1 -0
- package/dist/agent/engines/pi-coding/session.d.ts.map +1 -1
- package/dist/agent/engines/pi-coding/session.js +12 -0
- package/dist/agent/engines/pi-coding/session.js.map +1 -1
- package/dist/agent/engines/pi-coding/tool-schema-sanitizer.d.ts +24 -0
- package/dist/agent/engines/pi-coding/tool-schema-sanitizer.d.ts.map +1 -0
- package/dist/agent/engines/pi-coding/tool-schema-sanitizer.js +130 -0
- package/dist/agent/engines/pi-coding/tool-schema-sanitizer.js.map +1 -0
- package/dist/agent/llm-gateway-models.d.ts +31 -0
- package/dist/agent/llm-gateway-models.d.ts.map +1 -0
- package/dist/agent/llm-gateway-models.js +98 -0
- package/dist/agent/llm-gateway-models.js.map +1 -0
- package/dist/agent/memory-preload.d.ts +55 -0
- package/dist/agent/memory-preload.d.ts.map +1 -0
- package/dist/agent/memory-preload.js +166 -0
- package/dist/agent/memory-preload.js.map +1 -0
- package/dist/agent/model-provider.d.ts +4 -0
- package/dist/agent/model-provider.d.ts.map +1 -1
- package/dist/agent/model-provider.js +33 -4
- package/dist/agent/model-provider.js.map +1 -1
- package/dist/agent/providers/claude/cli-resolver.d.ts +16 -0
- package/dist/agent/providers/claude/cli-resolver.d.ts.map +1 -0
- package/dist/agent/providers/claude/cli-resolver.js +83 -0
- package/dist/agent/providers/claude/cli-resolver.js.map +1 -0
- package/dist/agent/providers/claude/session-browser-policy.d.ts +9 -0
- package/dist/agent/providers/claude/session-browser-policy.d.ts.map +1 -0
- package/dist/agent/providers/claude/session-browser-policy.js +49 -0
- package/dist/agent/providers/claude/session-browser-policy.js.map +1 -0
- package/dist/agent/providers/claude/session.d.ts +304 -0
- package/dist/agent/providers/claude/session.d.ts.map +1 -0
- package/dist/agent/providers/claude/session.js +1236 -0
- package/dist/agent/providers/claude/session.js.map +1 -0
- package/dist/agent/providers/client-factory.d.ts +60 -0
- package/dist/agent/providers/client-factory.d.ts.map +1 -0
- package/dist/agent/providers/client-factory.js +400 -0
- package/dist/agent/providers/client-factory.js.map +1 -0
- package/dist/agent/providers/openai/file-session.d.ts +19 -0
- package/dist/agent/providers/openai/file-session.d.ts.map +1 -0
- package/dist/agent/providers/openai/file-session.js +78 -0
- package/dist/agent/providers/openai/file-session.js.map +1 -0
- package/dist/agent/providers/openai/session.d.ts +55 -0
- package/dist/agent/providers/openai/session.d.ts.map +1 -0
- package/dist/agent/providers/openai/session.js +447 -0
- package/dist/agent/providers/openai/session.js.map +1 -0
- package/dist/agent/providers/openai/tools.d.ts +15 -0
- package/dist/agent/providers/openai/tools.d.ts.map +1 -0
- package/dist/agent/providers/openai/tools.js +229 -0
- package/dist/agent/providers/openai/tools.js.map +1 -0
- package/dist/agent/providers/session-types.d.ts +153 -0
- package/dist/agent/providers/session-types.d.ts.map +1 -0
- package/dist/agent/providers/session-types.js +2 -0
- package/dist/agent/providers/session-types.js.map +1 -0
- package/dist/agent/providers/system-prompt-log.d.ts +9 -0
- package/dist/agent/providers/system-prompt-log.d.ts.map +1 -0
- package/dist/agent/providers/system-prompt-log.js +46 -0
- package/dist/agent/providers/system-prompt-log.js.map +1 -0
- package/dist/agent/transcript-backfill.d.ts +54 -0
- package/dist/agent/transcript-backfill.d.ts.map +1 -0
- package/dist/agent/transcript-backfill.js +604 -0
- package/dist/agent/transcript-backfill.js.map +1 -0
- package/dist/agent/transcript-indexer.d.ts +200 -0
- package/dist/agent/transcript-indexer.d.ts.map +1 -0
- package/dist/agent/transcript-indexer.js +775 -0
- package/dist/agent/transcript-indexer.js.map +1 -0
- package/dist/agent/transcript-memory-migrations.d.ts +25 -0
- package/dist/agent/transcript-memory-migrations.d.ts.map +1 -0
- package/dist/agent/transcript-memory-migrations.js +87 -0
- package/dist/agent/transcript-memory-migrations.js.map +1 -0
- package/dist/agent/tunnel-credential-handler.d.ts +90 -0
- package/dist/agent/tunnel-credential-handler.d.ts.map +1 -0
- package/dist/agent/tunnel-credential-handler.js +162 -0
- package/dist/agent/tunnel-credential-handler.js.map +1 -0
- package/dist/agent/usage-backfill-handler.d.ts +18 -0
- package/dist/agent/usage-backfill-handler.d.ts.map +1 -0
- package/dist/agent/usage-backfill-handler.js +69 -0
- package/dist/agent/usage-backfill-handler.js.map +1 -0
- package/dist/agent/usage-gate.d.ts +25 -0
- package/dist/agent/usage-gate.d.ts.map +1 -0
- package/dist/agent/usage-gate.js +83 -0
- package/dist/agent/usage-gate.js.map +1 -0
- package/dist/agent/usage-handler.d.ts +7 -0
- package/dist/agent/usage-handler.d.ts.map +1 -0
- package/dist/agent/usage-handler.js +28 -0
- package/dist/agent/usage-handler.js.map +1 -0
- package/dist/agent/usage-report-builder.d.ts +26 -0
- package/dist/agent/usage-report-builder.d.ts.map +1 -0
- package/dist/agent/usage-report-builder.js +80 -0
- package/dist/agent/usage-report-builder.js.map +1 -0
- package/dist/agent/usage-report-queue.d.ts +26 -0
- package/dist/agent/usage-report-queue.d.ts.map +1 -0
- package/dist/agent/usage-report-queue.js +199 -0
- package/dist/agent/usage-report-queue.js.map +1 -0
- package/dist/agent/usage-report-types.d.ts +41 -0
- package/dist/agent/usage-report-types.d.ts.map +1 -0
- package/dist/agent/usage-report-types.js +2 -0
- package/dist/agent/usage-report-types.js.map +1 -0
- package/dist/agent/usage-reporter.d.ts +31 -0
- package/dist/agent/usage-reporter.d.ts.map +1 -0
- package/dist/agent/usage-reporter.js +102 -0
- package/dist/agent/usage-reporter.js.map +1 -0
- package/dist/agent/wake-cycle-runner.d.ts +1 -1
- package/dist/agent/wake-cycle-runner.d.ts.map +1 -1
- package/dist/agent/wake-cycle-runner.js +18 -4
- package/dist/agent/wake-cycle-runner.js.map +1 -1
- package/dist/agent/wake-cycle-tool-tracker.d.ts +39 -0
- package/dist/agent/wake-cycle-tool-tracker.d.ts.map +1 -0
- package/dist/agent/wake-cycle-tool-tracker.js +72 -0
- package/dist/agent/wake-cycle-tool-tracker.js.map +1 -0
- package/dist/billing/payg-handler.d.ts +29 -0
- package/dist/billing/payg-handler.d.ts.map +1 -0
- package/dist/billing/payg-handler.js +92 -0
- package/dist/billing/payg-handler.js.map +1 -0
- package/dist/billing/payment-handler.d.ts +24 -0
- package/dist/billing/payment-handler.d.ts.map +1 -0
- package/dist/billing/payment-handler.js +101 -0
- package/dist/billing/payment-handler.js.map +1 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/SKILL.md +412 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_input.sh +132 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_launch.sh +166 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_screenshot.sh +87 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_security_kbd.py +174 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_setup.sh +274 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_swipe.sh +111 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_tap.sh +87 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_ui_parse.py +176 -0
- package/dist/builtin-skills/catalog/phone-adb-automation/phone_wake_unlock.sh +67 -0
- package/dist/builtin-skills/transcribe-audio/SKILL.md +122 -0
- package/dist/channels/telegram.d.ts.map +1 -1
- package/dist/channels/telegram.js +29 -15
- package/dist/channels/telegram.js.map +1 -1
- package/dist/channels/web.d.ts +40 -0
- package/dist/channels/web.d.ts.map +1 -0
- package/dist/channels/web.js +137 -0
- package/dist/channels/web.js.map +1 -0
- package/dist/config/models.d.ts +23 -0
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +48 -0
- package/dist/config/models.js.map +1 -1
- package/dist/config/types.d.ts +8 -16
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +12 -10
- package/dist/config/types.js.map +1 -1
- package/dist/data-processing/convert-demo-cli.d.ts +7 -0
- package/dist/data-processing/convert-demo-cli.d.ts.map +1 -0
- package/dist/data-processing/convert-demo-cli.js +30 -0
- package/dist/data-processing/convert-demo-cli.js.map +1 -0
- package/dist/data-processing/convert-demo.d.ts +26 -0
- package/dist/data-processing/convert-demo.d.ts.map +1 -0
- package/dist/data-processing/convert-demo.js +233 -0
- package/dist/data-processing/convert-demo.js.map +1 -0
- package/dist/obs/auth.d.ts +45 -0
- package/dist/obs/auth.d.ts.map +1 -0
- package/dist/obs/auth.js +181 -0
- package/dist/obs/auth.js.map +1 -0
- package/dist/obs/mini-app/status.d.ts.map +1 -1
- package/dist/obs/mini-app/status.js +7 -0
- package/dist/obs/mini-app/status.js.map +1 -1
- package/dist/obs/mini-app/tasks.d.ts +2 -0
- package/dist/obs/mini-app/tasks.d.ts.map +1 -0
- package/dist/obs/mini-app/tasks.js +506 -0
- package/dist/obs/mini-app/tasks.js.map +1 -0
- package/dist/obs/rdp/icons/icons/app_windows.svg +4 -0
- package/dist/obs/rdp/icons/icons/clip_get.svg +4 -0
- package/dist/obs/rdp/icons/icons/clip_send.svg +4 -0
- package/dist/obs/rdp/icons/icons/clip_shared.svg +4 -0
- package/dist/obs/rdp/icons/icons/clipboard.svg +4 -0
- package/dist/obs/rdp/icons/icons/clipboard_shared.svg +4 -0
- package/dist/obs/rdp/icons/icons/control.svg +4 -0
- package/dist/obs/rdp/icons/icons/desktop.svg +4 -0
- package/dist/obs/rdp/icons/icons/display.svg +4 -0
- package/dist/obs/rdp/icons/icons/launchpad.svg +4 -0
- package/dist/obs/rdp/icons/icons/mission_control.svg +4 -0
- package/dist/obs/rdp/icons/icons/screenshot.svg +4 -0
- package/dist/obs/rdp/icons/icons/zoom_actual.svg +4 -0
- package/dist/obs/rdp/icons/icons/zoom_fit.svg +4 -0
- package/dist/obs/rdp/icons/icons/zoom_in.svg +4 -0
- package/dist/obs/rdp/icons/icons/zoom_out.svg +4 -0
- package/dist/obs/tunnel-telemetry.d.ts +46 -0
- package/dist/obs/tunnel-telemetry.d.ts.map +1 -0
- package/dist/obs/tunnel-telemetry.js +70 -0
- package/dist/obs/tunnel-telemetry.js.map +1 -0
- package/dist/onboarding/cloudflared-cert.d.ts +15 -0
- package/dist/onboarding/cloudflared-cert.d.ts.map +1 -0
- package/dist/onboarding/cloudflared-cert.js +57 -0
- package/dist/onboarding/cloudflared-cert.js.map +1 -0
- package/dist/phonecall-credentials.d.ts +21 -0
- package/dist/phonecall-credentials.d.ts.map +1 -0
- package/dist/phonecall-credentials.js +34 -0
- package/dist/phonecall-credentials.js.map +1 -0
- package/dist/realtime/agent-bridge.d.ts +7 -0
- package/dist/realtime/agent-bridge.d.ts.map +1 -0
- package/dist/realtime/agent-bridge.js +31 -0
- package/dist/realtime/agent-bridge.js.map +1 -0
- package/dist/realtime/assets/index.html +1058 -0
- package/dist/realtime/assets/samples/alloy.mp3 +0 -0
- package/dist/realtime/assets/samples/ash.mp3 +0 -0
- package/dist/realtime/assets/samples/ballad.mp3 +0 -0
- package/dist/realtime/assets/samples/cedar.mp3 +0 -0
- package/dist/realtime/assets/samples/coral.mp3 +0 -0
- package/dist/realtime/assets/samples/echo.mp3 +0 -0
- package/dist/realtime/assets/samples/marin.mp3 +0 -0
- package/dist/realtime/assets/samples/sage.mp3 +0 -0
- package/dist/realtime/assets/samples/shimmer.mp3 +0 -0
- package/dist/realtime/assets/samples/verse.mp3 +0 -0
- package/dist/realtime/context.d.ts +14 -0
- package/dist/realtime/context.d.ts.map +1 -0
- package/dist/realtime/context.js +153 -0
- package/dist/realtime/context.js.map +1 -0
- package/dist/realtime/http-helpers.d.ts +5 -0
- package/dist/realtime/http-helpers.d.ts.map +1 -0
- package/dist/realtime/http-helpers.js +29 -0
- package/dist/realtime/http-helpers.js.map +1 -0
- package/dist/realtime/index.d.ts +62 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +94 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/server.d.ts +6 -0
- package/dist/realtime/server.d.ts.map +1 -0
- package/dist/realtime/server.js +479 -0
- package/dist/realtime/server.js.map +1 -0
- package/dist/realtime/telegram-auth.d.ts +2 -0
- package/dist/realtime/telegram-auth.d.ts.map +1 -0
- package/dist/realtime/telegram-auth.js +24 -0
- package/dist/realtime/telegram-auth.js.map +1 -0
- package/dist/realtime/tools.d.ts +829 -0
- package/dist/realtime/tools.d.ts.map +1 -0
- package/dist/realtime/tools.js +611 -0
- package/dist/realtime/tools.js.map +1 -0
- package/dist/realtime/types.d.ts +62 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/types.js +3 -0
- package/dist/realtime/types.js.map +1 -0
- package/dist/realtime/voice-summarizer.d.ts +4 -0
- package/dist/realtime/voice-summarizer.d.ts.map +1 -0
- package/dist/realtime/voice-summarizer.js +123 -0
- package/dist/realtime/voice-summarizer.js.map +1 -0
- package/dist/realtime/websocket.d.ts +7 -0
- package/dist/realtime/websocket.d.ts.map +1 -0
- package/dist/realtime/websocket.js +65 -0
- package/dist/realtime/websocket.js.map +1 -0
- package/dist/service/gbox-tun.d.ts +14 -0
- package/dist/service/gbox-tun.d.ts.map +1 -0
- package/dist/service/gbox-tun.js +315 -0
- package/dist/service/gbox-tun.js.map +1 -0
- package/dist/skills/installed.d.ts +11 -0
- package/dist/skills/installed.d.ts.map +1 -0
- package/dist/skills/installed.js +35 -0
- package/dist/skills/installed.js.map +1 -0
- package/dist/threads/worker-entry.js.map +1 -1
- package/dist/tools/card.d.ts +11 -0
- package/dist/tools/card.d.ts.map +1 -0
- package/dist/tools/card.js +87 -0
- package/dist/tools/card.js.map +1 -0
- package/dist/tools/coordinate-resolver.d.ts +30 -0
- package/dist/tools/coordinate-resolver.d.ts.map +1 -0
- package/dist/tools/coordinate-resolver.js +104 -0
- package/dist/tools/coordinate-resolver.js.map +1 -0
- package/dist/tools/notify.d.ts.map +1 -1
- package/dist/tools/notify.js +1 -25
- package/dist/tools/notify.js.map +1 -1
- package/dist/tools/stock-data.d.ts +70 -0
- package/dist/tools/stock-data.d.ts.map +1 -0
- package/dist/tools/stock-data.js +596 -0
- package/dist/tools/stock-data.js.map +1 -0
- package/dist/tools/webapp.d.ts +30 -0
- package/dist/tools/webapp.d.ts.map +1 -0
- package/dist/tools/webapp.js +114 -0
- package/dist/tools/webapp.js.map +1 -0
- package/dist/utils/email.d.ts +7 -0
- package/dist/utils/email.d.ts.map +1 -0
- package/dist/utils/email.js +30 -0
- package/dist/utils/email.js.map +1 -0
- package/dist/utils/wechat-monitor.d.ts +21 -0
- package/dist/utils/wechat-monitor.d.ts.map +1 -0
- package/dist/utils/wechat-monitor.js +88 -0
- package/dist/utils/wechat-monitor.js.map +1 -0
- package/dist/webapp/index.d.ts +28 -0
- package/dist/webapp/index.d.ts.map +1 -0
- package/dist/webapp/index.js +75 -0
- package/dist/webapp/index.js.map +1 -0
- package/dist/webapp/server.d.ts +32 -0
- package/dist/webapp/server.d.ts.map +1 -0
- package/dist/webapp/server.js +375 -0
- package/dist/webapp/server.js.map +1 -0
- package/dist/webapp/storage.d.ts +64 -0
- package/dist/webapp/storage.d.ts.map +1 -0
- package/dist/webapp/storage.js +103 -0
- package/dist/webapp/storage.js.map +1 -0
- package/dist/webapp/ui.d.ts +2 -0
- package/dist/webapp/ui.d.ts.map +1 -0
- package/dist/webapp/ui.js +319 -0
- package/dist/webapp/ui.js.map +1 -0
- package/dist-agent/assets/index.html +1058 -0
- package/dist-agent/assets/samples/alloy.mp3 +0 -0
- package/dist-agent/assets/samples/ash.mp3 +0 -0
- package/dist-agent/assets/samples/ballad.mp3 +0 -0
- package/dist-agent/assets/samples/cedar.mp3 +0 -0
- package/dist-agent/assets/samples/coral.mp3 +0 -0
- package/dist-agent/assets/samples/echo.mp3 +0 -0
- package/dist-agent/assets/samples/marin.mp3 +0 -0
- package/dist-agent/assets/samples/sage.mp3 +0 -0
- package/dist-agent/assets/samples/shimmer.mp3 +0 -0
- package/dist-agent/assets/samples/verse.mp3 +0 -0
- package/dist-agent/bundle.cjs +14049 -17372
- package/dist-agent/realtime/assets/index.html +1058 -0
- package/dist-agent/realtime/assets/samples/alloy.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/ash.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/ballad.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/cedar.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/coral.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/echo.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/marin.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/sage.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/shimmer.mp3 +0 -0
- package/dist-agent/realtime/assets/samples/verse.mp3 +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applied-credential signature manifest.
|
|
3
|
+
*
|
|
4
|
+
* Persisted alongside materialised tunnel credentials at
|
|
5
|
+
* `<profileTunnelDir>/.applied-signature.json`. Records the signature
|
|
6
|
+
* the server handed us with the last bundle we successfully applied.
|
|
7
|
+
*
|
|
8
|
+
* The manifest is the *only* piece of state the agent has to remember
|
|
9
|
+
* across process restarts about credential bundles — everything else
|
|
10
|
+
* (creds JSON, config.yml) is reconstructable from a fresh server
|
|
11
|
+
* delivery. The signature is opaque to us; we just echo it back on the
|
|
12
|
+
* next heartbeat so the server can decide whether to re-ship the body.
|
|
13
|
+
*
|
|
14
|
+
* Self-healing properties (intentional):
|
|
15
|
+
* - Manifest missing on disk → no signature sent → server sends
|
|
16
|
+
* bundle → we re-apply and rewrite the manifest. Recovers any
|
|
17
|
+
* install where the manifest was deleted but credentials weren't,
|
|
18
|
+
* or vice versa.
|
|
19
|
+
* - Manifest present but probe says no live tunnel files → we treat
|
|
20
|
+
* the manifest as unusable (return null from `loadIfValid`), the
|
|
21
|
+
* next heartbeat goes signature-free, the server re-ships the
|
|
22
|
+
* bundle, and we land back in a coherent state.
|
|
23
|
+
* - Process restart with everything intact → manifest signature is
|
|
24
|
+
* sent on the startup heartbeat, server replies with no
|
|
25
|
+
* `credentialBundle`, no disk writes, no tunnel restart.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Read the persisted signature, if any. Returns `null` when the file
|
|
29
|
+
* does not exist, fails to parse, has the wrong shape, or refers to a
|
|
30
|
+
* tunnel state that no longer matches what's on disk.
|
|
31
|
+
*
|
|
32
|
+
* The on-disk-coherence check (`probeLocalTunnelCredential()`) is what
|
|
33
|
+
* gives us self-healing: a stranded manifest from a wiped tunnel dir
|
|
34
|
+
* gets ignored, forcing a fresh bundle on the next heartbeat.
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadAppliedSignatureIfValid(): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Persist the signature for the most recently applied bundle. Best-
|
|
39
|
+
* effort: a write failure is logged but does not throw, since the
|
|
40
|
+
* worst case is just an extra full-bundle delivery on the next
|
|
41
|
+
* heartbeat.
|
|
42
|
+
*
|
|
43
|
+
* The file is written with 0o600 to match the credentials sitting next
|
|
44
|
+
* to it; the directory itself is already 0o700 from
|
|
45
|
+
* `runtime-credentials.ts`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function writeAppliedSignature(signature: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Forget the persisted signature. Used by tests; production code never
|
|
50
|
+
* needs to delete it explicitly because writes overwrite in place.
|
|
51
|
+
*/
|
|
52
|
+
export declare function __clearAppliedSignatureForTests(): void;
|
|
53
|
+
//# sourceMappingURL=applied-credential-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applied-credential-signature.d.ts","sourceRoot":"","sources":["../../src/agent/applied-credential-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAwBH;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,GAAG,IAAI,CA2C3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAgC7D;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAMtD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applied-credential signature manifest.
|
|
3
|
+
*
|
|
4
|
+
* Persisted alongside materialised tunnel credentials at
|
|
5
|
+
* `<profileTunnelDir>/.applied-signature.json`. Records the signature
|
|
6
|
+
* the server handed us with the last bundle we successfully applied.
|
|
7
|
+
*
|
|
8
|
+
* The manifest is the *only* piece of state the agent has to remember
|
|
9
|
+
* across process restarts about credential bundles — everything else
|
|
10
|
+
* (creds JSON, config.yml) is reconstructable from a fresh server
|
|
11
|
+
* delivery. The signature is opaque to us; we just echo it back on the
|
|
12
|
+
* next heartbeat so the server can decide whether to re-ship the body.
|
|
13
|
+
*
|
|
14
|
+
* Self-healing properties (intentional):
|
|
15
|
+
* - Manifest missing on disk → no signature sent → server sends
|
|
16
|
+
* bundle → we re-apply and rewrite the manifest. Recovers any
|
|
17
|
+
* install where the manifest was deleted but credentials weren't,
|
|
18
|
+
* or vice versa.
|
|
19
|
+
* - Manifest present but probe says no live tunnel files → we treat
|
|
20
|
+
* the manifest as unusable (return null from `loadIfValid`), the
|
|
21
|
+
* next heartbeat goes signature-free, the server re-ships the
|
|
22
|
+
* bundle, and we land back in a coherent state.
|
|
23
|
+
* - Process restart with everything intact → manifest signature is
|
|
24
|
+
* sent on the startup heartbeat, server replies with no
|
|
25
|
+
* `credentialBundle`, no disk writes, no tunnel restart.
|
|
26
|
+
*/
|
|
27
|
+
import fs from "node:fs";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
import { getProfileTunnelDir } from "../config/index.js";
|
|
30
|
+
import { probeLocalTunnelCredential } from "./runtime-credentials.js";
|
|
31
|
+
import { logger } from "../logger.js";
|
|
32
|
+
const MANIFEST_FILENAME = ".applied-signature.json";
|
|
33
|
+
const MANIFEST_VERSION = 1;
|
|
34
|
+
function getManifestPath() {
|
|
35
|
+
return path.join(getProfileTunnelDir(), MANIFEST_FILENAME);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read the persisted signature, if any. Returns `null` when the file
|
|
39
|
+
* does not exist, fails to parse, has the wrong shape, or refers to a
|
|
40
|
+
* tunnel state that no longer matches what's on disk.
|
|
41
|
+
*
|
|
42
|
+
* The on-disk-coherence check (`probeLocalTunnelCredential()`) is what
|
|
43
|
+
* gives us self-healing: a stranded manifest from a wiped tunnel dir
|
|
44
|
+
* gets ignored, forcing a fresh bundle on the next heartbeat.
|
|
45
|
+
*/
|
|
46
|
+
export function loadAppliedSignatureIfValid() {
|
|
47
|
+
const manifestPath = getManifestPath();
|
|
48
|
+
if (!fs.existsSync(manifestPath))
|
|
49
|
+
return null;
|
|
50
|
+
let raw;
|
|
51
|
+
try {
|
|
52
|
+
raw = fs.readFileSync(manifestPath, "utf-8");
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
logger.warn(`Applied-signature manifest unreadable: ${err instanceof Error ? err.message : String(err)}`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = JSON.parse(raw);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
logger.warn(`Applied-signature manifest malformed; ignoring`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (!parsed ||
|
|
67
|
+
typeof parsed !== "object" ||
|
|
68
|
+
!("signature" in parsed) ||
|
|
69
|
+
typeof parsed.signature !== "string" ||
|
|
70
|
+
parsed.signature.trim() === "") {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const signature = parsed.signature.trim();
|
|
74
|
+
// Coherence: a manifest is only meaningful when the credentials it
|
|
75
|
+
// refers to actually still exist on disk. If the tunnel files were
|
|
76
|
+
// wiped (e.g. operator deleted `~/.visionclaw/profiles/default/tunnel`)
|
|
77
|
+
// the stored signature lies about our state, so pretend we have none
|
|
78
|
+
// and let the server reissue the bundle.
|
|
79
|
+
if (probeLocalTunnelCredential() === null) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return signature;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Persist the signature for the most recently applied bundle. Best-
|
|
86
|
+
* effort: a write failure is logged but does not throw, since the
|
|
87
|
+
* worst case is just an extra full-bundle delivery on the next
|
|
88
|
+
* heartbeat.
|
|
89
|
+
*
|
|
90
|
+
* The file is written with 0o600 to match the credentials sitting next
|
|
91
|
+
* to it; the directory itself is already 0o700 from
|
|
92
|
+
* `runtime-credentials.ts`.
|
|
93
|
+
*/
|
|
94
|
+
export function writeAppliedSignature(signature) {
|
|
95
|
+
if (typeof signature !== "string" || signature.trim() === "")
|
|
96
|
+
return;
|
|
97
|
+
const manifestPath = getManifestPath();
|
|
98
|
+
const dir = path.dirname(manifestPath);
|
|
99
|
+
try {
|
|
100
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// best-effort; the credential apply path will have created it
|
|
104
|
+
}
|
|
105
|
+
const payload = {
|
|
106
|
+
version: MANIFEST_VERSION,
|
|
107
|
+
signature: signature.trim(),
|
|
108
|
+
appliedAt: new Date().toISOString(),
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
fs.writeFileSync(manifestPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
112
|
+
if (process.platform !== "win32") {
|
|
113
|
+
try {
|
|
114
|
+
fs.chmodSync(manifestPath, 0o600);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// best-effort; directory perms still protect
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
logger.warn(`Failed to persist applied-signature manifest: ${err instanceof Error ? err.message : String(err)}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Forget the persisted signature. Used by tests; production code never
|
|
127
|
+
* needs to delete it explicitly because writes overwrite in place.
|
|
128
|
+
*/
|
|
129
|
+
export function __clearAppliedSignatureForTests() {
|
|
130
|
+
try {
|
|
131
|
+
fs.rmSync(getManifestPath(), { force: true });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// ignore
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=applied-credential-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applied-credential-signature.js","sourceRoot":"","sources":["../../src/agent/applied-credential-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAW3B,SAAS,eAAe;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAE9C,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,EAAE,C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C,YAAY,CAAC,CAAC;IAEvC,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,8DAA8D;IAChE,CAAC;IAED,MAAM,OAAO,GAAsB;QACjC,OAAO,EAAE,gBAAgB;QACzB,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE;QAC3B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IAEF,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1E,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,6CAA6C;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CACT,iDAAiD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACpG,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B;IAC7C,IAAI,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { CommandHandler } from "./command-dispatcher.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { VisionClawConfig } from "../config/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a CommandHandler for the "switch_engine" remote command.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (llm-gateway), persists the config, and schedules a restart so the new
|
|
10
|
-
* engine takes effect.
|
|
11
|
-
*
|
|
12
|
-
* Idempotent by design: after the restart the server re-delivers the
|
|
13
|
-
* command (the pre-restart ack usually doesn't make it out in time), at
|
|
14
|
-
* which point the engine family already matches and the handler acks
|
|
15
|
-
* `completed` as a no-op — closing the command loop.
|
|
6
|
+
* Payload `{ engine: "gpt" | "claude" | "<modelId>" }`:
|
|
7
|
+
* - gpt/claude → default family model + first compatible provider
|
|
8
|
+
* - other → pinned model id (Pi + llm-gateway), validated via `/v1/models`
|
|
16
9
|
*/
|
|
17
10
|
export declare function createEngineSwitchHandler(config: VisionClawConfig): CommandHandler;
|
|
18
11
|
//# sourceMappingURL=engine-switch-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-switch-handler.d.ts","sourceRoot":"","sources":["../../src/agent/engine-switch-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"engine-switch-handler.d.ts","sourceRoot":"","sources":["../../src/agent/engine-switch-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAkB3D;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc,CA6ElF"}
|
|
@@ -1,58 +1,66 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getSupportedProvidersForModel } from "../config/types.js";
|
|
3
|
-
import { DEFAULT_CLAUDE_MODEL, GPT_HEAVY_MODEL } from "../config/models.js";
|
|
4
|
-
import { isClaudeModel } from "./engines/engine-factory.js";
|
|
5
2
|
import { saveConfig, writePendingRestart } from "../config/index.js";
|
|
6
3
|
import { logger } from "../logger.js";
|
|
4
|
+
import { describeEngineTarget, isAlreadyOnEngineTarget, resolveEngineSwitchTarget, validateEngineSwitchTarget, } from "./engine-switch-target.js";
|
|
5
|
+
import { LlmGatewayModelsError } from "./llm-gateway-models.js";
|
|
6
|
+
/** Family aliases or a concrete pinned model id (e.g. kimi-k3). */
|
|
7
7
|
const EngineSwitchPayloadSchema = z.object({
|
|
8
|
-
engine: z.
|
|
8
|
+
engine: z.string().trim().min(1),
|
|
9
9
|
});
|
|
10
10
|
const RESTART_DELAY = 5_000;
|
|
11
11
|
/**
|
|
12
12
|
* Creates a CommandHandler for the "switch_engine" remote command.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* (llm-gateway), persists the config, and schedules a restart so the new
|
|
18
|
-
* engine takes effect.
|
|
19
|
-
*
|
|
20
|
-
* Idempotent by design: after the restart the server re-delivers the
|
|
21
|
-
* command (the pre-restart ack usually doesn't make it out in time), at
|
|
22
|
-
* which point the engine family already matches and the handler acks
|
|
23
|
-
* `completed` as a no-op — closing the command loop.
|
|
14
|
+
* Payload `{ engine: "gpt" | "claude" | "<modelId>" }`:
|
|
15
|
+
* - gpt/claude → default family model + first compatible provider
|
|
16
|
+
* - other → pinned model id (Pi + llm-gateway), validated via `/v1/models`
|
|
24
17
|
*/
|
|
25
18
|
export function createEngineSwitchHandler(config) {
|
|
26
19
|
return async (commandId, payload) => {
|
|
27
20
|
const parsed = EngineSwitchPayloadSchema.safeParse(payload);
|
|
28
21
|
if (!parsed.success) {
|
|
29
|
-
const errMsg = `Invalid switch_engine payload: expected { engine: "gpt" | "claude" }`;
|
|
22
|
+
const errMsg = `Invalid switch_engine payload: expected { engine: "gpt" | "claude" | "<modelId>" }`;
|
|
23
|
+
logger.err(`[engine-switch-handler] ${errMsg} (id=${commandId})`);
|
|
24
|
+
return {
|
|
25
|
+
status: "failed",
|
|
26
|
+
result: JSON.stringify({ error: errMsg }),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const target = resolveEngineSwitchTarget(parsed.data.engine);
|
|
30
|
+
if (!target) {
|
|
31
|
+
const errMsg = `Invalid switch_engine engine value: "${parsed.data.engine}"`;
|
|
30
32
|
logger.err(`[engine-switch-handler] ${errMsg} (id=${commandId})`);
|
|
31
33
|
return {
|
|
32
34
|
status: "failed",
|
|
33
35
|
result: JSON.stringify({ error: errMsg }),
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
logger.system(`[engine-switch-handler] Already on ${targetFamily} engine (model=${config.model}); no-op (id=${commandId})`);
|
|
38
|
+
if (isAlreadyOnEngineTarget(config, target)) {
|
|
39
|
+
const label = describeEngineTarget(target);
|
|
40
|
+
logger.system(`[engine-switch-handler] Already on ${label} (model=${config.model}); no-op (id=${commandId})`);
|
|
40
41
|
return {
|
|
41
42
|
status: "completed",
|
|
42
|
-
result: JSON.stringify({ message: `Already using ${
|
|
43
|
+
result: JSON.stringify({ message: `Already using ${label} (model=${config.model})` }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
await validateEngineSwitchTarget(config, target);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
const errMsg = err instanceof LlmGatewayModelsError || err instanceof Error
|
|
51
|
+
? err.message
|
|
52
|
+
: String(err);
|
|
53
|
+
logger.err(`[engine-switch-handler] ${errMsg} (id=${commandId})`);
|
|
54
|
+
return {
|
|
55
|
+
status: "failed",
|
|
56
|
+
result: JSON.stringify({ error: errMsg }),
|
|
43
57
|
};
|
|
44
58
|
}
|
|
45
|
-
const targetModel = targetFamily === "gpt" ? GPT_HEAVY_MODEL : DEFAULT_CLAUDE_MODEL;
|
|
46
|
-
const [targetProvider] = getSupportedProvidersForModel(targetModel);
|
|
47
59
|
// Run every fallible side effect *before* persisting the config. If any
|
|
48
60
|
// of these throw, the config is untouched and the no-op fast path above
|
|
49
61
|
// won't trigger on redelivery — so the admin can simply resend the
|
|
50
62
|
// command and get a full switch attempt. (After saveConfig, only the
|
|
51
63
|
// setTimeout-based scheduleRestart remains, which cannot fail.)
|
|
52
|
-
//
|
|
53
|
-
// Marker so the agent notifies the owner after the restart. Worst case
|
|
54
|
-
// (saveConfig throws below) this leaves a stray pending-restart marker
|
|
55
|
-
// that produces one redundant owner notification — harmless.
|
|
56
64
|
writePendingRestart({
|
|
57
65
|
channel: "onboarding-server",
|
|
58
66
|
sender: "admin",
|
|
@@ -60,17 +68,16 @@ export function createEngineSwitchHandler(config) {
|
|
|
60
68
|
});
|
|
61
69
|
const { scheduleRestart } = await import("../utils/restart.js");
|
|
62
70
|
const { runGracefulShutdown } = await import("./state.js");
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
config.model = targetModel;
|
|
66
|
-
config.provider = targetProvider;
|
|
71
|
+
config.model = target.model;
|
|
72
|
+
config.provider = target.provider;
|
|
67
73
|
saveConfig(config);
|
|
68
|
-
|
|
74
|
+
const label = describeEngineTarget(target);
|
|
75
|
+
logger.system(`[engine-switch-handler] Engine switch to ${label} (${target.model}, provider=${target.provider}) requested via onboarding server (id=${commandId})`);
|
|
69
76
|
scheduleRestart(RESTART_DELAY, runGracefulShutdown);
|
|
70
77
|
return {
|
|
71
78
|
status: "completed",
|
|
72
79
|
result: JSON.stringify({
|
|
73
|
-
message: `Switching to ${
|
|
80
|
+
message: `Switching to ${label} (${target.model}, provider=${target.provider}); restarting in ${RESTART_DELAY / 1000}s`,
|
|
74
81
|
}),
|
|
75
82
|
};
|
|
76
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-switch-handler.js","sourceRoot":"","sources":["../../src/agent/engine-switch-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,M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EAAqE;QACrE,gEAAgE;QAChE,mBAAmB,CAAC;YAClB,OAAO,EAAE,mBAAmB;YAC5B,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC,CAAC;QACH,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAChE,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAE3D,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,UAAU,CAAC,MAAM,CAAC,CAAC;QAEnB,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CACX,4CAA4C,KAAK,KAAK,MAAM,CAAC,KAAK,cAAc,MAAM,CAAC,QAAQ,yCAAyC,SAAS,GAAG,CACrJ,CAAC;QAEF,eAAe,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;QAEpD,OAAO;YACL,MAAM,EAAE,WAAoB;YAC5B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;gBACrB,OAAO,EAAE,gBAAgB,KAAK,KAAK,MAAM,CAAC,KAAK,cAAc,MAAM,CAAC,QAAQ,oBAAoB,aAAa,GAAG,IAAI,GAAG;aACxH,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resolution for `/engine` / `switch_engine` targets.
|
|
3
|
+
*/
|
|
4
|
+
import { getEngineSwitchKey, isPinnedModel } from "../config/models.js";
|
|
5
|
+
import { type Model, type Provider, type VisionClawConfig } from "../config/types.js";
|
|
6
|
+
export type EngineSwitchTarget = {
|
|
7
|
+
kind: "family";
|
|
8
|
+
family: "claude" | "gpt";
|
|
9
|
+
model: Model;
|
|
10
|
+
provider: Provider;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "pinned";
|
|
13
|
+
model: Model;
|
|
14
|
+
provider: Provider;
|
|
15
|
+
};
|
|
16
|
+
/** Parse `/engine <token>` — `claude`/`gpt` are families; anything else is a pinned model id. */
|
|
17
|
+
export declare function parseEngineSwitchToken(token: string): {
|
|
18
|
+
family: "claude" | "gpt";
|
|
19
|
+
} | {
|
|
20
|
+
pinnedModelId: string;
|
|
21
|
+
} | null;
|
|
22
|
+
export declare function resolveEngineSwitchTarget(token: string): EngineSwitchTarget | null;
|
|
23
|
+
export declare function isAlreadyOnEngineTarget(config: Pick<VisionClawConfig, "model">, target: EngineSwitchTarget): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Validate a pinned switch against LLM Gateway `/v1/models`.
|
|
26
|
+
* Family switches are no-ops here.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateEngineSwitchTarget(config: VisionClawConfig, target: EngineSwitchTarget, options?: {
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
export declare function describeEngineTarget(target: EngineSwitchTarget): string;
|
|
32
|
+
export { isPinnedModel, getEngineSwitchKey };
|
|
33
|
+
//# sourceMappingURL=engine-switch-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-switch-target.d.ts","sourceRoot":"","sources":["../../src/agent/engine-switch-target.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGL,kBAAkB,EAElB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEzD,iGAAiG;AACjG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;CAAE,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAmBrH;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,GACZ,kBAAkB,GAAG,IAAI,CAa3B;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,EACvC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;CAAO,GACzC,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAKvE;AAED,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resolution for `/engine` / `switch_engine` targets.
|
|
3
|
+
*/
|
|
4
|
+
import { DEFAULT_CLAUDE_MODEL, GPT_HEAVY_MODEL, getEngineSwitchKey, isKnownModel, isPinnedModel, } from "../config/models.js";
|
|
5
|
+
import { getSupportedProvidersForModel, } from "../config/types.js";
|
|
6
|
+
import { assertLlmGatewaySupportsModel } from "./llm-gateway-models.js";
|
|
7
|
+
/** Parse `/engine <token>` — `claude`/`gpt` are families; anything else is a pinned model id. */
|
|
8
|
+
export function parseEngineSwitchToken(token) {
|
|
9
|
+
const trimmed = token.trim();
|
|
10
|
+
if (!trimmed)
|
|
11
|
+
return null;
|
|
12
|
+
const lower = trimmed.toLowerCase();
|
|
13
|
+
if (lower === "claude" || lower === "gpt") {
|
|
14
|
+
return { family: lower };
|
|
15
|
+
}
|
|
16
|
+
// Reject reserved runtime aliases that are not valid pinned gateway model ids.
|
|
17
|
+
if (lower === "pi" || lower === "pi-coding" || lower === "coding") {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
// Reject built-in family model ids (e.g. claude-fable-5, gpt-5.6-luna):
|
|
21
|
+
// they are NOT pinned models — isPinnedModel() would be false after the
|
|
22
|
+
// switch, so routing would silently fall back to family behavior. Users
|
|
23
|
+
// should switch families via `/engine claude` / `/engine gpt` instead.
|
|
24
|
+
if (isKnownModel(trimmed)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return { pinnedModelId: trimmed };
|
|
28
|
+
}
|
|
29
|
+
export function resolveEngineSwitchTarget(token) {
|
|
30
|
+
const parsed = parseEngineSwitchToken(token);
|
|
31
|
+
if (!parsed)
|
|
32
|
+
return null;
|
|
33
|
+
if ("family" in parsed) {
|
|
34
|
+
const model = parsed.family === "gpt" ? GPT_HEAVY_MODEL : DEFAULT_CLAUDE_MODEL;
|
|
35
|
+
const [provider] = getSupportedProvidersForModel(model);
|
|
36
|
+
return { kind: "family", family: parsed.family, model, provider };
|
|
37
|
+
}
|
|
38
|
+
const model = parsed.pinnedModelId;
|
|
39
|
+
const [provider] = getSupportedProvidersForModel(model);
|
|
40
|
+
return { kind: "pinned", model, provider };
|
|
41
|
+
}
|
|
42
|
+
export function isAlreadyOnEngineTarget(config, target) {
|
|
43
|
+
const currentKey = getEngineSwitchKey(config.model);
|
|
44
|
+
if (target.kind === "family") {
|
|
45
|
+
return currentKey === target.family;
|
|
46
|
+
}
|
|
47
|
+
return currentKey === target.model;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate a pinned switch against LLM Gateway `/v1/models`.
|
|
51
|
+
* Family switches are no-ops here.
|
|
52
|
+
*/
|
|
53
|
+
export async function validateEngineSwitchTarget(config, target, options = {}) {
|
|
54
|
+
if (target.kind !== "pinned")
|
|
55
|
+
return;
|
|
56
|
+
if (target.provider !== "llm-gateway") {
|
|
57
|
+
throw new Error(`Pinned model "${target.model}" requires provider llm-gateway`);
|
|
58
|
+
}
|
|
59
|
+
// Prefer credentials from config; after switch we will set provider to llm-gateway.
|
|
60
|
+
await assertLlmGatewaySupportsModel({
|
|
61
|
+
llmGatewayBaseUrl: config.llmGatewayBaseUrl,
|
|
62
|
+
llmGatewayApiKey: config.llmGatewayApiKey,
|
|
63
|
+
}, target.model, options);
|
|
64
|
+
}
|
|
65
|
+
export function describeEngineTarget(target) {
|
|
66
|
+
if (target.kind === "family") {
|
|
67
|
+
return `${target.family} engine`;
|
|
68
|
+
}
|
|
69
|
+
return `pinned model "${target.model}"`;
|
|
70
|
+
}
|
|
71
|
+
export { isPinnedModel, getEngineSwitchKey };
|
|
72
|
+
//# sourceMappingURL=engine-switch-target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-switch-target.js","sourceRoot":"","sources":["../../src/agent/engine-switch-target.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,6BAA6B,GAI9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAMxE,iGAAiG;AACjG,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,IA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G,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC;IACtC,CAAC;IACD,OAAO,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,MAAwB,EACxB,MAA0B,EAC1B,UAAwC,EAAE;IAE1C,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO;IACrC,IAAI,MAAM,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,CAAC,KAAK,iCAAiC,CAAC,CAAC;IAClF,CAAC;IACD,oFAAoF;IACpF,MAAM,6BAA6B,CACjC;QACE,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,EACD,MAAM,CAAC,KAAK,EACZ,OAAO,CACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAA0B;IAC7D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,GAAG,MAAM,CAAC,MAAM,SAAS,CAAC;IACnC,CAAC;IACD,OAAO,iBAAiB,MAAM,CAAC,KAAK,GAAG,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for creating the correct Anthropic client (direct API vs Bedrock)
|
|
3
|
+
* and resolving provider-specific model IDs.
|
|
4
|
+
*/
|
|
5
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
6
|
+
import OpenAI, { AzureOpenAI } from "openai";
|
|
7
|
+
import { type Model, type Provider, type VisionClawConfig } from "../../config/types.js";
|
|
8
|
+
export declare const OPENAI_MODEL = "gpt-5.5";
|
|
9
|
+
export declare const AZURE_OPENAI_API_VERSION = "preview";
|
|
10
|
+
export declare function isOpenAIProvider(provider: Provider): provider is "openai" | "azure-openai";
|
|
11
|
+
/**
|
|
12
|
+
* True for any GPT-family model (e.g. "gpt-5.5", future "gpt-6", "gpt-5.5-mini").
|
|
13
|
+
* Routing to the OpenAI Agents SDK only depends on the family, not the exact
|
|
14
|
+
* version, so we match by prefix instead of pinning to a single literal.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isGptModel(model: Model | undefined): boolean;
|
|
17
|
+
export declare function getProviderLabel(provider: Provider): string;
|
|
18
|
+
export declare function getRuntimeLabel(config: VisionClawConfig): string;
|
|
19
|
+
/**
|
|
20
|
+
* Create an Anthropic-compatible client based on the provider in the config.
|
|
21
|
+
*
|
|
22
|
+
* - `"anthropic"`: uses the direct API with `anthropicApiKey`.
|
|
23
|
+
* - `"bedrock"`: uses `AnthropicBedrock` with explicit AWS credentials when
|
|
24
|
+
* provided, otherwise falls back to the default AWS credential provider chain.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createClient(config: VisionClawConfig): Anthropic;
|
|
27
|
+
export declare function hasProviderCredentials(provider: Provider, config: VisionClawConfig): boolean;
|
|
28
|
+
export declare function createOpenAIClient(config: VisionClawConfig): OpenAI | AzureOpenAI;
|
|
29
|
+
export declare function configureOpenAIProvider(config: VisionClawConfig): void;
|
|
30
|
+
/**
|
|
31
|
+
* Return the correct model identifier for direct SDK calls
|
|
32
|
+
* (fast-responder, tool-alarm-evaluator, etc.).
|
|
33
|
+
*
|
|
34
|
+
* Agent SDK `query()` calls do NOT need this - the SDK maps models
|
|
35
|
+
* internally when `CLAUDE_CODE_USE_BEDROCK=1` or `CLAUDE_CODE_USE_VERTEX=1` is set.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getModelId(config: VisionClawConfig): string;
|
|
38
|
+
/**
|
|
39
|
+
* Return the Sonnet model identifier for lightweight side-calls
|
|
40
|
+
* (fast-responder, etc.) that don't need the full Opus model.
|
|
41
|
+
* For non-Claude providers, falls back to the main model.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFastResponderModelId(config: VisionClawConfig): string;
|
|
44
|
+
/**
|
|
45
|
+
* Build the `env` record for the Agent SDK `query()` options.
|
|
46
|
+
*
|
|
47
|
+
* - Anthropic: passes `ANTHROPIC_API_KEY`.
|
|
48
|
+
* - Bedrock: passes `CLAUDE_CODE_USE_BEDROCK`, `AWS_REGION`,
|
|
49
|
+
* `AWS_BEARER_TOKEN_BEDROCK` (for the Claude Code CLI), and IAM
|
|
50
|
+
* credentials when available.
|
|
51
|
+
* - Vertex: passes `CLAUDE_CODE_USE_VERTEX`, `CLOUD_ML_REGION`,
|
|
52
|
+
* and `GOOGLE_APPLICATION_CREDENTIALS` for service account auth.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildAgentEnv(config: VisionClawConfig): Record<string, string | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Start the API logging proxy if running in dev mode with the Anthropic
|
|
57
|
+
* or 9Router provider. No-ops (and returns immediately) in production,
|
|
58
|
+
* for Bedrock (which bypasses ANTHROPIC_BASE_URL), or for OpenAI providers.
|
|
59
|
+
*
|
|
60
|
+
* Call once at startup, before the first `buildAgentEnv()` call.
|
|
61
|
+
*/
|
|
62
|
+
export declare function maybeStartApiProxy(config: VisionClawConfig): Promise<void>;
|
|
63
|
+
//# sourceMappingURL=client-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-factory.d.ts","sourceRoot":"","sources":["../../../src/agent/engines/client-factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,OAAO,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,gBAAgB,EAC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