@cotal-ai/cli 0.9.0 → 0.10.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/dist/command.d.ts +12 -3
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +58 -11
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +64 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +83 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/channels.d.ts +2 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +3 -16
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/completion.d.ts +6 -5
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +37 -14
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/console.d.ts +2 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +2 -12
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/down.d.ts +3 -2
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +4 -12
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/ext.d.ts +18 -0
- package/dist/commands/ext.d.ts.map +1 -0
- package/dist/commands/ext.js +220 -0
- package/dist/commands/ext.js.map +1 -0
- package/dist/commands/feedback.d.ts +2 -2
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +4 -283
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/history.d.ts +2 -1
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +3 -13
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts +2 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +2 -18
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes.d.ts +2 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +1 -1
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts +2 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +3 -14
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/personas.d.ts +2 -2
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +23 -20
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/send.d.ts +2 -2
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +21 -24
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/setup.d.ts +30 -8
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +151 -316
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/spawn.d.ts +117 -2
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +137 -48
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/topology.d.ts +2 -1
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +4 -8
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/up.d.ts +9 -4
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +96 -56
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/use.d.ts +2 -2
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +2 -2
- package/dist/commands/use.js.map +1 -1
- package/dist/ext-loader.d.ts +13 -0
- package/dist/ext-loader.d.ts.map +1 -0
- package/dist/ext-loader.js +121 -0
- package/dist/ext-loader.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -70
- package/dist/index.js.map +1 -1
- package/dist/lib/attach-client.d.ts +20 -0
- package/dist/lib/attach-client.d.ts.map +1 -0
- package/dist/lib/attach-client.js +218 -0
- package/dist/lib/attach-client.js.map +1 -0
- package/dist/lib/completion.d.ts +8 -0
- package/dist/lib/completion.d.ts.map +1 -0
- package/dist/lib/completion.js +66 -0
- package/dist/lib/completion.js.map +1 -0
- package/dist/lib/connect.d.ts +1 -73
- package/dist/lib/connect.d.ts.map +1 -1
- package/dist/lib/connect.js +4 -90
- package/dist/lib/connect.js.map +1 -1
- package/dist/lib/control.d.ts +34 -0
- package/dist/lib/control.d.ts.map +1 -0
- package/dist/lib/control.js +65 -0
- package/dist/lib/control.js.map +1 -0
- package/dist/lib/delivery-proc.d.ts +2 -0
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.d.ts +5 -13
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +3 -42
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/live.d.ts.map +1 -1
- package/dist/lib/manifest/live.js +4 -1
- package/dist/lib/manifest/live.js.map +1 -1
- package/dist/lib/status.d.ts +8 -4
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +21 -5
- package/dist/lib/status.js.map +1 -1
- package/dist/ui.d.ts +1 -12
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +4 -12
- package/dist/ui.js.map +1 -1
- package/package.json +8 -6
- package/dist/commands/demo.d.ts +0 -2
- package/dist/commands/demo.d.ts.map +0 -1
- package/dist/commands/demo.js +0 -163
- package/dist/commands/demo.js.map +0 -1
- package/dist/commands/web.d.ts +0 -32
- package/dist/commands/web.d.ts.map +0 -1
- package/dist/commands/web.js +0 -307
- package/dist/commands/web.js.map +0 -1
- package/dist/web/app.js +0 -823
- package/dist/web/graph.html +0 -207
- package/dist/web/graph.js +0 -512
- package/dist/web/index.html +0 -350
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
import { c } from "../ui.js";
|
|
3
|
+
/**
|
|
4
|
+
* The detach key — Ctrl-] (0x1d) by default, as in telnet/ssh escape conventions. `COTAL_DETACH_KEY`
|
|
5
|
+
* rebinds it to another control key when Ctrl-] clashes with a keybinding inside the agent's TUI;
|
|
6
|
+
* accepts `ctrl-<char>` or `^<char>` (e.g. `ctrl-b`, `^_`). Read at point of use, per the repo's
|
|
7
|
+
* `COTAL_*` convention. An unparseable value — including a set-but-empty or whitespace-only one —
|
|
8
|
+
* throws (named), never silently falling back; the caller turns that into a loud exit. Only an
|
|
9
|
+
* unset var = the Ctrl-] default.
|
|
10
|
+
*/
|
|
11
|
+
export function detachKey() {
|
|
12
|
+
const spec = process.env.COTAL_DETACH_KEY;
|
|
13
|
+
if (spec === undefined)
|
|
14
|
+
return { byte: 0x1d, label: "Ctrl-]", overridden: false };
|
|
15
|
+
const m = /^(?:ctrl-|\^)([a-z@[\\\]^_])$/i.exec(spec.trim());
|
|
16
|
+
if (!m) {
|
|
17
|
+
throw new Error(`invalid COTAL_DETACH_KEY "${spec}" — expected ctrl-<char> or ^<char> for a control key ` +
|
|
18
|
+
`(a-z, or one of @ [ \\ ] ^ _), e.g. ctrl-b`);
|
|
19
|
+
}
|
|
20
|
+
const ch = m[1].toUpperCase();
|
|
21
|
+
return { byte: ch.charCodeAt(0) & 0x1f, label: `Ctrl-${ch}`, overridden: true };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Terminal modes a full-screen child (a fullscreen TUI: OpenCode, or Claude under `/tui fullscreen`)
|
|
25
|
+
* commonly turns on but that we must undo locally on detach/exit: the agent keeps running after
|
|
26
|
+
* Ctrl-], so it never restores OUR terminal. Without this, detaching from a mouse-tracking TUI leaves
|
|
27
|
+
* the terminal reporting every cursor move as input (a stream of `ESC[<…M` escape codes), or its
|
|
28
|
+
* focus in/out as `ESC[I`/`ESC[O`. Disables all mouse-report modes + focus reporting + bracketed
|
|
29
|
+
* paste, resets the keypad/cursor-key modes, shows the cursor, and resets attributes. Leaving the
|
|
30
|
+
* alternate screen is handled separately (ALT_LEAVE_SEQ), only when we actually entered it — see
|
|
31
|
+
* cleanup().
|
|
32
|
+
*/
|
|
33
|
+
const MOUSE_OFF = "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1005l\x1b[?1006l\x1b[?1015l"; // all mouse tracking off
|
|
34
|
+
const RESTORE = MOUSE_OFF +
|
|
35
|
+
"\x1b[?1004l" + // focus reporting off
|
|
36
|
+
"\x1b[?2004l" + // bracketed paste off
|
|
37
|
+
"\x1b[?1l" + // application cursor keys off (DECCKM): a full-screen TUI enables it; left on, arrows emit ESC O A not ESC [ A
|
|
38
|
+
"\x1b>" + // keypad → numeric (DECKPNM)
|
|
39
|
+
"\x1b[?25h" + // show cursor
|
|
40
|
+
"\x1b[0m"; // reset attributes
|
|
41
|
+
// Leave the alternate screen on detach, but ONLY if the child put us there (altScreen). The attach
|
|
42
|
+
// snapshot faithfully re-enters the child's alt-screen (`?1049h`) on our terminal; without a matching
|
|
43
|
+
// leave we strand it in the alt buffer, which has no scrollback and — with xterm alt-scroll — turns
|
|
44
|
+
// the wheel into ↑/↓ that walk shell history. Leaving the alt buffer IS the whole fix: alt-scroll
|
|
45
|
+
// (`?1007`) only acts inside the alt buffer, so `?1049l` alone makes it inert. We deliberately don't
|
|
46
|
+
// send `?1007l` — nothing on this path ever enabled it (unlike console.ts, which sets `?1007h` on
|
|
47
|
+
// entry), so disabling it would clobber the operator's own alternate-scroll preference for later apps.
|
|
48
|
+
const ALT_LEAVE_SEQ = "\x1b[?1049l"; // leave alt-screen — alt-scroll is inert once back in the main buffer
|
|
49
|
+
// Wheel-scroll for full-screen children. A fullscreen TUI (OpenCode, or Claude under `/tui
|
|
50
|
+
// fullscreen`) runs in the alternate screen — where the terminal's native scrollback is dead — and
|
|
51
|
+
// scrolls its content itself off mouse reports. But it enables that mouse capture on ITS pty, and the
|
|
52
|
+
// enable doesn't reliably survive the attach hop (backlog eviction / nested pty), so our terminal
|
|
53
|
+
// never reports the wheel and scrolling dies. So while the child is in the alternate screen we enable
|
|
54
|
+
// SGR mouse reporting on OUR terminal and translate each wheel tick into PageUp/PageDown — the
|
|
55
|
+
// keystrokes a fullscreen TUI treats as "scroll the view" (OpenCode: `messages_page_up`/`_down`;
|
|
56
|
+
// Claude's fullscreen binds PageUp/PageDown too). A child in the normal screen (inline Claude) keeps
|
|
57
|
+
// altScreen=false, so this stays off and its native terminal-scrollback wheel is untouched.
|
|
58
|
+
const MOUSE_ON = "\x1b[?1002h\x1b[?1006h"; // button+drag tracking, SGR encoding
|
|
59
|
+
const PAGE_UP = "\x1b[5~";
|
|
60
|
+
const PAGE_DOWN = "\x1b[6~";
|
|
61
|
+
// Enter/leave the alternate screen: xterm `?1049`, plus the older `?1047`/`?47`.
|
|
62
|
+
const ALT_ENTER = /\x1b\[\?(?:1049|1047|47)h/g;
|
|
63
|
+
const ALT_LEAVE = /\x1b\[\?(?:1049|1047|47)l/g;
|
|
64
|
+
// A complete SGR mouse report: `ESC [ < btn ; col ; row (M|m)`.
|
|
65
|
+
const SGR_MOUSE = /^\x1b\[<(\d+);\d+;\d+[Mm]/;
|
|
66
|
+
const lastIndexOfRe = (re, s) => {
|
|
67
|
+
re.lastIndex = 0;
|
|
68
|
+
let last = -1;
|
|
69
|
+
for (let m = re.exec(s); m; m = re.exec(s))
|
|
70
|
+
last = m.index;
|
|
71
|
+
return last;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Drive a manager's attach endpoint from the terminal: raw-mode stdin streams to
|
|
75
|
+
* the PTY, PTY output streams to stdout, and SIGWINCH-style resizes are forwarded.
|
|
76
|
+
* The detach key (Ctrl-] by default, {@link detachKey}) detaches without killing the agent.
|
|
77
|
+
*/
|
|
78
|
+
export function attachClient(url) {
|
|
79
|
+
// Resolve the detach key before connecting so a bad COTAL_DETACH_KEY fails loudly up front
|
|
80
|
+
// (matching the manager's other fail-fast exits) instead of after an attach we'd only tear down.
|
|
81
|
+
let detach;
|
|
82
|
+
try {
|
|
83
|
+
detach = detachKey();
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
console.error(c.red(`✗ ${e.message}`));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
const ws = new WebSocket(url);
|
|
91
|
+
const stdin = process.stdin;
|
|
92
|
+
const wasRaw = stdin.isRaw ?? false;
|
|
93
|
+
// A broken local pipe (terminal closed / SIGHUP) makes stdout writes async-error on a later
|
|
94
|
+
// tick; with no listener that EPIPE/EIO becomes an uncaughtException — crashing on the per-frame
|
|
95
|
+
// PTY write or the on-detach restore write. Register a no-op listener once here (not in cleanup,
|
|
96
|
+
// so it outlives the async error tick) to turn it into a handled no-op.
|
|
97
|
+
process.stdout.on("error", () => { });
|
|
98
|
+
// Wheel-scroll state (see MOUSE_ON above): whether the child is in the alternate screen, and a
|
|
99
|
+
// buffer for an SGR mouse report split across stdin reads.
|
|
100
|
+
let altScreen = false;
|
|
101
|
+
let mouseBuf = "";
|
|
102
|
+
// Carry the tail of the previous output frame so an alt-screen escape split across ws frames
|
|
103
|
+
// (e.g. `ESC[?10` then `49h`) is still detected; 16 bytes covers these private-mode sequences.
|
|
104
|
+
// Acting only on state *change* below makes re-scanning the carried bytes idempotent.
|
|
105
|
+
let scanTail = "";
|
|
106
|
+
// Track the child's alt-screen transitions in its output so we can arm/disarm wheel translation.
|
|
107
|
+
const trackAltScreen = (data) => {
|
|
108
|
+
const s = scanTail + data.toString("latin1");
|
|
109
|
+
scanTail = s.slice(-16);
|
|
110
|
+
const enter = lastIndexOfRe(ALT_ENTER, s);
|
|
111
|
+
const leave = lastIndexOfRe(ALT_LEAVE, s);
|
|
112
|
+
if (enter === -1 && leave === -1)
|
|
113
|
+
return;
|
|
114
|
+
const nowAlt = enter > leave;
|
|
115
|
+
if (nowAlt === altScreen)
|
|
116
|
+
return;
|
|
117
|
+
altScreen = nowAlt;
|
|
118
|
+
if (altScreen) {
|
|
119
|
+
if (process.stdout.isTTY)
|
|
120
|
+
process.stdout.write(MOUSE_ON);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// Leaving alt-screen mid-session: undo the mouse modes WE enabled so the terminal stops
|
|
124
|
+
// reporting the wheel/clicks and native scrollback works again — don't wait for detach.
|
|
125
|
+
mouseBuf = "";
|
|
126
|
+
if (process.stdout.isTTY)
|
|
127
|
+
process.stdout.write(MOUSE_OFF);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const sendResize = () => ws.send(`r:${process.stdout.columns ?? 80},${process.stdout.rows ?? 24}`);
|
|
131
|
+
const onInput = (d) => {
|
|
132
|
+
if (d.length === 1 && d[0] === detach.byte) {
|
|
133
|
+
ws.close();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Inline child: forward keystrokes raw (its wheel scrolls the local terminal, not the app).
|
|
137
|
+
if (!altScreen) {
|
|
138
|
+
ws.send(d);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Full-screen child: rewrite wheel reports to PageUp/PageDown, pass everything else through.
|
|
142
|
+
mouseBuf += d.toString("latin1");
|
|
143
|
+
let out = "";
|
|
144
|
+
for (;;) {
|
|
145
|
+
const i = mouseBuf.indexOf("\x1b[<");
|
|
146
|
+
if (i === -1) {
|
|
147
|
+
// A report split right before `<` (`ESC[` now, `<…M` next) would slip through untranslated:
|
|
148
|
+
// hold a trailing `ESC[` for the next read. Never hold a bare trailing `ESC` — that's the
|
|
149
|
+
// Escape key and must forward at once (e.g. OpenCode's interrupt); the rarer `ESC`|`[<…`
|
|
150
|
+
// split stays raw by design.
|
|
151
|
+
const keep = mouseBuf.endsWith("\x1b[") ? 2 : 0;
|
|
152
|
+
out += mouseBuf.slice(0, mouseBuf.length - keep);
|
|
153
|
+
mouseBuf = mouseBuf.slice(mouseBuf.length - keep);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
out += mouseBuf.slice(0, i);
|
|
157
|
+
const rest = mouseBuf.slice(i);
|
|
158
|
+
const m = SGR_MOUSE.exec(rest);
|
|
159
|
+
if (!m) {
|
|
160
|
+
// Hold only a still-valid partial report (`ESC[<` + digits/semicolons) for the next read;
|
|
161
|
+
// anything else can't become an SGR mouse report, so pass it straight through.
|
|
162
|
+
if (/^\x1b\[<[\d;]*$/.test(rest))
|
|
163
|
+
mouseBuf = rest;
|
|
164
|
+
else {
|
|
165
|
+
out += rest;
|
|
166
|
+
mouseBuf = "";
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
const btn = Number(m[1]);
|
|
171
|
+
if (btn & 0x40)
|
|
172
|
+
out += btn & 1 ? PAGE_DOWN : PAGE_UP; // wheel: 64=up, 65=down
|
|
173
|
+
else
|
|
174
|
+
out += m[0]; // other mouse (click/drag): forward raw so the TUI still gets it
|
|
175
|
+
mouseBuf = rest.slice(m[0].length);
|
|
176
|
+
}
|
|
177
|
+
if (out)
|
|
178
|
+
ws.send(Buffer.from(out, "latin1"));
|
|
179
|
+
};
|
|
180
|
+
const cleanup = () => {
|
|
181
|
+
stdin.off("data", onInput);
|
|
182
|
+
process.stdout.off("resize", sendResize);
|
|
183
|
+
// Undo terminal modes the (still-running) agent's TUI enabled — it won't restore us on detach.
|
|
184
|
+
// If the child put us in its alternate screen (altScreen), leave it too so the terminal isn't
|
|
185
|
+
// stranded in the alt buffer; an inline child (altScreen=false) keeps its scrollback.
|
|
186
|
+
if (process.stdout.isTTY)
|
|
187
|
+
process.stdout.write(RESTORE + (altScreen ? ALT_LEAVE_SEQ : ""));
|
|
188
|
+
if (stdin.isTTY)
|
|
189
|
+
stdin.setRawMode(wasRaw);
|
|
190
|
+
stdin.pause();
|
|
191
|
+
};
|
|
192
|
+
ws.on("open", () => {
|
|
193
|
+
// Make an override visible (the CLI's "attached to X — Ctrl-] to detach" hint still prints the
|
|
194
|
+
// default label). Only on override, so the default case stays free of duplicate noise.
|
|
195
|
+
if (detach.overridden)
|
|
196
|
+
console.error(c.dim(`detach key: ${detach.label} (via COTAL_DETACH_KEY)`));
|
|
197
|
+
if (stdin.isTTY)
|
|
198
|
+
stdin.setRawMode(true);
|
|
199
|
+
stdin.resume();
|
|
200
|
+
sendResize();
|
|
201
|
+
process.stdout.on("resize", sendResize);
|
|
202
|
+
stdin.on("data", onInput);
|
|
203
|
+
});
|
|
204
|
+
ws.on("message", (data) => {
|
|
205
|
+
trackAltScreen(data);
|
|
206
|
+
process.stdout.write(data);
|
|
207
|
+
});
|
|
208
|
+
ws.on("close", () => {
|
|
209
|
+
cleanup();
|
|
210
|
+
resolve();
|
|
211
|
+
});
|
|
212
|
+
ws.on("error", (e) => {
|
|
213
|
+
cleanup();
|
|
214
|
+
reject(e);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=attach-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attach-client.js","sourceRoot":"","sources":["../../src/lib/attach-client.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAClF,MAAM,CAAC,GAAG,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,wDAAwD;YACvF,4CAA4C,CAC/C,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;GASG;AACH,MAA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AAE,OAAO,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE;YAChC,cAAc,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YAClB,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnB,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FlagSpec } from "@cotal-ai/core";
|
|
2
|
+
/** The string flag whose value is currently being completed, if the cursor is in one. */
|
|
3
|
+
export declare function completingFlagValue(argv: string[], flags: readonly FlagSpec[]): FlagSpec | undefined;
|
|
4
|
+
/** Strip declared flags and their values, leaving the positional cursor shape for sub-grammars. */
|
|
5
|
+
export declare function positionalsForCompletion(argv: string[], flags: readonly FlagSpec[]): string[];
|
|
6
|
+
export declare function hasCompletedFlagValue(argv: string[], flags: readonly FlagSpec[], name: string): boolean;
|
|
7
|
+
export declare function completedFlagValue(argv: string[], flags: readonly FlagSpec[], name: string): string | undefined;
|
|
8
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lib/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,GAAG,SAAS,CAKpG;AAED,mGAAmG;AACnG,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,EAAE,CAqB7F;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvG;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAe/G"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** The string flag whose value is currently being completed, if the cursor is in one. */
|
|
2
|
+
export function completingFlagValue(argv, flags) {
|
|
3
|
+
const prev = argv[argv.length - 2];
|
|
4
|
+
if (!prev)
|
|
5
|
+
return undefined;
|
|
6
|
+
const flag = flagForToken(prev, flags);
|
|
7
|
+
return flag?.type === "string" ? flag : undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Strip declared flags and their values, leaving the positional cursor shape for sub-grammars. */
|
|
10
|
+
export function positionalsForCompletion(argv, flags) {
|
|
11
|
+
const out = [];
|
|
12
|
+
let positionalOnly = false;
|
|
13
|
+
for (let i = 0; i < argv.length; i++) {
|
|
14
|
+
const word = argv[i];
|
|
15
|
+
if (!positionalOnly && word === "--") {
|
|
16
|
+
positionalOnly = true;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (!positionalOnly) {
|
|
20
|
+
const inline = /^--([^=]+)=/.exec(word);
|
|
21
|
+
if (inline && flagForLong(inline[1], flags))
|
|
22
|
+
continue;
|
|
23
|
+
const flag = flagForToken(word, flags);
|
|
24
|
+
if (flag) {
|
|
25
|
+
if (flag.type === "string" && i + 1 < argv.length)
|
|
26
|
+
i++;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
out.push(word);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
export function hasCompletedFlagValue(argv, flags, name) {
|
|
35
|
+
return completedFlagValue(argv, flags, name) !== undefined;
|
|
36
|
+
}
|
|
37
|
+
export function completedFlagValue(argv, flags, name) {
|
|
38
|
+
for (let i = 0; i < argv.length; i++) {
|
|
39
|
+
const word = argv[i];
|
|
40
|
+
const inline = /^--([^=]+)=(.*)$/.exec(word);
|
|
41
|
+
if (inline) {
|
|
42
|
+
const flag = flagForLong(inline[1], flags);
|
|
43
|
+
if (flag?.name === name && inline[2] !== "")
|
|
44
|
+
return inline[2];
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const flag = flagForToken(word, flags);
|
|
48
|
+
if (flag?.name !== name || flag.type !== "string")
|
|
49
|
+
continue;
|
|
50
|
+
const value = argv[i + 1];
|
|
51
|
+
if (value !== undefined && value !== "" && i + 1 < argv.length - 1)
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
function flagForToken(token, flags) {
|
|
57
|
+
if (token.startsWith("--"))
|
|
58
|
+
return flagForLong(token.slice(2), flags);
|
|
59
|
+
if (/^-[^-]$/.test(token))
|
|
60
|
+
return flags.find((f) => f.short === token.slice(1));
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
function flagForLong(name, flags) {
|
|
64
|
+
return flags.find((f) => f.name === name);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/lib/completion.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,MAAM,UAAU,mBAAmB,CAAC,IAAc,EAAE,KAA0B;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,IA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AC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACtE,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,KAA0B;IAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/lib/connect.d.ts
CHANGED
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { type MeshTarget } from "@cotal-ai/workspace";
|
|
3
|
-
export { classifyPreflightFailure, type PreflightFailure } from "@cotal-ai/workspace";
|
|
4
|
-
/**
|
|
5
|
-
* The one way every command that touches a running mesh figures out WHICH mesh + with what creds,
|
|
6
|
-
* and confirms it's actually up — so `spawn`, `send`/`dm`/`msg`/`ask`, `console`, `join`, `web`,
|
|
7
|
-
* `channels`, `history`, and `personas --running` all behave identically from any directory instead
|
|
8
|
-
* of each re-deriving it from a cwd walk-up (which mistook `$HOME/.cotal` for a space and crashed
|
|
9
|
-
* with a raw NATS auth violation). Two escape hatches take a RAW off-registry connection (no
|
|
10
|
-
* registry lookup, no stale-prune): explicit `--creds`, and `--server` + an unregistered `--space`
|
|
11
|
-
* (an open remote mesh that has no creds to pass).
|
|
12
|
-
*/
|
|
13
|
-
export interface ConnectFlags {
|
|
14
|
-
server?: string;
|
|
15
|
-
space?: string;
|
|
16
|
-
/** Explicit creds file — triggers a raw off-registry connection (see {@link connectOrExit}). */
|
|
17
|
-
creds?: string;
|
|
18
|
-
}
|
|
19
|
-
/** Raw NATS auth for an off-registry connection — a join link / --token / --user+--pass / --creds.
|
|
20
|
-
* Structurally matches what `probeConnect` accepts. */
|
|
21
|
-
export interface RawAuth {
|
|
22
|
-
token?: string;
|
|
23
|
-
user?: string;
|
|
24
|
-
pass?: string;
|
|
25
|
-
creds?: string;
|
|
26
|
-
tls?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface Connection {
|
|
29
|
-
server: string;
|
|
30
|
-
space: string;
|
|
31
|
-
creds?: string;
|
|
32
|
-
/** The mesh's trust material when resolved from the registry on an auth mesh — undefined for an
|
|
33
|
-
* open mesh or a raw off-registry connection (`--creds` or `--server`+unregistered `--space`).
|
|
34
|
-
* (web keeps it for its per-delete manager mint.) */
|
|
35
|
-
auth?: SpaceAuth;
|
|
36
|
-
/** The resolved mesh's recorded checkout root, for a REGISTERED mesh — undefined for a raw
|
|
37
|
-
* off-registry connection (`--creds`, or `--server`+unregistered `--space`). `spawn -f`/`down -f`
|
|
38
|
-
* use it to enforce the same-checkout invariant: local launch artifacts + the ledger live under
|
|
39
|
-
* this checkout, so deploying onto a mesh recorded by another checkout would decouple them. */
|
|
40
|
-
root?: string;
|
|
41
|
-
/** How the target was resolved (registry / current / flag-space / …) — undefined for raw. */
|
|
42
|
-
source?: MeshTarget["source"];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Resolve where a mesh-touching command connects + with what creds.
|
|
46
|
-
* • Explicit `--creds` → a RAW off-registry connection: straight to `--server` (default loopback)
|
|
47
|
-
* as `--space`, with those creds. No registry lookup, no stale-prune, plain reachability message
|
|
48
|
-
* (the user is deliberately off-registry — e.g. a remote mesh that isn't locally recorded).
|
|
49
|
-
* • Otherwise → resolve the running mesh from the registry (works from any dir), mint `role` creds
|
|
50
|
-
* on an auth mesh, and preflight with the registry's stale-prune.
|
|
51
|
-
*/
|
|
52
|
-
export declare function connectOrExit(flags: ConnectFlags, role: Profile): Promise<Connection>;
|
|
53
|
-
/** Reachability check for a RAW (off-registry) connection — one plain sentence, never a registry/
|
|
54
|
-
* stale-entry message and never a prune. Used by the `--creds` escape hatch and `join`'s explicit
|
|
55
|
-
* (link/token/creds) path, both of which connect to a broker the user named, not the registry. */
|
|
56
|
-
export declare function reachableOrExit(server: string, auth?: RawAuth): Promise<void>;
|
|
57
|
-
/** Resolve the mesh a command targets, exiting with one human sentence on an unresolved/ambiguous
|
|
58
|
-
* registry rather than a stack trace. Prunes dead registry entries first so a crashed mesh doesn't
|
|
59
|
-
* block a bare command or appear in the "pick one" list — but ONLY when resolving without an
|
|
60
|
-
* explicit `--space`. A named `--space` is resolved + preflighted directly, so pre-pruning can't
|
|
61
|
-
* erase a dead-recorded mesh the operator is recovering with a live `--server` override; preflight
|
|
62
|
-
* still prunes it (with the friendly message) when no override revives it. */
|
|
63
|
-
export declare function resolveTargetOrExit(flags: {
|
|
64
|
-
server?: string;
|
|
65
|
-
space?: string;
|
|
66
|
-
}): Promise<MeshTarget>;
|
|
67
|
-
/** Confirm the resolved mesh is up and accepts these creds — replaces the raw NATS "Authorization
|
|
68
|
-
* Violation" trace with one sentence, and prunes the entry if the broker is gone / mismatched.
|
|
69
|
-
* The probe + classify + render live in `@cotal-ai/workspace` (shared with the manager control
|
|
70
|
-
* commands); this wrapper owns the CLI's I/O — it acts on the prune decision, colours, and exits.
|
|
71
|
-
* Probes with `probeCreds` when given (the caller's `--creds`/minted creds); otherwise workspace mints
|
|
72
|
-
* a throwaway identity from the target's own trust material. */
|
|
73
|
-
export declare function preflightOrExit(target: MeshTarget, probeCreds?: string): Promise<void>;
|
|
1
|
+
export { connectOrExit, reachableOrExit, resolveTargetOrExit, preflightOrExit, classifyPreflightFailure, type ConnectFlags, type Connection, type RawAuth, type PreflightFailure, } from "@cotal-ai/workspace";
|
|
74
2
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/lib/connect.js
CHANGED
|
@@ -1,91 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// The workstation mechanics (target resolution, probe → classify → command-copy renderer +
|
|
6
|
-
// stale-prune) live in `@cotal-ai/workspace`, shared with the manager control commands. Re-exported
|
|
7
|
-
// here so existing importers — and `connect.smoke.ts` — keep resolving them from this module unchanged.
|
|
8
|
-
export { classifyPreflightFailure } from "@cotal-ai/workspace";
|
|
9
|
-
/**
|
|
10
|
-
* Resolve where a mesh-touching command connects + with what creds.
|
|
11
|
-
* • Explicit `--creds` → a RAW off-registry connection: straight to `--server` (default loopback)
|
|
12
|
-
* as `--space`, with those creds. No registry lookup, no stale-prune, plain reachability message
|
|
13
|
-
* (the user is deliberately off-registry — e.g. a remote mesh that isn't locally recorded).
|
|
14
|
-
* • Otherwise → resolve the running mesh from the registry (works from any dir), mint `role` creds
|
|
15
|
-
* on an auth mesh, and preflight with the registry's stale-prune.
|
|
16
|
-
*/
|
|
17
|
-
export async function connectOrExit(flags, role) {
|
|
18
|
-
if (flags.creds) {
|
|
19
|
-
const server = flags.server ?? DEFAULT_SERVER;
|
|
20
|
-
const space = flags.space ?? DEFAULT_SPACE;
|
|
21
|
-
const creds = readFileSync(flags.creds, "utf8");
|
|
22
|
-
await reachableOrExit(server, { creds });
|
|
23
|
-
return { server, space, creds };
|
|
24
|
-
}
|
|
25
|
-
// A raw OPEN remote mesh: explicit `--server` + a `--space` that isn't locally registered. Naming
|
|
26
|
-
// both is as deliberate as `--creds`, but an open broker has no creds to pass — connect bare,
|
|
27
|
-
// off-registry (no registry lookup, no prune). A registered `--space` still goes through the
|
|
28
|
-
// resolver below (which honors `--server` as an override); `--server` alone resolves there too.
|
|
29
|
-
if (flags.server && flags.space && !findMesh(flags.space)) {
|
|
30
|
-
await reachableOrExit(flags.server, {});
|
|
31
|
-
return { server: flags.server, space: flags.space };
|
|
32
|
-
}
|
|
33
|
-
const target = await resolveTargetOrExit({ server: flags.server, space: flags.space });
|
|
34
|
-
const creds = target.auth ? await mintCreds(target.auth, newIdentity(), role) : undefined;
|
|
35
|
-
await preflightOrExit(target, creds);
|
|
36
|
-
return { server: target.server, space: target.space, creds, auth: target.auth, root: target.root, source: target.source };
|
|
37
|
-
}
|
|
38
|
-
/** Reachability check for a RAW (off-registry) connection — one plain sentence, never a registry/
|
|
39
|
-
* stale-entry message and never a prune. Used by the `--creds` escape hatch and `join`'s explicit
|
|
40
|
-
* (link/token/creds) path, both of which connect to a broker the user named, not the registry. */
|
|
41
|
-
export async function reachableOrExit(server, auth = {}) {
|
|
42
|
-
const probe = await probeConnect(server, auth);
|
|
43
|
-
if (probe.ok)
|
|
44
|
-
return;
|
|
45
|
-
console.error(c.red(renderWorkspaceError({ kind: "reachable", reason: probe.reason, server })));
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
/** Resolve the mesh a command targets, exiting with one human sentence on an unresolved/ambiguous
|
|
49
|
-
* registry rather than a stack trace. Prunes dead registry entries first so a crashed mesh doesn't
|
|
50
|
-
* block a bare command or appear in the "pick one" list — but ONLY when resolving without an
|
|
51
|
-
* explicit `--space`. A named `--space` is resolved + preflighted directly, so pre-pruning can't
|
|
52
|
-
* erase a dead-recorded mesh the operator is recovering with a live `--server` override; preflight
|
|
53
|
-
* still prunes it (with the friendly message) when no override revives it. */
|
|
54
|
-
export async function resolveTargetOrExit(flags) {
|
|
55
|
-
if (!flags.space)
|
|
56
|
-
await pruneStaleMeshes();
|
|
57
|
-
let target;
|
|
58
|
-
try {
|
|
59
|
-
target = resolveMeshTarget(process.cwd(), flags);
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
if (isWorkspaceTargetError(e)) {
|
|
63
|
-
console.error(c.red(renderWorkspaceError({ kind: "target", error: e })));
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
throw e;
|
|
67
|
-
}
|
|
68
|
-
// If a dangling `current` was silently bypassed — it named a mesh that's since gone and we fell
|
|
69
|
-
// back to the only live one — say so. The N>1 case errors loudly; this is the one spot that would
|
|
70
|
-
// otherwise quietly redirect a stale default.
|
|
71
|
-
const cur = getCurrent();
|
|
72
|
-
if (cur && !findMesh(cur) && target.source === "registry")
|
|
73
|
-
console.error(c.dim(`note: default mesh "${cur}" is down — using "${target.space}"`));
|
|
74
|
-
return target;
|
|
75
|
-
}
|
|
76
|
-
/** Confirm the resolved mesh is up and accepts these creds — replaces the raw NATS "Authorization
|
|
77
|
-
* Violation" trace with one sentence, and prunes the entry if the broker is gone / mismatched.
|
|
78
|
-
* The probe + classify + render live in `@cotal-ai/workspace` (shared with the manager control
|
|
79
|
-
* commands); this wrapper owns the CLI's I/O — it acts on the prune decision, colours, and exits.
|
|
80
|
-
* Probes with `probeCreds` when given (the caller's `--creds`/minted creds); otherwise workspace mints
|
|
81
|
-
* a throwaway identity from the target's own trust material. */
|
|
82
|
-
export async function preflightOrExit(target, probeCreds) {
|
|
83
|
-
const r = await preflightTarget(target, probeCreds);
|
|
84
|
-
if (r.ok)
|
|
85
|
-
return;
|
|
86
|
-
if (r.prune)
|
|
87
|
-
removeMesh(target.space);
|
|
88
|
-
console.error(c.red(renderWorkspaceError({ kind: "preflight", failure: r.kind, target, pruned: r.prune })));
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
1
|
+
// The connect-or-exit wrappers moved into `@cotal-ai/workspace` (stage 4) so every command
|
|
2
|
+
// surface — this CLI and cotal-web — resolves meshes identically. Re-exported here
|
|
3
|
+
// so existing importers (and `connect.smoke.ts`) keep resolving them from this module unchanged.
|
|
4
|
+
export { connectOrExit, reachableOrExit, resolveTargetOrExit, preflightOrExit, classifyPreflightFailure, } from "@cotal-ai/workspace";
|
|
91
5
|
//# sourceMappingURL=connect.js.map
|
package/dist/lib/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,mFAAmF;AACnF,iGAAiG;AACjG,OAAO,EACL,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,wBAAwB,GAKzB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ControlReply, type ControlTier, type Profile } from "@cotal-ai/core";
|
|
2
|
+
import { type ConnectFlags } from "./connect.js";
|
|
3
|
+
/** Client-side request window for the manager's readiness-waiting launch ops (`start`, and the
|
|
4
|
+
* manifest `launch` — both funnel into the same startAgent readiness wait). #159 B1: the manager
|
|
5
|
+
* replies only on a REAL outcome — presence join, process exit, or its ~30s readiness backstop —
|
|
6
|
+
* so these requests must OUTLIVE that window, not the 5s op default. The tier rule forbids
|
|
7
|
+
* importing the manager's READINESS_TIMEOUT_MS here; the launch-parity smoke enforces the
|
|
8
|
+
* relation by test. */
|
|
9
|
+
export declare const START_TIMEOUT_MS = 40000;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve which running mesh a control command (`spawn --detach` / `stop` / `ps` / `attach`)
|
|
12
|
+
* targets. Exactly {@link connectOrExit}'s precedence (--creds raw > --server+unregistered-space
|
|
13
|
+
* open > registry/`current` with mint + preflight + stale-prune) with ONE control-specific delta:
|
|
14
|
+
* on the raw `--creds` path the space defaults to THIS FOLDER's `.cotal/auth` space, not
|
|
15
|
+
* `DEFAULT_SPACE` — a control op addresses the manager of the folder's mesh, which is more
|
|
16
|
+
* correct for a non-default-space project (deliberate, kept from the pre-move manager client).
|
|
17
|
+
* Lived in `@cotal-ai/manager` before stage 2a moved the control clients into the CLI; the
|
|
18
|
+
* duplicated resolution/preflight wrappers collapsed onto `lib/connect.ts`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveControlTarget(flags: ConnectFlags, profile: Profile): Promise<{
|
|
21
|
+
space: string;
|
|
22
|
+
server: string;
|
|
23
|
+
creds?: string;
|
|
24
|
+
}>;
|
|
25
|
+
/** Connect a short-lived client with the resolved creds, send one control request to the manager,
|
|
26
|
+
* disconnect. The target is already reachability- + auth-preflighted by
|
|
27
|
+
* {@link resolveControlTarget}, so this connects straight through. `tier` picks the control
|
|
28
|
+
* subject: privileged for spawn --detach/ps; admin for the operator's cross-agent ops
|
|
29
|
+
* (stop/attach), which the manager refuses on the privileged subject for a non-owner. `creds` is
|
|
30
|
+
* the tier-scoped caller cred (`control-caller-privileged` / `control-caller-admin` — each holds
|
|
31
|
+
* ONLY its own tier's pub grant), or undefined on an open mesh. */
|
|
32
|
+
export declare function askManager(space: string, server: string, op: string, args?: Record<string, unknown>, creds?: string, tier?: ControlTier, timeoutMs?: number): Promise<ControlReply>;
|
|
33
|
+
export declare function failIfNotOk(reply: ControlReply): void;
|
|
34
|
+
//# sourceMappingURL=control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/lib/control.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACb,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE;;;;;wBAKwB;AACxB,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAM5D;AAED;;;;;;oEAMoE;AACpE,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,GAAE,WAAgC,EACtC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,CAAC,CAoBvB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAKrD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CotalEndpoint, DEFAULT_SPACE, CONTROL_PRIVILEGED, } from "@cotal-ai/core";
|
|
2
|
+
import { authDir, findCotalRoot, loadSpaceAuth } from "@cotal-ai/workspace";
|
|
3
|
+
import { c } from "../ui.js";
|
|
4
|
+
import { connectOrExit } from "./connect.js";
|
|
5
|
+
/** Client-side request window for the manager's readiness-waiting launch ops (`start`, and the
|
|
6
|
+
* manifest `launch` — both funnel into the same startAgent readiness wait). #159 B1: the manager
|
|
7
|
+
* replies only on a REAL outcome — presence join, process exit, or its ~30s readiness backstop —
|
|
8
|
+
* so these requests must OUTLIVE that window, not the 5s op default. The tier rule forbids
|
|
9
|
+
* importing the manager's READINESS_TIMEOUT_MS here; the launch-parity smoke enforces the
|
|
10
|
+
* relation by test. */
|
|
11
|
+
export const START_TIMEOUT_MS = 40_000;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve which running mesh a control command (`spawn --detach` / `stop` / `ps` / `attach`)
|
|
14
|
+
* targets. Exactly {@link connectOrExit}'s precedence (--creds raw > --server+unregistered-space
|
|
15
|
+
* open > registry/`current` with mint + preflight + stale-prune) with ONE control-specific delta:
|
|
16
|
+
* on the raw `--creds` path the space defaults to THIS FOLDER's `.cotal/auth` space, not
|
|
17
|
+
* `DEFAULT_SPACE` — a control op addresses the manager of the folder's mesh, which is more
|
|
18
|
+
* correct for a non-default-space project (deliberate, kept from the pre-move manager client).
|
|
19
|
+
* Lived in `@cotal-ai/manager` before stage 2a moved the control clients into the CLI; the
|
|
20
|
+
* duplicated resolution/preflight wrappers collapsed onto `lib/connect.ts`.
|
|
21
|
+
*/
|
|
22
|
+
export async function resolveControlTarget(flags, profile) {
|
|
23
|
+
const withSpace = flags.creds
|
|
24
|
+
? { ...flags, space: flags.space ?? loadSpaceAuth(authDir(findCotalRoot()))?.space ?? DEFAULT_SPACE }
|
|
25
|
+
: flags;
|
|
26
|
+
const { space, server, creds } = await connectOrExit(withSpace, profile);
|
|
27
|
+
return { space, server, creds };
|
|
28
|
+
}
|
|
29
|
+
/** Connect a short-lived client with the resolved creds, send one control request to the manager,
|
|
30
|
+
* disconnect. The target is already reachability- + auth-preflighted by
|
|
31
|
+
* {@link resolveControlTarget}, so this connects straight through. `tier` picks the control
|
|
32
|
+
* subject: privileged for spawn --detach/ps; admin for the operator's cross-agent ops
|
|
33
|
+
* (stop/attach), which the manager refuses on the privileged subject for a non-owner. `creds` is
|
|
34
|
+
* the tier-scoped caller cred (`control-caller-privileged` / `control-caller-admin` — each holds
|
|
35
|
+
* ONLY its own tier's pub grant), or undefined on an open mesh. */
|
|
36
|
+
export async function askManager(space, server, op, args, creds, tier = CONTROL_PRIVILEGED, timeoutMs) {
|
|
37
|
+
const ep = new CotalEndpoint({
|
|
38
|
+
space,
|
|
39
|
+
servers: server,
|
|
40
|
+
creds,
|
|
41
|
+
channels: [],
|
|
42
|
+
consume: false, // request/reply only — binds no consumers (and under auth has no pre-created DM durable)
|
|
43
|
+
registerPresence: false,
|
|
44
|
+
watchPresence: false,
|
|
45
|
+
card: { name: "cli", kind: "endpoint" },
|
|
46
|
+
});
|
|
47
|
+
ep.on("error", (e) => console.error(c.red("! " + e.message)));
|
|
48
|
+
await ep.start();
|
|
49
|
+
try {
|
|
50
|
+
return await ep.requestControl(tier, { op, args }, timeoutMs);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
return { ok: false, error: `no manager reachable (${e.message})` };
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await ep.stop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function failIfNotOk(reply) {
|
|
60
|
+
if (!reply.ok) {
|
|
61
|
+
console.error(c.red(`✗ ${reply.error ?? "error"}`));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/lib/control.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,GAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAqB,MAAM,cAAc,CAAC;AAEhE;;;;;wBAKwB;AACxB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,KAAmB,EACnB,OAAgB;IAEhB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK;QAC3B,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,IAAI,aAAa,EAAE;QACrG,CAAC,CAAC,KAAK,CAAC;IACV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,OAAO,EAAE,KA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