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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/tools/delegation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GAEjB,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;GAQG;AAEH,SAAS,KAAK,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK;IAC1C,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,WAAW,GAAG,iEAAiE,CAAC;AAEtF,uFAAuF;AACvF,SAAS,cAAc,CAAC,eAA+B;IACrD,IAAI,KAAuC,CAAC;IAC5C,IAAI,CAAC;QAAC,KAAK,GAAG,aAAa,EAAE,CAAC;IAAC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from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { type MemoryStoreRoot } from "../agent/nightly-maintenance/dreaming-files.js";
|
|
4
|
+
import { type DreamingBatch, type DreamingReportData } from "../agent/nightly-maintenance/dreaming-batch.js";
|
|
5
|
+
/**
|
|
6
|
+
* The restricted memory capability of a Dreaming batch (#2805 stage 2).
|
|
7
|
+
*
|
|
8
|
+
* Not the conversational `memory` tool: Dreaming edits unattended, so every
|
|
9
|
+
* edit is bounded to what the model has actually read in this batch.
|
|
10
|
+
* - view is paginated (16 KB per response) and records the line ranges and
|
|
11
|
+
* content hash the model saw;
|
|
12
|
+
* - str_replace and insert require the touched lines to have been viewed at
|
|
13
|
+
* the file's current content; create refuses an existing path;
|
|
14
|
+
* - there is no delete or rename in this version, so an edit cannot remove a
|
|
15
|
+
* file or move content out of view;
|
|
16
|
+
* - every write goes through the shared memory-store path: store lock,
|
|
17
|
+
* version check, atomic replacement;
|
|
18
|
+
* - before a batch first changes a file, a backup of that content is kept;
|
|
19
|
+
* each edit appends local metadata (paths, hashes, line spans; no content).
|
|
20
|
+
*
|
|
21
|
+
* The protection is per edit, not per batch: a committed edit stays when the
|
|
22
|
+
* batch is preempted or runs out of budget. Hash-then-rename is not an atomic
|
|
23
|
+
* compare-and-swap against writers that bypass the memory store; such a
|
|
24
|
+
* change is detected at the next edit, not prevented.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DREAM_VIEW_MAX_BYTES = 16000;
|
|
27
|
+
export interface DreamingToolContext {
|
|
28
|
+
batch: DreamingBatch;
|
|
29
|
+
stores: MemoryStoreRoot[];
|
|
30
|
+
/** Ordinary memory root: the local edit log and backups live under its `.dream_log`. */
|
|
31
|
+
memoriesDir: string;
|
|
32
|
+
now?: () => Date;
|
|
33
|
+
}
|
|
34
|
+
/** Read and edit guard state for one batch, held by the worker process only. */
|
|
35
|
+
export declare class DreamingMemorySession {
|
|
36
|
+
private readonly context;
|
|
37
|
+
private readonly viewed;
|
|
38
|
+
private readonly backedUp;
|
|
39
|
+
/** Paths with at least one committed edit in this batch. */
|
|
40
|
+
private readonly touched;
|
|
41
|
+
private editSeq;
|
|
42
|
+
private report;
|
|
43
|
+
constructor(context: DreamingToolContext);
|
|
44
|
+
get reported(): DreamingReportData | null;
|
|
45
|
+
get editedPaths(): string[];
|
|
46
|
+
view(virtualPath: string, viewRange?: [number, number]): CallToolResult;
|
|
47
|
+
private renderPage;
|
|
48
|
+
private listDirectory;
|
|
49
|
+
private noteView;
|
|
50
|
+
private static isRangeViewed;
|
|
51
|
+
/** After an edit, keep coverage of known lines and shift later ones; unread lines never gain coverage. */
|
|
52
|
+
private refreshAfterEdit;
|
|
53
|
+
strReplace(virtualPath: string, oldStr: string, newStr: string): CallToolResult;
|
|
54
|
+
insert(virtualPath: string, insertLine: number, text: string): CallToolResult;
|
|
55
|
+
create(virtualPath: string, fileText: string): CallToolResult;
|
|
56
|
+
/**
|
|
57
|
+
* One version-checked edit under the store lock. The backup of the
|
|
58
|
+
* pre-batch content is written before the file is replaced; a failed
|
|
59
|
+
* backup leaves the file untouched.
|
|
60
|
+
*/
|
|
61
|
+
private edit;
|
|
62
|
+
private backupOnce;
|
|
63
|
+
private appendEdit;
|
|
64
|
+
/** The content hash of a file this batch has viewed in full at its current content; null otherwise. */
|
|
65
|
+
private fullyViewedHash;
|
|
66
|
+
private relativeOf;
|
|
67
|
+
/**
|
|
68
|
+
* Record the batch outcome once. Each vocabulary candidate is validated on
|
|
69
|
+
* its own: an invalid one, or one citing a source outside this batch, is
|
|
70
|
+
* dropped and counted, never echoed back. A file reported as reviewed
|
|
71
|
+
* (tidied or unchanged) must have been viewed in full at its current
|
|
72
|
+
* content; the report carries the hash it was reviewed at.
|
|
73
|
+
*/
|
|
74
|
+
submitReport(raw: {
|
|
75
|
+
ingestion?: {
|
|
76
|
+
status: "ingested" | "no_new_facts" | "not_done";
|
|
77
|
+
reason?: string;
|
|
78
|
+
};
|
|
79
|
+
files?: {
|
|
80
|
+
path: string;
|
|
81
|
+
status: "tidied" | "unchanged" | "not_done";
|
|
82
|
+
}[];
|
|
83
|
+
vocabularyCandidates?: unknown[];
|
|
84
|
+
}): CallToolResult;
|
|
85
|
+
}
|
|
86
|
+
export declare function installDreamingMemorySession(session: DreamingMemorySession | null): void;
|
|
87
|
+
export declare function getDreamingMemorySession(): DreamingMemorySession | null;
|
|
88
|
+
export declare const dreamMemoryTool: import("@anthropic-ai/claude-agent-sdk").SdkMcpToolDefinition<{
|
|
89
|
+
command: z.ZodEnum<{
|
|
90
|
+
create: "create";
|
|
91
|
+
view: "view";
|
|
92
|
+
str_replace: "str_replace";
|
|
93
|
+
insert: "insert";
|
|
94
|
+
}>;
|
|
95
|
+
path: z.ZodString;
|
|
96
|
+
view_range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
97
|
+
old_str: z.ZodOptional<z.ZodString>;
|
|
98
|
+
new_str: z.ZodOptional<z.ZodString>;
|
|
99
|
+
insert_line: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
insert_text: z.ZodOptional<z.ZodString>;
|
|
101
|
+
file_text: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}>;
|
|
103
|
+
export declare const dreamingReportTool: import("@anthropic-ai/claude-agent-sdk").SdkMcpToolDefinition<{
|
|
104
|
+
ingestion: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
status: z.ZodEnum<{
|
|
106
|
+
ingested: "ingested";
|
|
107
|
+
no_new_facts: "no_new_facts";
|
|
108
|
+
not_done: "not_done";
|
|
109
|
+
}>;
|
|
110
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
113
|
+
path: z.ZodString;
|
|
114
|
+
status: z.ZodEnum<{
|
|
115
|
+
unchanged: "unchanged";
|
|
116
|
+
not_done: "not_done";
|
|
117
|
+
tidied: "tidied";
|
|
118
|
+
}>;
|
|
119
|
+
}, z.core.$strip>>>;
|
|
120
|
+
vocabularyCandidates: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
121
|
+
}>;
|
|
122
|
+
//# sourceMappingURL=dream-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dream-memory.d.ts","sourceRoot":"","sources":["../../src/tools/dream-memory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAQzE,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAExB,MAAM,gDAAgD,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAc3C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AA6CD,gFAAgF;AAChF,qBAAa,qBAAqB;IAQpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,4DAA4D;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAAmC;gBAEpB,OAAO,EAAE,mBAAmB;IAEzD,IAAI,QAAQ,IAAI,kBAAkB,GAAG,IAAI,CAExC;IAED,IAAI,WAAW,IAAI,MAAM,EAAE,CAE1B;IAID,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAA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,CAAC"}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { tool } from "@anthropic-ai/claude-agent-sdk";
|
|
5
|
+
import { contentHash, editUnderLock, MemoryConflictError, replaceIfUnchanged, withMemoryLock, } from "../agent/memory-store.js";
|
|
6
|
+
import { dreamLogDir, isMemoryDirectoryRelative, isMemoryFileRelative, resolveMemoryPath, } from "../agent/nightly-maintenance/dreaming-files.js";
|
|
7
|
+
import { dreamEditsPath, DreamingReportDataSchema, VocabularyCandidateSchema, } from "../agent/nightly-maintenance/dreaming-batch.js";
|
|
8
|
+
import { getWorkerExecutionRuntime } from "../threads/worker-execution-runtime.js";
|
|
9
|
+
/**
|
|
10
|
+
* The restricted memory capability of a Dreaming batch (#2805 stage 2).
|
|
11
|
+
*
|
|
12
|
+
* Not the conversational `memory` tool: Dreaming edits unattended, so every
|
|
13
|
+
* edit is bounded to what the model has actually read in this batch.
|
|
14
|
+
* - view is paginated (16 KB per response) and records the line ranges and
|
|
15
|
+
* content hash the model saw;
|
|
16
|
+
* - str_replace and insert require the touched lines to have been viewed at
|
|
17
|
+
* the file's current content; create refuses an existing path;
|
|
18
|
+
* - there is no delete or rename in this version, so an edit cannot remove a
|
|
19
|
+
* file or move content out of view;
|
|
20
|
+
* - every write goes through the shared memory-store path: store lock,
|
|
21
|
+
* version check, atomic replacement;
|
|
22
|
+
* - before a batch first changes a file, a backup of that content is kept;
|
|
23
|
+
* each edit appends local metadata (paths, hashes, line spans; no content).
|
|
24
|
+
*
|
|
25
|
+
* The protection is per edit, not per batch: a committed edit stays when the
|
|
26
|
+
* batch is preempted or runs out of budget. Hash-then-rename is not an atomic
|
|
27
|
+
* compare-and-swap against writers that bypass the memory store; such a
|
|
28
|
+
* change is detected at the next edit, not prevented.
|
|
29
|
+
*/
|
|
30
|
+
export const DREAM_VIEW_MAX_BYTES = 16_000;
|
|
31
|
+
const MAX_FILE_LINES = 999_999;
|
|
32
|
+
function reply(text, isError = false) {
|
|
33
|
+
return { ...(isError ? { isError: true } : {}), content: [{ type: "text", text }] };
|
|
34
|
+
}
|
|
35
|
+
function lineCount(content) {
|
|
36
|
+
return content.split("\n").length;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Edit CRLF files as LF text and write them back with CRLF, so a model's
|
|
40
|
+
* LF-only old_str matches and inserted lines keep the file's line endings.
|
|
41
|
+
*/
|
|
42
|
+
function editLines(current, transform) {
|
|
43
|
+
const crlf = current.includes("\r\n");
|
|
44
|
+
const result = transform(crlf ? current.replace(/\r\n/g, "\n") : current);
|
|
45
|
+
return crlf && "content" in result ? { content: result.content.replace(/\r?\n/g, "\r\n") } : result;
|
|
46
|
+
}
|
|
47
|
+
/** A backup file name per memory path, without collisions between paths. */
|
|
48
|
+
function backupName(virtualPath) {
|
|
49
|
+
return encodeURIComponent(virtualPath.replace(/^\//, ""));
|
|
50
|
+
}
|
|
51
|
+
function isRegularFile(fullPath) {
|
|
52
|
+
try {
|
|
53
|
+
return fs.lstatSync(fullPath).isFile();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function splitLines(content) {
|
|
60
|
+
return content.replace(/\r\n/g, "\n").split("\n");
|
|
61
|
+
}
|
|
62
|
+
/** Tool error text. A file system error names host paths, so the model gets only its code. */
|
|
63
|
+
function errorText(error) {
|
|
64
|
+
if (error instanceof Error && typeof error.syscall === "string") {
|
|
65
|
+
return `The memory store could not complete this (${error.code ?? "error"})`;
|
|
66
|
+
}
|
|
67
|
+
return error instanceof Error ? error.message : String(error);
|
|
68
|
+
}
|
|
69
|
+
/** Read and edit guard state for one batch, held by the worker process only. */
|
|
70
|
+
export class DreamingMemorySession {
|
|
71
|
+
context;
|
|
72
|
+
viewed = new Map();
|
|
73
|
+
backedUp = new Set();
|
|
74
|
+
/** Paths with at least one committed edit in this batch. */
|
|
75
|
+
touched = new Set();
|
|
76
|
+
editSeq = 0;
|
|
77
|
+
report = null;
|
|
78
|
+
constructor(context) {
|
|
79
|
+
this.context = context;
|
|
80
|
+
}
|
|
81
|
+
get reported() {
|
|
82
|
+
return this.report;
|
|
83
|
+
}
|
|
84
|
+
get editedPaths() {
|
|
85
|
+
return [...this.touched];
|
|
86
|
+
}
|
|
87
|
+
// ------------------------------------------------------------------ view
|
|
88
|
+
view(virtualPath, viewRange) {
|
|
89
|
+
const relative = this.relativeOf(virtualPath.replace(/\/+$/, ""));
|
|
90
|
+
if (relative !== null && !isMemoryFileRelative(relative) && isMemoryDirectoryRelative(relative)) {
|
|
91
|
+
const directory = resolveMemoryPath(this.context.stores, virtualPath, "directory");
|
|
92
|
+
// A protected file has a directory-like path; the file check below refuses it by name.
|
|
93
|
+
if (!isRegularFile(directory.fullPath))
|
|
94
|
+
return this.listDirectory(directory);
|
|
95
|
+
}
|
|
96
|
+
const target = resolveMemoryPath(this.context.stores, virtualPath, "file");
|
|
97
|
+
let content;
|
|
98
|
+
try {
|
|
99
|
+
content = fs.readFileSync(target.fullPath, "utf8");
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (error.code === "ENOENT")
|
|
103
|
+
return reply(`${target.virtualPath} does not exist`, true);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
const lines = splitLines(content);
|
|
107
|
+
if (lines.length > MAX_FILE_LINES)
|
|
108
|
+
return reply(`${target.virtualPath} exceeds ${MAX_FILE_LINES} lines`, true);
|
|
109
|
+
const requestedStart = viewRange?.[0] ?? 1;
|
|
110
|
+
const requestedEnd = viewRange?.[1] ?? -1;
|
|
111
|
+
if (!Number.isInteger(requestedStart) || !Number.isInteger(requestedEnd)
|
|
112
|
+
|| requestedStart < 1 || (requestedEnd !== -1 && requestedEnd < 1)
|
|
113
|
+
|| (requestedEnd !== -1 && requestedEnd < requestedStart)) {
|
|
114
|
+
return reply(`Invalid view_range for ${target.virtualPath}; start at line 1 or later and use -1 for the end of the file.`, true);
|
|
115
|
+
}
|
|
116
|
+
const start = requestedStart;
|
|
117
|
+
const end = Math.min(lines.length, requestedEnd === -1 ? lines.length : requestedEnd);
|
|
118
|
+
if (start > lines.length)
|
|
119
|
+
return reply(`Line ${start} is beyond the end of ${target.virtualPath} (${lines.length} lines)`, true);
|
|
120
|
+
if (end < start)
|
|
121
|
+
return reply(`Invalid view_range for ${target.virtualPath}`, true);
|
|
122
|
+
// Fill the page greedily under the byte cap; only delivered lines count as viewed.
|
|
123
|
+
let page = null;
|
|
124
|
+
let last = start - 1;
|
|
125
|
+
for (let line = start; line <= end; line += 1) {
|
|
126
|
+
const candidate = this.renderPage(target.virtualPath, lines, start, line);
|
|
127
|
+
if (Buffer.byteLength(candidate, "utf8") > DREAM_VIEW_MAX_BYTES)
|
|
128
|
+
break;
|
|
129
|
+
page = candidate;
|
|
130
|
+
last = line;
|
|
131
|
+
}
|
|
132
|
+
if (page === null) {
|
|
133
|
+
return reply(`Line ${start} of ${target.virtualPath} is too long to show and has NOT been viewed; leave it unchanged.${start < lines.length ? ` Continue with view_range [${start + 1}, -1].` : ""}`, true);
|
|
134
|
+
}
|
|
135
|
+
this.noteView(target.virtualPath, content, start, last);
|
|
136
|
+
return reply(page);
|
|
137
|
+
}
|
|
138
|
+
renderPage(virtualPath, lines, start, last) {
|
|
139
|
+
return [
|
|
140
|
+
`${virtualPath} (lines ${start}-${last} of ${lines.length})`,
|
|
141
|
+
...lines.slice(start - 1, last).map((line, index) => `${String(start + index).padStart(6, " ")}\t${line}`),
|
|
142
|
+
last < lines.length ? `Next page: view_range [${last + 1}, -1].` : "End of file.",
|
|
143
|
+
].join("\n");
|
|
144
|
+
}
|
|
145
|
+
listDirectory(target) {
|
|
146
|
+
const rows = [];
|
|
147
|
+
const visit = (directory, prefix, depth) => {
|
|
148
|
+
let entries;
|
|
149
|
+
try {
|
|
150
|
+
entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error.code === "ENOENT")
|
|
154
|
+
return;
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
158
|
+
if (entry.isSymbolicLink())
|
|
159
|
+
continue;
|
|
160
|
+
const child = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
161
|
+
const relative = target.relative ? `${target.relative}/${child}` : child;
|
|
162
|
+
if (entry.isDirectory() && isMemoryDirectoryRelative(relative)) {
|
|
163
|
+
rows.push(`${target.virtualPath}/${child}/`);
|
|
164
|
+
if (depth < 2)
|
|
165
|
+
visit(path.join(directory, entry.name), child, depth + 1);
|
|
166
|
+
}
|
|
167
|
+
else if (entry.isFile() && isMemoryFileRelative(relative)) {
|
|
168
|
+
rows.push(`${fs.statSync(path.join(directory, entry.name)).size}\t${target.virtualPath}/${child}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
visit(target.fullPath, "", 1);
|
|
173
|
+
const kept = [`${target.virtualPath} (editable files up to 2 levels deep):`];
|
|
174
|
+
let bytes = Buffer.byteLength(kept[0], "utf8");
|
|
175
|
+
for (const [index, row] of rows.entries()) {
|
|
176
|
+
bytes += Buffer.byteLength(row, "utf8") + 1;
|
|
177
|
+
if (bytes > DREAM_VIEW_MAX_BYTES - 200) {
|
|
178
|
+
kept.push(`… ${rows.length - index} more entries; view a subdirectory to see them.`);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
kept.push(row);
|
|
182
|
+
}
|
|
183
|
+
return reply(kept.join("\n"));
|
|
184
|
+
}
|
|
185
|
+
noteView(virtualPath, content, start, end) {
|
|
186
|
+
const hash = contentHash(content);
|
|
187
|
+
const existing = this.viewed.get(virtualPath);
|
|
188
|
+
// Ranges seen at a different content never combine with the current ones.
|
|
189
|
+
if (existing?.hash !== hash) {
|
|
190
|
+
this.viewed.set(virtualPath, { hash, ranges: [[start, end]] });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
existing.ranges.push([start, end]);
|
|
194
|
+
}
|
|
195
|
+
static isRangeViewed(record, start, end) {
|
|
196
|
+
let covered = start - 1;
|
|
197
|
+
for (const [from, to] of [...record.ranges].sort((a, b) => a[0] - b[0])) {
|
|
198
|
+
if (from > covered + 1)
|
|
199
|
+
break;
|
|
200
|
+
covered = Math.max(covered, to);
|
|
201
|
+
}
|
|
202
|
+
return covered >= end;
|
|
203
|
+
}
|
|
204
|
+
/** After an edit, keep coverage of known lines and shift later ones; unread lines never gain coverage. */
|
|
205
|
+
refreshAfterEdit(virtualPath, before, newContent, span) {
|
|
206
|
+
const delta = span.newEnd - span.oldEnd;
|
|
207
|
+
const ranges = span.newEnd >= span.start ? [[span.start, span.newEnd]] : [];
|
|
208
|
+
for (const [from, to] of before.ranges) {
|
|
209
|
+
if (to < span.start)
|
|
210
|
+
ranges.push([from, to]);
|
|
211
|
+
else if (from > span.oldEnd)
|
|
212
|
+
ranges.push([from + delta, to + delta]);
|
|
213
|
+
else {
|
|
214
|
+
if (from < span.start)
|
|
215
|
+
ranges.push([from, span.start - 1]);
|
|
216
|
+
if (to > span.oldEnd)
|
|
217
|
+
ranges.push([span.newEnd + 1, to + delta]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
this.viewed.set(virtualPath, { hash: contentHash(newContent), ranges: ranges.filter(([from, to]) => from >= 1 && to >= from) });
|
|
221
|
+
}
|
|
222
|
+
// ----------------------------------------------------------------- edits
|
|
223
|
+
strReplace(virtualPath, oldStr, newStr) {
|
|
224
|
+
if (oldStr.length === 0)
|
|
225
|
+
return reply("old_str must not be empty", true);
|
|
226
|
+
const target = resolveMemoryPath(this.context.stores, virtualPath, "file");
|
|
227
|
+
const seen = this.viewed.get(target.virtualPath);
|
|
228
|
+
if (!seen)
|
|
229
|
+
return reply(`View ${target.virtualPath} before editing it`, true);
|
|
230
|
+
const span = { start: 0, oldEnd: 0, newEnd: 0 };
|
|
231
|
+
oldStr = oldStr.replace(/\r\n/g, "\n");
|
|
232
|
+
newStr = newStr.replace(/\r\n/g, "\n");
|
|
233
|
+
return this.edit(target, "str_replace", seen, span, (raw) => editLines(raw, (current) => {
|
|
234
|
+
const first = current.indexOf(oldStr);
|
|
235
|
+
if (first < 0)
|
|
236
|
+
return { refused: `old_str does not appear verbatim in ${target.virtualPath}` };
|
|
237
|
+
if (current.includes(oldStr, first + 1)) {
|
|
238
|
+
return { refused: `old_str appears more than once in ${target.virtualPath}; include more surrounding text` };
|
|
239
|
+
}
|
|
240
|
+
span.start = current.slice(0, first).split("\n").length;
|
|
241
|
+
span.oldEnd = span.start + lineCount(oldStr) - 1;
|
|
242
|
+
span.newEnd = span.start + lineCount(newStr) - 1;
|
|
243
|
+
if (!DreamingMemorySession.isRangeViewed(seen, span.start, span.oldEnd)) {
|
|
244
|
+
return { refused: `Lines ${span.start}-${span.oldEnd} of ${target.virtualPath} were not viewed; view them before editing` };
|
|
245
|
+
}
|
|
246
|
+
// A function replacement keeps `$&`/`$'` literal, so unread text cannot be copied in.
|
|
247
|
+
return { content: current.replace(oldStr, () => newStr) };
|
|
248
|
+
}), () => `Edited ${target.virtualPath} (now lines ${span.start}-${span.newEnd}).`);
|
|
249
|
+
}
|
|
250
|
+
insert(virtualPath, insertLine, text) {
|
|
251
|
+
const target = resolveMemoryPath(this.context.stores, virtualPath, "file");
|
|
252
|
+
const seen = this.viewed.get(target.virtualPath);
|
|
253
|
+
if (!seen)
|
|
254
|
+
return reply(`View ${target.virtualPath} before editing it`, true);
|
|
255
|
+
const inserted = text.replace(/\r\n/g, "\n").replace(/\n$/, "").split("\n");
|
|
256
|
+
const span = { start: insertLine + 1, oldEnd: insertLine, newEnd: insertLine + inserted.length };
|
|
257
|
+
return this.edit(target, "insert", seen, span, (raw) => editLines(raw, (current) => {
|
|
258
|
+
const lines = current.split("\n");
|
|
259
|
+
if (insertLine < 0 || insertLine > lines.length)
|
|
260
|
+
return { refused: `insert_line must be between 0 and ${lines.length}` };
|
|
261
|
+
// The insertion point must sit next to a line the model has read.
|
|
262
|
+
const anchor = Math.max(1, insertLine);
|
|
263
|
+
if (!DreamingMemorySession.isRangeViewed(seen, anchor, anchor)) {
|
|
264
|
+
return { refused: `Line ${anchor} of ${target.virtualPath} was not viewed; view it before inserting there` };
|
|
265
|
+
}
|
|
266
|
+
lines.splice(insertLine, 0, ...inserted);
|
|
267
|
+
return { content: lines.join("\n") };
|
|
268
|
+
}), () => `Inserted ${inserted.length} line(s) into ${target.virtualPath} after line ${insertLine}.`);
|
|
269
|
+
}
|
|
270
|
+
create(virtualPath, fileText) {
|
|
271
|
+
const target = resolveMemoryPath(this.context.stores, virtualPath, "file");
|
|
272
|
+
let hash;
|
|
273
|
+
try {
|
|
274
|
+
hash = replaceIfUnchanged(target.store.directory, target.fullPath, null, fileText);
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
if (!(error instanceof MemoryConflictError))
|
|
278
|
+
throw error;
|
|
279
|
+
this.appendEdit({ path: target.virtualPath, command: "create", beforeHash: error.currentHash, afterHash: null, startLine: 0, endLine: 0, lineDelta: 0, result: "conflict" });
|
|
280
|
+
return reply(`${target.virtualPath} already exists; view it and edit it instead`, true);
|
|
281
|
+
}
|
|
282
|
+
const lines = lineCount(fileText);
|
|
283
|
+
this.touched.add(target.virtualPath);
|
|
284
|
+
this.appendEdit({ path: target.virtualPath, command: "create", beforeHash: null, afterHash: hash, startLine: 1, endLine: lines, lineDelta: lines, result: "committed" });
|
|
285
|
+
this.viewed.set(target.virtualPath, { hash, ranges: [[1, lines]] });
|
|
286
|
+
return reply(`Created ${target.virtualPath}.`);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* One version-checked edit under the store lock. The backup of the
|
|
290
|
+
* pre-batch content is written before the file is replaced; a failed
|
|
291
|
+
* backup leaves the file untouched.
|
|
292
|
+
*/
|
|
293
|
+
edit(target, command, seen, span, compute, describe) {
|
|
294
|
+
const observed = { hash: null };
|
|
295
|
+
const result = editUnderLock(target.store.directory, target.fullPath, (current) => {
|
|
296
|
+
observed.hash = contentHash(current);
|
|
297
|
+
if (observed.hash !== seen.hash) {
|
|
298
|
+
return { refused: `${target.virtualPath} changed since you viewed it; view it again before editing` };
|
|
299
|
+
}
|
|
300
|
+
const next = compute(current);
|
|
301
|
+
// An edit that changes nothing is not an edit: no backup, no log, no ingestion credit.
|
|
302
|
+
if ("content" in next && next.content === current)
|
|
303
|
+
return { refused: `The edit leaves ${target.virtualPath} unchanged` };
|
|
304
|
+
// There is no delete in this version, so an edit may not empty a file either.
|
|
305
|
+
if ("content" in next && next.content.trim() === "" && current.trim() !== "") {
|
|
306
|
+
return { refused: `An edit may not empty ${target.virtualPath}; keep what is still useful` };
|
|
307
|
+
}
|
|
308
|
+
if ("content" in next)
|
|
309
|
+
this.backupOnce(target.virtualPath, current);
|
|
310
|
+
return next;
|
|
311
|
+
});
|
|
312
|
+
if ("refused" in result) {
|
|
313
|
+
if (observed.hash !== null && observed.hash !== seen.hash) {
|
|
314
|
+
// Changed by another writer since the view: record the conflict, require a re-read.
|
|
315
|
+
this.viewed.delete(target.virtualPath);
|
|
316
|
+
this.appendEdit({ path: target.virtualPath, command, beforeHash: seen.hash, afterHash: observed.hash, startLine: 0, endLine: 0, lineDelta: 0, result: "conflict" });
|
|
317
|
+
}
|
|
318
|
+
return reply(result.refused, true);
|
|
319
|
+
}
|
|
320
|
+
const afterHash = contentHash(result.content);
|
|
321
|
+
this.touched.add(target.virtualPath);
|
|
322
|
+
this.appendEdit({
|
|
323
|
+
path: target.virtualPath, command, beforeHash: observed.hash, afterHash,
|
|
324
|
+
startLine: span.start, endLine: span.newEnd, lineDelta: span.newEnd - span.oldEnd, result: "committed",
|
|
325
|
+
});
|
|
326
|
+
this.refreshAfterEdit(target.virtualPath, seen, result.content, span);
|
|
327
|
+
return reply(describe());
|
|
328
|
+
}
|
|
329
|
+
backupOnce(virtualPath, content) {
|
|
330
|
+
if (this.backedUp.has(virtualPath))
|
|
331
|
+
return;
|
|
332
|
+
const dir = path.join(dreamLogDir(this.context.memoriesDir), "backups", this.context.batch.batchId);
|
|
333
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
334
|
+
fs.writeFileSync(path.join(dir, backupName(virtualPath)), content, { encoding: "utf8", mode: 0o600 });
|
|
335
|
+
this.backedUp.add(virtualPath);
|
|
336
|
+
}
|
|
337
|
+
appendEdit(edit) {
|
|
338
|
+
const file = dreamEditsPath(this.context.batch.localDate, this.context.memoriesDir);
|
|
339
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
340
|
+
this.editSeq += 1;
|
|
341
|
+
const record = {
|
|
342
|
+
batchId: this.context.batch.batchId,
|
|
343
|
+
seq: this.editSeq,
|
|
344
|
+
at: (this.context.now?.() ?? new Date()).toISOString(),
|
|
345
|
+
...edit,
|
|
346
|
+
};
|
|
347
|
+
withMemoryLock(this.context.memoriesDir, () => {
|
|
348
|
+
fs.appendFileSync(file, `${JSON.stringify(record)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/** The content hash of a file this batch has viewed in full at its current content; null otherwise. */
|
|
352
|
+
fullyViewedHash(virtualPath) {
|
|
353
|
+
const seen = this.viewed.get(virtualPath);
|
|
354
|
+
if (!seen)
|
|
355
|
+
return null;
|
|
356
|
+
let content;
|
|
357
|
+
try {
|
|
358
|
+
content = fs.readFileSync(resolveMemoryPath(this.context.stores, virtualPath, "file").fullPath, "utf8");
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
if (contentHash(content) !== seen.hash)
|
|
364
|
+
return null;
|
|
365
|
+
const all = splitLines(content);
|
|
366
|
+
for (let line = 1; line <= all.length; line += 1) {
|
|
367
|
+
if (DreamingMemorySession.isRangeViewed(seen, line, line))
|
|
368
|
+
continue;
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
return seen.hash;
|
|
372
|
+
}
|
|
373
|
+
relativeOf(virtualPath) {
|
|
374
|
+
const store = this.context.stores.find((candidate) => virtualPath === candidate.prefix || virtualPath.startsWith(`${candidate.prefix}/`));
|
|
375
|
+
return store ? virtualPath.slice(store.prefix.length + 1) : null;
|
|
376
|
+
}
|
|
377
|
+
// ---------------------------------------------------------------- report
|
|
378
|
+
/**
|
|
379
|
+
* Record the batch outcome once. Each vocabulary candidate is validated on
|
|
380
|
+
* its own: an invalid one, or one citing a source outside this batch, is
|
|
381
|
+
* dropped and counted, never echoed back. A file reported as reviewed
|
|
382
|
+
* (tidied or unchanged) must have been viewed in full at its current
|
|
383
|
+
* content; the report carries the hash it was reviewed at.
|
|
384
|
+
*/
|
|
385
|
+
submitReport(raw) {
|
|
386
|
+
if (this.report)
|
|
387
|
+
return reply("The batch report was already submitted", true);
|
|
388
|
+
const { batch } = this.context;
|
|
389
|
+
if (batch.kind === "ingestion") {
|
|
390
|
+
if (!raw.ingestion)
|
|
391
|
+
return reply("An ingestion batch must report ingestion.status", true);
|
|
392
|
+
if (raw.ingestion.status === "no_new_facts" && !raw.ingestion.reason?.trim()) {
|
|
393
|
+
return reply("no_new_facts requires a short reason", true);
|
|
394
|
+
}
|
|
395
|
+
if (raw.ingestion.status === "ingested" && this.touched.size === 0) {
|
|
396
|
+
return reply("ingested means new facts were saved, but this batch committed no memory edit. Save them first, or report no_new_facts with a reason.", true);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const candidates = [];
|
|
400
|
+
let rejected = 0;
|
|
401
|
+
for (const item of raw.vocabularyCandidates ?? []) {
|
|
402
|
+
const parsed = VocabularyCandidateSchema.safeParse(item);
|
|
403
|
+
if (parsed.success && batch.vocabularyLearning && Object.hasOwn(batch.sources, parsed.data.sourceId)) {
|
|
404
|
+
candidates.push(parsed.data);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
rejected += 1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const planned = new Set(batch.files.map((file) => file.path));
|
|
411
|
+
const files = [];
|
|
412
|
+
const unread = [];
|
|
413
|
+
for (const file of raw.files ?? []) {
|
|
414
|
+
if (!planned.has(file.path))
|
|
415
|
+
continue;
|
|
416
|
+
if (file.status === "not_done") {
|
|
417
|
+
files.push({ path: file.path, status: "not_done" });
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const hash = this.fullyViewedHash(file.path);
|
|
421
|
+
if (hash === null)
|
|
422
|
+
unread.push(file.path);
|
|
423
|
+
else
|
|
424
|
+
files.push({ path: file.path, status: file.status, hash });
|
|
425
|
+
}
|
|
426
|
+
if (unread.length > 0) {
|
|
427
|
+
return reply(`A reviewed file must be viewed in full at its current content. View every page of ${unread.join(", ")}, or report it not_done.`, true);
|
|
428
|
+
}
|
|
429
|
+
const data = DreamingReportDataSchema.parse({
|
|
430
|
+
kind: batch.kind,
|
|
431
|
+
...(batch.kind === "ingestion" ? { ingestion: raw.ingestion } : {}),
|
|
432
|
+
files,
|
|
433
|
+
vocabularyCandidates: candidates,
|
|
434
|
+
rejectedVocabulary: rejected,
|
|
435
|
+
});
|
|
436
|
+
const runtime = getWorkerExecutionRuntime();
|
|
437
|
+
if (!runtime)
|
|
438
|
+
return reply("No Dreaming batch is active", true);
|
|
439
|
+
const outcome = runtime.reportResult({ status: "succeeded", summary: "Dreaming batch reported", data });
|
|
440
|
+
if (!outcome.accepted) {
|
|
441
|
+
return reply(outcome.reason === "pending_input"
|
|
442
|
+
? "New input arrived before this report. Read it, then report again."
|
|
443
|
+
: "A result was already reported for this batch", true);
|
|
444
|
+
}
|
|
445
|
+
this.report = data;
|
|
446
|
+
return reply(JSON.stringify({
|
|
447
|
+
ok: true,
|
|
448
|
+
acceptedVocabulary: candidates.length,
|
|
449
|
+
rejectedVocabulary: rejected,
|
|
450
|
+
next: "End your turn now with no further tool calls.",
|
|
451
|
+
}));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
let active = null;
|
|
455
|
+
export function installDreamingMemorySession(session) {
|
|
456
|
+
active = session;
|
|
457
|
+
}
|
|
458
|
+
export function getDreamingMemorySession() {
|
|
459
|
+
return active;
|
|
460
|
+
}
|
|
461
|
+
function withSession(run) {
|
|
462
|
+
const session = active;
|
|
463
|
+
if (!session)
|
|
464
|
+
return Promise.resolve(reply("No Dreaming batch is active", true));
|
|
465
|
+
try {
|
|
466
|
+
return Promise.resolve(run(session));
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
// Path and lock refusals reach the model as tool errors, without content or host paths.
|
|
470
|
+
return Promise.resolve(reply(errorText(error), true));
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
export const dreamMemoryTool = tool("dream_memory", "Read and edit memory files during a Dreaming batch. view lists a directory or shows one page of a file with line numbers; follow 'Next page' to read further. str_replace and insert change only lines you have viewed at the file's current content; create makes a new file. There is no delete or rename. Paths start with /memories or /auto-memory.", {
|
|
474
|
+
command: z.enum(["view", "str_replace", "insert", "create"]),
|
|
475
|
+
path: z.string().min(1).max(512),
|
|
476
|
+
view_range: z.tuple([z.number().int(), z.number().int()]).optional()
|
|
477
|
+
.describe("1-based inclusive [start, end] for view; -1 as end means end of file"),
|
|
478
|
+
old_str: z.string().optional().describe("Exact unique text to replace (str_replace)"),
|
|
479
|
+
new_str: z.string().optional().describe("Replacement text (str_replace)"),
|
|
480
|
+
insert_line: z.number().int().optional().describe("Insert after this line; 0 inserts at the top (insert)"),
|
|
481
|
+
insert_text: z.string().optional().describe("Text to insert (insert)"),
|
|
482
|
+
file_text: z.string().optional().describe("Content of a new file (create)"),
|
|
483
|
+
}, (args) => withSession((session) => {
|
|
484
|
+
switch (args.command) {
|
|
485
|
+
case "view":
|
|
486
|
+
return session.view(args.path, args.view_range);
|
|
487
|
+
case "str_replace":
|
|
488
|
+
if (args.old_str === undefined || args.new_str === undefined)
|
|
489
|
+
return reply("str_replace needs old_str and new_str", true);
|
|
490
|
+
return session.strReplace(args.path, args.old_str, args.new_str);
|
|
491
|
+
case "insert":
|
|
492
|
+
if (args.insert_line === undefined || args.insert_text === undefined)
|
|
493
|
+
return reply("insert needs insert_line and insert_text", true);
|
|
494
|
+
return session.insert(args.path, args.insert_line, args.insert_text);
|
|
495
|
+
case "create":
|
|
496
|
+
if (args.file_text === undefined)
|
|
497
|
+
return reply("create needs file_text", true);
|
|
498
|
+
return session.create(args.path, args.file_text);
|
|
499
|
+
}
|
|
500
|
+
}));
|
|
501
|
+
export const dreamingReportTool = tool("dreaming_report", "Report this Dreaming batch's outcome once, at the end. Ingestion batch: ingestion.status is ingested (new facts were saved to memory), no_new_facts (give a reason), or not_done. Review batch: one entry per listed file, tidied, unchanged, or not_done; tidied and unchanged require having viewed every page of the file at its current content. Optional vocabularyCandidates must cite a sourceId copied exactly from the transcript.", {
|
|
502
|
+
ingestion: z.object({
|
|
503
|
+
status: z.enum(["ingested", "no_new_facts", "not_done"]),
|
|
504
|
+
reason: z.string().max(1_000).optional(),
|
|
505
|
+
}).optional(),
|
|
506
|
+
files: z.array(z.object({
|
|
507
|
+
path: z.string().max(512),
|
|
508
|
+
status: z.enum(["tidied", "unchanged", "not_done"]),
|
|
509
|
+
})).max(64).optional(),
|
|
510
|
+
vocabularyCandidates: z.array(z.unknown()).max(200).optional()
|
|
511
|
+
.describe("Each: term, category, evidenceKind, sourceId; optional spokenForms, language, confidence"),
|
|
512
|
+
}, (args) => withSession((session) => session.submitReport(args)));
|
|
513
|
+
//# sourceMappingURL=dream-memory.js.map
|