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
|
@@ -4,11 +4,12 @@ import { findMainRepo } from "../worktree.js";
|
|
|
4
4
|
import { getStatePath } from "../paths.js";
|
|
5
5
|
import { wrapCommandWithShellIntegration, wrapInteractiveShellWithIntegration } from "../shell-hooks.js";
|
|
6
6
|
import { markLastUsed } from "../last-used.js";
|
|
7
|
+
import { removeTopologyService, upsertTopologyService, } from "../runtime-core/topology-services.js";
|
|
7
8
|
export function generateServiceId() {
|
|
8
9
|
return `service-${randomUUID().slice(0, 8)}`;
|
|
9
10
|
}
|
|
10
11
|
export function getServiceLaunchCommandLine(metadata) {
|
|
11
|
-
return metadata.
|
|
12
|
+
return metadata.args?.[0] === "-lc" ? (metadata.args[1] ?? "") : "";
|
|
12
13
|
}
|
|
13
14
|
function shellQuote(value) {
|
|
14
15
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -29,13 +30,14 @@ function buildServiceLaunchScript(commandLine, shellPath) {
|
|
|
29
30
|
].join("; ");
|
|
30
31
|
}
|
|
31
32
|
export function buildServiceStateFromMetadata(serviceId, metadata, opts = {}) {
|
|
33
|
+
const launchCommandLine = metadata.launchCommandLine?.trim() || getServiceLaunchCommandLine(metadata);
|
|
32
34
|
return {
|
|
33
35
|
id: serviceId,
|
|
34
36
|
createdAt: metadata.createdAt,
|
|
35
37
|
worktreePath: metadata.worktreePath,
|
|
36
38
|
cwd: opts.cwd,
|
|
37
39
|
label: metadata.label,
|
|
38
|
-
launchCommandLine
|
|
40
|
+
launchCommandLine,
|
|
39
41
|
tmuxTarget: opts.tmuxTarget,
|
|
40
42
|
retained: opts.retained,
|
|
41
43
|
};
|
|
@@ -55,6 +57,30 @@ function markServiceUsed(host, serviceId) {
|
|
|
55
57
|
}
|
|
56
58
|
catch { }
|
|
57
59
|
}
|
|
60
|
+
function serviceMetadataToTopologyState(serviceId, metadata, opts = {}) {
|
|
61
|
+
return {
|
|
62
|
+
id: serviceId,
|
|
63
|
+
command: metadata.command,
|
|
64
|
+
args: metadata.args ?? [],
|
|
65
|
+
createdAt: metadata.createdAt?.trim() || undefined,
|
|
66
|
+
worktreePath: metadata.worktreePath,
|
|
67
|
+
cwd: opts.cwd,
|
|
68
|
+
label: metadata.label,
|
|
69
|
+
launchCommandLine: metadata.launchCommandLine?.trim() || getServiceLaunchCommandLine(metadata),
|
|
70
|
+
tmuxTarget: opts.tmuxTarget,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function serviceStateToTopologyState(service) {
|
|
74
|
+
return {
|
|
75
|
+
id: service.id,
|
|
76
|
+
createdAt: service.createdAt?.trim() || undefined,
|
|
77
|
+
worktreePath: service.worktreePath,
|
|
78
|
+
cwd: service.cwd,
|
|
79
|
+
label: service.label,
|
|
80
|
+
launchCommandLine: service.launchCommandLine,
|
|
81
|
+
tmuxTarget: service.tmuxTarget,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
58
84
|
export function serviceLabelForCommand(commandLine) {
|
|
59
85
|
const trimmed = commandLine.trim();
|
|
60
86
|
if (!trimmed)
|
|
@@ -96,7 +122,7 @@ export function createService(host, commandLine, worktreePath, opts) {
|
|
|
96
122
|
const tmuxSession = host.tmuxRuntimeManager.ensureProjectSession(process.cwd());
|
|
97
123
|
const shouldRenderPending = host.startedInDashboard && host.mode === "dashboard";
|
|
98
124
|
if (shouldRenderPending) {
|
|
99
|
-
host.
|
|
125
|
+
host.setPendingDashboardServiceAction(serviceId, "creating", {
|
|
100
126
|
serviceSeed: {
|
|
101
127
|
id: serviceId,
|
|
102
128
|
command: trimmed ? shell : "shell",
|
|
@@ -123,19 +149,30 @@ export function createService(host, commandLine, worktreePath, opts) {
|
|
|
123
149
|
createdAt: new Date().toISOString(),
|
|
124
150
|
worktreePath,
|
|
125
151
|
label,
|
|
152
|
+
launchCommandLine: trimmed,
|
|
126
153
|
});
|
|
154
|
+
upsertTopologyService({
|
|
155
|
+
id: serviceId,
|
|
156
|
+
command: trimmed ? shell : "shell",
|
|
157
|
+
args: trimmed ? ["-lc", trimmed] : ["-l"],
|
|
158
|
+
launchCommandLine: trimmed,
|
|
159
|
+
worktreePath,
|
|
160
|
+
cwd,
|
|
161
|
+
label,
|
|
162
|
+
tmuxTarget: target,
|
|
163
|
+
}, "running");
|
|
127
164
|
host.tmuxRuntimeManager.applyManagedAgentWindowPolicy(target, "service");
|
|
128
165
|
host.saveState();
|
|
129
166
|
host.invalidateDesktopStateSnapshot();
|
|
130
167
|
host.refreshLocalDashboardModel();
|
|
131
168
|
host.updateWorktreeSessions();
|
|
132
169
|
host.preferDashboardEntrySelection("service", serviceId, worktreePath);
|
|
133
|
-
host.settleDashboardCreatePending(serviceId);
|
|
170
|
+
host.settleDashboardCreatePending(serviceId, "service");
|
|
134
171
|
return { serviceId };
|
|
135
172
|
}
|
|
136
173
|
catch (error) {
|
|
137
174
|
if (shouldRenderPending) {
|
|
138
|
-
host.
|
|
175
|
+
host.setPendingDashboardServiceAction(serviceId, null);
|
|
139
176
|
}
|
|
140
177
|
throw error;
|
|
141
178
|
}
|
|
@@ -159,6 +196,10 @@ export function stopService(host, serviceId) {
|
|
|
159
196
|
retained: true,
|
|
160
197
|
}),
|
|
161
198
|
];
|
|
199
|
+
upsertTopologyService(serviceMetadataToTopologyState(serviceId, match.metadata, {
|
|
200
|
+
cwd,
|
|
201
|
+
tmuxTarget: match.target,
|
|
202
|
+
}), "stopped");
|
|
162
203
|
host.tmuxRuntimeManager.sendKey(match.target, "C-c");
|
|
163
204
|
host.tmuxRuntimeManager.setWindowMetadata(match.target, {
|
|
164
205
|
...match.metadata,
|
|
@@ -190,6 +231,7 @@ export function removeOfflineService(host, serviceId) {
|
|
|
190
231
|
catch { }
|
|
191
232
|
}
|
|
192
233
|
host.offlineServices = host.offlineServices.filter((service) => service.id !== serviceId);
|
|
234
|
+
removeTopologyService(serviceId);
|
|
193
235
|
const statePath = getStatePath();
|
|
194
236
|
if (existsSync(statePath)) {
|
|
195
237
|
try {
|
|
@@ -274,11 +316,19 @@ export function resumeOfflineService(host, service) {
|
|
|
274
316
|
sessionId: service.id,
|
|
275
317
|
command: launchCommandLine ? shell : "shell",
|
|
276
318
|
args: launchCommandLine ? ["-lc", launchCommandLine] : ["-l"],
|
|
319
|
+
launchCommandLine,
|
|
277
320
|
toolConfigKey: "service",
|
|
278
321
|
createdAt: service.createdAt ?? new Date().toISOString(),
|
|
279
322
|
worktreePath: service.worktreePath,
|
|
280
323
|
label,
|
|
281
324
|
});
|
|
325
|
+
upsertTopologyService({
|
|
326
|
+
...serviceStateToTopologyState(service),
|
|
327
|
+
command: launchCommandLine ? shell : "shell",
|
|
328
|
+
args: launchCommandLine ? ["-lc", launchCommandLine] : ["-l"],
|
|
329
|
+
label,
|
|
330
|
+
tmuxTarget: target,
|
|
331
|
+
}, "running");
|
|
282
332
|
host.tmuxRuntimeManager.applyManagedAgentWindowPolicy(target, "service");
|
|
283
333
|
host.offlineServices = host.offlineServices.filter((entry) => entry.id !== service.id);
|
|
284
334
|
markServiceUsed(host, service.id);
|
|
@@ -306,4 +356,3 @@ export function resumeOfflineServiceById(host, serviceId) {
|
|
|
306
356
|
const restored = buildServiceStateFromMetadata(serviceId, existing.metadata);
|
|
307
357
|
return resumeOfflineService(host, restored);
|
|
308
358
|
}
|
|
309
|
-
//# sourceMappingURL=services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractCodexBackendSessionIdFromArgs(args: string[]): string | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function extractCodexBackendSessionIdFromArgs(args) {
|
|
2
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
3
|
+
const arg = args[i];
|
|
4
|
+
if (arg === "resume") {
|
|
5
|
+
const next = args[i + 1]?.trim();
|
|
6
|
+
if (next && !next.startsWith("-"))
|
|
7
|
+
return next;
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (arg === "--resume") {
|
|
11
|
+
const next = args[i + 1]?.trim();
|
|
12
|
+
if (next && !next.startsWith("-"))
|
|
13
|
+
return next;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (arg.startsWith("--resume=")) {
|
|
17
|
+
const value = arg.slice("--resume=".length).trim();
|
|
18
|
+
if (value)
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { SessionTeamMetadata } from "../team.js";
|
|
1
2
|
type SessionLaunchHost = any;
|
|
3
|
+
export declare function summarizeLaunchArgs(args: string[]): string[];
|
|
4
|
+
export declare function injectCodexDeveloperInstructions(args: string[], key: string, instructions: string): string[];
|
|
2
5
|
export declare function run(host: SessionLaunchHost, opts: {
|
|
3
6
|
command: string;
|
|
4
7
|
args: string[];
|
|
@@ -7,7 +10,7 @@ export declare function runDashboard(host: SessionLaunchHost): Promise<number>;
|
|
|
7
10
|
export declare function runProjectService(host: SessionLaunchHost): Promise<number>;
|
|
8
11
|
export declare function resumeSessions(host: SessionLaunchHost, toolFilter?: string): Promise<number>;
|
|
9
12
|
export declare function restoreSessions(host: SessionLaunchHost, toolFilter?: string): Promise<number>;
|
|
10
|
-
export declare function createSession(host: SessionLaunchHost, command: string, args: string[], preambleFlag?: string[], toolConfigKey?: string, extraPreamble?: string, sessionIdFlag?: string[], worktreePath?: string, backendSessionIdOverride?: string, sessionIdOverride?: string, detachedInTmux?: boolean, suppressStartupPreamble?: boolean): any;
|
|
13
|
+
export declare function createSession(host: SessionLaunchHost, command: string, args: string[], preambleFlag?: string[], toolConfigKey?: string, extraPreamble?: string, sessionIdFlag?: string[], worktreePath?: string, backendSessionIdOverride?: string, sessionIdOverride?: string, detachedInTmux?: boolean, suppressStartupPreamble?: boolean, team?: SessionTeamMetadata): any;
|
|
11
14
|
export declare function migrateAgent(host: SessionLaunchHost, sessionId: string, targetWorktreePath: string): Promise<void>;
|
|
12
15
|
export declare function getSessionWorktreePath(host: SessionLaunchHost, sessionId: string): string | undefined;
|
|
13
16
|
export declare function getSessionsByWorktree(host: SessionLaunchHost): Map<string | undefined, any[]>;
|
|
@@ -4,19 +4,108 @@ import { buildContextPreamble } from "../context/context-bridge.js";
|
|
|
4
4
|
import { readHistory } from "../context/history.js";
|
|
5
5
|
import { findMainRepo } from "../worktree.js";
|
|
6
6
|
import { TmuxSessionTransport } from "../tmux/session-transport.js";
|
|
7
|
-
import { injectClaudeHookArgs, shouldSkipClaudeSessionIdInjection } from "../claude-hooks.js";
|
|
7
|
+
import { extractClaudeBackendSessionIdFromArgs, injectClaudeHookArgs, shouldSkipClaudeSessionIdInjection, } from "../claude-hooks.js";
|
|
8
8
|
import { wrapCommandWithManagedLaunchEnv } from "../managed-launch-env.js";
|
|
9
9
|
import { wrapCommandWithShellIntegration } from "../shell-hooks.js";
|
|
10
|
-
import { debug } from "../debug.js";
|
|
10
|
+
import { debug, log } from "../debug.js";
|
|
11
11
|
import { updateNotificationContext } from "../notification-context.js";
|
|
12
12
|
import { markNotificationsRead } from "../notifications.js";
|
|
13
|
+
import { clearSessionTranscriptPath } from "../metadata-store.js";
|
|
14
|
+
import { extractCodexBackendSessionIdFromArgs } from "./session-capture.js";
|
|
15
|
+
import { listTopologySessionStates } from "../runtime-core/topology-sessions.js";
|
|
16
|
+
function listLaunchableTopologySessions(toolFilter) {
|
|
17
|
+
const sessions = listTopologySessionStates({ statuses: ["offline"] });
|
|
18
|
+
return toolFilter ? sessions.filter((s) => s.tool === toolFilter || s.toolConfigKey === toolFilter) : sessions;
|
|
19
|
+
}
|
|
20
|
+
function reconcileLaunchableTopology(host) {
|
|
21
|
+
host.syncSessionsFromTopology?.();
|
|
22
|
+
host.saveState?.();
|
|
23
|
+
}
|
|
24
|
+
const CODEX_OPTIONS_WITH_VALUE = new Set([
|
|
25
|
+
"-a",
|
|
26
|
+
"--add-dir",
|
|
27
|
+
"--ask-for-approval",
|
|
28
|
+
"-c",
|
|
29
|
+
"--cd",
|
|
30
|
+
"--config",
|
|
31
|
+
"-i",
|
|
32
|
+
"--image",
|
|
33
|
+
"--local-provider",
|
|
34
|
+
"-m",
|
|
35
|
+
"--model",
|
|
36
|
+
"-p",
|
|
37
|
+
"--profile",
|
|
38
|
+
"--remote",
|
|
39
|
+
"--remote-auth-token-env",
|
|
40
|
+
"-s",
|
|
41
|
+
"--sandbox",
|
|
42
|
+
]);
|
|
43
|
+
const SENSITIVE_ENV_ARG_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIAL|AUTH)[A-Za-z0-9_]*=/i;
|
|
44
|
+
const SENSITIVE_OPTION_ARG_PATTERN = /^--?[A-Za-z0-9-]*(?:token|secret|password|pass|key|credential|auth)[A-Za-z0-9-]*(?:=.*)?$/i;
|
|
45
|
+
const SENSITIVE_OPTION_ASSIGNMENT_PATTERN = /^(--?[A-Za-z0-9-]*(?:token|secret|password|pass|key|credential|auth)[A-Za-z0-9-]*=).+/i;
|
|
46
|
+
function summarizeLaunchArg(arg) {
|
|
47
|
+
const sensitiveOptionAssignment = arg.match(SENSITIVE_OPTION_ASSIGNMENT_PATTERN);
|
|
48
|
+
if (sensitiveOptionAssignment) {
|
|
49
|
+
return `${sensitiveOptionAssignment[1]}<redacted>`;
|
|
50
|
+
}
|
|
51
|
+
if (SENSITIVE_ENV_ARG_PATTERN.test(arg)) {
|
|
52
|
+
return `${arg.slice(0, arg.indexOf("=") + 1)}<redacted>`;
|
|
53
|
+
}
|
|
54
|
+
return arg.length > 100 ? `${arg.slice(0, 100)}...` : arg;
|
|
55
|
+
}
|
|
56
|
+
export function summarizeLaunchArgs(args) {
|
|
57
|
+
let redactNext = false;
|
|
58
|
+
return args.map((arg) => {
|
|
59
|
+
if (redactNext) {
|
|
60
|
+
redactNext = false;
|
|
61
|
+
return "<redacted>";
|
|
62
|
+
}
|
|
63
|
+
const summarized = summarizeLaunchArg(arg);
|
|
64
|
+
redactNext = SENSITIVE_OPTION_ARG_PATTERN.test(arg) && !arg.includes("=");
|
|
65
|
+
return summarized;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function firstCodexPositionalArgIndex(args) {
|
|
69
|
+
let skipNext = false;
|
|
70
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
71
|
+
const arg = args[i];
|
|
72
|
+
if (skipNext) {
|
|
73
|
+
skipNext = false;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (arg === "--") {
|
|
77
|
+
return i;
|
|
78
|
+
}
|
|
79
|
+
if (arg.startsWith("--")) {
|
|
80
|
+
const [name, value] = arg.split("=", 2);
|
|
81
|
+
if (CODEX_OPTIONS_WITH_VALUE.has(name) && value === undefined) {
|
|
82
|
+
skipNext = true;
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (arg.startsWith("-")) {
|
|
87
|
+
if (CODEX_OPTIONS_WITH_VALUE.has(arg)) {
|
|
88
|
+
skipNext = true;
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
return i;
|
|
93
|
+
}
|
|
94
|
+
return args.length;
|
|
95
|
+
}
|
|
96
|
+
function codexConfigArg(key, value) {
|
|
97
|
+
return `${key}=${JSON.stringify(value)}`;
|
|
98
|
+
}
|
|
99
|
+
export function injectCodexDeveloperInstructions(args, key, instructions) {
|
|
100
|
+
if (!key.trim() || !instructions.trim())
|
|
101
|
+
return [...args];
|
|
102
|
+
const insertionIndex = firstCodexPositionalArgIndex(args);
|
|
103
|
+
return [...args.slice(0, insertionIndex), "-c", codexConfigArg(key, instructions), ...args.slice(insertionIndex)];
|
|
104
|
+
}
|
|
13
105
|
export async function run(host, opts) {
|
|
14
106
|
initProject();
|
|
15
|
-
await host.instanceDirectory.registerInstance(host.instanceId, process.cwd());
|
|
16
107
|
host.startHeartbeat();
|
|
17
|
-
host.
|
|
18
|
-
host.taskDispatcher = host.createTaskDispatcher();
|
|
19
|
-
host.orchestrationDispatcher = host.createOrchestrationDispatcher();
|
|
108
|
+
host.syncSessionsFromTopology();
|
|
20
109
|
host.defaultCommand = opts.command;
|
|
21
110
|
host.defaultArgs = opts.args;
|
|
22
111
|
const config = loadConfig();
|
|
@@ -30,11 +119,10 @@ export async function run(host, opts) {
|
|
|
30
119
|
}
|
|
31
120
|
export async function runDashboard(host) {
|
|
32
121
|
initProject();
|
|
33
|
-
await host.instanceDirectory.registerInstance(host.instanceId, process.cwd());
|
|
34
122
|
host.startHeartbeat();
|
|
35
123
|
host.startedInDashboard = true;
|
|
36
124
|
host.mode = "dashboard";
|
|
37
|
-
host.
|
|
125
|
+
host.syncSessionsFromTopology();
|
|
38
126
|
const config = loadConfig();
|
|
39
127
|
const defaultTool = config.tools[config.defaultTool];
|
|
40
128
|
if (defaultTool) {
|
|
@@ -130,9 +218,7 @@ export async function runDashboard(host) {
|
|
|
130
218
|
export async function runProjectService(host) {
|
|
131
219
|
initProject();
|
|
132
220
|
host.mode = "project-service";
|
|
133
|
-
host.
|
|
134
|
-
host.taskDispatcher = host.createTaskDispatcher();
|
|
135
|
-
host.orchestrationDispatcher = host.createOrchestrationDispatcher();
|
|
221
|
+
host.syncSessionsFromTopology();
|
|
136
222
|
host.writeInstructionFiles();
|
|
137
223
|
await host.startProjectServices();
|
|
138
224
|
host.startStatusRefresh();
|
|
@@ -146,60 +232,50 @@ export async function runProjectService(host) {
|
|
|
146
232
|
}
|
|
147
233
|
export async function resumeSessions(host, toolFilter) {
|
|
148
234
|
initProject();
|
|
149
|
-
await host.instanceDirectory.registerInstance(host.instanceId, process.cwd());
|
|
150
235
|
host.startHeartbeat();
|
|
151
|
-
|
|
152
|
-
|
|
236
|
+
reconcileLaunchableTopology(host);
|
|
237
|
+
const sessionsToResume = listLaunchableTopologySessions(toolFilter);
|
|
238
|
+
if (sessionsToResume.length === 0) {
|
|
153
239
|
console.error("No saved session state found (or state is stale). Starting fresh.");
|
|
154
240
|
return host.runDashboard();
|
|
155
241
|
}
|
|
156
242
|
const config = loadConfig();
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
:
|
|
160
|
-
|
|
161
|
-
console.error(`No saved sessions found for tool "${toolFilter}". Starting fresh.`);
|
|
162
|
-
return host.runDashboard();
|
|
163
|
-
}
|
|
164
|
-
const ownedByOthers = host.getRemoteOwnedSessionKeys();
|
|
243
|
+
log.info("resuming saved sessions", "session", {
|
|
244
|
+
requestedTool: toolFilter,
|
|
245
|
+
count: sessionsToResume.length,
|
|
246
|
+
});
|
|
165
247
|
for (const saved of sessionsToResume) {
|
|
166
|
-
|
|
167
|
-
debug(`skipping resume of ${saved.id} — owned by another instance`, "session");
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
248
|
+
const backendSessionId = saved.backendSessionId;
|
|
170
249
|
const toolCfg = config.tools[saved.toolConfigKey];
|
|
171
250
|
if (!toolCfg)
|
|
172
251
|
continue;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
resumeArgs = toolCfg.resumeArgs.map((a) => a.replace("{sessionId}", bsid));
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
resumeArgs = toolCfg.resumeFallback ?? [];
|
|
252
|
+
if (!backendSessionId || !host.sessionBootstrap.canResumeWithBackendSessionId(toolCfg, backendSessionId)) {
|
|
253
|
+
console.error(`Skipping saved session "${saved.id}" because "${saved.toolConfigKey}" has no exact resumable backend session id.`);
|
|
254
|
+
continue;
|
|
180
255
|
}
|
|
256
|
+
const resumeArgs = toolCfg.resumeArgs.map((a) => a.replace("{sessionId}", backendSessionId));
|
|
181
257
|
const args = host.sessionBootstrap.composeToolArgs(toolCfg, resumeArgs, saved.args);
|
|
182
|
-
|
|
183
|
-
|
|
258
|
+
log.info("resuming session", "session", {
|
|
259
|
+
sessionId: saved.id,
|
|
260
|
+
command: saved.command,
|
|
261
|
+
backendSessionId,
|
|
262
|
+
toolConfigKey: saved.toolConfigKey,
|
|
263
|
+
worktreePath: saved.worktreePath,
|
|
264
|
+
});
|
|
265
|
+
host.createSession(saved.command, args, toolCfg.preambleFlag, saved.toolConfigKey, undefined, undefined, saved.worktreePath, backendSessionId, saved.id, false, true, saved.team);
|
|
184
266
|
}
|
|
185
267
|
host.openTmuxDashboardTarget();
|
|
186
268
|
return 0;
|
|
187
269
|
}
|
|
188
270
|
export async function restoreSessions(host, toolFilter) {
|
|
189
271
|
initProject();
|
|
190
|
-
|
|
191
|
-
|
|
272
|
+
reconcileLaunchableTopology(host);
|
|
273
|
+
const sessionsToRestore = listLaunchableTopologySessions(toolFilter);
|
|
274
|
+
if (sessionsToRestore.length === 0) {
|
|
192
275
|
console.error("No saved session state found (or state is stale). Starting fresh.");
|
|
193
276
|
return host.runDashboard();
|
|
194
277
|
}
|
|
195
278
|
const config = loadConfig();
|
|
196
|
-
const sessionsToRestore = toolFilter
|
|
197
|
-
? state.sessions.filter((s) => s.tool === toolFilter || s.toolConfigKey === toolFilter)
|
|
198
|
-
: state.sessions;
|
|
199
|
-
if (sessionsToRestore.length === 0) {
|
|
200
|
-
console.error(`No saved sessions found for tool "${toolFilter}". Starting fresh.`);
|
|
201
|
-
return host.runDashboard();
|
|
202
|
-
}
|
|
203
279
|
for (const saved of sessionsToRestore) {
|
|
204
280
|
const toolCfg = config.tools[saved.toolConfigKey];
|
|
205
281
|
if (!toolCfg)
|
|
@@ -225,12 +301,12 @@ export async function restoreSessions(host, toolFilter) {
|
|
|
225
301
|
}
|
|
226
302
|
const liveContext = buildContextPreamble(sessionsToRestore.filter((s) => s.id !== saved.id).map((s) => s.id));
|
|
227
303
|
const extraPreamble = historyContext + (liveContext ? "\n" + liveContext : "");
|
|
228
|
-
host.createSession(saved.command, saved.args, toolCfg.preambleFlag, saved.toolConfigKey, extraPreamble.trim() || undefined, undefined, saved.worktreePath);
|
|
304
|
+
host.createSession(saved.command, saved.args, toolCfg.preambleFlag, saved.toolConfigKey, extraPreamble.trim() || undefined, undefined, saved.worktreePath, undefined, saved.id, false, false, saved.team);
|
|
229
305
|
}
|
|
230
306
|
host.openTmuxDashboardTarget();
|
|
231
307
|
return 0;
|
|
232
308
|
}
|
|
233
|
-
export function createSession(host, command, args, preambleFlag, toolConfigKey, extraPreamble, sessionIdFlag, worktreePath, backendSessionIdOverride, sessionIdOverride, detachedInTmux = false, suppressStartupPreamble = false) {
|
|
309
|
+
export function createSession(host, command, args, preambleFlag, toolConfigKey, extraPreamble, sessionIdFlag, worktreePath, backendSessionIdOverride, sessionIdOverride, detachedInTmux = false, suppressStartupPreamble = false, team) {
|
|
234
310
|
const cols = process.stdout.columns ?? 80;
|
|
235
311
|
const sessionId = sessionIdOverride ?? `${command}-${Math.random().toString(36).slice(2, 8)}`;
|
|
236
312
|
if (host.sessions.some((session) => session.id === sessionId)) {
|
|
@@ -240,9 +316,18 @@ export function createSession(host, command, args, preambleFlag, toolConfigKey,
|
|
|
240
316
|
const toolCfg = toolConfigKey ? config.tools[toolConfigKey] : undefined;
|
|
241
317
|
const isClaudeResumeStyleLaunch = Boolean(toolCfg && toolConfigKey === "claude" && toolCfg.command === command) &&
|
|
242
318
|
shouldSkipClaudeSessionIdInjection(args);
|
|
243
|
-
const
|
|
319
|
+
const explicitClaudeBackendSessionId = toolCfg && toolConfigKey === "claude" && toolCfg.command === command
|
|
320
|
+
? extractClaudeBackendSessionIdFromArgs(args)
|
|
321
|
+
: undefined;
|
|
322
|
+
const explicitCodexBackendSessionId = toolCfg && toolConfigKey === "codex" && toolCfg.command === command
|
|
323
|
+
? extractCodexBackendSessionIdFromArgs(args)
|
|
324
|
+
: undefined;
|
|
325
|
+
const effectiveSuppressStartupPreamble = suppressStartupPreamble;
|
|
244
326
|
const effectiveSessionIdFlag = isClaudeResumeStyleLaunch ? undefined : sessionIdFlag;
|
|
245
|
-
const backendSessionId = backendSessionIdOverride ??
|
|
327
|
+
const backendSessionId = backendSessionIdOverride ??
|
|
328
|
+
explicitClaudeBackendSessionId ??
|
|
329
|
+
explicitCodexBackendSessionId ??
|
|
330
|
+
(effectiveSessionIdFlag ? randomUUID() : undefined);
|
|
246
331
|
const automaticPreambleEnabled = config.runtime.agentPreambleEnabled !== false;
|
|
247
332
|
const preamble = effectiveSuppressStartupPreamble
|
|
248
333
|
? ""
|
|
@@ -252,10 +337,19 @@ export function createSession(host, command, args, preambleFlag, toolConfigKey,
|
|
|
252
337
|
worktreePath,
|
|
253
338
|
extraPreamble,
|
|
254
339
|
includeAimuxPreamble: automaticPreambleEnabled,
|
|
340
|
+
team,
|
|
255
341
|
});
|
|
256
342
|
const shouldInjectLaunchPreamble = Boolean(!effectiveSuppressStartupPreamble && preambleFlag && preamble.trim());
|
|
343
|
+
const shouldInjectCodexDeveloperInstructions = Boolean(!effectiveSuppressStartupPreamble &&
|
|
344
|
+
toolCfg?.command === command &&
|
|
345
|
+
command === "codex" &&
|
|
346
|
+
toolCfg.developerInstructionsConfigKey &&
|
|
347
|
+
preamble.trim());
|
|
257
348
|
host.sessionBootstrap.ensurePlanFile(sessionId, command, worktreePath);
|
|
258
349
|
let finalArgs = shouldInjectLaunchPreamble ? [...args, ...preambleFlag, preamble] : [...args];
|
|
350
|
+
if (shouldInjectCodexDeveloperInstructions) {
|
|
351
|
+
finalArgs = injectCodexDeveloperInstructions(finalArgs, toolCfg.developerInstructionsConfigKey, preamble);
|
|
352
|
+
}
|
|
259
353
|
let launchCommand = command;
|
|
260
354
|
if (effectiveSessionIdFlag && backendSessionId) {
|
|
261
355
|
const expandedFlag = effectiveSessionIdFlag.map((a) => a.replace("{sessionId}", backendSessionId));
|
|
@@ -268,6 +362,8 @@ export function createSession(host, command, args, preambleFlag, toolConfigKey,
|
|
|
268
362
|
catch {
|
|
269
363
|
projectRoot = process.cwd();
|
|
270
364
|
}
|
|
365
|
+
clearSessionTranscriptPath(sessionId);
|
|
366
|
+
clearSessionTranscriptPath(sessionId, projectRoot);
|
|
271
367
|
if (toolCfg && toolConfigKey === "claude" && toolCfg.command === command && toolCfg.wrapperEnabled !== false) {
|
|
272
368
|
finalArgs = injectClaudeHookArgs(finalArgs, {
|
|
273
369
|
sessionId,
|
|
@@ -301,18 +397,19 @@ export function createSession(host, command, args, preambleFlag, toolConfigKey,
|
|
|
301
397
|
host.sessionBootstrap.finalizePreamble(command, preamble);
|
|
302
398
|
}
|
|
303
399
|
debug(`creating session: ${command} (configKey=${toolConfigKey ?? "cli"}, backendId=${backendSessionId ?? "none"}, cwd=${worktreePath ?? process.cwd()}, args=${finalArgs.length})`, "session");
|
|
304
|
-
debug(`spawn args: ${JSON.stringify(finalArgs
|
|
400
|
+
debug(`spawn args: ${JSON.stringify(summarizeLaunchArgs(finalArgs))}`, "session");
|
|
305
401
|
const sessionStartTime = Date.now();
|
|
306
402
|
const tmuxSession = host.tmuxRuntimeManager.ensureProjectSession(process.cwd());
|
|
307
403
|
const target = host.tmuxRuntimeManager.createWindow(tmuxSession.sessionName, host.getSessionLabel(sessionId) ?? command, worktreePath ?? process.cwd(), launchCommand, finalArgs, { detached: detachedInTmux });
|
|
308
404
|
const tmuxTransport = new TmuxSessionTransport(sessionId, command, target, host.tmuxRuntimeManager, cols, process.stdout.rows ?? 24);
|
|
309
405
|
host.sessionTmuxTargets.set(sessionId, target);
|
|
310
406
|
const session = tmuxTransport;
|
|
311
|
-
host.registerManagedSession(tmuxTransport, args, toolConfigKey, worktreePath, undefined, sessionStartTime);
|
|
407
|
+
host.registerManagedSession(tmuxTransport, args, toolConfigKey, worktreePath, undefined, sessionStartTime, team);
|
|
312
408
|
session.backendSessionId = backendSessionId;
|
|
313
409
|
if (session instanceof TmuxSessionTransport) {
|
|
314
410
|
host.syncTmuxWindowMetadata(sessionId);
|
|
315
411
|
}
|
|
412
|
+
void projectRoot;
|
|
316
413
|
host.activeIndex = host.sessions.length - 1;
|
|
317
414
|
if (host.startedInDashboard && host.mode === "dashboard") {
|
|
318
415
|
host.invalidateDesktopStateSnapshot();
|
|
@@ -322,14 +419,6 @@ export function createSession(host, command, args, preambleFlag, toolConfigKey,
|
|
|
322
419
|
host.renderDashboard();
|
|
323
420
|
}
|
|
324
421
|
host.saveState();
|
|
325
|
-
if (!effectiveSuppressStartupPreamble &&
|
|
326
|
-
!preambleFlag &&
|
|
327
|
-
!extraPreamble &&
|
|
328
|
-
automaticPreambleEnabled &&
|
|
329
|
-
preamble.trim()) {
|
|
330
|
-
const kickoff = host.sessionBootstrap.buildInitialKickoffPrompt(sessionId, preamble);
|
|
331
|
-
void host.sessionBootstrap.deliverDetachedCodexKickoffPrompt(sessionId, kickoff, 1800);
|
|
332
|
-
}
|
|
333
422
|
return session;
|
|
334
423
|
}
|
|
335
424
|
export async function migrateAgent(host, sessionId, targetWorktreePath) {
|
|
@@ -382,12 +471,11 @@ export async function migrateAgent(host, sessionId, targetWorktreePath) {
|
|
|
382
471
|
session.kill();
|
|
383
472
|
await waitForExit().catch(() => { });
|
|
384
473
|
if (!toolCfg?.preambleFlag) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
await host.sessionBootstrap.deliverDetachedCodexKickoffPrompt(sessionId, kickoff, 1800);
|
|
474
|
+
const continuityPreamble = host.sessionBootstrap.buildCodexMigrationContinuityPreamble(sessionId, sourceCwd, targetWorktreePath, sourceSnapshot);
|
|
475
|
+
createSession(host, session.command, migrateArgs, undefined, toolConfigKey, continuityPreamble, undefined, effectiveTarget, useBackendResume ? backendSessionId : undefined, sessionId, true, false, session.team);
|
|
388
476
|
return;
|
|
389
477
|
}
|
|
390
|
-
createSession(host, session.command, migrateArgs, useBackendResume ? undefined : toolCfg?.preambleFlag, toolConfigKey, historyContext.trim() || undefined, useBackendResume ? undefined : toolCfg?.sessionIdFlag, effectiveTarget, backendSessionId, sessionId);
|
|
478
|
+
createSession(host, session.command, migrateArgs, useBackendResume ? undefined : toolCfg?.preambleFlag, toolConfigKey, historyContext.trim() || undefined, useBackendResume ? undefined : toolCfg?.sessionIdFlag, effectiveTarget, useBackendResume ? backendSessionId : undefined, sessionId, false, false, session.team);
|
|
391
479
|
}
|
|
392
480
|
export function getSessionWorktreePath(host, sessionId) {
|
|
393
481
|
return host.sessionWorktreePaths.get(sessionId);
|
|
@@ -415,6 +503,7 @@ export function focusSession(host, index) {
|
|
|
415
503
|
host.agentTracker.markSeen(sid);
|
|
416
504
|
updateNotificationContext("tui", {
|
|
417
505
|
focused: true,
|
|
506
|
+
screen: "agent",
|
|
418
507
|
sessionId: sid,
|
|
419
508
|
panelOpen: false,
|
|
420
509
|
});
|
|
@@ -497,8 +586,7 @@ export function handleAction(host, action) {
|
|
|
497
586
|
host.showWorktreeList();
|
|
498
587
|
break;
|
|
499
588
|
case "review":
|
|
500
|
-
host.handleReviewRequest();
|
|
589
|
+
void host.handleReviewRequest();
|
|
501
590
|
break;
|
|
502
591
|
}
|
|
503
592
|
}
|
|
504
|
-
//# sourceMappingURL=session-launch.js.map
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readSessionMessages } from "../session-message-history.js";
|
|
3
|
-
import { type SessionInputOperationRecord } from "../session-input-operations.js";
|
|
1
|
+
import type { SessionTeamMetadata } from "../team.js";
|
|
4
2
|
type SessionRuntimeHost = any;
|
|
5
3
|
export declare function getSessionLabel(host: SessionRuntimeHost, sessionId: string): string | undefined;
|
|
6
4
|
export declare function applySessionLabel(host: SessionRuntimeHost, sessionId: string, label?: string): void;
|
|
@@ -10,24 +8,12 @@ export declare function readStatusHeadline(_host: SessionRuntimeHost, sessionId:
|
|
|
10
8
|
export declare function deriveHeadline(host: SessionRuntimeHost, sessionId: string): string | undefined;
|
|
11
9
|
export declare function resolveRunningSession(host: SessionRuntimeHost, sessionId: string): any;
|
|
12
10
|
export declare function resolveLiveSessionTmuxTarget(host: SessionRuntimeHost, sessionId: string, fallback?: any): any;
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function normalizeAgentInput(host: SessionRuntimeHost, data: string, submit: boolean, sessionId?: string): string;
|
|
15
|
-
export declare function paneStillContainsAgentDraft(host: SessionRuntimeHost, target: any, draft: string): boolean;
|
|
16
|
-
export declare function scheduleTmuxAgentSubmit(host: SessionRuntimeHost, sessionId: string, target: any, draft: string): void;
|
|
17
|
-
export declare function writeAgentInput(host: SessionRuntimeHost, sessionId: string, data?: string, parts?: any[], clientMessageId?: string, submit?: boolean): Promise<{
|
|
18
|
-
sessionId: string;
|
|
19
|
-
accepted: boolean;
|
|
20
|
-
operation: SessionInputOperationRecord;
|
|
21
|
-
messageId?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
}>;
|
|
24
|
-
export declare function readAgentHistory(host: SessionRuntimeHost, sessionId: string, lastN?: number): Promise<{
|
|
11
|
+
export declare function interruptAgent(host: SessionRuntimeHost, sessionId: string): Promise<{
|
|
25
12
|
sessionId: string;
|
|
26
|
-
messages: ReturnType<typeof readSessionMessages>;
|
|
27
|
-
lastN?: number;
|
|
28
13
|
}>;
|
|
29
|
-
export declare function
|
|
14
|
+
export declare function sendAgentInput(host: SessionRuntimeHost, sessionId: string, text: string): Promise<{
|
|
30
15
|
sessionId: string;
|
|
16
|
+
accepted: true;
|
|
31
17
|
}>;
|
|
32
18
|
export declare function readAgentOutput(host: SessionRuntimeHost, sessionId: string, startLine?: number): Promise<{
|
|
33
19
|
sessionId: string;
|
|
@@ -35,9 +21,11 @@ export declare function readAgentOutput(host: SessionRuntimeHost, sessionId: str
|
|
|
35
21
|
startLine?: number;
|
|
36
22
|
parsed: any;
|
|
37
23
|
}>;
|
|
38
|
-
export declare function registerManagedSession(host: SessionRuntimeHost, session: any, args: string[], toolConfigKey?: string, worktreePath?: string, role?: string, startTime?: number): any;
|
|
24
|
+
export declare function registerManagedSession(host: SessionRuntimeHost, session: any, args: string[], toolConfigKey?: string, worktreePath?: string, role?: string, startTime?: number, team?: SessionTeamMetadata): any;
|
|
39
25
|
export declare function handleSessionRuntimeEvent(host: SessionRuntimeHost, runtime: any, event: any): void;
|
|
40
|
-
export declare function buildTmuxWindowMetadata(host: SessionRuntimeHost, sessionId: string, command: string
|
|
26
|
+
export declare function buildTmuxWindowMetadata(host: SessionRuntimeHost, sessionId: string, command: string, existing?: {
|
|
27
|
+
team?: SessionTeamMetadata;
|
|
28
|
+
} | null): any;
|
|
41
29
|
export declare function syncTmuxWindowMetadata(host: SessionRuntimeHost, sessionId: string): void;
|
|
42
30
|
export declare function updateContextWatcherSessions(host: SessionRuntimeHost): void;
|
|
43
31
|
export {};
|