visionclaw 0.1.219-beta.0 → 0.1.219-dev.codex-issue-2805-worker-runtime.1
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/api-proxy.d.ts +0 -16
- package/dist/agent/api-proxy.d.ts.map +1 -1
- package/dist/agent/api-proxy.js +9 -8
- package/dist/agent/api-proxy.js.map +1 -1
- package/dist/agent/browser-launcher.d.ts +3 -0
- package/dist/agent/browser-launcher.d.ts.map +1 -1
- package/dist/agent/browser-launcher.js +101 -43
- package/dist/agent/browser-launcher.js.map +1 -1
- package/dist/agent/coding-conventions.d.ts +8 -0
- package/dist/agent/coding-conventions.d.ts.map +1 -0
- package/dist/agent/coding-conventions.js +19 -0
- package/dist/agent/coding-conventions.js.map +1 -0
- package/dist/agent/command-handlers.d.ts.map +1 -1
- package/dist/agent/command-handlers.js +4 -16
- package/dist/agent/command-handlers.js.map +1 -1
- package/dist/agent/context-action-restart-fallback.d.ts.map +1 -1
- package/dist/agent/context-action-restart-fallback.js +9 -3
- package/dist/agent/context-action-restart-fallback.js.map +1 -1
- package/dist/agent/context-refresh.d.ts.map +1 -1
- package/dist/agent/context-refresh.js +0 -7
- package/dist/agent/context-refresh.js.map +1 -1
- package/dist/agent/context.d.ts +2 -4
- package/dist/agent/context.d.ts.map +1 -1
- package/dist/agent/context.js +12 -21
- package/dist/agent/context.js.map +1 -1
- package/dist/agent/engine-fallback.d.ts +0 -35
- package/dist/agent/engine-fallback.d.ts.map +1 -1
- package/dist/agent/engine-fallback.js +4 -3
- package/dist/agent/engine-fallback.js.map +1 -1
- package/dist/agent/engine-switch.d.ts +19 -38
- package/dist/agent/engine-switch.d.ts.map +1 -1
- package/dist/agent/engine-switch.js +46 -111
- package/dist/agent/engine-switch.js.map +1 -1
- package/dist/agent/engines/browser-tool-policy.d.ts +12 -1
- package/dist/agent/engines/browser-tool-policy.d.ts.map +1 -1
- package/dist/agent/engines/browser-tool-policy.js +17 -2
- package/dist/agent/engines/browser-tool-policy.js.map +1 -1
- package/dist/agent/engines/claude/executor-shell-groups.d.ts +11 -0
- package/dist/agent/engines/claude/executor-shell-groups.d.ts.map +1 -0
- package/dist/agent/engines/claude/executor-shell-groups.js +22 -0
- package/dist/agent/engines/claude/executor-shell-groups.js.map +1 -0
- package/dist/agent/engines/claude/session.d.ts +13 -4
- package/dist/agent/engines/claude/session.d.ts.map +1 -1
- package/dist/agent/engines/claude/session.js +165 -84
- package/dist/agent/engines/claude/session.js.map +1 -1
- package/dist/agent/engines/pi/shared/usage.d.ts +6 -8
- package/dist/agent/engines/pi/shared/usage.d.ts.map +1 -1
- package/dist/agent/engines/pi/shared/usage.js +24 -7
- package/dist/agent/engines/pi/shared/usage.js.map +1 -1
- package/dist/agent/engines/pi/tools.d.ts +3 -10
- package/dist/agent/engines/pi/tools.d.ts.map +1 -1
- package/dist/agent/engines/pi/tools.js +6 -20
- package/dist/agent/engines/pi/tools.js.map +1 -1
- package/dist/agent/engines/pi-coding/executor-shell.d.ts +4 -0
- package/dist/agent/engines/pi-coding/executor-shell.d.ts.map +1 -0
- package/dist/agent/engines/pi-coding/executor-shell.js +175 -0
- package/dist/agent/engines/pi-coding/executor-shell.js.map +1 -0
- package/dist/agent/engines/pi-coding/session.d.ts +4 -4
- package/dist/agent/engines/pi-coding/session.d.ts.map +1 -1
- package/dist/agent/engines/pi-coding/session.js +118 -66
- package/dist/agent/engines/pi-coding/session.js.map +1 -1
- package/dist/agent/engines/pi-coding/tools.d.ts +2 -5
- package/dist/agent/engines/pi-coding/tools.d.ts.map +1 -1
- package/dist/agent/engines/pi-coding/tools.js +7 -5
- package/dist/agent/engines/pi-coding/tools.js.map +1 -1
- package/dist/agent/engines/session-types.d.ts +8 -8
- package/dist/agent/engines/session-types.d.ts.map +1 -1
- package/dist/agent/external-context/interrupt.d.ts +0 -2
- package/dist/agent/external-context/interrupt.d.ts.map +1 -1
- package/dist/agent/external-context/interrupt.js +0 -1
- package/dist/agent/external-context/interrupt.js.map +1 -1
- package/dist/agent/external-context/registry.d.ts +0 -2
- package/dist/agent/external-context/registry.d.ts.map +1 -1
- package/dist/agent/external-context/registry.js +2 -4
- package/dist/agent/external-context/registry.js.map +1 -1
- package/dist/agent/external-context/runtime.d.ts.map +1 -1
- package/dist/agent/external-context/runtime.js +15 -14
- package/dist/agent/external-context/runtime.js.map +1 -1
- package/dist/agent/external-context/types.d.ts +0 -2
- package/dist/agent/external-context/types.d.ts.map +1 -1
- package/dist/agent/fast-responder.d.ts +4 -20
- package/dist/agent/fast-responder.d.ts.map +1 -1
- package/dist/agent/fast-responder.js +28 -42
- package/dist/agent/fast-responder.js.map +1 -1
- package/dist/agent/interrupt-handler.d.ts +0 -6
- package/dist/agent/interrupt-handler.d.ts.map +1 -1
- package/dist/agent/interrupt-handler.js +5 -47
- package/dist/agent/interrupt-handler.js.map +1 -1
- package/dist/agent/lab-run-system-prompt.d.ts.map +1 -1
- package/dist/agent/lab-run-system-prompt.js +4 -1
- package/dist/agent/lab-run-system-prompt.js.map +1 -1
- package/dist/agent/lifecycle-trace.d.ts.map +1 -1
- package/dist/agent/lifecycle-trace.js +6 -5
- package/dist/agent/lifecycle-trace.js.map +1 -1
- package/dist/agent/loop.d.ts +8 -2
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +287 -156
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/memory-protocol.d.ts +2 -2
- package/dist/agent/memory-protocol.d.ts.map +1 -1
- package/dist/agent/memory-protocol.js +3 -15
- package/dist/agent/memory-protocol.js.map +1 -1
- package/dist/agent/memory-store.d.ts +58 -0
- package/dist/agent/memory-store.d.ts.map +1 -0
- package/dist/agent/memory-store.js +152 -0
- package/dist/agent/memory-store.js.map +1 -0
- package/dist/agent/model-provider.d.ts +18 -5
- package/dist/agent/model-provider.d.ts.map +1 -1
- package/dist/agent/model-provider.js +58 -18
- package/dist/agent/model-provider.js.map +1 -1
- package/dist/agent/nightly-maintenance/dreaming-batch.d.ts +184 -0
- package/dist/agent/nightly-maintenance/dreaming-batch.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-batch.js +192 -0
- package/dist/agent/nightly-maintenance/dreaming-batch.js.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-files.d.ts +48 -0
- package/dist/agent/nightly-maintenance/dreaming-files.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-files.js +109 -0
- package/dist/agent/nightly-maintenance/dreaming-files.js.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-ledger.d.ts +62 -0
- package/dist/agent/nightly-maintenance/dreaming-ledger.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-ledger.js +146 -0
- package/dist/agent/nightly-maintenance/dreaming-ledger.js.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-planner.d.ts +86 -0
- package/dist/agent/nightly-maintenance/dreaming-planner.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-planner.js +304 -0
- package/dist/agent/nightly-maintenance/dreaming-planner.js.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-runner.d.ts +93 -0
- package/dist/agent/nightly-maintenance/dreaming-runner.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-runner.js +156 -0
- package/dist/agent/nightly-maintenance/dreaming-runner.js.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-sources.d.ts +115 -0
- package/dist/agent/nightly-maintenance/dreaming-sources.d.ts.map +1 -0
- package/dist/agent/nightly-maintenance/dreaming-sources.js +270 -0
- package/dist/agent/nightly-maintenance/dreaming-sources.js.map +1 -0
- package/dist/agent/nightly-maintenance/index.d.ts +28 -8
- package/dist/agent/nightly-maintenance/index.d.ts.map +1 -1
- package/dist/agent/nightly-maintenance/index.js +42 -15
- package/dist/agent/nightly-maintenance/index.js.map +1 -1
- package/dist/agent/nightly-maintenance/skill-learning-gate.js +1 -1
- package/dist/agent/nightly-maintenance/skill-learning-gate.js.map +1 -1
- package/dist/agent/nightly-maintenance/vocabulary-processor.d.ts +1 -1
- package/dist/agent/nightly-maintenance/vocabulary-processor.d.ts.map +1 -1
- package/dist/agent/product-identity.d.ts +5 -4
- package/dist/agent/product-identity.d.ts.map +1 -1
- package/dist/agent/product-identity.js +7 -6
- package/dist/agent/product-identity.js.map +1 -1
- package/dist/agent/public-activity.js +1 -1
- package/dist/agent/public-activity.js.map +1 -1
- package/dist/agent/runtime-context.d.ts +27 -0
- package/dist/agent/runtime-context.d.ts.map +1 -0
- package/dist/agent/runtime-context.js +60 -0
- package/dist/agent/runtime-context.js.map +1 -0
- package/dist/agent/runtime-disclosure-policy.d.ts +6 -0
- package/dist/agent/runtime-disclosure-policy.d.ts.map +1 -0
- package/dist/agent/runtime-disclosure-policy.js +16 -0
- package/dist/agent/runtime-disclosure-policy.js.map +1 -0
- package/dist/agent/runtime-surface.d.ts +15 -4
- package/dist/agent/runtime-surface.d.ts.map +1 -1
- package/dist/agent/runtime-surface.js +0 -1
- package/dist/agent/runtime-surface.js.map +1 -1
- package/dist/agent/session-manager.d.ts +30 -126
- package/dist/agent/session-manager.d.ts.map +1 -1
- package/dist/agent/session-manager.js +60 -484
- package/dist/agent/session-manager.js.map +1 -1
- package/dist/agent/state.d.ts +42 -2
- package/dist/agent/state.d.ts.map +1 -1
- package/dist/agent/state.js +21 -11
- package/dist/agent/state.js.map +1 -1
- package/dist/agent/stream-handler.d.ts +6 -13
- package/dist/agent/stream-handler.d.ts.map +1 -1
- package/dist/agent/stream-handler.js +8 -62
- package/dist/agent/stream-handler.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +2 -0
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +21 -20
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/agent/tool-usage.d.ts.map +1 -1
- package/dist/agent/tool-usage.js +0 -1
- package/dist/agent/tool-usage.js.map +1 -1
- package/dist/agent/transcript/transcript-backfill.js +3 -3
- package/dist/agent/transcript/transcript-backfill.js.map +1 -1
- package/dist/agent/transcript/transcript-indexer.d.ts +3 -31
- package/dist/agent/transcript/transcript-indexer.d.ts.map +1 -1
- package/dist/agent/transcript/transcript-indexer.js +58 -57
- package/dist/agent/transcript/transcript-indexer.js.map +1 -1
- package/dist/agent/transcript-parsers/trivial-tools.d.ts.map +1 -1
- package/dist/agent/transcript-parsers/trivial-tools.js +0 -2
- package/dist/agent/transcript-parsers/trivial-tools.js.map +1 -1
- package/dist/agent/transcript-parsers/types.d.ts +1 -1
- package/dist/agent/transcript-summarizer.d.ts +14 -0
- package/dist/agent/transcript-summarizer.d.ts.map +1 -1
- package/dist/agent/transcript-summarizer.js +69 -45
- package/dist/agent/transcript-summarizer.js.map +1 -1
- package/dist/agent/usage/usage-report-queue.d.ts.map +1 -1
- package/dist/agent/usage/usage-report-queue.js +53 -52
- package/dist/agent/usage/usage-report-queue.js.map +1 -1
- package/dist/agent/usage/usage-report-types.d.ts +1 -1
- package/dist/agent/usage/usage-report-types.d.ts.map +1 -1
- package/dist/agent/vocabulary-glossary.d.ts +3 -3
- package/dist/agent/wake-cycle-runner.d.ts +14 -17
- package/dist/agent/wake-cycle-runner.d.ts.map +1 -1
- package/dist/agent/wake-cycle-runner.js +121 -290
- package/dist/agent/wake-cycle-runner.js.map +1 -1
- package/dist/builtin-skills/owner-manual/SKILL.md +2 -2
- package/dist/calendar/occurrence-ownership.d.ts.map +1 -1
- package/dist/calendar/occurrence-ownership.js +6 -5
- package/dist/calendar/occurrence-ownership.js.map +1 -1
- package/dist/calendar/scheduler.d.ts.map +1 -1
- package/dist/calendar/scheduler.js +4 -3
- package/dist/calendar/scheduler.js.map +1 -1
- package/dist/channels/interface.d.ts +8 -2
- package/dist/channels/interface.d.ts.map +1 -1
- package/dist/channels/interface.js +8 -1
- package/dist/channels/interface.js.map +1 -1
- package/dist/channels/manager.d.ts.map +1 -1
- package/dist/channels/manager.js +5 -1
- package/dist/channels/manager.js.map +1 -1
- package/dist/channels/queue.d.ts.map +1 -1
- package/dist/channels/queue.js +8 -0
- package/dist/channels/queue.js.map +1 -1
- package/dist/channels/tui.d.ts +14 -1
- package/dist/channels/tui.d.ts.map +1 -1
- package/dist/channels/tui.js +64 -2
- package/dist/channels/tui.js.map +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +22 -53
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +13 -7
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +51 -64
- package/dist/config/index.js.map +1 -1
- package/dist/config/types.d.ts +28 -7
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +22 -20
- package/dist/config/types.js.map +1 -1
- package/dist/conversations/lazy-runtime.d.ts +5 -0
- package/dist/conversations/lazy-runtime.d.ts.map +1 -0
- package/dist/conversations/lazy-runtime.js +12 -0
- package/dist/conversations/lazy-runtime.js.map +1 -0
- package/dist/conversations/runtime.d.ts +17 -0
- package/dist/conversations/runtime.d.ts.map +1 -0
- package/dist/conversations/runtime.js +92 -0
- package/dist/conversations/runtime.js.map +1 -0
- package/dist/conversations/scheduler.d.ts +57 -0
- package/dist/conversations/scheduler.d.ts.map +1 -0
- package/dist/conversations/scheduler.js +175 -0
- package/dist/conversations/scheduler.js.map +1 -0
- package/dist/data-processing/pipeline.d.ts +0 -2
- package/dist/data-processing/pipeline.d.ts.map +1 -1
- package/dist/data-processing/pipeline.js +19 -24
- package/dist/data-processing/pipeline.js.map +1 -1
- package/dist/data-processing/restructure.d.ts +0 -2
- package/dist/data-processing/restructure.d.ts.map +1 -1
- package/dist/data-processing/restructure.js +6 -9
- package/dist/data-processing/restructure.js.map +1 -1
- package/dist/data-processing/types.d.ts +2 -9
- package/dist/data-processing/types.d.ts.map +1 -1
- package/dist/data-processing/types.js +2 -13
- package/dist/data-processing/types.js.map +1 -1
- package/dist/email/email-route-store.d.ts.map +1 -1
- package/dist/email/email-route-store.js +6 -5
- package/dist/email/email-route-store.js.map +1 -1
- package/dist/i18n/messages.d.ts +26 -2
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/i18n/messages.js +30 -5
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +11 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +49 -1
- package/dist/logger.js.map +1 -1
- package/dist/obs/mini-app/status.d.ts.map +1 -1
- package/dist/obs/mini-app/status.js +0 -1
- package/dist/obs/mini-app/status.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/remote-set-owner.d.ts.map +1 -1
- package/dist/onboarding/remote-set-owner.js +0 -1
- package/dist/onboarding/remote-set-owner.js.map +1 -1
- package/dist/onboarding/set-owner.d.ts +1 -1
- package/dist/onboarding/set-owner.d.ts.map +1 -1
- package/dist/onboarding/set-owner.js +3 -6
- package/dist/onboarding/set-owner.js.map +1 -1
- package/dist/reconfigure.d.ts.map +1 -1
- package/dist/reconfigure.js +1 -32
- package/dist/reconfigure.js.map +1 -1
- package/dist/reset.d.ts.map +1 -1
- package/dist/reset.js +3 -1
- package/dist/reset.js.map +1 -1
- package/dist/threads/active-threads-store.d.ts.map +1 -1
- package/dist/threads/active-threads-store.js +8 -27
- package/dist/threads/active-threads-store.js.map +1 -1
- package/dist/threads/dreaming-execution.d.ts +10 -0
- package/dist/threads/dreaming-execution.d.ts.map +1 -0
- package/dist/threads/dreaming-execution.js +78 -0
- package/dist/threads/dreaming-execution.js.map +1 -0
- package/dist/threads/execution-authority.d.ts +43 -0
- package/dist/threads/execution-authority.d.ts.map +1 -0
- package/dist/threads/execution-authority.js +75 -0
- package/dist/threads/execution-authority.js.map +1 -0
- package/dist/threads/execution-budget.d.ts +107 -0
- package/dist/threads/execution-budget.d.ts.map +1 -0
- package/dist/threads/execution-budget.js +257 -0
- package/dist/threads/execution-budget.js.map +1 -0
- package/dist/threads/execution-host.d.ts +17 -0
- package/dist/threads/execution-host.d.ts.map +1 -0
- package/dist/threads/execution-host.js +66 -0
- package/dist/threads/execution-host.js.map +1 -0
- package/dist/threads/execution-scheduler.d.ts +162 -0
- package/dist/threads/execution-scheduler.d.ts.map +1 -0
- package/dist/threads/execution-scheduler.js +413 -0
- package/dist/threads/execution-scheduler.js.map +1 -0
- package/dist/threads/execution-snapshot.d.ts +91 -0
- package/dist/threads/execution-snapshot.d.ts.map +1 -0
- package/dist/threads/execution-snapshot.js +146 -0
- package/dist/threads/execution-snapshot.js.map +1 -0
- package/dist/threads/execution-store.d.ts +374 -0
- package/dist/threads/execution-store.d.ts.map +1 -0
- package/dist/threads/execution-store.js +910 -0
- package/dist/threads/execution-store.js.map +1 -0
- package/dist/threads/execution-thread-error.d.ts +9 -0
- package/dist/threads/execution-thread-error.d.ts.map +1 -0
- package/dist/threads/execution-thread-error.js +12 -0
- package/dist/threads/execution-thread-error.js.map +1 -0
- package/dist/threads/executor-exit.d.ts +18 -0
- package/dist/threads/executor-exit.d.ts.map +1 -0
- package/dist/threads/executor-exit.js +21 -0
- package/dist/threads/executor-exit.js.map +1 -0
- package/dist/threads/foreground-task.d.ts +91 -0
- package/dist/threads/foreground-task.d.ts.map +1 -0
- package/dist/threads/foreground-task.js +191 -0
- package/dist/threads/foreground-task.js.map +1 -0
- package/dist/threads/foreman-business.d.ts +9 -0
- package/dist/threads/foreman-business.d.ts.map +1 -0
- package/dist/threads/foreman-business.js +117 -0
- package/dist/threads/foreman-business.js.map +1 -0
- package/dist/threads/foreman-client.d.ts +18 -0
- package/dist/threads/foreman-client.d.ts.map +1 -0
- package/dist/threads/foreman-client.js +51 -0
- package/dist/threads/foreman-client.js.map +1 -0
- package/dist/threads/foreman-delivery.d.ts +5 -0
- package/dist/threads/foreman-delivery.d.ts.map +1 -0
- package/dist/threads/foreman-delivery.js +21 -0
- package/dist/threads/foreman-delivery.js.map +1 -0
- package/dist/threads/foreman-execution.d.ts +32 -0
- package/dist/threads/foreman-execution.d.ts.map +1 -0
- package/dist/threads/foreman-execution.js +90 -0
- package/dist/threads/foreman-execution.js.map +1 -0
- package/dist/threads/foreman-host.d.ts +77 -0
- package/dist/threads/foreman-host.d.ts.map +1 -0
- package/dist/threads/foreman-host.js +891 -0
- package/dist/threads/foreman-host.js.map +1 -0
- package/dist/threads/foreman-protocol.d.ts +242 -0
- package/dist/threads/foreman-protocol.d.ts.map +1 -0
- package/dist/threads/foreman-protocol.js +116 -0
- package/dist/threads/foreman-protocol.js.map +1 -0
- package/dist/threads/foreman-store.d.ts +151 -0
- package/dist/threads/foreman-store.d.ts.map +1 -0
- package/dist/threads/foreman-store.js +299 -0
- package/dist/threads/foreman-store.js.map +1 -0
- package/dist/threads/generic-execution.d.ts +25 -0
- package/dist/threads/generic-execution.d.ts.map +1 -0
- package/dist/threads/generic-execution.js +86 -0
- package/dist/threads/generic-execution.js.map +1 -0
- package/dist/threads/init-thread-dir.d.ts +2 -2
- package/dist/threads/init-thread-dir.d.ts.map +1 -1
- package/dist/threads/init-thread-dir.js +6 -6
- package/dist/threads/init-thread-dir.js.map +1 -1
- package/dist/threads/ipc.d.ts +108 -2
- package/dist/threads/ipc.d.ts.map +1 -1
- package/dist/threads/ipc.js +14 -2
- package/dist/threads/ipc.js.map +1 -1
- package/dist/threads/lab-run-thread.d.ts +3 -5
- package/dist/threads/lab-run-thread.d.ts.map +1 -1
- package/dist/threads/lab-run-thread.js +3 -5
- package/dist/threads/lab-run-thread.js.map +1 -1
- package/dist/threads/lab-runtime-policy.d.ts +26 -21
- package/dist/threads/lab-runtime-policy.d.ts.map +1 -1
- package/dist/threads/lab-runtime-policy.js +31 -126
- package/dist/threads/lab-runtime-policy.js.map +1 -1
- package/dist/threads/process-group.d.ts +41 -0
- package/dist/threads/process-group.d.ts.map +1 -0
- package/dist/threads/process-group.js +161 -0
- package/dist/threads/process-group.js.map +1 -0
- package/dist/threads/relay-adapter.d.ts +8 -0
- package/dist/threads/relay-adapter.d.ts.map +1 -1
- package/dist/threads/relay-adapter.js +26 -1
- package/dist/threads/relay-adapter.js.map +1 -1
- package/dist/threads/supervisor.d.ts +191 -57
- package/dist/threads/supervisor.d.ts.map +1 -1
- package/dist/threads/supervisor.js +766 -427
- package/dist/threads/supervisor.js.map +1 -1
- package/dist/threads/task-workspace.d.ts +8 -0
- package/dist/threads/task-workspace.d.ts.map +1 -0
- package/dist/threads/task-workspace.js +52 -0
- package/dist/threads/task-workspace.js.map +1 -0
- package/dist/threads/worker-entry.d.ts.map +1 -1
- package/dist/threads/worker-entry.js +314 -34
- package/dist/threads/worker-entry.js.map +1 -1
- package/dist/threads/worker-execution-runtime.d.ts +75 -0
- package/dist/threads/worker-execution-runtime.d.ts.map +1 -0
- package/dist/threads/worker-execution-runtime.js +142 -0
- package/dist/threads/worker-execution-runtime.js.map +1 -0
- package/dist/threads/worker-execution.d.ts +35 -0
- package/dist/threads/worker-execution.d.ts.map +1 -0
- package/dist/threads/worker-execution.js +2 -0
- package/dist/threads/worker-execution.js.map +1 -0
- package/dist/threads/worker-runtime-policy.d.ts +42 -0
- package/dist/threads/worker-runtime-policy.d.ts.map +1 -0
- package/dist/threads/worker-runtime-policy.js +98 -0
- package/dist/threads/worker-runtime-policy.js.map +1 -0
- package/dist/tools/adapter-tool.d.ts +12 -0
- package/dist/tools/adapter-tool.d.ts.map +1 -0
- package/dist/tools/adapter-tool.js +2 -0
- package/dist/tools/adapter-tool.js.map +1 -0
- package/dist/tools/data-service.d.ts +2 -2
- package/dist/tools/delegation.d.ts +121 -0
- package/dist/tools/delegation.d.ts.map +1 -0
- package/dist/tools/delegation.js +106 -0
- package/dist/tools/delegation.js.map +1 -0
- package/dist/tools/dream-memory.d.ts +122 -0
- package/dist/tools/dream-memory.d.ts.map +1 -0
- package/dist/tools/dream-memory.js +513 -0
- package/dist/tools/dream-memory.js.map +1 -0
- package/dist/tools/email.d.ts +1 -1
- package/dist/tools/execution-control.d.ts +31 -0
- package/dist/tools/execution-control.d.ts.map +1 -0
- package/dist/tools/execution-control.js +71 -0
- package/dist/tools/execution-control.js.map +1 -0
- package/dist/tools/index.d.ts +5 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp-manager.d.ts +1 -1
- package/dist/tools/memory.d.ts +1 -1
- package/dist/tools/memory.d.ts.map +1 -1
- package/dist/tools/memory.js +69 -45
- package/dist/tools/memory.js.map +1 -1
- package/dist/tools/notify.d.ts +5 -0
- package/dist/tools/notify.d.ts.map +1 -1
- package/dist/tools/notify.js +45 -10
- package/dist/tools/notify.js.map +1 -1
- package/dist/tools/skill.d.ts +1 -1
- package/dist/tools/totp.d.ts +1 -1
- package/dist/tui/client.d.ts +1 -16
- package/dist/tui/client.d.ts.map +1 -1
- package/dist/tui/client.js +0 -4
- package/dist/tui/client.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -41
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/protocol.d.ts +2 -1
- package/dist/tui/protocol.d.ts.map +1 -1
- package/dist/tui/protocol.js +2 -1
- package/dist/tui/protocol.js.map +1 -1
- package/dist/tui/renderer.d.ts.map +1 -1
- package/dist/tui/renderer.js +0 -5
- package/dist/tui/renderer.js.map +1 -1
- package/dist/tui/request-store.d.ts +1 -1
- package/dist/tui/request-store.d.ts.map +1 -1
- package/dist/tui/request-store.js +2 -2
- package/dist/tui/request-store.js.map +1 -1
- package/dist/tui/server.d.ts.map +1 -1
- package/dist/tui/server.js +137 -25
- package/dist/tui/server.js.map +1 -1
- package/dist/utils/claude-transcripts.d.ts +6 -0
- package/dist/utils/claude-transcripts.d.ts.map +1 -1
- package/dist/utils/claude-transcripts.js +8 -2
- package/dist/utils/claude-transcripts.js.map +1 -1
- package/dist/utils/restart.d.ts.map +1 -1
- package/dist/utils/restart.js +6 -0
- package/dist/utils/restart.js.map +1 -1
- package/dist-agent/bundle.cjs +2 -2
- package/package.json +1 -1
- package/dist/agent/mailbox.d.ts +0 -50
- package/dist/agent/mailbox.d.ts.map +0 -1
- package/dist/agent/mailbox.js +0 -124
- package/dist/agent/mailbox.js.map +0 -1
- package/dist/agent/nightly-maintenance/memory-dreaming-sweep.d.ts +0 -77
- package/dist/agent/nightly-maintenance/memory-dreaming-sweep.d.ts.map +0 -1
- package/dist/agent/nightly-maintenance/memory-dreaming-sweep.js +0 -158
- package/dist/agent/nightly-maintenance/memory-dreaming-sweep.js.map +0 -1
- package/dist/agent/nightly-maintenance/memory-dreaming.d.ts +0 -116
- package/dist/agent/nightly-maintenance/memory-dreaming.d.ts.map +0 -1
- package/dist/agent/nightly-maintenance/memory-dreaming.js +0 -458
- package/dist/agent/nightly-maintenance/memory-dreaming.js.map +0 -1
- package/dist/threads/task-contracts.d.ts +0 -194
- package/dist/threads/task-contracts.d.ts.map +0 -1
- package/dist/threads/task-contracts.js +0 -82
- package/dist/threads/task-contracts.js.map +0 -1
- package/dist/threads/task-sidecar.d.ts +0 -145
- package/dist/threads/task-sidecar.d.ts.map +0 -1
- package/dist/threads/task-sidecar.js +0 -311
- package/dist/threads/task-sidecar.js.map +0 -1
- package/dist/threads/task-store.d.ts +0 -172
- package/dist/threads/task-store.d.ts.map +0 -1
- package/dist/threads/task-store.js +0 -599
- package/dist/threads/task-store.js.map +0 -1
- package/dist/threads/thread-task-context.d.ts +0 -40
- package/dist/threads/thread-task-context.d.ts.map +0 -1
- package/dist/threads/thread-task-context.js +0 -160
- package/dist/threads/thread-task-context.js.map +0 -1
- package/dist/threads/thread-task-controller.d.ts +0 -122
- package/dist/threads/thread-task-controller.d.ts.map +0 -1
- package/dist/threads/thread-task-controller.js +0 -276
- package/dist/threads/thread-task-controller.js.map +0 -1
- package/dist/threads/thread-task-runtime.d.ts +0 -354
- package/dist/threads/thread-task-runtime.d.ts.map +0 -1
- package/dist/threads/thread-task-runtime.js +0 -917
- package/dist/threads/thread-task-runtime.js.map +0 -1
- package/dist/tools/switch-session.d.ts +0 -15
- package/dist/tools/switch-session.d.ts.map +0 -1
- package/dist/tools/switch-session.js +0 -88
- package/dist/tools/switch-session.js.map +0 -1
- package/dist/tools/thread-tasks.d.ts +0 -23
- package/dist/tools/thread-tasks.d.ts.map +0 -1
- package/dist/tools/thread-tasks.js +0 -122
- package/dist/tools/thread-tasks.js.map +0 -1
|
@@ -4,7 +4,7 @@ import crypto from "crypto";
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { configuredRuntimeApplicationId } from "../../../config/application-config.js";
|
|
7
|
-
import { getConfigDir, getSkillsDir,
|
|
7
|
+
import { getConfigDir, getSkillsDir, loadSessionId, loadUsageSnapshot, saveSessionId, saveUsageSnapshot } from "../../../config/index.js";
|
|
8
8
|
import { isGeminiEnabled, isTunnelEnabled, isWorkspaceEnabled } from "../../../config/types.js";
|
|
9
9
|
import { isFundLeaguePlayerRuntime } from "../../fund-league/core-contract.js";
|
|
10
10
|
import { logger } from "../../../logger.js";
|
|
@@ -14,13 +14,12 @@ import { COMPACTION_ABORT_RESTART_GRACE_MS, DEFAULT_COMPACTION_TIMEOUT_MS, COMPA
|
|
|
14
14
|
import { logSystemPrompt } from "../system-prompt-log.js";
|
|
15
15
|
import { resolvePiModel } from "../pi/shared/model.js";
|
|
16
16
|
import { resolvePiCompactionSettings, resolvePiMaxBase64ImageBlocks, } from "../pi/shared/context-window.js";
|
|
17
|
-
import { getEffectiveRoute, getLlmEffort } from "../../model-provider.js";
|
|
17
|
+
import { getEffectiveRoute, getLlmEffort, pinnedModelApplies } from "../../model-provider.js";
|
|
18
18
|
import { createLlmGatewayAttemptBinder, isLlmGatewayProvider, } from "../../llm-gateway-request-id.js";
|
|
19
19
|
import { needsGatewayResponsesSanitizer, sanitizeGrokResponsesPayload } from "./grok-responses-payload.js";
|
|
20
20
|
import { convertPiAgentEventToStreamMessages } from "../pi/shared/event-converter.js";
|
|
21
21
|
import { buildPiResultMessage, capturePiMessageUsage, createPiUsageAccumulator } from "../pi/shared/usage.js";
|
|
22
22
|
import { createPiCodingCustomTools } from "./tools.js";
|
|
23
|
-
import { isLabRunThreadId } from "../../../threads/lab-run-thread.js";
|
|
24
23
|
import { pruneSessionImages, sanitizeTranscript } from "../../image-pruner.js";
|
|
25
24
|
import { deriveArchivePath, trimTranscriptAfterCompaction } from "../../session-trimmer.js";
|
|
26
25
|
import { writePiMcpConfig } from "./mcp-config.js";
|
|
@@ -28,9 +27,10 @@ import { getMcpScriptRuntimeStatus } from "./mcp-script-runtime.js";
|
|
|
28
27
|
import { ensureBrowserForTool, isPlaywrightToolName } from "../browser-tool-policy.js";
|
|
29
28
|
import { sanitizeToolSchemasInPayload } from "./tool-schema-sanitizer.js";
|
|
30
29
|
import { getAgentState } from "../../state.js";
|
|
31
|
-
import {
|
|
30
|
+
import { resolvePiWorkerToolNames } from "../../../threads/worker-runtime-policy.js";
|
|
31
|
+
import { getWorkerExecutionRuntime } from "../../../threads/worker-execution-runtime.js";
|
|
32
|
+
import { getForegroundTaskTracker } from "../../../threads/foreground-task.js";
|
|
32
33
|
import { CompactionFailureError } from "../../compaction-failure.js";
|
|
33
|
-
import { buildThreadTaskContext } from "../../../threads/thread-task-runtime.js";
|
|
34
34
|
import { ToolOutputGuard } from "../../tool-output-cap.js";
|
|
35
35
|
import { repairTranscriptToolOutputs } from "../../transcript-output-repair.js";
|
|
36
36
|
import { guardPiToolResult } from "../pi/tools.js";
|
|
@@ -40,15 +40,20 @@ const MAX_TURNS = 100;
|
|
|
40
40
|
const PI_ABORT_TIMEOUT_MS = 5_000;
|
|
41
41
|
/** Budget for pi-mcp-adapter to close its stdio children on session_shutdown. */
|
|
42
42
|
const MCP_SHUTDOWN_TIMEOUT_MS = 8_000;
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Pi state lives under `<profile>/pi-agent/general`. The directory name is
|
|
45
|
+
* kept from the dual-session layout so existing transcripts still resume;
|
|
46
|
+
* `pi-agent/coding` is no longer read.
|
|
47
|
+
*/
|
|
48
|
+
const PI_AGENT_DIR_NAME = "general";
|
|
49
|
+
async function loadMcpAdapter(configPath) {
|
|
44
50
|
const module = await import("pi-mcp-adapter");
|
|
45
|
-
return module.
|
|
51
|
+
return module.createMcpAdapter({ configPath });
|
|
46
52
|
}
|
|
47
53
|
export class PiCodingAgentSession {
|
|
48
54
|
config;
|
|
49
55
|
buildSystemPrompt;
|
|
50
56
|
runtimeSurface;
|
|
51
|
-
getDualSessionEnabled;
|
|
52
57
|
agentDir;
|
|
53
58
|
sessionDir;
|
|
54
59
|
workspaceCwd;
|
|
@@ -63,6 +68,8 @@ export class PiCodingAgentSession {
|
|
|
63
68
|
_screenshotInjector = null;
|
|
64
69
|
inputClosed = true;
|
|
65
70
|
stopRequested = false;
|
|
71
|
+
/** Set only by `agent_settled`, the event that means the SDK will not continue. */
|
|
72
|
+
barrierConfirmed = false;
|
|
66
73
|
lastUsageSnapshot = null;
|
|
67
74
|
sessionId;
|
|
68
75
|
orphanedInjections = 0;
|
|
@@ -75,26 +82,23 @@ export class PiCodingAgentSession {
|
|
|
75
82
|
sessionRelease = Promise.resolve();
|
|
76
83
|
/** In-flight createSession(); its adapter children exist before `this.session` is set. */
|
|
77
84
|
sessionCreation = null;
|
|
78
|
-
mode;
|
|
79
85
|
set screenshotInjector(injector) {
|
|
80
86
|
this._screenshotInjector = injector;
|
|
81
87
|
}
|
|
82
|
-
constructor({ config, buildSystemPrompt, runtimeSurface,
|
|
88
|
+
constructor({ config, buildSystemPrompt, runtimeSurface, workspaceCwd, }) {
|
|
83
89
|
this.config = config;
|
|
84
90
|
this.buildSystemPrompt = buildSystemPrompt;
|
|
85
91
|
this.runtimeSurface = runtimeSurface;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (runtimeSurface.labRuntimePolicy && !workspaceCwd) {
|
|
89
|
-
throw new Error("Pi policy-isolated Lab sessions require a workspace cwd");
|
|
92
|
+
if (runtimeSurface.workerRuntimePolicy && !workspaceCwd) {
|
|
93
|
+
throw new Error("Pi policy-isolated worker sessions require a workspace cwd");
|
|
90
94
|
}
|
|
91
95
|
this.workspaceCwd = workspaceCwd ?? getConfigDir();
|
|
92
|
-
this.agentDir = path.join(getConfigDir(), "pi-agent",
|
|
96
|
+
this.agentDir = path.join(getConfigDir(), "pi-agent", PI_AGENT_DIR_NAME);
|
|
93
97
|
this.sessionDir = path.join(this.agentDir, "sessions");
|
|
94
|
-
const persistedSessionId = loadSessionId(
|
|
98
|
+
const persistedSessionId = loadSessionId();
|
|
95
99
|
this.sessionId = persistedSessionId ?? createSessionId();
|
|
96
|
-
saveSessionId(this.sessionId
|
|
97
|
-
const persistedUsage = loadUsageSnapshot(
|
|
100
|
+
saveSessionId(this.sessionId);
|
|
101
|
+
const persistedUsage = loadUsageSnapshot();
|
|
98
102
|
if (persistedUsage) {
|
|
99
103
|
this.lastUsageSnapshot = { ...persistedUsage, capturedAtMs: Date.now() };
|
|
100
104
|
}
|
|
@@ -125,6 +129,7 @@ export class PiCodingAgentSession {
|
|
|
125
129
|
logSystemPrompt(systemPrompt);
|
|
126
130
|
this.inputClosed = false;
|
|
127
131
|
this.stopRequested = false;
|
|
132
|
+
this.barrierConfirmed = false;
|
|
128
133
|
this.orphanedInjections = 0;
|
|
129
134
|
return this.streamMessages(content, systemPrompt, options?.effort);
|
|
130
135
|
}
|
|
@@ -167,6 +172,9 @@ export class PiCodingAgentSession {
|
|
|
167
172
|
isStopRequested() {
|
|
168
173
|
return this.stopRequested;
|
|
169
174
|
}
|
|
175
|
+
executionBarrierConfirmed() {
|
|
176
|
+
return this.barrierConfirmed;
|
|
177
|
+
}
|
|
170
178
|
captureSessionId(_id) {
|
|
171
179
|
// Pi Coding Agent owns its session id through SessionManager.
|
|
172
180
|
}
|
|
@@ -174,7 +182,7 @@ export class PiCodingAgentSession {
|
|
|
174
182
|
if (snapshot.contextWindow <= 0)
|
|
175
183
|
return;
|
|
176
184
|
this.lastUsageSnapshot = { ...snapshot, capturedAtMs: Date.now() };
|
|
177
|
-
saveUsageSnapshot(snapshot
|
|
185
|
+
saveUsageSnapshot(snapshot);
|
|
178
186
|
}
|
|
179
187
|
capturePostCompactionSnapshot(postCompactionTokens) {
|
|
180
188
|
const contextWindow = this.lastUsageSnapshot?.contextWindow ?? 0;
|
|
@@ -217,7 +225,7 @@ export class PiCodingAgentSession {
|
|
|
217
225
|
void activeSession.abort().catch((err) => {
|
|
218
226
|
logger.warn(`[pi-coding-session] Compaction abort failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
219
227
|
});
|
|
220
|
-
restartFallback.disarm ??= armContextActionRestartFallback(
|
|
228
|
+
restartFallback.disarm ??= armContextActionRestartFallback("context compaction abort (pi-coding)", COMPACTION_ABORT_RESTART_GRACE_MS);
|
|
221
229
|
}, DEFAULT_COMPACTION_TIMEOUT_MS);
|
|
222
230
|
try {
|
|
223
231
|
await activeSession.compact();
|
|
@@ -242,7 +250,7 @@ export class PiCodingAgentSession {
|
|
|
242
250
|
this.currentRuntimeFingerprint = null;
|
|
243
251
|
this.pendingResetSummary = summary ?? null;
|
|
244
252
|
this.sessionId = createSessionId();
|
|
245
|
-
saveSessionId(this.sessionId
|
|
253
|
+
saveSessionId(this.sessionId);
|
|
246
254
|
}
|
|
247
255
|
injectSummary(summary) {
|
|
248
256
|
this.disposeCurrentSession();
|
|
@@ -347,7 +355,7 @@ export class PiCodingAgentSession {
|
|
|
347
355
|
if (!transcriptPath || !fs.existsSync(transcriptPath))
|
|
348
356
|
return false;
|
|
349
357
|
if (this.session)
|
|
350
|
-
await awaitSdkSettled(this.session,
|
|
358
|
+
await awaitSdkSettled(this.session, "pi-coding");
|
|
351
359
|
// Prepare changes on a private copy. Keep an unchanged, idle SDK instance
|
|
352
360
|
// reusable; if maintenance changes anything, release it BEFORE the atomic
|
|
353
361
|
// commit. Only a new SessionManager may load the repaired transcript.
|
|
@@ -395,7 +403,7 @@ export class PiCodingAgentSession {
|
|
|
395
403
|
getMcpServers() {
|
|
396
404
|
return {
|
|
397
405
|
...this.runtimeSurface.externalMcpServers,
|
|
398
|
-
...(this.runtimeSurface.
|
|
406
|
+
...(this.runtimeSurface.workerRuntimePolicy ? {} : this.dynamicMcpServers),
|
|
399
407
|
};
|
|
400
408
|
}
|
|
401
409
|
getMcpFingerprint() {
|
|
@@ -411,13 +419,11 @@ export class PiCodingAgentSession {
|
|
|
411
419
|
baseUrl: model.baseUrl,
|
|
412
420
|
reasoning: model.reasoning,
|
|
413
421
|
contextWindow: model.contextWindow,
|
|
414
|
-
dualSession: this.getDualSessionEnabled(),
|
|
415
422
|
});
|
|
416
423
|
}
|
|
417
424
|
prepareMcpConfig() {
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
process.env.PI_CODING_AGENT_DIR = this.agentDir;
|
|
425
|
+
// Each SDK session receives its own explicit configuration path. Changing
|
|
426
|
+
// a process environment variable would race other foreground conversations.
|
|
421
427
|
writePiMcpConfig({
|
|
422
428
|
agentDir: this.agentDir,
|
|
423
429
|
servers: this.getMcpServers(),
|
|
@@ -473,7 +479,7 @@ export class PiCodingAgentSession {
|
|
|
473
479
|
const mcpFingerprint = this.prepareMcpConfig();
|
|
474
480
|
const { model, apiKey } = resolvePiModel(this.config, { useCase: "main_coding" });
|
|
475
481
|
const runtimeFingerprint = this.getRuntimeFingerprint(model);
|
|
476
|
-
const tierEffort = getLlmEffort(this.config,
|
|
482
|
+
const tierEffort = getLlmEffort(this.config, "main_general");
|
|
477
483
|
const thinkingLevel = resolveThinkingLevel(model, effort ?? tierEffort);
|
|
478
484
|
if (this.session &&
|
|
479
485
|
this.currentSystemPrompt === renderedSystemPrompt &&
|
|
@@ -525,20 +531,20 @@ export class PiCodingAgentSession {
|
|
|
525
531
|
}),
|
|
526
532
|
});
|
|
527
533
|
const sessionManager = this.getSessionManager();
|
|
528
|
-
const mcpAdapter = await loadMcpAdapter();
|
|
534
|
+
const mcpAdapter = await loadMcpAdapter(path.join(this.agentDir, "mcp-adapter.json"));
|
|
529
535
|
const profileDir = getConfigDir();
|
|
530
|
-
const
|
|
536
|
+
const workerPolicy = this.runtimeSurface.workerRuntimePolicy?.policy;
|
|
531
537
|
// Share the Claude `.claude/skills` directory so PiCodingAgentSession and
|
|
532
538
|
// ClaudeAgentSession see the same set of skills (installed by
|
|
533
539
|
// `installBuiltinSkills()` and the `skill` tool). Also use the profile
|
|
534
540
|
// directory as the Pi resource-loader `agentDir` and enable context-file
|
|
535
541
|
// loading so GPT/Pi sessions pick up profile-level CLAUDE.md/AGENTS.md in
|
|
536
542
|
// the same profile cwd that Claude Code sees.
|
|
537
|
-
const skillsDir =
|
|
543
|
+
const skillsDir = workerPolicy
|
|
538
544
|
? path.join(getConfigDir(), ".claude", "skills")
|
|
539
545
|
: getSkillsDir();
|
|
540
|
-
const allowedSkills = new Set(
|
|
541
|
-
const additionalSkillPaths =
|
|
546
|
+
const allowedSkills = new Set(workerPolicy?.skills.allowed ?? []);
|
|
547
|
+
const additionalSkillPaths = workerPolicy
|
|
542
548
|
? (fs.existsSync(skillsDir)
|
|
543
549
|
? fs.readdirSync(skillsDir, { withFileTypes: true })
|
|
544
550
|
.filter((entry) => entry.isDirectory() && allowedSkills.has(entry.name))
|
|
@@ -551,26 +557,26 @@ export class PiCodingAgentSession {
|
|
|
551
557
|
settingsManager,
|
|
552
558
|
extensionFactories: [mcpAdapter, this.createVisionClawRuntimeExtension()],
|
|
553
559
|
additionalSkillPaths,
|
|
554
|
-
|
|
560
|
+
// Disable automatic resource discovery while retaining the host's explicit
|
|
561
|
+
// skills and inline extensions. A nonempty skill allowlist must not reopen
|
|
562
|
+
// the SDK's global/profile/project default skill directories.
|
|
563
|
+
noSkills: workerPolicy !== undefined,
|
|
564
|
+
noExtensions: workerPolicy !== undefined,
|
|
555
565
|
noPromptTemplates: true,
|
|
556
566
|
noThemes: true,
|
|
557
|
-
noContextFiles:
|
|
567
|
+
noContextFiles: workerPolicy !== undefined,
|
|
568
|
+
...(workerPolicy ? { appendSystemPrompt: [] } : {}),
|
|
558
569
|
systemPrompt: renderedSystemPrompt,
|
|
559
570
|
});
|
|
560
571
|
await loader.reload();
|
|
561
572
|
const customTools = createPiCodingCustomTools({
|
|
562
|
-
dualSession: labPolicy ? false : this.getDualSessionEnabled(),
|
|
563
|
-
mode: this.mode,
|
|
564
573
|
workspaceEnabled: isWorkspaceEnabled(this.config),
|
|
565
574
|
geminiEnabled: isGeminiEnabled(this.config),
|
|
566
575
|
tunnelEnabled: isTunnelEnabled(this.config),
|
|
567
576
|
desktopEnabled: this.runtimeSurface.desktop.available,
|
|
568
577
|
eventTriggerEnabled: this.runtimeSurface.credentialBacked.eventTrigger,
|
|
569
|
-
finAppEnabled: this.runtimeSurface.credentialBacked.finApp,
|
|
570
578
|
referenceDataEnabled: this.runtimeSurface.credentialBacked.financialTool,
|
|
571
|
-
|
|
572
|
-
? labPolicy.tools.allowed.some((name) => name === "query_market_data" || name === "lab_run_control")
|
|
573
|
-
: isLabRunThreadId(getWorkerThreadId()),
|
|
579
|
+
adapterTools: this.runtimeSurface.adapterTools,
|
|
574
580
|
// A league player is identified by the credentials it actually holds, not
|
|
575
581
|
// by an env var the provisioner may not have set: claimed pool hosts run
|
|
576
582
|
// from a systemd unit that never gets VISIONCLAW_APPLICATION_ID, which
|
|
@@ -579,7 +585,7 @@ export class PiCodingAgentSession {
|
|
|
579
585
|
// wins where the runtime is explicitly pinned.
|
|
580
586
|
fundLeagueEnabled: isFundLeaguePlayerRuntime()
|
|
581
587
|
|| configuredRuntimeApplicationId() === "ai-fund",
|
|
582
|
-
allowedToolNames:
|
|
588
|
+
allowedToolNames: workerPolicy?.tools.allowed,
|
|
583
589
|
workspaceCwd: this.workspaceCwd,
|
|
584
590
|
});
|
|
585
591
|
const { session } = await createAgentSession({
|
|
@@ -599,11 +605,11 @@ export class PiCodingAgentSession {
|
|
|
599
605
|
});
|
|
600
606
|
try {
|
|
601
607
|
await session.bindExtensions({});
|
|
602
|
-
if (
|
|
603
|
-
const allowed = new Set(
|
|
608
|
+
if (workerPolicy) {
|
|
609
|
+
const allowed = new Set(resolvePiWorkerToolNames(workerPolicy.tools.allowed));
|
|
604
610
|
const mcpTools = session.getAllTools()
|
|
605
611
|
.map((tool) => tool.name)
|
|
606
|
-
.filter((name) => Object.keys(
|
|
612
|
+
.filter((name) => Object.keys(workerPolicy.mcp.staticServers)
|
|
607
613
|
.some((server) => name.startsWith(`${server}__`)));
|
|
608
614
|
session.setActiveToolsByName([...allowed, ...mcpTools]);
|
|
609
615
|
}
|
|
@@ -621,7 +627,7 @@ export class PiCodingAgentSession {
|
|
|
621
627
|
this.currentMcpFingerprint = mcpFingerprint;
|
|
622
628
|
this.currentRuntimeFingerprint = runtimeFingerprint;
|
|
623
629
|
this.session = session;
|
|
624
|
-
saveSessionId(this.sessionId
|
|
630
|
+
saveSessionId(this.sessionId);
|
|
625
631
|
this.logLoadedResources(session, "create", mcpFingerprint, this.sessionOpenMode);
|
|
626
632
|
return session;
|
|
627
633
|
}
|
|
@@ -714,7 +720,8 @@ export class PiCodingAgentSession {
|
|
|
714
720
|
// gpt/claude paths are known-good and stay byte-identical.
|
|
715
721
|
pi.on("before_provider_request", (event) => {
|
|
716
722
|
let payload = event.payload;
|
|
717
|
-
|
|
723
|
+
// Same predicate as the model id: a frozen execution keeps its admitted pin.
|
|
724
|
+
if (pinnedModelApplies(this.config)) {
|
|
718
725
|
payload = sanitizeToolSchemasInPayload(payload);
|
|
719
726
|
}
|
|
720
727
|
// Grok and DeepSeek: hoist tool-result screenshots onto a user message
|
|
@@ -726,14 +733,32 @@ export class PiCodingAgentSession {
|
|
|
726
733
|
});
|
|
727
734
|
pi.on("tool_result", (event) => guardPiToolResult(event, this.toolOutputGuard));
|
|
728
735
|
pi.on("tool_call", async (event) => {
|
|
736
|
+
// Every call that reaches execution is counted, each call of a batch
|
|
737
|
+
// separately; once exhausted no further tool starts.
|
|
738
|
+
const refusal = this.runtimeSurface.executionBudget?.beforeToolCall();
|
|
739
|
+
if (refusal)
|
|
740
|
+
return { block: true, reason: refusal };
|
|
741
|
+
// Foreman: the foreground limit of a conversational task, checked
|
|
742
|
+
// before the call starts. A refused call never ran and is not counted.
|
|
743
|
+
const foreground = this.runtimeSurface.workerRuntimePolicy
|
|
744
|
+
? undefined
|
|
745
|
+
: getForegroundTaskTracker()?.admit(event.toolName);
|
|
746
|
+
if (foreground && !foreground.allowed)
|
|
747
|
+
return { block: true, reason: foreground.reason };
|
|
748
|
+
getWorkerExecutionRuntime()?.toolBoundary(event.toolCallId, event.toolName, "started");
|
|
729
749
|
const browserToolName = getBrowserToolName(event);
|
|
730
750
|
if (!browserToolName || !this.runtimeSurface.browser.available)
|
|
731
751
|
return {};
|
|
732
|
-
await ensureBrowserForTool({
|
|
752
|
+
const gate = await ensureBrowserForTool({
|
|
733
753
|
toolName: browserToolName,
|
|
734
754
|
config: this.config,
|
|
735
755
|
});
|
|
736
|
-
|
|
756
|
+
if (gate.proceed)
|
|
757
|
+
return {};
|
|
758
|
+
return {
|
|
759
|
+
block: true,
|
|
760
|
+
reason: gate.reason ?? "The selected browser did not open its debugging port.",
|
|
761
|
+
};
|
|
737
762
|
});
|
|
738
763
|
};
|
|
739
764
|
}
|
|
@@ -768,7 +793,6 @@ export class PiCodingAgentSession {
|
|
|
768
793
|
subtype: "init",
|
|
769
794
|
session_id: session.sessionId,
|
|
770
795
|
model: piModel.id,
|
|
771
|
-
mode: this.mode,
|
|
772
796
|
open_mode: this.sessionOpenMode,
|
|
773
797
|
mcp_servers: Object.keys(this.getMcpServers()).sort().map((name) => ({ name, status: "connected" })),
|
|
774
798
|
};
|
|
@@ -787,7 +811,7 @@ export class PiCodingAgentSession {
|
|
|
787
811
|
// started was still active — the very collision this barrier prevents.
|
|
788
812
|
// Waiting for idle first guarantees the listener below only ever observes
|
|
789
813
|
// events belonging to the run this call starts.
|
|
790
|
-
await awaitSdkSettled(session,
|
|
814
|
+
await awaitSdkSettled(session, "pi-coding");
|
|
791
815
|
const eventQueue = [];
|
|
792
816
|
let resolveWaiting = null;
|
|
793
817
|
let done = false;
|
|
@@ -795,6 +819,8 @@ export class PiCodingAgentSession {
|
|
|
795
819
|
const isDone = () => done;
|
|
796
820
|
const usage = createPiUsageAccumulator();
|
|
797
821
|
let turnCount = 0;
|
|
822
|
+
const budget = this.runtimeSurface.executionBudget;
|
|
823
|
+
budget?.assertRunning();
|
|
798
824
|
const compactionTrim = { needed: false };
|
|
799
825
|
let compactionFailure = null;
|
|
800
826
|
let unsubscribed = false;
|
|
@@ -808,8 +834,38 @@ export class PiCodingAgentSession {
|
|
|
808
834
|
const msg = event.message;
|
|
809
835
|
capturePiMessageUsage(usage, msg);
|
|
810
836
|
}
|
|
837
|
+
if (event.type === "turn_start" && budget) {
|
|
838
|
+
// One Pi turn is one model attempt; retries start a new turn.
|
|
839
|
+
try {
|
|
840
|
+
budget.beginModelAttempt();
|
|
841
|
+
}
|
|
842
|
+
catch {
|
|
843
|
+
// The meter latched and asked the host to stop; abort this run now.
|
|
844
|
+
}
|
|
845
|
+
if (budget.stopReason) {
|
|
846
|
+
session.abort().catch((err) => {
|
|
847
|
+
logger.warn(`[pi-coding-session] Abort failed after budget exhaustion: ${err instanceof Error ? err.message : String(err)}`);
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
}
|
|
811
851
|
if (event.type === "turn_end") {
|
|
812
852
|
turnCount++;
|
|
853
|
+
if (budget) {
|
|
854
|
+
const ended = event.message;
|
|
855
|
+
if (ended?.role === "assistant" && (ended.stopReason === "error" || ended.stopReason === "aborted")) {
|
|
856
|
+
budget.recordFailedModelAttempt();
|
|
857
|
+
}
|
|
858
|
+
if (ended?.usage)
|
|
859
|
+
budget.recordTokens(ended.usage.input, ended.usage.output);
|
|
860
|
+
// A tool-use turn needs one more attempt to read its results; with
|
|
861
|
+
// none left, stop now instead of starting a turn that is refused.
|
|
862
|
+
if (ended?.stopReason === "toolUse" && budget.stopBeforeNextAttempt()) {
|
|
863
|
+
session.abort().catch((err) => {
|
|
864
|
+
logger.warn(`[pi-coding-session] Abort failed after budget exhaustion: ${err instanceof Error ? err.message : String(err)}`);
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
// The SDK per-send cap stays as an extra guard; the task budget is authoritative.
|
|
813
869
|
if (turnCount >= MAX_TURNS) {
|
|
814
870
|
session.abort().catch((err) => {
|
|
815
871
|
logger.warn(`[pi-coding-session] Abort failed after max turns: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -821,19 +877,6 @@ export class PiCodingAgentSession {
|
|
|
821
877
|
this.capturePostCompactionSnapshot(estimatePostCompactionTokens(event.result.summary));
|
|
822
878
|
compactionTrim.needed = true;
|
|
823
879
|
compactionFailure = null;
|
|
824
|
-
// The summary replaced the transcript; re-inject the thread's tasks
|
|
825
|
-
// and checkpoints when the run continues on it (#1996), the role of
|
|
826
|
-
// the Claude engine's SessionStart(compact) hook. A threshold
|
|
827
|
-
// compaction ends the run; steering then would force an extra turn,
|
|
828
|
-
// and the next wake or session switch carries the block anyway.
|
|
829
|
-
// TODO: an in-wake continuation send after a threshold compaction,
|
|
830
|
-
// an overflow compaction that stops instead of retrying, or a manual
|
|
831
|
-
// compaction goes without the block until the next wake or switch.
|
|
832
|
-
// This block is also not reconciled first (this subscriber is
|
|
833
|
-
// synchronous); it shows the latest commit plus unfolded results.
|
|
834
|
-
const threadTaskBlock = event.willRetry ? buildThreadTaskContext() : null;
|
|
835
|
-
if (threadTaskBlock)
|
|
836
|
-
this.injectMessage([{ type: "text", text: threadTaskBlock }]);
|
|
837
880
|
}
|
|
838
881
|
else if (!event.aborted && !event.willRetry && event.errorMessage) {
|
|
839
882
|
const errorCode = extractCompactionErrorCode(event.errorMessage);
|
|
@@ -852,6 +895,11 @@ export class PiCodingAgentSession {
|
|
|
852
895
|
}
|
|
853
896
|
}
|
|
854
897
|
if (event.type === "tool_execution_end") {
|
|
898
|
+
if (budget && event.isError)
|
|
899
|
+
budget.recordToolFailure();
|
|
900
|
+
const ended = event;
|
|
901
|
+
if (ended.toolCallId)
|
|
902
|
+
getWorkerExecutionRuntime()?.toolBoundary(ended.toolCallId, ended.toolName ?? "unknown", "finished");
|
|
855
903
|
// TODO: detect MCP-proxied Playwright browser actions when Pi reports them through the generic mcp tool name.
|
|
856
904
|
const toolName = event.toolName;
|
|
857
905
|
if (toolName && this._screenshotInjector) {
|
|
@@ -878,6 +926,7 @@ export class PiCodingAgentSession {
|
|
|
878
926
|
// `_isAgentRunActive` BEFORE emitting it, so by the time we observe
|
|
879
927
|
// this the next send can no longer collide.
|
|
880
928
|
this.inputClosed = true;
|
|
929
|
+
this.barrierConfirmed = true;
|
|
881
930
|
done = true;
|
|
882
931
|
resolveWaiting?.();
|
|
883
932
|
}
|
|
@@ -887,7 +936,7 @@ export class PiCodingAgentSession {
|
|
|
887
936
|
resolveWaiting?.();
|
|
888
937
|
}
|
|
889
938
|
});
|
|
890
|
-
session.sendUserMessage(contentToPiContent(effectiveContent)).catch((err) => {
|
|
939
|
+
const sendPromise = session.sendUserMessage(contentToPiContent(effectiveContent)).catch((err) => {
|
|
891
940
|
runError = err;
|
|
892
941
|
done = true;
|
|
893
942
|
resolveWaiting?.();
|
|
@@ -904,6 +953,9 @@ export class PiCodingAgentSession {
|
|
|
904
953
|
await new Promise((r) => { resolveWaiting = r; });
|
|
905
954
|
resolveWaiting = null;
|
|
906
955
|
}
|
|
956
|
+
// agent_settled is emitted from the SDK's finally block, before the
|
|
957
|
+
// send promise may reject. Include finalization failures in the result.
|
|
958
|
+
await sendPromise;
|
|
907
959
|
unsubscribe();
|
|
908
960
|
unsubscribed = true;
|
|
909
961
|
if (compactionTrim.needed) {
|
|
@@ -915,7 +967,7 @@ export class PiCodingAgentSession {
|
|
|
915
967
|
logger.warn(`[pi-coding-session] Post-compaction JSONL trim failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
916
968
|
}
|
|
917
969
|
}
|
|
918
|
-
const assistantError = usage.
|
|
970
|
+
const assistantError = usage.terminalAssistantError;
|
|
919
971
|
yield buildPiResultMessage({
|
|
920
972
|
error: runError ?? compactionFailure ?? (assistantError ? new Error(assistantError) : null),
|
|
921
973
|
inputTokens: usage.inputTokens,
|