@haywoodmarx/agent-pager 0.1.0
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/src/broker/address.d.ts +49 -0
- package/dist/src/broker/address.js +110 -0
- package/dist/src/broker/broker.d.ts +665 -0
- package/dist/src/broker/broker.js +2270 -0
- package/dist/src/broker/database.d.ts +81 -0
- package/dist/src/broker/database.js +69 -0
- package/dist/src/broker/operator-projection.d.ts +291 -0
- package/dist/src/broker/operator-projection.js +722 -0
- package/dist/src/broker/protocol.d.ts +237 -0
- package/dist/src/broker/protocol.js +311 -0
- package/dist/src/broker/schema.d.ts +94 -0
- package/dist/src/broker/schema.js +454 -0
- package/dist/src/broker/snapshot.d.ts +171 -0
- package/dist/src/broker/snapshot.js +78 -0
- package/dist/src/configuration-defaults.d.ts +64 -0
- package/dist/src/configuration-defaults.js +48 -0
- package/dist/src/configuration.d.ts +76 -0
- package/dist/src/configuration.js +156 -0
- package/dist/src/implementations/claude/environment.d.ts +8 -0
- package/dist/src/implementations/claude/environment.js +9 -0
- package/dist/src/implementations/claude/gateway-cli.d.ts +2 -0
- package/dist/src/implementations/claude/gateway-cli.js +136 -0
- package/dist/src/implementations/claude/gateway-identity.d.ts +134 -0
- package/dist/src/implementations/claude/gateway-identity.js +103 -0
- package/dist/src/implementations/claude/gateway.d.ts +148 -0
- package/dist/src/implementations/claude/gateway.js +236 -0
- package/dist/src/implementations/claude/instructions.d.ts +33 -0
- package/dist/src/implementations/claude/instructions.js +64 -0
- package/dist/src/implementations/claude/manifest.d.ts +33 -0
- package/dist/src/implementations/claude/manifest.js +108 -0
- package/dist/src/implementations/claude/plugin-directory.d.ts +80 -0
- package/dist/src/implementations/claude/plugin-directory.js +137 -0
- package/dist/src/implementations/claude/session-continuation.d.ts +25 -0
- package/dist/src/implementations/claude/session-continuation.js +125 -0
- package/dist/src/implementations/claude/session-identity.d.ts +25 -0
- package/dist/src/implementations/claude/session-identity.js +31 -0
- package/dist/src/implementations/claude/session-start-cli.d.ts +2 -0
- package/dist/src/implementations/claude/session-start-cli.js +16 -0
- package/dist/src/implementations/claude/socket-delivery.d.ts +52 -0
- package/dist/src/implementations/claude/socket-delivery.js +159 -0
- package/dist/src/implementations/model.d.ts +162 -0
- package/dist/src/implementations/model.js +1 -0
- package/dist/src/implementations/opencode/adapter.d.ts +71 -0
- package/dist/src/implementations/opencode/adapter.js +94 -0
- package/dist/src/implementations/opencode/environment.d.ts +8 -0
- package/dist/src/implementations/opencode/environment.js +9 -0
- package/dist/src/implementations/opencode/manifest.d.ts +30 -0
- package/dist/src/implementations/opencode/manifest.js +93 -0
- package/dist/src/implementations/opencode/plugin-api.d.ts +120 -0
- package/dist/src/implementations/opencode/plugin-api.js +1 -0
- package/dist/src/implementations/opencode/plugin.d.ts +38 -0
- package/dist/src/implementations/opencode/plugin.js +303 -0
- package/dist/src/implementations/opencode/self-close-tool.d.ts +9 -0
- package/dist/src/implementations/opencode/self-close-tool.js +31 -0
- package/dist/src/implementations/orca/terminal.d.ts +48 -0
- package/dist/src/implementations/orca/terminal.js +154 -0
- package/dist/src/implementations/pi/broker-client.d.ts +56 -0
- package/dist/src/implementations/pi/broker-client.js +156 -0
- package/dist/src/implementations/pi/environment.d.ts +8 -0
- package/dist/src/implementations/pi/environment.js +9 -0
- package/dist/src/implementations/pi/extension.d.ts +57 -0
- package/dist/src/implementations/pi/extension.js +253 -0
- package/dist/src/implementations/pi/host-slots.d.ts +18 -0
- package/dist/src/implementations/pi/host-slots.js +27 -0
- package/dist/src/implementations/pi/manifest.d.ts +11 -0
- package/dist/src/implementations/pi/manifest.js +61 -0
- package/dist/src/implementations/pi/self-close-tool.d.ts +7 -0
- package/dist/src/implementations/pi/self-close-tool.js +27 -0
- package/dist/src/implementations/registry.d.ts +47 -0
- package/dist/src/implementations/registry.js +157 -0
- package/dist/src/implementations/session-key.d.ts +13 -0
- package/dist/src/implementations/session-key.js +19 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.js +26 -0
- package/dist/src/launch/broker-lock.d.ts +257 -0
- package/dist/src/launch/broker-lock.js +644 -0
- package/dist/src/launch/cli.d.ts +37 -0
- package/dist/src/launch/cli.js +317 -0
- package/dist/src/launch/environment.d.ts +45 -0
- package/dist/src/launch/environment.js +48 -0
- package/dist/src/launch/launch.d.ts +235 -0
- package/dist/src/launch/launch.js +223 -0
- package/dist/src/launch/on-demand.d.ts +202 -0
- package/dist/src/launch/on-demand.js +435 -0
- package/dist/src/launch/runtime-composition.d.ts +88 -0
- package/dist/src/launch/runtime-composition.js +253 -0
- package/dist/src/launch/runtime.d.ts +79 -0
- package/dist/src/launch/runtime.js +196 -0
- package/dist/src/launch/service-system.d.ts +11 -0
- package/dist/src/launch/service-system.js +39 -0
- package/dist/src/launch/service.d.ts +173 -0
- package/dist/src/launch/service.js +492 -0
- package/dist/src/launch/skill.d.ts +57 -0
- package/dist/src/launch/skill.js +81 -0
- package/dist/src/launch/terminal.d.ts +26 -0
- package/dist/src/launch/terminal.js +43 -0
- package/dist/src/launch/workspace-branch.d.ts +10 -0
- package/dist/src/launch/workspace-branch.js +29 -0
- package/dist/src/messaging/delivery-client.d.ts +144 -0
- package/dist/src/messaging/delivery-client.js +261 -0
- package/dist/src/messaging/delivery.d.ts +75 -0
- package/dist/src/messaging/delivery.js +22 -0
- package/dist/src/messaging/inbox-socket.d.ts +98 -0
- package/dist/src/messaging/inbox-socket.js +278 -0
- package/dist/src/messaging/mcp.d.ts +53 -0
- package/dist/src/messaging/mcp.js +501 -0
- package/dist/src/messaging/notifications.d.ts +231 -0
- package/dist/src/messaging/notifications.js +489 -0
- package/dist/src/messaging/push-delivery.d.ts +77 -0
- package/dist/src/messaging/push-delivery.js +187 -0
- package/dist/src/messaging/tools.d.ts +11 -0
- package/dist/src/messaging/tools.js +102 -0
- package/dist/src/messaging/wake.d.ts +23 -0
- package/dist/src/messaging/wake.js +39 -0
- package/dist/src/operator/agent-projection.d.ts +102 -0
- package/dist/src/operator/agent-projection.js +249 -0
- package/dist/src/operator/commands.d.ts +50 -0
- package/dist/src/operator/commands.js +199 -0
- package/dist/src/operator/diagnostics.d.ts +21 -0
- package/dist/src/operator/diagnostics.js +22 -0
- package/dist/src/operator/protocol.d.ts +511 -0
- package/dist/src/operator/protocol.js +49 -0
- package/dist/src/operator/repository-system.d.ts +14 -0
- package/dist/src/operator/repository-system.js +150 -0
- package/dist/src/operator/repository.d.ts +79 -0
- package/dist/src/operator/repository.js +72 -0
- package/dist/src/operator/traffic-projection.d.ts +19 -0
- package/dist/src/operator/traffic-projection.js +229 -0
- package/dist/src/operator/transport.d.ts +87 -0
- package/dist/src/operator/transport.js +549 -0
- package/dist/src/operator/update-store.d.ts +53 -0
- package/dist/src/operator/update-store.js +162 -0
- package/dist/src/operator/updates.d.ts +94 -0
- package/dist/src/operator/updates.js +280 -0
- package/dist/src/operator/validation.d.ts +114 -0
- package/dist/src/operator/validation.js +916 -0
- package/dist/src/shared/guards.d.ts +59 -0
- package/dist/src/shared/guards.js +119 -0
- package/dist/src/shared/http.d.ts +30 -0
- package/dist/src/shared/http.js +50 -0
- package/dist/src/shared/row.d.ts +2 -0
- package/dist/src/shared/row.js +1 -0
- package/dist/src/shared/shell.d.ts +6 -0
- package/dist/src/shared/shell.js +8 -0
- package/dist/src/tui/actions.d.ts +166 -0
- package/dist/src/tui/actions.js +253 -0
- package/dist/src/tui/agent-tree.d.ts +125 -0
- package/dist/src/tui/agent-tree.js +663 -0
- package/dist/src/tui/app.d.ts +38 -0
- package/dist/src/tui/app.js +378 -0
- package/dist/src/tui/chrome.d.ts +86 -0
- package/dist/src/tui/chrome.js +85 -0
- package/dist/src/tui/client.d.ts +41 -0
- package/dist/src/tui/client.js +279 -0
- package/dist/src/tui/composition.d.ts +41 -0
- package/dist/src/tui/composition.js +146 -0
- package/dist/src/tui/message-views.d.ts +94 -0
- package/dist/src/tui/message-views.js +515 -0
- package/dist/src/tui/model.d.ts +414 -0
- package/dist/src/tui/model.js +758 -0
- package/dist/src/tui/presentation.d.ts +350 -0
- package/dist/src/tui/presentation.js +541 -0
- package/dist/src/tui/production.d.ts +79 -0
- package/dist/src/tui/production.js +253 -0
- package/dist/src/tui/run-terminal.d.ts +32 -0
- package/dist/src/tui/run-terminal.js +54 -0
- package/dist/src/tui/runtime.d.ts +113 -0
- package/dist/src/tui/runtime.js +189 -0
- package/dist/src/tui/theme.d.ts +49 -0
- package/dist/src/tui/theme.js +55 -0
- package/dist/src/tui/transport.d.ts +31 -0
- package/dist/src/tui/transport.js +255 -0
- package/dist/src/version.d.ts +11 -0
- package/dist/src/version.js +52 -0
- package/package.json +142 -0
- package/skills/pager/SKILL.md +112 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { skillInstallCommand } from "../launch/skill.js";
|
|
3
|
+
import { useKeyboard, useRenderer } from "@opentui/react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Overlay, PaneBar, Rule } from "./chrome.js";
|
|
6
|
+
import { copyRaw } from "./message-views.js";
|
|
7
|
+
import { stepWrappingIndex } from "./presentation.js";
|
|
8
|
+
import { RunTerminal } from "./run-terminal.js";
|
|
9
|
+
/** Sizes the actions menu, which holds one short label per row. */
|
|
10
|
+
const ACTIONS_OVERLAY_COLUMNS = 34;
|
|
11
|
+
/**
|
|
12
|
+
* Sizes the confirmation overlay.
|
|
13
|
+
*
|
|
14
|
+
* Wide enough to show an indented absolute source path without wrapping.
|
|
15
|
+
*/
|
|
16
|
+
const ACTION_CONFIRM_OVERLAY_COLUMNS = 110;
|
|
17
|
+
/**
|
|
18
|
+
* Installs into the global scope, leaving every other choice to the operator.
|
|
19
|
+
*
|
|
20
|
+
* The child runs in a terminal it can prompt through, so nothing here answers on the operator's
|
|
21
|
+
* behalf.
|
|
22
|
+
*/
|
|
23
|
+
export const SKILL_INSTALL_FLAGS = ["--global"];
|
|
24
|
+
/** Stable empty buffer, so a terminal with no run yet does not see a new array on every render. */
|
|
25
|
+
const NO_CHUNKS = [];
|
|
26
|
+
/** Names every skill action in the menu. */
|
|
27
|
+
export const SKILL_ACTION_LABEL = "Install skills";
|
|
28
|
+
/** Footer keys of the actions menu. A constant, because JSX collapses runs of spaces in inline text. */
|
|
29
|
+
export const ACTIONS_FOOTER_KEYS = "⏎ select";
|
|
30
|
+
/** Columns the child's terminal is told it has, after the frame's border and the body's padding. */
|
|
31
|
+
const RUN_TERMINAL_COLUMNS = ACTION_CONFIRM_OVERLAY_COLUMNS - 4;
|
|
32
|
+
/** Overlay rows the frame, the pane bar, both rules, and the footer occupy, leaving the rest for content. */
|
|
33
|
+
const RUN_OVERLAY_CHROME_ROWS = 6;
|
|
34
|
+
/** Rows the run overlay leaves around itself, so the shell it covers is still visibly there. */
|
|
35
|
+
const RUN_OVERLAY_MARGIN_ROWS = 4;
|
|
36
|
+
/** Fewest rows the run overlay takes, below which a child has no room to draw a question. */
|
|
37
|
+
const RUN_OVERLAY_MINIMUM_ROWS = 12;
|
|
38
|
+
/** Most rows the run overlay takes, beyond which a child gains nothing from the extra height. */
|
|
39
|
+
const RUN_OVERLAY_MAXIMUM_ROWS = 44;
|
|
40
|
+
const NO_RUN_REQUEST = { kind: "none" };
|
|
41
|
+
/**
|
|
42
|
+
* List the actions the operator may start from the menu, in display order.
|
|
43
|
+
*
|
|
44
|
+
* Declared as data so a further action is an entry here rather than a branch in the menu, which
|
|
45
|
+
* never names a specific action.
|
|
46
|
+
* @param catalogue - Skills and harness registrations this build offers.
|
|
47
|
+
* @returns - Every selectable action, in display order.
|
|
48
|
+
*/
|
|
49
|
+
export function operatorActions(catalogue) {
|
|
50
|
+
return [
|
|
51
|
+
...catalogue.skills.map((skill) => ({
|
|
52
|
+
id: `install_skill:${skill.name}`,
|
|
53
|
+
label: SKILL_ACTION_LABEL,
|
|
54
|
+
title: `install ${skill.name}`,
|
|
55
|
+
command: skillActionCommand(skill),
|
|
56
|
+
})),
|
|
57
|
+
...catalogue.registrations.map((registration) => ({
|
|
58
|
+
id: `register_host:${registration.id}`,
|
|
59
|
+
label: "Install plugins",
|
|
60
|
+
title: `install ${registration.label} plugin`,
|
|
61
|
+
command: registration.command,
|
|
62
|
+
})),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build the command that installs one skill.
|
|
67
|
+
* @param skill - Skill the action installs.
|
|
68
|
+
* @returns - Command the action runs.
|
|
69
|
+
*/
|
|
70
|
+
function skillActionCommand(skill) {
|
|
71
|
+
const install = skillInstallCommand(SKILL_INSTALL_FLAGS, skill.source);
|
|
72
|
+
return { ...install, display: [install.command, ...install.args].join(" ") };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Find the action an overlay was opened for.
|
|
76
|
+
* @param id - Action id recorded when the action was selected.
|
|
77
|
+
* @param catalogue - Skills and harness registrations this build offers.
|
|
78
|
+
* @returns - The action, or undefined when this build no longer offers one by that id.
|
|
79
|
+
*/
|
|
80
|
+
export function menuAction(id, catalogue) {
|
|
81
|
+
return operatorActions(catalogue).find((action) => action.id === id);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Reduce one key pressed while an action overlay is open.
|
|
85
|
+
*
|
|
86
|
+
* Pure. `y`, which copies the command before a run, is the one action-overlay key `ActionRunOverlay`
|
|
87
|
+
* answers itself.
|
|
88
|
+
*
|
|
89
|
+
* Escape during a run ends the child at once, without asking again, so the operator can always leave a
|
|
90
|
+
* run that will not finish, including an Escape the operator meant for a prompt of the child's own.
|
|
91
|
+
* @param state - Current model state.
|
|
92
|
+
* @param key - Key name reported by the terminal.
|
|
93
|
+
* @param catalogue - Skills and harness registrations this build offers.
|
|
94
|
+
* @returns - Next view state, unchanged when the key means nothing here, and the run request the key makes.
|
|
95
|
+
*/
|
|
96
|
+
export function reduceOperatorActionsKey(state, key, catalogue) {
|
|
97
|
+
const view = state.view;
|
|
98
|
+
const actions = operatorActions(catalogue);
|
|
99
|
+
const unchanged = { view, request: NO_RUN_REQUEST };
|
|
100
|
+
const close = () => ({
|
|
101
|
+
view: { ...view, focus: view.overlayReturnFocus, overlay: { kind: "none" }, actionIndex: 0 },
|
|
102
|
+
request: { kind: "clear" },
|
|
103
|
+
});
|
|
104
|
+
if (view.overlay.kind === "actions") {
|
|
105
|
+
if (key === "escape")
|
|
106
|
+
return close();
|
|
107
|
+
if (key === "up" || key === "down")
|
|
108
|
+
return {
|
|
109
|
+
view: { ...view, actionIndex: stepWrappingIndex(view.actionIndex, key, actions.length) },
|
|
110
|
+
request: NO_RUN_REQUEST,
|
|
111
|
+
};
|
|
112
|
+
if (key !== "enter" && key !== "return")
|
|
113
|
+
return unchanged;
|
|
114
|
+
const action = actions[view.actionIndex];
|
|
115
|
+
return action
|
|
116
|
+
? { view: { ...view, overlay: { kind: "action_run", actionId: action.id } }, request: NO_RUN_REQUEST }
|
|
117
|
+
: unchanged;
|
|
118
|
+
}
|
|
119
|
+
const opened = view.overlay;
|
|
120
|
+
if (opened.kind !== "action_run")
|
|
121
|
+
return unchanged;
|
|
122
|
+
const action = menuAction(opened.actionId, catalogue);
|
|
123
|
+
if (!action)
|
|
124
|
+
return unchanged;
|
|
125
|
+
const running = state.run?.outcome.kind === "running";
|
|
126
|
+
// A key of its own to run again, so the one that closes the overlay never also repeats the command.
|
|
127
|
+
if (key === "r" && state.run !== null && !running)
|
|
128
|
+
return { view, request: { kind: "start", command: action.command } };
|
|
129
|
+
// The overlay stays open on the outcome of the run Escape ended, and the next Escape leaves.
|
|
130
|
+
if (key === "escape")
|
|
131
|
+
return running ? { view, request: { kind: "cancel" } } : close();
|
|
132
|
+
if (key !== "enter" && key !== "return")
|
|
133
|
+
return unchanged;
|
|
134
|
+
if (state.run === null)
|
|
135
|
+
return { view, request: { kind: "start", command: action.command } };
|
|
136
|
+
// Enter started the run, so the reflex press that dismisses a finished overlay must not repeat a
|
|
137
|
+
// command that writes to the operator's machine; `r` runs it again.
|
|
138
|
+
return running ? unchanged : close();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Render the operator actions menu.
|
|
142
|
+
* @param properties - Described on each property below.
|
|
143
|
+
* @returns Overlay centred over the shell, listing the packaged skills first and then each registration.
|
|
144
|
+
*/
|
|
145
|
+
export function ActionsOverlay({ actionIndex, catalogue, theme, onSelect, }) {
|
|
146
|
+
return (_jsxs(Overlay, { theme: theme, width: ACTIONS_OVERLAY_COLUMNS, children: [_jsx(PaneBar, { left: _jsx("text", { fg: theme.structure.emphasis, children: "Menu" }), right: _jsx("text", { fg: theme.structure.rulesAndLabels, children: "esc" }) }), _jsx(Rule, { theme: theme }), _jsx("box", { flexDirection: "column", children: operatorActions(catalogue).map((action, index) => (_jsx("box", { height: 1, paddingLeft: 1, paddingRight: 1, ...(index === actionIndex ? { backgroundColor: theme.structure.selection.background } : {}), onMouseDown: () => {
|
|
147
|
+
onSelect(action);
|
|
148
|
+
}, children: _jsx("text", { fg: index === actionIndex ? theme.structure.selection.text : theme.structure.bodyText, children: action.label }) }, action.id))) }), _jsx(Rule, { theme: theme }), _jsx(PaneBar, { left: _jsx("text", { fg: theme.structure.rulesAndLabels, children: ACTIONS_FOOTER_KEYS }), right: null })] }));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Describe a run in the words the title bar uses.
|
|
152
|
+
* @param run - Current run, or null before one has started.
|
|
153
|
+
* @returns - Short status shown beside the overlay title.
|
|
154
|
+
*/
|
|
155
|
+
function skillInstallStatus(run) {
|
|
156
|
+
if (run === null)
|
|
157
|
+
return "ready";
|
|
158
|
+
const dropped = run.truncated ? " earlier output dropped" : "";
|
|
159
|
+
switch (run.outcome.kind) {
|
|
160
|
+
case "running":
|
|
161
|
+
return run.truncated ? "running earlier output dropped" : "running";
|
|
162
|
+
case "failed":
|
|
163
|
+
return `failed ${run.outcome.reason}${dropped}`;
|
|
164
|
+
case "cancelled":
|
|
165
|
+
return `cancelled${dropped}`;
|
|
166
|
+
case "exited":
|
|
167
|
+
// "complete" says the command finished, not that everything it attempted worked: this CLI exits
|
|
168
|
+
// zero having reported some of its own installations as failed, so only its output says that.
|
|
169
|
+
return run.outcome.code === 0 ? `complete${dropped}` : `failed exit ${String(run.outcome.code)}${dropped}`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Describe the keys available in the words the footer uses.
|
|
174
|
+
* @param run - Current run, or null before one has started.
|
|
175
|
+
* @param copyStatus - Outcome of the operator's last copy, or null if they have not asked for one.
|
|
176
|
+
* @returns - Footer key hints for the run's current state.
|
|
177
|
+
*/
|
|
178
|
+
function skillInstallFooterKeys(run, copyStatus) {
|
|
179
|
+
// A running child holds every key the overlay would otherwise offer, apart from the one that ends it.
|
|
180
|
+
if (run?.outcome.kind === "running")
|
|
181
|
+
return "esc cancel";
|
|
182
|
+
if (run !== null)
|
|
183
|
+
return "⏎ close r rerun";
|
|
184
|
+
if (copyStatus !== null)
|
|
185
|
+
return copyStatus === "unavailable" ? "copy unavailable" : "command copied";
|
|
186
|
+
return "⏎ run y copy";
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Colour the outcome so a clean exit and a failure read as such without being read. No run yet, a run
|
|
190
|
+
* still going, and a cancelled run share the neutral colour; only the status text tells them apart.
|
|
191
|
+
*
|
|
192
|
+
* Green marks a zero exit, which says the command finished and nothing more; see `skillInstallStatus`.
|
|
193
|
+
* @param run - Current run, or null before one has started.
|
|
194
|
+
* @param theme - Semantic palette the surface draws from.
|
|
195
|
+
* @returns - Colour for the status shown beside the title.
|
|
196
|
+
*/
|
|
197
|
+
export function skillInstallStatusColor(run, theme) {
|
|
198
|
+
if (run === null)
|
|
199
|
+
return theme.structure.rulesAndLabels;
|
|
200
|
+
switch (run.outcome.kind) {
|
|
201
|
+
case "running":
|
|
202
|
+
case "cancelled":
|
|
203
|
+
return theme.structure.rulesAndLabels;
|
|
204
|
+
case "failed":
|
|
205
|
+
return theme.states.failed;
|
|
206
|
+
case "exited":
|
|
207
|
+
return run.outcome.code === 0 ? theme.states.complete : theme.states.failed;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Report the terminal the install's child is given.
|
|
212
|
+
*
|
|
213
|
+
* The child lays its output out for this size, and the emulator that renders that output is built to
|
|
214
|
+
* match, so the two must be read from here rather than each deciding for itself.
|
|
215
|
+
* @param terminalRows - Rows the whole terminal has.
|
|
216
|
+
* @returns - Columns and rows of the run overlay's terminal.
|
|
217
|
+
*/
|
|
218
|
+
export function skillInstallTerminalSize(terminalRows) {
|
|
219
|
+
return { columns: RUN_TERMINAL_COLUMNS, rows: skillInstallOverlayRows(terminalRows) - RUN_OVERLAY_CHROME_ROWS };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Report how tall the run overlay is on a terminal of a given height.
|
|
223
|
+
*
|
|
224
|
+
* The child draws a question the operator has to answer, and a selection list shows only as many
|
|
225
|
+
* options as it has rows, so the overlay takes what the terminal can spare rather than a fixed size.
|
|
226
|
+
* @param terminalRows - Rows the whole terminal has.
|
|
227
|
+
* @returns - Rows the overlay occupies, including its frame.
|
|
228
|
+
*/
|
|
229
|
+
function skillInstallOverlayRows(terminalRows) {
|
|
230
|
+
const available = terminalRows - RUN_OVERLAY_MARGIN_ROWS;
|
|
231
|
+
return Math.max(RUN_OVERLAY_MINIMUM_ROWS, Math.min(RUN_OVERLAY_MAXIMUM_ROWS, available));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Render one action's run: its command, its terminal, its outcome, and the keys it answers.
|
|
235
|
+
* @param properties - Described on each property below.
|
|
236
|
+
* @returns The run overlay, or nothing when this build no longer offers the action.
|
|
237
|
+
*/
|
|
238
|
+
export function ActionRunOverlay({ run, actionId, catalogue, terminalRows, copyFallback, onInput, onResize, theme, }) {
|
|
239
|
+
const action = menuAction(actionId, catalogue);
|
|
240
|
+
const size = skillInstallTerminalSize(terminalRows);
|
|
241
|
+
const renderer = useRenderer();
|
|
242
|
+
const [copyStatus, setCopyStatus] = useState(null);
|
|
243
|
+
useKeyboard((key) => {
|
|
244
|
+
// Only before a run: once the command has been given a terminal here, copying it for another one
|
|
245
|
+
// has no purpose.
|
|
246
|
+
if (key.name !== "y" || run !== null || !action)
|
|
247
|
+
return;
|
|
248
|
+
setCopyStatus(copyRaw(renderer, action.command.display, copyFallback));
|
|
249
|
+
});
|
|
250
|
+
if (!action)
|
|
251
|
+
return null;
|
|
252
|
+
return (_jsxs(Overlay, { theme: theme, width: ACTION_CONFIRM_OVERLAY_COLUMNS, height: skillInstallOverlayRows(terminalRows), children: [_jsx(PaneBar, { left: _jsx("text", { fg: theme.structure.emphasis, children: action.title }), right: _jsx("text", { fg: skillInstallStatusColor(run, theme), children: skillInstallStatus(run) }) }), _jsx(Rule, { theme: theme }), _jsx("box", { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: _jsx(RunTerminal, { preamble: `$ ${action.command.display}\r\n`, chunks: run?.chunks ?? NO_CHUNKS, received: run?.received ?? 0, columns: size.columns, rows: size.rows, live: run?.outcome.kind === "running", dimmed: run !== null && run.outcome.kind !== "running", onInput: onInput, onResize: onResize }, run?.id ?? 0) }), _jsx(Rule, { theme: theme }), _jsx(PaneBar, { left: _jsx("text", { fg: theme.structure.rulesAndLabels, children: skillInstallFooterKeys(run, copyStatus) }), right: null })] }));
|
|
253
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { AgentId } from "../broker/protocol.js";
|
|
2
|
+
import type { OperatorAgent, OperatorCommand, OperatorRepository } from "../operator/protocol.js";
|
|
3
|
+
import type { TuiOperatorModel, TuiOperatorModelState, TuiOperatorViewState } from "./model.js";
|
|
4
|
+
import type { TuiTheme } from "./theme.js";
|
|
5
|
+
/** Agent rows grouped by their projected repository without creating broker scope. */
|
|
6
|
+
export type TuiRepositoryAgentGroup = {
|
|
7
|
+
/** Projected repository shown by this group. */
|
|
8
|
+
readonly repository: OperatorRepository;
|
|
9
|
+
/** Active agents in registration order. */
|
|
10
|
+
readonly active: readonly OperatorAgent[];
|
|
11
|
+
/** Agents `isOperatorAgentArchived` places in the archive section, in registration order. */
|
|
12
|
+
readonly archived: readonly OperatorAgent[];
|
|
13
|
+
};
|
|
14
|
+
/** One focusable action offered for a selected agent row. */
|
|
15
|
+
export type TuiAgentContextAction = "ping" | "details" | "archive" | "collapse";
|
|
16
|
+
/** One focusable action offered for a selected workspace row. */
|
|
17
|
+
export type TuiWorkspaceContextAction = "hide" | "unhide";
|
|
18
|
+
/** A keyboard-reachable projected tree row. */
|
|
19
|
+
export type TuiAgentTreeRow = {
|
|
20
|
+
readonly kind: "workspace";
|
|
21
|
+
readonly repositoryId: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "agent";
|
|
24
|
+
readonly agentId: AgentId;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: "archived";
|
|
27
|
+
readonly repositoryId: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "hidden";
|
|
30
|
+
};
|
|
31
|
+
/** Supplies the agent-tree presentation with model state and command delegates. */
|
|
32
|
+
export type AgentTreeProps = {
|
|
33
|
+
/** Renderer-independent state owner. */
|
|
34
|
+
readonly model: TuiOperatorModel;
|
|
35
|
+
/** Semantic terminal palette. */
|
|
36
|
+
readonly theme: Readonly<TuiTheme>;
|
|
37
|
+
/** Submits the broker command a tree action raised, a ping or an archive. */
|
|
38
|
+
readonly onCommand: (command: OperatorCommand) => void;
|
|
39
|
+
/** Enables terminal colours without changing textual distinctions. */
|
|
40
|
+
readonly colorEnabled?: boolean;
|
|
41
|
+
/** Character columns the pane gives the tree, including its one-column insets. */
|
|
42
|
+
readonly width?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Group projected agents under their projected repositories in stable registration order.
|
|
46
|
+
* @param snapshot - Authoritative projection currently installed by the client model.
|
|
47
|
+
* @returns Repository groups suitable for the tree presentation.
|
|
48
|
+
*/
|
|
49
|
+
export declare function selectTuiRepositoryAgentGroups(snapshot: TuiOperatorModelState["snapshot"]): readonly TuiRepositoryAgentGroup[];
|
|
50
|
+
/**
|
|
51
|
+
* Report whether one workspace's archive section is open: its stored preference, or else its default.
|
|
52
|
+
* @param view - Local view state holding the operator's archive preferences.
|
|
53
|
+
* @param group - Repository and its agents, already split by archive membership.
|
|
54
|
+
* @returns - Whether the section shows its agents.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isTuiArchivedSectionOpen(view: TuiOperatorViewState, group: TuiRepositoryAgentGroup): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Report whether a workspace is archived, which is to say every conversation in it is.
|
|
59
|
+
* @param group - Repository and its agents, already split by archive membership.
|
|
60
|
+
* @returns - Whether the workspace holds archived agents and no others.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isArchivedGroup(group: TuiRepositoryAgentGroup): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Select visible rows in tree order from model-owned expansion state.
|
|
65
|
+
* @param state - Current projection and local view state.
|
|
66
|
+
* @returns Rows available to keyboard navigation.
|
|
67
|
+
*/
|
|
68
|
+
export declare function selectVisibleTuiAgentTreeRows(state: TuiOperatorModelState): readonly TuiAgentTreeRow[];
|
|
69
|
+
/**
|
|
70
|
+
* Report the workspace or archive section a tree selection can expand and collapse.
|
|
71
|
+
* @param state - Current authoritative projection and local presentation state.
|
|
72
|
+
* @returns The collapsible row's kind and repository, or null when the selection cannot collapse.
|
|
73
|
+
*/
|
|
74
|
+
export declare function selectTuiCollapsibleSelection(state: TuiOperatorModelState): {
|
|
75
|
+
readonly kind: "workspace" | "archived";
|
|
76
|
+
readonly repositoryId: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/** The renderer-independent result of one tree keyboard command. */
|
|
79
|
+
export type TuiAgentTreeKeyResult = {
|
|
80
|
+
/** Next model-owned presentation state. */
|
|
81
|
+
readonly view: TuiOperatorModelState["view"];
|
|
82
|
+
/** Broker-owned command this result asks the shell to submit. */
|
|
83
|
+
readonly command?: OperatorCommand;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Execute one already-reduced tree result through the model and broker delegate.
|
|
87
|
+
* @param model - Model that owns the local view state.
|
|
88
|
+
* @param onCommand - Submits a broker-owned command on the tree's behalf.
|
|
89
|
+
* @param result - Reducer result shared by keyboard and pointer actions.
|
|
90
|
+
*/
|
|
91
|
+
export declare function executeAgentTreeResult(model: TuiOperatorModel, onCommand: (command: OperatorCommand) => void, result: TuiAgentTreeKeyResult): void;
|
|
92
|
+
/**
|
|
93
|
+
* Reduce a context-menu action for both keyboard and pointer activation.
|
|
94
|
+
* @param state - Current authoritative facts and local view state.
|
|
95
|
+
* @param action - Context action selected by the user.
|
|
96
|
+
* @returns The next local view and optional broker ping request.
|
|
97
|
+
*/
|
|
98
|
+
export declare function reduceAgentTreeContextAction(state: TuiOperatorModelState, action: TuiAgentContextAction): TuiAgentTreeKeyResult;
|
|
99
|
+
/**
|
|
100
|
+
* Reduce one keyboard command without depending on an OpenTUI input source.
|
|
101
|
+
* @param state - Current authoritative projection and local presentation state.
|
|
102
|
+
* @param key - Normalized OpenTUI key name.
|
|
103
|
+
* @returns The next model-owned view and an optional broker command, a ping or an archive.
|
|
104
|
+
*/
|
|
105
|
+
export declare function reduceAgentTreeKey(state: TuiOperatorModelState, key: string): TuiAgentTreeKeyResult;
|
|
106
|
+
/**
|
|
107
|
+
* Render projected repositories, agents, archive sections, identity, and row actions.
|
|
108
|
+
* @param properties - Model, palette, and broker command delegate.
|
|
109
|
+
* @returns OpenTUI terminal presentation for the agent tree.
|
|
110
|
+
*/
|
|
111
|
+
export declare function AgentTree({ model, theme, onCommand, colorEnabled, width, }: AgentTreeProps): import("react").ReactNode;
|
|
112
|
+
/**
|
|
113
|
+
* Render the tree-owned modal at the terminal root rather than inside the fixed pane.
|
|
114
|
+
* @param properties - Model state and palette shared with the agent-tree pane.
|
|
115
|
+
* @returns The overlay the tree owns for the current view state, or nothing when the open overlay is not the tree's.
|
|
116
|
+
*/
|
|
117
|
+
export declare function AgentTreeOverlay({ model, theme, onCommand, colorEnabled }: AgentTreeProps): import("react").ReactNode;
|
|
118
|
+
/** Keys a row-action menu advertises in its footer. */
|
|
119
|
+
export declare const CONTEXT_FOOTER_KEYS = "\u23CE select";
|
|
120
|
+
/**
|
|
121
|
+
* List the actions offered for the workspace the menu was opened on.
|
|
122
|
+
* @param state - Current model state, holding what is hidden.
|
|
123
|
+
* @returns - The one action that applies, in a list so the menu never names a specific action.
|
|
124
|
+
*/
|
|
125
|
+
export declare function workspaceContextActions(state: TuiOperatorModelState): readonly TuiWorkspaceContextAction[];
|