pulseed 0.5.3 → 0.5.4
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/base/state/state-manager-goal-state.d.ts +40 -0
- package/dist/base/state/state-manager-goal-state.d.ts.map +1 -0
- package/dist/base/state/state-manager-goal-state.js +235 -0
- package/dist/base/state/state-manager-goal-state.js.map +1 -0
- package/dist/base/state/state-manager.d.ts +0 -5
- package/dist/base/state/state-manager.d.ts.map +1 -1
- package/dist/base/state/state-manager.js +27 -273
- package/dist/base/state/state-manager.js.map +1 -1
- package/dist/base/types/goal-activation.d.ts +25 -0
- package/dist/base/types/goal-activation.d.ts.map +1 -0
- package/dist/base/types/goal-activation.js +9 -0
- package/dist/base/types/goal-activation.js.map +1 -0
- package/dist/interface/chat/chat-history.d.ts +129 -0
- package/dist/interface/chat/chat-history.d.ts.map +1 -1
- package/dist/interface/chat/chat-history.js +135 -0
- package/dist/interface/chat/chat-history.js.map +1 -1
- package/dist/interface/chat/chat-runner-command-helpers.d.ts +50 -0
- package/dist/interface/chat/chat-runner-command-helpers.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-command-helpers.js +189 -0
- package/dist/interface/chat/chat-runner-command-helpers.js.map +1 -0
- package/dist/interface/chat/chat-runner-commands.d.ts +76 -0
- package/dist/interface/chat/chat-runner-commands.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-commands.js +814 -0
- package/dist/interface/chat/chat-runner-commands.js.map +1 -0
- package/dist/interface/chat/chat-runner-event-bridge.d.ts +53 -0
- package/dist/interface/chat/chat-runner-event-bridge.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-event-bridge.js +311 -0
- package/dist/interface/chat/chat-runner-event-bridge.js.map +1 -0
- package/dist/interface/chat/chat-runner-routes.d.ts +67 -0
- package/dist/interface/chat/chat-runner-routes.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-routes.js +594 -0
- package/dist/interface/chat/chat-runner-routes.js.map +1 -0
- package/dist/interface/chat/chat-runner-runtime.d.ts +37 -0
- package/dist/interface/chat/chat-runner-runtime.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-runtime.js +236 -0
- package/dist/interface/chat/chat-runner-runtime.js.map +1 -0
- package/dist/interface/chat/chat-runner-state.d.ts +20 -0
- package/dist/interface/chat/chat-runner-state.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-state.js +157 -0
- package/dist/interface/chat/chat-runner-state.js.map +1 -0
- package/dist/interface/chat/chat-runner-support.d.ts +15 -0
- package/dist/interface/chat/chat-runner-support.d.ts.map +1 -0
- package/dist/interface/chat/chat-runner-support.js +116 -0
- package/dist/interface/chat/chat-runner-support.js.map +1 -0
- package/dist/interface/chat/chat-runner.d.ts +10 -153
- package/dist/interface/chat/chat-runner.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.js +299 -2642
- package/dist/interface/chat/chat-runner.js.map +1 -1
- package/dist/interface/chat/chat-session-store.d.ts +32 -0
- package/dist/interface/chat/chat-session-store.d.ts.map +1 -1
- package/dist/interface/chat/chat-session-store.js +100 -10
- package/dist/interface/chat/chat-session-store.js.map +1 -1
- package/dist/interface/chat/cross-platform-session.d.ts.map +1 -1
- package/dist/interface/chat/cross-platform-session.js +2 -5
- package/dist/interface/chat/cross-platform-session.js.map +1 -1
- package/dist/interface/chat/event-subscriber.d.ts.map +1 -1
- package/dist/interface/chat/event-subscriber.js +41 -0
- package/dist/interface/chat/event-subscriber.js.map +1 -1
- package/dist/interface/chat/ingress-router.d.ts +0 -25
- package/dist/interface/chat/ingress-router.d.ts.map +1 -1
- package/dist/interface/chat/ingress-router.js +12 -85
- package/dist/interface/chat/ingress-router.js.map +1 -1
- package/dist/interface/chat/tend-command.d.ts.map +1 -1
- package/dist/interface/chat/tend-command.js +2 -0
- package/dist/interface/chat/tend-command.js.map +1 -1
- package/dist/interface/cli/commands/daemon-shared.d.ts +32 -0
- package/dist/interface/cli/commands/daemon-shared.d.ts.map +1 -0
- package/dist/interface/cli/commands/daemon-shared.js +120 -0
- package/dist/interface/cli/commands/daemon-shared.js.map +1 -0
- package/dist/interface/cli/commands/daemon.d.ts +2 -2
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +4 -120
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/schedule/history.d.ts.map +1 -1
- package/dist/interface/cli/commands/schedule/history.js +5 -1
- package/dist/interface/cli/commands/schedule/history.js.map +1 -1
- package/dist/interface/cli/commands/schedule.js +34 -4
- package/dist/interface/cli/commands/schedule.js.map +1 -1
- package/dist/interface/tui/app.d.ts.map +1 -1
- package/dist/interface/tui/app.js +14 -1
- package/dist/interface/tui/app.js.map +1 -1
- package/dist/interface/tui/chat/suggestions.d.ts.map +1 -1
- package/dist/interface/tui/chat/suggestions.js +118 -4
- package/dist/interface/tui/chat/suggestions.js.map +1 -1
- package/dist/interface/tui/entry-approval.d.ts +8 -0
- package/dist/interface/tui/entry-approval.d.ts.map +1 -0
- package/dist/interface/tui/entry-approval.js +59 -0
- package/dist/interface/tui/entry-approval.js.map +1 -0
- package/dist/interface/tui/entry-daemon.d.ts +12 -0
- package/dist/interface/tui/entry-daemon.d.ts.map +1 -0
- package/dist/interface/tui/entry-daemon.js +74 -0
- package/dist/interface/tui/entry-daemon.js.map +1 -0
- package/dist/interface/tui/entry-deps.d.ts +22 -0
- package/dist/interface/tui/entry-deps.d.ts.map +1 -0
- package/dist/interface/tui/entry-deps.js +409 -0
- package/dist/interface/tui/entry-deps.js.map +1 -0
- package/dist/interface/tui/entry.d.ts +2 -4
- package/dist/interface/tui/entry.d.ts.map +1 -1
- package/dist/interface/tui/entry.js +10 -557
- package/dist/interface/tui/entry.js.map +1 -1
- package/dist/interface/tui/fullscreen-chat-render.d.ts +127 -0
- package/dist/interface/tui/fullscreen-chat-render.d.ts.map +1 -0
- package/dist/interface/tui/fullscreen-chat-render.js +667 -0
- package/dist/interface/tui/fullscreen-chat-render.js.map +1 -0
- package/dist/interface/tui/fullscreen-chat.d.ts +2 -111
- package/dist/interface/tui/fullscreen-chat.d.ts.map +1 -1
- package/dist/interface/tui/fullscreen-chat.js +4 -663
- package/dist/interface/tui/fullscreen-chat.js.map +1 -1
- package/dist/interface/tui/help-overlay.d.ts.map +1 -1
- package/dist/interface/tui/help-overlay.js +1 -1
- package/dist/interface/tui/help-overlay.js.map +1 -1
- package/dist/interface/tui/intent-recognizer.js +2 -2
- package/dist/interface/tui/intent-recognizer.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js +8 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-default-profile.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js +2 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-router.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts +2 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js +31 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-tool-runtime.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/agent-loop-turn-context.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts +1 -0
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js +36 -2
- package/dist/orchestrator/execution/agent-loop/bounded-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js +2 -1
- package/dist/orchestrator/execution/agent-loop/chat-agent-loop-runner.js.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts +19 -0
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.d.ts.map +1 -1
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js +164 -14
- package/dist/orchestrator/execution/agent-loop/core-loop-control-tools.js.map +1 -1
- package/dist/orchestrator/execution/reflection-generator.d.ts +1 -0
- package/dist/orchestrator/execution/reflection-generator.d.ts.map +1 -1
- package/dist/orchestrator/execution/reflection-generator.js +10 -1
- package/dist/orchestrator/execution/reflection-generator.js.map +1 -1
- package/dist/orchestrator/execution/task/task-context-enricher.d.ts +2 -0
- package/dist/orchestrator/execution/task/task-context-enricher.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-context-enricher.js +9 -4
- package/dist/orchestrator/execution/task/task-context-enricher.js.map +1 -1
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts +5 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.js +6 -0
- package/dist/orchestrator/execution/task/task-execution-helpers-internal.js.map +1 -0
- package/dist/orchestrator/execution/task/task-generation.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-generation.js +8 -3
- package/dist/orchestrator/execution/task/task-generation.js.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts +73 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js +184 -0
- package/dist/orchestrator/execution/task/task-lifecycle-runner.js.map +1 -0
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts +7 -7
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.js +37 -181
- package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-internal.d.ts +2 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.d.ts.map +1 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.js +2 -0
- package/dist/orchestrator/execution/task/task-verifier-internal.js.map +1 -0
- package/dist/orchestrator/goal/goal-negotiator.d.ts.map +1 -1
- package/dist/orchestrator/goal/goal-negotiator.js +23 -3
- package/dist/orchestrator/goal/goal-negotiator.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/contracts.d.ts +1 -0
- package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts +7 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js +43 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-knowledge.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts +14 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js +41 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel-wait.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts +3 -2
- package/dist/orchestrator/loop/core-loop/iteration-kernel.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js +16 -87
- package/dist/orchestrator/loop/core-loop/iteration-kernel.js.map +1 -1
- package/dist/orchestrator/loop/core-loop/phase-policy.js +5 -5
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts +9 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.js +297 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-stall.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts +11 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.js +176 -0
- package/dist/orchestrator/loop/core-loop/task-cycle-wait.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +3 -15
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/task-cycle.js +10 -444
- package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -1
- package/dist/orchestrator/loop/core-loop.d.ts +3 -0
- package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop.js +4 -0
- package/dist/orchestrator/loop/core-loop.js.map +1 -1
- package/dist/orchestrator/strategy/portfolio-manager.d.ts +3 -2
- package/dist/orchestrator/strategy/portfolio-manager.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-manager.js +16 -11
- package/dist/orchestrator/strategy/portfolio-manager.js.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.d.ts.map +1 -1
- package/dist/orchestrator/strategy/portfolio-rebalance.js +31 -9
- package/dist/orchestrator/strategy/portfolio-rebalance.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager-base.d.ts +12 -2
- package/dist/orchestrator/strategy/strategy-manager-base.d.ts.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager-base.js +23 -7
- package/dist/orchestrator/strategy/strategy-manager-base.js.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager.d.ts +1 -11
- package/dist/orchestrator/strategy/strategy-manager.d.ts.map +1 -1
- package/dist/orchestrator/strategy/strategy-manager.js +78 -19
- package/dist/orchestrator/strategy/strategy-manager.js.map +1 -1
- package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts +18 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.d.ts.map +1 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.js +130 -0
- package/dist/platform/dream/dream-consolidator/fs-metrics.js.map +1 -0
- package/dist/platform/dream/dream-consolidator.d.ts +4 -14
- package/dist/platform/dream/dream-consolidator.d.ts.map +1 -1
- package/dist/platform/dream/dream-consolidator.js +46 -166
- package/dist/platform/dream/dream-consolidator.js.map +1 -1
- package/dist/platform/dream/dream-soil-sync.d.ts +1 -0
- package/dist/platform/dream/dream-soil-sync.d.ts.map +1 -1
- package/dist/platform/dream/dream-soil-sync.js +8 -1
- package/dist/platform/dream/dream-soil-sync.js.map +1 -1
- package/dist/platform/dream/dream-types.d.ts +5 -0
- package/dist/platform/dream/dream-types.d.ts.map +1 -1
- package/dist/platform/dream/dream-types.js +1 -0
- package/dist/platform/dream/dream-types.js.map +1 -1
- package/dist/platform/dream/playbook-memory.d.ts +4 -4
- package/dist/platform/drive/stall-detector/analysis.d.ts +5 -0
- package/dist/platform/drive/stall-detector/analysis.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/analysis.js +55 -0
- package/dist/platform/drive/stall-detector/analysis.js.map +1 -0
- package/dist/platform/drive/stall-detector/repetitive.d.ts +3 -0
- package/dist/platform/drive/stall-detector/repetitive.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/repetitive.js +72 -0
- package/dist/platform/drive/stall-detector/repetitive.js.map +1 -0
- package/dist/platform/drive/stall-detector/thresholds.d.ts +10 -0
- package/dist/platform/drive/stall-detector/thresholds.d.ts.map +1 -0
- package/dist/platform/drive/stall-detector/thresholds.js +61 -0
- package/dist/platform/drive/stall-detector/thresholds.js.map +1 -0
- package/dist/platform/drive/stall-detector.d.ts +2 -20
- package/dist/platform/drive/stall-detector.d.ts.map +1 -1
- package/dist/platform/drive/stall-detector.js +9 -202
- package/dist/platform/drive/stall-detector.js.map +1 -1
- package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts +55 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.js +232 -0
- package/dist/platform/knowledge/knowledge-manager-agent-memory.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-internals.d.ts +10 -0
- package/dist/platform/knowledge/knowledge-manager-internals.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-internals.js +43 -0
- package/dist/platform/knowledge/knowledge-manager-internals.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-store.d.ts +13 -0
- package/dist/platform/knowledge/knowledge-manager-store.d.ts.map +1 -0
- package/dist/platform/knowledge/knowledge-manager-store.js +67 -0
- package/dist/platform/knowledge/knowledge-manager-store.js.map +1 -0
- package/dist/platform/knowledge/knowledge-manager.d.ts +6 -2
- package/dist/platform/knowledge/knowledge-manager.d.ts.map +1 -1
- package/dist/platform/knowledge/knowledge-manager.js +43 -344
- package/dist/platform/knowledge/knowledge-manager.js.map +1 -1
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts +4 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.d.ts.map +1 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.js +106 -0
- package/dist/platform/knowledge/memory/memory-lifecycle-storage.js.map +1 -0
- package/dist/platform/knowledge/memory/memory-lifecycle.d.ts.map +1 -1
- package/dist/platform/knowledge/memory/memory-lifecycle.js +6 -112
- package/dist/platform/knowledge/memory/memory-lifecycle.js.map +1 -1
- package/dist/platform/observation/capability-detector/prompts.d.ts +18 -0
- package/dist/platform/observation/capability-detector/prompts.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/prompts.js +80 -0
- package/dist/platform/observation/capability-detector/prompts.js.map +1 -0
- package/dist/platform/observation/capability-detector/recommendations.d.ts +5 -0
- package/dist/platform/observation/capability-detector/recommendations.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/recommendations.js +76 -0
- package/dist/platform/observation/capability-detector/recommendations.js.map +1 -0
- package/dist/platform/observation/capability-detector/types.d.ts +112 -0
- package/dist/platform/observation/capability-detector/types.d.ts.map +1 -0
- package/dist/platform/observation/capability-detector/types.js +75 -0
- package/dist/platform/observation/capability-detector/types.js.map +1 -0
- package/dist/platform/observation/capability-detector.d.ts +4 -9
- package/dist/platform/observation/capability-detector.d.ts.map +1 -1
- package/dist/platform/observation/capability-detector.js +12 -212
- package/dist/platform/observation/capability-detector.js.map +1 -1
- package/dist/platform/observation/context-provider/collector.d.ts +13 -0
- package/dist/platform/observation/context-provider/collector.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/collector.js +259 -0
- package/dist/platform/observation/context-provider/collector.js.map +1 -0
- package/dist/platform/observation/context-provider/search-terms.d.ts +2 -0
- package/dist/platform/observation/context-provider/search-terms.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/search-terms.js +24 -0
- package/dist/platform/observation/context-provider/search-terms.js.map +1 -0
- package/dist/platform/observation/context-provider/shared.d.ts +17 -0
- package/dist/platform/observation/context-provider/shared.d.ts.map +1 -0
- package/dist/platform/observation/context-provider/shared.js +87 -0
- package/dist/platform/observation/context-provider/shared.js.map +1 -0
- package/dist/platform/observation/context-provider.d.ts +3 -28
- package/dist/platform/observation/context-provider.d.ts.map +1 -1
- package/dist/platform/observation/context-provider.js +7 -395
- package/dist/platform/observation/context-provider.js.map +1 -1
- package/dist/platform/soil/compiled-memory-projections.d.ts +2 -0
- package/dist/platform/soil/compiled-memory-projections.d.ts.map +1 -1
- package/dist/platform/soil/compiled-memory-projections.js +59 -0
- package/dist/platform/soil/compiled-memory-projections.js.map +1 -1
- package/dist/platform/soil/contracts.d.ts +2 -2
- package/dist/platform/soil/retriever.d.ts +25 -0
- package/dist/platform/soil/retriever.d.ts.map +1 -1
- package/dist/platform/soil/retriever.js +94 -5
- package/dist/platform/soil/retriever.js.map +1 -1
- package/dist/platform/soil/sqlite-repository-helpers.d.ts +80 -0
- package/dist/platform/soil/sqlite-repository-helpers.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-helpers.js +143 -0
- package/dist/platform/soil/sqlite-repository-helpers.js.map +1 -0
- package/dist/platform/soil/sqlite-repository-search.d.ts +8 -0
- package/dist/platform/soil/sqlite-repository-search.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-search.js +367 -0
- package/dist/platform/soil/sqlite-repository-search.js.map +1 -0
- package/dist/platform/soil/sqlite-repository-storage.d.ts +8 -0
- package/dist/platform/soil/sqlite-repository-storage.d.ts.map +1 -0
- package/dist/platform/soil/sqlite-repository-storage.js +278 -0
- package/dist/platform/soil/sqlite-repository-storage.js.map +1 -0
- package/dist/platform/soil/sqlite-repository.d.ts +1 -4
- package/dist/platform/soil/sqlite-repository.d.ts.map +1 -1
- package/dist/platform/soil/sqlite-repository.js +26 -820
- package/dist/platform/soil/sqlite-repository.js.map +1 -1
- package/dist/runtime/daemon/index.d.ts +1 -1
- package/dist/runtime/daemon/index.d.ts.map +1 -1
- package/dist/runtime/daemon/index.js +1 -1
- package/dist/runtime/daemon/index.js.map +1 -1
- package/dist/runtime/daemon/maintenance.d.ts +2 -10
- package/dist/runtime/daemon/maintenance.d.ts.map +1 -1
- package/dist/runtime/daemon/maintenance.js +14 -45
- package/dist/runtime/daemon/maintenance.js.map +1 -1
- package/dist/runtime/daemon/runner-bootstrap.d.ts +25 -0
- package/dist/runtime/daemon/runner-bootstrap.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-bootstrap.js +77 -0
- package/dist/runtime/daemon/runner-bootstrap.js.map +1 -0
- package/dist/runtime/daemon/runner-commands.d.ts +7 -7
- package/dist/runtime/daemon/runner-commands.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-commands.js +35 -20
- package/dist/runtime/daemon/runner-commands.js.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-goal-cycle.js +3 -5
- package/dist/runtime/daemon/runner-goal-cycle.js.map +1 -1
- package/dist/runtime/daemon/runner-resident-curiosity.d.ts +12 -0
- package/dist/runtime/daemon/runner-resident-curiosity.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-curiosity.js +155 -0
- package/dist/runtime/daemon/runner-resident-curiosity.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-dream.d.ts +20 -0
- package/dist/runtime/daemon/runner-resident-dream.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-dream.js +148 -0
- package/dist/runtime/daemon/runner-resident-dream.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-proactive.d.ts +4 -0
- package/dist/runtime/daemon/runner-resident-proactive.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-proactive.js +113 -0
- package/dist/runtime/daemon/runner-resident-proactive.js.map +1 -0
- package/dist/runtime/daemon/runner-resident-shared.d.ts +40 -0
- package/dist/runtime/daemon/runner-resident-shared.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-resident-shared.js +101 -0
- package/dist/runtime/daemon/runner-resident-shared.js.map +1 -0
- package/dist/runtime/daemon/runner-resident.d.ts +4 -68
- package/dist/runtime/daemon/runner-resident.d.ts.map +1 -1
- package/dist/runtime/daemon/runner-resident.js +4 -506
- package/dist/runtime/daemon/runner-resident.js.map +1 -1
- package/dist/runtime/daemon/runner-runtime.d.ts +12 -0
- package/dist/runtime/daemon/runner-runtime.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-runtime.js +43 -0
- package/dist/runtime/daemon/runner-runtime.js.map +1 -0
- package/dist/runtime/daemon/runner-startup.js +3 -4
- package/dist/runtime/daemon/runner-startup.js.map +1 -1
- package/dist/runtime/daemon/runner.d.ts +10 -23
- package/dist/runtime/daemon/runner.d.ts.map +1 -1
- package/dist/runtime/daemon/runner.js +27 -110
- package/dist/runtime/daemon/runner.js.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts +5 -2
- package/dist/runtime/daemon/wait-deadline-resolver.d.ts.map +1 -1
- package/dist/runtime/daemon/wait-deadline-resolver.js +55 -35
- package/dist/runtime/daemon/wait-deadline-resolver.js.map +1 -1
- package/dist/runtime/event/dispatcher.d.ts +0 -2
- package/dist/runtime/event/dispatcher.d.ts.map +1 -1
- package/dist/runtime/event/dispatcher.js +0 -4
- package/dist/runtime/event/dispatcher.js.map +1 -1
- package/dist/runtime/executor/goal-worker.d.ts +2 -1
- package/dist/runtime/executor/goal-worker.d.ts.map +1 -1
- package/dist/runtime/executor/goal-worker.js +2 -1
- package/dist/runtime/executor/goal-worker.js.map +1 -1
- package/dist/runtime/executor/loop-supervisor.d.ts +3 -0
- package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
- package/dist/runtime/executor/loop-supervisor.js +37 -11
- package/dist/runtime/executor/loop-supervisor.js.map +1 -1
- package/dist/runtime/schedule/engine-cron-reflection.d.ts +31 -0
- package/dist/runtime/schedule/engine-cron-reflection.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-cron-reflection.js +229 -0
- package/dist/runtime/schedule/engine-cron-reflection.js.map +1 -0
- package/dist/runtime/schedule/engine-execution.d.ts +47 -0
- package/dist/runtime/schedule/engine-execution.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-execution.js +424 -0
- package/dist/runtime/schedule/engine-execution.js.map +1 -0
- package/dist/runtime/schedule/engine-heartbeat.d.ts +5 -0
- package/dist/runtime/schedule/engine-heartbeat.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-heartbeat.js +104 -0
- package/dist/runtime/schedule/engine-heartbeat.js.map +1 -0
- package/dist/runtime/schedule/engine-layers.d.ts +2 -0
- package/dist/runtime/schedule/engine-layers.d.ts.map +1 -1
- package/dist/runtime/schedule/engine-layers.js +12 -228
- package/dist/runtime/schedule/engine-layers.js.map +1 -1
- package/dist/runtime/schedule/engine-mutations.d.ts +37 -0
- package/dist/runtime/schedule/engine-mutations.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-mutations.js +263 -0
- package/dist/runtime/schedule/engine-mutations.js.map +1 -0
- package/dist/runtime/schedule/engine.d.ts +11 -38
- package/dist/runtime/schedule/engine.d.ts.map +1 -1
- package/dist/runtime/schedule/engine.js +65 -810
- package/dist/runtime/schedule/engine.js.map +1 -1
- package/dist/runtime/schedule/history.d.ts +16 -0
- package/dist/runtime/schedule/history.d.ts.map +1 -1
- package/dist/runtime/schedule/history.js +8 -0
- package/dist/runtime/schedule/history.js.map +1 -1
- package/dist/runtime/schedule/index.d.ts +1 -0
- package/dist/runtime/schedule/index.d.ts.map +1 -1
- package/dist/runtime/schedule/index.js +1 -0
- package/dist/runtime/schedule/index.js.map +1 -1
- package/dist/runtime/schedule/legacy-cron-migration.d.ts +9 -0
- package/dist/runtime/schedule/legacy-cron-migration.d.ts.map +1 -0
- package/dist/runtime/schedule/legacy-cron-migration.js +89 -0
- package/dist/runtime/schedule/legacy-cron-migration.js.map +1 -0
- package/dist/runtime/schedule/wait-projection.d.ts +6 -0
- package/dist/runtime/schedule/wait-projection.d.ts.map +1 -0
- package/dist/runtime/schedule/wait-projection.js +102 -0
- package/dist/runtime/schedule/wait-projection.js.map +1 -0
- package/dist/runtime/session-registry/registry-helpers.d.ts +34 -0
- package/dist/runtime/session-registry/registry-helpers.d.ts.map +1 -0
- package/dist/runtime/session-registry/registry-helpers.js +241 -0
- package/dist/runtime/session-registry/registry-helpers.js.map +1 -0
- package/dist/runtime/session-registry/registry.d.ts.map +1 -1
- package/dist/runtime/session-registry/registry.js +14 -243
- package/dist/runtime/session-registry/registry.js.map +1 -1
- package/dist/runtime/session-registry/types.d.ts +36 -36
- package/dist/runtime/store/runtime-operation-schemas.d.ts +36 -36
- package/dist/runtime/store/runtime-schemas.d.ts +2 -2
- package/dist/runtime/types/daemon.d.ts +10 -0
- package/dist/runtime/types/daemon.d.ts.map +1 -1
- package/dist/runtime/types/daemon.js +2 -0
- package/dist/runtime/types/daemon.js.map +1 -1
- package/dist/runtime/types/schedule.d.ts +65 -0
- package/dist/runtime/types/schedule.d.ts.map +1 -1
- package/dist/runtime/types/schedule.js +5 -0
- package/dist/runtime/types/schedule.js.map +1 -1
- package/dist/tools/builtin/exports.d.ts +1 -0
- package/dist/tools/builtin/exports.d.ts.map +1 -1
- package/dist/tools/builtin/exports.js +1 -0
- package/dist/tools/builtin/exports.js.map +1 -1
- package/dist/tools/builtin/factory.d.ts +2 -0
- package/dist/tools/builtin/factory.d.ts.map +1 -1
- package/dist/tools/builtin/factory.js +8 -1
- package/dist/tools/builtin/factory.js.map +1 -1
- package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts +1 -0
- package/dist/tools/fs/FileValidationTool/protected-path-policy.d.ts.map +1 -1
- package/dist/tools/fs/FileValidationTool/protected-path-policy.js +17 -4
- package/dist/tools/fs/FileValidationTool/protected-path-policy.js.map +1 -1
- package/dist/tools/fs/ListDirTool/ListDirTool.js +1 -1
- package/dist/tools/fs/ListDirTool/ListDirTool.js.map +1 -1
- package/dist/tools/kaggle/paths.d.ts.map +1 -1
- package/dist/tools/kaggle/paths.js +6 -0
- package/dist/tools/kaggle/paths.js.map +1 -1
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.d.ts.map +1 -1
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js +23 -2
- package/dist/tools/query/CodeSearchRepairTool/CodeSearchRepairTool.js.map +1 -1
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.d.ts.map +1 -1
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js +24 -2
- package/dist/tools/query/CodeSearchTool/CodeSearchTool.js.map +1 -1
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.d.ts.map +1 -1
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.js +43 -9
- package/dist/tools/query/SoilQueryTool/SoilQueryTool.js.map +1 -1
- package/dist/tools/query/code-search-root.d.ts +8 -0
- package/dist/tools/query/code-search-root.d.ts.map +1 -0
- package/dist/tools/query/code-search-root.js +41 -0
- package/dist/tools/query/code-search-root.js.map +1 -0
- package/dist/tools/query/runtime-session-tools.d.ts +560 -0
- package/dist/tools/query/runtime-session-tools.d.ts.map +1 -0
- package/dist/tools/query/runtime-session-tools.js +1015 -0
- package/dist/tools/query/runtime-session-tools.js.map +1 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts +821 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.d.ts.map +1 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.js +845 -0
- package/dist/tools/runtime/LongRunningRuntimeTools.js.map +1 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts +1 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.d.ts.map +1 -1
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js +11 -0
- package/dist/tools/system/ProcessSessionTool/ProcessSessionTool.js.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.d.ts.map +1 -1
- package/dist/tools/system/ShellTool/ShellTool.js +2 -1
- package/dist/tools/system/ShellTool/ShellTool.js.map +1 -1
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/base/types/cron.d.ts +0 -2
- package/dist/base/types/cron.d.ts.map +0 -1
- package/dist/base/types/cron.js +0 -3
- package/dist/base/types/cron.js.map +0 -1
- package/dist/runtime/cron-scheduler.d.ts +0 -13
- package/dist/runtime/cron-scheduler.d.ts.map +0 -1
- package/dist/runtime/cron-scheduler.js +0 -90
- package/dist/runtime/cron-scheduler.js.map +0 -1
- package/dist/runtime/types/cron.d.ts +0 -59
- package/dist/runtime/types/cron.d.ts.map +0 -1
- package/dist/runtime/types/cron.js +0 -13
- package/dist/runtime/types/cron.js.map +0 -1
|
@@ -0,0 +1,814 @@
|
|
|
1
|
+
import { ChatHistory } from "./chat-history.js";
|
|
2
|
+
import { ChatSessionCatalog } from "./chat-session-store.js";
|
|
3
|
+
import { resolveGitRoot } from "../../platform/observation/context-provider.js";
|
|
4
|
+
import { TendCommand } from "./tend-command.js";
|
|
5
|
+
import { EventSubscriber } from "./event-subscriber.js";
|
|
6
|
+
import { createRuntimeSessionRegistry } from "../../runtime/session-registry/index.js";
|
|
7
|
+
import { activeGoals, buildGoalUsageSummary, buildScheduleUsageSummary, deterministicChatSummary, findTask, formatConfig, formatGoalLine, formatHistory, formatTask, formatTaskLine, formatUsageCounter, hasUsage, loadGoals, normalizeUsageCounter, parseTaskArgs, readProviderConfigSummary, readTasksForGoalFromState, resolveGoalForTasks, usageFromLLMResponse, zeroUsageCounter, } from "./chat-runner-command-helpers.js";
|
|
8
|
+
import { checkGitChanges } from "./chat-runner-support.js";
|
|
9
|
+
import { formatFailureRecovery } from "./failure-recovery.js";
|
|
10
|
+
import { summarizeExecutionPolicy, withExecutionPolicyOverrides, } from "../../orchestrator/execution/agent-loop/execution-policy.js";
|
|
11
|
+
import { formatRoute, formatRuntimeSessionsList, formatRuntimeStatus } from "./chat-runner-runtime.js";
|
|
12
|
+
export const COMMAND_HELP = `Available commands:
|
|
13
|
+
Session
|
|
14
|
+
/help Show this help message
|
|
15
|
+
/clear Clear conversation history
|
|
16
|
+
/sessions List prior chat sessions
|
|
17
|
+
/history [id|title] Show saved chat history
|
|
18
|
+
/title <title> Rename the current session
|
|
19
|
+
/resume [id|title] Resume native agentloop state for the current or selected session
|
|
20
|
+
/cleanup [--dry-run] Clean up stale chat sessions
|
|
21
|
+
/compact Summarize older chat turns and keep the latest turns
|
|
22
|
+
/context Show active working context and session assumptions
|
|
23
|
+
/exit Exit chat mode
|
|
24
|
+
|
|
25
|
+
Goals and tasks
|
|
26
|
+
/status [goal-id] Show active goal status, or one goal when an id is provided
|
|
27
|
+
/goals List goals
|
|
28
|
+
/tasks [goal-id] List tasks for a goal; uses the only active goal when unambiguous
|
|
29
|
+
/task <task-id> [goal-id]
|
|
30
|
+
Show one task; searches goals when no goal id is provided
|
|
31
|
+
/track Promote session to Tier 2 goal pursuit (not yet implemented)
|
|
32
|
+
/tend Generate a goal from chat history and start autonomous daemon execution
|
|
33
|
+
|
|
34
|
+
Configuration
|
|
35
|
+
/config Show provider configuration with secrets masked
|
|
36
|
+
/model Show the active provider/model/adapter
|
|
37
|
+
/permissions [args] Show or update session execution policy
|
|
38
|
+
/plugins List installed plugins when plugin metadata is available
|
|
39
|
+
/usage [scope] Show usage summary (session, goal <id>, daemon <goal-id>, schedule [7d|24h|2w])
|
|
40
|
+
|
|
41
|
+
Review and branching
|
|
42
|
+
/review Show current diff summary and verification context
|
|
43
|
+
/fork [title] Fork the current chat session into a new session
|
|
44
|
+
/undo Remove the latest chat turn from session history
|
|
45
|
+
|
|
46
|
+
Deferred
|
|
47
|
+
/retry is intentionally not supported yet.`;
|
|
48
|
+
export class ChatRunnerCommandHandler {
|
|
49
|
+
host;
|
|
50
|
+
constructor(host) {
|
|
51
|
+
this.host = host;
|
|
52
|
+
}
|
|
53
|
+
parseResumeCommand(input) {
|
|
54
|
+
const trimmed = input.trim();
|
|
55
|
+
const match = /^\/resume(?:\s+(.+))?$/i.exec(trimmed);
|
|
56
|
+
if (!match)
|
|
57
|
+
return null;
|
|
58
|
+
const selector = match[1]?.trim();
|
|
59
|
+
return selector ? { selector } : {};
|
|
60
|
+
}
|
|
61
|
+
async handleCommand(input, cwd) {
|
|
62
|
+
const trimmed = input.trim();
|
|
63
|
+
if (!trimmed.startsWith("/"))
|
|
64
|
+
return null;
|
|
65
|
+
const cmd = trimmed.toLowerCase().split(/\s+/)[0];
|
|
66
|
+
const start = Date.now();
|
|
67
|
+
if (cmd === "/help") {
|
|
68
|
+
return { success: true, output: COMMAND_HELP, elapsed_ms: Date.now() - start };
|
|
69
|
+
}
|
|
70
|
+
if (cmd === "/clear") {
|
|
71
|
+
await this.host.getHistory()?.clear();
|
|
72
|
+
return { success: true, output: "Conversation history cleared.", elapsed_ms: Date.now() - start };
|
|
73
|
+
}
|
|
74
|
+
if (cmd === "/sessions") {
|
|
75
|
+
const registry = createRuntimeSessionRegistry({ stateManager: this.host.deps.stateManager });
|
|
76
|
+
const snapshot = await registry.snapshot();
|
|
77
|
+
return { success: true, output: formatRuntimeSessionsList(snapshot), elapsed_ms: Date.now() - start };
|
|
78
|
+
}
|
|
79
|
+
if (cmd === "/history") {
|
|
80
|
+
const catalog = new ChatSessionCatalog(this.host.deps.stateManager);
|
|
81
|
+
const selector = trimmed.slice("/history".length).trim();
|
|
82
|
+
const history = this.host.getHistory();
|
|
83
|
+
const session = selector
|
|
84
|
+
? await catalog.loadSessionBySelector(selector)
|
|
85
|
+
: history
|
|
86
|
+
? await catalog.loadSession(history.getSessionId())
|
|
87
|
+
: null;
|
|
88
|
+
if (!session) {
|
|
89
|
+
return { success: false, output: "No chat session history found.", elapsed_ms: Date.now() - start };
|
|
90
|
+
}
|
|
91
|
+
return { success: true, output: this.formatHistory(session), elapsed_ms: Date.now() - start };
|
|
92
|
+
}
|
|
93
|
+
if (cmd === "/title") {
|
|
94
|
+
const title = trimmed.slice("/title".length).trim();
|
|
95
|
+
if (!title) {
|
|
96
|
+
return { success: false, output: "Usage: /title <title>", elapsed_ms: Date.now() - start };
|
|
97
|
+
}
|
|
98
|
+
const history = this.host.getHistory();
|
|
99
|
+
if (!history) {
|
|
100
|
+
return { success: false, output: "No active chat session to rename.", elapsed_ms: Date.now() - start };
|
|
101
|
+
}
|
|
102
|
+
const catalog = new ChatSessionCatalog(this.host.deps.stateManager);
|
|
103
|
+
history.setTitle(title);
|
|
104
|
+
await history.persist();
|
|
105
|
+
await catalog.renameSession(history.getSessionId(), title);
|
|
106
|
+
return { success: true, output: `Renamed chat session to "${title}".`, elapsed_ms: Date.now() - start };
|
|
107
|
+
}
|
|
108
|
+
if (cmd === "/cleanup") {
|
|
109
|
+
const catalog = new ChatSessionCatalog(this.host.deps.stateManager);
|
|
110
|
+
const dryRun = trimmed.includes("--dry-run");
|
|
111
|
+
const report = await catalog.cleanupSessions({
|
|
112
|
+
dryRun,
|
|
113
|
+
activeSessionId: this.host.getHistory()?.getSessionId(),
|
|
114
|
+
});
|
|
115
|
+
const verb = dryRun ? "would remove" : "removed";
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
output: `Chat session cleanup ${verb} ${report.removedSessionIds.length} session(s).`,
|
|
119
|
+
elapsed_ms: Date.now() - start,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (cmd === "/compact") {
|
|
123
|
+
return this.handleCompact(start);
|
|
124
|
+
}
|
|
125
|
+
if (cmd === "/status") {
|
|
126
|
+
return this.handleStatus(trimmed.slice("/status".length).trim(), start);
|
|
127
|
+
}
|
|
128
|
+
if (cmd === "/goals") {
|
|
129
|
+
return this.handleGoals(start);
|
|
130
|
+
}
|
|
131
|
+
if (cmd === "/tasks") {
|
|
132
|
+
return this.handleTasks(trimmed.slice("/tasks".length).trim(), start);
|
|
133
|
+
}
|
|
134
|
+
if (cmd === "/task") {
|
|
135
|
+
return this.handleTask(trimmed.slice("/task".length).trim(), start);
|
|
136
|
+
}
|
|
137
|
+
if (cmd === "/config") {
|
|
138
|
+
return this.handleConfig(start);
|
|
139
|
+
}
|
|
140
|
+
if (cmd === "/model") {
|
|
141
|
+
return this.handleModel(start);
|
|
142
|
+
}
|
|
143
|
+
if (cmd === "/permissions") {
|
|
144
|
+
return this.handlePermissions(trimmed.slice("/permissions".length).trim(), start);
|
|
145
|
+
}
|
|
146
|
+
if (cmd === "/plugins") {
|
|
147
|
+
return this.handlePlugins(start);
|
|
148
|
+
}
|
|
149
|
+
if (cmd === "/usage") {
|
|
150
|
+
return this.handleUsage(trimmed.slice("/usage".length).trim(), start);
|
|
151
|
+
}
|
|
152
|
+
if (cmd === "/context" || cmd === "/working-memory") {
|
|
153
|
+
return this.handleContext(start, cwd);
|
|
154
|
+
}
|
|
155
|
+
if (cmd === "/review") {
|
|
156
|
+
return this.handleReview(start);
|
|
157
|
+
}
|
|
158
|
+
if (cmd === "/fork") {
|
|
159
|
+
return this.handleFork(trimmed.slice("/fork".length).trim(), start);
|
|
160
|
+
}
|
|
161
|
+
if (cmd === "/undo") {
|
|
162
|
+
return this.handleUndo(start);
|
|
163
|
+
}
|
|
164
|
+
if (cmd === "/retry") {
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
output: [
|
|
168
|
+
"/retry is not supported yet.",
|
|
169
|
+
"",
|
|
170
|
+
formatFailureRecovery({
|
|
171
|
+
kind: "runtime_interruption",
|
|
172
|
+
label: "Retry unavailable",
|
|
173
|
+
summary: "PulSeed does not yet have a safe replay contract for the previous turn.",
|
|
174
|
+
nextActions: [
|
|
175
|
+
"Use /review to inspect any current diff before continuing.",
|
|
176
|
+
"Use /resume when PulSeed reports resumable agent-loop state.",
|
|
177
|
+
"Ask for the exact next step to rerun instead of replaying the full turn.",
|
|
178
|
+
],
|
|
179
|
+
}),
|
|
180
|
+
].join("\n"),
|
|
181
|
+
elapsed_ms: Date.now() - start,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (cmd === "/exit") {
|
|
185
|
+
return { success: true, output: "Exiting chat mode.", elapsed_ms: Date.now() - start };
|
|
186
|
+
}
|
|
187
|
+
if (cmd === "/track") {
|
|
188
|
+
return this.handleTrack(start);
|
|
189
|
+
}
|
|
190
|
+
if (cmd === "/tend") {
|
|
191
|
+
const args = trimmed.slice("/tend".length).trim();
|
|
192
|
+
return this.handleTend(args, start);
|
|
193
|
+
}
|
|
194
|
+
if (this.host.getPendingTend() !== null) {
|
|
195
|
+
return this.handleTendConfirmation(trimmed, start);
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
success: false,
|
|
199
|
+
output: `Unknown command: ${input.trim()}. Type /help for available commands.`,
|
|
200
|
+
elapsed_ms: Date.now() - start,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async handleTendConfirmation(input, start) {
|
|
204
|
+
const pending = this.host.getPendingTend();
|
|
205
|
+
this.host.setPendingTend(null);
|
|
206
|
+
const normalized = input.trim().toLowerCase();
|
|
207
|
+
const confirmed = normalized === "" || normalized === "y" || normalized === "yes";
|
|
208
|
+
if (!confirmed) {
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
output: "Tend cancelled. Continue chatting to refine your goal, then try /tend again.",
|
|
212
|
+
elapsed_ms: Date.now() - start,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
if (!this.host.deps.daemonClient) {
|
|
216
|
+
return {
|
|
217
|
+
success: false,
|
|
218
|
+
output: "Daemon client not available.",
|
|
219
|
+
elapsed_ms: Date.now() - start,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const { goalId, maxIterations } = pending;
|
|
223
|
+
let subscriber = null;
|
|
224
|
+
if (this.host.deps.daemonBaseUrl && !this.host.getActiveSubscribers().has(goalId)) {
|
|
225
|
+
subscriber = new EventSubscriber(this.host.deps.daemonBaseUrl, goalId, "normal");
|
|
226
|
+
this.host.getActiveSubscribers().set(goalId, subscriber);
|
|
227
|
+
subscriber.on("notification", (notification) => {
|
|
228
|
+
const n = notification;
|
|
229
|
+
this.host.deps.onNotification?.(n.message);
|
|
230
|
+
this.host.onNotification?.(n.message);
|
|
231
|
+
});
|
|
232
|
+
subscriber.on("chat_event", (event) => {
|
|
233
|
+
this.host.emitEvent(event);
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
236
|
+
await subscriber.subscribeReady();
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
subscriber.unsubscribe();
|
|
240
|
+
this.host.getActiveSubscribers().delete(goalId);
|
|
241
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
242
|
+
return {
|
|
243
|
+
success: false,
|
|
244
|
+
output: `Daemon event stream unavailable: ${msg}. Goal was not started.`,
|
|
245
|
+
elapsed_ms: Date.now() - start,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const tendDeps = this.buildTendDeps(this.host.deps.llmClient, this.host.deps.goalNegotiator, this.host.deps.daemonClient);
|
|
251
|
+
const result = await new TendCommand().startAcceptedGoal(goalId, maxIterations, tendDeps);
|
|
252
|
+
if (!result.success) {
|
|
253
|
+
if (subscriber) {
|
|
254
|
+
subscriber.unsubscribe();
|
|
255
|
+
this.host.getActiveSubscribers().delete(goalId);
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
success: false,
|
|
259
|
+
output: result.message,
|
|
260
|
+
elapsed_ms: Date.now() - start,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const shortId = goalId.length > 12 ? goalId.slice(0, 12) : goalId;
|
|
264
|
+
return {
|
|
265
|
+
success: true,
|
|
266
|
+
output: `[tend] ${shortId}: Started — daemon is now tending your goal${maxIterations !== undefined ? ` (max ${maxIterations} iterations)` : ""}.\nBackground run: ${result.backgroundRunId}\nRun 'pulseed status' to check progress.`,
|
|
267
|
+
elapsed_ms: Date.now() - start,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
if (subscriber) {
|
|
272
|
+
subscriber.unsubscribe();
|
|
273
|
+
this.host.getActiveSubscribers().delete(goalId);
|
|
274
|
+
}
|
|
275
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
276
|
+
return {
|
|
277
|
+
success: false,
|
|
278
|
+
output: `Daemon unavailable: ${msg}. Start the daemon with 'pulseed daemon start' first.`,
|
|
279
|
+
elapsed_ms: Date.now() - start,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
formatHistory(session) {
|
|
284
|
+
return formatHistory(session);
|
|
285
|
+
}
|
|
286
|
+
async loadGoals() {
|
|
287
|
+
return loadGoals(this.host.deps.stateManager);
|
|
288
|
+
}
|
|
289
|
+
activeGoals(goals) {
|
|
290
|
+
return activeGoals(goals);
|
|
291
|
+
}
|
|
292
|
+
formatGoalLine(goal) {
|
|
293
|
+
return formatGoalLine(goal);
|
|
294
|
+
}
|
|
295
|
+
async handleStatus(args, start) {
|
|
296
|
+
if (args) {
|
|
297
|
+
const goal = await this.host.deps.stateManager.loadGoal(args);
|
|
298
|
+
if (!goal) {
|
|
299
|
+
return { success: false, output: `Goal not found: ${args}`, elapsed_ms: Date.now() - start };
|
|
300
|
+
}
|
|
301
|
+
const lines = [
|
|
302
|
+
`Goal status: ${goal.title}`,
|
|
303
|
+
`ID: ${goal.id}`,
|
|
304
|
+
`Status: ${goal.status}`,
|
|
305
|
+
`Loop: ${goal.loop_status}`,
|
|
306
|
+
`Updated: ${goal.updated_at}`,
|
|
307
|
+
`Children: ${goal.children_ids.length}`,
|
|
308
|
+
`Dimensions:`,
|
|
309
|
+
...goal.dimensions.map((dimension) => `- ${dimension.name}: current=${String(dimension.current_value)}, threshold=${JSON.stringify(dimension.threshold)}, confidence=${dimension.confidence}`),
|
|
310
|
+
];
|
|
311
|
+
return { success: true, output: lines.join("\n"), elapsed_ms: Date.now() - start };
|
|
312
|
+
}
|
|
313
|
+
const registry = createRuntimeSessionRegistry({ stateManager: this.host.deps.stateManager });
|
|
314
|
+
const [goals, runtimeSnapshot] = await Promise.all([
|
|
315
|
+
this.loadGoals(),
|
|
316
|
+
registry.snapshot(),
|
|
317
|
+
]);
|
|
318
|
+
const active = this.activeGoals(goals);
|
|
319
|
+
const runtimeStatus = formatRuntimeStatus(runtimeSnapshot);
|
|
320
|
+
if (active.length === 0) {
|
|
321
|
+
return { success: true, output: `No active goals found.\n\n${runtimeStatus}`, elapsed_ms: Date.now() - start };
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
success: true,
|
|
325
|
+
output: `Active goals:\n${active.map((goal) => this.formatGoalLine(goal)).join("\n")}\n\n${runtimeStatus}`,
|
|
326
|
+
elapsed_ms: Date.now() - start,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
async handleGoals(start) {
|
|
330
|
+
const goals = await this.loadGoals();
|
|
331
|
+
if (goals.length === 0) {
|
|
332
|
+
return { success: true, output: "No goals found.", elapsed_ms: Date.now() - start };
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
success: true,
|
|
336
|
+
output: `Goals:\n${goals.map((goal) => this.formatGoalLine(goal)).join("\n")}`,
|
|
337
|
+
elapsed_ms: Date.now() - start,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
async readTasksForGoal(goalId) {
|
|
341
|
+
return readTasksForGoalFromState(this.host.deps.stateManager, goalId);
|
|
342
|
+
}
|
|
343
|
+
async resolveGoalForTasks(selector) {
|
|
344
|
+
return resolveGoalForTasks(this.host.deps.stateManager, selector);
|
|
345
|
+
}
|
|
346
|
+
formatTaskLine(task) {
|
|
347
|
+
return formatTaskLine(task);
|
|
348
|
+
}
|
|
349
|
+
async handleTasks(args, start) {
|
|
350
|
+
const resolved = await this.resolveGoalForTasks(args);
|
|
351
|
+
if (resolved.error || !resolved.goalId) {
|
|
352
|
+
return { success: false, output: resolved.error ?? "Usage: /tasks <goal-id>", elapsed_ms: Date.now() - start };
|
|
353
|
+
}
|
|
354
|
+
const tasks = await this.readTasksForGoal(resolved.goalId);
|
|
355
|
+
if (tasks.length === 0) {
|
|
356
|
+
return { success: true, output: `No tasks found for goal "${resolved.goalId}".`, elapsed_ms: Date.now() - start };
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
success: true,
|
|
360
|
+
output: `Tasks for goal ${resolved.goalId}:\n${tasks.map((task) => this.formatTaskLine(task)).join("\n")}`,
|
|
361
|
+
elapsed_ms: Date.now() - start,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
parseTaskArgs(args) {
|
|
365
|
+
return parseTaskArgs(args);
|
|
366
|
+
}
|
|
367
|
+
async findTask(taskId, goalId) {
|
|
368
|
+
return findTask(this.host.deps.stateManager, taskId, goalId);
|
|
369
|
+
}
|
|
370
|
+
formatTask(task) {
|
|
371
|
+
return formatTask(task);
|
|
372
|
+
}
|
|
373
|
+
async handleTask(args, start) {
|
|
374
|
+
const { taskId, goalId } = this.parseTaskArgs(args);
|
|
375
|
+
if (!taskId) {
|
|
376
|
+
return { success: false, output: "Usage: /task <task-id> [goal-id]", elapsed_ms: Date.now() - start };
|
|
377
|
+
}
|
|
378
|
+
const found = await this.findTask(taskId, goalId);
|
|
379
|
+
if (found.matches.length > 1) {
|
|
380
|
+
return {
|
|
381
|
+
success: false,
|
|
382
|
+
output: `Task selector "${taskId}" matched multiple goals. Use /task ${taskId} <goal-id>.\n${found.matches.map((match) => `- ${match.goalId}`).join("\n")}`,
|
|
383
|
+
elapsed_ms: Date.now() - start,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
if (!found.task) {
|
|
387
|
+
const suffix = goalId ? ` for goal "${goalId}"` : "";
|
|
388
|
+
return { success: false, output: `Task not found: ${taskId}${suffix}`, elapsed_ms: Date.now() - start };
|
|
389
|
+
}
|
|
390
|
+
return { success: true, output: this.formatTask(found.task), elapsed_ms: Date.now() - start };
|
|
391
|
+
}
|
|
392
|
+
async readProviderConfigSummary() {
|
|
393
|
+
return readProviderConfigSummary(this.host.deps.stateManager);
|
|
394
|
+
}
|
|
395
|
+
formatConfig(config) {
|
|
396
|
+
return formatConfig(config);
|
|
397
|
+
}
|
|
398
|
+
async handleConfig(start) {
|
|
399
|
+
const config = await this.readProviderConfigSummary();
|
|
400
|
+
return { success: true, output: `Provider configuration:\n${this.formatConfig(config)}`, elapsed_ms: Date.now() - start };
|
|
401
|
+
}
|
|
402
|
+
async handleModel(start) {
|
|
403
|
+
const config = await this.readProviderConfigSummary();
|
|
404
|
+
return {
|
|
405
|
+
success: true,
|
|
406
|
+
output: `Model: ${config.model}\nProvider: ${config.provider}\nAdapter: ${config.adapter}`,
|
|
407
|
+
elapsed_ms: Date.now() - start,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async handlePlugins(start) {
|
|
411
|
+
if (!this.host.deps.pluginLoader) {
|
|
412
|
+
return { success: true, output: "Plugin information is not available in this chat session.", elapsed_ms: Date.now() - start };
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const plugins = await this.host.deps.pluginLoader.loadAll();
|
|
416
|
+
if (plugins.length === 0) {
|
|
417
|
+
return { success: true, output: "No plugins found.", elapsed_ms: Date.now() - start };
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
success: true,
|
|
421
|
+
output: `Plugins:\n${plugins.map((plugin) => `${plugin.name} - ${plugin.type ?? "unknown"} - ${plugin.enabled === false ? "disabled" : "enabled"}`).join("\n")}`,
|
|
422
|
+
elapsed_ms: Date.now() - start,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
catch (err) {
|
|
426
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
427
|
+
return { success: true, output: `Plugin information is unavailable: ${message}`, elapsed_ms: Date.now() - start };
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
zeroUsageCounter() {
|
|
431
|
+
return zeroUsageCounter();
|
|
432
|
+
}
|
|
433
|
+
normalizeUsageCounter(usage) {
|
|
434
|
+
return normalizeUsageCounter(usage);
|
|
435
|
+
}
|
|
436
|
+
usageFromLLMResponse(response) {
|
|
437
|
+
return usageFromLLMResponse(response);
|
|
438
|
+
}
|
|
439
|
+
hasUsage(usage) {
|
|
440
|
+
return hasUsage(usage);
|
|
441
|
+
}
|
|
442
|
+
formatUsageCounter(prefix, usage) {
|
|
443
|
+
return formatUsageCounter(prefix, usage);
|
|
444
|
+
}
|
|
445
|
+
async handleUsage(args, start) {
|
|
446
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
447
|
+
const scope = tokens[0]?.toLowerCase();
|
|
448
|
+
if (!scope || scope === "session") {
|
|
449
|
+
const history = this.host.getHistory();
|
|
450
|
+
if (!history) {
|
|
451
|
+
return { success: false, output: "No active chat session. Start a session and run work before /usage.", elapsed_ms: Date.now() - start };
|
|
452
|
+
}
|
|
453
|
+
const session = history.getSessionData();
|
|
454
|
+
const totals = this.normalizeUsageCounter(session.usage?.totals ?? this.zeroUsageCounter());
|
|
455
|
+
const lines = [
|
|
456
|
+
`Usage summary (session ${session.id})`,
|
|
457
|
+
...this.formatUsageCounter("Session", totals),
|
|
458
|
+
];
|
|
459
|
+
const phaseEntries = Object.entries(session.usage?.byPhase ?? {})
|
|
460
|
+
.map(([phase, usage]) => ({ phase, usage: this.normalizeUsageCounter(usage) }))
|
|
461
|
+
.filter((entry) => this.hasUsage(entry.usage))
|
|
462
|
+
.sort((left, right) => right.usage.totalTokens - left.usage.totalTokens);
|
|
463
|
+
if (phaseEntries.length > 0) {
|
|
464
|
+
lines.push("");
|
|
465
|
+
lines.push("By phase:");
|
|
466
|
+
for (const entry of phaseEntries) {
|
|
467
|
+
lines.push(`- ${entry.phase}: ${entry.usage.totalTokens} (in=${entry.usage.inputTokens}, out=${entry.usage.outputTokens})`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return { success: true, output: lines.join("\n"), elapsed_ms: Date.now() - start };
|
|
471
|
+
}
|
|
472
|
+
if (scope === "goal" || scope === "daemon") {
|
|
473
|
+
const goalId = tokens[1] ?? this.host.deps.goalId;
|
|
474
|
+
if (!goalId) {
|
|
475
|
+
return { success: false, output: "Usage: /usage goal <goal-id>", elapsed_ms: Date.now() - start };
|
|
476
|
+
}
|
|
477
|
+
const lines = await buildGoalUsageSummary(this.host.deps.stateManager, goalId);
|
|
478
|
+
return { success: true, output: lines.join("\n"), elapsed_ms: Date.now() - start };
|
|
479
|
+
}
|
|
480
|
+
if (scope === "schedule") {
|
|
481
|
+
const period = tokens[1] ?? "7d";
|
|
482
|
+
try {
|
|
483
|
+
const lines = await buildScheduleUsageSummary(this.host.deps.stateManager, period);
|
|
484
|
+
return { success: true, output: lines.join("\n"), elapsed_ms: Date.now() - start };
|
|
485
|
+
}
|
|
486
|
+
catch (err) {
|
|
487
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
488
|
+
return { success: false, output: `Usage: /usage schedule [24h|7d|2w]\nError: ${message}`, elapsed_ms: Date.now() - start };
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
success: false,
|
|
493
|
+
output: "Usage: /usage [session|goal <goal-id>|daemon <goal-id>|schedule [24h|7d|2w]]",
|
|
494
|
+
elapsed_ms: Date.now() - start,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
deterministicChatSummary(messages) {
|
|
498
|
+
return deterministicChatSummary(messages);
|
|
499
|
+
}
|
|
500
|
+
async summarizeChatForCompaction(messages, existingSummary) {
|
|
501
|
+
const content = [
|
|
502
|
+
existingSummary ? `Previous summary:\n${existingSummary}` : "",
|
|
503
|
+
`Messages to summarize:\n${messages.map((message) => `${message.role}: ${message.content}`).join("\n")}`,
|
|
504
|
+
].filter(Boolean).join("\n\n");
|
|
505
|
+
if (this.host.deps.llmClient) {
|
|
506
|
+
try {
|
|
507
|
+
const response = await this.host.deps.llmClient.sendMessage([
|
|
508
|
+
{ role: "user", content: `Summarize this chat history for later continuation. Preserve decisions, open tasks, constraints, and user preferences. Keep it concise.\n\n${content}` },
|
|
509
|
+
], { max_tokens: 700, model_tier: "light" });
|
|
510
|
+
if (response.content.trim())
|
|
511
|
+
return { summary: response.content.trim(), usedLlm: true };
|
|
512
|
+
}
|
|
513
|
+
catch {
|
|
514
|
+
// Fall back to deterministic summary below.
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
const fallback = [
|
|
518
|
+
existingSummary ? `Previous summary:\n${existingSummary}` : "",
|
|
519
|
+
"Extractive summary:",
|
|
520
|
+
this.deterministicChatSummary(messages),
|
|
521
|
+
].filter(Boolean).join("\n\n");
|
|
522
|
+
return { summary: fallback, usedLlm: false };
|
|
523
|
+
}
|
|
524
|
+
async handleCompact(start) {
|
|
525
|
+
const history = this.host.getHistory();
|
|
526
|
+
if (!history) {
|
|
527
|
+
return { success: false, output: "No active chat session to compact.", elapsed_ms: Date.now() - start };
|
|
528
|
+
}
|
|
529
|
+
const session = history.getSessionData();
|
|
530
|
+
if (session.messages.length <= 4) {
|
|
531
|
+
return { success: true, output: "Chat history is already compact. No messages were removed.", elapsed_ms: Date.now() - start };
|
|
532
|
+
}
|
|
533
|
+
const olderMessages = session.messages.slice(0, -4);
|
|
534
|
+
const { summary, usedLlm } = await this.summarizeChatForCompaction(olderMessages, session.compactionSummary);
|
|
535
|
+
const { before, after } = await history.compact(summary, 4);
|
|
536
|
+
const method = usedLlm ? "LLM summary" : "deterministic summary";
|
|
537
|
+
return {
|
|
538
|
+
success: true,
|
|
539
|
+
output: `Compacted chat history with ${method}. Persisted ${before} message(s) down to ${after}; the latest user/assistant turns were kept.`,
|
|
540
|
+
elapsed_ms: Date.now() - start,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
async handleContext(start, cwdOverride) {
|
|
544
|
+
const cwd = this.host.getSessionCwd() ?? (cwdOverride ? resolveGitRoot(cwdOverride) : process.cwd());
|
|
545
|
+
const session = this.host.getHistory()?.getSessionData() ?? null;
|
|
546
|
+
const messages = session?.messages ?? [];
|
|
547
|
+
const policy = await this.host.getSessionExecutionPolicy();
|
|
548
|
+
const recentMessages = messages.slice(-6);
|
|
549
|
+
const userTurns = messages.filter((message) => message.role === "user").length;
|
|
550
|
+
const assistantTurns = messages.filter((message) => message.role === "assistant").length;
|
|
551
|
+
const compactionSummary = session?.compactionSummary?.trim() ?? "";
|
|
552
|
+
const agentLoopPath = this.host.getNativeAgentLoopStatePath() ?? session?.agentLoopStatePath ?? null;
|
|
553
|
+
const replyTarget = this.host.getRuntimeControlContext()?.replyTarget ?? this.host.deps.runtimeReplyTarget ?? null;
|
|
554
|
+
const routeCapabilities = {
|
|
555
|
+
hasAgentLoop: this.host.deps.chatAgentLoopRunner !== undefined,
|
|
556
|
+
hasToolLoop: this.host.deps.llmClient !== undefined,
|
|
557
|
+
hasRuntimeControlService: this.host.deps.runtimeControlService !== undefined,
|
|
558
|
+
};
|
|
559
|
+
const replyTargetParts = replyTarget
|
|
560
|
+
? [replyTarget.surface, replyTarget.platform, replyTarget.conversation_id].filter(Boolean)
|
|
561
|
+
: [];
|
|
562
|
+
const contextLines = [
|
|
563
|
+
"Working context",
|
|
564
|
+
"",
|
|
565
|
+
"Session",
|
|
566
|
+
`- session_id: ${this.host.getHistory()?.getSessionId() ?? "none"}`,
|
|
567
|
+
`- cwd: ${cwd}`,
|
|
568
|
+
`- messages: ${messages.length} (${userTurns} user, ${assistantTurns} assistant)`,
|
|
569
|
+
`- recent_turns_retained: ${recentMessages.length}`,
|
|
570
|
+
`- compaction_summary: ${compactionSummary ? "present" : "none"}`,
|
|
571
|
+
`- agentloop_state_path: ${agentLoopPath ?? "none"}`,
|
|
572
|
+
"",
|
|
573
|
+
"Turn context",
|
|
574
|
+
`- last_selected_route: ${formatRoute(this.host.getLastSelectedRoute())}`,
|
|
575
|
+
`- reply_target: ${replyTargetParts.length > 0 ? replyTargetParts.join(":") : "none"}`,
|
|
576
|
+
`- route_capabilities: agent_loop=${routeCapabilities.hasAgentLoop}, tool_loop=${routeCapabilities.hasToolLoop}, runtime_control=${routeCapabilities.hasRuntimeControlService}`,
|
|
577
|
+
"",
|
|
578
|
+
"Working assumptions",
|
|
579
|
+
"- this view exposes operational context, not hidden reasoning",
|
|
580
|
+
"- last_selected_route describes the most recent non-command turn in this ChatRunner",
|
|
581
|
+
"- future turns may select a different route based on the next input",
|
|
582
|
+
"",
|
|
583
|
+
"Active constraints",
|
|
584
|
+
...summarizeExecutionPolicy(policy).split("\n").map((line) => `- ${line}`),
|
|
585
|
+
"",
|
|
586
|
+
"Included context",
|
|
587
|
+
"- current session cwd and execution policy because they constrain tool and route behavior",
|
|
588
|
+
`- ${recentMessages.length} latest persisted message(s)`,
|
|
589
|
+
`- ${compactionSummary ? "compacted older chat summary because older turns were summarized" : "no compacted older chat summary because none is stored"}`,
|
|
590
|
+
`- ${agentLoopPath ? "native agent-loop resume path because this session can persist agent-loop state" : "no native agent-loop resume path because none is active"}`,
|
|
591
|
+
"",
|
|
592
|
+
"Not included",
|
|
593
|
+
"- hidden reasoning or private model chain-of-thought",
|
|
594
|
+
"- raw state files unless a command explicitly reads them",
|
|
595
|
+
"- older chat turns beyond the retained window unless compacted into the session summary",
|
|
596
|
+
];
|
|
597
|
+
return {
|
|
598
|
+
success: true,
|
|
599
|
+
output: contextLines.join("\n"),
|
|
600
|
+
elapsed_ms: Date.now() - start,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
async handleTrack(start) {
|
|
604
|
+
if (!this.host.deps.escalationHandler) {
|
|
605
|
+
return {
|
|
606
|
+
success: false,
|
|
607
|
+
output: "Escalation not available — missing LLM configuration",
|
|
608
|
+
elapsed_ms: Date.now() - start,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
if (!this.host.getHistory() || this.host.getHistory().getMessages().length === 0) {
|
|
612
|
+
return {
|
|
613
|
+
success: false,
|
|
614
|
+
output: "No conversation to escalate. Chat first, then /track.",
|
|
615
|
+
elapsed_ms: Date.now() - start,
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
const result = await this.host.deps.escalationHandler.escalateToGoal(this.host.getHistory());
|
|
620
|
+
return {
|
|
621
|
+
success: true,
|
|
622
|
+
output: `Goal created: ${result.title} (ID: ${result.goalId})\nRun: pulseed run --goal ${result.goalId} --yes`,
|
|
623
|
+
elapsed_ms: Date.now() - start,
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
catch (err) {
|
|
627
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
628
|
+
return {
|
|
629
|
+
success: false,
|
|
630
|
+
output: `Escalation failed: ${message}`,
|
|
631
|
+
elapsed_ms: Date.now() - start,
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async handlePermissions(args, start) {
|
|
636
|
+
const policy = await this.host.getSessionExecutionPolicy();
|
|
637
|
+
if (!args) {
|
|
638
|
+
return {
|
|
639
|
+
success: true,
|
|
640
|
+
output: summarizeExecutionPolicy(policy),
|
|
641
|
+
elapsed_ms: Date.now() - start,
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const tokens = args.toLowerCase().split(/\s+/).filter(Boolean);
|
|
645
|
+
let nextPolicy = policy;
|
|
646
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
647
|
+
const token = tokens[index];
|
|
648
|
+
if (token === "read-only" || token === "readonly" || token === "read_only") {
|
|
649
|
+
nextPolicy = withExecutionPolicyOverrides(nextPolicy, { sandboxMode: "read_only" });
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
if (token === "workspace-write" || token === "workspace_write") {
|
|
653
|
+
nextPolicy = withExecutionPolicyOverrides(nextPolicy, { sandboxMode: "workspace_write" });
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (token === "full-access" || token === "danger-full-access" || token === "danger_full_access") {
|
|
657
|
+
nextPolicy = withExecutionPolicyOverrides(nextPolicy, { sandboxMode: "danger_full_access" });
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (token === "network" && tokens[index + 1]) {
|
|
661
|
+
nextPolicy = withExecutionPolicyOverrides(nextPolicy, { networkAccess: tokens[index + 1] === "on" });
|
|
662
|
+
index += 1;
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
if (token === "approval" && tokens[index + 1]) {
|
|
666
|
+
const approvalPolicy = tokens[index + 1];
|
|
667
|
+
if (approvalPolicy === "never" || approvalPolicy === "on_request" || approvalPolicy === "untrusted") {
|
|
668
|
+
nextPolicy = withExecutionPolicyOverrides(nextPolicy, { approvalPolicy });
|
|
669
|
+
index += 1;
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
success: false,
|
|
675
|
+
output: "Usage: /permissions [read-only|workspace-write|full-access] [network on|off] [approval on_request|never|untrusted]",
|
|
676
|
+
elapsed_ms: Date.now() - start,
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const runner = this.host;
|
|
680
|
+
if (typeof runner.setSessionExecutionPolicy === "function") {
|
|
681
|
+
runner.setSessionExecutionPolicy(nextPolicy);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
runner.sessionExecutionPolicy = nextPolicy;
|
|
685
|
+
}
|
|
686
|
+
return {
|
|
687
|
+
success: true,
|
|
688
|
+
output: summarizeExecutionPolicy(nextPolicy),
|
|
689
|
+
elapsed_ms: Date.now() - start,
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
async handleReview(start) {
|
|
693
|
+
const cwd = this.host.getSessionCwd() ?? process.cwd();
|
|
694
|
+
const diffStat = await checkGitChanges(cwd);
|
|
695
|
+
const reviewPolicy = withExecutionPolicyOverrides(await this.host.getSessionExecutionPolicy(), {
|
|
696
|
+
sandboxMode: "read_only",
|
|
697
|
+
approvalPolicy: "never",
|
|
698
|
+
});
|
|
699
|
+
if (this.host.deps.reviewAgentLoopRunner) {
|
|
700
|
+
const review = await this.host.deps.reviewAgentLoopRunner.execute({
|
|
701
|
+
cwd,
|
|
702
|
+
diffStat,
|
|
703
|
+
executionPolicy: reviewPolicy,
|
|
704
|
+
});
|
|
705
|
+
return { success: review.success, output: review.output, elapsed_ms: Date.now() - start };
|
|
706
|
+
}
|
|
707
|
+
const output = [
|
|
708
|
+
"Review summary",
|
|
709
|
+
diffStat ? diffStat : "No uncommitted changes detected.",
|
|
710
|
+
"",
|
|
711
|
+
"Execution policy",
|
|
712
|
+
summarizeExecutionPolicy(reviewPolicy),
|
|
713
|
+
].join("\n");
|
|
714
|
+
return { success: true, output, elapsed_ms: Date.now() - start };
|
|
715
|
+
}
|
|
716
|
+
async handleFork(title, start) {
|
|
717
|
+
const cwd = this.host.getSessionCwd() ?? process.cwd();
|
|
718
|
+
const sessionId = crypto.randomUUID();
|
|
719
|
+
const baseSession = this.host.getHistory()?.getSessionData() ?? {
|
|
720
|
+
id: sessionId,
|
|
721
|
+
cwd,
|
|
722
|
+
createdAt: new Date().toISOString(),
|
|
723
|
+
updatedAt: new Date().toISOString(),
|
|
724
|
+
messages: [],
|
|
725
|
+
};
|
|
726
|
+
const now = new Date().toISOString();
|
|
727
|
+
const forkedSession = {
|
|
728
|
+
...baseSession,
|
|
729
|
+
id: sessionId,
|
|
730
|
+
createdAt: now,
|
|
731
|
+
updatedAt: now,
|
|
732
|
+
title: title || (baseSession.title ? `${baseSession.title} (fork)` : "Forked session"),
|
|
733
|
+
};
|
|
734
|
+
this.host.setHistory(ChatHistory.fromSession(this.host.deps.stateManager, forkedSession));
|
|
735
|
+
this.host.setSessionCwd(resolveGitRoot(cwd));
|
|
736
|
+
this.host.setSessionActive(true);
|
|
737
|
+
this.host.setNativeAgentLoopStatePath(`chat/agentloop/${sessionId}.state.json`);
|
|
738
|
+
this.host.getHistory().resetAgentLoopState(this.host.getNativeAgentLoopStatePath());
|
|
739
|
+
await this.host.getHistory().persist();
|
|
740
|
+
const runner = this.host;
|
|
741
|
+
runner.resetSessionExecutionPolicy?.();
|
|
742
|
+
return {
|
|
743
|
+
success: true,
|
|
744
|
+
output: `Forked chat session as ${sessionId}.`,
|
|
745
|
+
elapsed_ms: Date.now() - start,
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
async handleUndo(start) {
|
|
749
|
+
const history = this.host.getHistory();
|
|
750
|
+
if (!history) {
|
|
751
|
+
return { success: false, output: "No active chat session to undo.", elapsed_ms: Date.now() - start };
|
|
752
|
+
}
|
|
753
|
+
const removed = await history.removeLastTurn();
|
|
754
|
+
if (removed === 0) {
|
|
755
|
+
return { success: false, output: "No chat turn to undo.", elapsed_ms: Date.now() - start };
|
|
756
|
+
}
|
|
757
|
+
return {
|
|
758
|
+
success: true,
|
|
759
|
+
output: `Removed ${removed} message(s) from chat history. File changes were not reverted.`,
|
|
760
|
+
elapsed_ms: Date.now() - start,
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
async handleTend(args, start) {
|
|
764
|
+
if (!this.host.deps.llmClient) {
|
|
765
|
+
return {
|
|
766
|
+
success: false,
|
|
767
|
+
output: "Tend not available — missing LLM configuration",
|
|
768
|
+
elapsed_ms: Date.now() - start,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
if (!this.host.deps.goalNegotiator) {
|
|
772
|
+
return {
|
|
773
|
+
success: false,
|
|
774
|
+
output: "Tend not available — missing goal negotiator",
|
|
775
|
+
elapsed_ms: Date.now() - start,
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
if (!this.host.deps.daemonClient) {
|
|
779
|
+
return {
|
|
780
|
+
success: false,
|
|
781
|
+
output: "Tend not available — daemon client not configured. Start the daemon with 'pulseed daemon start' first.",
|
|
782
|
+
elapsed_ms: Date.now() - start,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
const tendCommand = new TendCommand();
|
|
786
|
+
const result = await tendCommand.execute(args, this.buildTendDeps(this.host.deps.llmClient, this.host.deps.goalNegotiator, this.host.deps.daemonClient));
|
|
787
|
+
if (result.needsConfirmation && result.goalId) {
|
|
788
|
+
this.host.setPendingTend({ goalId: result.goalId, maxIterations: result.maxIterations });
|
|
789
|
+
return {
|
|
790
|
+
success: true,
|
|
791
|
+
output: result.confirmation ?? result.message,
|
|
792
|
+
elapsed_ms: Date.now() - start,
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
return {
|
|
796
|
+
success: result.success,
|
|
797
|
+
output: result.message,
|
|
798
|
+
elapsed_ms: Date.now() - start,
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
buildTendDeps(llmClient, goalNegotiator, daemonClient) {
|
|
802
|
+
return {
|
|
803
|
+
llmClient,
|
|
804
|
+
goalNegotiator,
|
|
805
|
+
daemonClient,
|
|
806
|
+
stateManager: this.host.deps.stateManager,
|
|
807
|
+
chatHistory: this.host.getHistory()?.getMessages() ?? [],
|
|
808
|
+
sessionId: this.host.getHistory()?.getSessionId() ?? null,
|
|
809
|
+
workspace: this.host.getSessionCwd() ?? process.cwd(),
|
|
810
|
+
replyTarget: this.host.getRuntimeControlContext()?.replyTarget ?? this.host.deps.runtimeReplyTarget ?? null,
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
//# sourceMappingURL=chat-runner-commands.js.map
|