@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,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// input: TabData for threads tab
|
|
3
|
+
// output: Threads list — status icon + template name + step progress
|
|
4
|
+
// pos: Dashboard tab: read-only thread list
|
|
5
|
+
// [c] key opens ConfirmModal → threads.cancel mutate via mutate prop
|
|
6
|
+
import { useState, useEffect, useRef } from 'react';
|
|
7
|
+
import { Box, Text, useInput } from 'ink';
|
|
8
|
+
import { ConfirmModal } from './ConfirmModal.js';
|
|
9
|
+
export function DashboardThreadsTab({ data, mutate, active = true }) {
|
|
10
|
+
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
11
|
+
const [confirmingIndex, setConfirmingIndex] = useState(null);
|
|
12
|
+
const [alreadyTerminalRows, setAlreadyTerminalRows] = useState(new Set());
|
|
13
|
+
const feedbackTimeoutRef = useRef(null);
|
|
14
|
+
// Cleanup feedback timeout on unmount
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
return () => {
|
|
17
|
+
feedbackTimeoutRef.current?.();
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
// Clamp focused index when data shrinks
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (data.data.length > 0 && focusedIndex >= data.data.length) {
|
|
23
|
+
setFocusedIndex(data.data.length - 1);
|
|
24
|
+
}
|
|
25
|
+
}, [data.data.length, focusedIndex]);
|
|
26
|
+
useInput((input, key) => {
|
|
27
|
+
if (confirmingIndex !== null)
|
|
28
|
+
return;
|
|
29
|
+
if (data.data.length === 0)
|
|
30
|
+
return;
|
|
31
|
+
if (key.upArrow) {
|
|
32
|
+
setFocusedIndex(prev => Math.max(0, prev - 1));
|
|
33
|
+
}
|
|
34
|
+
else if (key.downArrow) {
|
|
35
|
+
setFocusedIndex(prev => Math.min(data.data.length - 1, prev + 1));
|
|
36
|
+
}
|
|
37
|
+
else if (input === 'c' && !key.ctrl && mutate) {
|
|
38
|
+
setConfirmingIndex(focusedIndex);
|
|
39
|
+
}
|
|
40
|
+
}, { isActive: active });
|
|
41
|
+
if (data.loading && data.data.length === 0) {
|
|
42
|
+
return _jsx(Text, { dimColor: true, children: "Loading threads..." });
|
|
43
|
+
}
|
|
44
|
+
if (data.error) {
|
|
45
|
+
return _jsxs(Text, { color: "red", children: ["Error: ", data.error] });
|
|
46
|
+
}
|
|
47
|
+
if (data.data.length === 0) {
|
|
48
|
+
return _jsx(Text, { dimColor: true, children: "No threads" });
|
|
49
|
+
}
|
|
50
|
+
const thread = confirmingIndex !== null ? data.data[confirmingIndex] : null;
|
|
51
|
+
return (_jsx(Box, { flexDirection: "column", children: confirmingIndex !== null && thread ? (_jsx(ConfirmModal, { title: "Cancel thread?", body: `${thread.templateName ?? 'unnamed'} — ${thread.currentStep?.name ?? ''} (${thread.status})`, onConfirm: async () => {
|
|
52
|
+
if (!mutate)
|
|
53
|
+
return;
|
|
54
|
+
const result = await mutate('threads.cancel', { threadId: thread.id });
|
|
55
|
+
if (result.ok === false && result.error.code === 'already-terminal') {
|
|
56
|
+
const idx = confirmingIndex;
|
|
57
|
+
setAlreadyTerminalRows(prev => new Set([...prev, idx]));
|
|
58
|
+
const timer = setTimeout(() => {
|
|
59
|
+
setAlreadyTerminalRows(prev => {
|
|
60
|
+
const next = new Set(prev);
|
|
61
|
+
next.delete(idx);
|
|
62
|
+
return next;
|
|
63
|
+
});
|
|
64
|
+
}, 5000);
|
|
65
|
+
feedbackTimeoutRef.current?.();
|
|
66
|
+
feedbackTimeoutRef.current = () => clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
setConfirmingIndex(null);
|
|
69
|
+
}, onCancel: () => setConfirmingIndex(null) })) : (data.data.map((t, i) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [i === focusedIndex ? _jsx(Text, { color: "cyan", children: "\u25B8 " }) : _jsx(Text, { children: " " }), _jsx(StatusIcon, { status: t.status }), _jsx(Text, { children: " " }), _jsx(Text, { bold: i === focusedIndex, children: t.templateName ?? 'unnamed' })] }), _jsx(Box, { marginLeft: 2, children: _jsxs(Text, { dimColor: true, children: [t.status, t.currentStep ? ` — step ${t.currentStep.index + 1}/${t.totalSteps}` : ''] }) }), alreadyTerminalRows.has(i) ? (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { dimColor: true, children: "(already finished)" }) })) : null] }, t.id ?? i)))) }));
|
|
70
|
+
}
|
|
71
|
+
function StatusIcon({ status }) {
|
|
72
|
+
switch (status) {
|
|
73
|
+
case 'running': return _jsx(Text, { color: "green", children: "\u25B6" });
|
|
74
|
+
case 'waiting': return _jsx(Text, { color: "yellow", children: "\u23F3" });
|
|
75
|
+
case 'completed': return _jsx(Text, { color: "blue", children: "\u2713" });
|
|
76
|
+
case 'failed': return _jsx(Text, { color: "red", children: "\u2717" });
|
|
77
|
+
case 'cancelled': return _jsx(Text, { dimColor: true, children: "\u2298" });
|
|
78
|
+
case 'aborted': return _jsx(Text, { color: "red", children: "\u26D4" });
|
|
79
|
+
default: return _jsx(Text, { dimColor: true, children: "?" });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface HeaderProps {
|
|
3
|
+
projectId: string | null;
|
|
4
|
+
sessionName: string | null;
|
|
5
|
+
queuedCount: number;
|
|
6
|
+
connected: boolean;
|
|
7
|
+
notificationCount?: number;
|
|
8
|
+
costSummary?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function Header({ projectId, sessionName, queuedCount, connected, notificationCount, costSummary, }: HeaderProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
export function Header({ projectId, sessionName, queuedCount, connected, notificationCount = 0, costSummary, }) {
|
|
4
|
+
return (_jsxs(Box, { borderStyle: "single", borderDimColor: true, paddingX: 1, marginBottom: 1, children: [_jsxs(Text, { bold: true, children: [connected ? '●' : '○', " ", ' ', "cortex-tui"] }), _jsx(Text, { children: " " }), projectId ? (_jsxs(Text, { dimColor: true, children: [" | ", projectId] })) : null, sessionName ? (_jsxs(Text, { dimColor: true, children: [" | ", sessionName] })) : null, costSummary ? (_jsxs(Text, { dimColor: true, children: [" | ", costSummary] })) : null, queuedCount > 0 ? (_jsxs(Text, { color: "yellow", children: [" | \u23F3 ", queuedCount] })) : null, notificationCount > 0 ? (_jsxs(Text, { color: "yellow", children: [" | \uD83D\uDD14 ", notificationCount] })) : null] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface InputBoxProps {
|
|
3
|
+
onSubmit: (text: string) => void;
|
|
4
|
+
/** While true the user can still type, but Enter does not send (text preserved). */
|
|
5
|
+
awaitingResponse?: boolean;
|
|
6
|
+
/** Whether this input owns the keyboard (false when dashboard/modal has focus). */
|
|
7
|
+
focus?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function InputBox({ onSubmit, awaitingResponse, focus }: InputBoxProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// input: ink-text-input TextInput (controlled)
|
|
3
|
+
// output: Message input — always typeable; submission blocked while awaiting a response
|
|
4
|
+
// pos: User text input component
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
import TextInput from 'ink-text-input';
|
|
8
|
+
export function InputBox({ onSubmit, awaitingResponse, focus = true }) {
|
|
9
|
+
const [value, setValue] = useState('');
|
|
10
|
+
const handleSubmit = useCallback((text) => {
|
|
11
|
+
if (awaitingResponse)
|
|
12
|
+
return; // block send, keep typed text
|
|
13
|
+
if (text.trim().length === 0)
|
|
14
|
+
return;
|
|
15
|
+
onSubmit(text);
|
|
16
|
+
setValue('');
|
|
17
|
+
}, [awaitingResponse, onSubmit]);
|
|
18
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Box, { borderStyle: "single", borderDimColor: true, paddingX: 1, children: _jsx(Box, { flexGrow: 1, children: _jsx(TextInput, { value: value, onChange: setValue, onSubmit: handleSubmit, focus: focus, placeholder: "Type a message..." }) }) }), awaitingResponse ? (_jsx(Text, { dimColor: true, children: "Waiting for response \u2014 Enter is disabled until the agent replies (Ctrl+C to cancel)" })) : !focus ? (_jsx(Text, { dimColor: true, children: "Press Ctrl+D to return to the input" })) : null] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { RichBlocks } from '../render/rich-blocks.js';
|
|
4
|
+
import { collectStreamText } from '../logic.js';
|
|
5
|
+
export function MessageRow({ message }) {
|
|
6
|
+
// Concatenate all stream segments + mutable regions into a single flowing
|
|
7
|
+
// string instead of one Text per chunk (chunks don't align to line breaks).
|
|
8
|
+
const streamText = message.streams.size > 0 ? collectStreamText(message.streams) : '';
|
|
9
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { flexDirection: "column", children: [message.text ? _jsx(Text, { children: message.text }) : null, message.richBlocks && message.richBlocks.length > 0 ? (_jsx(RichBlocks, { blocks: message.richBlocks })) : null] }), streamText.length > 0 ? (_jsx(Text, { dimColor: true, children: streamText })) : null, message.queued ? (_jsx(Text, { dimColor: true, children: " \u23F3 queued" })) : null] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NotificationEntry } from '../hooks/useNotifications.js';
|
|
3
|
+
interface NotificationsProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
unreadCount: number;
|
|
6
|
+
notifications: Map<string, NotificationEntry>;
|
|
7
|
+
ids: string[];
|
|
8
|
+
onMarkRead: (id: string) => void;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
/** Called when user selects a notification from detail view. Triggers session switch. */
|
|
11
|
+
onSelect?: (notif: NotificationEntry) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function NotificationsBadge({ unreadCount }: {
|
|
14
|
+
unreadCount: number;
|
|
15
|
+
}): React.JSX.Element | null;
|
|
16
|
+
export declare function NotificationsModal({ open, notifications, ids, onMarkRead, onClose, onSelect, }: Omit<NotificationsProps, 'unreadCount'> & {
|
|
17
|
+
open: boolean;
|
|
18
|
+
}): React.JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// input: useNotifications result
|
|
3
|
+
// output: Corner badge with notification count + Enter-to-open modal listing active notifications
|
|
4
|
+
// pos: Notification UI — badge in corner, modal overlay on open
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Box, Text, useInput } from 'ink';
|
|
7
|
+
export function NotificationsBadge({ unreadCount }) {
|
|
8
|
+
if (unreadCount === 0)
|
|
9
|
+
return null;
|
|
10
|
+
return _jsxs(Text, { color: "yellow", children: ["\uD83D\uDD14 ", unreadCount] });
|
|
11
|
+
}
|
|
12
|
+
export function NotificationsModal({ open, notifications, ids, onMarkRead, onClose, onSelect, }) {
|
|
13
|
+
const [selectedIdx, setSelectedIdx] = React.useState(0);
|
|
14
|
+
const [focusedId, setFocusedId] = React.useState(null);
|
|
15
|
+
// Reset selection when modal opens
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (open) {
|
|
18
|
+
setSelectedIdx(0);
|
|
19
|
+
setFocusedId(null);
|
|
20
|
+
}
|
|
21
|
+
}, [open]);
|
|
22
|
+
useInput((_input, key) => {
|
|
23
|
+
if (!open)
|
|
24
|
+
return;
|
|
25
|
+
if (key.escape) {
|
|
26
|
+
if (focusedId) {
|
|
27
|
+
setFocusedId(null); // Back to list
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
onClose();
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (key.upArrow && !focusedId) {
|
|
35
|
+
setSelectedIdx(prev => Math.max(0, prev - 1));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (key.downArrow && !focusedId) {
|
|
39
|
+
setSelectedIdx(prev => Math.min(ids.length - 1, prev + 1));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (key.return) {
|
|
43
|
+
if (focusedId) {
|
|
44
|
+
const selected = notifications.get(focusedId);
|
|
45
|
+
if (selected && onSelect) {
|
|
46
|
+
onSelect(selected);
|
|
47
|
+
}
|
|
48
|
+
onMarkRead(focusedId);
|
|
49
|
+
setFocusedId(null);
|
|
50
|
+
}
|
|
51
|
+
else if (ids.length > 0) {
|
|
52
|
+
const selected = ids[selectedIdx];
|
|
53
|
+
if (selected) {
|
|
54
|
+
setFocusedId(selected);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (!open)
|
|
61
|
+
return null;
|
|
62
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [_jsx(Text, { bold: true, children: "Notifications" }), _jsx(Box, { flexDirection: "column", marginTop: 1, children: ids.length === 0 ? (_jsx(Text, { dimColor: true, children: "No notifications" })) : (ids.map((id, i) => {
|
|
63
|
+
const notif = notifications.get(id);
|
|
64
|
+
if (!notif)
|
|
65
|
+
return null;
|
|
66
|
+
if (focusedId === id) {
|
|
67
|
+
// Detail view
|
|
68
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, borderStyle: "single", paddingX: 1, children: [_jsx(Text, { bold: true, children: notif.title }), _jsxs(Text, { dimColor: true, children: [notif.kind, " | ", new Date(notif.ts).toLocaleTimeString()] }), _jsx(Text, { children: notif.body }), _jsx(Text, { dimColor: true, children: "\u2014 Press Enter to mark read, Esc to go back" })] }, id));
|
|
69
|
+
}
|
|
70
|
+
return (_jsxs(Box, { marginBottom: 0, children: [_jsx(Text, { children: i === selectedIdx ? '▶' : ' ' }), _jsx(Text, { children: " " }), _jsx(Text, { dimColor: notif.read, children: notif.read ? '✓' : '○' }), _jsx(Text, { children: " " }), _jsxs(Text, { bold: !notif.read, dimColor: notif.read, children: [String(notif.title).slice(0, 30), notif.title.length > 30 ? '…' : ''] })] }, id));
|
|
71
|
+
})) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191/\u2193 navigate \u00B7 Enter detail \u00B7 Esc close" }) })] }));
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ModalDefinition, TuiFrame } from '../../platform/tui/protocol.js';
|
|
3
|
+
interface PlanFeedbackModalProps {
|
|
4
|
+
modal: ModalDefinition;
|
|
5
|
+
triggerId: string;
|
|
6
|
+
sendFrame: (frame: TuiFrame) => void;
|
|
7
|
+
ackErrors: Record<string, string>;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function PlanFeedbackModal({ modal, triggerId, sendFrame, ackErrors, onClose, }: PlanFeedbackModalProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// input: protocol types (ModalDefinition, ModalField, ModalFieldValue, ModalSubmit)
|
|
3
|
+
// output: Plan-approval modal — plan text + approve/feedback/cancel hot-keys + feedback text input
|
|
4
|
+
// pos: Modal UI for the interactive-reply plan approval flow
|
|
5
|
+
//
|
|
6
|
+
// Renders:
|
|
7
|
+
// plan text (from section field) as a scrollable region
|
|
8
|
+
// 3 radio-style options: Approve (1), Provide Feedback (2), Cancel (3)
|
|
9
|
+
// feedback text input (shown when feedback is selected and confirmed)
|
|
10
|
+
// submit button
|
|
11
|
+
// Numbered hot-keys, ↑/↓ navigation, Enter to confirm, Esc to cancel.
|
|
12
|
+
// Builds modal.submit values matching the plan-approval server handler contract.
|
|
13
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
14
|
+
import { Box, Text, useInput } from 'ink';
|
|
15
|
+
const OPTIONS = [
|
|
16
|
+
{ id: 'approve', label: 'Approve', value: 'approve' },
|
|
17
|
+
{ id: 'feedback', label: 'Provide Feedback', value: 'feedback' },
|
|
18
|
+
{ id: 'cancel', label: 'Cancel', value: 'cancel' },
|
|
19
|
+
];
|
|
20
|
+
// ── Component ──
|
|
21
|
+
export function PlanFeedbackModal({ modal, triggerId, sendFrame, ackErrors, onClose, }) {
|
|
22
|
+
// ── State ──
|
|
23
|
+
/** Currently focused slot: 0=approve, 1=feedback, 2=cancel, 3=submit */
|
|
24
|
+
const [focusSlot, setFocusSlot] = useState(0);
|
|
25
|
+
/** Which option is radio-selected (follows focus for slots 0-2, frozen for slot 3) */
|
|
26
|
+
const [activeOption, setActiveOption] = useState('approve');
|
|
27
|
+
/** Interaction mode */
|
|
28
|
+
const [mode, setMode] = useState('decision');
|
|
29
|
+
/** Feedback text input buffer */
|
|
30
|
+
const [feedbackText, setFeedbackText] = useState('');
|
|
31
|
+
/** Prevent double-submit */
|
|
32
|
+
const submittedRef = useRef(false);
|
|
33
|
+
// Reset submitted when ack errors arrive — user can fix and resubmit
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (Object.keys(ackErrors).length > 0) {
|
|
36
|
+
submittedRef.current = false;
|
|
37
|
+
setMode('decision');
|
|
38
|
+
}
|
|
39
|
+
}, [ackErrors]);
|
|
40
|
+
// ── Extract plan text from section field ──
|
|
41
|
+
const planText = modal.fields.find(f => f.type === 'section')?.text ?? '';
|
|
42
|
+
const SLOT_COUNT = 4; // 3 options + submit
|
|
43
|
+
// ── Submit ──
|
|
44
|
+
const handleSubmit = useCallback((option, fbText) => {
|
|
45
|
+
if (submittedRef.current)
|
|
46
|
+
return;
|
|
47
|
+
submittedRef.current = true;
|
|
48
|
+
setMode('submitted');
|
|
49
|
+
const values = {};
|
|
50
|
+
values.decision = { decision: { value: option } };
|
|
51
|
+
if (option === 'feedback' && fbText) {
|
|
52
|
+
values.feedback = { text: { value: fbText } };
|
|
53
|
+
}
|
|
54
|
+
sendFrame({
|
|
55
|
+
type: 'modal.submit',
|
|
56
|
+
id: `modal-submit-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
57
|
+
callbackId: modal.callbackId,
|
|
58
|
+
privateMetadata: modal.privateMetadata || '',
|
|
59
|
+
values,
|
|
60
|
+
userId: 'tui',
|
|
61
|
+
});
|
|
62
|
+
}, [modal, sendFrame]);
|
|
63
|
+
// ── Keyboard handling ──
|
|
64
|
+
useInput((input, key) => {
|
|
65
|
+
// Escape
|
|
66
|
+
if (key.escape) {
|
|
67
|
+
if (mode === 'feedback-text') {
|
|
68
|
+
// Exit feedback mode back to decision mode
|
|
69
|
+
setMode('decision');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (!submittedRef.current) {
|
|
73
|
+
onClose();
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (submittedRef.current)
|
|
78
|
+
return;
|
|
79
|
+
// ── Feedback text input mode ──
|
|
80
|
+
if (mode === 'feedback-text') {
|
|
81
|
+
if (key.return) {
|
|
82
|
+
handleSubmit('feedback', feedbackText);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (key.backspace || key.delete) {
|
|
86
|
+
setFeedbackText(prev => prev.slice(0, -1));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (input.length === 1 && !key.ctrl && !key.meta && !key.shift) {
|
|
90
|
+
setFeedbackText(prev => prev + input);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// ── Decision mode ──
|
|
96
|
+
if (key.return) {
|
|
97
|
+
if (focusSlot === 0) {
|
|
98
|
+
handleSubmit('approve', '');
|
|
99
|
+
}
|
|
100
|
+
else if (focusSlot === 1) {
|
|
101
|
+
// Enter feedback text mode
|
|
102
|
+
setMode('feedback-text');
|
|
103
|
+
setFeedbackText('');
|
|
104
|
+
}
|
|
105
|
+
else if (focusSlot === 2) {
|
|
106
|
+
onClose();
|
|
107
|
+
}
|
|
108
|
+
else if (focusSlot === 3) {
|
|
109
|
+
// Submit with the currently active option; cancel means close
|
|
110
|
+
if (activeOption === 'cancel') {
|
|
111
|
+
onClose();
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
handleSubmit(activeOption, activeOption === 'feedback' ? feedbackText : '');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Arrow navigation — move focus (▶) only.
|
|
120
|
+
// Selection (●) is changed only by numbered hot-keys, matching AskUserModal pattern.
|
|
121
|
+
if (key.upArrow || key.downArrow) {
|
|
122
|
+
if (key.downArrow && focusSlot < SLOT_COUNT - 1) {
|
|
123
|
+
setFocusSlot(focusSlot + 1);
|
|
124
|
+
}
|
|
125
|
+
else if (key.upArrow && focusSlot > 0) {
|
|
126
|
+
setFocusSlot(focusSlot - 1);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Numbered hot-keys
|
|
131
|
+
if (input === '1') {
|
|
132
|
+
setFocusSlot(0);
|
|
133
|
+
setActiveOption('approve');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (input === '2') {
|
|
137
|
+
setFocusSlot(1);
|
|
138
|
+
setActiveOption('feedback');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (input === '3') {
|
|
142
|
+
setFocusSlot(2);
|
|
143
|
+
setActiveOption('cancel');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
// ── Render ──
|
|
148
|
+
const submitLabel = modal.submitLabel || 'Submit';
|
|
149
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, paddingY: 1, borderStyle: "single", children: [_jsx(Text, { bold: true, children: modal.title }), planText ? (_jsx(Box, { marginTop: 1, height: 5, flexShrink: 0, children: _jsx(Text, { dimColor: true, children: planText }) })) : null, _jsx(Box, { flexDirection: "column", marginTop: 1, children: OPTIONS.map((opt, idx) => {
|
|
150
|
+
const isFocused = focusSlot === idx;
|
|
151
|
+
const isSelected = activeOption === opt.id;
|
|
152
|
+
return (_jsx(Box, { children: _jsxs(Text, { bold: isFocused, children: [isFocused ? '▶' : ' ', " ", isSelected ? '●' : '○', " ", idx + 1, ". ", opt.label] }) }, opt.id));
|
|
153
|
+
}) }), mode === 'feedback-text' ? (_jsx(Box, { flexDirection: "column", marginTop: 1, children: _jsx(Box, { borderStyle: "single", paddingX: 1, marginLeft: 2, children: feedbackText ? (_jsx(Text, { children: feedbackText })) : (_jsx(Text, { dimColor: true, children: "Type your feedback..." })) }) })) : null, Object.keys(ackErrors).length > 0 ? (_jsx(Box, { flexDirection: "column", marginTop: 1, children: Object.entries(ackErrors).map(([blockId, errorMsg]) => {
|
|
154
|
+
const found = modal.fields.find((f) => (f.type === 'select' || f.type === 'multi_select' || f.type === 'text_input') &&
|
|
155
|
+
f.blockId === blockId);
|
|
156
|
+
const label = found?.label ?? blockId;
|
|
157
|
+
return (_jsx(Box, { children: _jsxs(Text, { color: "red", children: ["\u26A0 ", label, ": ", errorMsg] }) }, `err-${blockId}`));
|
|
158
|
+
}) })) : null, _jsx(Box, { marginTop: 1, children: _jsxs(Text, { bold: focusSlot === 3, dimColor: focusSlot !== 3, children: [focusSlot === 3 ? '▶' : ' ', " [", submitLabel, "]"] }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: mode === 'feedback-text'
|
|
159
|
+
? 'Enter to submit · Esc back'
|
|
160
|
+
: '↑/↓ navigate · Enter confirm · Esc cancel' }) })] }));
|
|
161
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ProjectEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
kind?: string;
|
|
5
|
+
contextDir?: string;
|
|
6
|
+
hasMission?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface ProjectSwitcherProps {
|
|
9
|
+
open: boolean;
|
|
10
|
+
projects: ProjectEntry[];
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
onSelect: (projectId: string) => void;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
onRequestRefresh: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ProjectSwitcher({ open, projects, loading, error, onSelect, onClose, onRequestRefresh, }: ProjectSwitcherProps): React.JSX.Element | null;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// input: Projects list + selection callback
|
|
3
|
+
// output: Ctrl+P modal — list projects, select to send session.switch
|
|
4
|
+
// pos: Project/session switcher modal (state managed by parent)
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { Box, Text, useInput } from 'ink';
|
|
7
|
+
export function ProjectSwitcher({ open, projects, loading, error, onSelect, onClose, onRequestRefresh, }) {
|
|
8
|
+
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
9
|
+
// Reset selection when modal opens
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (open) {
|
|
12
|
+
setSelectedIdx(0);
|
|
13
|
+
onRequestRefresh();
|
|
14
|
+
}
|
|
15
|
+
}, [open, onRequestRefresh]);
|
|
16
|
+
useInput((_input, key) => {
|
|
17
|
+
if (!open)
|
|
18
|
+
return;
|
|
19
|
+
if (key.escape) {
|
|
20
|
+
onClose();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (key.upArrow) {
|
|
24
|
+
setSelectedIdx(prev => Math.max(0, prev - 1));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (key.downArrow) {
|
|
28
|
+
setSelectedIdx(prev => Math.min(projects.length - 1, prev + 1));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (key.return && projects.length > 0) {
|
|
32
|
+
const selected = projects[selectedIdx];
|
|
33
|
+
if (selected) {
|
|
34
|
+
onSelect(selected.id);
|
|
35
|
+
onClose();
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (!open)
|
|
41
|
+
return null;
|
|
42
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [_jsx(Text, { bold: true, children: "Switch Project" }), loading ? (_jsx(Text, { dimColor: true, children: "Loading projects..." })) : error ? (_jsxs(Text, { color: "red", children: ["Error: ", error] })) : projects.length === 0 ? (_jsx(Text, { dimColor: true, children: "No projects found" })) : (_jsx(Box, { flexDirection: "column", marginTop: 1, children: projects.map((proj, i) => (_jsxs(Box, { marginBottom: 0, children: [_jsx(Text, { children: i === selectedIdx ? '▶' : ' ' }), _jsx(Text, { children: " " }), _jsx(Text, { bold: i === selectedIdx, children: proj.id }), proj.kind ? _jsxs(Text, { dimColor: true, children: [" (", proj.kind, ")"] }) : null, proj.hasMission ? _jsx(Text, { color: "green", children: " \u2605" }) : null] }, proj.id))) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191/\u2193 navigate \u00B7 Enter switch \u00B7 Esc cancel" }) })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ResumableSession {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
projectId: string;
|
|
6
|
+
label: string | null;
|
|
7
|
+
}
|
|
8
|
+
interface SessionPickerProps {
|
|
9
|
+
sessions: ResumableSession[];
|
|
10
|
+
onSelect: (sessionId: string, projectId: string) => void;
|
|
11
|
+
onCancel: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function SessionPicker({ sessions, onSelect, onCancel }: SessionPickerProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// input: Resumable sessions list + selection callback
|
|
3
|
+
// output: Session picker for --resume mode — ↑/↓/Enter to select
|
|
4
|
+
// pos: Pick a session to resume before the main App renders
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { Box, Text, useInput } from 'ink';
|
|
7
|
+
export function SessionPicker({ sessions, onSelect, onCancel }) {
|
|
8
|
+
const [selectedIdx, setSelectedIdx] = useState(0);
|
|
9
|
+
useInput((_input, key) => {
|
|
10
|
+
if (key.escape) {
|
|
11
|
+
onCancel();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (key.upArrow) {
|
|
15
|
+
setSelectedIdx(prev => Math.max(0, prev - 1));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (key.downArrow) {
|
|
19
|
+
setSelectedIdx(prev => Math.min(sessions.length - 1, prev + 1));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (key.return) {
|
|
23
|
+
const selected = sessions[selectedIdx];
|
|
24
|
+
if (selected) {
|
|
25
|
+
onSelect(selected.sessionId, selected.projectId);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (sessions.length === 0) {
|
|
31
|
+
return _jsx(Text, { dimColor: true, children: "No resumable sessions" });
|
|
32
|
+
}
|
|
33
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, children: "Select a session to resume:" }), _jsx(Box, { flexDirection: "column", marginTop: 1, children: sessions.map((s, i) => (_jsxs(Box, { marginBottom: 0, children: [_jsx(Text, { children: i === selectedIdx ? '▶' : ' ' }), _jsx(Text, { children: " " }), _jsx(Text, { bold: i === selectedIdx, children: s.name }), _jsxs(Text, { dimColor: true, children: [" (", s.projectId, ")"] }), s.label ? _jsxs(Text, { dimColor: true, children: [" \u2014 ", s.label] }) : null] }, s.sessionId))) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191/\u2193 navigate \u00B7 Enter resume \u00B7 Esc fresh session" }) })] }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DashState } from '../hooks/useDashboardData.js';
|
|
3
|
+
import type { MutateResult } from '../hooks/useMutate.js';
|
|
4
|
+
interface SidePanelProps {
|
|
5
|
+
visible: boolean;
|
|
6
|
+
/** Whether the dashboard currently owns the keyboard (focus zone === 'dashboard'). */
|
|
7
|
+
active: boolean;
|
|
8
|
+
sendFrame: (frame: any) => void;
|
|
9
|
+
projectId: string | null;
|
|
10
|
+
dashState: DashState;
|
|
11
|
+
onMarkPending: (tab: string) => void;
|
|
12
|
+
onRegisterSubscription: (queryId: string, tab: string) => void;
|
|
13
|
+
onUnregisterSubscription: (queryId: string) => void;
|
|
14
|
+
activeTab: string;
|
|
15
|
+
onSetActiveTab: (tab: string) => void;
|
|
16
|
+
onMutate?: (op: string, args: Record<string, unknown>) => Promise<MutateResult>;
|
|
17
|
+
}
|
|
18
|
+
export declare function SidePanel({ visible, active, sendFrame, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, onMutate, }: SidePanelProps): React.JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from 'ink';
|
|
3
|
+
import { Dashboard } from './Dashboard.js';
|
|
4
|
+
export function SidePanel({ visible, active, sendFrame, projectId, dashState, onMarkPending, onRegisterSubscription, onUnregisterSubscription, activeTab, onSetActiveTab, onMutate, }) {
|
|
5
|
+
if (!visible)
|
|
6
|
+
return null;
|
|
7
|
+
return (_jsx(Box, { width: 40, borderStyle: "single", borderDimColor: true, marginLeft: 1, flexShrink: 0, children: _jsx(Dashboard, { active: active, sendFrame: sendFrame, projectId: projectId, dashState: dashState, onMarkPending: onMarkPending, onRegisterSubscription: onRegisterSubscription, onUnregisterSubscription: onUnregisterSubscription, activeTab: activeTab, onSetActiveTab: onSetActiveTab, mutate: onMutate }) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WsState } from '../ws-client.js';
|
|
3
|
+
interface StatusLineProps {
|
|
4
|
+
connectionState: WsState;
|
|
5
|
+
queuedCount: number;
|
|
6
|
+
notificationCount: number;
|
|
7
|
+
errorMessage?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function StatusLine({ connectionState, queuedCount, notificationCount, errorMessage, }: StatusLineProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
export function StatusLine({ connectionState, queuedCount, notificationCount, errorMessage, }) {
|
|
4
|
+
const statusText = getStatusText(connectionState, queuedCount, notificationCount, errorMessage);
|
|
5
|
+
const statusColor = getStatusColor(connectionState, errorMessage);
|
|
6
|
+
return (_jsxs(Text, { color: statusColor, dimColor: connectionState === 'connected' && !errorMessage, children: [statusText, notificationCount > 0 ? ` | 🔔 ${notificationCount}` : '', ' — ', _jsx(Text, { dimColor: true, children: "Ctrl+D Dashboard | Ctrl+N Notifications | Ctrl+P Projects" })] }));
|
|
7
|
+
}
|
|
8
|
+
function getStatusText(state, queuedCount, notificationCount, errorMessage) {
|
|
9
|
+
if (errorMessage)
|
|
10
|
+
return `⚠ ${errorMessage}`;
|
|
11
|
+
if (state === 'reconnecting')
|
|
12
|
+
return '⟳ Reconnecting...';
|
|
13
|
+
if (state === 'connecting')
|
|
14
|
+
return '⟳ Connecting...';
|
|
15
|
+
if (state === 'disconnected')
|
|
16
|
+
return '○ Disconnected — press R to retry, Ctrl+C to exit';
|
|
17
|
+
if (queuedCount > 0)
|
|
18
|
+
return `⏳ ${queuedCount} queued`;
|
|
19
|
+
return '● Connected';
|
|
20
|
+
}
|
|
21
|
+
function getStatusColor(state, errorMessage) {
|
|
22
|
+
if (errorMessage)
|
|
23
|
+
return 'red';
|
|
24
|
+
if (state === 'reconnecting' || state === 'connecting')
|
|
25
|
+
return 'yellow';
|
|
26
|
+
if (state === 'disconnected')
|
|
27
|
+
return 'red';
|
|
28
|
+
return 'green';
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RenderedMessage } from '../hooks/useTranscript.js';
|
|
3
|
+
export interface TranscriptHandle {
|
|
4
|
+
scrollUp: (page?: boolean) => void;
|
|
5
|
+
scrollDown: (page?: boolean) => void;
|
|
6
|
+
scrollToEnd: () => void;
|
|
7
|
+
}
|
|
8
|
+
interface TranscriptProps {
|
|
9
|
+
messages: Map<string, RenderedMessage>;
|
|
10
|
+
ids: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const Transcript: React.ForwardRefExoticComponent<TranscriptProps & React.RefAttributes<TranscriptHandle>>;
|
|
13
|
+
export {};
|