@cortex-agent/server 2026.5.25 → 2026.6.11
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/config/thread-templates.json +28 -1
- package/defaults/hooks/cortex-md-injector.mjs +47 -31
- package/defaults/hooks/post-task-hook.mjs +6 -0
- package/defaults/hooks/task-status-check.mjs +8 -0
- package/defaults/mcp-config-slack.json +11 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +18 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +5 -6
- package/defaults/prompts/directives/manager.md +67 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +35 -3
- package/dist/agent-adapter/claude/adapter-tui.js +91 -12
- package/dist/agent-adapter/claude/adapter.js +11 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +30 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +2 -2
- package/dist/agent-adapter/claude/jsonl-tail.js +25 -20
- package/dist/agent-adapter/claude/spawn-args.d.ts +11 -0
- package/dist/agent-adapter/claude/spawn-args.js +49 -7
- package/dist/agent-adapter/claude/tmux-control.d.ts +20 -0
- package/dist/agent-adapter/claude/tmux-control.js +54 -8
- package/dist/agent-adapter/codex/adapter.js +1 -1
- package/dist/agent-adapter/normalize/event-types.d.ts +1 -0
- package/dist/agent-adapter/pi/adapter.js +46 -19
- package/dist/agent-adapter/pi/agent-dir.d.ts +21 -0
- package/dist/agent-adapter/pi/agent-dir.js +53 -2
- package/dist/agent-adapter/pi/event-parser.js +13 -1
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +12 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +47 -9
- package/dist/agent-adapter/pi/tool-shims.d.ts +14 -0
- package/dist/agent-adapter/pi/tool-shims.js +167 -140
- package/dist/agent-adapter/types.d.ts +7 -2
- package/dist/core/atomic-write.js +21 -0
- package/dist/core/config-generator.d.ts +10 -0
- package/dist/core/config-generator.js +28 -0
- package/dist/core/gateway-generator.d.ts +77 -7
- package/dist/core/gateway-generator.js +301 -29
- package/dist/core/icons.d.ts +68 -0
- package/dist/core/icons.js +67 -0
- package/dist/core/profile-generator.d.ts +6 -0
- package/dist/core/profile-generator.js +35 -7
- package/dist/core/running-executions.d.ts +51 -41
- package/dist/core/running-executions.js +120 -73
- package/dist/core/status-format.js +3 -2
- package/dist/core/task-parser.d.ts +3 -0
- package/dist/core/task-parser.js +3 -1
- package/dist/core/types/thread-types.d.ts +54 -8
- package/dist/domain/agents/facade.d.ts +18 -0
- package/dist/domain/agents/facade.js +26 -3
- package/dist/domain/agents/profile-manager.d.ts +11 -0
- package/dist/domain/agents/profile-manager.js +21 -2
- package/dist/domain/costs/codex-usage-monitor.js +2 -1
- package/dist/domain/costs/rate-limit-throttle.js +14 -2
- package/dist/domain/executions/registry.d.ts +24 -0
- package/dist/domain/executions/registry.js +38 -0
- package/dist/domain/mcp/core-server.js +15 -3
- package/dist/domain/mcp/feishu/bitable.d.ts +3 -0
- package/dist/domain/mcp/feishu/bitable.js +168 -0
- package/dist/domain/mcp/feishu/block-types.d.ts +44 -0
- package/dist/domain/mcp/feishu/block-types.js +127 -0
- package/dist/domain/mcp/feishu/blocks-to-text.d.ts +19 -0
- package/dist/domain/mcp/feishu/blocks-to-text.js +43 -0
- package/dist/domain/mcp/feishu/client.d.ts +46 -0
- package/dist/domain/mcp/feishu/client.js +87 -0
- package/dist/domain/mcp/feishu/docx.d.ts +3 -0
- package/dist/domain/mcp/feishu/docx.js +163 -0
- package/dist/domain/mcp/feishu/drive.d.ts +23 -0
- package/dist/domain/mcp/feishu/drive.js +66 -0
- package/dist/domain/mcp/feishu/file.d.ts +14 -0
- package/dist/domain/mcp/feishu/file.js +107 -0
- package/dist/domain/mcp/feishu/index.d.ts +6 -0
- package/dist/domain/mcp/feishu/index.js +61 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +40 -0
- package/dist/domain/mcp/feishu/markdown-to-blocks.js +191 -0
- package/dist/domain/mcp/feishu/sheets.d.ts +3 -0
- package/dist/domain/mcp/feishu/sheets.js +119 -0
- package/dist/domain/mcp/feishu/types.d.ts +26 -0
- package/dist/domain/mcp/feishu/types.js +38 -0
- package/dist/domain/mcp/feishu/user-auth.d.ts +140 -0
- package/dist/domain/mcp/feishu/user-auth.js +286 -0
- package/dist/domain/mcp/feishu/wiki.d.ts +3 -0
- package/dist/domain/mcp/feishu/wiki.js +77 -0
- package/dist/domain/mcp/feishu-server.d.ts +2 -0
- package/dist/domain/mcp/feishu-server.js +33 -0
- package/dist/domain/mcp/server.d.ts +0 -1
- package/dist/domain/mcp/server.js +6 -25
- package/dist/domain/mcp/slack-server.d.ts +3 -0
- package/dist/domain/mcp/slack-server.js +46 -0
- package/dist/domain/mcp/tools/context.js +1 -1
- package/dist/domain/mcp/tools/schedule.d.ts +1 -1
- package/dist/domain/mcp/tools/schedule.js +6 -20
- package/dist/domain/mcp/tools/slack.js +20 -7
- package/dist/domain/mcp/tools/thread-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/thread-ops.js +121 -0
- package/dist/domain/mcp/tools/time.d.ts +2 -0
- package/dist/domain/mcp/tools/time.js +66 -0
- package/dist/domain/mcp/tools/tui-ask.js +1 -1
- package/dist/domain/mcp/tools/tui-plan.js +2 -2
- package/dist/domain/mcp/tui-server.js +1 -0
- package/dist/domain/monitor/disk-monitor.js +2 -1
- package/dist/domain/monitor/gpu-monitor.js +2 -1
- package/dist/domain/remote/client-hot-reload.js +3 -2
- package/dist/domain/remote/client-manager.js +8 -6
- package/dist/domain/scheduling/job-registry.d.ts +4 -0
- package/dist/domain/scheduling/job-registry.js +1 -0
- package/dist/domain/scheduling/jobs/_shared.js +2 -1
- package/dist/domain/scheduling/jobs/memory-index-regen.js +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +9 -23
- package/dist/domain/scheduling/jobs/sync-public.js +4 -3
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +1 -8
- package/dist/domain/scheduling/jobs/target-dispatch.js +0 -7
- package/dist/domain/scheduling/jobs/task-archive.js +3 -2
- package/dist/domain/scheduling/jobs/task-dispatch.js +120 -10
- package/dist/domain/scheduling/schedule-command.js +16 -15
- package/dist/domain/scheduling/scheduler.d.ts +1 -1
- package/dist/domain/scheduling/scheduler.js +2 -1
- package/dist/domain/sessions/session-hooks.d.ts +2 -2
- package/dist/domain/sessions/session-hooks.js +19 -18
- package/dist/domain/sessions/session-lifecycle.d.ts +38 -0
- package/dist/domain/sessions/session-lifecycle.js +44 -0
- package/dist/domain/system/install-cli.d.ts +7 -0
- package/dist/domain/system/install-cli.js +106 -0
- package/dist/domain/system/server-update-check.js +2 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +58 -1
- package/dist/domain/tasks/dispatch-utils.js +53 -4
- package/dist/domain/tasks/dispatcher.js +26 -0
- package/dist/domain/tasks/lint.js +28 -0
- package/dist/domain/tasks/mutator.d.ts +16 -3
- package/dist/domain/tasks/mutator.js +41 -12
- package/dist/domain/tasks/pending-tracker.js +6 -5
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +37 -6
- package/dist/domain/tasks/system/task-lifecycle-edit.js +6 -1
- package/dist/domain/tasks/system/task-mutations.d.ts +41 -3
- package/dist/domain/tasks/system/task-mutations.js +166 -8
- package/dist/domain/threads/contract.d.ts +17 -0
- package/dist/domain/threads/contract.js +59 -0
- package/dist/domain/threads/hook-runner.js +7 -6
- package/dist/domain/threads/index.d.ts +2 -0
- package/dist/domain/threads/index.js +3 -1
- package/dist/domain/threads/prompt-builder.d.ts +15 -1
- package/dist/domain/threads/prompt-builder.js +41 -2
- package/dist/domain/threads/runner.d.ts +6 -5
- package/dist/domain/threads/runner.js +128 -79
- package/dist/domain/threads/state-machine.d.ts +23 -21
- package/dist/domain/threads/state-machine.js +113 -54
- package/dist/domain/threads/template-loader.js +3 -2
- package/dist/domain/threads/tree.d.ts +45 -0
- package/dist/domain/threads/tree.js +171 -0
- package/dist/domain/tui-session/index.d.ts +2 -0
- package/dist/domain/tui-session/index.js +3 -0
- package/dist/domain/tui-session/tui-session-service.d.ts +2 -0
- package/dist/domain/tui-session/tui-session-service.js +103 -0
- package/dist/domain/tui-session/types.d.ts +67 -0
- package/dist/domain/tui-session/types.js +4 -0
- package/dist/domain/ui-service/index.d.ts +5 -0
- package/dist/domain/ui-service/index.js +3 -0
- package/dist/domain/ui-service/mutate/executions.d.ts +4 -0
- package/dist/domain/ui-service/mutate/executions.js +15 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +10 -0
- package/dist/domain/ui-service/mutate/schedules.js +39 -0
- package/dist/domain/ui-service/mutate/tasks.d.ts +23 -0
- package/dist/domain/ui-service/mutate/tasks.js +59 -0
- package/dist/domain/ui-service/mutate/threads.d.ts +4 -0
- package/dist/domain/ui-service/mutate/threads.js +21 -0
- package/dist/domain/ui-service/query/cost.d.ts +3 -0
- package/dist/domain/ui-service/query/cost.js +6 -0
- package/dist/domain/ui-service/query/executions.d.ts +2 -0
- package/dist/domain/ui-service/query/executions.js +35 -0
- package/dist/domain/ui-service/query/projects.d.ts +2 -0
- package/dist/domain/ui-service/query/projects.js +30 -0
- package/dist/domain/ui-service/query/schedules.d.ts +2 -0
- package/dist/domain/ui-service/query/schedules.js +23 -0
- package/dist/domain/ui-service/query/sessions.d.ts +2 -0
- package/dist/domain/ui-service/query/sessions.js +35 -0
- package/dist/domain/ui-service/query/tasks.d.ts +2 -0
- package/dist/domain/ui-service/query/tasks.js +30 -0
- package/dist/domain/ui-service/query/threads.d.ts +2 -0
- package/dist/domain/ui-service/query/threads.js +27 -0
- package/dist/domain/ui-service/subscribe.d.ts +5 -0
- package/dist/domain/ui-service/subscribe.js +118 -0
- package/dist/domain/ui-service/types.d.ts +237 -0
- package/dist/domain/ui-service/types.js +5 -0
- package/dist/domain/ui-service/ui-service.d.ts +2 -0
- package/dist/domain/ui-service/ui-service.js +83 -0
- package/dist/entry/app.js +94 -5
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +122 -12
- package/dist/entry/feishu-login.d.ts +28 -0
- package/dist/entry/feishu-login.js +218 -0
- package/dist/entry/init.d.ts +25 -2
- package/dist/entry/init.js +211 -64
- package/dist/events/event-types.d.ts +14 -0
- package/dist/hooks/cortex-md-injector.mjs +47 -31
- package/dist/hooks/post-task-hook.mjs +6 -0
- package/dist/hooks/task-status-check.mjs +8 -0
- package/dist/orchestration/agent-runner.d.ts +2 -1
- package/dist/orchestration/agent-runner.js +55 -55
- package/dist/orchestration/conduit-queue.d.ts +18 -0
- package/dist/orchestration/conduit-queue.js +32 -0
- package/dist/orchestration/conversation-runner.d.ts +48 -0
- package/dist/orchestration/conversation-runner.js +109 -0
- package/dist/orchestration/dispatch-reconciler.js +8 -1
- package/dist/orchestration/interactions/ask-user-question.d.ts +1 -1
- package/dist/orchestration/interactions/ask-user-question.js +3 -3
- package/dist/orchestration/interactions/interaction-handlers.js +48 -17
- package/dist/orchestration/interactions/plan-handler.d.ts +2 -2
- package/dist/orchestration/interactions/plan-handler.js +4 -3
- package/dist/orchestration/interactions/update-prompt.d.ts +6 -0
- package/dist/orchestration/interactions/update-prompt.js +100 -0
- package/dist/orchestration/lifecycle.d.ts +4 -4
- package/dist/orchestration/lifecycle.js +24 -22
- package/dist/orchestration/orchestrator.d.ts +1 -1
- package/dist/orchestration/routing/commands/cancel.js +39 -47
- package/dist/orchestration/routing/commands/channel.js +24 -11
- package/dist/orchestration/routing/commands/cost.js +2 -1
- package/dist/orchestration/routing/commands/device.js +3 -2
- package/dist/orchestration/routing/commands/dispatch.js +6 -5
- package/dist/orchestration/routing/commands/index.d.ts +1 -1
- package/dist/orchestration/routing/commands/index.js +11 -10
- package/dist/orchestration/routing/commands/mode.js +19 -18
- package/dist/orchestration/routing/commands/nvtop.js +10 -9
- package/dist/orchestration/routing/commands/sendfile.js +7 -6
- package/dist/orchestration/routing/commands/session.d.ts +1 -1
- package/dist/orchestration/routing/commands/session.js +17 -33
- package/dist/orchestration/routing/commands/tail.js +4 -3
- package/dist/orchestration/routing/commands/task.js +4 -3
- package/dist/orchestration/routing/commands/thread-handlers.js +16 -6
- package/dist/orchestration/routing/edit-handler.js +8 -7
- package/dist/orchestration/routing/hook-bridge-subscribers.js +17 -1
- package/dist/orchestration/routing/message-router.d.ts +1 -1
- package/dist/orchestration/routing/message-router.js +9 -9
- package/dist/orchestration/routing/webhook.js +233 -2
- package/dist/orchestration/status-helpers.d.ts +5 -1
- package/dist/orchestration/status-helpers.js +7 -6
- package/dist/orchestration/thread-callback.d.ts +67 -0
- package/dist/orchestration/thread-callback.js +465 -0
- package/dist/orchestration/thread-executor.d.ts +22 -1
- package/dist/orchestration/thread-executor.js +85 -36
- package/dist/platform/adapter.d.ts +6 -2
- package/dist/platform/adapters/composite-adapter.d.ts +89 -0
- package/dist/platform/adapters/composite-adapter.js +318 -0
- package/dist/platform/adapters/feishu-output-stream.d.ts +26 -4
- package/dist/platform/adapters/feishu-output-stream.js +274 -36
- package/dist/platform/adapters/feishu.d.ts +50 -5
- package/dist/platform/adapters/feishu.js +370 -116
- package/dist/platform/adapters/index.d.ts +24 -3
- package/dist/platform/adapters/index.js +89 -11
- package/dist/platform/adapters/project-conduits.d.ts +9 -0
- package/dist/platform/adapters/project-conduits.js +42 -0
- package/dist/platform/adapters/slack-project-conduits.d.ts +1 -9
- package/dist/platform/adapters/slack-project-conduits.js +6 -40
- package/dist/platform/adapters/slack.d.ts +9 -2
- package/dist/platform/adapters/slack.js +83 -39
- package/dist/platform/adapters/tui/index.d.ts +9 -0
- package/dist/platform/adapters/tui/index.js +10 -0
- package/dist/platform/adapters/tui/ports.d.ts +20 -0
- package/dist/platform/adapters/tui/ports.js +4 -0
- package/dist/platform/adapters/tui/tui-conduit-state.d.ts +10 -0
- package/dist/platform/adapters/tui/tui-conduit-state.js +17 -0
- package/dist/platform/adapters/tui/tui-connection.d.ts +30 -0
- package/dist/platform/adapters/tui/tui-connection.js +53 -0
- package/dist/platform/adapters/tui/tui-gateway.d.ts +120 -0
- package/dist/platform/adapters/tui/tui-gateway.js +919 -0
- package/dist/platform/adapters/tui/tui-notifications.d.ts +12 -0
- package/dist/platform/adapters/tui/tui-notifications.js +60 -0
- package/dist/platform/adapters/tui/tui-output-stream.d.ts +36 -0
- package/dist/platform/adapters/tui/tui-output-stream.js +99 -0
- package/dist/platform/adapters/tui/tui-transcript.d.ts +8 -0
- package/dist/platform/adapters/tui/tui-transcript.js +56 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +2 -1
- package/dist/platform/interactive-builder.js +3 -2
- package/dist/platform/output-stream.d.ts +5 -0
- package/dist/platform/testing.d.ts +7 -11
- package/dist/platform/testing.js +18 -15
- package/dist/platform/tool-trace.js +15 -5
- package/dist/platform/tui/protocol.d.ts +355 -0
- package/dist/platform/tui/protocol.js +199 -0
- package/dist/platform/types.d.ts +12 -3
- package/dist/store/execution-repo.d.ts +6 -1
- package/dist/store/execution-repo.js +13 -3
- package/dist/store/hook-sync.d.ts +18 -0
- package/dist/store/hook-sync.js +92 -0
- package/dist/store/outbound-queue.js +2 -2
- package/dist/store/profile-repo.js +3 -2
- package/dist/store/schedule-repo.d.ts +1 -8
- package/dist/store/session-registry-repo.d.ts +9 -1
- package/dist/store/session-registry-repo.js +19 -3
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +23 -0
- package/dist/store/thread-repo.d.ts +3 -0
- package/dist/store/thread-repo.js +49 -2
- package/dist/store/version-migrations.js +95 -0
- package/dist/tui/App.d.ts +27 -0
- package/dist/tui/App.js +219 -0
- package/dist/tui/components/AskUserModal.d.ts +11 -0
- package/dist/tui/components/AskUserModal.js +364 -0
- package/dist/tui/components/ConfirmModal.d.ts +12 -0
- package/dist/tui/components/ConfirmModal.js +31 -0
- package/dist/tui/components/Dashboard.d.ts +23 -0
- package/dist/tui/components/Dashboard.js +80 -0
- package/dist/tui/components/DashboardCostTab.d.ts +7 -0
- package/dist/tui/components/DashboardCostTab.js +16 -0
- package/dist/tui/components/DashboardExecutionsTab.d.ts +11 -0
- package/dist/tui/components/DashboardExecutionsTab.js +94 -0
- package/dist/tui/components/DashboardSchedulesTab.d.ts +11 -0
- package/dist/tui/components/DashboardSchedulesTab.js +124 -0
- package/dist/tui/components/DashboardTasksTab.d.ts +12 -0
- package/dist/tui/components/DashboardTasksTab.js +200 -0
- package/dist/tui/components/DashboardThreadsTab.d.ts +11 -0
- package/dist/tui/components/DashboardThreadsTab.js +81 -0
- package/dist/tui/components/Header.d.ts +11 -0
- package/dist/tui/components/Header.js +5 -0
- package/dist/tui/components/InputBox.d.ts +10 -0
- package/dist/tui/components/InputBox.js +19 -0
- package/dist/tui/components/MessageRow.d.ts +7 -0
- package/dist/tui/components/MessageRow.js +10 -0
- package/dist/tui/components/Notifications.d.ts +19 -0
- package/dist/tui/components/Notifications.js +72 -0
- package/dist/tui/components/PlanFeedbackModal.d.ts +11 -0
- package/dist/tui/components/PlanFeedbackModal.js +161 -0
- package/dist/tui/components/ProjectSwitcher.d.ts +18 -0
- package/dist/tui/components/ProjectSwitcher.js +43 -0
- package/dist/tui/components/SessionPicker.d.ts +14 -0
- package/dist/tui/components/SessionPicker.js +34 -0
- package/dist/tui/components/SidePanel.d.ts +19 -0
- package/dist/tui/components/SidePanel.js +8 -0
- package/dist/tui/components/StatusLine.d.ts +10 -0
- package/dist/tui/components/StatusLine.js +29 -0
- package/dist/tui/components/Transcript.d.ts +13 -0
- package/dist/tui/components/Transcript.js +56 -0
- package/dist/tui/hooks/useDashboardData.d.ts +32 -0
- package/dist/tui/hooks/useDashboardData.js +104 -0
- package/dist/tui/hooks/useKeybindings.d.ts +19 -0
- package/dist/tui/hooks/useKeybindings.js +87 -0
- package/dist/tui/hooks/useMutate.d.ts +22 -0
- package/dist/tui/hooks/useMutate.js +56 -0
- package/dist/tui/hooks/useNotifications.d.ts +28 -0
- package/dist/tui/hooks/useNotifications.js +70 -0
- package/dist/tui/hooks/useTranscript.d.ts +39 -0
- package/dist/tui/hooks/useTranscript.js +265 -0
- package/dist/tui/hooks/useWsClient.d.ts +29 -0
- package/dist/tui/hooks/useWsClient.js +69 -0
- package/dist/tui/index.d.ts +2 -0
- package/dist/tui/index.js +210 -0
- package/dist/tui/logic.d.ts +16 -0
- package/dist/tui/logic.js +49 -0
- package/dist/tui/render/markdown.d.ts +10 -0
- package/dist/tui/render/markdown.js +38 -0
- package/dist/tui/render/rich-blocks.d.ts +11 -0
- package/dist/tui/render/rich-blocks.js +24 -0
- package/dist/tui/ws-client.d.ts +44 -0
- package/dist/tui/ws-client.js +157 -0
- package/package.json +11 -3
- package/dist/orchestration/channel-queue.d.ts +0 -18
- package/dist/orchestration/channel-queue.js +0 -32
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TuiConnection } from './tui-connection.js';
|
|
2
|
+
import type { MessageRef } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Send a project-report notification to all connections. Connections whose active
|
|
5
|
+
* session matches the source session get chat.post (inline); all others get a
|
|
6
|
+
* notification frame (including cross-project connections).
|
|
7
|
+
*/
|
|
8
|
+
export declare function sendProjectReport(connections: TuiConnection[], projectId: string, sourceSessionId: string, title: string, body: string, ref?: MessageRef): void;
|
|
9
|
+
/**
|
|
10
|
+
* Send a system-notice to all TUI connections.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sendSystemNotice(connections: TuiConnection[], title: string, body: string): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// input: TuiConnection, protocol types
|
|
2
|
+
// output: sendProjectReport / sendSystemNotice — notification fan-out to TUI connections
|
|
3
|
+
// pos: TUI adapter — routes project-report and system-notice to matching conduits
|
|
4
|
+
// >>> If I am updated, update the folder's CORTEX.md <<<
|
|
5
|
+
import { createLogger } from '../../../core/log.js';
|
|
6
|
+
const log = createLogger('tui-notif');
|
|
7
|
+
/**
|
|
8
|
+
* Send a project-report notification to all connections. Connections whose active
|
|
9
|
+
* session matches the source session get chat.post (inline); all others get a
|
|
10
|
+
* notification frame (including cross-project connections).
|
|
11
|
+
*/
|
|
12
|
+
export function sendProjectReport(connections, projectId, sourceSessionId, title, body, ref) {
|
|
13
|
+
let sent = 0;
|
|
14
|
+
for (const conn of connections) {
|
|
15
|
+
if (conn.activeSessionId === sourceSessionId) {
|
|
16
|
+
// Render as chat.post in the active session
|
|
17
|
+
const seq = 0;
|
|
18
|
+
conn.send({
|
|
19
|
+
type: 'chat.post',
|
|
20
|
+
ref: ref ?? { conduit: conn.conduitId, messageId: '', threadId: null },
|
|
21
|
+
content: { text: `${title}\n${body}` },
|
|
22
|
+
seq,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Render as notification
|
|
27
|
+
const seq = 0;
|
|
28
|
+
conn.send({
|
|
29
|
+
type: 'notification',
|
|
30
|
+
kind: 'project-report',
|
|
31
|
+
projectId,
|
|
32
|
+
sessionId: sourceSessionId,
|
|
33
|
+
title,
|
|
34
|
+
body,
|
|
35
|
+
ref,
|
|
36
|
+
seq,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
sent++;
|
|
40
|
+
}
|
|
41
|
+
if (sent === 0) {
|
|
42
|
+
log.warn(`No TUI connections matched project "${projectId}" for project-report`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Send a system-notice to all TUI connections.
|
|
47
|
+
*/
|
|
48
|
+
export function sendSystemNotice(connections, title, body) {
|
|
49
|
+
for (const conn of connections) {
|
|
50
|
+
const seq = 0;
|
|
51
|
+
conn.send({
|
|
52
|
+
type: 'notification',
|
|
53
|
+
kind: 'system-notice',
|
|
54
|
+
projectId: conn.activeProjectId,
|
|
55
|
+
title,
|
|
56
|
+
body,
|
|
57
|
+
seq,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { OutputStream, MutableRegion } from '../../output-stream.js';
|
|
2
|
+
import type { MessageRef, RichBlock, ActionElement, Destination } from '../../types.js';
|
|
3
|
+
import type { TuiConnection } from './tui-connection.js';
|
|
4
|
+
export declare class TuiOutputStream implements OutputStream {
|
|
5
|
+
private conn;
|
|
6
|
+
private streamId;
|
|
7
|
+
private seq;
|
|
8
|
+
private parentRef;
|
|
9
|
+
readonly refs: MessageRef[];
|
|
10
|
+
private destination;
|
|
11
|
+
/** Adapter reference for posting messages through outbound methods */
|
|
12
|
+
private adapter;
|
|
13
|
+
constructor(conn: TuiConnection, destination: Destination, adapter: {
|
|
14
|
+
postMessage(dest: Destination, content: {
|
|
15
|
+
text: string;
|
|
16
|
+
richBlocks?: RichBlock[];
|
|
17
|
+
}): Promise<MessageRef>;
|
|
18
|
+
postInteractive(dest: Destination, content: {
|
|
19
|
+
text: string;
|
|
20
|
+
richBlocks?: RichBlock[];
|
|
21
|
+
actions: ActionElement[];
|
|
22
|
+
}): Promise<MessageRef>;
|
|
23
|
+
}, opts?: {
|
|
24
|
+
threadId?: string | null;
|
|
25
|
+
});
|
|
26
|
+
private _nextSeq;
|
|
27
|
+
emitText(text: string): void;
|
|
28
|
+
openMutable(text: string): MutableRegion;
|
|
29
|
+
postInteractive(text: string, opts?: {
|
|
30
|
+
richBlocks?: RichBlock[];
|
|
31
|
+
actions?: ActionElement[];
|
|
32
|
+
}): Promise<MessageRef | null>;
|
|
33
|
+
flush(): Promise<void>;
|
|
34
|
+
getRefs(): MessageRef[];
|
|
35
|
+
getParentRef(): MessageRef | null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// input: OutputStream interface, TuiConnection, protocol types
|
|
2
|
+
// output: TuiOutputStream — OutputStream impl emitting WS frames
|
|
3
|
+
// pos: TUI adapter — no coalescing, client groups by streamId
|
|
4
|
+
// >>> If I am updated, update the folder's CORTEX.md <<<
|
|
5
|
+
import { createLogger } from '../../../core/log.js';
|
|
6
|
+
const log = createLogger('tui-out');
|
|
7
|
+
let _streamIdCounter = 0;
|
|
8
|
+
function nextStreamId() {
|
|
9
|
+
return `s${++_streamIdCounter}`;
|
|
10
|
+
}
|
|
11
|
+
function nextRegionId() {
|
|
12
|
+
return `r${_streamIdCounter}-${Date.now().toString(36)}`;
|
|
13
|
+
}
|
|
14
|
+
export class TuiOutputStream {
|
|
15
|
+
conn;
|
|
16
|
+
streamId;
|
|
17
|
+
seq;
|
|
18
|
+
parentRef = null;
|
|
19
|
+
refs = [];
|
|
20
|
+
destination;
|
|
21
|
+
/** Adapter reference for posting messages through outbound methods */
|
|
22
|
+
adapter;
|
|
23
|
+
constructor(conn, destination, adapter, opts) {
|
|
24
|
+
this.conn = conn;
|
|
25
|
+
this.streamId = nextStreamId();
|
|
26
|
+
this.seq = 0;
|
|
27
|
+
this.destination = destination;
|
|
28
|
+
this.adapter = adapter;
|
|
29
|
+
}
|
|
30
|
+
_nextSeq() {
|
|
31
|
+
return ++this.seq;
|
|
32
|
+
}
|
|
33
|
+
emitText(text) {
|
|
34
|
+
if (!text?.trim())
|
|
35
|
+
return;
|
|
36
|
+
this.conn.send({
|
|
37
|
+
type: 'stream.text',
|
|
38
|
+
streamId: this.streamId,
|
|
39
|
+
text,
|
|
40
|
+
seq: this._nextSeq(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
openMutable(text) {
|
|
44
|
+
if (!text?.trim())
|
|
45
|
+
return { update: () => { } };
|
|
46
|
+
const regionId = nextRegionId();
|
|
47
|
+
this.conn.send({
|
|
48
|
+
type: 'stream.mutableOpen',
|
|
49
|
+
streamId: this.streamId,
|
|
50
|
+
regionId,
|
|
51
|
+
text,
|
|
52
|
+
seq: this._nextSeq(),
|
|
53
|
+
});
|
|
54
|
+
const sId = this.streamId;
|
|
55
|
+
const rId = regionId;
|
|
56
|
+
const conn = this.conn;
|
|
57
|
+
return {
|
|
58
|
+
update: (t) => {
|
|
59
|
+
if (!t?.trim())
|
|
60
|
+
return;
|
|
61
|
+
conn.send({
|
|
62
|
+
type: 'stream.mutableUpdate',
|
|
63
|
+
streamId: sId,
|
|
64
|
+
regionId: rId,
|
|
65
|
+
text: t,
|
|
66
|
+
seq: this._nextSeq(),
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async postInteractive(text, opts) {
|
|
72
|
+
const actions = opts?.actions;
|
|
73
|
+
if (actions && actions.length > 0) {
|
|
74
|
+
const ref = await this.adapter.postInteractive(this.destination, { text, richBlocks: opts?.richBlocks, actions });
|
|
75
|
+
this.refs.push(ref);
|
|
76
|
+
if (!this.parentRef)
|
|
77
|
+
this.parentRef = ref;
|
|
78
|
+
return ref;
|
|
79
|
+
}
|
|
80
|
+
const ref = await this.adapter.postMessage(this.destination, { text, richBlocks: opts?.richBlocks });
|
|
81
|
+
this.refs.push(ref);
|
|
82
|
+
if (!this.parentRef)
|
|
83
|
+
this.parentRef = ref;
|
|
84
|
+
return ref;
|
|
85
|
+
}
|
|
86
|
+
async flush() {
|
|
87
|
+
this.conn.send({
|
|
88
|
+
type: 'stream.flush',
|
|
89
|
+
streamId: this.streamId,
|
|
90
|
+
seq: this._nextSeq(),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getRefs() {
|
|
94
|
+
return [...this.refs];
|
|
95
|
+
}
|
|
96
|
+
getParentRef() {
|
|
97
|
+
return this.parentRef;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TranscriptReplay } from '../../tui/protocol.js';
|
|
2
|
+
import type { TranscriptData } from './ports.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build a TranscriptReplay frame from transcript data.
|
|
5
|
+
* Pure synchronous formatter — no store/IO dependencies.
|
|
6
|
+
* Returns null when there are no replayable items.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildTranscriptReplay(data: TranscriptData): TranscriptReplay | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// input: protocol types + ports types
|
|
2
|
+
// output: buildTranscriptReplay — pure synchronous formatter, TranscriptData → TranscriptReplay | null
|
|
3
|
+
// pos: TUI adapter — replays prior chat messages as TranscriptReplay frames
|
|
4
|
+
// ZERO @store/@domain/@orch imports (see ports.ts for boundary types)
|
|
5
|
+
// >>> If I am updated, update the folder's CORTEX.md <<<
|
|
6
|
+
/**
|
|
7
|
+
* Build a TranscriptReplay frame from transcript data.
|
|
8
|
+
* Pure synchronous formatter — no store/IO dependencies.
|
|
9
|
+
* Returns null when there are no replayable items.
|
|
10
|
+
*/
|
|
11
|
+
export function buildTranscriptReplay(data) {
|
|
12
|
+
const { sessionId, channel, turns } = data;
|
|
13
|
+
const items = [];
|
|
14
|
+
let seq = 0;
|
|
15
|
+
for (const turn of turns) {
|
|
16
|
+
// Skip processing turns
|
|
17
|
+
if (turn.status === 'processing')
|
|
18
|
+
continue;
|
|
19
|
+
// The user message turn: render as a ChatPost
|
|
20
|
+
const userRef = {
|
|
21
|
+
conduit: channel,
|
|
22
|
+
messageId: turn.userMessageTs,
|
|
23
|
+
threadId: null,
|
|
24
|
+
};
|
|
25
|
+
items.push({
|
|
26
|
+
type: 'chat.post',
|
|
27
|
+
ref: userRef,
|
|
28
|
+
content: { text: `**You:** ${turn.userMessageText}` },
|
|
29
|
+
seq: ++seq,
|
|
30
|
+
});
|
|
31
|
+
// Response messages
|
|
32
|
+
for (const responseTs of turn.responseMessageTimestamps) {
|
|
33
|
+
const responseRef = {
|
|
34
|
+
conduit: channel,
|
|
35
|
+
messageId: responseTs,
|
|
36
|
+
threadId: null,
|
|
37
|
+
};
|
|
38
|
+
items.push({
|
|
39
|
+
type: 'chat.post',
|
|
40
|
+
ref: responseRef,
|
|
41
|
+
content: { text: `*(response)*` },
|
|
42
|
+
seq: ++seq,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (items.length === 0)
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
type: 'transcript.replay',
|
|
50
|
+
sessionId,
|
|
51
|
+
items,
|
|
52
|
+
seqStart: 1,
|
|
53
|
+
seqEnd: seq,
|
|
54
|
+
isCatchUp: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
package/dist/platform/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { SlackAdapter } from './adapters/slack.js';
|
|
|
11
11
|
export type { SlackAdapterConfig } from './adapters/slack.js';
|
|
12
12
|
export { FeishuAdapter } from './adapters/feishu.js';
|
|
13
13
|
export type { FeishuAdapterConfig } from './adapters/feishu.js';
|
|
14
|
+
export { CompositeAdapter, extractTuiAdapter } from './adapters/composite-adapter.js';
|
package/dist/platform/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// input: adapter + types + output-stream + adapters/*
|
|
1
|
+
// input: adapter + types + output-stream + adapters/* + composite-adapter
|
|
2
2
|
// output: Re-export full family of PlatformAdapter public APIs
|
|
3
3
|
// pos: Public API export of the Platform abstraction
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
@@ -8,3 +8,4 @@ export { buildQuestionGroupBlocks, buildQuestionModalDefinition, buildPlanApprov
|
|
|
8
8
|
export { createAdapter, createAdapterFromEnv } from './adapters/index.js';
|
|
9
9
|
export { SlackAdapter } from './adapters/slack.js';
|
|
10
10
|
export { FeishuAdapter } from './adapters/feishu.js';
|
|
11
|
+
export { CompositeAdapter, extractTuiAdapter } from './adapters/composite-adapter.js';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// output: Question types + buildQuestion*/buildPlan* builders
|
|
3
3
|
// pos: Platform-independent interactive component builder
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { Icons } from '../core/icons.js';
|
|
5
6
|
// --- AskUserQuestion builders ---
|
|
6
7
|
export function buildQuestionGroupBlocks(group) {
|
|
7
8
|
const blocks = [];
|
|
@@ -13,7 +14,7 @@ export function buildQuestionGroupBlocks(group) {
|
|
|
13
14
|
const answer = group.answers.get(q.pendingId);
|
|
14
15
|
if (answer) {
|
|
15
16
|
const formatted = Array.isArray(answer.value) ? `[${answer.value.join(', ')}]` : answer.value;
|
|
16
|
-
blocks.push({ type: 'context', text:
|
|
17
|
+
blocks.push({ type: 'context', text: `${Icons.ok} ${formatted}` });
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
20
|
const optionsList = q.options.map(o => o.label).join(' · ');
|
|
@@ -93,7 +94,7 @@ export function buildQuestionModalDefinition(group) {
|
|
|
93
94
|
export function buildPlanApprovalContent(requestId) {
|
|
94
95
|
return {
|
|
95
96
|
richBlocks: [
|
|
96
|
-
{ type: 'section', text:
|
|
97
|
+
{ type: 'section', text: `${Icons.memo} *Plan ready for review.* Approve to proceed or provide feedback.` },
|
|
97
98
|
],
|
|
98
99
|
actions: [
|
|
99
100
|
{ type: 'button', text: 'Approve', actionId: 'hook_plan_approve', value: requestId, style: 'primary' },
|
|
@@ -23,6 +23,11 @@ export interface OutputStream {
|
|
|
23
23
|
}
|
|
24
24
|
export interface OpenOutputStreamOpts {
|
|
25
25
|
threadId?: string | null;
|
|
26
|
+
/** Anchor message to thread under. For composite (multi-platform) destinations this may carry
|
|
27
|
+
* `parts[]` (per-platform sub-refs); CompositeAdapter resolves the right per-platform anchor for
|
|
28
|
+
* each sub-stream so a platform never receives another platform's (incompatible) messageId.
|
|
29
|
+
* Single adapters ignore this and rely on `threadId`. */
|
|
30
|
+
anchorRef?: MessageRef | null;
|
|
26
31
|
onMessagePosted?: ((ref: MessageRef) => void) | null;
|
|
27
32
|
durable?: DurableHooks | null;
|
|
28
33
|
}
|
|
@@ -14,9 +14,8 @@ export interface UpdatedMessage {
|
|
|
14
14
|
export interface DeletedMessage {
|
|
15
15
|
ref: MessageRef;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface MarkedQueued {
|
|
18
18
|
ref: MessageRef;
|
|
19
|
-
emoji: string;
|
|
20
19
|
}
|
|
21
20
|
export interface UploadedFile {
|
|
22
21
|
destination: Destination;
|
|
@@ -27,11 +26,6 @@ export interface OpenedModal {
|
|
|
27
26
|
triggerId: string;
|
|
28
27
|
modal: ModalDefinition;
|
|
29
28
|
}
|
|
30
|
-
export interface EphemeralMessage {
|
|
31
|
-
channel: string;
|
|
32
|
-
userId: string;
|
|
33
|
-
text: string;
|
|
34
|
-
}
|
|
35
29
|
export interface MockSegmentRecord {
|
|
36
30
|
kind: 'text' | 'mutable-open' | 'mutable-update' | 'interactive';
|
|
37
31
|
text: string;
|
|
@@ -67,10 +61,9 @@ export declare class MockAdapter implements PlatformAdapter {
|
|
|
67
61
|
posted: PostedMessage[];
|
|
68
62
|
updated: UpdatedMessage[];
|
|
69
63
|
deleted: DeletedMessage[];
|
|
70
|
-
|
|
64
|
+
marksQueued: MarkedQueued[];
|
|
71
65
|
uploads: UploadedFile[];
|
|
72
66
|
modals: OpenedModal[];
|
|
73
|
-
ephemeralMessages: EphemeralMessage[];
|
|
74
67
|
/** Optional fault injection for tests: count of remaining failures, then succeed. */
|
|
75
68
|
failPostMessageCount: number;
|
|
76
69
|
failUpdateMessageCount: number;
|
|
@@ -98,17 +91,20 @@ export declare class MockAdapter implements PlatformAdapter {
|
|
|
98
91
|
actions: ActionElement[];
|
|
99
92
|
}, opts?: PostMessageOpts): Promise<MessageRef>;
|
|
100
93
|
openModal(triggerId: string, modal: ModalDefinition): Promise<void>;
|
|
101
|
-
|
|
94
|
+
markQueued(ref: MessageRef): Promise<void>;
|
|
102
95
|
uploadFile(destination: Destination, filePath: string, opts?: FileUploadOpts): Promise<void>;
|
|
103
96
|
downloadFile(fileRef: PlatformFileRef, destDir: string): Promise<DownloadedFile>;
|
|
104
97
|
getPermalink(ref: MessageRef): Promise<string | null>;
|
|
105
|
-
postEphemeral(channel: string, userId: string, text: string): Promise<void>;
|
|
106
98
|
openOutputStream(destination: Destination, opts?: OpenOutputStreamOpts): OutputStream;
|
|
107
99
|
private _projectConduits;
|
|
108
100
|
bindProjectConduit(projectId: string, conduitHint: string): Promise<void>;
|
|
109
101
|
unbindProjectConduit(projectId: string): Promise<void>;
|
|
110
102
|
getProjectConduits(): Promise<Record<string, string>>;
|
|
111
103
|
resolveInboundProject(conduit: string): Promise<string | null>;
|
|
104
|
+
/** Default ownership: anything not owned by the TUI gateway. Override per-test
|
|
105
|
+
* via `ownsConduitFn` to simulate platform-specific routing. */
|
|
106
|
+
ownsConduitFn: ((conduit: string) => boolean) | null;
|
|
107
|
+
ownsConduit(conduit: string): boolean;
|
|
112
108
|
/** Simulate an inbound message for testing event handlers. */
|
|
113
109
|
simulateMessage(channel: string, text: string, opts?: {
|
|
114
110
|
senderId?: string;
|
package/dist/platform/testing.js
CHANGED
|
@@ -78,10 +78,9 @@ export class MockAdapter {
|
|
|
78
78
|
posted = [];
|
|
79
79
|
updated = [];
|
|
80
80
|
deleted = [];
|
|
81
|
-
|
|
81
|
+
marksQueued = [];
|
|
82
82
|
uploads = [];
|
|
83
83
|
modals = [];
|
|
84
|
-
ephemeralMessages = [];
|
|
85
84
|
/** Optional fault injection for tests: count of remaining failures, then succeed. */
|
|
86
85
|
failPostMessageCount = 0;
|
|
87
86
|
failUpdateMessageCount = 0;
|
|
@@ -101,7 +100,6 @@ export class MockAdapter {
|
|
|
101
100
|
messageEdit: true,
|
|
102
101
|
modals: true,
|
|
103
102
|
reactions: true,
|
|
104
|
-
ephemeral: true,
|
|
105
103
|
fileUpload: true,
|
|
106
104
|
richFormatting: true,
|
|
107
105
|
maxMessageLength: 3000,
|
|
@@ -131,7 +129,7 @@ export class MockAdapter {
|
|
|
131
129
|
const channel = resolveDestinationConduit(destination, this._adminChannel);
|
|
132
130
|
const messageId = String(this.nextId++);
|
|
133
131
|
this.posted.push({ destination, content, threadId: opts?.threadId });
|
|
134
|
-
return { channel, messageId, threadId: opts?.threadId };
|
|
132
|
+
return { conduit: channel, messageId, threadId: opts?.threadId };
|
|
135
133
|
}
|
|
136
134
|
async updateMessage(ref, content) {
|
|
137
135
|
if (this.failUpdateMessageCount > 0) {
|
|
@@ -151,13 +149,13 @@ export class MockAdapter {
|
|
|
151
149
|
const channel = resolveDestinationConduit(destination, this._adminChannel);
|
|
152
150
|
const messageId = String(this.nextId++);
|
|
153
151
|
this.posted.push({ destination, content, threadId: opts?.threadId, actions: content.actions });
|
|
154
|
-
return { channel, messageId, threadId: opts?.threadId };
|
|
152
|
+
return { conduit: channel, messageId, threadId: opts?.threadId };
|
|
155
153
|
}
|
|
156
154
|
async openModal(triggerId, modal) {
|
|
157
155
|
this.modals.push({ triggerId, modal });
|
|
158
156
|
}
|
|
159
|
-
async
|
|
160
|
-
this.
|
|
157
|
+
async markQueued(ref) {
|
|
158
|
+
this.marksQueued.push({ ref });
|
|
161
159
|
}
|
|
162
160
|
async uploadFile(destination, filePath, opts) {
|
|
163
161
|
this.uploads.push({ destination, filePath, opts });
|
|
@@ -166,10 +164,7 @@ export class MockAdapter {
|
|
|
166
164
|
return { localPath: `${destDir}/${fileRef.id}`, mimetype: fileRef.mimetype, name: fileRef.name };
|
|
167
165
|
}
|
|
168
166
|
async getPermalink(ref) {
|
|
169
|
-
return `https://mock.test/permalink/${ref.
|
|
170
|
-
}
|
|
171
|
-
async postEphemeral(channel, userId, text) {
|
|
172
|
-
this.ephemeralMessages.push({ channel, userId, text });
|
|
167
|
+
return `https://mock.test/permalink/${ref.conduit}/${ref.messageId}`;
|
|
173
168
|
}
|
|
174
169
|
// --- Output stream ---
|
|
175
170
|
openOutputStream(destination, opts) {
|
|
@@ -193,11 +188,19 @@ export class MockAdapter {
|
|
|
193
188
|
}
|
|
194
189
|
return null;
|
|
195
190
|
}
|
|
191
|
+
/** Default ownership: anything not owned by the TUI gateway. Override per-test
|
|
192
|
+
* via `ownsConduitFn` to simulate platform-specific routing. */
|
|
193
|
+
ownsConduitFn = null;
|
|
194
|
+
ownsConduit(conduit) {
|
|
195
|
+
if (this.ownsConduitFn)
|
|
196
|
+
return this.ownsConduitFn(conduit);
|
|
197
|
+
return !conduit.startsWith('tui-') && !conduit.startsWith('tui:');
|
|
198
|
+
}
|
|
196
199
|
// --- Test helpers ---
|
|
197
200
|
/** Simulate an inbound message for testing event handlers. */
|
|
198
201
|
async simulateMessage(channel, text, opts) {
|
|
199
202
|
const ref = {
|
|
200
|
-
channel,
|
|
203
|
+
conduit: channel,
|
|
201
204
|
messageId: String(this.nextId++),
|
|
202
205
|
threadId: opts?.threadId,
|
|
203
206
|
};
|
|
@@ -208,6 +211,7 @@ export class MockAdapter {
|
|
|
208
211
|
text,
|
|
209
212
|
senderId: opts?.senderId || 'user-1',
|
|
210
213
|
isBot: opts?.isBot ?? false,
|
|
214
|
+
kind: 'user',
|
|
211
215
|
raw: {},
|
|
212
216
|
},
|
|
213
217
|
async reply(content, replyOpts) {
|
|
@@ -223,7 +227,7 @@ export class MockAdapter {
|
|
|
223
227
|
/** Simulate a message edit for testing edit handlers. */
|
|
224
228
|
async simulateMessageEdit(channel, messageId, newText) {
|
|
225
229
|
const ctx = {
|
|
226
|
-
originalRef: { channel, messageId },
|
|
230
|
+
originalRef: { conduit: channel, messageId },
|
|
227
231
|
newText,
|
|
228
232
|
raw: {},
|
|
229
233
|
};
|
|
@@ -266,10 +270,9 @@ export class MockAdapter {
|
|
|
266
270
|
this.posted = [];
|
|
267
271
|
this.updated = [];
|
|
268
272
|
this.deleted = [];
|
|
269
|
-
this.
|
|
273
|
+
this.marksQueued = [];
|
|
270
274
|
this.uploads = [];
|
|
271
275
|
this.modals = [];
|
|
272
|
-
this.ephemeralMessages = [];
|
|
273
276
|
this.nextId = 1000;
|
|
274
277
|
this.failPostMessageCount = 0;
|
|
275
278
|
this.failUpdateMessageCount = 0;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// output: ToolTrace class + createToolTrace factory + isToolTraceEnabled
|
|
3
3
|
// pos: Compact tool_use trace rendered via OutputStream openMutable/update
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import { Icons } from '../core/icons.js';
|
|
5
6
|
const MAX_LINE_LEN = 120;
|
|
6
7
|
const ELLIPSIS = '…';
|
|
7
8
|
function isEnvTruthy(v) {
|
|
@@ -87,7 +88,7 @@ function renderToolLine(toolName, summaries, opts) {
|
|
|
87
88
|
const prefix = opts?.prefix ? `${opts.prefix} ` : '';
|
|
88
89
|
const display = stripMcpPrefix(toolName) || '?';
|
|
89
90
|
const count = summaries.length;
|
|
90
|
-
const head = `${prefix}
|
|
91
|
+
const head = `${prefix}${Icons.tools} ${display} \u00d7${count}`;
|
|
91
92
|
const nonEmpty = summaries.filter(s => s && s.trim().length > 0);
|
|
92
93
|
if (nonEmpty.length === 0)
|
|
93
94
|
return head;
|
|
@@ -106,10 +107,19 @@ function renderToolLine(toolName, summaries, opts) {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
if (kept.length < nonEmpty.length) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
// Reserve room for the "+N…" tail; pop kept summaries until it fits.
|
|
111
|
+
// Dropping the tail entirely would hide the fact that items were truncated.
|
|
112
|
+
let missing = nonEmpty.length - kept.length;
|
|
113
|
+
let withTail = `${line}${sep}+${missing}${ELLIPSIS}`;
|
|
114
|
+
while (withTail.length > MAX_LINE_LEN + 4 && kept.length > 0) {
|
|
115
|
+
kept.pop();
|
|
116
|
+
missing = nonEmpty.length - kept.length;
|
|
117
|
+
line = kept.length === 0
|
|
118
|
+
? head
|
|
119
|
+
: `${head}${sep}${kept.join(sep)}`;
|
|
120
|
+
withTail = `${line}${sep}+${missing}${ELLIPSIS}`;
|
|
121
|
+
}
|
|
122
|
+
line = withTail;
|
|
113
123
|
}
|
|
114
124
|
// Final hard-cap (if even the head+first summary exceeded — rare).
|
|
115
125
|
if (line.length > MAX_LINE_LEN + 4) {
|