aimux-cli 0.1.16 → 0.1.19
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/README.md +184 -67
- package/bin/aimux-dev +10 -0
- package/dist/agent-events.js +0 -1
- package/dist/agent-output-parser.js +0 -1
- package/dist/agent-prompt-delivery.js +0 -1
- package/dist/agent-tracker.js +0 -1
- package/dist/agent-watcher.js +0 -1
- package/dist/alert-display.d.ts +21 -0
- package/dist/alert-display.js +85 -0
- package/dist/atomic-write.js +0 -1
- package/dist/attachment-store.d.ts +0 -7
- package/dist/attachment-store.js +2 -87
- package/dist/builtin-metadata-watchers.js +4 -5
- package/dist/claude-hooks.d.ts +1 -0
- package/dist/claude-hooks.js +25 -1
- package/dist/config.d.ts +19 -13
- package/dist/config.js +28 -15
- package/dist/connection-targets.d.ts +8 -0
- package/dist/connection-targets.js +27 -0
- package/dist/context/compactor.js +0 -1
- package/dist/context/context-bridge.js +0 -1
- package/dist/context/context-file.js +0 -1
- package/dist/context/history.js +0 -1
- package/dist/credentials.d.ts +12 -0
- package/dist/credentials.js +48 -0
- package/dist/daemon.d.ts +23 -0
- package/dist/daemon.js +391 -67
- package/dist/dashboard/command-spec.js +0 -1
- package/dist/dashboard/feedback.js +0 -1
- package/dist/dashboard/index.d.ts +13 -10
- package/dist/dashboard/index.js +3 -27
- package/dist/dashboard/operation-failures.js +0 -1
- package/dist/dashboard/order.d.ts +22 -0
- package/dist/dashboard/order.js +54 -0
- package/dist/dashboard/pending-actions.d.ts +39 -10
- package/dist/dashboard/pending-actions.js +166 -37
- package/dist/dashboard/quick-jump.d.ts +2 -1
- package/dist/dashboard/quick-jump.js +7 -5
- package/dist/dashboard/runtime-evidence.js +0 -1
- package/dist/dashboard/session-actions.d.ts +4 -4
- package/dist/dashboard/session-actions.js +1 -2
- package/dist/dashboard/session-registry.d.ts +4 -3
- package/dist/dashboard/session-registry.js +16 -51
- package/dist/dashboard/sort.js +0 -1
- package/dist/dashboard/state.d.ts +1 -1
- package/dist/dashboard/state.js +0 -1
- package/dist/dashboard/targets.js +0 -1
- package/dist/dashboard/ui-state-store.d.ts +16 -1
- package/dist/dashboard/ui-state-store.js +73 -3
- package/dist/debug-state.d.ts +97 -0
- package/dist/debug-state.js +540 -0
- package/dist/debug.d.ts +38 -0
- package/dist/debug.js +219 -16
- package/dist/default-plugins/gh-pr-context.d.ts +2 -1
- package/dist/default-plugins/gh-pr-context.js +17 -12
- package/dist/default-plugins/transcript-length.js +15 -3
- package/dist/fast-control.js +37 -20
- package/dist/hotkeys.js +0 -1
- package/dist/http-client.js +31 -3
- package/dist/key-parser.js +0 -1
- package/dist/last-used.js +0 -1
- package/dist/local-ui-server.d.ts +22 -0
- package/dist/local-ui-server.js +185 -0
- package/dist/login-flow.d.ts +7 -0
- package/dist/login-flow.js +119 -0
- package/dist/main.js +821 -152
- package/dist/managed-launch-env.js +14 -1
- package/dist/metadata-server.d.ts +36 -36
- package/dist/metadata-server.js +638 -138
- package/dist/metadata-store.d.ts +4 -1
- package/dist/metadata-store.js +30 -3
- package/dist/multiplexer/agent-io-methods.d.ts +2 -10
- package/dist/multiplexer/agent-io-methods.js +12 -44
- package/dist/multiplexer/archives.js +8 -10
- package/dist/multiplexer/dashboard-actions-methods.js +0 -1
- package/dist/multiplexer/dashboard-control.js +45 -14
- package/dist/multiplexer/dashboard-interaction.d.ts +8 -2
- package/dist/multiplexer/dashboard-interaction.js +187 -29
- package/dist/multiplexer/dashboard-model.d.ts +10 -3
- package/dist/multiplexer/dashboard-model.js +417 -36
- package/dist/multiplexer/dashboard-ops.d.ts +9 -7
- package/dist/multiplexer/dashboard-ops.js +178 -69
- package/dist/multiplexer/dashboard-state-methods.d.ts +2 -1
- package/dist/multiplexer/dashboard-state-methods.js +3 -3
- package/dist/multiplexer/dashboard-tail-methods.d.ts +22 -10
- package/dist/multiplexer/dashboard-tail-methods.js +164 -48
- package/dist/multiplexer/dashboard-view-methods.d.ts +1 -1
- package/dist/multiplexer/dashboard-view-methods.js +23 -9
- package/dist/multiplexer/graveyard-view-model.d.ts +9 -1
- package/dist/multiplexer/graveyard-view-model.js +39 -1
- package/dist/multiplexer/index.d.ts +15 -12
- package/dist/multiplexer/index.js +64 -44
- package/dist/multiplexer/navigation.js +0 -1
- package/dist/multiplexer/notifications.js +107 -25
- package/dist/multiplexer/persistence-methods.d.ts +31 -4
- package/dist/multiplexer/persistence-methods.js +304 -309
- package/dist/multiplexer/runtime-lifecycle-methods.d.ts +8 -10
- package/dist/multiplexer/runtime-lifecycle-methods.js +104 -87
- package/dist/multiplexer/runtime-state.d.ts +8 -10
- package/dist/multiplexer/runtime-state.js +82 -146
- package/dist/multiplexer/runtime-sync.d.ts +2 -10
- package/dist/multiplexer/runtime-sync.js +3 -19
- package/dist/multiplexer/service-state-snapshot.d.ts +2 -4
- package/dist/multiplexer/service-state-snapshot.js +4 -52
- package/dist/multiplexer/services.d.ts +1 -0
- package/dist/multiplexer/services.js +55 -6
- package/dist/multiplexer/session-capture.d.ts +1 -0
- package/dist/multiplexer/session-capture.js +23 -0
- package/dist/multiplexer/session-launch.d.ts +4 -1
- package/dist/multiplexer/session-launch.js +152 -64
- package/dist/multiplexer/session-runtime-core.d.ts +8 -20
- package/dist/multiplexer/session-runtime-core.js +40 -136
- package/dist/multiplexer/subscreens.js +10 -4
- package/dist/multiplexer/tool-picker.js +0 -1
- package/dist/multiplexer/worktree-graveyard.d.ts +0 -1
- package/dist/multiplexer/worktree-graveyard.js +15 -17
- package/dist/multiplexer/worktrees.js +96 -41
- package/dist/notification-context.js +8 -5
- package/dist/notifications.js +163 -102
- package/dist/notify.d.ts +4 -0
- package/dist/notify.js +14 -1
- package/dist/orchestration-actions.js +0 -1
- package/dist/orchestration-routing.js +0 -1
- package/dist/orchestration.js +0 -1
- package/dist/osc-notifications.js +0 -1
- package/dist/paths.d.ts +32 -7
- package/dist/paths.js +82 -59
- package/dist/pending-actions.d.ts +5 -0
- package/dist/pending-actions.js +13 -0
- package/dist/plugin-runtime.js +9 -3
- package/dist/project-events.d.ts +1 -10
- package/dist/project-events.js +0 -11
- package/dist/project-scanner.d.ts +2 -3
- package/dist/project-scanner.js +58 -130
- package/dist/project-service-manifest.d.ts +1 -3
- package/dist/project-service-manifest.js +1 -4
- package/dist/recency.js +0 -1
- package/dist/recorder.js +0 -1
- package/dist/relay-client.d.ts +30 -0
- package/dist/relay-client.js +190 -0
- package/dist/remote-access.d.ts +16 -0
- package/dist/remote-access.js +90 -0
- package/dist/runtime-core/exchange-derived.d.ts +2 -0
- package/dist/runtime-core/exchange-derived.js +153 -0
- package/dist/runtime-core/exchange-import.d.ts +24 -0
- package/dist/runtime-core/exchange-import.js +317 -0
- package/dist/runtime-core/exchange-store.d.ts +157 -0
- package/dist/runtime-core/exchange-store.js +452 -0
- package/dist/runtime-core/topology-services.d.ts +38 -0
- package/dist/runtime-core/topology-services.js +170 -0
- package/dist/runtime-core/topology-sessions.d.ts +52 -0
- package/dist/runtime-core/topology-sessions.js +238 -0
- package/dist/runtime-core/topology-store.d.ts +171 -0
- package/dist/runtime-core/topology-store.js +419 -0
- package/dist/runtime-core/topology-worktrees.d.ts +60 -0
- package/dist/runtime-core/topology-worktrees.js +199 -0
- package/dist/runtime-migration.d.ts +69 -0
- package/dist/runtime-migration.js +398 -0
- package/dist/session-bootstrap.d.ts +8 -6
- package/dist/session-bootstrap.js +51 -159
- package/dist/session-runtime.d.ts +2 -0
- package/dist/session-runtime.js +1 -1
- package/dist/session-semantics.d.ts +12 -4
- package/dist/session-semantics.js +14 -1
- package/dist/shell-args.js +0 -1
- package/dist/shell-hooks.js +32 -11
- package/dist/shell-state.d.ts +2 -0
- package/dist/shell-state.js +26 -2
- package/dist/status-detector.js +0 -1
- package/dist/statusline-model.d.ts +10 -2
- package/dist/statusline-model.js +106 -31
- package/dist/task-workflow.d.ts +6 -9
- package/dist/task-workflow.js +37 -85
- package/dist/tasks.d.ts +6 -33
- package/dist/tasks.js +46 -89
- package/dist/team.d.ts +29 -0
- package/dist/team.js +40 -1
- package/dist/terminal-host.js +0 -1
- package/dist/threads.d.ts +6 -35
- package/dist/threads.js +89 -99
- package/dist/tmux/doctor.js +0 -1
- package/dist/tmux/inbox-popup.js +37 -16
- package/dist/tmux/runtime-manager.d.ts +3 -0
- package/dist/tmux/runtime-manager.js +21 -5
- package/dist/tmux/session-transport.js +0 -1
- package/dist/tmux/statusline-cache.js +0 -1
- package/dist/tmux/statusline.js +49 -10
- package/dist/tmux/switcher.js +0 -1
- package/dist/tmux/window-open.js +1 -3
- package/dist/tool-output-watchers.d.ts +0 -18
- package/dist/tool-output-watchers.js +0 -323
- package/dist/tui/render/box.js +0 -1
- package/dist/tui/render/text.js +0 -1
- package/dist/tui/screens/dashboard-renderers.js +37 -26
- package/dist/tui/screens/overlay-renderers.d.ts +2 -0
- package/dist/tui/screens/overlay-renderers.js +37 -2
- package/dist/tui/screens/subscreen-renderers.js +7 -1
- package/dist/workflow.js +0 -1
- package/dist/worktree.js +17 -1
- package/dist-ui/_expo/static/css/web-30453ede1678c16acb08b97e83e8646d.css +1 -0
- package/dist-ui/_expo/static/js/web/entry-477c745b2adc79367a4380ecf07d9ff6.js +14620 -0
- package/dist-ui/assets/assets/images/icon.a5413dcd2e811c9f2317d01a28118d8a.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png +0 -0
- package/dist-ui/assets/node_modules/@react-navigation/elements/lib/module/assets/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png +0 -0
- package/dist-ui/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png +0 -0
- package/dist-ui/favicon.ico +0 -0
- package/dist-ui/index.html +38 -0
- package/dist-ui/metadata.json +1 -0
- package/package.json +29 -12
- package/dist/agent-events.js.map +0 -1
- package/dist/agent-message-parts.d.ts +0 -17
- package/dist/agent-message-parts.js +0 -31
- package/dist/agent-message-parts.js.map +0 -1
- package/dist/agent-output-parser.js.map +0 -1
- package/dist/agent-prompt-delivery.js.map +0 -1
- package/dist/agent-tracker.js.map +0 -1
- package/dist/agent-watcher.js.map +0 -1
- package/dist/atomic-write.js.map +0 -1
- package/dist/attachment-store.js.map +0 -1
- package/dist/builtin-metadata-watchers.js.map +0 -1
- package/dist/claude-hooks.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context/compactor.js.map +0 -1
- package/dist/context/context-bridge.js.map +0 -1
- package/dist/context/context-file.js.map +0 -1
- package/dist/context/history.js.map +0 -1
- package/dist/daemon.js.map +0 -1
- package/dist/dashboard/command-spec.js.map +0 -1
- package/dist/dashboard/feedback.js.map +0 -1
- package/dist/dashboard/index.js.map +0 -1
- package/dist/dashboard/operation-failures.js.map +0 -1
- package/dist/dashboard/pending-actions.js.map +0 -1
- package/dist/dashboard/quick-jump.js.map +0 -1
- package/dist/dashboard/runtime-evidence.js.map +0 -1
- package/dist/dashboard/session-actions.js.map +0 -1
- package/dist/dashboard/session-registry.js.map +0 -1
- package/dist/dashboard/sort.js.map +0 -1
- package/dist/dashboard/state.js.map +0 -1
- package/dist/dashboard/targets.js.map +0 -1
- package/dist/dashboard/ui-state-store.js.map +0 -1
- package/dist/debug.js.map +0 -1
- package/dist/default-plugins/gh-pr-context.js.map +0 -1
- package/dist/default-plugins/transcript-length.js.map +0 -1
- package/dist/fast-control.js.map +0 -1
- package/dist/hotkeys.js.map +0 -1
- package/dist/http-client.js.map +0 -1
- package/dist/instance-directory.d.ts +0 -32
- package/dist/instance-directory.js +0 -82
- package/dist/instance-directory.js.map +0 -1
- package/dist/instance-registry.d.ts +0 -39
- package/dist/instance-registry.js +0 -208
- package/dist/instance-registry.js.map +0 -1
- package/dist/key-parser.js.map +0 -1
- package/dist/last-used.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/managed-launch-env.js.map +0 -1
- package/dist/metadata-server.js.map +0 -1
- package/dist/metadata-store.js.map +0 -1
- package/dist/multiplexer/agent-io-methods.js.map +0 -1
- package/dist/multiplexer/archives.js.map +0 -1
- package/dist/multiplexer/dashboard-actions-methods.js.map +0 -1
- package/dist/multiplexer/dashboard-control.js.map +0 -1
- package/dist/multiplexer/dashboard-interaction.js.map +0 -1
- package/dist/multiplexer/dashboard-model.js.map +0 -1
- package/dist/multiplexer/dashboard-ops.js.map +0 -1
- package/dist/multiplexer/dashboard-state-methods.js.map +0 -1
- package/dist/multiplexer/dashboard-tail-methods.js.map +0 -1
- package/dist/multiplexer/dashboard-view-methods.js.map +0 -1
- package/dist/multiplexer/graveyard-view-model.js.map +0 -1
- package/dist/multiplexer/index.js.map +0 -1
- package/dist/multiplexer/navigation.js.map +0 -1
- package/dist/multiplexer/notifications.js.map +0 -1
- package/dist/multiplexer/persistence-methods.js.map +0 -1
- package/dist/multiplexer/runtime-lifecycle-methods.js.map +0 -1
- package/dist/multiplexer/runtime-state.js.map +0 -1
- package/dist/multiplexer/runtime-sync.js.map +0 -1
- package/dist/multiplexer/service-state-snapshot.js.map +0 -1
- package/dist/multiplexer/services.js.map +0 -1
- package/dist/multiplexer/session-actions.d.ts +0 -40
- package/dist/multiplexer/session-actions.js +0 -110
- package/dist/multiplexer/session-actions.js.map +0 -1
- package/dist/multiplexer/session-launch.js.map +0 -1
- package/dist/multiplexer/session-runtime-core.js.map +0 -1
- package/dist/multiplexer/subscreens.js.map +0 -1
- package/dist/multiplexer/tool-picker.js.map +0 -1
- package/dist/multiplexer/worktree-graveyard.js.map +0 -1
- package/dist/multiplexer/worktrees.js.map +0 -1
- package/dist/notification-context.js.map +0 -1
- package/dist/notifications.js.map +0 -1
- package/dist/notify.js.map +0 -1
- package/dist/orchestration-actions.js.map +0 -1
- package/dist/orchestration-dispatcher.d.ts +0 -25
- package/dist/orchestration-dispatcher.js +0 -59
- package/dist/orchestration-dispatcher.js.map +0 -1
- package/dist/orchestration-routing.js.map +0 -1
- package/dist/orchestration.js.map +0 -1
- package/dist/osc-notifications.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/plugin-runtime.js.map +0 -1
- package/dist/project-events.js.map +0 -1
- package/dist/project-scanner.js.map +0 -1
- package/dist/project-service-manifest.js.map +0 -1
- package/dist/recency.js.map +0 -1
- package/dist/recorder.js.map +0 -1
- package/dist/session-bootstrap.js.map +0 -1
- package/dist/session-input-operations.d.ts +0 -19
- package/dist/session-input-operations.js +0 -46
- package/dist/session-input-operations.js.map +0 -1
- package/dist/session-message-history.d.ts +0 -27
- package/dist/session-message-history.js +0 -105
- package/dist/session-message-history.js.map +0 -1
- package/dist/session-runtime.js.map +0 -1
- package/dist/session-semantics.js.map +0 -1
- package/dist/shell-args.js.map +0 -1
- package/dist/shell-hooks.js.map +0 -1
- package/dist/shell-state.js.map +0 -1
- package/dist/status-detector.js.map +0 -1
- package/dist/statusline-model.js.map +0 -1
- package/dist/task-dispatcher.d.ts +0 -64
- package/dist/task-dispatcher.js +0 -213
- package/dist/task-dispatcher.js.map +0 -1
- package/dist/task-workflow.js.map +0 -1
- package/dist/tasks.js.map +0 -1
- package/dist/team.js.map +0 -1
- package/dist/terminal-host.js.map +0 -1
- package/dist/threads.js.map +0 -1
- package/dist/tmux/doctor.js.map +0 -1
- package/dist/tmux/inbox-popup.js.map +0 -1
- package/dist/tmux/runtime-manager.js.map +0 -1
- package/dist/tmux/session-transport.js.map +0 -1
- package/dist/tmux/statusline-cache.js.map +0 -1
- package/dist/tmux/statusline.js.map +0 -1
- package/dist/tmux/switcher.js.map +0 -1
- package/dist/tmux/window-open.js.map +0 -1
- package/dist/tool-output-watchers.js.map +0 -1
- package/dist/tui/render/box.js.map +0 -1
- package/dist/tui/render/text.js.map +0 -1
- package/dist/tui/screens/dashboard-renderers.js.map +0 -1
- package/dist/tui/screens/overlay-renderers.js.map +0 -1
- package/dist/tui/screens/subscreen-renderers.js.map +0 -1
- package/dist/workflow.js.map +0 -1
- package/dist/worktree.js.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export declare const RUNTIME_EXCHANGE_VERSION = 1;
|
|
2
|
+
export type RuntimeExchangeThreadKind = "conversation" | "task" | "review" | "handoff" | "user";
|
|
3
|
+
export type RuntimeExchangeThreadStatus = "open" | "waiting" | "blocked" | "done" | "abandoned";
|
|
4
|
+
export type RuntimeExchangeMessageKind = "request" | "reply" | "status" | "decision" | "handoff" | "note";
|
|
5
|
+
export type RuntimeExchangeTaskStatus = "pending" | "assigned" | "in_progress" | "blocked" | "done" | "failed";
|
|
6
|
+
export type RuntimeExchangeReviewStatus = "pending" | "approved" | "changes_requested";
|
|
7
|
+
export type RuntimeExchangeWaitStatus = "waiting" | "satisfied" | "cancelled";
|
|
8
|
+
export interface RuntimeExchangeThread {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
kind: RuntimeExchangeThreadKind;
|
|
12
|
+
status: RuntimeExchangeThreadStatus;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
createdBy: string;
|
|
16
|
+
participants: string[];
|
|
17
|
+
owner?: string;
|
|
18
|
+
waitingOn?: string[];
|
|
19
|
+
worktreePath?: string;
|
|
20
|
+
taskId?: string;
|
|
21
|
+
relatedPlanIds?: string[];
|
|
22
|
+
lastMessageId?: string;
|
|
23
|
+
unreadBy?: string[];
|
|
24
|
+
tags?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface RuntimeExchangeMessage {
|
|
27
|
+
id: string;
|
|
28
|
+
threadId: string;
|
|
29
|
+
ts: string;
|
|
30
|
+
from: string;
|
|
31
|
+
to?: string[];
|
|
32
|
+
kind: RuntimeExchangeMessageKind;
|
|
33
|
+
body: string;
|
|
34
|
+
taskId?: string;
|
|
35
|
+
planId?: string;
|
|
36
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
37
|
+
deliveredTo?: string[];
|
|
38
|
+
deliveredAt?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface RuntimeExchangeTask {
|
|
41
|
+
id: string;
|
|
42
|
+
status: RuntimeExchangeTaskStatus;
|
|
43
|
+
assignedBy: string;
|
|
44
|
+
assignedTo?: string;
|
|
45
|
+
assignee?: string;
|
|
46
|
+
assigner?: string;
|
|
47
|
+
threadId?: string;
|
|
48
|
+
tool?: string;
|
|
49
|
+
description: string;
|
|
50
|
+
prompt: string;
|
|
51
|
+
result?: string;
|
|
52
|
+
error?: string;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
notifiedAt?: string;
|
|
56
|
+
type?: "task" | "review";
|
|
57
|
+
reviewStatus?: RuntimeExchangeReviewStatus;
|
|
58
|
+
reviewFeedback?: string;
|
|
59
|
+
diff?: string;
|
|
60
|
+
iteration?: number;
|
|
61
|
+
reviewOf?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface RuntimeExchangeHandoff {
|
|
64
|
+
id: string;
|
|
65
|
+
threadId: string;
|
|
66
|
+
status: "waiting" | "accepted" | "completed" | "cancelled";
|
|
67
|
+
from: string;
|
|
68
|
+
to: string[];
|
|
69
|
+
acceptedBy?: string;
|
|
70
|
+
completedBy?: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
}
|
|
74
|
+
export interface RuntimeExchangeReview {
|
|
75
|
+
id: string;
|
|
76
|
+
taskId: string;
|
|
77
|
+
reviewOf?: string;
|
|
78
|
+
reviewer?: string;
|
|
79
|
+
status: RuntimeExchangeReviewStatus;
|
|
80
|
+
feedback?: string;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
updatedAt: string;
|
|
83
|
+
}
|
|
84
|
+
export interface RuntimeExchangeWait {
|
|
85
|
+
id: string;
|
|
86
|
+
status: RuntimeExchangeWaitStatus;
|
|
87
|
+
subjectKind: "thread" | "task" | "handoff" | "review" | "message";
|
|
88
|
+
subjectId: string;
|
|
89
|
+
waitingOn: string[];
|
|
90
|
+
owner?: string;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
resolvedAt?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface RuntimeExchangeInboxEntry {
|
|
96
|
+
id: string;
|
|
97
|
+
participantId: string;
|
|
98
|
+
subjectKind: "thread" | "task" | "handoff" | "review" | "message";
|
|
99
|
+
subjectId: string;
|
|
100
|
+
state: "unread" | "waiting" | "blocked" | "done";
|
|
101
|
+
urgency: number;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
}
|
|
104
|
+
export interface RuntimeExchangePlanRef {
|
|
105
|
+
id: string;
|
|
106
|
+
path: string;
|
|
107
|
+
ownerSessionId?: string;
|
|
108
|
+
threadId?: string;
|
|
109
|
+
taskId?: string;
|
|
110
|
+
title?: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
updatedAt: string;
|
|
113
|
+
}
|
|
114
|
+
export interface RuntimeExchangeContinuityRef {
|
|
115
|
+
id: string;
|
|
116
|
+
kind: "history" | "context" | "recording" | "status";
|
|
117
|
+
path: string;
|
|
118
|
+
sessionId?: string;
|
|
119
|
+
threadId?: string;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
updatedAt: string;
|
|
122
|
+
}
|
|
123
|
+
export interface RuntimeExchangeAttachmentRef {
|
|
124
|
+
id: string;
|
|
125
|
+
path: string;
|
|
126
|
+
contentUrl?: string;
|
|
127
|
+
threadId?: string;
|
|
128
|
+
messageId?: string;
|
|
129
|
+
mediaType?: string;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
updatedAt: string;
|
|
132
|
+
}
|
|
133
|
+
export interface RuntimeExchange {
|
|
134
|
+
version: typeof RUNTIME_EXCHANGE_VERSION;
|
|
135
|
+
generatedAt: string;
|
|
136
|
+
threads: RuntimeExchangeThread[];
|
|
137
|
+
messages: RuntimeExchangeMessage[];
|
|
138
|
+
tasks: RuntimeExchangeTask[];
|
|
139
|
+
handoffs: RuntimeExchangeHandoff[];
|
|
140
|
+
reviews: RuntimeExchangeReview[];
|
|
141
|
+
waits: RuntimeExchangeWait[];
|
|
142
|
+
inbox: RuntimeExchangeInboxEntry[];
|
|
143
|
+
planRefs: RuntimeExchangePlanRef[];
|
|
144
|
+
continuityRefs: RuntimeExchangeContinuityRef[];
|
|
145
|
+
attachmentRefs: RuntimeExchangeAttachmentRef[];
|
|
146
|
+
}
|
|
147
|
+
export declare function emptyRuntimeExchange(now?: string): RuntimeExchange;
|
|
148
|
+
export declare class RuntimeExchangeStore {
|
|
149
|
+
readonly path: string;
|
|
150
|
+
constructor(path?: string);
|
|
151
|
+
read(): RuntimeExchange;
|
|
152
|
+
write(exchange: RuntimeExchange): RuntimeExchange;
|
|
153
|
+
private acquireUpdateLock;
|
|
154
|
+
private recoverStaleUpdateLock;
|
|
155
|
+
update(mutator: (exchange: RuntimeExchange) => RuntimeExchange): RuntimeExchange;
|
|
156
|
+
}
|
|
157
|
+
export declare function createRuntimeExchangeStore(path?: string): RuntimeExchangeStore;
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { parse, stringify } from "yaml";
|
|
4
|
+
import { getRuntimeExchangePath } from "../paths.js";
|
|
5
|
+
export const RUNTIME_EXCHANGE_VERSION = 1;
|
|
6
|
+
const UPDATE_LOCK_TIMEOUT_MS = 5_000;
|
|
7
|
+
const UPDATE_LOCK_RETRY_MS = 25;
|
|
8
|
+
const UPDATE_LOCK_STALE_MS = UPDATE_LOCK_TIMEOUT_MS - 1_000;
|
|
9
|
+
export function emptyRuntimeExchange(now = new Date().toISOString()) {
|
|
10
|
+
return {
|
|
11
|
+
version: RUNTIME_EXCHANGE_VERSION,
|
|
12
|
+
generatedAt: now,
|
|
13
|
+
threads: [],
|
|
14
|
+
messages: [],
|
|
15
|
+
tasks: [],
|
|
16
|
+
handoffs: [],
|
|
17
|
+
reviews: [],
|
|
18
|
+
waits: [],
|
|
19
|
+
inbox: [],
|
|
20
|
+
planRefs: [],
|
|
21
|
+
continuityRefs: [],
|
|
22
|
+
attachmentRefs: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function asRecord(value, context) {
|
|
26
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
27
|
+
throw new Error(`invalid runtime exchange: ${context} must be an object`);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
function asString(value, context) {
|
|
32
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
33
|
+
throw new Error(`invalid runtime exchange: ${context} must be a non-empty string`);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function asOptionalString(value) {
|
|
38
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
function asStringArray(value) {
|
|
41
|
+
if (!Array.isArray(value))
|
|
42
|
+
return undefined;
|
|
43
|
+
return value.map((entry) => String(entry));
|
|
44
|
+
}
|
|
45
|
+
function asRequiredStringArray(value, context) {
|
|
46
|
+
if (!Array.isArray(value))
|
|
47
|
+
throw new Error(`invalid runtime exchange: ${context} must be an array`);
|
|
48
|
+
return value.map((entry) => String(entry)).filter((entry) => entry.trim().length > 0);
|
|
49
|
+
}
|
|
50
|
+
function asOptionalNumber(value) {
|
|
51
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
52
|
+
}
|
|
53
|
+
function asNumber(value) {
|
|
54
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
55
|
+
}
|
|
56
|
+
function asMessageMetadata(value) {
|
|
57
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
58
|
+
return undefined;
|
|
59
|
+
const entries = Object.entries(value).filter((entry) => {
|
|
60
|
+
const [, field] = entry;
|
|
61
|
+
return field === null || typeof field === "string" || typeof field === "number" || typeof field === "boolean";
|
|
62
|
+
});
|
|
63
|
+
return Object.fromEntries(entries);
|
|
64
|
+
}
|
|
65
|
+
function asArray(value) {
|
|
66
|
+
return Array.isArray(value) ? value : [];
|
|
67
|
+
}
|
|
68
|
+
function normalizeRuntimeExchange(exchange) {
|
|
69
|
+
const threads = exchange.threads;
|
|
70
|
+
const threadIds = new Set(threads.map((thread) => thread.id));
|
|
71
|
+
const messages = exchange.messages.filter((message) => threadIds.has(message.threadId));
|
|
72
|
+
const messageIds = new Set(messages.map((message) => message.id));
|
|
73
|
+
const tasks = exchange.tasks.filter((task) => !task.threadId || threadIds.has(task.threadId));
|
|
74
|
+
const taskIds = new Set(tasks.map((task) => task.id));
|
|
75
|
+
const handoffs = exchange.handoffs.filter((handoff) => threadIds.has(handoff.threadId));
|
|
76
|
+
const handoffIds = new Set(handoffs.map((handoff) => handoff.id));
|
|
77
|
+
const reviews = exchange.reviews.filter((review) => taskIds.has(review.taskId));
|
|
78
|
+
const reviewIds = new Set(reviews.map((review) => review.id));
|
|
79
|
+
const subjectExists = (kind, id) => {
|
|
80
|
+
if (kind === "thread")
|
|
81
|
+
return threadIds.has(id);
|
|
82
|
+
if (kind === "task")
|
|
83
|
+
return taskIds.has(id);
|
|
84
|
+
if (kind === "handoff")
|
|
85
|
+
return handoffIds.has(id);
|
|
86
|
+
if (kind === "review")
|
|
87
|
+
return reviewIds.has(id);
|
|
88
|
+
return messageIds.has(id);
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
...exchange,
|
|
92
|
+
threads,
|
|
93
|
+
messages,
|
|
94
|
+
tasks,
|
|
95
|
+
handoffs,
|
|
96
|
+
reviews,
|
|
97
|
+
waits: exchange.waits.filter((wait) => subjectExists(wait.subjectKind, wait.subjectId)),
|
|
98
|
+
inbox: exchange.inbox.filter((entry) => subjectExists(entry.subjectKind, entry.subjectId)),
|
|
99
|
+
planRefs: exchange.planRefs.filter((ref) => (!ref.threadId || threadIds.has(ref.threadId)) && (!ref.taskId || taskIds.has(ref.taskId))),
|
|
100
|
+
continuityRefs: exchange.continuityRefs.filter((ref) => !ref.threadId || threadIds.has(ref.threadId)),
|
|
101
|
+
attachmentRefs: exchange.attachmentRefs.filter((ref) => (!ref.threadId || threadIds.has(ref.threadId)) && (!ref.messageId || messageIds.has(ref.messageId))),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function coerceRuntimeExchange(raw) {
|
|
105
|
+
const record = asRecord(raw, "root");
|
|
106
|
+
if (record.version !== RUNTIME_EXCHANGE_VERSION) {
|
|
107
|
+
throw new Error(`unsupported runtime exchange version: ${String(record.version)}`);
|
|
108
|
+
}
|
|
109
|
+
return normalizeRuntimeExchange({
|
|
110
|
+
version: RUNTIME_EXCHANGE_VERSION,
|
|
111
|
+
generatedAt: asString(record.generatedAt, "generatedAt"),
|
|
112
|
+
threads: asArray(record.threads).map((entry, index) => {
|
|
113
|
+
const row = asRecord(entry, `threads[${index}]`);
|
|
114
|
+
return {
|
|
115
|
+
id: asString(row.id, `threads[${index}].id`),
|
|
116
|
+
title: asString(row.title, `threads[${index}].title`),
|
|
117
|
+
kind: asThreadKind(row.kind),
|
|
118
|
+
status: asThreadStatus(row.status),
|
|
119
|
+
createdAt: asString(row.createdAt, `threads[${index}].createdAt`),
|
|
120
|
+
updatedAt: asString(row.updatedAt, `threads[${index}].updatedAt`),
|
|
121
|
+
createdBy: asString(row.createdBy, `threads[${index}].createdBy`),
|
|
122
|
+
participants: asRequiredStringArray(row.participants, `threads[${index}].participants`),
|
|
123
|
+
owner: asOptionalString(row.owner),
|
|
124
|
+
waitingOn: asStringArray(row.waitingOn),
|
|
125
|
+
worktreePath: asOptionalString(row.worktreePath),
|
|
126
|
+
taskId: asOptionalString(row.taskId),
|
|
127
|
+
relatedPlanIds: asStringArray(row.relatedPlanIds),
|
|
128
|
+
lastMessageId: asOptionalString(row.lastMessageId),
|
|
129
|
+
unreadBy: asStringArray(row.unreadBy),
|
|
130
|
+
tags: asStringArray(row.tags),
|
|
131
|
+
};
|
|
132
|
+
}),
|
|
133
|
+
messages: asArray(record.messages).map((entry, index) => {
|
|
134
|
+
const row = asRecord(entry, `messages[${index}]`);
|
|
135
|
+
return {
|
|
136
|
+
id: asString(row.id, `messages[${index}].id`),
|
|
137
|
+
threadId: asString(row.threadId, `messages[${index}].threadId`),
|
|
138
|
+
ts: asString(row.ts, `messages[${index}].ts`),
|
|
139
|
+
from: asString(row.from, `messages[${index}].from`),
|
|
140
|
+
to: asStringArray(row.to),
|
|
141
|
+
kind: asMessageKind(row.kind),
|
|
142
|
+
body: asString(row.body, `messages[${index}].body`),
|
|
143
|
+
taskId: asOptionalString(row.taskId),
|
|
144
|
+
planId: asOptionalString(row.planId),
|
|
145
|
+
metadata: asMessageMetadata(row.metadata),
|
|
146
|
+
deliveredTo: asStringArray(row.deliveredTo),
|
|
147
|
+
deliveredAt: asOptionalString(row.deliveredAt),
|
|
148
|
+
};
|
|
149
|
+
}),
|
|
150
|
+
tasks: asArray(record.tasks).map((entry, index) => {
|
|
151
|
+
const row = asRecord(entry, `tasks[${index}]`);
|
|
152
|
+
return {
|
|
153
|
+
id: asString(row.id, `tasks[${index}].id`),
|
|
154
|
+
status: asTaskStatus(row.status),
|
|
155
|
+
assignedBy: asString(row.assignedBy, `tasks[${index}].assignedBy`),
|
|
156
|
+
assignedTo: asOptionalString(row.assignedTo),
|
|
157
|
+
assignee: asOptionalString(row.assignee),
|
|
158
|
+
assigner: asOptionalString(row.assigner),
|
|
159
|
+
threadId: asOptionalString(row.threadId),
|
|
160
|
+
tool: asOptionalString(row.tool),
|
|
161
|
+
description: asString(row.description, `tasks[${index}].description`),
|
|
162
|
+
prompt: asString(row.prompt, `tasks[${index}].prompt`),
|
|
163
|
+
result: asOptionalString(row.result),
|
|
164
|
+
error: asOptionalString(row.error),
|
|
165
|
+
createdAt: asString(row.createdAt, `tasks[${index}].createdAt`),
|
|
166
|
+
updatedAt: asString(row.updatedAt, `tasks[${index}].updatedAt`),
|
|
167
|
+
notifiedAt: asOptionalString(row.notifiedAt),
|
|
168
|
+
type: asTaskType(row.type),
|
|
169
|
+
reviewStatus: row.reviewStatus ? asReviewStatus(row.reviewStatus) : undefined,
|
|
170
|
+
reviewFeedback: asOptionalString(row.reviewFeedback),
|
|
171
|
+
diff: asOptionalString(row.diff),
|
|
172
|
+
iteration: asOptionalNumber(row.iteration),
|
|
173
|
+
reviewOf: asOptionalString(row.reviewOf),
|
|
174
|
+
};
|
|
175
|
+
}),
|
|
176
|
+
handoffs: asArray(record.handoffs).map((entry, index) => {
|
|
177
|
+
const row = asRecord(entry, `handoffs[${index}]`);
|
|
178
|
+
return {
|
|
179
|
+
id: asString(row.id, `handoffs[${index}].id`),
|
|
180
|
+
threadId: asString(row.threadId, `handoffs[${index}].threadId`),
|
|
181
|
+
status: asHandoffStatus(row.status),
|
|
182
|
+
from: asString(row.from, `handoffs[${index}].from`),
|
|
183
|
+
to: asRequiredStringArray(row.to, `handoffs[${index}].to`),
|
|
184
|
+
acceptedBy: asOptionalString(row.acceptedBy),
|
|
185
|
+
completedBy: asOptionalString(row.completedBy),
|
|
186
|
+
createdAt: asString(row.createdAt, `handoffs[${index}].createdAt`),
|
|
187
|
+
updatedAt: asString(row.updatedAt, `handoffs[${index}].updatedAt`),
|
|
188
|
+
};
|
|
189
|
+
}),
|
|
190
|
+
reviews: asArray(record.reviews).map((entry, index) => {
|
|
191
|
+
const row = asRecord(entry, `reviews[${index}]`);
|
|
192
|
+
return {
|
|
193
|
+
id: asString(row.id, `reviews[${index}].id`),
|
|
194
|
+
taskId: asString(row.taskId, `reviews[${index}].taskId`),
|
|
195
|
+
reviewOf: asOptionalString(row.reviewOf),
|
|
196
|
+
reviewer: asOptionalString(row.reviewer),
|
|
197
|
+
status: asReviewStatus(row.status),
|
|
198
|
+
feedback: asOptionalString(row.feedback),
|
|
199
|
+
createdAt: asString(row.createdAt, `reviews[${index}].createdAt`),
|
|
200
|
+
updatedAt: asString(row.updatedAt, `reviews[${index}].updatedAt`),
|
|
201
|
+
};
|
|
202
|
+
}),
|
|
203
|
+
waits: asArray(record.waits).map((entry, index) => {
|
|
204
|
+
const row = asRecord(entry, `waits[${index}]`);
|
|
205
|
+
return {
|
|
206
|
+
id: asString(row.id, `waits[${index}].id`),
|
|
207
|
+
status: asWaitStatus(row.status),
|
|
208
|
+
subjectKind: asSubjectKind(row.subjectKind),
|
|
209
|
+
subjectId: asString(row.subjectId, `waits[${index}].subjectId`),
|
|
210
|
+
waitingOn: asRequiredStringArray(row.waitingOn, `waits[${index}].waitingOn`),
|
|
211
|
+
owner: asOptionalString(row.owner),
|
|
212
|
+
createdAt: asString(row.createdAt, `waits[${index}].createdAt`),
|
|
213
|
+
updatedAt: asString(row.updatedAt, `waits[${index}].updatedAt`),
|
|
214
|
+
resolvedAt: asOptionalString(row.resolvedAt),
|
|
215
|
+
};
|
|
216
|
+
}),
|
|
217
|
+
inbox: asArray(record.inbox).map((entry, index) => {
|
|
218
|
+
const row = asRecord(entry, `inbox[${index}]`);
|
|
219
|
+
return {
|
|
220
|
+
id: asString(row.id, `inbox[${index}].id`),
|
|
221
|
+
participantId: asString(row.participantId, `inbox[${index}].participantId`),
|
|
222
|
+
subjectKind: asSubjectKind(row.subjectKind),
|
|
223
|
+
subjectId: asString(row.subjectId, `inbox[${index}].subjectId`),
|
|
224
|
+
state: asInboxState(row.state),
|
|
225
|
+
urgency: asNumber(row.urgency),
|
|
226
|
+
updatedAt: asString(row.updatedAt, `inbox[${index}].updatedAt`),
|
|
227
|
+
};
|
|
228
|
+
}),
|
|
229
|
+
planRefs: asArray(record.planRefs).map((entry, index) => {
|
|
230
|
+
const row = asRecord(entry, `planRefs[${index}]`);
|
|
231
|
+
return {
|
|
232
|
+
id: asString(row.id, `planRefs[${index}].id`),
|
|
233
|
+
path: asString(row.path, `planRefs[${index}].path`),
|
|
234
|
+
ownerSessionId: asOptionalString(row.ownerSessionId),
|
|
235
|
+
threadId: asOptionalString(row.threadId),
|
|
236
|
+
taskId: asOptionalString(row.taskId),
|
|
237
|
+
title: asOptionalString(row.title),
|
|
238
|
+
createdAt: asString(row.createdAt, `planRefs[${index}].createdAt`),
|
|
239
|
+
updatedAt: asString(row.updatedAt, `planRefs[${index}].updatedAt`),
|
|
240
|
+
};
|
|
241
|
+
}),
|
|
242
|
+
continuityRefs: asArray(record.continuityRefs).map((entry, index) => {
|
|
243
|
+
const row = asRecord(entry, `continuityRefs[${index}]`);
|
|
244
|
+
return {
|
|
245
|
+
id: asString(row.id, `continuityRefs[${index}].id`),
|
|
246
|
+
kind: asContinuityKind(row.kind),
|
|
247
|
+
path: asString(row.path, `continuityRefs[${index}].path`),
|
|
248
|
+
sessionId: asOptionalString(row.sessionId),
|
|
249
|
+
threadId: asOptionalString(row.threadId),
|
|
250
|
+
createdAt: asString(row.createdAt, `continuityRefs[${index}].createdAt`),
|
|
251
|
+
updatedAt: asString(row.updatedAt, `continuityRefs[${index}].updatedAt`),
|
|
252
|
+
};
|
|
253
|
+
}),
|
|
254
|
+
attachmentRefs: asArray(record.attachmentRefs).map((entry, index) => {
|
|
255
|
+
const row = asRecord(entry, `attachmentRefs[${index}]`);
|
|
256
|
+
return {
|
|
257
|
+
id: asString(row.id, `attachmentRefs[${index}].id`),
|
|
258
|
+
path: asString(row.path, `attachmentRefs[${index}].path`),
|
|
259
|
+
contentUrl: asOptionalString(row.contentUrl),
|
|
260
|
+
threadId: asOptionalString(row.threadId),
|
|
261
|
+
messageId: asOptionalString(row.messageId),
|
|
262
|
+
mediaType: asOptionalString(row.mediaType),
|
|
263
|
+
createdAt: asString(row.createdAt, `attachmentRefs[${index}].createdAt`),
|
|
264
|
+
updatedAt: asString(row.updatedAt, `attachmentRefs[${index}].updatedAt`),
|
|
265
|
+
};
|
|
266
|
+
}),
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function asThreadKind(value) {
|
|
270
|
+
const kind = String(value);
|
|
271
|
+
if (kind === "conversation" || kind === "task" || kind === "review" || kind === "handoff" || kind === "user") {
|
|
272
|
+
return kind;
|
|
273
|
+
}
|
|
274
|
+
return "conversation";
|
|
275
|
+
}
|
|
276
|
+
function asThreadStatus(value) {
|
|
277
|
+
const status = String(value);
|
|
278
|
+
if (status === "open" ||
|
|
279
|
+
status === "waiting" ||
|
|
280
|
+
status === "blocked" ||
|
|
281
|
+
status === "done" ||
|
|
282
|
+
status === "abandoned") {
|
|
283
|
+
return status;
|
|
284
|
+
}
|
|
285
|
+
return "open";
|
|
286
|
+
}
|
|
287
|
+
function asMessageKind(value) {
|
|
288
|
+
const kind = String(value);
|
|
289
|
+
if (kind === "request" ||
|
|
290
|
+
kind === "reply" ||
|
|
291
|
+
kind === "status" ||
|
|
292
|
+
kind === "decision" ||
|
|
293
|
+
kind === "handoff" ||
|
|
294
|
+
kind === "note") {
|
|
295
|
+
return kind;
|
|
296
|
+
}
|
|
297
|
+
return "note";
|
|
298
|
+
}
|
|
299
|
+
function asTaskStatus(value) {
|
|
300
|
+
const status = String(value);
|
|
301
|
+
if (status === "pending" ||
|
|
302
|
+
status === "assigned" ||
|
|
303
|
+
status === "in_progress" ||
|
|
304
|
+
status === "blocked" ||
|
|
305
|
+
status === "done" ||
|
|
306
|
+
status === "failed") {
|
|
307
|
+
return status;
|
|
308
|
+
}
|
|
309
|
+
return "failed";
|
|
310
|
+
}
|
|
311
|
+
function asReviewStatus(value) {
|
|
312
|
+
const status = String(value);
|
|
313
|
+
if (status === "pending" || status === "approved" || status === "changes_requested")
|
|
314
|
+
return status;
|
|
315
|
+
return "pending";
|
|
316
|
+
}
|
|
317
|
+
function asTaskType(value) {
|
|
318
|
+
const type = String(value);
|
|
319
|
+
if (type === "task" || type === "review")
|
|
320
|
+
return type;
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
function asHandoffStatus(value) {
|
|
324
|
+
const status = String(value);
|
|
325
|
+
if (status === "waiting" || status === "accepted" || status === "completed" || status === "cancelled") {
|
|
326
|
+
return status;
|
|
327
|
+
}
|
|
328
|
+
return "waiting";
|
|
329
|
+
}
|
|
330
|
+
function asWaitStatus(value) {
|
|
331
|
+
const status = String(value);
|
|
332
|
+
if (status === "waiting" || status === "satisfied" || status === "cancelled")
|
|
333
|
+
return status;
|
|
334
|
+
return "cancelled";
|
|
335
|
+
}
|
|
336
|
+
function asSubjectKind(value) {
|
|
337
|
+
const kind = String(value);
|
|
338
|
+
if (kind === "thread" || kind === "task" || kind === "handoff" || kind === "review" || kind === "message") {
|
|
339
|
+
return kind;
|
|
340
|
+
}
|
|
341
|
+
return "thread";
|
|
342
|
+
}
|
|
343
|
+
function asInboxState(value) {
|
|
344
|
+
const state = String(value);
|
|
345
|
+
if (state === "unread" || state === "waiting" || state === "blocked" || state === "done")
|
|
346
|
+
return state;
|
|
347
|
+
return "unread";
|
|
348
|
+
}
|
|
349
|
+
function asContinuityKind(value) {
|
|
350
|
+
const kind = String(value);
|
|
351
|
+
if (kind === "history" || kind === "context" || kind === "recording" || kind === "status")
|
|
352
|
+
return kind;
|
|
353
|
+
return "history";
|
|
354
|
+
}
|
|
355
|
+
function sleepSync(ms) {
|
|
356
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
357
|
+
}
|
|
358
|
+
function isProcessAlive(pid) {
|
|
359
|
+
try {
|
|
360
|
+
process.kill(pid, 0);
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
return error.code === "EPERM";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
export class RuntimeExchangeStore {
|
|
368
|
+
path;
|
|
369
|
+
constructor(path = getRuntimeExchangePath()) {
|
|
370
|
+
this.path = path;
|
|
371
|
+
}
|
|
372
|
+
read() {
|
|
373
|
+
if (!existsSync(this.path))
|
|
374
|
+
return emptyRuntimeExchange();
|
|
375
|
+
const parsed = parse(readFileSync(this.path, "utf-8"));
|
|
376
|
+
return coerceRuntimeExchange(parsed);
|
|
377
|
+
}
|
|
378
|
+
write(exchange) {
|
|
379
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
380
|
+
const normalized = coerceRuntimeExchange(exchange);
|
|
381
|
+
const tmpPath = `${this.path}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
382
|
+
writeFileSync(tmpPath, stringify(normalized, {
|
|
383
|
+
lineWidth: 120,
|
|
384
|
+
sortMapEntries: false,
|
|
385
|
+
}));
|
|
386
|
+
renameSync(tmpPath, this.path);
|
|
387
|
+
return normalized;
|
|
388
|
+
}
|
|
389
|
+
acquireUpdateLock() {
|
|
390
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
391
|
+
const lockPath = `${this.path}.lock`;
|
|
392
|
+
const deadline = Date.now() + UPDATE_LOCK_TIMEOUT_MS;
|
|
393
|
+
while (true) {
|
|
394
|
+
try {
|
|
395
|
+
mkdirSync(lockPath);
|
|
396
|
+
try {
|
|
397
|
+
writeFileSync(join(lockPath, "owner"), `${process.pid}\n`);
|
|
398
|
+
}
|
|
399
|
+
catch (ownerError) {
|
|
400
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
401
|
+
throw ownerError;
|
|
402
|
+
}
|
|
403
|
+
return () => rmSync(lockPath, { recursive: true, force: true });
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
if (this.recoverStaleUpdateLock(lockPath)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (Date.now() >= deadline) {
|
|
410
|
+
throw new Error(`Timed out acquiring runtime exchange update lock at ${lockPath}`, { cause: error });
|
|
411
|
+
}
|
|
412
|
+
sleepSync(UPDATE_LOCK_RETRY_MS);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
recoverStaleUpdateLock(lockPath) {
|
|
417
|
+
const ownerPath = join(lockPath, "owner");
|
|
418
|
+
try {
|
|
419
|
+
const ownerPid = Number.parseInt(readFileSync(ownerPath, "utf-8").trim(), 10);
|
|
420
|
+
if (Number.isFinite(ownerPid) && ownerPid > 0) {
|
|
421
|
+
if (isProcessAlive(ownerPid))
|
|
422
|
+
return false;
|
|
423
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
if (existsSync(ownerPath))
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
if (Date.now() - statSync(lockPath).mtimeMs > UPDATE_LOCK_STALE_MS) {
|
|
433
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch { }
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
update(mutator) {
|
|
441
|
+
const release = this.acquireUpdateLock();
|
|
442
|
+
try {
|
|
443
|
+
return this.write(mutator(this.read()));
|
|
444
|
+
}
|
|
445
|
+
finally {
|
|
446
|
+
release();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
export function createRuntimeExchangeStore(path) {
|
|
451
|
+
return new RuntimeExchangeStore(path);
|
|
452
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type RuntimeTopology, type RuntimeTopologyService, type RuntimeTopologyServiceStatus, type RuntimeTopologyStore } from "./topology-store.js";
|
|
2
|
+
export type RuntimeTopologyServiceState = {
|
|
3
|
+
id: string;
|
|
4
|
+
status?: RuntimeTopologyServiceStatus;
|
|
5
|
+
command?: string;
|
|
6
|
+
args?: string[];
|
|
7
|
+
launchCommandLine?: string;
|
|
8
|
+
worktreePath?: string;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
lastSeenAt?: string;
|
|
13
|
+
retained?: boolean;
|
|
14
|
+
tmuxTarget?: {
|
|
15
|
+
sessionName: string;
|
|
16
|
+
windowId: string;
|
|
17
|
+
windowIndex: number;
|
|
18
|
+
windowName: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function topologyServiceToServiceState(service: RuntimeTopologyService, topology: RuntimeTopology): RuntimeTopologyServiceState;
|
|
22
|
+
export declare function listTopologyServiceStates(input?: {
|
|
23
|
+
statuses?: RuntimeTopologyServiceStatus[];
|
|
24
|
+
store?: RuntimeTopologyStore;
|
|
25
|
+
}): RuntimeTopologyServiceState[];
|
|
26
|
+
export declare function upsertTopologyService(service: RuntimeTopologyServiceState, status: RuntimeTopologyServiceStatus, input?: {
|
|
27
|
+
store?: RuntimeTopologyStore;
|
|
28
|
+
now?: string;
|
|
29
|
+
projectRoot?: string;
|
|
30
|
+
}): RuntimeTopology;
|
|
31
|
+
export declare function removeTopologyService(serviceId: string, input?: {
|
|
32
|
+
store?: RuntimeTopologyStore;
|
|
33
|
+
now?: string;
|
|
34
|
+
}): RuntimeTopologyServiceState | undefined;
|
|
35
|
+
export declare function removeTopologyServicesForWorktree(worktreePath: string, input?: {
|
|
36
|
+
store?: RuntimeTopologyStore;
|
|
37
|
+
now?: string;
|
|
38
|
+
}): RuntimeTopologyServiceState[];
|