tmux-ide 2.9.18 → 2.9.21
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 +14703 -3882
- 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 +2 -0
- package/packages/contracts/src/plain-text.ts +61 -0
- 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/doctor.js +12 -5
- package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
- package/packages/daemon/dist/lib/daemon-embed.js +24 -1
- package/packages/daemon/dist/lib/headless-daemon.js +1 -0
- package/packages/daemon/dist/lib/native-split-capability.js +13 -15
- 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/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 +132 -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/terminal/mirror/session-channel.js +3 -2
- package/packages/daemon/dist/terminal/mirror/window-split-authority.js +1 -1
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +27 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
- 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/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/doctor.ts +12 -5
- package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
- package/packages/daemon/src/lib/daemon-embed.ts +42 -0
- package/packages/daemon/src/lib/headless-daemon.ts +1 -0
- package/packages/daemon/src/lib/native-split-capability.ts +12 -13
- package/packages/daemon/src/lib/worktree.ts +16 -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 +182 -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/terminal/mirror/session-channel.ts +3 -2
- package/packages/daemon/src/terminal/mirror/window-split-authority.ts +3 -2
- package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +32 -0
- package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
- 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/workspace/application-command-description.ts +44 -2
- package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tmux-ide",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.21",
|
|
4
4
|
"description": "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"demo:themes": "bun --preload @opentui/solid/preload docs/scripts/render-theme-gallery.tsx && node docs/scripts/rasterize-theme-gallery.mjs",
|
|
74
74
|
"demo:font": "node docs/scripts/tui-demo-font/build.mjs",
|
|
75
75
|
"readme:media": "node docs/scripts/readme-media.mjs",
|
|
76
|
-
"test:tui-renderer": "bun test --preload @opentui/solid/preload --preload ./packages/daemon/test-support/opentui-renderer-preload.ts ./packages/daemon/src/tui/mirror/automatic-contrast-renderer.test.tsx ./packages/daemon/src/tui/mirror/pane-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/native-grid-projection-renderer.test.tsx ./packages/daemon/src/tui/mirror/widget-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/missions-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/recipes-gallery-renderer.test.tsx ./packages/daemon/src/tui/mirror/shell-chrome-renderer.test.tsx ./packages/daemon/src/tui/mirror/sidebar-renderer.test.tsx ./packages/daemon/src/tui/mirror/home-files-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/changes-terminal-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/activity-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/features/files/session-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-renderer.test.tsx ./packages/daemon/src/tui/mirror/testing/styled-frame-oracle.test.tsx ./packages/daemon/src/tui/mirror/runtime/terminal-transient-frame-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/terminal-draw-failure-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-view-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-root-error-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-backpressure-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-demand-cadence-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/files-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/changes-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/missions-activity-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/dialogs-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/optional-feature-registry-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/palette-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/features/rich-preview/feature.test.ts ./packages/daemon/src/tui/mirror/runtime/rich-preview-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/application-shell-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/pane-frame-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome-view.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-window-strip-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/workbench-shell-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/workbench-dock-dual-host-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/command-palette-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/opentui-insertion-stability-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-home-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-pane-header-polish-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-home-agent-roster-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-home-agent-flow-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/guided-tour-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-sidebar-catalog-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/ui-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/pane-interaction-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-machine-sidebar-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-add-machine-dialog-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-new-agent-dialog-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-switcher-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-palette-preview-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-palette-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-session-actions-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/agent-team-renderer.test.tsx ./scripts/solid-conditional-props.test.tsx",
|
|
76
|
+
"test:tui-renderer": "bun test --preload @opentui/solid/preload --preload ./packages/daemon/test-support/opentui-renderer-preload.ts ./packages/daemon/src/tui/mirror/automatic-contrast-renderer.test.tsx ./packages/daemon/src/tui/mirror/pane-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/native-grid-projection-renderer.test.tsx ./packages/daemon/src/tui/mirror/widget-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/missions-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/recipes-gallery-renderer.test.tsx ./packages/daemon/src/tui/mirror/shell-chrome-renderer.test.tsx ./packages/daemon/src/tui/mirror/sidebar-renderer.test.tsx ./packages/daemon/src/tui/mirror/home-files-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/changes-terminal-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/activity-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/features/files/session-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-renderer.test.tsx ./packages/daemon/src/tui/mirror/testing/styled-frame-oracle.test.tsx ./packages/daemon/src/tui/mirror/runtime/terminal-transient-frame-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/terminal-draw-failure-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-view-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-root-error-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-backpressure-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-demand-cadence-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/files-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/changes-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/missions-activity-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/dialogs-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/optional-feature-registry-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/palette-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/features/rich-preview/feature.test.ts ./packages/daemon/src/tui/mirror/runtime/rich-preview-optional-feature-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/application-shell-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/pane-frame-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome-view.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-window-strip-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/workbench-shell-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/workbench-dock-dual-host-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/command-palette-surface-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/opentui-insertion-stability-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-home-renderer.test.tsx ./packages/daemon/src/tui/mirror/workspace/terminal-pane-header-polish-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-home-agent-roster-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-home-agent-flow-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/guided-tour-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-shell-sidebar-catalog-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/ui-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/pane-interaction-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-machine-sidebar-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-add-machine-dialog-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-new-agent-dialog-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-switcher-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-palette-preview-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-palette-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-plugin-palette-renderer.test.tsx ./packages/daemon/src/tui/mirror/runtime/application-fleet-session-actions-renderer.test.tsx ./packages/daemon/src/tui/mirror/ui/agent-team-renderer.test.tsx ./scripts/solid-conditional-props.test.tsx",
|
|
77
77
|
"test:tui-smoke": "bun scripts/smoke-tui-missions.mjs",
|
|
78
78
|
"test:tui-live": "node scripts/tui-testdrive.mjs smoke",
|
|
79
79
|
"test:tui-testdrive": "node --test scripts/lib/tui-testdrive-clipboard-hook.test.mjs scripts/lib/tui-testdrive-input.test.mjs",
|
|
@@ -143,6 +143,7 @@
|
|
|
143
143
|
"js-yaml": "^4.3.1",
|
|
144
144
|
"node-pty": "1.2.0-beta.12",
|
|
145
145
|
"string-width": "^7.2.0",
|
|
146
|
+
"wasmoon": "1.16.0",
|
|
146
147
|
"ws": "^8.21.0",
|
|
147
148
|
"zod": "^4.3.6"
|
|
148
149
|
},
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { plainTextSchema } from "./plain-text.ts";
|
|
3
|
+
import {
|
|
4
|
+
CommandDescriptorSchemaZ,
|
|
5
|
+
CommandIdSchemaZ,
|
|
6
|
+
CommandSourceKindSchemaZ,
|
|
7
|
+
} from "./commands.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The command catalog: every command a palette, a key binding or the CLI can
|
|
11
|
+
* offer, built-in daemon actions and plugin actions alike. Plugin actions
|
|
12
|
+
* carry a parameter list the palette turns into a form before invoking.
|
|
13
|
+
*/
|
|
14
|
+
export const COMMAND_CATALOG_VERSION = 1 as const;
|
|
15
|
+
|
|
16
|
+
export const CommandParamTypeSchemaZ = z.enum(["string", "text", "number", "boolean", "choice"]);
|
|
17
|
+
export type CommandParamType = z.infer<typeof CommandParamTypeSchemaZ>;
|
|
18
|
+
|
|
19
|
+
export const CommandParamNameSchemaZ = z.string().regex(/^[a-z_][a-z0-9_]{0,63}$/u);
|
|
20
|
+
|
|
21
|
+
export const CommandChoiceSchemaZ = z
|
|
22
|
+
.object({
|
|
23
|
+
value: plainTextSchema(0, 500),
|
|
24
|
+
label: plainTextSchema(1, 200),
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
export type CommandChoice = z.infer<typeof CommandChoiceSchemaZ>;
|
|
28
|
+
|
|
29
|
+
export const CommandParamSchemaZ = z
|
|
30
|
+
.object({
|
|
31
|
+
name: CommandParamNameSchemaZ,
|
|
32
|
+
type: CommandParamTypeSchemaZ,
|
|
33
|
+
label: plainTextSchema(1, 120),
|
|
34
|
+
description: plainTextSchema(0, 500).optional(),
|
|
35
|
+
/** False only when the plugin marked it `optional = true`. */
|
|
36
|
+
required: z.boolean(),
|
|
37
|
+
/** A fixed default; `dynamicDefault` means the plugin computes one per invocation. */
|
|
38
|
+
default: z.union([plainTextSchema(0, 10_000), z.number(), z.boolean()]).optional(),
|
|
39
|
+
dynamicDefault: z.boolean(),
|
|
40
|
+
/** Fixed choices for `choice`; `dynamicChoices` means ask the plugin. */
|
|
41
|
+
choices: z.array(CommandChoiceSchemaZ).max(500).optional(),
|
|
42
|
+
dynamicChoices: z.boolean(),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
|
45
|
+
export type CommandParam = z.infer<typeof CommandParamSchemaZ>;
|
|
46
|
+
|
|
47
|
+
export const CommandCatalogEntrySchemaZ = z
|
|
48
|
+
.object({
|
|
49
|
+
descriptor: CommandDescriptorSchemaZ,
|
|
50
|
+
/** The plugin that registered it; absent for built-in commands. */
|
|
51
|
+
plugin: z.string().min(1).max(64).optional(),
|
|
52
|
+
params: z.array(CommandParamSchemaZ).max(32),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
export type CommandCatalogEntry = z.infer<typeof CommandCatalogEntrySchemaZ>;
|
|
56
|
+
|
|
57
|
+
export const CommandCatalogResourceSchemaZ = z
|
|
58
|
+
.object({
|
|
59
|
+
version: z.literal(COMMAND_CATALOG_VERSION),
|
|
60
|
+
revision: z.number().int().nonnegative(),
|
|
61
|
+
entries: z.array(CommandCatalogEntrySchemaZ).max(2000),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
export type CommandCatalogResource = z.infer<typeof CommandCatalogResourceSchemaZ>;
|
|
65
|
+
|
|
66
|
+
/** Where an invocation came from, so a plugin can act on the right session and pane. */
|
|
67
|
+
export const CommandInvocationContextSchemaZ = z
|
|
68
|
+
.object({
|
|
69
|
+
source: CommandSourceKindSchemaZ,
|
|
70
|
+
session: z.string().min(1).max(200).optional(),
|
|
71
|
+
window: z.string().min(1).max(200).optional(),
|
|
72
|
+
pane: z.string().min(1).max(200).optional(),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
export type CommandInvocationContext = z.infer<typeof CommandInvocationContextSchemaZ>;
|
|
76
|
+
|
|
77
|
+
export const CommandArgValueSchemaZ = z.union([z.string().max(100_000), z.number(), z.boolean()]);
|
|
78
|
+
|
|
79
|
+
export const CommandInvokeRequestSchemaZ = z
|
|
80
|
+
.object({
|
|
81
|
+
id: CommandIdSchemaZ,
|
|
82
|
+
args: z.record(CommandParamNameSchemaZ, CommandArgValueSchemaZ),
|
|
83
|
+
context: CommandInvocationContextSchemaZ,
|
|
84
|
+
/** Required for a dangerous command: the person confirmed it. */
|
|
85
|
+
confirmed: z.boolean().optional(),
|
|
86
|
+
})
|
|
87
|
+
.strict();
|
|
88
|
+
export type CommandInvokeRequest = z.infer<typeof CommandInvokeRequestSchemaZ>;
|
|
89
|
+
|
|
90
|
+
export const CommandInvokeResultSchemaZ = z.discriminatedUnion("ok", [
|
|
91
|
+
z.object({ ok: z.literal(true), value: z.json().optional() }).strict(),
|
|
92
|
+
z.object({ ok: z.literal(false), error: z.string() }).strict(),
|
|
93
|
+
]);
|
|
94
|
+
export type CommandInvokeResult = z.infer<typeof CommandInvokeResultSchemaZ>;
|
|
95
|
+
|
|
96
|
+
/** Ask a plugin for one parameter's choices and default, for the current context. */
|
|
97
|
+
export const CommandParamOptionsRequestSchemaZ = z
|
|
98
|
+
.object({
|
|
99
|
+
id: CommandIdSchemaZ,
|
|
100
|
+
param: CommandParamNameSchemaZ,
|
|
101
|
+
context: CommandInvocationContextSchemaZ,
|
|
102
|
+
})
|
|
103
|
+
.strict();
|
|
104
|
+
export type CommandParamOptionsRequest = z.infer<typeof CommandParamOptionsRequestSchemaZ>;
|
|
105
|
+
|
|
106
|
+
export const CommandParamOptionsResultSchemaZ = z.discriminatedUnion("ok", [
|
|
107
|
+
z
|
|
108
|
+
.object({
|
|
109
|
+
ok: z.literal(true),
|
|
110
|
+
choices: z.array(CommandChoiceSchemaZ).max(500).optional(),
|
|
111
|
+
default: z.union([z.string().max(10_000), z.number(), z.boolean()]).optional(),
|
|
112
|
+
})
|
|
113
|
+
.strict(),
|
|
114
|
+
z.object({ ok: z.literal(false), error: z.string() }).strict(),
|
|
115
|
+
]);
|
|
116
|
+
export type CommandParamOptionsResult = z.infer<typeof CommandParamOptionsResultSchemaZ>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { plainTextSchema } from "./plain-text.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Stable, process-neutral command protocol shared by daemon and renderer hosts.
|
|
@@ -17,7 +18,7 @@ export const CommandIdSchemaZ = z
|
|
|
17
18
|
"command id must be a dot-namespaced identifier",
|
|
18
19
|
);
|
|
19
20
|
|
|
20
|
-
export const CommandOwnerSchemaZ = z.enum(["daemon", "renderer"]);
|
|
21
|
+
export const CommandOwnerSchemaZ = z.enum(["daemon", "renderer", "plugin"]);
|
|
21
22
|
|
|
22
23
|
export const CommandSourceKindSchemaZ = z.enum([
|
|
23
24
|
"cli",
|
|
@@ -52,9 +53,9 @@ export const CommandDescriptorSchemaZ = z
|
|
|
52
53
|
version: z.literal(COMMAND_PROTOCOL_VERSION),
|
|
53
54
|
id: CommandIdSchemaZ,
|
|
54
55
|
owner: CommandOwnerSchemaZ,
|
|
55
|
-
label:
|
|
56
|
-
description:
|
|
57
|
-
category:
|
|
56
|
+
label: plainTextSchema(1, 160),
|
|
57
|
+
description: plainTextSchema(1, 500).optional(),
|
|
58
|
+
category: plainTextSchema(1, 80),
|
|
58
59
|
schemas: CommandSchemaReferencesSchemaZ,
|
|
59
60
|
dangerous: z.boolean(),
|
|
60
61
|
confirmation: CommandConfirmationSchemaZ,
|
|
@@ -21,7 +21,7 @@ const SessionNamesSchemaZ = z.array(z.string());
|
|
|
21
21
|
export const DaemonEventResourceInterestSchemaZ = z.discriminatedUnion("resource", [
|
|
22
22
|
z
|
|
23
23
|
.object({
|
|
24
|
-
resource: z.enum(["workspace-catalog", "fleet-catalog"]),
|
|
24
|
+
resource: z.enum(["workspace-catalog", "fleet-catalog", "command-catalog"]),
|
|
25
25
|
workspaceName: z.null(),
|
|
26
26
|
})
|
|
27
27
|
.strict(),
|
|
@@ -168,6 +168,7 @@ export const DaemonEventResourceKindSchemaZ = z.enum([
|
|
|
168
168
|
"workspace-files",
|
|
169
169
|
"workspace-changes",
|
|
170
170
|
"workspace-missions",
|
|
171
|
+
"command-catalog",
|
|
171
172
|
]);
|
|
172
173
|
export type DaemonEventResourceKind = z.infer<typeof DaemonEventResourceKindSchemaZ>;
|
|
173
174
|
|
|
@@ -33,6 +33,8 @@ export * from "./terminal-attachments.ts";
|
|
|
33
33
|
export * from "./pane-stream.ts";
|
|
34
34
|
export * from "./control.ts";
|
|
35
35
|
export * from "./commands.ts";
|
|
36
|
+
export * from "./command-catalog.ts";
|
|
37
|
+
export * from "./plain-text.ts";
|
|
36
38
|
// Explicit leaf exports let bundled transport clients avoid desktop resources.
|
|
37
39
|
export {
|
|
38
40
|
DesktopDaemonCapabilityErrorCodeSchemaZ,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Text that comes from plugins (titles, labels, choices, results, errors)
|
|
5
|
+
* ends up in terminals. C0 controls, DEL and C1 controls would let it
|
|
6
|
+
* drive the terminal (OSC 52 writes the clipboard, `ESC[2K` rewrites a
|
|
7
|
+
* prompt line), bidi and other format characters would let it reorder or
|
|
8
|
+
* hide what is shown, and U+2028/U+2029 break lines in some viewers.
|
|
9
|
+
*/
|
|
10
|
+
// The same classes as the app's clean(): controls (Cc: C0, DEL, C1), format
|
|
11
|
+
// characters (Cf: bidi controls, zero-width characters, U+FEFF, soft hyphen,
|
|
12
|
+
// …) and the line and paragraph separators.
|
|
13
|
+
const UNSAFE_CLASS = "[\\p{Cc}\\p{Cf}\\u2028\\u2029]";
|
|
14
|
+
const UNSAFE = new RegExp(UNSAFE_CLASS, "u");
|
|
15
|
+
const UNSAFE_GLOBAL = new RegExp(UNSAFE_CLASS, "gu");
|
|
16
|
+
|
|
17
|
+
export function hasUnsafeText(text: string): boolean {
|
|
18
|
+
return UNSAFE.test(text);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One line of plain text: every unsafe character becomes a space. */
|
|
22
|
+
export function terminalSafe(text: string, max = 2000): string {
|
|
23
|
+
return text.replace(UNSAFE_GLOBAL, " ").slice(0, max);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Several lines of plain text, for whole outputs: newlines and tabs stay,
|
|
28
|
+
* every other unsafe character becomes a space.
|
|
29
|
+
*/
|
|
30
|
+
export function terminalSafeBlock(text: string): string {
|
|
31
|
+
return text.replace(UNSAFE_GLOBAL, (char) => (char === "\n" || char === "\t" ? char : " "));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Every string inside a JSON value made terminal-safe. Values keep their
|
|
36
|
+
* newlines and tabs (program output is several lines); keys become one line.
|
|
37
|
+
*/
|
|
38
|
+
export function terminalSafeDeep(value: unknown, max = 10_000): unknown {
|
|
39
|
+
if (typeof value === "string") return terminalSafeBlock(value).slice(0, max);
|
|
40
|
+
if (Array.isArray(value)) return value.map((item) => terminalSafeDeep(item, max));
|
|
41
|
+
if (value && typeof value === "object")
|
|
42
|
+
return Object.fromEntries(
|
|
43
|
+
Object.entries(value).map(([key, item]) => [
|
|
44
|
+
terminalSafe(key, 200),
|
|
45
|
+
terminalSafeDeep(item, max),
|
|
46
|
+
]),
|
|
47
|
+
);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A string schema that refuses control, DEL, C1 and bidi characters, newlines included. */
|
|
52
|
+
export function plainTextSchema(min: number, max: number) {
|
|
53
|
+
return z
|
|
54
|
+
.string()
|
|
55
|
+
.min(min)
|
|
56
|
+
.max(max)
|
|
57
|
+
.refine(
|
|
58
|
+
(value) => !hasUnsafeText(value),
|
|
59
|
+
"must be plain text: no control characters or newlines",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { COMMAND_CATALOG_VERSION, CommandInvokeRequestSchemaZ, CommandParamOptionsRequestSchemaZ, } from "@tmux-ide/contracts";
|
|
12
|
+
import { bodyLimit } from "hono/body-limit";
|
|
13
|
+
import { ownerOnlyNonBrowserGuard } from "./plugin-routes.js";
|
|
14
|
+
export function buildCommandCatalog(builtins, plugins) {
|
|
15
|
+
const pluginCatalog = plugins?.actionCatalog() ?? { revision: 0, entries: [] };
|
|
16
|
+
return {
|
|
17
|
+
version: COMMAND_CATALOG_VERSION,
|
|
18
|
+
revision: pluginCatalog.revision,
|
|
19
|
+
entries: [
|
|
20
|
+
...builtins.map((descriptor) => ({ descriptor, params: [] })),
|
|
21
|
+
...pluginCatalog.entries,
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function mountCommandCatalogRoutes(app, options) {
|
|
26
|
+
const guard = ownerOnlyNonBrowserGuard(options.ownerToken);
|
|
27
|
+
app.get("/api/resources/command-catalog", (c) => {
|
|
28
|
+
const gate = guard(c);
|
|
29
|
+
if (gate)
|
|
30
|
+
return gate;
|
|
31
|
+
c.header("Cache-Control", "no-store");
|
|
32
|
+
return c.json(buildCommandCatalog(options.builtins(), options.backend));
|
|
33
|
+
});
|
|
34
|
+
app.post("/api/v2/commands/invoke", bodyLimit({ maxSize: 256 * 1024 }), async (c) => {
|
|
35
|
+
const gate = guard(c);
|
|
36
|
+
if (gate)
|
|
37
|
+
return gate;
|
|
38
|
+
c.header("Cache-Control", "no-store");
|
|
39
|
+
let body;
|
|
40
|
+
try {
|
|
41
|
+
body = await c.req.json();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return c.json({ error: "Invalid invoke request" }, 400);
|
|
45
|
+
}
|
|
46
|
+
const parsed = CommandInvokeRequestSchemaZ.safeParse(body);
|
|
47
|
+
if (!parsed.success)
|
|
48
|
+
return c.json({ error: "Invalid invoke request" }, 400);
|
|
49
|
+
if (!parsed.data.id.startsWith("plugin."))
|
|
50
|
+
return c.json({ error: "Built-in commands use /api/v2/action/:name" }, 404);
|
|
51
|
+
if (!options.backend)
|
|
52
|
+
return c.json({ error: "Plugins are not enabled in this daemon" }, 503);
|
|
53
|
+
const { id, args, context, confirmed } = parsed.data;
|
|
54
|
+
const result = await options.backend.invokeAction(id, args, context, {
|
|
55
|
+
confirmed: confirmed === true,
|
|
56
|
+
});
|
|
57
|
+
return c.json(result);
|
|
58
|
+
});
|
|
59
|
+
app.post("/api/v2/commands/param-options", bodyLimit({ maxSize: 16 * 1024 }), async (c) => {
|
|
60
|
+
const gate = guard(c);
|
|
61
|
+
if (gate)
|
|
62
|
+
return gate;
|
|
63
|
+
c.header("Cache-Control", "no-store");
|
|
64
|
+
let body;
|
|
65
|
+
try {
|
|
66
|
+
body = await c.req.json();
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return c.json({ error: "Invalid options request" }, 400);
|
|
70
|
+
}
|
|
71
|
+
const parsed = CommandParamOptionsRequestSchemaZ.safeParse(body);
|
|
72
|
+
if (!parsed.success)
|
|
73
|
+
return c.json({ error: "Invalid options request" }, 400);
|
|
74
|
+
if (!options.backend)
|
|
75
|
+
return c.json({ error: "Plugins are not enabled in this daemon" }, 503);
|
|
76
|
+
return c.json(await options.backend.actionParamOptions(parsed.data.id, parsed.data.param, parsed.data.context));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { bodyLimit } from "hono/body-limit";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ownerAuthorityGate } from "./owner-authority.js";
|
|
4
|
+
const ReloadRequestZ = z.strictObject({ name: z.string().min(1).max(64).optional() });
|
|
5
|
+
const RunRequestZ = z.strictObject({
|
|
6
|
+
code: z.string().max(1024 * 1024),
|
|
7
|
+
chunkName: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(200)
|
|
11
|
+
.regex(/^[=@][^\0\n]*$/u)
|
|
12
|
+
.optional(),
|
|
13
|
+
budgetMs: z.number().int().min(10).max(600_000).optional(),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The gate every plugin and command-catalog route uses: refuse anything a
|
|
17
|
+
* browser sent, then require the owner capability.
|
|
18
|
+
*/
|
|
19
|
+
export function ownerOnlyNonBrowserGuard(ownerToken) {
|
|
20
|
+
const authorize = ownerAuthorityGate(ownerToken, {
|
|
21
|
+
whenOwnerless: "unavailable",
|
|
22
|
+
unavailableMessage: "Plugins are unavailable",
|
|
23
|
+
mismatchMessage: "Plugins require owner authority",
|
|
24
|
+
});
|
|
25
|
+
const refuseBrowser = (c) => {
|
|
26
|
+
const headers = c.req.header();
|
|
27
|
+
const fromBrowser = Object.keys(headers).some((name) => name === "origin" || name.startsWith("sec-fetch-"));
|
|
28
|
+
return fromBrowser ? c.json({ error: "Plugins cannot be used from a browser" }, 403) : null;
|
|
29
|
+
};
|
|
30
|
+
return (c) => refuseBrowser(c) ?? authorize(c);
|
|
31
|
+
}
|
|
32
|
+
export function mountPluginRoutes(app, options) {
|
|
33
|
+
const guard = ownerOnlyNonBrowserGuard(options.ownerToken);
|
|
34
|
+
const unavailable = { error: "Plugins are not enabled in this daemon" };
|
|
35
|
+
app.get("/api/v2/plugins", (c) => {
|
|
36
|
+
const gate = guard(c);
|
|
37
|
+
if (gate)
|
|
38
|
+
return gate;
|
|
39
|
+
c.header("Cache-Control", "no-store");
|
|
40
|
+
if (!options.backend)
|
|
41
|
+
return c.json(unavailable, 503);
|
|
42
|
+
return c.json({ ok: true, ...options.backend.status() });
|
|
43
|
+
});
|
|
44
|
+
app.post("/api/v2/plugins/reload", bodyLimit({ maxSize: 4 * 1024 }), async (c) => {
|
|
45
|
+
const gate = guard(c);
|
|
46
|
+
if (gate)
|
|
47
|
+
return gate;
|
|
48
|
+
c.header("Cache-Control", "no-store");
|
|
49
|
+
if (!options.backend)
|
|
50
|
+
return c.json(unavailable, 503);
|
|
51
|
+
let body;
|
|
52
|
+
try {
|
|
53
|
+
const text = await c.req.text();
|
|
54
|
+
body = text ? JSON.parse(text) : {};
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return c.json({ error: "Invalid reload request" }, 400);
|
|
58
|
+
}
|
|
59
|
+
const parsed = ReloadRequestZ.safeParse(body);
|
|
60
|
+
if (!parsed.success)
|
|
61
|
+
return c.json({ error: "Invalid reload request" }, 400);
|
|
62
|
+
return c.json({ ok: true, ...(await options.backend.reload(parsed.data.name)) });
|
|
63
|
+
});
|
|
64
|
+
app.post("/api/v2/lua/run", bodyLimit({ maxSize: 1024 * 1024 + 4096 }), async (c) => {
|
|
65
|
+
const gate = guard(c);
|
|
66
|
+
if (gate)
|
|
67
|
+
return gate;
|
|
68
|
+
c.header("Cache-Control", "no-store");
|
|
69
|
+
if (!options.backend)
|
|
70
|
+
return c.json(unavailable, 503);
|
|
71
|
+
let body;
|
|
72
|
+
try {
|
|
73
|
+
body = await c.req.json();
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return c.json({ error: "Invalid run request" }, 400);
|
|
77
|
+
}
|
|
78
|
+
const parsed = RunRequestZ.safeParse(body);
|
|
79
|
+
if (!parsed.success)
|
|
80
|
+
return c.json({ error: "Invalid run request" }, 400);
|
|
81
|
+
const { code, ...runOptions } = parsed.data;
|
|
82
|
+
return c.json({ result: await options.backend.run(code, runOptions) });
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -58,6 +58,8 @@ import { FilesAuthority } from "./resources/workspace-files-authority.js";
|
|
|
58
58
|
import { ChangesAuthority } from "./resources/workspace-changes-authority.js";
|
|
59
59
|
import { loadApplicationShellAppWindows } from "../lib/application-shell-app-windows.js";
|
|
60
60
|
import { daemonActionCommandRegistry } from "./actions/command-definitions.js";
|
|
61
|
+
import { mountPluginRoutes } from "./plugin-routes.js";
|
|
62
|
+
import { mountCommandCatalogRoutes } from "./command-catalog-routes.js";
|
|
61
63
|
import { MissionRepository } from "../lib/mission-repository.js";
|
|
62
64
|
import { projectDesktopMissionWorkspace } from "./resources/desktop-missions.js";
|
|
63
65
|
import { mountTerminalAttachmentIssueRoute, } from "./terminal-attachment-issue.js";
|
|
@@ -239,6 +241,8 @@ function matchLogChannel(channel) {
|
|
|
239
241
|
return (entry) => entry.component.startsWith("hq") || entry.component.startsWith("remote");
|
|
240
242
|
case "watchdog":
|
|
241
243
|
return (entry) => entry.component.startsWith("watchdog");
|
|
244
|
+
case "plugins":
|
|
245
|
+
return (entry) => entry.component.startsWith("plugin.");
|
|
242
246
|
default:
|
|
243
247
|
return null;
|
|
244
248
|
}
|
|
@@ -375,6 +379,15 @@ export function createApp(options = {}) {
|
|
|
375
379
|
daemon: daemonInstanceIdentity,
|
|
376
380
|
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
377
381
|
});
|
|
382
|
+
mountPluginRoutes(app, {
|
|
383
|
+
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
384
|
+
backend: options.pluginBackend ?? null,
|
|
385
|
+
});
|
|
386
|
+
mountCommandCatalogRoutes(app, {
|
|
387
|
+
ownerToken: options.remoteAccess?.ownerToken ?? null,
|
|
388
|
+
builtins: () => daemonActionCommandRegistry.descriptors(),
|
|
389
|
+
backend: options.pluginBackend ?? null,
|
|
390
|
+
});
|
|
378
391
|
// --- Auth routes (always available, bypassed by middleware) ---
|
|
379
392
|
app.post("/api/auth/challenge", async (c) => {
|
|
380
393
|
const body = await c.req.json();
|
|
@@ -153,8 +153,8 @@ function check(label, fn, { optional = false } = {}) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
const UNKNOWN = (command) => new RegExp(`^unknown command: ${command}$`, "mu");
|
|
156
|
-
/** The same reading of the server as the mirror's: stock
|
|
157
|
-
*
|
|
156
|
+
/** The same reading of the server as the mirror's: the stock resize when it refuses
|
|
157
|
+
* the split command by name, and full only with the split capability it requires. */
|
|
158
158
|
function nativeCommands(probe) {
|
|
159
159
|
const ask = (command) => {
|
|
160
160
|
try {
|
|
@@ -171,8 +171,14 @@ function nativeCommands(probe) {
|
|
|
171
171
|
if (failures.some((text) => /no server running|error connecting/u.test(text)))
|
|
172
172
|
return "no-server";
|
|
173
173
|
const refused = (answer, command) => answer.failure !== undefined && UNKNOWN(command).test(answer.failure);
|
|
174
|
-
if (refused(split, "tmux-ide-resize-split")
|
|
175
|
-
|
|
174
|
+
if (refused(split, "tmux-ide-resize-split")) {
|
|
175
|
+
if (refused(events, "tmux-ide-events"))
|
|
176
|
+
return "stock";
|
|
177
|
+
// The journal answers: a tmux-ide tmux built before the split command.
|
|
178
|
+
if (events.output !== undefined)
|
|
179
|
+
return "older";
|
|
180
|
+
return "unknown";
|
|
181
|
+
}
|
|
176
182
|
if (split.output !== undefined && events.output !== undefined) {
|
|
177
183
|
try {
|
|
178
184
|
return nativeSplitCapability(split.output) ? "full" : "partial";
|
|
@@ -192,13 +198,14 @@ export function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
192
198
|
const details = {
|
|
193
199
|
full: "bundled tmux: full features",
|
|
194
200
|
stock: "stock tmux: reduced features",
|
|
201
|
+
older: "older tmux-ide tmux: reduced features (restart it with tmux-ide's own tmux for every feature; that ends its sessions)",
|
|
195
202
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
196
203
|
"no-server": "could not read the tmux server's features",
|
|
197
204
|
unknown: "could not read the tmux server's features",
|
|
198
205
|
};
|
|
199
206
|
return {
|
|
200
207
|
label: "tmux features",
|
|
201
|
-
pass: answer === "full" || answer === "stock",
|
|
208
|
+
pass: answer === "full" || answer === "stock" || answer === "older",
|
|
202
209
|
detail: details[answer],
|
|
203
210
|
optional: true,
|
|
204
211
|
};
|
|
@@ -194,3 +194,18 @@ export async function tryDispatchAction(name, input, options = {}) {
|
|
|
194
194
|
}
|
|
195
195
|
return null;
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* The running canonical daemon's base URL and owner token, for CLI commands
|
|
199
|
+
* that call daemon routes other than the action dispatcher.
|
|
200
|
+
*/
|
|
201
|
+
export async function resolveCanonicalDaemonEndpoint(options = {}) {
|
|
202
|
+
const bridgeDeps = deps;
|
|
203
|
+
return resolveCanonicalDaemon(bridgeDeps, {
|
|
204
|
+
autostart: options.autostart ?? true,
|
|
205
|
+
cwd: options.cwd ?? bridgeDeps.cwd(),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/** `fetch`, replaceable in tests through {@link __setCliActionBridgeDepsForTests}. */
|
|
209
|
+
export function cliBridgeFetch() {
|
|
210
|
+
return deps.fetch;
|
|
211
|
+
}
|
|
@@ -95,6 +95,7 @@ import { setActivationBackend } from "./active-projects.js";
|
|
|
95
95
|
import { readOrMintEnvironmentId } from "./environment-identity.js";
|
|
96
96
|
import { captureDaemonProvenance } from "./daemon-provenance.js";
|
|
97
97
|
import { registerLogSecret, setLogIdentity } from "./log.js";
|
|
98
|
+
import { createDaemonPluginSupervisor, pluginsEnabled } from "../plugins/daemon-plugins.js";
|
|
98
99
|
import { canonicalDaemonUrl, getCanonicalDaemonInfoPath, clearCanonicalDaemonInfoIfOwned, clearCanonicalDaemonInfoIfUnchanged, inspectCanonicalDaemonInfo, isCanonicalDaemonAlive, isCanonicalDaemonRecordOwnerProvenDead, probeCanonicalDaemonHealth, probeCanonicalDaemonIdentity, releaseCanonicalDaemonClaim, tryAcquireCanonicalDaemonClaim, writeCanonicalDaemonInfo, matchesCanonicalDaemonPredecessor, } from "./canonical-daemon.js";
|
|
99
100
|
const requireFromHere = createRequire(import.meta.url);
|
|
100
101
|
const DEFAULT_HOSTNAME = "127.0.0.1";
|
|
@@ -502,7 +503,7 @@ function closeWsGoingAway(ws) {
|
|
|
502
503
|
}
|
|
503
504
|
ws.close(1001, reason);
|
|
504
505
|
}
|
|
505
|
-
async function startHttpServer({ sessionName, requestedPort, bindHostname, dir, authToken, localBypassToken, silent, readProjectAuth, tmuxServerProof, daemonIdentity, workspacePaneCreationBackend, workspaceOpenBackend, workspaceOpenHandoffBackend, fleetLifecycleBackend, workspacePromotionBackend, appWindowMutationBackend, workspaceMultiplexerBackend, workspaceRegistry, terminalInventoryRuntime, getTerminalAttachmentRuntime, peekTerminalAttachmentRuntime, paneStreamRuntime, catalogLiveSessions, catalogFleet, fleetPreviewCapture, sessionRuntimeRegistry, serverOwners, }) {
|
|
506
|
+
async function startHttpServer({ sessionName, requestedPort, bindHostname, dir, authToken, localBypassToken, silent, readProjectAuth, tmuxServerProof, daemonIdentity, workspacePaneCreationBackend, workspaceOpenBackend, workspaceOpenHandoffBackend, fleetLifecycleBackend, workspacePromotionBackend, appWindowMutationBackend, workspaceMultiplexerBackend, workspaceRegistry, terminalInventoryRuntime, getTerminalAttachmentRuntime, peekTerminalAttachmentRuntime, paneStreamRuntime, catalogLiveSessions, catalogFleet, fleetPreviewCapture, sessionRuntimeRegistry, serverOwners, pluginBackend, }) {
|
|
506
507
|
const { createApp } = await import("../command-center/server.js");
|
|
507
508
|
const { getRequestListener } = await import(__rewriteRelativeImportExtension(requireFromHere.resolve("@hono/node-server"), true));
|
|
508
509
|
const { AuthService } = await import("./auth/auth-service.js");
|
|
@@ -555,6 +556,7 @@ async function startHttpServer({ sessionName, requestedPort, bindHostname, dir,
|
|
|
555
556
|
catalogLiveSessions,
|
|
556
557
|
catalogFleet,
|
|
557
558
|
fleetPreviewCapture,
|
|
559
|
+
pluginBackend,
|
|
558
560
|
});
|
|
559
561
|
mountTerminalNativeBackingRoute(app, {
|
|
560
562
|
ownerToken: localBypassToken ?? null,
|
|
@@ -1000,6 +1002,19 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1000
1002
|
setFleetFactsObserverDiagnostics(null);
|
|
1001
1003
|
await runtimeTraceWriter?.close(incomplete);
|
|
1002
1004
|
};
|
|
1005
|
+
// Plugins reach the daemon's own routes over loopback with the owner token.
|
|
1006
|
+
const pluginEndpoint = canonicalDaemonUrl("http", bindHostname === "0.0.0.0" || bindHostname === "::" ? "127.0.0.1" : bindHostname, port);
|
|
1007
|
+
// Created now so its routes mount with the server; it spawns nothing until
|
|
1008
|
+
// start(), which runs once this generation is published.
|
|
1009
|
+
const pluginSupervisor = opts.plugins && pluginsEnabled()
|
|
1010
|
+
? createDaemonPluginSupervisor({
|
|
1011
|
+
productVersion,
|
|
1012
|
+
secrets: [localBypassToken, authToken ?? null],
|
|
1013
|
+
endpoint: () => pluginEndpoint ? { baseUrl: pluginEndpoint, ownerToken: localBypassToken } : null,
|
|
1014
|
+
tmux: (args) => fleetFactsTmuxRunner(args, AbortSignal.timeout(5000)),
|
|
1015
|
+
onCatalogChange: () => broadcastResourceChanged({ workspaceName: null, resource: "command-catalog" }, instanceId),
|
|
1016
|
+
})
|
|
1017
|
+
: null;
|
|
1003
1018
|
let startedServer;
|
|
1004
1019
|
try {
|
|
1005
1020
|
const selector = tmuxAuthority.socketSelector;
|
|
@@ -1516,6 +1531,7 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1516
1531
|
setFleetFactsTmuxRunner(fleetFactsTmuxRunner);
|
|
1517
1532
|
startedServer = await startHttpServer({
|
|
1518
1533
|
serverOwners,
|
|
1534
|
+
pluginBackend: pluginSupervisor,
|
|
1519
1535
|
sessionName,
|
|
1520
1536
|
requestedPort: port,
|
|
1521
1537
|
bindHostname,
|
|
@@ -1623,6 +1639,7 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1623
1639
|
return [...transportResults, ...runtimeResults].flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
1624
1640
|
};
|
|
1625
1641
|
const abortStartedServer = async () => {
|
|
1642
|
+
await pluginSupervisor?.stop().catch(() => { });
|
|
1626
1643
|
await serverOwners?.dispose();
|
|
1627
1644
|
setFleetFactsTmuxRunner(null);
|
|
1628
1645
|
const terminalFailures = [
|
|
@@ -1708,6 +1725,11 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1708
1725
|
await abortStartedServer();
|
|
1709
1726
|
throw error;
|
|
1710
1727
|
}
|
|
1728
|
+
// Plugins load after publication, in the background: a slow or broken
|
|
1729
|
+
// plugin never delays or fails daemon startup.
|
|
1730
|
+
void pluginSupervisor?.start().catch((error) => {
|
|
1731
|
+
console.warn(`[daemon] plugins failed to start: ${error.message}`);
|
|
1732
|
+
});
|
|
1711
1733
|
let stopped = false;
|
|
1712
1734
|
let stopping = null;
|
|
1713
1735
|
let stopSelf = null;
|
|
@@ -1872,6 +1894,7 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1872
1894
|
};
|
|
1873
1895
|
try {
|
|
1874
1896
|
stopped = true;
|
|
1897
|
+
await capture(() => pluginSupervisor?.stop());
|
|
1875
1898
|
await capture(() => setActivationBackend(null));
|
|
1876
1899
|
await capture(() => sessionMonitor?.stop());
|
|
1877
1900
|
paneSourceCredentials.dispose();
|
|
@@ -241,6 +241,7 @@ async function runHeadlessDaemonGeneration(options, deps, restoreTmuxWorkspaces,
|
|
|
241
241
|
try {
|
|
242
242
|
handle = await deps.startEmbeddedDaemon({
|
|
243
243
|
launcher: "headless",
|
|
244
|
+
plugins: true,
|
|
244
245
|
...(options.supervisionId
|
|
245
246
|
? { supervisionId: options.supervisionId, predecessor: lifecycle.predecessor }
|
|
246
247
|
: {}),
|