tmux-ide 2.9.20 → 2.9.22
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/bin/cli.js +16998 -4283
- package/package.json +3 -2
- package/packages/contracts/src/command-catalog.ts +116 -0
- package/packages/contracts/src/commands.ts +5 -4
- package/packages/contracts/src/daemon-events.ts +2 -1
- package/packages/contracts/src/index.ts +3 -0
- package/packages/contracts/src/pane-reader.ts +121 -0
- package/packages/contracts/src/pane-stream.ts +18 -0
- package/packages/contracts/src/plain-text.ts +61 -0
- package/packages/contracts/src/visual-theme-presets.ts +58 -2
- package/packages/daemon/dist/command-center/command-catalog-routes.js +78 -0
- package/packages/daemon/dist/command-center/plugin-routes.js +84 -0
- package/packages/daemon/dist/command-center/server.js +13 -0
- package/packages/daemon/dist/command-center/tmux-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +6 -0
- package/packages/daemon/dist/doctor.js +106 -43
- package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +39 -1
- package/packages/daemon/dist/lib/headless-daemon.js +1 -0
- package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
- package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
- package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
- package/packages/daemon/dist/lib/tmux-pane-reader.js +105 -0
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +9 -0
- package/packages/daemon/dist/lib/worktree.js +18 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/open-browser.js +26 -12
- package/packages/daemon/dist/open-reader.js +84 -0
- package/packages/daemon/dist/plugins/action-catalog.js +129 -0
- package/packages/daemon/dist/plugins/action-cli.js +212 -0
- package/packages/daemon/dist/plugins/api-table.js +303 -0
- package/packages/daemon/dist/plugins/cli.js +556 -0
- package/packages/daemon/dist/plugins/consent.js +107 -0
- package/packages/daemon/dist/plugins/daemon-plugins.js +124 -0
- package/packages/daemon/dist/plugins/discovery.js +142 -0
- package/packages/daemon/dist/plugins/examples/worktree-tasks.js +115 -0
- package/packages/daemon/dist/plugins/exec-sandbox.js +202 -0
- package/packages/daemon/dist/plugins/host/actions-prelude.js +279 -0
- package/packages/daemon/dist/plugins/host/entry.js +4 -0
- package/packages/daemon/dist/plugins/host/host-api-prelude.js +232 -0
- package/packages/daemon/dist/plugins/host/lua-state.js +493 -0
- package/packages/daemon/dist/plugins/host/main.js +322 -0
- package/packages/daemon/dist/plugins/host/sandbox.js +299 -0
- package/packages/daemon/dist/plugins/host-calls.js +279 -0
- package/packages/daemon/dist/plugins/manifest.js +69 -0
- package/packages/daemon/dist/plugins/plugin-exec.js +261 -0
- package/packages/daemon/dist/plugins/plugin-log.js +54 -0
- package/packages/daemon/dist/plugins/plugin-store.js +74 -0
- package/packages/daemon/dist/plugins/protocol.js +252 -0
- package/packages/daemon/dist/plugins/safe-files.js +97 -0
- package/packages/daemon/dist/plugins/supervisor.js +790 -0
- package/packages/daemon/dist/plugins/worktree-calls.js +154 -0
- package/packages/daemon/dist/restore.js +57 -40
- package/packages/daemon/dist/terminal/mirror/session-channel.js +4 -1
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +12 -3
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +7 -2
- package/packages/daemon/dist/tmux-upgrade/cli.js +106 -0
- package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
- package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
- package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +62 -5
- package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
- package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +30 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-plugin-commands.js +152 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-plugin-form.js +251 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
- package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +14 -0
- package/packages/daemon/dist/tui/mirror/workspace/palette-list-layout.js +5 -0
- package/packages/daemon/src/command-center/command-catalog-routes.ts +116 -0
- package/packages/daemon/src/command-center/plugin-routes.ts +110 -0
- package/packages/daemon/src/command-center/server.ts +15 -0
- package/packages/daemon/src/command-center/tmux-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +6 -0
- package/packages/daemon/src/doctor.ts +118 -45
- package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +59 -0
- package/packages/daemon/src/lib/headless-daemon.ts +1 -0
- package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
- package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
- package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
- package/packages/daemon/src/lib/tmux-pane-reader.ts +144 -0
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +9 -0
- package/packages/daemon/src/lib/worktree.ts +16 -0
- package/packages/daemon/src/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/action-catalog.ts +141 -0
- package/packages/daemon/src/plugins/action-cli.ts +248 -0
- package/packages/daemon/src/plugins/api-table.ts +346 -0
- package/packages/daemon/src/plugins/cli.ts +630 -0
- package/packages/daemon/src/plugins/consent.ts +125 -0
- package/packages/daemon/src/plugins/daemon-plugins.ts +172 -0
- package/packages/daemon/src/plugins/discovery.ts +176 -0
- package/packages/daemon/src/plugins/examples/worktree-tasks.ts +120 -0
- package/packages/daemon/src/plugins/exec-sandbox.ts +264 -0
- package/packages/daemon/src/plugins/host/actions-prelude.ts +280 -0
- package/packages/daemon/src/plugins/host/entry.ts +5 -0
- package/packages/daemon/src/plugins/host/host-api-prelude.ts +233 -0
- package/packages/daemon/src/plugins/host/lua-state.ts +557 -0
- package/packages/daemon/src/plugins/host/main.ts +359 -0
- package/packages/daemon/src/plugins/host/sandbox.ts +301 -0
- package/packages/daemon/src/plugins/host-calls.ts +343 -0
- package/packages/daemon/src/plugins/manifest.ts +74 -0
- package/packages/daemon/src/plugins/plugin-exec.ts +326 -0
- package/packages/daemon/src/plugins/plugin-log.ts +63 -0
- package/packages/daemon/src/plugins/plugin-store.ts +80 -0
- package/packages/daemon/src/plugins/protocol.ts +275 -0
- package/packages/daemon/src/plugins/safe-files.ts +105 -0
- package/packages/daemon/src/plugins/supervisor.ts +954 -0
- package/packages/daemon/src/plugins/worktree-calls.ts +183 -0
- package/packages/daemon/src/restore.ts +80 -44
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +6 -1
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +15 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
- package/packages/daemon/src/tmux-upgrade/cli.ts +118 -0
- package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
- package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
- package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
- package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
- package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +90 -6
- package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
- package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +42 -2
- package/packages/daemon/src/tui/mirror/runtime/application-palette-preview.tsx +7 -1
- package/packages/daemon/src/tui/mirror/runtime/application-plugin-commands.ts +229 -0
- package/packages/daemon/src/tui/mirror/runtime/application-plugin-form.ts +312 -0
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
- package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +44 -2
- package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
- package/packages/tmux-bridge/src/runner.ts +3 -1
package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js
CHANGED
|
@@ -525,88 +525,110 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
525
525
|
return;
|
|
526
526
|
finishLinkSelection(snapshot.current !== null && paneForWindow(snapshot.current) === pending.paneId);
|
|
527
527
|
};
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const active = selectionGeneration;
|
|
544
|
-
if (active?.status !== "live" || observedLayoutEpoch !== active.rendererEpoch)
|
|
545
|
-
return "pending";
|
|
546
|
-
return panePresent();
|
|
547
|
-
});
|
|
548
|
-
if (!ready || !selectionCurrent())
|
|
528
|
+
// The one way a pane selection reaches the runtime (#764: also used once an
|
|
529
|
+
// admitted agent selection settles).
|
|
530
|
+
const selectInRuntime = async (paneId) => {
|
|
531
|
+
finishLinkSelection(false);
|
|
532
|
+
const initial = options.generation();
|
|
533
|
+
const selectionControl = controlIdentity(initial);
|
|
534
|
+
const selectionVersion = paneInput.selectionVersion;
|
|
535
|
+
const selectionCurrent = () => paneInput.selectionVersion === selectionVersion &&
|
|
536
|
+
sameControl(selectionControl, controlIdentity(selectionGeneration));
|
|
537
|
+
const panePresent = () => selectionLayout.windows.some((window) => window.panes.some((pane) => pane.pane === paneId));
|
|
538
|
+
if (initial?.status === "rebinding") {
|
|
539
|
+
// Reserve the optimistic target now, but send its FIRST mutation only
|
|
540
|
+
// after this same control connection has a coherent terminal runtime.
|
|
541
|
+
const ready = await selectionWaiter.wait(() => {
|
|
542
|
+
if (!selectionCurrent())
|
|
549
543
|
return false;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
return
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
544
|
+
const active = selectionGeneration;
|
|
545
|
+
if (active?.status !== "live" || observedLayoutEpoch !== active.rendererEpoch)
|
|
546
|
+
return "pending";
|
|
547
|
+
return panePresent();
|
|
548
|
+
});
|
|
549
|
+
if (!ready || !selectionCurrent())
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
const expected = liveSelectionTarget();
|
|
553
|
+
let dispatchedRendererEpoch;
|
|
554
|
+
const selecting = pendingWindowSwitch;
|
|
555
|
+
const operationId = selecting?.traceId;
|
|
556
|
+
const selectionFailure = { current: null };
|
|
557
|
+
const receipt = expected
|
|
558
|
+
? await selectTerminalPane(expected, () => {
|
|
559
|
+
if (!selectionControl)
|
|
560
|
+
return liveSelectionTarget();
|
|
561
|
+
return sameControl(selectionControl, controlIdentity(options.generation()))
|
|
562
|
+
? expected
|
|
563
|
+
: null;
|
|
564
|
+
}, paneId, operationId, (failure) => {
|
|
565
|
+
selectionFailure.current = failure;
|
|
566
|
+
}, windowLinkForPane(options.layout(), paneId) ?? undefined, () => {
|
|
567
|
+
dispatchedRendererEpoch = options.generation()?.rendererEpoch;
|
|
568
|
+
})
|
|
569
|
+
: null;
|
|
570
|
+
if (receipt === null &&
|
|
571
|
+
selectionFailure.current?.reason === "topology-changed" &&
|
|
572
|
+
selectionCurrent()) {
|
|
573
|
+
// The daemon may have selected the pane before retiring its stream.
|
|
574
|
+
// Observe the replacement runtime; never resubmit an uncertain command
|
|
575
|
+
// or manufacture an operation receipt. Input still waits on this promise.
|
|
576
|
+
const confirmed = await selectionWaiter.wait(() => {
|
|
577
|
+
if (!selectionCurrent())
|
|
578
|
+
return false;
|
|
579
|
+
const active = selectionGeneration;
|
|
580
|
+
if (active?.status !== "live" ||
|
|
581
|
+
active.rendererEpoch === dispatchedRendererEpoch ||
|
|
582
|
+
observedLayoutEpoch !== active.rendererEpoch)
|
|
583
|
+
return "pending";
|
|
584
|
+
if (!panePresent())
|
|
585
|
+
return false;
|
|
586
|
+
const current = selectionLayout.current;
|
|
587
|
+
const activePanes = current?.panes.filter((pane) => pane.active) ?? [];
|
|
588
|
+
if (!current?.currentWindow || activePanes.length !== 1)
|
|
589
|
+
return "pending";
|
|
590
|
+
return activePanes[0]?.pane === paneId ? true : "pending";
|
|
591
|
+
});
|
|
592
|
+
if (selecting && pendingWindowSwitch === selecting)
|
|
593
|
+
pendingWindowSwitch = null;
|
|
594
|
+
return confirmed && selectionCurrent();
|
|
595
|
+
}
|
|
596
|
+
if (selecting && pendingWindowSwitch === selecting) {
|
|
597
|
+
const receiptAtMicros = options.detailedWindowSwitchTiming ? diagnosticNowMicros() : null;
|
|
598
|
+
if (selecting.timing)
|
|
599
|
+
selecting.timing.receiptAtMicros = receiptAtMicros;
|
|
600
|
+
selecting.selectionApplied =
|
|
601
|
+
receipt?.applied === true &&
|
|
602
|
+
receipt.operationId === selecting.traceId &&
|
|
603
|
+
receipt.semanticPaneId === selecting.paneId;
|
|
604
|
+
diagnose("window-switch-receipt", {
|
|
605
|
+
traceId: selecting.traceId,
|
|
606
|
+
target: selecting.target,
|
|
607
|
+
paneId: selecting.paneId,
|
|
608
|
+
operationId: receipt?.operationId ?? null,
|
|
609
|
+
selected: receipt !== null,
|
|
610
|
+
applied: receipt?.applied === true,
|
|
611
|
+
daemonGeneration: selecting.daemonGeneration,
|
|
612
|
+
clientGeneration: selecting.clientGeneration,
|
|
613
|
+
rendererEpoch: selecting.rendererEpoch,
|
|
614
|
+
sourceEpoch: selecting.sourceEpoch,
|
|
615
|
+
generation: selecting.generation,
|
|
616
|
+
incarnation: selecting.incarnation,
|
|
617
|
+
revision: selecting.revision,
|
|
618
|
+
stateHash: selecting.stateHash,
|
|
619
|
+
cols: selecting.cols,
|
|
620
|
+
rows: selecting.rows,
|
|
621
|
+
failureStage: selectionFailure.current?.stage ?? (expected ? null : "pre-dispatch"),
|
|
622
|
+
failureReason: selectionFailure.current?.reason ?? (expected ? null : "generation-replaced"),
|
|
623
|
+
failureBackendReason: selectionFailure.current?.backendReason ?? null,
|
|
624
|
+
durationMicros: receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
|
|
625
|
+
...(receiptAtMicros === null ? {} : { phaseAtMicros: receiptAtMicros }),
|
|
626
|
+
});
|
|
627
|
+
if (!selecting.selectionApplied) {
|
|
628
|
+
diagnoseCritical(`window-switch:${selecting.traceId}:failed`, "window-switch-failed", {
|
|
604
629
|
traceId: selecting.traceId,
|
|
605
630
|
target: selecting.target,
|
|
606
631
|
paneId: selecting.paneId,
|
|
607
|
-
operationId: receipt?.operationId ?? null,
|
|
608
|
-
selected: receipt !== null,
|
|
609
|
-
applied: receipt?.applied === true,
|
|
610
632
|
daemonGeneration: selecting.daemonGeneration,
|
|
611
633
|
clientGeneration: selecting.clientGeneration,
|
|
612
634
|
rendererEpoch: selecting.rendererEpoch,
|
|
@@ -617,40 +639,21 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
617
639
|
stateHash: selecting.stateHash,
|
|
618
640
|
cols: selecting.cols,
|
|
619
641
|
rows: selecting.rows,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
642
|
+
stage: selectionFailure.current?.stage ?? (expected ? "receipt" : "pre-dispatch"),
|
|
643
|
+
reason: selectionFailure.current?.reason ??
|
|
644
|
+
(expected ? "receipt-invalid" : "generation-replaced"),
|
|
645
|
+
backendReason: selectionFailure.current?.backendReason ?? null,
|
|
623
646
|
durationMicros: receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
|
|
624
|
-
...(receiptAtMicros === null ? {} : { phaseAtMicros: receiptAtMicros }),
|
|
625
647
|
});
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
traceId: selecting.traceId,
|
|
629
|
-
target: selecting.target,
|
|
630
|
-
paneId: selecting.paneId,
|
|
631
|
-
daemonGeneration: selecting.daemonGeneration,
|
|
632
|
-
clientGeneration: selecting.clientGeneration,
|
|
633
|
-
rendererEpoch: selecting.rendererEpoch,
|
|
634
|
-
sourceEpoch: selecting.sourceEpoch,
|
|
635
|
-
generation: selecting.generation,
|
|
636
|
-
incarnation: selecting.incarnation,
|
|
637
|
-
revision: selecting.revision,
|
|
638
|
-
stateHash: selecting.stateHash,
|
|
639
|
-
cols: selecting.cols,
|
|
640
|
-
rows: selecting.rows,
|
|
641
|
-
stage: selectionFailure.current?.stage ?? (expected ? "receipt" : "pre-dispatch"),
|
|
642
|
-
reason: selectionFailure.current?.reason ??
|
|
643
|
-
(expected ? "receipt-invalid" : "generation-replaced"),
|
|
644
|
-
backendReason: selectionFailure.current?.backendReason ?? null,
|
|
645
|
-
durationMicros: receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
|
|
646
|
-
});
|
|
647
|
-
pendingWindowSwitch = null;
|
|
648
|
-
return false;
|
|
649
|
-
}
|
|
650
|
-
maybeRequestWindowSwitchFrame();
|
|
648
|
+
pendingWindowSwitch = null;
|
|
649
|
+
return false;
|
|
651
650
|
}
|
|
652
|
-
|
|
653
|
-
}
|
|
651
|
+
maybeRequestWindowSwitchFrame();
|
|
652
|
+
}
|
|
653
|
+
return receipt !== null;
|
|
654
|
+
};
|
|
655
|
+
const paneInput = new TerminalPaneInputRouter({
|
|
656
|
+
select: (paneId) => selectInRuntime(paneId),
|
|
654
657
|
send: async (paneId, routed) => {
|
|
655
658
|
const { input, parserOrigin } = routed;
|
|
656
659
|
const selectionVersion = paneInput.selectionVersion;
|
|
@@ -913,9 +916,20 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
913
916
|
maybeRequestWindowSwitchFrame();
|
|
914
917
|
maybeRequestPaneResizeFrame();
|
|
915
918
|
},
|
|
916
|
-
selectPane: (paneId) => {
|
|
919
|
+
selectPane: (paneId, admission) => {
|
|
917
920
|
finishLinkSelection(false);
|
|
918
|
-
|
|
921
|
+
if (admission)
|
|
922
|
+
// Ordered now; selected only once admitted, otherwise held input drops.
|
|
923
|
+
paneInput.selectPane(paneId, {
|
|
924
|
+
presentOptimistically: false,
|
|
925
|
+
selection: () => {
|
|
926
|
+
// A later selection supersedes this one: never select it after all.
|
|
927
|
+
const version = paneInput.selectionVersion;
|
|
928
|
+
return admission.then((admitted) => admitted && paneInput.selectionVersion === version ? selectInRuntime(paneId) : false);
|
|
929
|
+
},
|
|
930
|
+
});
|
|
931
|
+
else
|
|
932
|
+
paneInput.selectPane(paneId);
|
|
919
933
|
selectionWaiter.reconcile();
|
|
920
934
|
},
|
|
921
935
|
async unlinkWindowLink(target) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CHROME_ACTIONS } from "./application-action-descriptions.js";
|
|
2
|
+
import { terminalSafe } from "@tmux-ide/contracts";
|
|
2
3
|
import { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.js";
|
|
3
4
|
export { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.js";
|
|
4
5
|
import { PANE_ACTION_MENU_ITEMS } from "./pane-action-menu-model.js";
|
|
@@ -32,6 +33,19 @@ export function applicationCommandDescription(command) {
|
|
|
32
33
|
};
|
|
33
34
|
if (command === "shortcuts" || command === "whats-new")
|
|
34
35
|
return { id: command, ...PALETTE_REFERENCE_COMMANDS[command], detail: "Help and reference" };
|
|
36
|
+
if (typeof command === "object" && command.kind === "plugin-command")
|
|
37
|
+
return {
|
|
38
|
+
id: JSON.stringify([command.kind, command.id]),
|
|
39
|
+
// Plugin text: plain text only, even if something upstream let it through.
|
|
40
|
+
label: terminalSafe(command.params.length > 0 || command.dangerous ? `${command.label}…` : command.label, 200),
|
|
41
|
+
detail: terminalSafe(`${command.category} · ${command.plugin} plugin`, 200),
|
|
42
|
+
};
|
|
43
|
+
if (typeof command === "object" && command.kind === "plugin-form")
|
|
44
|
+
return {
|
|
45
|
+
id: JSON.stringify([command.kind, command.key]),
|
|
46
|
+
label: terminalSafe(command.label, 200),
|
|
47
|
+
detail: terminalSafe(command.detail, 500),
|
|
48
|
+
};
|
|
35
49
|
if (typeof command === "object" && command.kind === "open-machine")
|
|
36
50
|
return {
|
|
37
51
|
id: JSON.stringify([
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { terminalSafe } from "@tmux-ide/contracts";
|
|
1
2
|
export function paletteSection(command) {
|
|
2
3
|
if (command === "switch-session")
|
|
3
4
|
return "Sessions";
|
|
5
|
+
if (typeof command === "object" && command.kind === "plugin-command")
|
|
6
|
+
return terminalSafe(command.category, 80);
|
|
7
|
+
if (typeof command === "object" && command.kind === "plugin-form")
|
|
8
|
+
return "Choose";
|
|
4
9
|
if (typeof command === "object")
|
|
5
10
|
return command.kind === "jump-agent"
|
|
6
11
|
? "Agents"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command catalog and plugin action invocation, owner-only and never for
|
|
3
|
+
* browsers (the same gate as the plugin routes):
|
|
4
|
+
* GET /api/resources/command-catalog built-in and plugin commands
|
|
5
|
+
* POST /api/v2/commands/invoke run a plugin action
|
|
6
|
+
* POST /api/v2/commands/param-options one parameter's choices and default
|
|
7
|
+
*
|
|
8
|
+
* Built-in actions keep their own typed route, `/api/v2/action/:name`; the
|
|
9
|
+
* catalog lists them so the CLI and palettes see one list.
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
COMMAND_CATALOG_VERSION,
|
|
13
|
+
CommandInvokeRequestSchemaZ,
|
|
14
|
+
CommandParamOptionsRequestSchemaZ,
|
|
15
|
+
type CommandCatalogEntry,
|
|
16
|
+
type CommandCatalogResource,
|
|
17
|
+
type CommandDescriptor,
|
|
18
|
+
type CommandInvocationContext,
|
|
19
|
+
type CommandInvokeResult,
|
|
20
|
+
type CommandParamOptionsResult,
|
|
21
|
+
} from "@tmux-ide/contracts";
|
|
22
|
+
import type { Hono } from "hono";
|
|
23
|
+
import { bodyLimit } from "hono/body-limit";
|
|
24
|
+
import { ownerOnlyNonBrowserGuard } from "./plugin-routes.ts";
|
|
25
|
+
|
|
26
|
+
export interface CommandCatalogBackend {
|
|
27
|
+
actionCatalog(): { revision: number; entries: CommandCatalogEntry[] };
|
|
28
|
+
invokeAction(
|
|
29
|
+
id: string,
|
|
30
|
+
args: Record<string, string | number | boolean>,
|
|
31
|
+
context: CommandInvocationContext,
|
|
32
|
+
options: { confirmed?: boolean },
|
|
33
|
+
): Promise<CommandInvokeResult>;
|
|
34
|
+
actionParamOptions(
|
|
35
|
+
id: string,
|
|
36
|
+
param: string,
|
|
37
|
+
context: CommandInvocationContext,
|
|
38
|
+
): Promise<CommandParamOptionsResult>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function buildCommandCatalog(
|
|
42
|
+
builtins: readonly CommandDescriptor[],
|
|
43
|
+
plugins: CommandCatalogBackend | null,
|
|
44
|
+
): CommandCatalogResource {
|
|
45
|
+
const pluginCatalog = plugins?.actionCatalog() ?? { revision: 0, entries: [] };
|
|
46
|
+
return {
|
|
47
|
+
version: COMMAND_CATALOG_VERSION,
|
|
48
|
+
revision: pluginCatalog.revision,
|
|
49
|
+
entries: [
|
|
50
|
+
...builtins.map((descriptor) => ({ descriptor, params: [] })),
|
|
51
|
+
...pluginCatalog.entries,
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function mountCommandCatalogRoutes(
|
|
57
|
+
app: Hono,
|
|
58
|
+
options: {
|
|
59
|
+
ownerToken: string | null;
|
|
60
|
+
builtins: () => readonly CommandDescriptor[];
|
|
61
|
+
backend: CommandCatalogBackend | null;
|
|
62
|
+
},
|
|
63
|
+
): void {
|
|
64
|
+
const guard = ownerOnlyNonBrowserGuard(options.ownerToken);
|
|
65
|
+
|
|
66
|
+
app.get("/api/resources/command-catalog", (c) => {
|
|
67
|
+
const gate = guard(c);
|
|
68
|
+
if (gate) return gate;
|
|
69
|
+
c.header("Cache-Control", "no-store");
|
|
70
|
+
return c.json(buildCommandCatalog(options.builtins(), options.backend));
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
app.post("/api/v2/commands/invoke", bodyLimit({ maxSize: 256 * 1024 }), async (c) => {
|
|
74
|
+
const gate = guard(c);
|
|
75
|
+
if (gate) return gate;
|
|
76
|
+
c.header("Cache-Control", "no-store");
|
|
77
|
+
let body: unknown;
|
|
78
|
+
try {
|
|
79
|
+
body = await c.req.json();
|
|
80
|
+
} catch {
|
|
81
|
+
return c.json({ error: "Invalid invoke request" }, 400);
|
|
82
|
+
}
|
|
83
|
+
const parsed = CommandInvokeRequestSchemaZ.safeParse(body);
|
|
84
|
+
if (!parsed.success) return c.json({ error: "Invalid invoke request" }, 400);
|
|
85
|
+
if (!parsed.data.id.startsWith("plugin."))
|
|
86
|
+
return c.json({ error: "Built-in commands use /api/v2/action/:name" }, 404);
|
|
87
|
+
if (!options.backend) return c.json({ error: "Plugins are not enabled in this daemon" }, 503);
|
|
88
|
+
const { id, args, context, confirmed } = parsed.data;
|
|
89
|
+
const result = await options.backend.invokeAction(id, args, context, {
|
|
90
|
+
confirmed: confirmed === true,
|
|
91
|
+
});
|
|
92
|
+
return c.json(result);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
app.post("/api/v2/commands/param-options", bodyLimit({ maxSize: 16 * 1024 }), async (c) => {
|
|
96
|
+
const gate = guard(c);
|
|
97
|
+
if (gate) return gate;
|
|
98
|
+
c.header("Cache-Control", "no-store");
|
|
99
|
+
let body: unknown;
|
|
100
|
+
try {
|
|
101
|
+
body = await c.req.json();
|
|
102
|
+
} catch {
|
|
103
|
+
return c.json({ error: "Invalid options request" }, 400);
|
|
104
|
+
}
|
|
105
|
+
const parsed = CommandParamOptionsRequestSchemaZ.safeParse(body);
|
|
106
|
+
if (!parsed.success) return c.json({ error: "Invalid options request" }, 400);
|
|
107
|
+
if (!options.backend) return c.json({ error: "Plugins are not enabled in this daemon" }, 503);
|
|
108
|
+
return c.json(
|
|
109
|
+
await options.backend.actionParamOptions(
|
|
110
|
+
parsed.data.id,
|
|
111
|
+
parsed.data.param,
|
|
112
|
+
parsed.data.context,
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner-only routes for plugins:
|
|
3
|
+
* GET /api/v2/plugins status of the host and every plugin
|
|
4
|
+
* POST /api/v2/plugins/reload { name? }: discover again and reload
|
|
5
|
+
* POST /api/v2/lua/run { code, chunkName?, budgetMs? }: run once
|
|
6
|
+
*
|
|
7
|
+
* `lua/run` executes code with the owner's authority, so every route needs
|
|
8
|
+
* the owner capability, never the shared remote-access token. The check is
|
|
9
|
+
* `ownerAuthorityGate`, the same one behind `/api/v2/capabilities` and the
|
|
10
|
+
* owner-only actions such as `project.launch`, which also run user code.
|
|
11
|
+
*
|
|
12
|
+
* None of these routes serve browsers: a request that carries `Origin` or
|
|
13
|
+
* any `Sec-Fetch-*` header is refused before the credential is looked at,
|
|
14
|
+
* so the daemon's permissive CORS policy cannot expose them to a web page.
|
|
15
|
+
*/
|
|
16
|
+
import type { Context, Hono } from "hono";
|
|
17
|
+
import { bodyLimit } from "hono/body-limit";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { ownerAuthorityGate } from "./owner-authority.ts";
|
|
20
|
+
import type { LuaRunResult, PluginSupervisorStatus } from "../plugins/supervisor.ts";
|
|
21
|
+
|
|
22
|
+
export interface PluginRouteBackend {
|
|
23
|
+
status(): PluginSupervisorStatus;
|
|
24
|
+
reload(name?: string): Promise<PluginSupervisorStatus>;
|
|
25
|
+
run(code: string, options: { chunkName?: string; budgetMs?: number }): Promise<LuaRunResult>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ReloadRequestZ = z.strictObject({ name: z.string().min(1).max(64).optional() });
|
|
29
|
+
const RunRequestZ = z.strictObject({
|
|
30
|
+
code: z.string().max(1024 * 1024),
|
|
31
|
+
chunkName: z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1)
|
|
34
|
+
.max(200)
|
|
35
|
+
.regex(/^[=@][^\0\n]*$/u)
|
|
36
|
+
.optional(),
|
|
37
|
+
budgetMs: z.number().int().min(10).max(600_000).optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The gate every plugin and command-catalog route uses: refuse anything a
|
|
42
|
+
* browser sent, then require the owner capability.
|
|
43
|
+
*/
|
|
44
|
+
export function ownerOnlyNonBrowserGuard(
|
|
45
|
+
ownerToken: string | null,
|
|
46
|
+
): (c: Context) => Response | null {
|
|
47
|
+
const authorize = ownerAuthorityGate(ownerToken, {
|
|
48
|
+
whenOwnerless: "unavailable",
|
|
49
|
+
unavailableMessage: "Plugins are unavailable",
|
|
50
|
+
mismatchMessage: "Plugins require owner authority",
|
|
51
|
+
});
|
|
52
|
+
const refuseBrowser = (c: Context): Response | null => {
|
|
53
|
+
const headers = c.req.header();
|
|
54
|
+
const fromBrowser = Object.keys(headers).some(
|
|
55
|
+
(name) => name === "origin" || name.startsWith("sec-fetch-"),
|
|
56
|
+
);
|
|
57
|
+
return fromBrowser ? c.json({ error: "Plugins cannot be used from a browser" }, 403) : null;
|
|
58
|
+
};
|
|
59
|
+
return (c) => refuseBrowser(c) ?? authorize(c);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function mountPluginRoutes(
|
|
63
|
+
app: Hono,
|
|
64
|
+
options: { ownerToken: string | null; backend: PluginRouteBackend | null },
|
|
65
|
+
): void {
|
|
66
|
+
const guard = ownerOnlyNonBrowserGuard(options.ownerToken);
|
|
67
|
+
const unavailable = { error: "Plugins are not enabled in this daemon" };
|
|
68
|
+
|
|
69
|
+
app.get("/api/v2/plugins", (c) => {
|
|
70
|
+
const gate = guard(c);
|
|
71
|
+
if (gate) return gate;
|
|
72
|
+
c.header("Cache-Control", "no-store");
|
|
73
|
+
if (!options.backend) return c.json(unavailable, 503);
|
|
74
|
+
return c.json({ ok: true, ...options.backend.status() });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
app.post("/api/v2/plugins/reload", bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
78
|
+
const gate = guard(c);
|
|
79
|
+
if (gate) return gate;
|
|
80
|
+
c.header("Cache-Control", "no-store");
|
|
81
|
+
if (!options.backend) return c.json(unavailable, 503);
|
|
82
|
+
let body: unknown;
|
|
83
|
+
try {
|
|
84
|
+
const text = await c.req.text();
|
|
85
|
+
body = text ? JSON.parse(text) : {};
|
|
86
|
+
} catch {
|
|
87
|
+
return c.json({ error: "Invalid reload request" }, 400);
|
|
88
|
+
}
|
|
89
|
+
const parsed = ReloadRequestZ.safeParse(body);
|
|
90
|
+
if (!parsed.success) return c.json({ error: "Invalid reload request" }, 400);
|
|
91
|
+
return c.json({ ok: true, ...(await options.backend.reload(parsed.data.name)) });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
app.post("/api/v2/lua/run", bodyLimit({ maxSize: 1024 * 1024 + 4096 }), async (c) => {
|
|
95
|
+
const gate = guard(c);
|
|
96
|
+
if (gate) return gate;
|
|
97
|
+
c.header("Cache-Control", "no-store");
|
|
98
|
+
if (!options.backend) return c.json(unavailable, 503);
|
|
99
|
+
let body: unknown;
|
|
100
|
+
try {
|
|
101
|
+
body = await c.req.json();
|
|
102
|
+
} catch {
|
|
103
|
+
return c.json({ error: "Invalid run request" }, 400);
|
|
104
|
+
}
|
|
105
|
+
const parsed = RunRequestZ.safeParse(body);
|
|
106
|
+
if (!parsed.success) return c.json({ error: "Invalid run request" }, 400);
|
|
107
|
+
const { code, ...runOptions } = parsed.data;
|
|
108
|
+
return c.json({ result: await options.backend.run(code, runOptions) });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -147,6 +147,8 @@ import { FilesAuthority } from "./resources/workspace-files-authority.ts";
|
|
|
147
147
|
import { ChangesAuthority } from "./resources/workspace-changes-authority.ts";
|
|
148
148
|
import { loadApplicationShellAppWindows } from "../lib/application-shell-app-windows.ts";
|
|
149
149
|
import { daemonActionCommandRegistry } from "./actions/command-definitions.ts";
|
|
150
|
+
import { mountPluginRoutes, type PluginRouteBackend } from "./plugin-routes.ts";
|
|
151
|
+
import { mountCommandCatalogRoutes, type CommandCatalogBackend } from "./command-catalog-routes.ts";
|
|
150
152
|
import { MissionRepository, type MissionRepositorySnapshot } from "../lib/mission-repository.ts";
|
|
151
153
|
import { projectDesktopMissionWorkspace } from "./resources/desktop-missions.ts";
|
|
152
154
|
import {
|
|
@@ -194,6 +196,8 @@ export interface CreateAppOptions {
|
|
|
194
196
|
appWindowMutationBackend?: import("./actions/handlers/app-window-mutate.ts").AppWindowMutationBackend;
|
|
195
197
|
workspaceMultiplexerBackend?: import("./actions/handlers/workspace-multiplexer.ts").WorkspaceMultiplexerBackend;
|
|
196
198
|
workspaceRegistry?: import("../lib/workspace-registry.ts").WorkspaceRegistry;
|
|
199
|
+
/** The canonical daemon's plugin supervisor; absent in other daemons. */
|
|
200
|
+
pluginBackend?: (PluginRouteBackend & CommandCatalogBackend) | null;
|
|
197
201
|
terminalAttachmentIssueBackend?: TerminalAttachmentIssueBackend | null;
|
|
198
202
|
/** Catalog + startup-barrier facts for the startup readiness ladder. */
|
|
199
203
|
startupReadinessAttachmentBackend?: StartupReadinessAttachmentAuthority | null;
|
|
@@ -441,6 +445,8 @@ function matchLogChannel(channel: string): ((entry: LogEntry) => boolean) | null
|
|
|
441
445
|
return (entry) => entry.component.startsWith("hq") || entry.component.startsWith("remote");
|
|
442
446
|
case "watchdog":
|
|
443
447
|
return (entry) => entry.component.startsWith("watchdog");
|
|
448
|
+
case "plugins":
|
|
449
|
+
return (entry) => entry.component.startsWith("plugin.");
|
|
444
450
|
default:
|
|
445
451
|
return null;
|
|
446
452
|
}
|
|
@@ -605,6 +611,15 @@ export function createApp(options: CreateAppOptions = {}): Hono {
|
|
|
605
611
|
daemon: daemonInstanceIdentity,
|
|
606
612
|
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
607
613
|
});
|
|
614
|
+
mountPluginRoutes(app, {
|
|
615
|
+
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
616
|
+
backend: options.pluginBackend ?? null,
|
|
617
|
+
});
|
|
618
|
+
mountCommandCatalogRoutes(app, {
|
|
619
|
+
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
620
|
+
builtins: () => daemonActionCommandRegistry.descriptors(),
|
|
621
|
+
backend: options.pluginBackend ?? null,
|
|
622
|
+
});
|
|
608
623
|
|
|
609
624
|
// --- Auth routes (always available, bypassed by middleware) ---
|
|
610
625
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Context, Hono } from "hono";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import {
|
|
4
|
+
PaneReaderAssetRequestSchemaZ,
|
|
5
|
+
PaneReaderRequestSchemaZ,
|
|
6
|
+
TmuxServerScopeSchemaZ,
|
|
7
|
+
} from "@tmux-ide/contracts";
|
|
8
|
+
import { TmuxServerScopeError, type TmuxServerOwners } from "../lib/tmux-server-owners.ts";
|
|
9
|
+
import type { NativeTmuxServerOwner } from "../lib/tmux-server-owner.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The native Markdown reader's routes (card #756). Mount only below the
|
|
13
|
+
* owner-authenticated, no-store scoped router. Responses never carry a path,
|
|
14
|
+
* a file-system error or validation detail.
|
|
15
|
+
*/
|
|
16
|
+
export function mountTmuxServerReaderRoutes(
|
|
17
|
+
app: Hono,
|
|
18
|
+
options: {
|
|
19
|
+
readonly scopedPath: string;
|
|
20
|
+
readonly owners: TmuxServerOwners<NativeTmuxServerOwner>;
|
|
21
|
+
readonly readBody: (request: Request) => Promise<unknown>;
|
|
22
|
+
},
|
|
23
|
+
): void {
|
|
24
|
+
const handle =
|
|
25
|
+
(schema: z.ZodType<{ target: { generation: string } }>, kind: "read" | "asset") =>
|
|
26
|
+
async (c: Context) => {
|
|
27
|
+
const scope = TmuxServerScopeSchemaZ.safeParse({
|
|
28
|
+
serverId: c.req.param("serverId"),
|
|
29
|
+
generation: c.req.param("generation"),
|
|
30
|
+
});
|
|
31
|
+
if (!scope.success) return c.json({ error: { code: "invalid-request" } }, 400);
|
|
32
|
+
let request: { target: { generation: string } };
|
|
33
|
+
try {
|
|
34
|
+
request = schema.parse(await options.readBody(c.req.raw));
|
|
35
|
+
} catch {
|
|
36
|
+
return c.json({ error: { code: "invalid-request" } }, 400);
|
|
37
|
+
}
|
|
38
|
+
if (request.target.generation !== scope.data.generation)
|
|
39
|
+
return c.json({ error: { code: "stale-generation" } }, 409);
|
|
40
|
+
try {
|
|
41
|
+
c.req.raw.signal.throwIfAborted();
|
|
42
|
+
const response: unknown = await options.owners.withOwner(
|
|
43
|
+
scope.data,
|
|
44
|
+
(owner): Promise<unknown> =>
|
|
45
|
+
kind === "read"
|
|
46
|
+
? owner.paneReader.read(request, c.req.raw.signal)
|
|
47
|
+
: owner.paneReader.asset(request, c.req.raw.signal),
|
|
48
|
+
);
|
|
49
|
+
c.req.raw.signal.throwIfAborted();
|
|
50
|
+
return c.json(response);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof TmuxServerScopeError)
|
|
53
|
+
return c.json(
|
|
54
|
+
{ error: { code: "scope-unavailable" } },
|
|
55
|
+
error.code === "not-found" ? 404 : 409,
|
|
56
|
+
);
|
|
57
|
+
return c.json({ error: { code: "reader-unavailable" } }, 503);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
app.post(`${options.scopedPath}/reader`, handle(PaneReaderRequestSchemaZ, "read"));
|
|
61
|
+
app.post(`${options.scopedPath}/reader/asset`, handle(PaneReaderAssetRequestSchemaZ, "asset"));
|
|
62
|
+
}
|