visionclaw 0.1.192-dev.feat-virtual-card-phase2.2 → 0.1.193-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/engines/claude/cli-resolver.d.ts +16 -0
- package/dist/agent/engines/claude/cli-resolver.d.ts.map +1 -0
- package/dist/agent/engines/claude/cli-resolver.js +83 -0
- package/dist/agent/engines/claude/cli-resolver.js.map +1 -0
- package/dist/agent/engines/claude/session-browser-policy.d.ts +9 -0
- package/dist/agent/engines/claude/session-browser-policy.d.ts.map +1 -0
- package/dist/agent/engines/claude/session-browser-policy.js +49 -0
- package/dist/agent/engines/claude/session-browser-policy.js.map +1 -0
- package/dist/agent/engines/claude/session.d.ts +291 -0
- package/dist/agent/engines/claude/session.d.ts.map +1 -0
- package/dist/agent/engines/claude/session.js +1177 -0
- package/dist/agent/engines/claude/session.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.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 +49 -0
- package/dist/agent/engines/openai/file-session.d.ts.map +1 -0
- package/dist/agent/engines/openai/file-session.js +108 -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 +190 -0
- package/dist/agent/engines/openai/session.d.ts.map +1 -0
- package/dist/agent/engines/openai/session.js +1066 -0
- package/dist/agent/engines/openai/session.js.map +1 -0
- package/dist/agent/engines/openai/tools.d.ts +13 -0
- package/dist/agent/engines/openai/tools.d.ts.map +1 -0
- package/dist/agent/engines/openai/tools.js +248 -0
- package/dist/agent/engines/openai/tools.js.map +1 -0
- package/dist/agent/engines/session-types.d.ts +146 -0
- package/dist/agent/engines/session-types.d.ts.map +1 -0
- package/dist/agent/engines/session-types.js +2 -0
- package/dist/agent/engines/session-types.js.map +1 -0
- package/dist/agent/engines/system-prompt-log.d.ts +9 -0
- package/dist/agent/engines/system-prompt-log.d.ts.map +1 -0
- package/dist/agent/engines/system-prompt-log.js +46 -0
- package/dist/agent/engines/system-prompt-log.js.map +1 -0
- package/dist/agent/heartbeat-manager.d.ts +3 -0
- package/dist/agent/heartbeat-manager.d.ts.map +1 -1
- package/dist/agent/heartbeat-manager.js +37 -0
- package/dist/agent/heartbeat-manager.js.map +1 -1
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +1 -0
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/providers/claude/session.d.ts +1 -0
- package/dist/agent/providers/claude/session.d.ts.map +1 -1
- package/dist/agent/providers/claude/session.js +3 -0
- package/dist/agent/providers/claude/session.js.map +1 -1
- package/dist/agent/providers/openai/session.d.ts +1 -0
- package/dist/agent/providers/openai/session.d.ts.map +1 -1
- package/dist/agent/providers/openai/session.js +3 -0
- package/dist/agent/providers/openai/session.js.map +1 -1
- package/dist/agent/providers/openai/tools.d.ts +1 -0
- package/dist/agent/providers/openai/tools.d.ts.map +1 -1
- package/dist/agent/providers/openai/tools.js +4 -0
- package/dist/agent/providers/openai/tools.js.map +1 -1
- package/dist/agent/providers/session-types.d.ts +1 -0
- package/dist/agent/providers/session-types.d.ts.map +1 -1
- package/dist/agent/session-manager.d.ts.map +1 -1
- package/dist/agent/session-manager.js +9 -0
- package/dist/agent/session-manager.js.map +1 -1
- package/dist/agent/state.d.ts +7 -0
- package/dist/agent/state.d.ts.map +1 -1
- package/dist/agent/state.js.map +1 -1
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +14 -1
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/transcript/transcript-backfill.d.ts +54 -0
- package/dist/agent/transcript/transcript-backfill.d.ts.map +1 -0
- package/dist/agent/transcript/transcript-backfill.js +604 -0
- package/dist/agent/transcript/transcript-backfill.js.map +1 -0
- package/dist/agent/transcript/transcript-indexer.d.ts +273 -0
- package/dist/agent/transcript/transcript-indexer.d.ts.map +1 -0
- package/dist/agent/transcript/transcript-indexer.js +1217 -0
- package/dist/agent/transcript/transcript-indexer.js.map +1 -0
- package/dist/agent/transcript/transcript-memory-migrations.d.ts +25 -0
- package/dist/agent/transcript/transcript-memory-migrations.d.ts.map +1 -0
- package/dist/agent/transcript/transcript-memory-migrations.js +87 -0
- package/dist/agent/transcript/transcript-memory-migrations.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/usage-backfill-handler.d.ts +18 -0
- package/dist/agent/usage/usage-backfill-handler.d.ts.map +1 -0
- package/dist/agent/usage/usage-backfill-handler.js +69 -0
- package/dist/agent/usage/usage-backfill-handler.js.map +1 -0
- package/dist/agent/usage/usage-gate.d.ts +25 -0
- package/dist/agent/usage/usage-gate.d.ts.map +1 -0
- package/dist/agent/usage/usage-gate.js +83 -0
- package/dist/agent/usage/usage-gate.js.map +1 -0
- package/dist/agent/usage/usage-handler.d.ts +7 -0
- package/dist/agent/usage/usage-handler.d.ts.map +1 -0
- package/dist/agent/usage/usage-handler.js +28 -0
- package/dist/agent/usage/usage-handler.js.map +1 -0
- package/dist/agent/usage/usage-report-builder.d.ts +26 -0
- package/dist/agent/usage/usage-report-builder.d.ts.map +1 -0
- package/dist/agent/usage/usage-report-builder.js +80 -0
- package/dist/agent/usage/usage-report-builder.js.map +1 -0
- package/dist/agent/usage/usage-report-queue.d.ts +26 -0
- package/dist/agent/usage/usage-report-queue.d.ts.map +1 -0
- package/dist/agent/usage/usage-report-queue.js +199 -0
- package/dist/agent/usage/usage-report-queue.js.map +1 -0
- package/dist/agent/usage/usage-report-types.d.ts +41 -0
- package/dist/agent/usage/usage-report-types.d.ts.map +1 -0
- package/dist/agent/usage/usage-report-types.js +2 -0
- package/dist/agent/usage/usage-report-types.js.map +1 -0
- package/dist/agent/usage/usage-reporter.d.ts +31 -0
- package/dist/agent/usage/usage-reporter.d.ts.map +1 -0
- package/dist/agent/usage/usage-reporter.js +102 -0
- package/dist/agent/usage/usage-reporter.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-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-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/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/index.js.map +1 -1
- 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/onboarding/index.d.ts.map +1 -1
- package/dist/onboarding/index.js +18 -8
- package/dist/onboarding/index.js.map +1 -1
- package/dist/onboarding/onboarding-service-client.d.ts +1 -0
- package/dist/onboarding/onboarding-service-client.d.ts.map +1 -1
- package/dist/onboarding/onboarding-service-client.js.map +1 -1
- package/dist/onboarding/playwriter-extension.d.ts +19 -0
- package/dist/onboarding/playwriter-extension.d.ts.map +1 -0
- package/dist/onboarding/playwriter-extension.js +246 -0
- package/dist/onboarding/playwriter-extension.js.map +1 -0
- package/dist/onboarding/prepare-mac.d.ts.map +1 -1
- package/dist/onboarding/prepare-mac.js +40 -15
- package/dist/onboarding/prepare-mac.js.map +1 -1
- package/dist/onboarding/provisioning-spec.d.ts +1 -0
- package/dist/onboarding/provisioning-spec.d.ts.map +1 -1
- package/dist/onboarding/provisioning-spec.js +2 -1
- package/dist/onboarding/provisioning-spec.js.map +1 -1
- package/dist/onboarding/setup-shared.d.ts +5 -0
- package/dist/onboarding/setup-shared.d.ts.map +1 -1
- package/dist/onboarding/setup-shared.js +38 -4
- package/dist/onboarding/setup-shared.js.map +1 -1
- package/dist/onboarding/setup-steps.d.ts.map +1 -1
- package/dist/onboarding/setup-steps.js +19 -10
- package/dist/onboarding/setup-steps.js.map +1 -1
- package/dist/reset.js +2 -2
- package/dist/reset.js.map +1 -1
- package/dist/service/daemon.d.ts +15 -0
- package/dist/service/daemon.d.ts.map +1 -0
- package/dist/service/daemon.js +357 -0
- package/dist/service/daemon.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/service/launchd.d.ts +4 -4
- package/dist/service/launchd.d.ts.map +1 -1
- package/dist/service/launchd.js +65 -175
- package/dist/service/launchd.js.map +1 -1
- 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/tools/card.d.ts +0 -7
- package/dist/tools/card.d.ts.map +1 -1
- package/dist/tools/card.js +6 -28
- package/dist/tools/card.js.map +1 -1
- 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/email.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/upgrade.js +1 -1
- package/dist/tools/upgrade.js.map +1 -1
- package/dist/utils/playwriter-relay.d.ts +9 -0
- package/dist/utils/playwriter-relay.d.ts.map +1 -0
- package/dist/utils/playwriter-relay.js +77 -0
- package/dist/utils/playwriter-relay.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-agent/bundle.cjs +2256 -1890
- 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,CAAC,YAAY,CAA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-js";
|
|
6
|
+
path: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "sdk-default";
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveClaudeCliExecutable(): ClaudeCliResolution;
|
|
11
|
+
/** Convenience wrapper — return just the path, or `undefined` when we should
|
|
12
|
+
* leave the option unset and let the SDK do its own lookup. */
|
|
13
|
+
export declare function getClaudeExecutablePath(): string | undefined;
|
|
14
|
+
/** For tests. */
|
|
15
|
+
export declare function _resetClaudeCliResolverCache(): void;
|
|
16
|
+
//# sourceMappingURL=cli-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-resolver.d.ts","sourceRoot":"","sources":["../../../../src/agent/engines/claude/cli-resolver.ts"],"names":[],"mappings":"AA8BA,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAQ5B,wBAAgB,0BAA0B,IAAI,mBAAmB,CAIhE;AAED;gEACgE;AAChE,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAG5D;AAsCD,iBAAiB;AACjB,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the executable path that `@anthropic-ai/claude-agent-sdk` should
|
|
3
|
+
* spawn as its "Claude Code" subprocess.
|
|
4
|
+
*
|
|
5
|
+
* Why we need this:
|
|
6
|
+
* - In 0.2.108–0.2.112 the SDK shipped a `cli.js` alongside `sdk.mjs`, and
|
|
7
|
+
* the intended way to pin it from a bundled app was to pass
|
|
8
|
+
* `pathToClaudeCodeExecutable` pointing at that file.
|
|
9
|
+
* - Starting with 0.2.113 (published 2026-04-14) the SDK tarball dropped
|
|
10
|
+
* `cli.js` entirely and switched to a platform-specific native binary
|
|
11
|
+
* shipped via an optional peer package
|
|
12
|
+
* `@anthropic-ai/claude-agent-sdk-<platform>-<arch>`.
|
|
13
|
+
* - Our previous implementation hard-coded `cli.js`, so a stock
|
|
14
|
+
* `pnpm install` that pulled the newer SDK caused the child process to
|
|
15
|
+
* fail with `MODULE_NOT_FOUND`, which in turn surfaced as an async EPIPE
|
|
16
|
+
* in the parent.
|
|
17
|
+
*
|
|
18
|
+
* Resolution order:
|
|
19
|
+
* 1. The native binary from `claude-agent-sdk-<platform>-<arch>/claude`
|
|
20
|
+
* (the forward-compatible choice for 0.2.113+).
|
|
21
|
+
* 2. A legacy `cli.js` next to `sdk.mjs` (still valid for 0.2.112 and older).
|
|
22
|
+
* 3. `null`, meaning: let the SDK resolve the executable itself. Recent SDK
|
|
23
|
+
* versions implement the same fallback chain internally and throw a
|
|
24
|
+
* clear `ReferenceError` if nothing is found, which is much easier to
|
|
25
|
+
* diagnose than a silent EPIPE.
|
|
26
|
+
*/
|
|
27
|
+
import { createRequire } from "module";
|
|
28
|
+
import fs from "fs";
|
|
29
|
+
import path from "path";
|
|
30
|
+
/**
|
|
31
|
+
* Resolve once per process — filesystem lookups here are cheap but the result
|
|
32
|
+
* never changes for a given installation.
|
|
33
|
+
*/
|
|
34
|
+
let cached;
|
|
35
|
+
export function resolveClaudeCliExecutable() {
|
|
36
|
+
if (cached)
|
|
37
|
+
return cached;
|
|
38
|
+
cached = doResolve();
|
|
39
|
+
return cached;
|
|
40
|
+
}
|
|
41
|
+
/** Convenience wrapper — return just the path, or `undefined` when we should
|
|
42
|
+
* leave the option unset and let the SDK do its own lookup. */
|
|
43
|
+
export function getClaudeExecutablePath() {
|
|
44
|
+
const r = resolveClaudeCliExecutable();
|
|
45
|
+
return r.kind === "sdk-default" ? undefined : r.path;
|
|
46
|
+
}
|
|
47
|
+
function doResolve() {
|
|
48
|
+
const _require = createRequire(import.meta.url);
|
|
49
|
+
// 1. Modern native binary (claude-agent-sdk >= 0.2.113).
|
|
50
|
+
const nativePkg = `@anthropic-ai/claude-agent-sdk-${process.platform}-${process.arch}`;
|
|
51
|
+
try {
|
|
52
|
+
const pkgJsonPath = _require.resolve(`${nativePkg}/package.json`);
|
|
53
|
+
const pkgDir = path.dirname(pkgJsonPath);
|
|
54
|
+
// The package ships a single executable named `claude`.
|
|
55
|
+
const candidate = path.join(pkgDir, "claude");
|
|
56
|
+
if (fs.existsSync(candidate)) {
|
|
57
|
+
return { kind: "native", path: candidate };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Optional dep not installed — fall through to legacy cli.js.
|
|
62
|
+
}
|
|
63
|
+
// 2. Legacy JS entry (claude-agent-sdk <= 0.2.112).
|
|
64
|
+
try {
|
|
65
|
+
const sdkDir = path.dirname(_require.resolve("@anthropic-ai/claude-agent-sdk"));
|
|
66
|
+
const candidate = path.join(sdkDir, "cli.js");
|
|
67
|
+
if (fs.existsSync(candidate)) {
|
|
68
|
+
return { kind: "legacy-cli-js", path: candidate };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// No SDK at all — let the caller's catch handle this.
|
|
73
|
+
}
|
|
74
|
+
// 3. Give up and let the SDK resolve on its own. Newer versions still have
|
|
75
|
+
// a reasonable internal lookup and will throw a clear error if nothing
|
|
76
|
+
// works, rather than silently spawning a missing module.
|
|
77
|
+
return { kind: "sdk-default" };
|
|
78
|
+
}
|
|
79
|
+
/** For tests. */
|
|
80
|
+
export function _resetClaudeCliResolverCache() {
|
|
81
|
+
cached = undefined;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=cli-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-resolver.js","sourceRoot":"","sources":["../../../../src/agent/engines/claude/cli-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,E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QAAQ,CAAC,OAAO,CAAC,gCAAgC,CAAC,CACnD,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACpD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sDAAsD;IACxD,CAAC;IAED,2EAA2E;IAC3E,0EAA0E;IAC1E,4DAA4D;IAC5D,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACjC,CAAC;AAED,iBAAiB;AACjB,MAAM,UAAU,4BAA4B;IAC1C,MAAM,GAAG,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure Chrome is running (Playwriter mode). On the first Playwriter tool call
|
|
3
|
+
* of each turn we force a clean restart to reset stale extension connections;
|
|
4
|
+
* later calls in the same turn only ensure Chrome is up.
|
|
5
|
+
*
|
|
6
|
+
* Returns true when a connection reset was performed for this turn.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensurePlaywriterChrome(didResetConnectionsThisTurn: boolean): boolean;
|
|
9
|
+
//# sourceMappingURL=session-browser-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-browser-policy.d.ts","sourceRoot":"","sources":["../../../../src/agent/engines/claude/session-browser-policy.ts"],"names":[],"mappings":"AAsBA;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,2BAA2B,EAAE,OAAO,GACnC,OAAO,CAmBT"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import { logger } from "../../../logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Force Chrome to restart once per turn before the first Playwriter tool call.
|
|
5
|
+
* This clears stale extension relay connections from earlier sessions so the
|
|
6
|
+
* Playwriter MCP sees a single fresh extension connection.
|
|
7
|
+
*/
|
|
8
|
+
function restartChromeForPlaywriter() {
|
|
9
|
+
try {
|
|
10
|
+
execSync("pkill -x 'Google Chrome'", { stdio: "ignore" });
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
// pkill exits non-zero when Chrome is not running — expected.
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
execSync('open -a "Google Chrome"', { stdio: "ignore" });
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
logger.warn(`Failed to restart Chrome for Playwriter: ${err instanceof Error ? err.message : String(err)}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Ensure Chrome is running (Playwriter mode). On the first Playwriter tool call
|
|
24
|
+
* of each turn we force a clean restart to reset stale extension connections;
|
|
25
|
+
* later calls in the same turn only ensure Chrome is up.
|
|
26
|
+
*
|
|
27
|
+
* Returns true when a connection reset was performed for this turn.
|
|
28
|
+
*/
|
|
29
|
+
export function ensurePlaywriterChrome(didResetConnectionsThisTurn) {
|
|
30
|
+
if (!didResetConnectionsThisTurn) {
|
|
31
|
+
logger.system("Resetting Chrome before Playwriter session");
|
|
32
|
+
restartChromeForPlaywriter();
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
execSync("pgrep -x 'Google Chrome'", { stdio: "ignore" });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
logger.system("Chrome not running — launching for Playwriter extension");
|
|
40
|
+
try {
|
|
41
|
+
execSync('open -a "Google Chrome"', { stdio: "ignore" });
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
logger.warn(`Failed to launch Chrome: ${err instanceof Error ? err.message : String(err)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=session-browser-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-browser-policy.js","sourceRoot":"","sources":["../../../../src/agent/engines/claude/session-browser-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;GAIG;AACH,SAAS,0BAA0B;IACjC,IAAI,CAAC;QACH,QAAQ,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,8DAA8D;IAChE,CAAC;IAED,IAAI,CAAC;QACH,QAAQ,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,4CAA4C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,2BAAoC;IAEpC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC;QAC5D,0BAA0B,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,QAAQ,CAAC,0BAA0B,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,CAAC,MAAM,CAAC,yDAAyD,CAAC,CAAC;QACzE,IAAI,CAAC;YACH,QAAQ,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3D,CAAC;QA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