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,1015 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ChatHistory, ChatSessionSchema } from "../../interface/chat/chat-history.js";
|
|
4
|
+
import { ChatSessionCatalog } from "../../interface/chat/chat-session-store.js";
|
|
5
|
+
import { createRuntimeSessionRegistry } from "../../runtime/session-registry/index.js";
|
|
6
|
+
import { OutboxStore } from "../../runtime/store/outbox-store.js";
|
|
7
|
+
const READ_ONLY = true;
|
|
8
|
+
const READ_PERMISSION = "read_only";
|
|
9
|
+
const WRITE_PERMISSION = "write_local";
|
|
10
|
+
const TAGS = ["session", "self-grounding"];
|
|
11
|
+
function normalizeConversationSelector(selector) {
|
|
12
|
+
return selector.startsWith("session:conversation:")
|
|
13
|
+
? selector.slice("session:conversation:".length)
|
|
14
|
+
: selector;
|
|
15
|
+
}
|
|
16
|
+
function toConversationRuntimeId(sessionId) {
|
|
17
|
+
return `session:conversation:${sessionId}`;
|
|
18
|
+
}
|
|
19
|
+
function buildCompletionMessage(session, status, summary) {
|
|
20
|
+
const title = session.title ? ` "${session.title}"` : "";
|
|
21
|
+
return `Session ${session.id}${title} ${status}: ${summary}`;
|
|
22
|
+
}
|
|
23
|
+
function summarizeMessages(messages, limit) {
|
|
24
|
+
return messages.slice(-limit).map((message) => ({
|
|
25
|
+
role: message.role,
|
|
26
|
+
content: message.content,
|
|
27
|
+
timestamp: message.timestamp,
|
|
28
|
+
turnIndex: message.turnIndex,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function reindexMessages(messages) {
|
|
32
|
+
return messages.map((message, index) => ({
|
|
33
|
+
role: message.role,
|
|
34
|
+
content: message.content,
|
|
35
|
+
timestamp: message.timestamp,
|
|
36
|
+
turnIndex: index,
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
function toChatSessionRecord(session) {
|
|
40
|
+
return {
|
|
41
|
+
id: session.id,
|
|
42
|
+
cwd: session.cwd,
|
|
43
|
+
createdAt: session.createdAt,
|
|
44
|
+
updatedAt: session.updatedAt,
|
|
45
|
+
messages: [...session.messages],
|
|
46
|
+
...(session.parentSessionId ? { parentSessionId: session.parentSessionId } : {}),
|
|
47
|
+
...(session.spawnedBySessionId ? { spawnedBySessionId: session.spawnedBySessionId } : {}),
|
|
48
|
+
...(session.spawnedByRuntimeSessionId ? { spawnedByRuntimeSessionId: session.spawnedByRuntimeSessionId } : {}),
|
|
49
|
+
...(session.spawnedAt ? { spawnedAt: session.spawnedAt } : {}),
|
|
50
|
+
...(session.sessionStatus ? { sessionStatus: session.sessionStatus } : {}),
|
|
51
|
+
...(session.sessionSummary ? { sessionSummary: session.sessionSummary } : {}),
|
|
52
|
+
...(session.completedAt ? { completedAt: session.completedAt } : {}),
|
|
53
|
+
...(session.goalId ? { goalId: session.goalId } : {}),
|
|
54
|
+
...(session.strategyId ? { strategyId: session.strategyId } : {}),
|
|
55
|
+
...(session.notificationPolicy ? { notificationPolicy: session.notificationPolicy } : {}),
|
|
56
|
+
...(session.ownerId ? { ownerId: session.ownerId } : {}),
|
|
57
|
+
...(session.ownerClaimedAt ? { ownerClaimedAt: session.ownerClaimedAt } : {}),
|
|
58
|
+
...(session.waitingUntil ? { waitingUntil: session.waitingUntil } : {}),
|
|
59
|
+
...(session.waitingCondition ? { waitingCondition: session.waitingCondition } : {}),
|
|
60
|
+
...(session.retryCount !== null && session.retryCount !== undefined ? { retryCount: session.retryCount } : {}),
|
|
61
|
+
...(session.lastRetryAt ? { lastRetryAt: session.lastRetryAt } : {}),
|
|
62
|
+
...(session.lastResumedAt ? { lastResumedAt: session.lastResumedAt } : {}),
|
|
63
|
+
...(session.notificationReplyTarget ? { notificationReplyTarget: session.notificationReplyTarget } : {}),
|
|
64
|
+
...(session.parentNotificationStatus ? { parentNotificationStatus: session.parentNotificationStatus } : {}),
|
|
65
|
+
...(session.parentNotificationSummary ? { parentNotificationSummary: session.parentNotificationSummary } : {}),
|
|
66
|
+
...(session.parentNotifiedAt ? { parentNotifiedAt: session.parentNotifiedAt } : {}),
|
|
67
|
+
...(session.compactionSummary ? { compactionSummary: session.compactionSummary } : {}),
|
|
68
|
+
...(session.title ? { title: session.title } : {}),
|
|
69
|
+
...(session.agentLoopStatePath ? { agentLoopStatePath: session.agentLoopStatePath } : {}),
|
|
70
|
+
...(session.agentLoopStatus === "running" || session.agentLoopStatus === "completed" || session.agentLoopStatus === "failed"
|
|
71
|
+
? { agentLoopStatus: session.agentLoopStatus }
|
|
72
|
+
: {}),
|
|
73
|
+
...(session.agentLoopResumable ? { agentLoopResumable: true } : {}),
|
|
74
|
+
...(session.agentLoopUpdatedAt ? { agentLoopUpdatedAt: session.agentLoopUpdatedAt } : {}),
|
|
75
|
+
...(session.agentLoop ? { agentLoop: session.agentLoop } : {}),
|
|
76
|
+
...(session.usage ? { usage: session.usage } : {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
class RuntimeSessionToolService {
|
|
80
|
+
stateManager;
|
|
81
|
+
constructor(stateManager) {
|
|
82
|
+
this.stateManager = stateManager;
|
|
83
|
+
}
|
|
84
|
+
catalog() {
|
|
85
|
+
return new ChatSessionCatalog(this.stateManager);
|
|
86
|
+
}
|
|
87
|
+
registry() {
|
|
88
|
+
return createRuntimeSessionRegistry({ stateManager: this.stateManager });
|
|
89
|
+
}
|
|
90
|
+
outbox() {
|
|
91
|
+
return new OutboxStore(this.stateManager.getBaseDir());
|
|
92
|
+
}
|
|
93
|
+
async listSessions(input, context) {
|
|
94
|
+
const snapshot = await this.registry().snapshot();
|
|
95
|
+
const allowedConversationIds = await this.allowedConversationIds(input.scope, context);
|
|
96
|
+
const runtimeAllowedIds = allowedConversationIds
|
|
97
|
+
? new Set(Array.from(allowedConversationIds, (id) => toConversationRuntimeId(id)))
|
|
98
|
+
: null;
|
|
99
|
+
const kindFilter = input.kinds?.length ? new Set(input.kinds) : null;
|
|
100
|
+
const sessions = snapshot.sessions.filter((session) => {
|
|
101
|
+
if (kindFilter && !kindFilter.has(session.kind))
|
|
102
|
+
return false;
|
|
103
|
+
if (input.activeOnly && session.status !== "active")
|
|
104
|
+
return false;
|
|
105
|
+
if (!runtimeAllowedIds)
|
|
106
|
+
return true;
|
|
107
|
+
if (session.kind === "conversation")
|
|
108
|
+
return runtimeAllowedIds.has(session.id);
|
|
109
|
+
return session.parent_session_id ? runtimeAllowedIds.has(session.parent_session_id) : false;
|
|
110
|
+
});
|
|
111
|
+
if (!input.includeRuns) {
|
|
112
|
+
return { sessions };
|
|
113
|
+
}
|
|
114
|
+
const runs = snapshot.background_runs.filter((run) => {
|
|
115
|
+
if (!runtimeAllowedIds)
|
|
116
|
+
return true;
|
|
117
|
+
if (run.parent_session_id && runtimeAllowedIds.has(run.parent_session_id))
|
|
118
|
+
return true;
|
|
119
|
+
return run.child_session_id ? sessions.some((session) => session.id === run.child_session_id) : false;
|
|
120
|
+
});
|
|
121
|
+
return { sessions, runs };
|
|
122
|
+
}
|
|
123
|
+
async loadHistory(selector, limit) {
|
|
124
|
+
const session = await this.resolveConversationSession(selector);
|
|
125
|
+
return {
|
|
126
|
+
sessionId: session.id,
|
|
127
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
128
|
+
title: session.title,
|
|
129
|
+
parentSessionId: session.parentSessionId ?? null,
|
|
130
|
+
cwd: session.cwd,
|
|
131
|
+
createdAt: session.createdAt,
|
|
132
|
+
updatedAt: session.updatedAt,
|
|
133
|
+
...(session.compactionSummary ? { compactionSummary: session.compactionSummary } : {}),
|
|
134
|
+
messages: summarizeMessages(session.messages, limit),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async readSession(selector) {
|
|
138
|
+
const session = await this.resolveConversationSession(selector);
|
|
139
|
+
const entries = await this.catalog().listSessions();
|
|
140
|
+
return {
|
|
141
|
+
sessionId: session.id,
|
|
142
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
143
|
+
title: session.title,
|
|
144
|
+
parentSessionId: session.parentSessionId ?? null,
|
|
145
|
+
childSessionIds: entries.filter((entry) => entry.parentSessionId === session.id).map((entry) => entry.id),
|
|
146
|
+
cwd: session.cwd,
|
|
147
|
+
createdAt: session.createdAt,
|
|
148
|
+
updatedAt: session.updatedAt,
|
|
149
|
+
sessionStatus: session.sessionStatus ?? null,
|
|
150
|
+
sessionSummary: session.sessionSummary ?? null,
|
|
151
|
+
completedAt: session.completedAt ?? null,
|
|
152
|
+
goalId: session.goalId ?? null,
|
|
153
|
+
strategyId: session.strategyId ?? null,
|
|
154
|
+
notificationPolicy: session.notificationPolicy ?? null,
|
|
155
|
+
ownerId: session.ownerId ?? null,
|
|
156
|
+
ownerClaimedAt: session.ownerClaimedAt ?? null,
|
|
157
|
+
waitingUntil: session.waitingUntil ?? null,
|
|
158
|
+
waitingCondition: session.waitingCondition ?? null,
|
|
159
|
+
retryCount: session.retryCount ?? null,
|
|
160
|
+
lastRetryAt: session.lastRetryAt ?? null,
|
|
161
|
+
lastResumedAt: session.lastResumedAt ?? null,
|
|
162
|
+
parentNotificationStatus: session.parentNotificationStatus ?? null,
|
|
163
|
+
parentNotifiedAt: session.parentNotifiedAt ?? null,
|
|
164
|
+
notificationReplyTarget: session.notificationReplyTarget ?? null,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async listChildren(selector) {
|
|
168
|
+
const session = await this.resolveConversationSession(selector);
|
|
169
|
+
const entries = await this.catalog().listSessions();
|
|
170
|
+
const loadedChildren = await Promise.all(entries
|
|
171
|
+
.filter((entry) => entry.parentSessionId === session.id)
|
|
172
|
+
.map((entry) => this.catalog().loadSession(entry.id)));
|
|
173
|
+
return {
|
|
174
|
+
sessionId: session.id,
|
|
175
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
176
|
+
children: loadedChildren
|
|
177
|
+
.filter((child) => child !== null)
|
|
178
|
+
.map((child) => ({
|
|
179
|
+
sessionId: child.id,
|
|
180
|
+
runtimeSessionId: toConversationRuntimeId(child.id),
|
|
181
|
+
title: child.title,
|
|
182
|
+
sessionStatus: child.sessionStatus ?? null,
|
|
183
|
+
goalId: child.goalId ?? null,
|
|
184
|
+
strategyId: child.strategyId ?? null,
|
|
185
|
+
waitingUntil: child.waitingUntil ?? null,
|
|
186
|
+
ownerId: child.ownerId ?? null,
|
|
187
|
+
})),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
async spawnSession(input, context) {
|
|
191
|
+
const now = new Date().toISOString();
|
|
192
|
+
const sessionId = randomUUID();
|
|
193
|
+
const parentSessionId = context.conversationSessionId ?? null;
|
|
194
|
+
const baseSession = input.copy_recent_messages && parentSessionId
|
|
195
|
+
? await this.catalog().loadSession(parentSessionId)
|
|
196
|
+
: null;
|
|
197
|
+
const seededMessages = input.copy_recent_messages && baseSession
|
|
198
|
+
? reindexMessages(baseSession.messages.slice(-input.recent_message_limit))
|
|
199
|
+
: [];
|
|
200
|
+
const persisted = ChatSessionSchema.parse({
|
|
201
|
+
id: sessionId,
|
|
202
|
+
cwd: input.cwd?.trim() || context.cwd,
|
|
203
|
+
createdAt: now,
|
|
204
|
+
updatedAt: now,
|
|
205
|
+
messages: seededMessages,
|
|
206
|
+
...(input.title?.trim() ? { title: input.title.trim() } : {}),
|
|
207
|
+
...(parentSessionId ? { parentSessionId } : {}),
|
|
208
|
+
...(parentSessionId ? { spawnedBySessionId: parentSessionId } : {}),
|
|
209
|
+
...(context.sessionId ? { spawnedByRuntimeSessionId: context.sessionId } : {}),
|
|
210
|
+
spawnedAt: now,
|
|
211
|
+
...(input.goal_id?.trim() ? { goalId: input.goal_id.trim() } : {}),
|
|
212
|
+
...(input.strategy_id?.trim() ? { strategyId: input.strategy_id.trim() } : {}),
|
|
213
|
+
notificationPolicy: input.notification_policy ?? (parentSessionId ? "all_terminal" : "important_only"),
|
|
214
|
+
...(input.owner_id?.trim() ? { ownerId: input.owner_id.trim() } : {}),
|
|
215
|
+
...(input.owner_id?.trim() ? { ownerClaimedAt: now } : {}),
|
|
216
|
+
sessionStatus: input.message?.trim() ? "queued" : "idle",
|
|
217
|
+
parentNotificationStatus: parentSessionId ? "pending" : "none",
|
|
218
|
+
...(baseSession?.notificationReplyTarget ? { notificationReplyTarget: baseSession.notificationReplyTarget } : {}),
|
|
219
|
+
agentLoopStatePath: `chat/agentloop/${sessionId}.state.json`,
|
|
220
|
+
});
|
|
221
|
+
const history = ChatHistory.fromSession(this.stateManager, persisted);
|
|
222
|
+
if (input.message?.trim()) {
|
|
223
|
+
await history.appendUserMessage(input.message.trim());
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
await history.persist();
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
sessionId,
|
|
230
|
+
runtimeSessionId: toConversationRuntimeId(sessionId),
|
|
231
|
+
parentSessionId,
|
|
232
|
+
resumeCommand: `/resume session:conversation:${sessionId}`,
|
|
233
|
+
messageQueued: Boolean(input.message?.trim()),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
async sendToSession(selector, message) {
|
|
237
|
+
const session = await this.resolveConversationSession(selector);
|
|
238
|
+
const history = ChatHistory.fromSession(this.stateManager, toChatSessionRecord(session));
|
|
239
|
+
history.setSessionLifecycle({ status: "queued" });
|
|
240
|
+
await history.appendUserMessage(message.trim());
|
|
241
|
+
const updated = history.getSessionData();
|
|
242
|
+
return {
|
|
243
|
+
sessionId: session.id,
|
|
244
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
245
|
+
messageCount: updated.messages.length,
|
|
246
|
+
updatedAt: updated.updatedAt ?? updated.createdAt,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
async updateSession(selector, input) {
|
|
250
|
+
const session = await this.resolveConversationSession(selector);
|
|
251
|
+
const history = ChatHistory.fromSession(this.stateManager, toChatSessionRecord(session));
|
|
252
|
+
const completedAt = input.status === "completed" || input.status === "failed"
|
|
253
|
+
? (input.completed_at ?? new Date().toISOString())
|
|
254
|
+
: null;
|
|
255
|
+
history.setSessionLifecycle({
|
|
256
|
+
status: input.status,
|
|
257
|
+
summary: input.summary ?? undefined,
|
|
258
|
+
completedAt,
|
|
259
|
+
goalId: input.goal_id ?? undefined,
|
|
260
|
+
strategyId: input.strategy_id ?? undefined,
|
|
261
|
+
notificationPolicy: input.notification_policy ?? undefined,
|
|
262
|
+
waitingUntil: input.waiting_until ?? (input.status === "waiting" ? null : undefined),
|
|
263
|
+
waitingCondition: input.waiting_condition ?? (input.status === "waiting" ? null : undefined),
|
|
264
|
+
lastResumedAt: input.status === "running" ? new Date().toISOString() : undefined,
|
|
265
|
+
parentNotificationStatus: session.parentSessionId && input.notify_parent ? "pending" : undefined,
|
|
266
|
+
});
|
|
267
|
+
if (input.append_assistant_message && input.summary?.trim()) {
|
|
268
|
+
await history.appendAssistantMessage(input.summary.trim());
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
await history.persist();
|
|
272
|
+
}
|
|
273
|
+
let notified = false;
|
|
274
|
+
let parentNotificationStatus = session.parentNotificationStatus ?? null;
|
|
275
|
+
if (session.parentSessionId
|
|
276
|
+
&& input.notify_parent
|
|
277
|
+
&& input.summary?.trim()
|
|
278
|
+
&& (input.status === "completed" || input.status === "failed")) {
|
|
279
|
+
try {
|
|
280
|
+
await this.notifyParentSession(session, input.status, input.summary.trim(), completedAt ?? new Date().toISOString());
|
|
281
|
+
parentNotificationStatus = "sent";
|
|
282
|
+
notified = true;
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
parentNotificationStatus = "failed";
|
|
286
|
+
}
|
|
287
|
+
const refreshed = ChatHistory.fromSession(this.stateManager, {
|
|
288
|
+
...history.getSessionData(),
|
|
289
|
+
});
|
|
290
|
+
refreshed.setSessionLifecycle({
|
|
291
|
+
parentNotificationStatus,
|
|
292
|
+
parentNotificationSummary: input.summary.trim(),
|
|
293
|
+
parentNotifiedAt: notified ? new Date().toISOString() : null,
|
|
294
|
+
});
|
|
295
|
+
await refreshed.persist();
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
sessionId: session.id,
|
|
299
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
300
|
+
status: input.status,
|
|
301
|
+
parentSessionId: session.parentSessionId ?? null,
|
|
302
|
+
parentNotificationStatus,
|
|
303
|
+
notified,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
async claimSession(selector, ownerId) {
|
|
307
|
+
const session = await this.resolveConversationSession(selector);
|
|
308
|
+
const history = ChatHistory.fromSession(this.stateManager, toChatSessionRecord(session));
|
|
309
|
+
const ownerClaimedAt = new Date().toISOString();
|
|
310
|
+
history.setSessionLifecycle({ ownerId, ownerClaimedAt });
|
|
311
|
+
await history.persist();
|
|
312
|
+
return {
|
|
313
|
+
sessionId: session.id,
|
|
314
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
315
|
+
ownerId,
|
|
316
|
+
ownerClaimedAt,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
async cancelSession(selector, reason) {
|
|
320
|
+
await this.updateSession(selector, {
|
|
321
|
+
session_id: selector,
|
|
322
|
+
status: "failed",
|
|
323
|
+
summary: reason,
|
|
324
|
+
append_assistant_message: false,
|
|
325
|
+
notify_parent: true,
|
|
326
|
+
});
|
|
327
|
+
const session = await this.resolveConversationSession(selector);
|
|
328
|
+
return {
|
|
329
|
+
sessionId: session.id,
|
|
330
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
331
|
+
status: "failed",
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
async retrySession(selector, message) {
|
|
335
|
+
const session = await this.resolveConversationSession(selector);
|
|
336
|
+
const history = ChatHistory.fromSession(this.stateManager, toChatSessionRecord(session));
|
|
337
|
+
const retryCount = (session.retryCount ?? 0) + 1;
|
|
338
|
+
const now = new Date().toISOString();
|
|
339
|
+
history.setSessionLifecycle({
|
|
340
|
+
status: "queued",
|
|
341
|
+
completedAt: null,
|
|
342
|
+
summary: null,
|
|
343
|
+
retryCount,
|
|
344
|
+
lastRetryAt: now,
|
|
345
|
+
waitingUntil: null,
|
|
346
|
+
waitingCondition: null,
|
|
347
|
+
parentNotificationStatus: session.parentSessionId ? "pending" : session.parentNotificationStatus ?? null,
|
|
348
|
+
});
|
|
349
|
+
if (message?.trim()) {
|
|
350
|
+
await history.appendUserMessage(message.trim());
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
await history.persist();
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
sessionId: session.id,
|
|
357
|
+
runtimeSessionId: toConversationRuntimeId(session.id),
|
|
358
|
+
retryCount,
|
|
359
|
+
status: "queued",
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
async notifyParentSession(childSession, status, summary, completedAt) {
|
|
363
|
+
const parentSession = await this.resolveConversationSession(childSession.parentSessionId);
|
|
364
|
+
const parentHistory = ChatHistory.fromSession(this.stateManager, toChatSessionRecord(parentSession));
|
|
365
|
+
const message = buildCompletionMessage(childSession, status, summary);
|
|
366
|
+
await parentHistory.appendAssistantMessage(message);
|
|
367
|
+
const replyTarget = parentSession.notificationReplyTarget ?? childSession.notificationReplyTarget ?? null;
|
|
368
|
+
if (!replyTarget)
|
|
369
|
+
return;
|
|
370
|
+
const outbox = this.outbox();
|
|
371
|
+
const createdAt = Date.now();
|
|
372
|
+
await outbox.append({
|
|
373
|
+
event_type: "session_completion",
|
|
374
|
+
correlation_id: childSession.id,
|
|
375
|
+
created_at: createdAt,
|
|
376
|
+
payload: {
|
|
377
|
+
session_id: childSession.id,
|
|
378
|
+
runtime_session_id: toConversationRuntimeId(childSession.id),
|
|
379
|
+
parent_session_id: childSession.parentSessionId,
|
|
380
|
+
status,
|
|
381
|
+
summary,
|
|
382
|
+
completed_at: completedAt,
|
|
383
|
+
reply_target: replyTarget,
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
await outbox.append({
|
|
387
|
+
event_type: "chat_response",
|
|
388
|
+
correlation_id: childSession.id,
|
|
389
|
+
created_at: Date.now(),
|
|
390
|
+
payload: {
|
|
391
|
+
goalId: `session:${childSession.id}`,
|
|
392
|
+
goal_id: `session:${childSession.id}`,
|
|
393
|
+
message,
|
|
394
|
+
status,
|
|
395
|
+
reply_target: replyTarget,
|
|
396
|
+
session_completion: {
|
|
397
|
+
session_id: childSession.id,
|
|
398
|
+
runtime_session_id: toConversationRuntimeId(childSession.id),
|
|
399
|
+
parent_session_id: childSession.parentSessionId,
|
|
400
|
+
status,
|
|
401
|
+
summary,
|
|
402
|
+
completed_at: completedAt,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
async resolveConversationSession(selector) {
|
|
408
|
+
const session = await this.catalog().loadSessionBySelector(normalizeConversationSelector(selector));
|
|
409
|
+
if (!session) {
|
|
410
|
+
throw new Error(`No chat session matched selector "${selector}".`);
|
|
411
|
+
}
|
|
412
|
+
return session;
|
|
413
|
+
}
|
|
414
|
+
async allowedConversationIds(scope, context) {
|
|
415
|
+
const currentConversationId = context.conversationSessionId ?? null;
|
|
416
|
+
if (scope === "all" || !currentConversationId)
|
|
417
|
+
return null;
|
|
418
|
+
if (scope === "self")
|
|
419
|
+
return new Set([currentConversationId]);
|
|
420
|
+
const entries = await this.catalog().listSessions();
|
|
421
|
+
const descendants = new Set([currentConversationId]);
|
|
422
|
+
let changed = true;
|
|
423
|
+
while (changed) {
|
|
424
|
+
changed = false;
|
|
425
|
+
for (const entry of entries) {
|
|
426
|
+
if (!entry.parentSessionId)
|
|
427
|
+
continue;
|
|
428
|
+
if (descendants.has(entry.parentSessionId) && !descendants.has(entry.id)) {
|
|
429
|
+
descendants.add(entry.id);
|
|
430
|
+
changed = true;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return descendants;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
export const RuntimeSessionsListInputSchema = z.object({
|
|
438
|
+
scope: z.enum(["self", "tree", "all"]).default("tree"),
|
|
439
|
+
kinds: z.array(z.enum(["conversation", "agent", "coreloop"])).optional(),
|
|
440
|
+
activeOnly: z.boolean().default(false),
|
|
441
|
+
includeRuns: z.boolean().default(false),
|
|
442
|
+
});
|
|
443
|
+
export class RuntimeSessionsListTool {
|
|
444
|
+
service;
|
|
445
|
+
metadata = {
|
|
446
|
+
name: "sessions_list",
|
|
447
|
+
aliases: ["list_sessions", "runtime_sessions_list"],
|
|
448
|
+
permissionLevel: READ_PERMISSION,
|
|
449
|
+
isReadOnly: READ_ONLY,
|
|
450
|
+
isDestructive: false,
|
|
451
|
+
shouldDefer: false,
|
|
452
|
+
alwaysLoad: false,
|
|
453
|
+
maxConcurrency: 0,
|
|
454
|
+
maxOutputChars: 12000,
|
|
455
|
+
tags: [...TAGS],
|
|
456
|
+
};
|
|
457
|
+
inputSchema = RuntimeSessionsListInputSchema;
|
|
458
|
+
constructor(service) {
|
|
459
|
+
this.service = service;
|
|
460
|
+
}
|
|
461
|
+
description(_context) {
|
|
462
|
+
return "List PulSeed runtime sessions. Supports current-session scope, spawned-session tree scope, or all sessions.";
|
|
463
|
+
}
|
|
464
|
+
async call(input, context) {
|
|
465
|
+
const started = Date.now();
|
|
466
|
+
try {
|
|
467
|
+
const data = await this.service.listSessions(input, context);
|
|
468
|
+
return {
|
|
469
|
+
success: true,
|
|
470
|
+
data,
|
|
471
|
+
summary: `Found ${data.sessions.length} session(s)`,
|
|
472
|
+
durationMs: Date.now() - started,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
return {
|
|
477
|
+
success: false,
|
|
478
|
+
data: null,
|
|
479
|
+
summary: `sessions_list failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
480
|
+
error: error instanceof Error ? error.message : String(error),
|
|
481
|
+
durationMs: Date.now() - started,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
async checkPermissions() {
|
|
486
|
+
return { status: "allowed" };
|
|
487
|
+
}
|
|
488
|
+
isConcurrencySafe() {
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
export const RuntimeSessionsHistoryInputSchema = z.object({
|
|
493
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
494
|
+
limit: z.number().int().positive().max(100).default(20),
|
|
495
|
+
});
|
|
496
|
+
export class RuntimeSessionsHistoryTool {
|
|
497
|
+
service;
|
|
498
|
+
metadata = {
|
|
499
|
+
name: "sessions_history",
|
|
500
|
+
aliases: ["read_session_history", "runtime_session_history"],
|
|
501
|
+
permissionLevel: READ_PERMISSION,
|
|
502
|
+
isReadOnly: READ_ONLY,
|
|
503
|
+
isDestructive: false,
|
|
504
|
+
shouldDefer: false,
|
|
505
|
+
alwaysLoad: false,
|
|
506
|
+
maxConcurrency: 0,
|
|
507
|
+
maxOutputChars: 12000,
|
|
508
|
+
tags: [...TAGS],
|
|
509
|
+
};
|
|
510
|
+
inputSchema = RuntimeSessionsHistoryInputSchema;
|
|
511
|
+
constructor(service) {
|
|
512
|
+
this.service = service;
|
|
513
|
+
}
|
|
514
|
+
description(_context) {
|
|
515
|
+
return "Read recent message history from a PulSeed chat conversation session by chat id or runtime session id.";
|
|
516
|
+
}
|
|
517
|
+
async call(input, _context) {
|
|
518
|
+
const started = Date.now();
|
|
519
|
+
try {
|
|
520
|
+
const data = await this.service.loadHistory(input.session_id, input.limit);
|
|
521
|
+
return {
|
|
522
|
+
success: true,
|
|
523
|
+
data,
|
|
524
|
+
summary: `Loaded ${data.messages.length} message(s) from session ${data.sessionId}`,
|
|
525
|
+
durationMs: Date.now() - started,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
return {
|
|
530
|
+
success: false,
|
|
531
|
+
data: null,
|
|
532
|
+
summary: `sessions_history failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
533
|
+
error: error instanceof Error ? error.message : String(error),
|
|
534
|
+
durationMs: Date.now() - started,
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async checkPermissions() {
|
|
539
|
+
return { status: "allowed" };
|
|
540
|
+
}
|
|
541
|
+
isConcurrencySafe() {
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
export const RuntimeSessionsReadInputSchema = z.object({
|
|
546
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
547
|
+
});
|
|
548
|
+
export class RuntimeSessionsReadTool {
|
|
549
|
+
service;
|
|
550
|
+
metadata = {
|
|
551
|
+
name: "sessions_read",
|
|
552
|
+
aliases: ["read_session", "runtime_session_read"],
|
|
553
|
+
permissionLevel: READ_PERMISSION,
|
|
554
|
+
isReadOnly: READ_ONLY,
|
|
555
|
+
isDestructive: false,
|
|
556
|
+
shouldDefer: false,
|
|
557
|
+
alwaysLoad: false,
|
|
558
|
+
maxConcurrency: 0,
|
|
559
|
+
maxOutputChars: 12000,
|
|
560
|
+
tags: [...TAGS],
|
|
561
|
+
};
|
|
562
|
+
inputSchema = RuntimeSessionsReadInputSchema;
|
|
563
|
+
constructor(service) {
|
|
564
|
+
this.service = service;
|
|
565
|
+
}
|
|
566
|
+
description() {
|
|
567
|
+
return "Read one PulSeed conversation session with parent/child relationships, lifecycle state, and notification metadata.";
|
|
568
|
+
}
|
|
569
|
+
async call(input, _context) {
|
|
570
|
+
const started = Date.now();
|
|
571
|
+
try {
|
|
572
|
+
const data = await this.service.readSession(input.session_id);
|
|
573
|
+
return {
|
|
574
|
+
success: true,
|
|
575
|
+
data,
|
|
576
|
+
summary: `Loaded session ${data.sessionId}`,
|
|
577
|
+
durationMs: Date.now() - started,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
catch (error) {
|
|
581
|
+
return {
|
|
582
|
+
success: false,
|
|
583
|
+
data: null,
|
|
584
|
+
summary: `sessions_read failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
585
|
+
error: error instanceof Error ? error.message : String(error),
|
|
586
|
+
durationMs: Date.now() - started,
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
async checkPermissions() {
|
|
591
|
+
return { status: "allowed" };
|
|
592
|
+
}
|
|
593
|
+
isConcurrencySafe() {
|
|
594
|
+
return true;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
export const RuntimeSessionsChildrenInputSchema = z.object({
|
|
598
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
599
|
+
});
|
|
600
|
+
export class RuntimeSessionsChildrenTool {
|
|
601
|
+
service;
|
|
602
|
+
metadata = {
|
|
603
|
+
name: "sessions_children",
|
|
604
|
+
aliases: ["list_session_children", "runtime_session_children"],
|
|
605
|
+
permissionLevel: READ_PERMISSION,
|
|
606
|
+
isReadOnly: READ_ONLY,
|
|
607
|
+
isDestructive: false,
|
|
608
|
+
shouldDefer: false,
|
|
609
|
+
alwaysLoad: false,
|
|
610
|
+
maxConcurrency: 0,
|
|
611
|
+
maxOutputChars: 12000,
|
|
612
|
+
tags: [...TAGS],
|
|
613
|
+
};
|
|
614
|
+
inputSchema = RuntimeSessionsChildrenInputSchema;
|
|
615
|
+
constructor(service) {
|
|
616
|
+
this.service = service;
|
|
617
|
+
}
|
|
618
|
+
description() {
|
|
619
|
+
return "List child conversation sessions spawned from a PulSeed conversation session.";
|
|
620
|
+
}
|
|
621
|
+
async call(input, _context) {
|
|
622
|
+
const started = Date.now();
|
|
623
|
+
try {
|
|
624
|
+
const data = await this.service.listChildren(input.session_id);
|
|
625
|
+
return {
|
|
626
|
+
success: true,
|
|
627
|
+
data,
|
|
628
|
+
summary: `Loaded ${data.children.length} child session(s) for ${data.sessionId}`,
|
|
629
|
+
durationMs: Date.now() - started,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
catch (error) {
|
|
633
|
+
return {
|
|
634
|
+
success: false,
|
|
635
|
+
data: null,
|
|
636
|
+
summary: `sessions_children failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
637
|
+
error: error instanceof Error ? error.message : String(error),
|
|
638
|
+
durationMs: Date.now() - started,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
async checkPermissions() {
|
|
643
|
+
return { status: "allowed" };
|
|
644
|
+
}
|
|
645
|
+
isConcurrencySafe() {
|
|
646
|
+
return true;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
export const RuntimeSessionsSpawnInputSchema = z.object({
|
|
650
|
+
title: z.string().trim().min(1).max(200).optional(),
|
|
651
|
+
message: z.string().trim().min(1).optional(),
|
|
652
|
+
cwd: z.string().trim().min(1).optional(),
|
|
653
|
+
goal_id: z.string().trim().min(1).optional(),
|
|
654
|
+
strategy_id: z.string().trim().min(1).optional(),
|
|
655
|
+
notification_policy: z.enum(["silent", "important_only", "periodic", "all_terminal"]).optional(),
|
|
656
|
+
owner_id: z.string().trim().min(1).optional(),
|
|
657
|
+
copy_recent_messages: z.boolean().default(false),
|
|
658
|
+
recent_message_limit: z.number().int().positive().max(20).default(6),
|
|
659
|
+
});
|
|
660
|
+
export class RuntimeSessionsSpawnTool {
|
|
661
|
+
service;
|
|
662
|
+
metadata = {
|
|
663
|
+
name: "sessions_spawn",
|
|
664
|
+
aliases: ["spawn_session_runtime", "delegate_session"],
|
|
665
|
+
permissionLevel: WRITE_PERMISSION,
|
|
666
|
+
isReadOnly: false,
|
|
667
|
+
isDestructive: false,
|
|
668
|
+
shouldDefer: false,
|
|
669
|
+
alwaysLoad: false,
|
|
670
|
+
maxConcurrency: 1,
|
|
671
|
+
maxOutputChars: 8000,
|
|
672
|
+
tags: [...TAGS],
|
|
673
|
+
};
|
|
674
|
+
inputSchema = RuntimeSessionsSpawnInputSchema;
|
|
675
|
+
constructor(service) {
|
|
676
|
+
this.service = service;
|
|
677
|
+
}
|
|
678
|
+
description(_context) {
|
|
679
|
+
return "Create a new PulSeed chat conversation session, optionally seeded with a task message, so work can be moved into a separate session.";
|
|
680
|
+
}
|
|
681
|
+
async call(input, context) {
|
|
682
|
+
const started = Date.now();
|
|
683
|
+
try {
|
|
684
|
+
const data = await this.service.spawnSession(input, context);
|
|
685
|
+
return {
|
|
686
|
+
success: true,
|
|
687
|
+
data,
|
|
688
|
+
summary: `Spawned session ${data.sessionId}`,
|
|
689
|
+
contextModifier: `Use ${data.resumeCommand} to continue the delegated work in that separate session.`,
|
|
690
|
+
durationMs: Date.now() - started,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
catch (error) {
|
|
694
|
+
return {
|
|
695
|
+
success: false,
|
|
696
|
+
data: null,
|
|
697
|
+
summary: `sessions_spawn failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
698
|
+
error: error instanceof Error ? error.message : String(error),
|
|
699
|
+
durationMs: Date.now() - started,
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
async checkPermissions() {
|
|
704
|
+
return { status: "allowed" };
|
|
705
|
+
}
|
|
706
|
+
isConcurrencySafe() {
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
export const RuntimeSessionsSendInputSchema = z.object({
|
|
711
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
712
|
+
message: z.string().trim().min(1, "message is required"),
|
|
713
|
+
});
|
|
714
|
+
export class RuntimeSessionsSendTool {
|
|
715
|
+
service;
|
|
716
|
+
metadata = {
|
|
717
|
+
name: "sessions_send",
|
|
718
|
+
aliases: ["send_session_message", "enqueue_session_message"],
|
|
719
|
+
permissionLevel: WRITE_PERMISSION,
|
|
720
|
+
isReadOnly: false,
|
|
721
|
+
isDestructive: false,
|
|
722
|
+
shouldDefer: false,
|
|
723
|
+
alwaysLoad: false,
|
|
724
|
+
maxConcurrency: 1,
|
|
725
|
+
maxOutputChars: 8000,
|
|
726
|
+
tags: [...TAGS],
|
|
727
|
+
};
|
|
728
|
+
inputSchema = RuntimeSessionsSendInputSchema;
|
|
729
|
+
constructor(service) {
|
|
730
|
+
this.service = service;
|
|
731
|
+
}
|
|
732
|
+
description(_context) {
|
|
733
|
+
return "Append a user message to another PulSeed chat conversation session by chat id or runtime session id.";
|
|
734
|
+
}
|
|
735
|
+
async call(input, _context) {
|
|
736
|
+
const started = Date.now();
|
|
737
|
+
try {
|
|
738
|
+
const data = await this.service.sendToSession(input.session_id, input.message);
|
|
739
|
+
return {
|
|
740
|
+
success: true,
|
|
741
|
+
data,
|
|
742
|
+
summary: `Queued a message for session ${data.sessionId}`,
|
|
743
|
+
contextModifier: `Resume ${data.runtimeSessionId} later to act on the queued message in that separate session.`,
|
|
744
|
+
durationMs: Date.now() - started,
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
return {
|
|
749
|
+
success: false,
|
|
750
|
+
data: null,
|
|
751
|
+
summary: `sessions_send failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
752
|
+
error: error instanceof Error ? error.message : String(error),
|
|
753
|
+
durationMs: Date.now() - started,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
async checkPermissions() {
|
|
758
|
+
return { status: "allowed" };
|
|
759
|
+
}
|
|
760
|
+
isConcurrencySafe() {
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
export const RuntimeSessionsUpdateInputSchema = z.object({
|
|
765
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
766
|
+
status: z.enum(["queued", "running", "waiting", "completed", "failed"]),
|
|
767
|
+
summary: z.string().trim().min(1).optional(),
|
|
768
|
+
goal_id: z.string().trim().min(1).optional(),
|
|
769
|
+
strategy_id: z.string().trim().min(1).optional(),
|
|
770
|
+
notification_policy: z.enum(["silent", "important_only", "periodic", "all_terminal"]).optional(),
|
|
771
|
+
waiting_until: z.string().trim().min(1).nullable().optional(),
|
|
772
|
+
waiting_condition: z.string().trim().min(1).nullable().optional(),
|
|
773
|
+
append_assistant_message: z.boolean().default(false),
|
|
774
|
+
notify_parent: z.boolean().default(false),
|
|
775
|
+
completed_at: z.string().optional(),
|
|
776
|
+
}).superRefine((value, ctx) => {
|
|
777
|
+
if ((value.status === "completed" || value.status === "failed") && !value.summary) {
|
|
778
|
+
ctx.addIssue({
|
|
779
|
+
code: z.ZodIssueCode.custom,
|
|
780
|
+
path: ["summary"],
|
|
781
|
+
message: "summary is required when marking a session completed or failed",
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
if (value.status === "waiting" && !value.waiting_until && !value.waiting_condition) {
|
|
785
|
+
ctx.addIssue({
|
|
786
|
+
code: z.ZodIssueCode.custom,
|
|
787
|
+
path: ["waiting_until"],
|
|
788
|
+
message: "waiting_until or waiting_condition is required when marking a session waiting",
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
export class RuntimeSessionsUpdateTool {
|
|
793
|
+
service;
|
|
794
|
+
metadata = {
|
|
795
|
+
name: "sessions_update",
|
|
796
|
+
aliases: ["update_session_status", "complete_session", "fail_session"],
|
|
797
|
+
permissionLevel: WRITE_PERMISSION,
|
|
798
|
+
isReadOnly: false,
|
|
799
|
+
isDestructive: false,
|
|
800
|
+
shouldDefer: false,
|
|
801
|
+
alwaysLoad: false,
|
|
802
|
+
maxConcurrency: 1,
|
|
803
|
+
maxOutputChars: 8000,
|
|
804
|
+
tags: [...TAGS],
|
|
805
|
+
};
|
|
806
|
+
inputSchema = RuntimeSessionsUpdateInputSchema;
|
|
807
|
+
constructor(service) {
|
|
808
|
+
this.service = service;
|
|
809
|
+
}
|
|
810
|
+
description() {
|
|
811
|
+
return "Update a PulSeed conversation session lifecycle state. Can mark child sessions completed or failed and notify the parent session durably.";
|
|
812
|
+
}
|
|
813
|
+
async call(input, _context) {
|
|
814
|
+
const started = Date.now();
|
|
815
|
+
try {
|
|
816
|
+
const data = await this.service.updateSession(input.session_id, input);
|
|
817
|
+
return {
|
|
818
|
+
success: true,
|
|
819
|
+
data,
|
|
820
|
+
summary: `Updated session ${data.sessionId} to ${data.status}`,
|
|
821
|
+
durationMs: Date.now() - started,
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
catch (error) {
|
|
825
|
+
return {
|
|
826
|
+
success: false,
|
|
827
|
+
data: null,
|
|
828
|
+
summary: `sessions_update failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
829
|
+
error: error instanceof Error ? error.message : String(error),
|
|
830
|
+
durationMs: Date.now() - started,
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
async checkPermissions() {
|
|
835
|
+
return { status: "allowed" };
|
|
836
|
+
}
|
|
837
|
+
isConcurrencySafe() {
|
|
838
|
+
return false;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
export const RuntimeSessionsClaimInputSchema = z.object({
|
|
842
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
843
|
+
owner_id: z.string().trim().min(1, "owner_id is required"),
|
|
844
|
+
});
|
|
845
|
+
export class RuntimeSessionsClaimTool {
|
|
846
|
+
service;
|
|
847
|
+
metadata = {
|
|
848
|
+
name: "sessions_claim",
|
|
849
|
+
aliases: ["claim_session", "runtime_session_claim"],
|
|
850
|
+
permissionLevel: WRITE_PERMISSION,
|
|
851
|
+
isReadOnly: false,
|
|
852
|
+
isDestructive: false,
|
|
853
|
+
shouldDefer: false,
|
|
854
|
+
alwaysLoad: false,
|
|
855
|
+
maxConcurrency: 1,
|
|
856
|
+
maxOutputChars: 8000,
|
|
857
|
+
tags: [...TAGS],
|
|
858
|
+
};
|
|
859
|
+
inputSchema = RuntimeSessionsClaimInputSchema;
|
|
860
|
+
constructor(service) {
|
|
861
|
+
this.service = service;
|
|
862
|
+
}
|
|
863
|
+
description() {
|
|
864
|
+
return "Claim ownership of a PulSeed conversation session so delegated work has an explicit owner.";
|
|
865
|
+
}
|
|
866
|
+
async call(input, _context) {
|
|
867
|
+
const started = Date.now();
|
|
868
|
+
try {
|
|
869
|
+
const data = await this.service.claimSession(input.session_id, input.owner_id);
|
|
870
|
+
return {
|
|
871
|
+
success: true,
|
|
872
|
+
data,
|
|
873
|
+
summary: `Claimed session ${data.sessionId} for ${data.ownerId}`,
|
|
874
|
+
durationMs: Date.now() - started,
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
catch (error) {
|
|
878
|
+
return {
|
|
879
|
+
success: false,
|
|
880
|
+
data: null,
|
|
881
|
+
summary: `sessions_claim failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
882
|
+
error: error instanceof Error ? error.message : String(error),
|
|
883
|
+
durationMs: Date.now() - started,
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
async checkPermissions() {
|
|
888
|
+
return { status: "allowed" };
|
|
889
|
+
}
|
|
890
|
+
isConcurrencySafe() {
|
|
891
|
+
return false;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
export const RuntimeSessionsCancelInputSchema = z.object({
|
|
895
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
896
|
+
reason: z.string().trim().min(1, "reason is required"),
|
|
897
|
+
});
|
|
898
|
+
export class RuntimeSessionsCancelTool {
|
|
899
|
+
service;
|
|
900
|
+
metadata = {
|
|
901
|
+
name: "sessions_cancel",
|
|
902
|
+
aliases: ["cancel_session", "runtime_session_cancel"],
|
|
903
|
+
permissionLevel: WRITE_PERMISSION,
|
|
904
|
+
isReadOnly: false,
|
|
905
|
+
isDestructive: false,
|
|
906
|
+
shouldDefer: false,
|
|
907
|
+
alwaysLoad: false,
|
|
908
|
+
maxConcurrency: 1,
|
|
909
|
+
maxOutputChars: 8000,
|
|
910
|
+
tags: [...TAGS],
|
|
911
|
+
};
|
|
912
|
+
inputSchema = RuntimeSessionsCancelInputSchema;
|
|
913
|
+
constructor(service) {
|
|
914
|
+
this.service = service;
|
|
915
|
+
}
|
|
916
|
+
description() {
|
|
917
|
+
return "Cancel a PulSeed conversation session by marking it failed and notifying its parent if configured.";
|
|
918
|
+
}
|
|
919
|
+
async call(input, _context) {
|
|
920
|
+
const started = Date.now();
|
|
921
|
+
try {
|
|
922
|
+
const data = await this.service.cancelSession(input.session_id, input.reason);
|
|
923
|
+
return {
|
|
924
|
+
success: true,
|
|
925
|
+
data,
|
|
926
|
+
summary: `Canceled session ${data.sessionId}`,
|
|
927
|
+
durationMs: Date.now() - started,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
catch (error) {
|
|
931
|
+
return {
|
|
932
|
+
success: false,
|
|
933
|
+
data: null,
|
|
934
|
+
summary: `sessions_cancel failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
935
|
+
error: error instanceof Error ? error.message : String(error),
|
|
936
|
+
durationMs: Date.now() - started,
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
async checkPermissions() {
|
|
941
|
+
return { status: "allowed" };
|
|
942
|
+
}
|
|
943
|
+
isConcurrencySafe() {
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
export const RuntimeSessionsRetryInputSchema = z.object({
|
|
948
|
+
session_id: z.string().min(1, "session_id is required"),
|
|
949
|
+
message: z.string().trim().min(1).optional(),
|
|
950
|
+
});
|
|
951
|
+
export class RuntimeSessionsRetryTool {
|
|
952
|
+
service;
|
|
953
|
+
metadata = {
|
|
954
|
+
name: "sessions_retry",
|
|
955
|
+
aliases: ["retry_session", "runtime_session_retry"],
|
|
956
|
+
permissionLevel: WRITE_PERMISSION,
|
|
957
|
+
isReadOnly: false,
|
|
958
|
+
isDestructive: false,
|
|
959
|
+
shouldDefer: false,
|
|
960
|
+
alwaysLoad: false,
|
|
961
|
+
maxConcurrency: 1,
|
|
962
|
+
maxOutputChars: 8000,
|
|
963
|
+
tags: [...TAGS],
|
|
964
|
+
};
|
|
965
|
+
inputSchema = RuntimeSessionsRetryInputSchema;
|
|
966
|
+
constructor(service) {
|
|
967
|
+
this.service = service;
|
|
968
|
+
}
|
|
969
|
+
description() {
|
|
970
|
+
return "Re-queue a PulSeed conversation session for another attempt, preserving retry metadata.";
|
|
971
|
+
}
|
|
972
|
+
async call(input, _context) {
|
|
973
|
+
const started = Date.now();
|
|
974
|
+
try {
|
|
975
|
+
const data = await this.service.retrySession(input.session_id, input.message);
|
|
976
|
+
return {
|
|
977
|
+
success: true,
|
|
978
|
+
data,
|
|
979
|
+
summary: `Retried session ${data.sessionId}`,
|
|
980
|
+
durationMs: Date.now() - started,
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
catch (error) {
|
|
984
|
+
return {
|
|
985
|
+
success: false,
|
|
986
|
+
data: null,
|
|
987
|
+
summary: `sessions_retry failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
988
|
+
error: error instanceof Error ? error.message : String(error),
|
|
989
|
+
durationMs: Date.now() - started,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
async checkPermissions() {
|
|
994
|
+
return { status: "allowed" };
|
|
995
|
+
}
|
|
996
|
+
isConcurrencySafe() {
|
|
997
|
+
return false;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
export function createRuntimeSessionTools(stateManager) {
|
|
1001
|
+
const service = new RuntimeSessionToolService(stateManager);
|
|
1002
|
+
return [
|
|
1003
|
+
new RuntimeSessionsListTool(service),
|
|
1004
|
+
new RuntimeSessionsHistoryTool(service),
|
|
1005
|
+
new RuntimeSessionsReadTool(service),
|
|
1006
|
+
new RuntimeSessionsChildrenTool(service),
|
|
1007
|
+
new RuntimeSessionsSpawnTool(service),
|
|
1008
|
+
new RuntimeSessionsSendTool(service),
|
|
1009
|
+
new RuntimeSessionsUpdateTool(service),
|
|
1010
|
+
new RuntimeSessionsClaimTool(service),
|
|
1011
|
+
new RuntimeSessionsCancelTool(service),
|
|
1012
|
+
new RuntimeSessionsRetryTool(service),
|
|
1013
|
+
];
|
|
1014
|
+
}
|
|
1015
|
+
//# sourceMappingURL=runtime-session-tools.js.map
|