@stratusagent/cli 0.11.2 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -8
- package/dist/approvals.d.ts +93 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +368 -0
- package/dist/approvals.js.map +1 -0
- package/dist/commands/agent-new.d.ts +22 -0
- package/dist/commands/agent-new.d.ts.map +1 -0
- package/dist/commands/agent-new.js +159 -0
- package/dist/commands/agent-new.js.map +1 -0
- package/dist/commands/agents.d.ts +4 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +90 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/chat.d.ts +4 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +227 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/credential.d.ts +22 -0
- package/dist/commands/credential.d.ts.map +1 -0
- package/dist/commands/credential.js +93 -0
- package/dist/commands/credential.js.map +1 -0
- package/dist/commands/dashboard.d.ts +14 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +195 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/doctor.d.ts +40 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +376 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/grants.d.ts +19 -0
- package/dist/commands/grants.d.ts.map +1 -0
- package/dist/commands/grants.js +128 -0
- package/dist/commands/grants.js.map +1 -0
- package/dist/commands/logs.d.ts +9 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +58 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/memory.d.ts +20 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +110 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/plugins.d.ts +103 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +386 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/restart.d.ts +4 -0
- package/dist/commands/restart.d.ts.map +1 -0
- package/dist/commands/restart.js +25 -0
- package/dist/commands/restart.js.map +1 -0
- package/dist/commands/schedules.d.ts +11 -0
- package/dist/commands/schedules.d.ts.map +1 -0
- package/dist/commands/schedules.js +50 -0
- package/dist/commands/schedules.js.map +1 -0
- package/dist/commands/serve.d.ts +4 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +633 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/service.d.ts +9 -0
- package/dist/commands/service.d.ts.map +1 -0
- package/dist/commands/service.js +97 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/session.d.ts +9 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +25 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +2467 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/skills.d.ts +15 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +272 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/template.d.ts +4 -0
- package/dist/commands/template.d.ts.map +1 -0
- package/dist/commands/template.js +593 -0
- package/dist/commands/template.js.map +1 -0
- package/dist/commands/update.d.ts +21 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +291 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/daemon.d.ts +74 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +192 -0
- package/dist/daemon.js.map +1 -0
- package/dist/environment.d.ts +114 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +2 -0
- package/dist/environment.js.map +1 -0
- package/dist/events.d.ts +17 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +87 -0
- package/dist/events.js.map +1 -0
- package/dist/help.d.ts +2 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +272 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +32 -624
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -6981
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +16 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +45 -0
- package/dist/io.js.map +1 -0
- package/dist/loaders.d.ts +31 -0
- package/dist/loaders.d.ts.map +1 -0
- package/dist/loaders.js +56 -0
- package/dist/loaders.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +218 -0
- package/dist/main.js.map +1 -0
- package/dist/npm.d.ts +66 -0
- package/dist/npm.d.ts.map +1 -0
- package/dist/npm.js +201 -0
- package/dist/npm.js.map +1 -0
- package/dist/parse.d.ts +245 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +1098 -0
- package/dist/parse.js.map +1 -0
- package/dist/plugin-catalog.d.ts +44 -0
- package/dist/plugin-catalog.d.ts.map +1 -0
- package/dist/plugin-catalog.js +70 -0
- package/dist/plugin-catalog.js.map +1 -0
- package/dist/preflight.d.ts +60 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +102 -0
- package/dist/preflight.js.map +1 -0
- package/dist/prompter.d.ts +84 -0
- package/dist/prompter.d.ts.map +1 -0
- package/dist/prompter.js +347 -0
- package/dist/prompter.js.map +1 -0
- package/dist/roster.d.ts +57 -0
- package/dist/roster.d.ts.map +1 -0
- package/dist/roster.js +78 -0
- package/dist/roster.js.map +1 -0
- package/dist/runtime.d.ts +76 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +372 -0
- package/dist/runtime.js.map +1 -0
- package/dist/slack.d.ts +26 -0
- package/dist/slack.d.ts.map +1 -0
- package/dist/slack.js +113 -0
- package/dist/slack.js.map +1 -0
- package/dist/source.d.ts +24 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +80 -0
- package/dist/source.js.map +1 -0
- package/dist/supervisor.d.ts +69 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +218 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/trusted-config.d.ts +84 -0
- package/dist/trusted-config.d.ts.map +1 -0
- package/dist/trusted-config.js +159 -0
- package/dist/trusted-config.js.map +1 -0
- package/package.json +27 -23
package/dist/prompter.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
2
|
+
import { writeLine } from "./io.js";
|
|
3
|
+
import { CLI_VERSION } from "./npm.js";
|
|
4
|
+
/**
|
|
5
|
+
* Whether a string is a specifier npm would install — and therefore one
|
|
6
|
+
* safe to hand a shell.
|
|
7
|
+
*
|
|
8
|
+
* npm's own name grammar, which is far narrower than anything a shell
|
|
9
|
+
* treats as special: an optional `@scope/`, then lowercase alphanumerics
|
|
10
|
+
* with `-`, `_` and `.`, no leading `.` or `_`, 214 characters at most,
|
|
11
|
+
* and an optional `@version` of the same restricted alphabet. Nothing that
|
|
12
|
+
* matches contains a space, a quote, or a metacharacter — not `&`, not
|
|
13
|
+
* `|`, not `` ` ``, and not cmd.exe's `^` — so the fence and the
|
|
14
|
+
* correctness check are one check.
|
|
15
|
+
*
|
|
16
|
+
* The version half is deliberately not npm's full range syntax: `^1.0.0`
|
|
17
|
+
* is a valid range and `^` is cmd.exe's escape character. Only the plain
|
|
18
|
+
* forms this CLI actually passes are accepted, and a range that needs more
|
|
19
|
+
* is a thing to install by hand.
|
|
20
|
+
*
|
|
21
|
+
* A config key that fails this was never installable, so refusing costs no
|
|
22
|
+
* capability: `npm install -g 'pkg & whoami'` is not a thing that works
|
|
23
|
+
* and quietly becomes a thing that runs.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The columns `selectInteractive` spends before an option's own text.
|
|
27
|
+
*
|
|
28
|
+
* Two for the selection marker, then `${n}) ` — so it grows with the option
|
|
29
|
+
* *count*, since every row is fitted to the widest prefix any row will
|
|
30
|
+
* have. A menu whose length a config decides therefore cannot reserve a
|
|
31
|
+
* constant: five first-party plugins plus five from a `plugins` block is
|
|
32
|
+
* ten rows, and ` 10) ` is a column wider than ` 1) `.
|
|
33
|
+
*
|
|
34
|
+
* The extra column is a deliberate spare. `fitMenuRow` trims to exactly its
|
|
35
|
+
* budget, and a row that fills the last column wraps on terminals that
|
|
36
|
+
* advance the cursor eagerly — which costs a whole redraw, since the rewind
|
|
37
|
+
* counts options rather than rendered rows.
|
|
38
|
+
*/
|
|
39
|
+
export const menuPrefixWidth = (optionCount) => ` ${optionCount}) `.length + 1;
|
|
40
|
+
// Printed commands must survive copy-paste into a shell, so anything outside
|
|
41
|
+
// the safe character set gets single-quoted.
|
|
42
|
+
export const quoteShellArg = (value) => /^[A-Za-z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
43
|
+
// The fixed header drawn at the top of every interactive screen.
|
|
44
|
+
export const stratusHeaderLines = () => {
|
|
45
|
+
const title = 'Stratus Agent';
|
|
46
|
+
const version = `v${CLI_VERSION}`;
|
|
47
|
+
const gap = ' ';
|
|
48
|
+
const content = ` ${title}${gap}${version} `;
|
|
49
|
+
return [
|
|
50
|
+
`\u001b[2m╭${'─'.repeat(content.length)}╮\u001b[0m`,
|
|
51
|
+
`\u001b[2m│\u001b[0m \u001b[1m${title}\u001b[0m${gap}\u001b[2m${version}\u001b[0m \u001b[2m│\u001b[0m`,
|
|
52
|
+
`\u001b[2m╰${'─'.repeat(content.length)}╯\u001b[0m`,
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
export const createSetupPrompter = (streams, env, view) => {
|
|
56
|
+
// On a real TTY, menus are arrow-key driven and secrets are read without
|
|
57
|
+
// echo; with piped input (tests, scripts) everything is plain lines.
|
|
58
|
+
const interactive = env.setupInput === undefined && process.stdin.isTTY === true;
|
|
59
|
+
if (interactive) {
|
|
60
|
+
let closed = false;
|
|
61
|
+
process.stdin.once('end', () => {
|
|
62
|
+
closed = true;
|
|
63
|
+
});
|
|
64
|
+
const question = (prompt, secret, prefill) => {
|
|
65
|
+
const readline = createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
66
|
+
if (secret) {
|
|
67
|
+
const internal = readline;
|
|
68
|
+
const original = internal._writeToOutput?.bind(readline);
|
|
69
|
+
internal._writeToOutput = (chunk) => {
|
|
70
|
+
// Echo the prompt itself, swallow the typed secret.
|
|
71
|
+
if (chunk.startsWith(prompt)) {
|
|
72
|
+
original?.(prompt);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return new Promise((resolve) => {
|
|
77
|
+
readline.on('SIGINT', () => {
|
|
78
|
+
readline.close();
|
|
79
|
+
streams.stdout.write('\n');
|
|
80
|
+
process.exit(130);
|
|
81
|
+
});
|
|
82
|
+
readline.question(prompt, (answer) => {
|
|
83
|
+
readline.close();
|
|
84
|
+
if (secret) {
|
|
85
|
+
streams.stdout.write('\n');
|
|
86
|
+
}
|
|
87
|
+
resolve(answer.trim());
|
|
88
|
+
});
|
|
89
|
+
if (prefill) {
|
|
90
|
+
// Pre-typed and editable: backspace over it or press Enter to keep.
|
|
91
|
+
readline.write(prefill);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
// Each menu replaces the screen: clear, draw the header, carry over the
|
|
96
|
+
// most recent status lines, then the menu itself.
|
|
97
|
+
const drawScreen = (out) => {
|
|
98
|
+
out.write('\u001b[2J\u001b[H');
|
|
99
|
+
for (const line of view?.header() ?? []) {
|
|
100
|
+
out.write(`${line}\n`);
|
|
101
|
+
}
|
|
102
|
+
const notices = view?.consumeNotices() ?? [];
|
|
103
|
+
if (notices.length > 0) {
|
|
104
|
+
for (const line of notices) {
|
|
105
|
+
out.write(`\u001b[2m${line}\u001b[0m\n`);
|
|
106
|
+
}
|
|
107
|
+
out.write('\n');
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const selectInteractive = (heading, options, opts) => new Promise((resolve) => {
|
|
111
|
+
const stdin = process.stdin;
|
|
112
|
+
const out = streams.stdout;
|
|
113
|
+
let index = Math.min(Math.max(opts.defaultIndex ?? 0, 0), options.length - 1);
|
|
114
|
+
const wasRaw = stdin.isRaw === true;
|
|
115
|
+
stdin.setRawMode?.(true);
|
|
116
|
+
stdin.resume();
|
|
117
|
+
const render = (redraw) => {
|
|
118
|
+
if (redraw) {
|
|
119
|
+
out.write(`\u001b[${options.length}A`);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
drawScreen(out);
|
|
123
|
+
if (heading.length > 0) {
|
|
124
|
+
out.write(`${heading}\n`);
|
|
125
|
+
}
|
|
126
|
+
if (opts.footnote) {
|
|
127
|
+
out.write(`${opts.footnote}\n`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
options.forEach((option, i) => {
|
|
131
|
+
const active = i === index;
|
|
132
|
+
out.write(`\u001b[2K\r${active ? '\u001b[36m\u276f ' : ' '}${i + 1}) ${option}${active ? '\u001b[0m' : ''}\n`);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const finish = (answer) => {
|
|
136
|
+
if (pendingTimer !== undefined) {
|
|
137
|
+
clearTimeout(pendingTimer);
|
|
138
|
+
pendingTimer = undefined;
|
|
139
|
+
}
|
|
140
|
+
stdin.off('data', onData);
|
|
141
|
+
if (!wasRaw) {
|
|
142
|
+
stdin.setRawMode?.(false);
|
|
143
|
+
}
|
|
144
|
+
// Pause so keys typed between menus buffer for the next consumer
|
|
145
|
+
// instead of being dropped by a flowing stream with no listener.
|
|
146
|
+
stdin.pause();
|
|
147
|
+
if (pendingEscape.length > 0) {
|
|
148
|
+
stdin.unshift(Buffer.from(pendingEscape, 'utf8'));
|
|
149
|
+
pendingEscape = '';
|
|
150
|
+
}
|
|
151
|
+
resolve(answer);
|
|
152
|
+
};
|
|
153
|
+
const handleKey = (key) => {
|
|
154
|
+
if (key === '\u0003') {
|
|
155
|
+
// Ctrl-C: restore the terminal and leave setup entirely.
|
|
156
|
+
stdin.setRawMode?.(false);
|
|
157
|
+
out.write('\n');
|
|
158
|
+
process.exit(130);
|
|
159
|
+
}
|
|
160
|
+
if (key === '\u001b[A' || key === '\u001bOA' || key === 'k') {
|
|
161
|
+
index = (index - 1 + options.length) % options.length;
|
|
162
|
+
render(true);
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
if (key === '\u001b[B' || key === '\u001bOB' || key === 'j' || key === '\t') {
|
|
166
|
+
index = (index + 1) % options.length;
|
|
167
|
+
render(true);
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (key === '\r' || key === '\n') {
|
|
171
|
+
finish({ kind: 'index', index });
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
if (key === '\u001b' || key === 'q') {
|
|
175
|
+
finish({ kind: 'back' });
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (/^[1-9]$/.test(key)) {
|
|
179
|
+
const jump = Number(key) - 1;
|
|
180
|
+
if (jump < options.length) {
|
|
181
|
+
index = jump;
|
|
182
|
+
render(true);
|
|
183
|
+
finish({ kind: 'index', index });
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
};
|
|
189
|
+
// Key repeat and pasted input arrive as one chunk containing several
|
|
190
|
+
// sequences — split it into individual keys before handling. Bytes
|
|
191
|
+
// that follow the selecting key (e.g. a pasted "2sk-ant-…") are
|
|
192
|
+
// pushed back onto stdin for whatever prompt comes next. Terminals
|
|
193
|
+
// and SSH can also split an escape sequence ACROSS chunks (ESC, then
|
|
194
|
+
// "[A"), so an incomplete escape tail is held briefly: completed by
|
|
195
|
+
// the next chunk, or treated as a real Esc press after a beat.
|
|
196
|
+
let pendingEscape = '';
|
|
197
|
+
let pendingTimer;
|
|
198
|
+
const processText = (text) => {
|
|
199
|
+
let position = 0;
|
|
200
|
+
while (position < text.length) {
|
|
201
|
+
const remaining = text.length - position;
|
|
202
|
+
if (text[position] === '\u001b' && remaining < 3
|
|
203
|
+
&& (remaining === 1 || text[position + 1] === '[' || text[position + 1] === 'O')) {
|
|
204
|
+
pendingEscape = text.slice(position);
|
|
205
|
+
pendingTimer = setTimeout(() => {
|
|
206
|
+
// No continuation arrived: it was a genuine Esc press.
|
|
207
|
+
pendingEscape = '';
|
|
208
|
+
pendingTimer = undefined;
|
|
209
|
+
handleKey('\u001b');
|
|
210
|
+
}, 75);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
let key;
|
|
214
|
+
if (text[position] === '\u001b' && (text[position + 1] === '[' || text[position + 1] === 'O')) {
|
|
215
|
+
key = text.slice(position, position + 3);
|
|
216
|
+
position += 3;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
key = text[position];
|
|
220
|
+
position += 1;
|
|
221
|
+
}
|
|
222
|
+
if (handleKey(key)) {
|
|
223
|
+
const rest = text.slice(position);
|
|
224
|
+
if (rest.length > 0) {
|
|
225
|
+
stdin.unshift(Buffer.from(rest, 'utf8'));
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
const onData = (chunk) => {
|
|
232
|
+
if (pendingTimer !== undefined) {
|
|
233
|
+
clearTimeout(pendingTimer);
|
|
234
|
+
pendingTimer = undefined;
|
|
235
|
+
}
|
|
236
|
+
const text = pendingEscape + chunk.toString('utf8');
|
|
237
|
+
pendingEscape = '';
|
|
238
|
+
processText(text);
|
|
239
|
+
};
|
|
240
|
+
render(false);
|
|
241
|
+
stdin.on('data', onData);
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
ask: (q, opts) => question(q, false, opts?.prefill),
|
|
245
|
+
askSecret: (q) => question(q, true),
|
|
246
|
+
isInteractive: () => true,
|
|
247
|
+
async select(heading, options, opts = {}) {
|
|
248
|
+
if (options.length === 0) {
|
|
249
|
+
return { kind: 'back' };
|
|
250
|
+
}
|
|
251
|
+
return selectInteractive(heading, options, opts);
|
|
252
|
+
},
|
|
253
|
+
isClosed: () => closed,
|
|
254
|
+
close: () => {
|
|
255
|
+
// A resumed raw-mode stdin keeps the event loop alive; release it
|
|
256
|
+
// so the process can exit once setup returns.
|
|
257
|
+
process.stdin.setRawMode?.(false);
|
|
258
|
+
process.stdin.pause();
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const input = env.setupInput ?? process.stdin;
|
|
263
|
+
const readline = createInterface({ input, terminal: false });
|
|
264
|
+
const pendingLines = [];
|
|
265
|
+
let closed = false;
|
|
266
|
+
readline.on('line', (line) => {
|
|
267
|
+
pendingLines.push(line);
|
|
268
|
+
});
|
|
269
|
+
readline.once('close', () => {
|
|
270
|
+
closed = true;
|
|
271
|
+
});
|
|
272
|
+
const nextLine = async () => {
|
|
273
|
+
while (pendingLines.length === 0) {
|
|
274
|
+
if (closed) {
|
|
275
|
+
return '';
|
|
276
|
+
}
|
|
277
|
+
await new Promise((resolve) => {
|
|
278
|
+
readline.once('line', () => resolve());
|
|
279
|
+
readline.once('close', () => resolve());
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return (pendingLines.shift() ?? '').trim();
|
|
283
|
+
};
|
|
284
|
+
const selectPlain = async (heading, options, opts) => {
|
|
285
|
+
const defaultIndex = Math.min(Math.max(opts.defaultIndex ?? 0, 0), options.length - 1);
|
|
286
|
+
while (true) {
|
|
287
|
+
streams.stdout.write(`${heading}\n`);
|
|
288
|
+
if (opts.footnote) {
|
|
289
|
+
streams.stdout.write(`${opts.footnote}\n`);
|
|
290
|
+
}
|
|
291
|
+
for (const [i, option] of options.entries()) {
|
|
292
|
+
streams.stdout.write(` ${i + 1}) ${option}\n`);
|
|
293
|
+
}
|
|
294
|
+
streams.stdout.write(`Choose [${defaultIndex + 1}]: `);
|
|
295
|
+
const line = await nextLine();
|
|
296
|
+
if (line === '') {
|
|
297
|
+
if (closed && pendingLines.length === 0) {
|
|
298
|
+
return { kind: 'back' };
|
|
299
|
+
}
|
|
300
|
+
return { kind: 'index', index: defaultIndex };
|
|
301
|
+
}
|
|
302
|
+
if (/^\d+$/.test(line)) {
|
|
303
|
+
const picked = Number(line) - 1;
|
|
304
|
+
if (picked >= 0 && picked < options.length) {
|
|
305
|
+
return { kind: 'index', index: picked };
|
|
306
|
+
}
|
|
307
|
+
writeLine(streams.stdout, `Pick a number between 1 and ${options.length}.`);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (/^(back|b|q(uit)?)$/i.test(line)) {
|
|
311
|
+
return { kind: 'back' };
|
|
312
|
+
}
|
|
313
|
+
if (opts.allowText) {
|
|
314
|
+
return { kind: 'text', text: line };
|
|
315
|
+
}
|
|
316
|
+
const matched = options.findIndex((option) => option.toLowerCase().includes(line.toLowerCase()));
|
|
317
|
+
if (matched !== -1) {
|
|
318
|
+
return { kind: 'index', index: matched };
|
|
319
|
+
}
|
|
320
|
+
writeLine(streams.stdout, `Pick a number between 1 and ${options.length}.`);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
return {
|
|
324
|
+
async ask(q, opts) {
|
|
325
|
+
streams.stdout.write(q);
|
|
326
|
+
const line = await nextLine();
|
|
327
|
+
return line || (opts?.prefill ?? '');
|
|
328
|
+
},
|
|
329
|
+
async askSecret(q) {
|
|
330
|
+
// Piped input never echoes, so plain reads are safe here.
|
|
331
|
+
streams.stdout.write(q);
|
|
332
|
+
return nextLine();
|
|
333
|
+
},
|
|
334
|
+
isInteractive: () => false,
|
|
335
|
+
async select(heading, options, opts = {}) {
|
|
336
|
+
if (options.length === 0) {
|
|
337
|
+
return { kind: 'back' };
|
|
338
|
+
}
|
|
339
|
+
return selectPlain(heading, options, opts);
|
|
340
|
+
},
|
|
341
|
+
isClosed: () => closed && pendingLines.length === 0,
|
|
342
|
+
close: () => {
|
|
343
|
+
readline.close();
|
|
344
|
+
},
|
|
345
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,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,CAAC;YACf,0DAA0D;YAC1D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACxB,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC;QACD,aAAa,EAAE,GAAG,EAAE,CAAC,KAAK;QAC1B,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE;YACtC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;QACnD,KAAK,EAAE,GAAG,EAAE;YACV,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/roster.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { loadRosterSouls } from '@stratusagent/state';
|
|
2
|
+
import type { CliEnvironment } from './environment.ts';
|
|
3
|
+
/**
|
|
4
|
+
* npm's package-name grammar, and nothing else: an optional `@scope/`, then
|
|
5
|
+
* lowercase alphanumerics with `-`, `_` and `.`, no leading `.` or `_`, 214
|
|
6
|
+
* characters at most.
|
|
7
|
+
*
|
|
8
|
+
* This is what a `plugins` config key has to be, because that key is *also*
|
|
9
|
+
* the module specifier the loader hands `import.meta.resolve`. A version
|
|
10
|
+
* suffix is a thing npm installs and Node cannot resolve, so a key carrying
|
|
11
|
+
* one names a plugin that is permanently absent however many times it is
|
|
12
|
+
* installed.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Whether one soul's allowlist reaches a tool a plugin contributes.
|
|
16
|
+
*
|
|
17
|
+
* The second gate, in the form both surfaces need it: `stratus plugins`
|
|
18
|
+
* asks it per tool to build the who-can-call-what table, and the setup
|
|
19
|
+
* menu asks it per agent to say what enabling just granted. An omitted
|
|
20
|
+
* list is every registered tool; a *declared namespace* is matched by
|
|
21
|
+
* overlap rather than by prefix, since `mcp.linear.*` sits under a granted
|
|
22
|
+
* `mcp.*` and neither is the other's prefix.
|
|
23
|
+
*
|
|
24
|
+
* Shared rather than written twice, and this is the fifth time on this
|
|
25
|
+
* change that mattered: a menu that answers "who can call it" differently
|
|
26
|
+
* from the command that reports it is two answers to one question.
|
|
27
|
+
*/
|
|
28
|
+
export declare const soulGrantsTool: (tools: readonly string[] | undefined, name: string, discovered: boolean) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The souls skill enablement is judged against: the agents directory plus
|
|
31
|
+
* the configured default soul (config `soul:` / STRATUS_SOUL), which may
|
|
32
|
+
* live outside it and is served all the same. The daemon's roster and
|
|
33
|
+
* `stratus agents` both include it, so `skill add --agent` and `stratus
|
|
34
|
+
* skills` must not answer from a narrower set.
|
|
35
|
+
*/
|
|
36
|
+
export declare const rosterSoulsWithConfigured: (env: CliEnvironment, warn: (line: string) => void, options?: {
|
|
37
|
+
/**
|
|
38
|
+
* The config whose `soul` key names the configured agent. A caller
|
|
39
|
+
* reading everything else from `--config` and this from the default
|
|
40
|
+
* file would answer for a roster the daemon it describes does not
|
|
41
|
+
* serve.
|
|
42
|
+
*/
|
|
43
|
+
configPath?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Seed the reserved built-in agent, the way `loadRoster` does. It has
|
|
46
|
+
* no `tools:` key, so it is granted every registered tool — and on a
|
|
47
|
+
* fresh install it is the only agent there is, which made "granted to
|
|
48
|
+
* nobody" exactly backwards for the most common configuration of all.
|
|
49
|
+
* Off by default: a caller reporting on souls should not have one
|
|
50
|
+
* appear that has no file.
|
|
51
|
+
*/
|
|
52
|
+
includeBuiltIn?: boolean;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
entries: Awaited<ReturnType<typeof loadRosterSouls>>;
|
|
55
|
+
complete: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
//# sourceMappingURL=roster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roster.d.ts","sourceRoot":"","sources":["../src/roster.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,SAAS,MAAM,EAAE,GAAG,SAAS,EACpC,MAAM,MAAM,EACZ,YAAY,OAAO,KAClB,OAOF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACpC,KAAK,cAAc,EACnB,MAAM,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC5B,UAAS;IACP;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CACrB,KACL,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAgCrF,CAAC"}
|
package/dist/roster.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { matchesToolAllowlist, toolScopesOverlap } from '@stratusagent/core';
|
|
2
|
+
import { DEFAULT_STRATUS_AGENT, loadRosterSouls, resolveConfiguredSoul } from '@stratusagent/state';
|
|
3
|
+
/**
|
|
4
|
+
* npm's package-name grammar, and nothing else: an optional `@scope/`, then
|
|
5
|
+
* lowercase alphanumerics with `-`, `_` and `.`, no leading `.` or `_`, 214
|
|
6
|
+
* characters at most.
|
|
7
|
+
*
|
|
8
|
+
* This is what a `plugins` config key has to be, because that key is *also*
|
|
9
|
+
* the module specifier the loader hands `import.meta.resolve`. A version
|
|
10
|
+
* suffix is a thing npm installs and Node cannot resolve, so a key carrying
|
|
11
|
+
* one names a plugin that is permanently absent however many times it is
|
|
12
|
+
* installed.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Whether one soul's allowlist reaches a tool a plugin contributes.
|
|
16
|
+
*
|
|
17
|
+
* The second gate, in the form both surfaces need it: `stratus plugins`
|
|
18
|
+
* asks it per tool to build the who-can-call-what table, and the setup
|
|
19
|
+
* menu asks it per agent to say what enabling just granted. An omitted
|
|
20
|
+
* list is every registered tool; a *declared namespace* is matched by
|
|
21
|
+
* overlap rather than by prefix, since `mcp.linear.*` sits under a granted
|
|
22
|
+
* `mcp.*` and neither is the other's prefix.
|
|
23
|
+
*
|
|
24
|
+
* Shared rather than written twice, and this is the fifth time on this
|
|
25
|
+
* change that mattered: a menu that answers "who can call it" differently
|
|
26
|
+
* from the command that reports it is two answers to one question.
|
|
27
|
+
*/
|
|
28
|
+
export const soulGrantsTool = (tools, name, discovered) => {
|
|
29
|
+
if (tools === undefined) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return discovered
|
|
33
|
+
? tools.some((granted) => toolScopesOverlap(granted, name))
|
|
34
|
+
: matchesToolAllowlist(name, tools);
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The souls skill enablement is judged against: the agents directory plus
|
|
38
|
+
* the configured default soul (config `soul:` / STRATUS_SOUL), which may
|
|
39
|
+
* live outside it and is served all the same. The daemon's roster and
|
|
40
|
+
* `stratus agents` both include it, so `skill add --agent` and `stratus
|
|
41
|
+
* skills` must not answer from a narrower set.
|
|
42
|
+
*/
|
|
43
|
+
export const rosterSoulsWithConfigured = async (env, warn, options = {}) => {
|
|
44
|
+
const { configPath, includeBuiltIn = false } = options;
|
|
45
|
+
// Before the roster, exactly as the gateway registers it: a roster file
|
|
46
|
+
// claiming the reserved id is dropped by `loadRosterSouls`, and only the
|
|
47
|
+
// configured default soul may take it over — which the replace below
|
|
48
|
+
// does on id, so nothing extra is needed for that case.
|
|
49
|
+
const entries = includeBuiltIn
|
|
50
|
+
? [{ soul: { agent: { ...DEFAULT_STRATUS_AGENT } } },
|
|
51
|
+
...await loadRosterSouls(env, warn)]
|
|
52
|
+
: await loadRosterSouls(env, warn);
|
|
53
|
+
let complete = true;
|
|
54
|
+
try {
|
|
55
|
+
const configured = await resolveConfiguredSoul(configPath !== undefined ? { configPath } : {}, env);
|
|
56
|
+
if (configured) {
|
|
57
|
+
const entry = { soul: configured.soul, path: configured.path };
|
|
58
|
+
const clash = entries.findIndex((candidate) => candidate.soul.agent.id === configured.soul.agent.id);
|
|
59
|
+
// Replaced, not skipped: a roster file claiming the configured
|
|
60
|
+
// soul's id is the one the gateway stops serving — both commands
|
|
61
|
+
// must answer for the soul a dispatch actually runs.
|
|
62
|
+
if (clash >= 0) {
|
|
63
|
+
entries[clash] = entry;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
entries.push(entry);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// The configured agent's allowlist was not read, so the set is not
|
|
72
|
+
// the roster — callers making enablement claims must withhold them.
|
|
73
|
+
complete = false;
|
|
74
|
+
warn(`could not read the configured soul: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
|
+
}
|
|
76
|
+
return { entries, complete };
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=roster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roster.js","sourceRoot":"","sources":["../src/roster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGpG;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;GAaG;AACH,M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AK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACrG,+DAA+D;YAC/D,iEAAiE;YACjE,qDAAqD;YACrD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mEAAmE;QACnE,oEAAoE;QACpE,QAAQ,GAAG,KAAK,CAAC;QACjB,IAAI,CAAC,uCAAuC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AgentRunner, type AgentDefinition, type JsonObject, type Session, type StratusEvent } from '@stratusagent/core';
|
|
2
|
+
import { type RuntimeSelection, type RuntimeConfig, type IgnoredUntrustedConfig } from '@stratusagent/state';
|
|
3
|
+
import type { CliStreams, CliEnvironment } from './environment.ts';
|
|
4
|
+
import type { CliApprovalMode, ParsedRunCommand } from './parse.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Kept with its historical CLI signature: a parsed run command is a
|
|
7
|
+
* RuntimeSelection plus CLI-only fields the resolver ignores.
|
|
8
|
+
*
|
|
9
|
+
* Those fields are *permitted*, not required. Demanding a whole
|
|
10
|
+
* `ParsedRunCommand` made the type claim the resolver cared about
|
|
11
|
+
* `approvals`, `format`, and `events` — it reads none of them — so every
|
|
12
|
+
* caller with a selection in hand had to invent values to get past it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveRuntimeConfig: (command: RuntimeSelection & Partial<Omit<ParsedRunCommand, keyof RuntimeSelection>>, env?: CliEnvironment) => Promise<RuntimeConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* Says, once the run is up, what an auto-discovered project config asked
|
|
17
|
+
* for and did not get. The resolver only records it — nothing is logging
|
|
18
|
+
* while a run resolves — and a persona that silently failed to apply would
|
|
19
|
+
* read as the agent ignoring its instructions rather than as the trust
|
|
20
|
+
* decision it is.
|
|
21
|
+
*/
|
|
22
|
+
export declare const warnOnUntrustedConfig: (runtime: RuntimeConfig, streams: CliStreams, soulFlag?: boolean) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The way out of a refused persona, as one sentence. `--config` trusts the
|
|
25
|
+
* file; the other way is the operator's own channel for the key — the
|
|
26
|
+
* `--soul` flag where the command takes one (`run` and `chat`; `serve` and
|
|
27
|
+
* `doctor` do not, and a notice sending the operator to a flag the daemon
|
|
28
|
+
* refuses is a notice that cost a restart), the environment otherwise.
|
|
29
|
+
* Never "move the key to ~/.stratus/config.json": the project file that
|
|
30
|
+
* caused this shadows the global one in discovery, so a key moved there
|
|
31
|
+
* would go on being unset for every run started here.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ignoredConfigRemedy: (ignored: IgnoredUntrustedConfig, soulFlag: boolean) => string;
|
|
34
|
+
/** `soulFlag`: whether the command printing this takes `--soul` — see {@link ignoredConfigRemedy}. */
|
|
35
|
+
export declare const warnOnIgnoredConfig: (ignored: IgnoredUntrustedConfig | undefined, streams: CliStreams, soulFlag?: boolean) => void;
|
|
36
|
+
/**
|
|
37
|
+
* A saved subscription sign-in silently demoted to per-token billing is the
|
|
38
|
+
* one config surprise that costs money — an API key in the environment
|
|
39
|
+
* outranks the stored credential, and the run otherwise looks identical.
|
|
40
|
+
* Detected from the resolved config: an apiKey where the stored credential
|
|
41
|
+
* is a subscription token means the environment won.
|
|
42
|
+
*/
|
|
43
|
+
export declare const warnOnCredentialOverride: (runtime: RuntimeConfig, streams: CliStreams, env?: CliEnvironment) => Promise<void>;
|
|
44
|
+
export declare const createAgentRuntime: (streams: CliStreams, options: {
|
|
45
|
+
events?: boolean;
|
|
46
|
+
/** Replaces the default event printer when provided. */
|
|
47
|
+
onEvent?: (event: StratusEvent) => void;
|
|
48
|
+
/** Answers --approvals ask questions when the caller owns stdin. */
|
|
49
|
+
askApproval?: (prompt: string) => Promise<string>;
|
|
50
|
+
runtime: RuntimeConfig;
|
|
51
|
+
approvals?: CliApprovalMode;
|
|
52
|
+
/** The mode came from `defaultApprovalMode`, not from a flag. */
|
|
53
|
+
approvalsDefaulted?: boolean;
|
|
54
|
+
maxTurns?: number;
|
|
55
|
+
env?: CliEnvironment;
|
|
56
|
+
/** The config this command was pinned to, for reading its `plugins` block. */
|
|
57
|
+
configPath?: string;
|
|
58
|
+
}) => Promise<{
|
|
59
|
+
runner: AgentRunner;
|
|
60
|
+
agent: AgentDefinition;
|
|
61
|
+
metadata: JsonObject;
|
|
62
|
+
disposePlugins: () => Promise<void>;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const runSingleLoop: (prompt: string, streams: CliStreams, options: {
|
|
65
|
+
events?: boolean;
|
|
66
|
+
runtime: RuntimeConfig;
|
|
67
|
+
approvals?: CliApprovalMode;
|
|
68
|
+
/** The mode came from `defaultApprovalMode`, not from a flag. */
|
|
69
|
+
approvalsDefaulted?: boolean;
|
|
70
|
+
maxTurns?: number;
|
|
71
|
+
env?: CliEnvironment;
|
|
72
|
+
configPath?: string;
|
|
73
|
+
}) => Promise<Session>;
|
|
74
|
+
export declare const printSessionSummary: (session: Session, streams: CliStreams) => void;
|
|
75
|
+
export declare const formatRuntimeBanner: (runtime: RuntimeConfig) => string;
|
|
76
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.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