@cortex-agent/server 2026.5.19-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/.claude/settings.json +13 -0
- package/defaults/CORTEX.md +15 -0
- package/defaults/config/budget.json +4 -0
- package/defaults/config/session-hooks.json +7 -0
- package/defaults/config/thread-templates.json +528 -0
- package/defaults/context/CORTEX.md +40 -0
- package/defaults/context/decisions/DR-0012.md +54 -0
- package/defaults/context/ideas/CORTEX.md +10 -0
- package/defaults/context/projects/CORTEX.md +25 -0
- package/defaults/context/scans/CORTEX.md +13 -0
- package/defaults/context/user/CORTEX.md +21 -0
- package/defaults/data/schedules.json +52 -0
- package/defaults/gitignore +44 -0
- package/defaults/hooks/ask-user-question-hook.mjs +66 -0
- package/defaults/hooks/cortex-md-injector.mjs +237 -0
- package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
- package/defaults/hooks/memory-ref-tracker.mjs +154 -0
- package/defaults/hooks/new-session-hook.mjs +83 -0
- package/defaults/hooks/post-task-hook.mjs +63 -0
- package/defaults/hooks/rules-loader.mjs +212 -0
- package/defaults/hooks/sensitive-file-edit.mjs +84 -0
- package/defaults/hooks/session-activity-tracker.mjs +254 -0
- package/defaults/hooks/task-status-check.mjs +218 -0
- package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
- package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
- package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
- package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
- package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
- package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
- package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
- package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
- package/defaults/prompts/directives/coder-reviewer.md +106 -0
- package/defaults/prompts/directives/coder.md +90 -0
- package/defaults/prompts/directives/director.md +97 -0
- package/defaults/prompts/directives/doc-reviewer.md +93 -0
- package/defaults/prompts/directives/doc-writer.md +85 -0
- package/defaults/prompts/directives/executor-reviewer.md +96 -0
- package/defaults/prompts/directives/executor.md +85 -0
- package/defaults/prompts/directives/milestone-executor.md +119 -0
- package/defaults/prompts/directives/milestone-reviewer.md +108 -0
- package/defaults/prompts/directives/plan-executor.md +121 -0
- package/defaults/prompts/directives/plan-reviewer.md +99 -0
- package/defaults/prompts/systemPrompts/coder.md +64 -0
- package/defaults/prompts/systemPrompts/direct.md +92 -0
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
- package/defaults/prompts/systemPrompts/web.md +50 -0
- package/defaults/prompts/systemPrompts/worker.md +67 -0
- package/defaults/rules/correction-propagation.md +31 -0
- package/defaults/rules/decision-records.md +49 -0
- package/defaults/rules/experiment-format.md +165 -0
- package/defaults/rules/issues-md.md +37 -0
- package/defaults/rules/meta-conventions.md +45 -0
- package/defaults/rules/mission-md.md +47 -0
- package/defaults/rules/overview-md.md +41 -0
- package/defaults/rules/roadmap-md.md +55 -0
- package/defaults/rules/status-md.md +49 -0
- package/defaults/rules/task-system.md +53 -0
- package/dist/agent-adapter/capabilities.d.ts +12 -0
- package/dist/agent-adapter/capabilities.js +52 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
- package/dist/agent-adapter/claude/adapter-tui.js +422 -0
- package/dist/agent-adapter/claude/adapter.d.ts +85 -0
- package/dist/agent-adapter/claude/adapter.js +771 -0
- package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
- package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +49 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
- package/dist/agent-adapter/claude/event-parser.js +173 -0
- package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
- package/dist/agent-adapter/claude/hooks-builder.js +57 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
- package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
- package/dist/agent-adapter/claude/spawn-args.js +83 -0
- package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
- package/dist/agent-adapter/claude/tmux-control.js +127 -0
- package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
- package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
- package/dist/agent-adapter/codex/adapter.d.ts +42 -0
- package/dist/agent-adapter/codex/adapter.js +916 -0
- package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
- package/dist/agent-adapter/codex/event-parser.js +41 -0
- package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
- package/dist/agent-adapter/codex/spawn-args.js +30 -0
- package/dist/agent-adapter/index.d.ts +8 -0
- package/dist/agent-adapter/index.js +33 -0
- package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
- package/dist/agent-adapter/normalize/event-stream.js +47 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
- package/dist/agent-adapter/normalize/event-types.js +5 -0
- package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
- package/dist/agent-adapter/normalize/hooks.js +5 -0
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
- package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
- package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
- package/dist/agent-adapter/normalize/tool-names.js +73 -0
- package/dist/agent-adapter/pi/adapter.d.ts +60 -0
- package/dist/agent-adapter/pi/adapter.js +626 -0
- package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
- package/dist/agent-adapter/pi/agent-dir.js +34 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
- package/dist/agent-adapter/pi/event-parser.js +313 -0
- package/dist/agent-adapter/pi/framing.d.ts +6 -0
- package/dist/agent-adapter/pi/framing.js +35 -0
- package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
- package/dist/agent-adapter/pi/hook-bridge.js +233 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
- package/dist/agent-adapter/pi/spawn-args.js +54 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
- package/dist/agent-adapter/pi/tool-shims.js +181 -0
- package/dist/agent-adapter/types.d.ts +94 -0
- package/dist/agent-adapter/types.js +5 -0
- package/dist/core/async-mutex.d.ts +6 -0
- package/dist/core/async-mutex.js +36 -0
- package/dist/core/cli-utils.d.ts +37 -0
- package/dist/core/cli-utils.js +69 -0
- package/dist/core/config-generator.d.ts +9 -0
- package/dist/core/config-generator.js +58 -0
- package/dist/core/gateway-generator.d.ts +46 -0
- package/dist/core/gateway-generator.js +336 -0
- package/dist/core/log.d.ts +7 -0
- package/dist/core/log.js +103 -0
- package/dist/core/paths.d.ts +32 -0
- package/dist/core/paths.js +49 -0
- package/dist/core/profile-generator.d.ts +65 -0
- package/dist/core/profile-generator.js +310 -0
- package/dist/core/running-executions.d.ts +88 -0
- package/dist/core/running-executions.js +186 -0
- package/dist/core/status-format.d.ts +18 -0
- package/dist/core/status-format.js +31 -0
- package/dist/core/task-parser.d.ts +69 -0
- package/dist/core/task-parser.js +423 -0
- package/dist/core/types/agent-types.d.ts +31 -0
- package/dist/core/types/agent-types.js +5 -0
- package/dist/core/types/thread-types.d.ts +261 -0
- package/dist/core/types/thread-types.js +5 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.js +98 -0
- package/dist/core/version.d.ts +3 -0
- package/dist/core/version.js +12 -0
- package/dist/domain/agents/config.d.ts +58 -0
- package/dist/domain/agents/config.js +313 -0
- package/dist/domain/agents/facade.d.ts +52 -0
- package/dist/domain/agents/facade.js +264 -0
- package/dist/domain/agents/index.d.ts +2 -0
- package/dist/domain/agents/index.js +4 -0
- package/dist/domain/agents/profile-manager.d.ts +54 -0
- package/dist/domain/agents/profile-manager.js +161 -0
- package/dist/domain/costs/codex-event-format.d.ts +4 -0
- package/dist/domain/costs/codex-event-format.js +66 -0
- package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
- package/dist/domain/costs/codex-usage-monitor.js +72 -0
- package/dist/domain/costs/cost-tracker.d.ts +115 -0
- package/dist/domain/costs/cost-tracker.js +327 -0
- package/dist/domain/costs/gateway-manager.d.ts +6 -0
- package/dist/domain/costs/gateway-manager.js +228 -0
- package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
- package/dist/domain/costs/rate-limit-parser.js +87 -0
- package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
- package/dist/domain/costs/rate-limit-throttle.js +129 -0
- package/dist/domain/executions/registry.d.ts +20 -0
- package/dist/domain/executions/registry.js +124 -0
- package/dist/domain/mcp/core-server.d.ts +2 -0
- package/dist/domain/mcp/core-server.js +34 -0
- package/dist/domain/mcp/server.d.ts +3 -0
- package/dist/domain/mcp/server.js +78 -0
- package/dist/domain/mcp/tools/context.d.ts +23 -0
- package/dist/domain/mcp/tools/context.js +51 -0
- package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
- package/dist/domain/mcp/tools/cortex-md.js +36 -0
- package/dist/domain/mcp/tools/cost.d.ts +2 -0
- package/dist/domain/mcp/tools/cost.js +54 -0
- package/dist/domain/mcp/tools/executions.d.ts +2 -0
- package/dist/domain/mcp/tools/executions.js +94 -0
- package/dist/domain/mcp/tools/schedule.d.ts +23 -0
- package/dist/domain/mcp/tools/schedule.js +245 -0
- package/dist/domain/mcp/tools/slack.d.ts +21 -0
- package/dist/domain/mcp/tools/slack.js +124 -0
- package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/task-ops.js +509 -0
- package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
- package/dist/domain/mcp/tools/tui-ask.js +108 -0
- package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
- package/dist/domain/mcp/tools/tui-plan.js +118 -0
- package/dist/domain/mcp/tui-server.d.ts +2 -0
- package/dist/domain/mcp/tui-server.js +69 -0
- package/dist/domain/memory/consolidate.d.ts +55 -0
- package/dist/domain/memory/consolidate.js +471 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
- package/dist/domain/memory/cortex-md-injector.js +123 -0
- package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
- package/dist/domain/memory/cortex-md-scanner.js +67 -0
- package/dist/domain/memory/index-regen.d.ts +19 -0
- package/dist/domain/memory/index-regen.js +398 -0
- package/dist/domain/memory/rules-loader.d.ts +27 -0
- package/dist/domain/memory/rules-loader.js +97 -0
- package/dist/domain/memory/skill-scanner.d.ts +5 -0
- package/dist/domain/memory/skill-scanner.js +132 -0
- package/dist/domain/memory/user-context.d.ts +5 -0
- package/dist/domain/memory/user-context.js +34 -0
- package/dist/domain/memory/watcher.d.ts +2 -0
- package/dist/domain/memory/watcher.js +81 -0
- package/dist/domain/monitor/disk-monitor.d.ts +20 -0
- package/dist/domain/monitor/disk-monitor.js +97 -0
- package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
- package/dist/domain/monitor/gpu-monitor.js +135 -0
- package/dist/domain/remote/client-bootstrap.d.ts +1 -0
- package/dist/domain/remote/client-bootstrap.js +139 -0
- package/dist/domain/remote/client-hot-reload.d.ts +18 -0
- package/dist/domain/remote/client-hot-reload.js +142 -0
- package/dist/domain/remote/client-manager.d.ts +50 -0
- package/dist/domain/remote/client-manager.js +452 -0
- package/dist/domain/remote/cortex-client.d.ts +1 -0
- package/dist/domain/remote/cortex-client.js +704 -0
- package/dist/domain/scheduling/job-registry.d.ts +31 -0
- package/dist/domain/scheduling/job-registry.js +34 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
- package/dist/domain/scheduling/jobs/_shared.js +45 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
- package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
- package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
- package/dist/domain/scheduling/jobs/task-archive.js +19 -0
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
- package/dist/domain/scheduling/runner.d.ts +13 -0
- package/dist/domain/scheduling/runner.js +24 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
- package/dist/domain/scheduling/schedule-cli.js +268 -0
- package/dist/domain/scheduling/schedule-command.d.ts +4 -0
- package/dist/domain/scheduling/schedule-command.js +274 -0
- package/dist/domain/scheduling/scheduler.d.ts +86 -0
- package/dist/domain/scheduling/scheduler.js +544 -0
- package/dist/domain/sessions/session-backup.d.ts +49 -0
- package/dist/domain/sessions/session-backup.js +217 -0
- package/dist/domain/sessions/session-hooks.d.ts +103 -0
- package/dist/domain/sessions/session-hooks.js +311 -0
- package/dist/domain/sessions/session-registry.d.ts +21 -0
- package/dist/domain/sessions/session-registry.js +31 -0
- package/dist/domain/sessions/session.d.ts +3 -0
- package/dist/domain/sessions/session.js +14 -0
- package/dist/domain/tasks/archiver.d.ts +9 -0
- package/dist/domain/tasks/archiver.js +123 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
- package/dist/domain/tasks/dispatch-utils.js +143 -0
- package/dist/domain/tasks/dispatcher.d.ts +48 -0
- package/dist/domain/tasks/dispatcher.js +285 -0
- package/dist/domain/tasks/lint.d.ts +12 -0
- package/dist/domain/tasks/lint.js +102 -0
- package/dist/domain/tasks/mutator.d.ts +21 -0
- package/dist/domain/tasks/mutator.js +208 -0
- package/dist/domain/tasks/parser.d.ts +1 -0
- package/dist/domain/tasks/parser.js +6 -0
- package/dist/domain/tasks/pending-tracker.d.ts +67 -0
- package/dist/domain/tasks/pending-tracker.js +163 -0
- package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
- package/dist/domain/tasks/recommendation/extractor.js +563 -0
- package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
- package/dist/domain/tasks/recommendation/patterns.js +99 -0
- package/dist/domain/tasks/recommendation/types.d.ts +67 -0
- package/dist/domain/tasks/recommendation/types.js +5 -0
- package/dist/domain/tasks/store.d.ts +1 -0
- package/dist/domain/tasks/store.js +3 -0
- package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
- package/dist/domain/tasks/system/cortex-run.js +342 -0
- package/dist/domain/tasks/system/task-cli.d.ts +49 -0
- package/dist/domain/tasks/system/task-cli.js +664 -0
- package/dist/domain/tasks/system/task-completion.d.ts +22 -0
- package/dist/domain/tasks/system/task-completion.js +89 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
- package/dist/domain/tasks/system/task-id-utils.js +84 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
- package/dist/domain/tasks/system/task-lock.d.ts +25 -0
- package/dist/domain/tasks/system/task-lock.js +139 -0
- package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
- package/dist/domain/tasks/system/task-mutations.js +110 -0
- package/dist/domain/tasks/system/task-process.d.ts +37 -0
- package/dist/domain/tasks/system/task-process.js +119 -0
- package/dist/domain/tasks/system/task-state.d.ts +70 -0
- package/dist/domain/tasks/system/task-state.js +176 -0
- package/dist/domain/threads/artifact-io.d.ts +18 -0
- package/dist/domain/threads/artifact-io.js +182 -0
- package/dist/domain/threads/auto-thread.d.ts +3 -0
- package/dist/domain/threads/auto-thread.js +19 -0
- package/dist/domain/threads/hook-runner.d.ts +4 -0
- package/dist/domain/threads/hook-runner.js +250 -0
- package/dist/domain/threads/index.d.ts +5 -0
- package/dist/domain/threads/index.js +7 -0
- package/dist/domain/threads/prompt-builder.d.ts +25 -0
- package/dist/domain/threads/prompt-builder.js +176 -0
- package/dist/domain/threads/runner.d.ts +83 -0
- package/dist/domain/threads/runner.js +434 -0
- package/dist/domain/threads/state-machine.d.ts +61 -0
- package/dist/domain/threads/state-machine.js +440 -0
- package/dist/domain/threads/template-loader.d.ts +20 -0
- package/dist/domain/threads/template-loader.js +189 -0
- package/dist/domain/threads/template-resolver.d.ts +1 -0
- package/dist/domain/threads/template-resolver.js +95 -0
- package/dist/domain/threads/utils.d.ts +19 -0
- package/dist/domain/threads/utils.js +49 -0
- package/dist/entry/app.d.ts +1 -0
- package/dist/entry/app.js +234 -0
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +254 -0
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +521 -0
- package/dist/entry/init.d.ts +93 -0
- package/dist/entry/init.js +1299 -0
- package/dist/entry/startup-helpers.d.ts +2 -0
- package/dist/entry/startup-helpers.js +56 -0
- package/dist/entry/startup-notify.d.ts +10 -0
- package/dist/entry/startup-notify.js +20 -0
- package/dist/events/event-bus.d.ts +42 -0
- package/dist/events/event-bus.js +84 -0
- package/dist/events/event-logger.d.ts +12 -0
- package/dist/events/event-logger.js +135 -0
- package/dist/events/event-replay.d.ts +1 -0
- package/dist/events/event-replay.js +51 -0
- package/dist/events/event-types.d.ts +145 -0
- package/dist/events/event-types.js +5 -0
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +6 -0
- package/dist/hooks/ask-user-question-hook.mjs +66 -0
- package/dist/hooks/cortex-md-injector.mjs +237 -0
- package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
- package/dist/hooks/memory-ref-tracker.mjs +154 -0
- package/dist/hooks/new-session-hook.mjs +83 -0
- package/dist/hooks/post-task-hook.mjs +63 -0
- package/dist/hooks/rules-loader.mjs +212 -0
- package/dist/hooks/sensitive-file-edit.mjs +84 -0
- package/dist/hooks/session-activity-tracker.mjs +254 -0
- package/dist/hooks/task-status-check.mjs +218 -0
- package/dist/hooks/tasks-yaml-guard.mjs +230 -0
- package/dist/orchestration/agent-runner.d.ts +72 -0
- package/dist/orchestration/agent-runner.js +289 -0
- package/dist/orchestration/busy-tracker.d.ts +12 -0
- package/dist/orchestration/busy-tracker.js +35 -0
- package/dist/orchestration/channel-queue.d.ts +18 -0
- package/dist/orchestration/channel-queue.js +32 -0
- package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
- package/dist/orchestration/dispatch-reconciler.js +16 -0
- package/dist/orchestration/durable-helpers.d.ts +4 -0
- package/dist/orchestration/durable-helpers.js +42 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
- package/dist/orchestration/interactions/ask-user-question.js +182 -0
- package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
- package/dist/orchestration/interactions/command-action-router.js +91 -0
- package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
- package/dist/orchestration/interactions/interaction-handlers.js +279 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
- package/dist/orchestration/interactions/plan-approvals.js +77 -0
- package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
- package/dist/orchestration/interactions/plan-handler.js +12 -0
- package/dist/orchestration/lifecycle.d.ts +50 -0
- package/dist/orchestration/lifecycle.js +308 -0
- package/dist/orchestration/orchestrator.d.ts +29 -0
- package/dist/orchestration/orchestrator.js +25 -0
- package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
- package/dist/orchestration/routing/commands/cancel.js +136 -0
- package/dist/orchestration/routing/commands/channel.d.ts +11 -0
- package/dist/orchestration/routing/commands/channel.js +219 -0
- package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
- package/dist/orchestration/routing/commands/command-context.js +4 -0
- package/dist/orchestration/routing/commands/cost.d.ts +3 -0
- package/dist/orchestration/routing/commands/cost.js +22 -0
- package/dist/orchestration/routing/commands/device.d.ts +6 -0
- package/dist/orchestration/routing/commands/device.js +83 -0
- package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
- package/dist/orchestration/routing/commands/dispatch.js +49 -0
- package/dist/orchestration/routing/commands/index.d.ts +15 -0
- package/dist/orchestration/routing/commands/index.js +130 -0
- package/dist/orchestration/routing/commands/mode.d.ts +13 -0
- package/dist/orchestration/routing/commands/mode.js +290 -0
- package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
- package/dist/orchestration/routing/commands/nvtop.js +103 -0
- package/dist/orchestration/routing/commands/orient.d.ts +2 -0
- package/dist/orchestration/routing/commands/orient.js +3 -0
- package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
- package/dist/orchestration/routing/commands/schedule.js +132 -0
- package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
- package/dist/orchestration/routing/commands/sendfile.js +92 -0
- package/dist/orchestration/routing/commands/session.d.ts +9 -0
- package/dist/orchestration/routing/commands/session.js +153 -0
- package/dist/orchestration/routing/commands/status.d.ts +7 -0
- package/dist/orchestration/routing/commands/status.js +180 -0
- package/dist/orchestration/routing/commands/tail.d.ts +2 -0
- package/dist/orchestration/routing/commands/tail.js +73 -0
- package/dist/orchestration/routing/commands/task.d.ts +6 -0
- package/dist/orchestration/routing/commands/task.js +142 -0
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
- package/dist/orchestration/routing/commands/thread.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread.js +2 -0
- package/dist/orchestration/routing/edit-handler.d.ts +24 -0
- package/dist/orchestration/routing/edit-handler.js +161 -0
- package/dist/orchestration/routing/file-handler.d.ts +6 -0
- package/dist/orchestration/routing/file-handler.js +23 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
- package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
- package/dist/orchestration/routing/hook-bridge.js +112 -0
- package/dist/orchestration/routing/message-router.d.ts +6 -0
- package/dist/orchestration/routing/message-router.js +70 -0
- package/dist/orchestration/routing/webhook.d.ts +10 -0
- package/dist/orchestration/routing/webhook.js +239 -0
- package/dist/orchestration/status-helpers.d.ts +66 -0
- package/dist/orchestration/status-helpers.js +222 -0
- package/dist/orchestration/superseded-edits.d.ts +22 -0
- package/dist/orchestration/superseded-edits.js +31 -0
- package/dist/orchestration/thread-executor.d.ts +31 -0
- package/dist/orchestration/thread-executor.js +234 -0
- package/dist/platform/adapter.d.ts +28 -0
- package/dist/platform/adapter.js +5 -0
- package/dist/platform/adapters/feishu.d.ts +66 -0
- package/dist/platform/adapters/feishu.js +558 -0
- package/dist/platform/adapters/index.d.ts +16 -0
- package/dist/platform/adapters/index.js +65 -0
- package/dist/platform/adapters/slack.d.ts +90 -0
- package/dist/platform/adapters/slack.js +630 -0
- package/dist/platform/index.d.ts +12 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/interactive-builder.d.ts +27 -0
- package/dist/platform/interactive-builder.js +120 -0
- package/dist/platform/testing.d.ts +100 -0
- package/dist/platform/testing.js +190 -0
- package/dist/platform/tool-trace.d.ts +33 -0
- package/dist/platform/tool-trace.js +165 -0
- package/dist/platform/types.d.ts +176 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/utils/rate-limiter.d.ts +92 -0
- package/dist/platform/utils/rate-limiter.js +213 -0
- package/dist/platform/virtual-message.d.ts +68 -0
- package/dist/platform/virtual-message.js +464 -0
- package/dist/store/atomic-write.d.ts +6 -0
- package/dist/store/atomic-write.js +18 -0
- package/dist/store/channel-repo.d.ts +21 -0
- package/dist/store/channel-repo.js +55 -0
- package/dist/store/conversation-ledger-repo.d.ts +86 -0
- package/dist/store/conversation-ledger-repo.js +220 -0
- package/dist/store/cost-repo.d.ts +57 -0
- package/dist/store/cost-repo.js +135 -0
- package/dist/store/execution-repo.d.ts +172 -0
- package/dist/store/execution-repo.js +343 -0
- package/dist/store/in-memory-repository.d.ts +14 -0
- package/dist/store/in-memory-repository.js +31 -0
- package/dist/store/json-repository.d.ts +51 -0
- package/dist/store/json-repository.js +118 -0
- package/dist/store/outbound-queue.d.ts +65 -0
- package/dist/store/outbound-queue.js +269 -0
- package/dist/store/profile-repo.d.ts +36 -0
- package/dist/store/profile-repo.js +144 -0
- package/dist/store/project-dir-repo.d.ts +22 -0
- package/dist/store/project-dir-repo.js +60 -0
- package/dist/store/schedule-repo.d.ts +92 -0
- package/dist/store/schedule-repo.js +88 -0
- package/dist/store/session-registry-repo.d.ts +38 -0
- package/dist/store/session-registry-repo.js +96 -0
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +56 -0
- package/dist/store/task-repo.d.ts +41 -0
- package/dist/store/task-repo.js +137 -0
- package/dist/store/thread-repo.d.ts +50 -0
- package/dist/store/thread-repo.js +190 -0
- package/package.json +58 -0
- package/scripts/postinstall-restart-trigger.mjs +39 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// input: PlatformAdapter, threadStore, domain/threads APIs
|
|
2
|
+
// output: handleThreadCmd(channel, adapter, msg)
|
|
3
|
+
// pos: !thread sub-command family handlers
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { createLogger } from '../../../core/log.js';
|
|
6
|
+
import { threadStore } from '../../../store/thread-repo.js';
|
|
7
|
+
import { listTemplates, listAgents } from '../../../domain/threads/index.js';
|
|
8
|
+
import { runningExecutions } from '../../../core/running-executions.js';
|
|
9
|
+
import { channelQueues } from '../../channel-queue.js';
|
|
10
|
+
const log = createLogger('thread-handlers');
|
|
11
|
+
async function handleThreadStatus(channel, adapter) {
|
|
12
|
+
const active = threadStore.findActive(channel);
|
|
13
|
+
if (!active) {
|
|
14
|
+
await adapter.postMessage(channel, { text: 'No active thread in this channel.' });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const agents = Object.keys(active.agents).join(', ');
|
|
18
|
+
const modeLabel = active.templateName ? active.templateName : 'ad-hoc';
|
|
19
|
+
const lines = [
|
|
20
|
+
`*Active Thread* \`${active.id}\` (${modeLabel})`,
|
|
21
|
+
`Status: ${active.status} | Active agent: ${active.activeAgent}`,
|
|
22
|
+
`Steps: ${active.steps.length} | Cost: $${active.totalCostUsd.toFixed(4)}`,
|
|
23
|
+
`Agents: ${agents}`,
|
|
24
|
+
];
|
|
25
|
+
if (active.status === 'aborted' && active.abortReason) {
|
|
26
|
+
lines.push(`Abort reason: ${active.abortReason}`);
|
|
27
|
+
}
|
|
28
|
+
await adapter.postMessage(channel, { text: lines.join('\n') });
|
|
29
|
+
}
|
|
30
|
+
async function handleThreadTemplates(channel, adapter) {
|
|
31
|
+
const templates = listTemplates();
|
|
32
|
+
if (templates.length === 0) {
|
|
33
|
+
await adapter.postMessage(channel, { text: 'No thread templates configured.' });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const lines = ['*Available Thread Templates*'];
|
|
37
|
+
for (const t of templates) {
|
|
38
|
+
const agentList = t.agents.map(a => typeof a === 'string' ? a : a.ref).join(', ');
|
|
39
|
+
lines.push(`• \`${t.name}\` — ${t.description} [agents: ${agentList}]`);
|
|
40
|
+
}
|
|
41
|
+
await adapter.postMessage(channel, { text: lines.join('\n') });
|
|
42
|
+
}
|
|
43
|
+
async function handleThreadAgents(channel, adapter) {
|
|
44
|
+
const agentDefs = listAgents();
|
|
45
|
+
const lines = [];
|
|
46
|
+
if (agentDefs.length > 0) {
|
|
47
|
+
lines.push('*Available Agents*');
|
|
48
|
+
for (const a of agentDefs) {
|
|
49
|
+
lines.push(`• \`${a.name}\` (${a.profile}) — ${a.description || ''}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
lines.push('No agents configured.');
|
|
54
|
+
}
|
|
55
|
+
const active = threadStore.findActive(channel);
|
|
56
|
+
if (active) {
|
|
57
|
+
lines.push('');
|
|
58
|
+
lines.push(`*Active Thread* \`${active.id}\``);
|
|
59
|
+
for (const [slotId, slot] of Object.entries(active.agents)) {
|
|
60
|
+
const isActiveAgent = slotId === active.activeAgent ? ' :arrow_left:' : '';
|
|
61
|
+
const sessionStr = slot.sessionName || 'no session';
|
|
62
|
+
lines.push(` • *${slotId}* (${slot.profile}) — ${slot.status} | ${sessionStr}${isActiveAgent}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
await adapter.postMessage(channel, { text: lines.join('\n') });
|
|
66
|
+
}
|
|
67
|
+
async function handleThreadCancelAlias(channel, adapter) {
|
|
68
|
+
// Alias for !cancel — delegate to the same killByKey behavior
|
|
69
|
+
if (runningExecutions.killByKey(channel)) {
|
|
70
|
+
log.info('Cancel requested for channel:', channel);
|
|
71
|
+
channelQueues.delete(channel);
|
|
72
|
+
await adapter.postMessage(channel, { text: ':octagonal_sign: Cancelled. Session preserved — next message will resume.' });
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
await adapter.postMessage(channel, { text: 'Nothing running to cancel.' });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function handleThreadList(channel, adapter) {
|
|
79
|
+
const threads = threadStore.findByChannel(channel).slice(0, 10);
|
|
80
|
+
if (threads.length === 0) {
|
|
81
|
+
await adapter.postMessage(channel, { text: 'No threads found for this channel.' });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const lines = ['*Recent Threads*'];
|
|
85
|
+
for (const t of threads) {
|
|
86
|
+
const modeLabel = t.templateName || 'ad-hoc';
|
|
87
|
+
lines.push(`• \`${t.id}\` ${modeLabel} — ${t.status} | ${t.steps.length} steps | $${t.totalCostUsd.toFixed(4)}`);
|
|
88
|
+
}
|
|
89
|
+
await adapter.postMessage(channel, { text: lines.join('\n') });
|
|
90
|
+
}
|
|
91
|
+
async function handleThreadListRunning(channel, adapter) {
|
|
92
|
+
const executions = runningExecutions.getAll().filter(e => e.threadId);
|
|
93
|
+
if (executions.length === 0) {
|
|
94
|
+
await adapter.postMessage(channel, { text: 'No running threads.' });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const lines = ['*Running Threads*'];
|
|
98
|
+
for (const exec of executions) {
|
|
99
|
+
const thread = exec.threadId ? threadStore.get(exec.threadId) : null;
|
|
100
|
+
const modeLabel = thread?.templateName || 'ad-hoc';
|
|
101
|
+
const stepCount = thread?.steps.length ?? 0;
|
|
102
|
+
const cost = thread?.totalCostUsd ?? 0;
|
|
103
|
+
lines.push(`• \`${exec.threadId}\` — ${exec.channel || '?'} | ${modeLabel} | ${stepCount} step(s) | $${cost.toFixed(4)}`);
|
|
104
|
+
}
|
|
105
|
+
await adapter.postMessage(channel, { text: lines.join('\n') });
|
|
106
|
+
}
|
|
107
|
+
async function sendThreadUsage(channel, adapter) {
|
|
108
|
+
await adapter.postMessage(channel, {
|
|
109
|
+
text: [
|
|
110
|
+
'*Thread Commands*',
|
|
111
|
+
'`!thread` — show active thread status',
|
|
112
|
+
'`!thread agents` — list available agents',
|
|
113
|
+
'`!thread templates` — list available templates',
|
|
114
|
+
'`!thread <agent> <message>` — start ad-hoc thread with one agent',
|
|
115
|
+
'`!thread <template> <message>` — start template-based thread',
|
|
116
|
+
'`!thread add <agent> [message]` — add agent to current thread',
|
|
117
|
+
'`!cancel` — cancel active thread (also `!thread cancel`)',
|
|
118
|
+
'`!thread list` — list recent threads',
|
|
119
|
+
'`!thread list --running` — list running threads across channels',
|
|
120
|
+
].join('\n'),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export async function handleThreadCmd(channel, adapter, msg) {
|
|
124
|
+
const args = msg.replace(/^!thread\s*/, '').trim();
|
|
125
|
+
if (!args)
|
|
126
|
+
return handleThreadStatus(channel, adapter);
|
|
127
|
+
if (args === 'templates')
|
|
128
|
+
return handleThreadTemplates(channel, adapter);
|
|
129
|
+
if (args === 'agents')
|
|
130
|
+
return handleThreadAgents(channel, adapter);
|
|
131
|
+
if (args === 'cancel')
|
|
132
|
+
return handleThreadCancelAlias(channel, adapter);
|
|
133
|
+
if (args === 'list')
|
|
134
|
+
return handleThreadList(channel, adapter);
|
|
135
|
+
if (args === 'list --running')
|
|
136
|
+
return handleThreadListRunning(channel, adapter);
|
|
137
|
+
return sendThreadUsage(channel, adapter);
|
|
138
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PlatformAdapter, MessageEditContext } from '../../platform/index.js';
|
|
2
|
+
import type { RunningExecutions } from '../../core/running-executions.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create an edit handler with injected app-level dependencies.
|
|
5
|
+
*
|
|
6
|
+
* @param deps.activeAgents - ActiveAgents singleton for per-channel handle registry
|
|
7
|
+
* @param deps.reprocessMessage - function(channel, text, client, opts) to re-process a message as a retry
|
|
8
|
+
* @param deps.closePooledSession - tear down any pooled agent process for the channel before
|
|
9
|
+
* reprocessing. Required for Claude backend, whose CLI runs in stream-json mode and keeps
|
|
10
|
+
* the conversation in memory; without an explicit close the new turn appends to stale state
|
|
11
|
+
* and ignores the freshly-restored JSONL.
|
|
12
|
+
*/
|
|
13
|
+
declare function createEditHandler(deps: {
|
|
14
|
+
activeAgents: RunningExecutions;
|
|
15
|
+
reprocessMessage: (channel: string, text: string, adapter: PlatformAdapter, opts: {
|
|
16
|
+
originalTs: string;
|
|
17
|
+
isRetry: boolean;
|
|
18
|
+
sessionId: string | null;
|
|
19
|
+
sessionName: string | null;
|
|
20
|
+
supersededStatusTimestamps?: string[];
|
|
21
|
+
}) => void;
|
|
22
|
+
closePooledSession?: (channel: string, backend: string) => void;
|
|
23
|
+
}): (ctx: MessageEditContext, adapter: PlatformAdapter) => Promise<void>;
|
|
24
|
+
export { createEditHandler };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createLogger } from '../../core/log.js';
|
|
2
|
+
import { conversationLedger } from '../../store/conversation-ledger-repo.js';
|
|
3
|
+
import * as sessionBackup from '../../domain/sessions/session-backup.js';
|
|
4
|
+
import { deleteSessionAsync } from '../../domain/sessions/session.js';
|
|
5
|
+
import { resolveBackendForChannel } from '../../domain/agents/index.js';
|
|
6
|
+
import { channelQueues } from '../channel-queue.js';
|
|
7
|
+
import { supersededEdits } from '../superseded-edits.js';
|
|
8
|
+
const log = createLogger('edit-handler');
|
|
9
|
+
const DEBOUNCE_MS = 500;
|
|
10
|
+
// Per-channel debounce timers for rapid edits
|
|
11
|
+
const pendingEdits = new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Create an edit handler with injected app-level dependencies.
|
|
14
|
+
*
|
|
15
|
+
* @param deps.activeAgents - ActiveAgents singleton for per-channel handle registry
|
|
16
|
+
* @param deps.reprocessMessage - function(channel, text, client, opts) to re-process a message as a retry
|
|
17
|
+
* @param deps.closePooledSession - tear down any pooled agent process for the channel before
|
|
18
|
+
* reprocessing. Required for Claude backend, whose CLI runs in stream-json mode and keeps
|
|
19
|
+
* the conversation in memory; without an explicit close the new turn appends to stale state
|
|
20
|
+
* and ignores the freshly-restored JSONL.
|
|
21
|
+
*/
|
|
22
|
+
function createEditHandler(deps) {
|
|
23
|
+
return async function handleMessageEdit(ctx, adapter) {
|
|
24
|
+
const { originalRef, newText } = ctx;
|
|
25
|
+
const channel = originalRef.channel;
|
|
26
|
+
const originalTs = originalRef.messageId;
|
|
27
|
+
log.info('Message edited:', { channel, ts: originalTs, new: newText?.substring(0, 40) });
|
|
28
|
+
// Look up the original processing record
|
|
29
|
+
const found = await conversationLedger.findTurn(channel, originalTs);
|
|
30
|
+
if (!found) {
|
|
31
|
+
log.info('No ledger record for edited message, ignoring');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Debounce: if another edit comes within 500ms, cancel the previous timer
|
|
35
|
+
const debounceKey = `${channel}:${originalTs}`;
|
|
36
|
+
if (pendingEdits.has(debounceKey)) {
|
|
37
|
+
clearTimeout(pendingEdits.get(debounceKey));
|
|
38
|
+
}
|
|
39
|
+
pendingEdits.set(debounceKey, setTimeout(async () => {
|
|
40
|
+
pendingEdits.delete(debounceKey);
|
|
41
|
+
try {
|
|
42
|
+
await processEdit({
|
|
43
|
+
channel,
|
|
44
|
+
adapter,
|
|
45
|
+
originalTs,
|
|
46
|
+
newText,
|
|
47
|
+
turnIndex: found.turnIndex,
|
|
48
|
+
conversation: found.conversation,
|
|
49
|
+
deps,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
log.error('Error processing edit:', e.message);
|
|
54
|
+
}
|
|
55
|
+
}, DEBOUNCE_MS));
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function processEdit({ channel, adapter, originalTs, newText, turnIndex, conversation, deps }) {
|
|
59
|
+
const { activeAgents, reprocessMessage, closePooledSession } = deps;
|
|
60
|
+
// Resolve the *effective* backend for this channel. conversation.backend was captured at
|
|
61
|
+
// initTurnTracking time using the global activeBackend, which doesn't honor channel
|
|
62
|
+
// profiles — a channel running profile `execute` (backend=pi) but global backend=claude
|
|
63
|
+
// would otherwise be routed to the Claude restore branch and miss the PI backup file.
|
|
64
|
+
// resolveBackendForChannel reads the channel's profile and falls back to global if absent.
|
|
65
|
+
const backend = resolveBackendForChannel(channel) || conversation.backend;
|
|
66
|
+
// Step 1: Cancel any active processing on this channel
|
|
67
|
+
if (activeAgents.has(channel)) {
|
|
68
|
+
supersededEdits.mark(channel);
|
|
69
|
+
activeAgents.supersede(channel, 'edit');
|
|
70
|
+
channelQueues.delete(channel);
|
|
71
|
+
log.info('Killed active process for edit retry');
|
|
72
|
+
}
|
|
73
|
+
// Step 2: Rollback — mark all turns from editedTurnIndex onward as superseded
|
|
74
|
+
const rollbackResult = await conversationLedger.rollbackTo(channel, turnIndex);
|
|
75
|
+
if (!rollbackResult) {
|
|
76
|
+
log.error('Rollback failed — no conversation found');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const { supersededTurns } = rollbackResult;
|
|
80
|
+
// Step 3: Delete old response messages + collect superseded status ts for permalink backfill
|
|
81
|
+
const supersededStatusTimestamps = await cleanupSupersededMessages(supersededTurns, channel, adapter);
|
|
82
|
+
// Step 4: Restore session backup
|
|
83
|
+
const sessionId = conversation.sessionId;
|
|
84
|
+
let useSessionId = sessionId;
|
|
85
|
+
let sessionName = conversation.sessionName;
|
|
86
|
+
if (turnIndex === 0) {
|
|
87
|
+
// Editing the first message — no prior context to preserve
|
|
88
|
+
await deleteSessionAsync(channel, backend);
|
|
89
|
+
useSessionId = null;
|
|
90
|
+
sessionName = null;
|
|
91
|
+
}
|
|
92
|
+
else if (backend === 'pi') {
|
|
93
|
+
// PI: restore via file-path-based backup + switch_session on next spawn
|
|
94
|
+
const piFile = sessionId ? sessionBackup.findPISessionFile(sessionId) : null;
|
|
95
|
+
const restored = piFile ? sessionBackup.restoreSessionFile(piFile, turnIndex) : false;
|
|
96
|
+
if (!restored) {
|
|
97
|
+
log.warn('No backup found for PI session, falling back to new session');
|
|
98
|
+
await deleteSessionAsync(channel, backend);
|
|
99
|
+
useSessionId = null;
|
|
100
|
+
sessionName = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Claude / other backends: restore via sessionId-based backup
|
|
105
|
+
const restored = sessionId ? sessionBackup.restoreBackup(sessionId, turnIndex) : false;
|
|
106
|
+
if (!restored) {
|
|
107
|
+
log.warn('No backup found, falling back to new session');
|
|
108
|
+
await deleteSessionAsync(channel, backend);
|
|
109
|
+
useSessionId = null;
|
|
110
|
+
sessionName = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Step 4.5: Tear down any pooled agent process for this channel BEFORE reprocessing.
|
|
114
|
+
// Claude CLI runs in stream-json mode as a long-lived process and keeps the conversation
|
|
115
|
+
// in memory; restoring the JSONL on disk is a no-op unless we kill that process so the
|
|
116
|
+
// next runAgent spawns a fresh one with `--resume <sessionId>`. Without this, the
|
|
117
|
+
// edited message is appended as turn N+1 instead of replacing turn N — the symptom the
|
|
118
|
+
// user reported. PI/codex spawn a new subprocess per turn, so close is a no-op for them
|
|
119
|
+
// (the wiring still calls through but the function-level no-ops handle that branch).
|
|
120
|
+
closePooledSession?.(channel, backend);
|
|
121
|
+
// Step 5: Cleanup — remove superseded turns from ledger and invalidated backups
|
|
122
|
+
await conversationLedger.truncateTurns(channel, turnIndex);
|
|
123
|
+
if (backend === 'pi' && sessionId) {
|
|
124
|
+
const piFile = sessionBackup.findPISessionFile(sessionId);
|
|
125
|
+
if (piFile)
|
|
126
|
+
sessionBackup.cleanupBackupsForFile(piFile, turnIndex);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
sessionBackup.cleanupBackupsAfter(sessionId ?? '', turnIndex);
|
|
130
|
+
}
|
|
131
|
+
// Step 6: Re-enqueue the edited message for processing
|
|
132
|
+
reprocessMessage(channel, newText, adapter, {
|
|
133
|
+
originalTs,
|
|
134
|
+
isRetry: true,
|
|
135
|
+
sessionId: useSessionId,
|
|
136
|
+
sessionName,
|
|
137
|
+
supersededStatusTimestamps,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Delete response messages and update status messages for superseded turns.
|
|
142
|
+
* Returns the status message timestamps for permalink backfill by reprocessMessage.
|
|
143
|
+
*/
|
|
144
|
+
async function cleanupSupersededMessages(supersededTurns, channel, adapter) {
|
|
145
|
+
const promises = [];
|
|
146
|
+
const supersededStatusTimestamps = [];
|
|
147
|
+
for (const turn of supersededTurns) {
|
|
148
|
+
for (const ts of turn.responseMessageTimestamps) {
|
|
149
|
+
promises.push(adapter.deleteMessage({ channel, messageId: ts }).catch((e) => {
|
|
150
|
+
log.warn('Failed to delete message:', ts, e.message);
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
if (turn.statusMessageTs) {
|
|
154
|
+
supersededStatusTimestamps.push(turn.statusMessageTs);
|
|
155
|
+
promises.push(adapter.updateMessage({ channel, messageId: turn.statusMessageTs }, { text: `:fast_forward: Superseded by edit` }).catch(() => { }));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
await Promise.allSettled(promises);
|
|
159
|
+
return supersededStatusTimestamps;
|
|
160
|
+
}
|
|
161
|
+
export { createEditHandler };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PlatformAdapter } from '../../platform/adapter.js';
|
|
2
|
+
import type { PlatformFileRef, DownloadedFile } from '../../platform/types.js';
|
|
3
|
+
declare const IMAGE_MIMES: Set<string>;
|
|
4
|
+
declare const VIDEO_MIMES: Set<string>;
|
|
5
|
+
declare function downloadFiles(files: PlatformFileRef[] | undefined, adapter: PlatformAdapter, tempDir: string): Promise<DownloadedFile[]>;
|
|
6
|
+
export { downloadFiles, IMAGE_MIMES, VIDEO_MIMES };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// input: PlatformAdapter, PlatformFileRef, temp directory
|
|
2
|
+
// output: downloadFiles / IMAGE_MIMES / VIDEO_MIMES
|
|
3
|
+
// pos: Platform-agnostic file download and mimetype classification
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { createLogger } from '../../core/log.js';
|
|
6
|
+
const log = createLogger('file-handler');
|
|
7
|
+
const IMAGE_MIMES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
8
|
+
const VIDEO_MIMES = new Set(['video/mp4', 'video/webm', 'video/quicktime', 'video/x-msvideo', 'video/x-matroska']);
|
|
9
|
+
async function downloadFiles(files, adapter, tempDir) {
|
|
10
|
+
if (!files?.length)
|
|
11
|
+
return [];
|
|
12
|
+
const results = [];
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
try {
|
|
15
|
+
results.push(await adapter.downloadFile(file, tempDir));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
log.error('Failed to download file:', file.name, e.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return results;
|
|
22
|
+
}
|
|
23
|
+
export { downloadFiles, IMAGE_MIMES, VIDEO_MIMES };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventBus } from '../../events/index.js';
|
|
2
|
+
import type { PlatformAdapter } from '../../platform/index.js';
|
|
3
|
+
import type { PlanApprovals } from '../interactions/plan-approvals.js';
|
|
4
|
+
export declare function registerHookBridgeSubscribers(bus: EventBus, adapter: PlatformAdapter, planApprovals: PlanApprovals): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// input: EventBus, PlatformAdapter, PlanApprovals
|
|
2
|
+
// output: registerHookBridgeSubscribers(bus, adapter, planApprovals) — extracts
|
|
3
|
+
// ask-user.requested / plan.submitted handler bodies from entry/app.ts into orch/
|
|
4
|
+
// pos: orch/routing/ — hook-bridge event subscribers (S13 composition-root extraction)
|
|
5
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
6
|
+
import { createLogger } from '../../core/log.js';
|
|
7
|
+
import { buildPlanApprovalContent } from '../../platform/index.js';
|
|
8
|
+
import * as askUserQuestion from '../interactions/ask-user-question.js';
|
|
9
|
+
import { sendPlanToSlack } from '../interactions/plan-handler.js';
|
|
10
|
+
import { resolveRequest as resolveHookRequest, getStreamingCallback } from './hook-bridge.js';
|
|
11
|
+
const log = createLogger('hook-bridge');
|
|
12
|
+
export function registerHookBridgeSubscribers(bus, adapter, planApprovals) {
|
|
13
|
+
bus.subscribe('ask-user.requested', async (e) => {
|
|
14
|
+
const ev = e;
|
|
15
|
+
if (ev.dryRun)
|
|
16
|
+
return; // smoke-test: event is journalled, skip Slack post
|
|
17
|
+
try {
|
|
18
|
+
const group = askUserQuestion.createHookGroup(ev.requestId, ev.channel, ev.sessionId, ev.questions, ev.extensionUiId, ev.threadId ?? null);
|
|
19
|
+
askUserQuestion.registerHookResolver(ev.requestId, (data) => resolveHookRequest(ev.requestId, data));
|
|
20
|
+
// streamingCb is fetched only to extract the vm reference — not invoked directly for AskUser
|
|
21
|
+
const streamingCb = getStreamingCallback(ev.channel);
|
|
22
|
+
const vm = streamingCb?.vm;
|
|
23
|
+
const text = `Questions (${group.questions.length})`;
|
|
24
|
+
const richBlocks = askUserQuestion.buildQuestionGroupBlocks(group);
|
|
25
|
+
// Route through vm when available so standalone post flushes pending appends
|
|
26
|
+
// and resets vm state — without this, messages emitted after the form would
|
|
27
|
+
// be merged back into the message that preceded it.
|
|
28
|
+
if (vm) {
|
|
29
|
+
const ref = await vm.postStandalone(text, { richBlocks });
|
|
30
|
+
group.responseMessageTs = ref?.messageId || null;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const ref = await adapter.postMessage(ev.channel, { text, richBlocks });
|
|
34
|
+
group.responseMessageTs = ref.messageId;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
log.error(`Failed to post AskUserQuestion: ${e.message}`);
|
|
39
|
+
resolveHookRequest(ev.requestId, { error: 'post_failed', answers: {} });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
bus.subscribe('plan.submitted', async (e) => {
|
|
43
|
+
const ev = e;
|
|
44
|
+
if (ev.dryRun)
|
|
45
|
+
return; // smoke-test: event is journalled, skip Slack post + approval registration
|
|
46
|
+
try {
|
|
47
|
+
const streamingCb = getStreamingCallback(ev.channel);
|
|
48
|
+
const vm = streamingCb?.vm;
|
|
49
|
+
if (streamingCb && ev.planContent) {
|
|
50
|
+
streamingCb(ev.planContent);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
await sendPlanToSlack(ev.planContent || null, ev.channel, adapter);
|
|
54
|
+
}
|
|
55
|
+
planApprovals.register(ev.requestId, { channel: ev.channel, extensionUiId: ev.extensionUiId ?? null, threadId: ev.threadId ?? null });
|
|
56
|
+
const planApproval = buildPlanApprovalContent(ev.requestId);
|
|
57
|
+
// Route approval form through vm so it enqueues behind the plan content append,
|
|
58
|
+
// ensuring Slack ordering (plan text first, then button card) and resetting vm
|
|
59
|
+
// state so subsequent assistant output starts a fresh message instead of
|
|
60
|
+
// merging back into the message that preceded the form.
|
|
61
|
+
if (vm) {
|
|
62
|
+
await vm.postStandalone('Plan approval', {
|
|
63
|
+
richBlocks: planApproval.richBlocks,
|
|
64
|
+
actions: planApproval.actions,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await adapter.postInteractive(ev.channel, {
|
|
69
|
+
text: 'Plan approval',
|
|
70
|
+
...planApproval,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
log.error(`Failed to post plan: ${e.message}`);
|
|
76
|
+
resolveHookRequest(ev.requestId, { error: 'post_failed', approved: true, reason: '' });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EventBus } from '../../events/index.js';
|
|
2
|
+
/** Called once from app.ts during startup, before startWebhookServer(). */
|
|
3
|
+
declare function initHookBridge(bus: EventBus): void;
|
|
4
|
+
type QuestionNotify = (requestId: string, channel: string, sessionId: string, questions: any[]) => void;
|
|
5
|
+
type PlanNotify = (requestId: string, channel: string, sessionId: string, planContent: string, toolInput: any) => void;
|
|
6
|
+
/** @deprecated no-op since S5; replaced by bus.subscribe('ask-user.requested') in app.ts */
|
|
7
|
+
declare function setQuestionNotify(_cb: QuestionNotify): void;
|
|
8
|
+
/** @deprecated no-op since S5; replaced by bus.subscribe('plan.submitted') in app.ts */
|
|
9
|
+
declare function setPlanNotify(_cb: PlanNotify): void;
|
|
10
|
+
declare function registerAskQuestion(requestId: string, channel: string, sessionId: string, questions: any[], dryRun?: boolean, threadId?: string | null): Promise<any>;
|
|
11
|
+
declare function registerPlanApproval(requestId: string, channel: string, sessionId: string, planContent: string, toolInput: any, dryRun?: boolean, threadId?: string | null): Promise<any>;
|
|
12
|
+
declare function resolveRequest(requestId: string, data: any): boolean;
|
|
13
|
+
/** Register the active onAssistantMessage callback for a channel (called by app.ts before runAgent). */
|
|
14
|
+
declare function setStreamingCallback(channel: string, cb: (text: string) => void): void;
|
|
15
|
+
/** Clear the streaming callback when the turn ends (called by app.ts after runAgent). */
|
|
16
|
+
declare function clearStreamingCallback(channel: string): void;
|
|
17
|
+
/** Get the active streaming callback for a channel, if any. */
|
|
18
|
+
declare function getStreamingCallback(channel: string): ((text: string) => void) | null;
|
|
19
|
+
/**
|
|
20
|
+
* Publish plan.submitted directly (non-blocking, no pendingRequest).
|
|
21
|
+
* Used by PI backend: the resolution goes through sendExtensionUiResponse, not resolveRequest.
|
|
22
|
+
*/
|
|
23
|
+
declare function publishPlanSubmitted(requestId: string, channel: string, sessionId: string, planContent: string, extensionUiId: string, threadId?: string | null): void;
|
|
24
|
+
/**
|
|
25
|
+
* Publish ask-user.requested directly (non-blocking, no pendingRequest).
|
|
26
|
+
* Used by PI backend: the resolution goes through sendExtensionUiResponse, not resolveRequest.
|
|
27
|
+
* @param extensionUiId — original PI extension_ui_request id; required for sendExtensionUiResponse to unblock the PI subprocess.
|
|
28
|
+
*/
|
|
29
|
+
declare function publishAskUserRequested(requestId: string, channel: string, sessionId: string, questions: any[], extensionUiId?: string, threadId?: string | null): void;
|
|
30
|
+
export { initHookBridge, setQuestionNotify, setPlanNotify, registerAskQuestion, registerPlanApproval, resolveRequest, setStreamingCallback, clearStreamingCallback, getStreamingCallback, publishPlanSubmitted, publishAskUserRequested };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// input: HTTP hook requests (AskUserQuestion/ExitPlanMode)
|
|
2
|
+
// output: register/resolve + bus publish
|
|
3
|
+
// pos: PreToolUse hook ↔ Slack interaction communication bridge (S5: callbacks replaced by EventBus)
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { createLogger } from '../../core/log.js';
|
|
6
|
+
const TTL_MS = 30 * 60 * 1000; // 30 minutes — matches ASK_USER_QUESTION_TTL_MS
|
|
7
|
+
const log = createLogger('hook-bridge');
|
|
8
|
+
const pendingRequests = new Map();
|
|
9
|
+
// --- EventBus reference (set once by app.ts via initHookBridge) ---
|
|
10
|
+
let _bus = null;
|
|
11
|
+
/** Called once from app.ts during startup, before startWebhookServer(). */
|
|
12
|
+
function initHookBridge(bus) {
|
|
13
|
+
_bus = bus;
|
|
14
|
+
}
|
|
15
|
+
/** @deprecated no-op since S5; replaced by bus.subscribe('ask-user.requested') in app.ts */
|
|
16
|
+
function setQuestionNotify(_cb) { }
|
|
17
|
+
/** @deprecated no-op since S5; replaced by bus.subscribe('plan.submitted') in app.ts */
|
|
18
|
+
function setPlanNotify(_cb) { }
|
|
19
|
+
// --- Registration (called by webhook routes, blocks until Slack interaction completes) ---
|
|
20
|
+
function registerAskQuestion(requestId, channel, sessionId, questions, dryRun = false, threadId) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
if (!_bus) {
|
|
23
|
+
log.error('bus not initialised; failing ask-user request immediately');
|
|
24
|
+
resolve({ error: 'bus_not_initialized', answers: {} });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (dryRun) {
|
|
28
|
+
// Smoke-test path: publish event for journal capture, skip Slack interaction, resolve synthetically.
|
|
29
|
+
_bus.publish({ type: 'ask-user.requested', requestId, channel, sessionId, threadId: threadId ?? null, questions, dryRun: true });
|
|
30
|
+
resolve({ dryRun: true, answers: {} });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
pendingRequests.set(requestId, { resolve, channel, sessionId, createdAt: Date.now() });
|
|
34
|
+
_bus.publish({ type: 'ask-user.requested', requestId, channel, sessionId, threadId: threadId ?? null, questions });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function registerPlanApproval(requestId, channel, sessionId, planContent, toolInput, dryRun = false, threadId) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
if (!_bus) {
|
|
40
|
+
log.error('bus not initialised; failing plan-approval request immediately');
|
|
41
|
+
resolve({ error: 'bus_not_initialized', approved: true, reason: '' });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (dryRun) {
|
|
45
|
+
// Smoke-test path: publish event for journal capture, skip Slack post, resolve synthetically.
|
|
46
|
+
_bus.publish({ type: 'plan.submitted', requestId, channel, sessionId, threadId: threadId ?? null, planContent, toolInput, dryRun: true });
|
|
47
|
+
resolve({ dryRun: true, approved: true, reason: '' });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
pendingRequests.set(requestId, { resolve, channel, sessionId, createdAt: Date.now() });
|
|
51
|
+
_bus.publish({ type: 'plan.submitted', requestId, channel, sessionId, threadId: threadId ?? null, planContent, toolInput });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// --- Resolution (called by Slack handlers in app.ts) ---
|
|
55
|
+
function resolveRequest(requestId, data) {
|
|
56
|
+
const pending = pendingRequests.get(requestId);
|
|
57
|
+
if (!pending)
|
|
58
|
+
return false;
|
|
59
|
+
pending.resolve(data);
|
|
60
|
+
pendingRequests.delete(requestId);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
// --- Cleanup stale requests ---
|
|
64
|
+
function cleanupStale() {
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
for (const [id, req] of pendingRequests) {
|
|
67
|
+
if (now - req.createdAt > TTL_MS) {
|
|
68
|
+
req.resolve({ error: 'timeout', answers: {} });
|
|
69
|
+
pendingRequests.delete(id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Run cleanup every 5 minutes
|
|
74
|
+
setInterval(cleanupStale, 5 * 60 * 1000).unref();
|
|
75
|
+
// --- Per-channel streaming context (for thread-aware hook messages) ---
|
|
76
|
+
const streamingCallbacks = new Map();
|
|
77
|
+
/** Register the active onAssistantMessage callback for a channel (called by app.ts before runAgent). */
|
|
78
|
+
function setStreamingCallback(channel, cb) {
|
|
79
|
+
streamingCallbacks.set(channel, cb);
|
|
80
|
+
}
|
|
81
|
+
/** Clear the streaming callback when the turn ends (called by app.ts after runAgent). */
|
|
82
|
+
function clearStreamingCallback(channel) {
|
|
83
|
+
streamingCallbacks.delete(channel);
|
|
84
|
+
}
|
|
85
|
+
/** Get the active streaming callback for a channel, if any. */
|
|
86
|
+
function getStreamingCallback(channel) {
|
|
87
|
+
return streamingCallbacks.get(channel) || null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Publish plan.submitted directly (non-blocking, no pendingRequest).
|
|
91
|
+
* Used by PI backend: the resolution goes through sendExtensionUiResponse, not resolveRequest.
|
|
92
|
+
*/
|
|
93
|
+
function publishPlanSubmitted(requestId, channel, sessionId, planContent, extensionUiId, threadId) {
|
|
94
|
+
if (!_bus) {
|
|
95
|
+
log.error('bus not initialised; dropping PI plan.submitted');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
_bus.publish({ type: 'plan.submitted', requestId, channel, sessionId, threadId: threadId ?? null, planContent, toolInput: {}, extensionUiId });
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Publish ask-user.requested directly (non-blocking, no pendingRequest).
|
|
102
|
+
* Used by PI backend: the resolution goes through sendExtensionUiResponse, not resolveRequest.
|
|
103
|
+
* @param extensionUiId — original PI extension_ui_request id; required for sendExtensionUiResponse to unblock the PI subprocess.
|
|
104
|
+
*/
|
|
105
|
+
function publishAskUserRequested(requestId, channel, sessionId, questions, extensionUiId, threadId) {
|
|
106
|
+
if (!_bus) {
|
|
107
|
+
log.error('bus not initialised; dropping PI ask-user.requested');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
_bus.publish({ type: 'ask-user.requested', requestId, channel, sessionId, threadId: threadId ?? null, questions, extensionUiId });
|
|
111
|
+
}
|
|
112
|
+
export { initHookBridge, setQuestionNotify, setPlanNotify, registerAskQuestion, registerPlanApproval, resolveRequest, setStreamingCallback, clearStreamingCallback, getStreamingCallback, publishPlanSubmitted, publishAskUserRequested };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PlatformAdapter, MessageEditContext } from '../../platform/index.js';
|
|
2
|
+
export interface MessageHandlerDeps {
|
|
3
|
+
dispatchCommand: (text: string | undefined, channel: string, adapter: PlatformAdapter, threadTs?: string | null) => boolean;
|
|
4
|
+
handleMessageEdit: (ctx: MessageEditContext, adapter: PlatformAdapter) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function registerMessageHandler(adapter: PlatformAdapter, deps: MessageHandlerDeps): void;
|