@stratusagent/cli 0.13.6 → 0.13.7
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/commands/agent-new.d.ts.map +1 -1
- package/dist/commands/agent-new.js +3 -11
- package/dist/commands/agent-new.js.map +1 -1
- package/dist/commands/channel.d.ts.map +1 -1
- package/dist/commands/channel.js +5 -0
- package/dist/commands/channel.js.map +1 -1
- package/dist/commands/dashboard.d.ts.map +1 -1
- package/dist/commands/dashboard.js +157 -7
- package/dist/commands/dashboard.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +81 -14
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +2 -2
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +12 -5
- package/dist/commands/serve.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +128 -126
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/signin.d.ts.map +1 -1
- package/dist/commands/signin.js +32 -3
- package/dist/commands/signin.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +71 -16
- package/dist/commands/update.js.map +1 -1
- package/dist/companions.d.ts.map +1 -1
- package/dist/companions.js +2 -2
- package/dist/companions.js.map +1 -1
- package/dist/environment.d.ts +5 -0
- package/dist/environment.d.ts.map +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +10 -6
- package/dist/help.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +14 -7
- package/dist/main.js.map +1 -1
- package/dist/npm.d.ts +17 -1
- package/dist/npm.d.ts.map +1 -1
- package/dist/npm.js +21 -6
- package/dist/npm.js.map +1 -1
- package/dist/parse.d.ts +5 -0
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +12 -1
- package/dist/parse.js.map +1 -1
- package/dist/plugin-catalog.d.ts +0 -9
- package/dist/plugin-catalog.d.ts.map +1 -1
- package/dist/plugin-catalog.js +3 -14
- package/dist/plugin-catalog.js.map +1 -1
- package/dist/plugin-index.d.ts +136 -0
- package/dist/plugin-index.d.ts.map +1 -0
- package/dist/plugin-index.js +293 -0
- package/dist/plugin-index.js.map +1 -0
- package/dist/plugin-updates.d.ts +54 -0
- package/dist/plugin-updates.d.ts.map +1 -0
- package/dist/plugin-updates.js +68 -0
- package/dist/plugin-updates.js.map +1 -0
- package/dist/provider-packages.d.ts +34 -0
- package/dist/provider-packages.d.ts.map +1 -0
- package/dist/{harness-packages.js → provider-packages.js} +19 -16
- package/dist/provider-packages.js.map +1 -0
- package/dist/roster.d.ts.map +1 -1
- package/dist/roster.js +19 -2
- package/dist/roster.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -1
- package/dist/slack.d.ts.map +1 -1
- package/dist/slack.js +4 -0
- package/dist/slack.js.map +1 -1
- package/package.json +22 -25
- package/dist/harness-packages.d.ts +0 -31
- package/dist/harness-packages.d.ts.map +0 -1
- package/dist/harness-packages.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-index.d.ts","sourceRoot":"","sources":["../src/plugin-index.ts"],"names":[],"mappings":"AACA,OAAO,EAA+D,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AACjE,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,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jG,eAAO,MAAM,mBAAmB,GAC9B,OAAO,SAAS,MAAM,EAAE,EACxB,KAAK,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,KAC/C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAWpC,CAAC;AAEF,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAID;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,YAatC,CAAC;AA6BF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,MAAM,EACZ,SAAS,aAAa,EACtB,MAAM,YAAY,KACjB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAiD/F,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,SAAS,aAAa,EACtB,MAAM,YAAY,KACjB;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAUnE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,KAAG,MAA8B,CAAC"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { isPackageName, parsePluginManifest, PLUGIN_MANIFEST_VERSION } from '@stratusagent/plugins';
|
|
3
|
+
import { isInstallableSpecifier, runNpm } from "./npm.js";
|
|
4
|
+
/**
|
|
5
|
+
* The curated plugin index: the plugins that release on their own, apart
|
|
6
|
+
* from this CLI, which setup's Plugins menu can offer under "More plugins".
|
|
7
|
+
*
|
|
8
|
+
* The packages released with the CLI are not in it. They are listed in
|
|
9
|
+
* `plugin-catalog.ts`, always match this CLI, and are already rows of the
|
|
10
|
+
* menu. The index is for everything else: `stratuslabs/plugins` and,
|
|
11
|
+
* once there are some, third-party plugins someone has reviewed.
|
|
12
|
+
*
|
|
13
|
+
* It is data in `stratuslabs/plugins`, published to npm as
|
|
14
|
+
* `@stratusagent/plugin-index`, with the list in a `stratusPluginIndex`
|
|
15
|
+
* field of that package's package.json. npm because the repository is
|
|
16
|
+
* private and npm is already the registry setup installs from, so no new
|
|
17
|
+
* host is involved; and a field rather than a file because `npm view`
|
|
18
|
+
* returns package.json fields without downloading anything.
|
|
19
|
+
*
|
|
20
|
+
* The index decides what setup *suggests*, never what it trusts or what a
|
|
21
|
+
* plugin contributes: that is read from the plugin's own release, and
|
|
22
|
+
* setup still asks before enabling anything.
|
|
23
|
+
*/
|
|
24
|
+
export const PLUGIN_INDEX_PACKAGE = '@stratusagent/plugin-index';
|
|
25
|
+
export const PLUGIN_INDEX_FIELD = 'stratusPluginIndex';
|
|
26
|
+
export const PLUGIN_INDEX_SCHEMA_VERSION = 1;
|
|
27
|
+
/**
|
|
28
|
+
* The index as it was when this CLI was released: what setup shows when npm
|
|
29
|
+
* has no index or cannot be reached. Keep it equal to `index/package.json`
|
|
30
|
+
* in `stratuslabs/plugins` at release time.
|
|
31
|
+
*/
|
|
32
|
+
export const BUNDLED_PLUGIN_INDEX = [
|
|
33
|
+
{ name: '@stratusagent/plugin-spawn', description: 'Run several tasks at once in short-lived sub-agents' },
|
|
34
|
+
{ name: '@stratusagent/plugin-peer', description: 'Hand a task to an agent on another Stratus daemon' },
|
|
35
|
+
{ name: '@stratusagent/plugin-fleet', description: 'Read-only fleet metadata for an agent that reports what needs a person' },
|
|
36
|
+
{ name: '@stratusagent/plugin-a2ui', description: 'Show a native screen as A2UI, checked against your catalogs' },
|
|
37
|
+
{ name: '@stratusagent/plugin-dreams', description: 'Overnight experiment runs and a morning report (macOS)' },
|
|
38
|
+
];
|
|
39
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
40
|
+
/**
|
|
41
|
+
* Line breaks and control characters (C0, DEL, C1, and the Unicode line and
|
|
42
|
+
* paragraph separators). Index text and registry versions are printed
|
|
43
|
+
* straight into setup's menu: a line break breaks the row, and an escape
|
|
44
|
+
* sequence is something the terminal would act on.
|
|
45
|
+
*/
|
|
46
|
+
const UNPRINTABLE = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
|
|
47
|
+
/** A version as npm publishes one: semver's characters and nothing else. */
|
|
48
|
+
const PLAIN_VERSION = /^[0-9A-Za-z.+-]+$/;
|
|
49
|
+
/**
|
|
50
|
+
* The entries of an index this CLI can read, or `undefined` for anything
|
|
51
|
+
* else. An entry without a package name npm could be handed is dropped,
|
|
52
|
+
* since the names reach `npm view` and `npm install -g`, and on Windows
|
|
53
|
+
* those run through a shell. So is one whose description is empty or has a
|
|
54
|
+
* line break or control character.
|
|
55
|
+
*/
|
|
56
|
+
export const parsePluginIndex = (value) => {
|
|
57
|
+
if (!isObject(value) || value.schemaVersion !== PLUGIN_INDEX_SCHEMA_VERSION || !Array.isArray(value.plugins)) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const entries = [];
|
|
61
|
+
const seen = new Set();
|
|
62
|
+
for (const entry of value.plugins) {
|
|
63
|
+
if (!isObject(entry) || typeof entry.name !== 'string' || typeof entry.description !== 'string') {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const description = entry.description.trim();
|
|
67
|
+
if (!isPackageName(entry.name) || description.length === 0 || UNPRINTABLE.test(description) || seen.has(entry.name)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
seen.add(entry.name);
|
|
71
|
+
entries.push({ name: entry.name, description });
|
|
72
|
+
}
|
|
73
|
+
return entries;
|
|
74
|
+
};
|
|
75
|
+
export const defaultPluginIndexReader = async () => {
|
|
76
|
+
const result = await runNpm(['view', `${PLUGIN_INDEX_PACKAGE}@latest`, PLUGIN_INDEX_FIELD, '--json']);
|
|
77
|
+
if (result === undefined || result.code !== 0 || result.stdout.trim().length === 0) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(result.stdout);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/** The index to show, and whether it came from npm or this CLI's own copy. */
|
|
88
|
+
export const readPluginIndex = async (env) => {
|
|
89
|
+
const published = await (env.pluginIndexReader ?? defaultPluginIndexReader)().catch(() => undefined);
|
|
90
|
+
const entries = parsePluginIndex(published);
|
|
91
|
+
return entries === undefined
|
|
92
|
+
? { source: 'bundled', entries: [...BUNDLED_PLUGIN_INDEX] }
|
|
93
|
+
: { source: 'npm', entries };
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Reads `npm view <name>@latest version stratus os cpu libc --json`.
|
|
97
|
+
*
|
|
98
|
+
* npm prints an object when more than one requested field exists and the
|
|
99
|
+
* bare value when only one does. `version` always exists, so a bare string
|
|
100
|
+
* is a release with neither a manifest nor an os field.
|
|
101
|
+
*/
|
|
102
|
+
export const parseNpmView = (result) => {
|
|
103
|
+
if (result === undefined) {
|
|
104
|
+
return { status: 'unknown' };
|
|
105
|
+
}
|
|
106
|
+
let printed;
|
|
107
|
+
try {
|
|
108
|
+
printed = result.stdout.trim().length > 0 ? JSON.parse(result.stdout) : undefined;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
printed = undefined;
|
|
112
|
+
}
|
|
113
|
+
if (result.code !== 0) {
|
|
114
|
+
const code = isObject(printed) && isObject(printed.error) ? printed.error.code : undefined;
|
|
115
|
+
return code === 'E404' || /\bE404\b/.test(result.stderr) ? { status: 'unpublished' } : { status: 'unknown' };
|
|
116
|
+
}
|
|
117
|
+
// The version is printed in setup's reason lines, and the registry is
|
|
118
|
+
// whichever one the operator's npm points at.
|
|
119
|
+
if (typeof printed === 'string') {
|
|
120
|
+
return PLAIN_VERSION.test(printed) ? { status: 'published', version: printed } : { status: 'unknown' };
|
|
121
|
+
}
|
|
122
|
+
if (!isObject(printed) || typeof printed.version !== 'string' || !PLAIN_VERSION.test(printed.version)) {
|
|
123
|
+
return { status: 'unknown' };
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
status: 'published',
|
|
127
|
+
version: printed.version,
|
|
128
|
+
...('stratus' in printed ? { stratus: printed.stratus } : {}),
|
|
129
|
+
...('os' in printed ? { os: printed.os } : {}),
|
|
130
|
+
...('cpu' in printed ? { cpu: printed.cpu } : {}),
|
|
131
|
+
...('libc' in printed ? { libc: printed.libc } : {}),
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export const defaultPluginReleaseReader = async (name) => {
|
|
135
|
+
if (!isPackageName(name)) {
|
|
136
|
+
return { status: 'unknown' };
|
|
137
|
+
}
|
|
138
|
+
return parseNpmView(await runNpm(['view', `${name}@latest`, 'version', 'stratus', 'os', 'cpu', 'libc', '--json']));
|
|
139
|
+
};
|
|
140
|
+
/** How many `npm view` processes run at once. Each is a Node process. */
|
|
141
|
+
const RELEASE_CHECK_CONCURRENCY = 4;
|
|
142
|
+
/** Asks npm about each name once, a few at a time. A reader that throws is an unknown answer. */
|
|
143
|
+
export const checkPluginReleases = async (names, env) => {
|
|
144
|
+
const read = env.pluginReleaseReader ?? defaultPluginReleaseReader;
|
|
145
|
+
const queue = [...new Set(names)];
|
|
146
|
+
const releases = new Map();
|
|
147
|
+
const worker = async () => {
|
|
148
|
+
for (let name = queue.shift(); name !== undefined; name = queue.shift()) {
|
|
149
|
+
releases.set(name, await read(name).catch(() => ({ status: 'unknown' })));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
await Promise.all(Array.from({ length: Math.min(RELEASE_CHECK_CONCURRENCY, queue.length) }, worker));
|
|
153
|
+
return releases;
|
|
154
|
+
};
|
|
155
|
+
let libcFamily;
|
|
156
|
+
/**
|
|
157
|
+
* This machine, read the way npm reads it before an install: libc only on
|
|
158
|
+
* Linux, from `/usr/bin/ldd` and then the process report.
|
|
159
|
+
*/
|
|
160
|
+
export const currentPlatformHost = () => {
|
|
161
|
+
if (process.platform === 'linux' && libcFamily === undefined) {
|
|
162
|
+
try {
|
|
163
|
+
const ldd = readFileSync('/usr/bin/ldd', 'utf8');
|
|
164
|
+
libcFamily = ldd.includes('musl') ? 'musl' : ldd.includes('GNU C Library') ? 'glibc' : null;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
const report = process.report?.getReport();
|
|
168
|
+
libcFamily = report?.header?.glibcVersionRuntime
|
|
169
|
+
? 'glibc'
|
|
170
|
+
: report?.sharedObjects?.some((file) => file.includes('libc.musl-') || file.includes('ld-musl-')) ? 'musl' : null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { os: process.platform, cpu: process.arch, libc: process.platform === 'linux' ? libcFamily ?? null : null };
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* npm's own reading of an `os`, `cpu` or `libc` field (npm-install-checks
|
|
177
|
+
* `checkList`): a `!name` entry excludes that value, any plain entry makes
|
|
178
|
+
* the list an allowlist, and `any` alone allows everything. A field that is
|
|
179
|
+
* neither a string nor a list of strings is one npm would not enforce
|
|
180
|
+
* either.
|
|
181
|
+
*/
|
|
182
|
+
const listAllows = (field, value) => {
|
|
183
|
+
const list = typeof field === 'string' ? [field] : Array.isArray(field) && field.every((entry) => typeof entry === 'string') ? field : undefined;
|
|
184
|
+
if (list === undefined || list.length === 0 || (list.length === 1 && list[0] === 'any')) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
let negated = 0;
|
|
188
|
+
let match = false;
|
|
189
|
+
for (const entry of list) {
|
|
190
|
+
if (entry.startsWith('!')) {
|
|
191
|
+
negated += 1;
|
|
192
|
+
if (entry.slice(1) === value) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (entry === value) {
|
|
197
|
+
match = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return match || negated === list.length;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Whether a release would install and load here, read from the release
|
|
204
|
+
* itself rather than the index. Each check defers to the code that would
|
|
205
|
+
* refuse it later: the loader's own manifest parser, npm's platform checks,
|
|
206
|
+
* and the installer's fence on what reaches npm. Only the latest release is
|
|
207
|
+
* asked about, and whoever installs it pins exactly that version. One that
|
|
208
|
+
* fails is never installed, so a publisher's incompatible release can't
|
|
209
|
+
* break an older CLI.
|
|
210
|
+
*
|
|
211
|
+
* `stratus update` uses this as it is. Setup's More plugins adds one more
|
|
212
|
+
* condition on top (`releaseVerdict`).
|
|
213
|
+
*/
|
|
214
|
+
export const loadableRelease = (name, release, host) => {
|
|
215
|
+
if (release.status === 'unpublished') {
|
|
216
|
+
return { ok: false, reason: 'not on npm yet' };
|
|
217
|
+
}
|
|
218
|
+
if (release.status === 'unknown') {
|
|
219
|
+
return { ok: false, reason: 'npm did not answer' };
|
|
220
|
+
}
|
|
221
|
+
const { version, stratus } = release;
|
|
222
|
+
if (!isObject(stratus)) {
|
|
223
|
+
return { ok: false, reason: `its latest release (${version}) is not a Stratus plugin` };
|
|
224
|
+
}
|
|
225
|
+
if (stratus.pluginVersion !== PLUGIN_MANIFEST_VERSION) {
|
|
226
|
+
return {
|
|
227
|
+
ok: false,
|
|
228
|
+
reason: `its latest release (${version}) is plugin version ${JSON.stringify(stratus.pluginVersion)}, and this CLI loads version ${PLUGIN_MANIFEST_VERSION}`,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
let contributes;
|
|
232
|
+
try {
|
|
233
|
+
({ contributes } = parsePluginManifest({ name, stratus }, name));
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
// The loader quotes what it refuses with JSON.stringify, and anything
|
|
237
|
+
// that still is not printable goes, since this is printed to a terminal.
|
|
238
|
+
const message = (error instanceof Error ? error.message : String(error)).replace(new RegExp(UNPRINTABLE.source, 'g'), '');
|
|
239
|
+
return { ok: false, reason: `its latest release (${version}) has a manifest this CLI would refuse: ${message}` };
|
|
240
|
+
}
|
|
241
|
+
// The checks npm makes before it installs (checkPlatform), so npm does
|
|
242
|
+
// not refuse with EBADPLATFORM what was just judged installable.
|
|
243
|
+
if (!listAllows(release.os, host.os)) {
|
|
244
|
+
return { ok: false, reason: `it does not run on ${host.os}` };
|
|
245
|
+
}
|
|
246
|
+
if (!listAllows(release.cpu, host.cpu)) {
|
|
247
|
+
return { ok: false, reason: `it does not run on ${host.cpu}` };
|
|
248
|
+
}
|
|
249
|
+
if (release.libc !== undefined && release.libc !== null && host.libc === null) {
|
|
250
|
+
return { ok: false, reason: 'it needs a libc this host does not report' };
|
|
251
|
+
}
|
|
252
|
+
if (host.libc !== null && !listAllows(release.libc, host.libc)) {
|
|
253
|
+
return { ok: false, reason: `it does not run with ${host.libc}` };
|
|
254
|
+
}
|
|
255
|
+
// Last, the installer's own fence on what reaches npm (a shell on
|
|
256
|
+
// Windows): a release the installer then refuses is a dead end.
|
|
257
|
+
if (!isInstallableSpecifier(installSpecifier(name, version))) {
|
|
258
|
+
return {
|
|
259
|
+
ok: false,
|
|
260
|
+
reason: `this CLI can't pass its latest release (${version}) to npm; run npm install -g ${installSpecifier(name, version)} yourself`,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return { ok: true, version, contributes };
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Whether setup's More plugins offers a release: it has to be loadable
|
|
267
|
+
* (`loadableRelease`), and it has to add tools, since setup's Plugins menu
|
|
268
|
+
* is a tools menu.
|
|
269
|
+
*
|
|
270
|
+
* A package that is already installed but not configured goes to the
|
|
271
|
+
* normal enable path, which checks the installed copy's manifest with the
|
|
272
|
+
* loader's preflight before writing anything. Setup doesn't replace a copy
|
|
273
|
+
* the operator installed; keeping it current is `stratus update`'s job.
|
|
274
|
+
*/
|
|
275
|
+
export const releaseVerdict = (name, release, host) => {
|
|
276
|
+
const loadable = loadableRelease(name, release, host);
|
|
277
|
+
if (!loadable.ok) {
|
|
278
|
+
return { offer: false, reason: loadable.reason };
|
|
279
|
+
}
|
|
280
|
+
const { contributes } = loadable;
|
|
281
|
+
if (contributes.tools.length === 0 && contributes.toolsDiscovered.length === 0) {
|
|
282
|
+
return { offer: false, reason: 'it adds no tools' };
|
|
283
|
+
}
|
|
284
|
+
return { offer: true, version: loadable.version };
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* What setup hands `npm install -g` for a release it checked: that exact
|
|
288
|
+
* version. A bare name installs whatever npm's configured `tag` points at,
|
|
289
|
+
* which need not be the `latest` release the checks above passed. The
|
|
290
|
+
* `plugins` key stays the bare name, since that is what the loader imports.
|
|
291
|
+
*/
|
|
292
|
+
export const installSpecifier = (name, version) => `${name}@${version}`;
|
|
293
|
+
//# sourceMappingURL=plugin-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-index.js","sourceRoot":"","sources":["../src/plugin-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,uBAAuB,EAA4B,MAAM,uBAAuB,CAAC;AAE9H,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAS7C;;;;GAIG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OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IACjC,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAU,EAAE,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CliEnvironment } from './environment.ts';
|
|
2
|
+
/** One configured plugin that releases apart from the CLI, and what `stratus update` can do about it. */
|
|
3
|
+
export type PluginUpdate = {
|
|
4
|
+
name: string;
|
|
5
|
+
installed: string;
|
|
6
|
+
state: 'current';
|
|
7
|
+
}
|
|
8
|
+
/** Its latest release is newer and would load here: install exactly `version`. */
|
|
9
|
+
| {
|
|
10
|
+
name: string;
|
|
11
|
+
installed: string;
|
|
12
|
+
state: 'behind';
|
|
13
|
+
version: string;
|
|
14
|
+
}
|
|
15
|
+
/** Its latest release is newer, and this CLI would refuse it. */
|
|
16
|
+
| {
|
|
17
|
+
name: string;
|
|
18
|
+
installed: string;
|
|
19
|
+
state: 'held';
|
|
20
|
+
version: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
/** npm gave no answer about it. */
|
|
24
|
+
| {
|
|
25
|
+
name: string;
|
|
26
|
+
installed: string;
|
|
27
|
+
state: 'unchecked';
|
|
28
|
+
reason: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The plugins this machine runs that release on their own (everything from
|
|
32
|
+
* `stratuslabs/plugins`, and anyone else's), and whether each lags its
|
|
33
|
+
* latest release.
|
|
34
|
+
*
|
|
35
|
+
* The inventory is the trusted config's `plugins` block, read the way the
|
|
36
|
+
* daemon reads it, narrowed to packages that are installed here: that is
|
|
37
|
+
* what the daemon loads. Not the curated index, so a plugin installed by
|
|
38
|
+
* hand, or later dropped from the index, is still kept current, and a
|
|
39
|
+
* package that moves out of the monorepo keeps upgrading where it is
|
|
40
|
+
* configured. A plugin installed but never configured is not loaded, and
|
|
41
|
+
* setup's enable path checks its installed copy before using it.
|
|
42
|
+
*
|
|
43
|
+
* A newer release counts only if this build would load it, judged as
|
|
44
|
+
* setup's More plugins judges one (`loadableRelease`), so an update never
|
|
45
|
+
* moves a plugin to a release the loader would then refuse. Only the
|
|
46
|
+
* latest release is asked about; one that fails is reported as held and
|
|
47
|
+
* the installed copy stays.
|
|
48
|
+
*
|
|
49
|
+
* A config that can't be read gives no inventory rather than an error:
|
|
50
|
+
* the daemon would load no plugins from it either, and `doctor` is the
|
|
51
|
+
* command that reports why.
|
|
52
|
+
*/
|
|
53
|
+
export declare const readPluginUpdates: (env: CliEnvironment, configPath: string | undefined) => Promise<PluginUpdate[]>;
|
|
54
|
+
//# sourceMappingURL=plugin-updates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-updates.d.ts","sourceRoot":"","sources":["../src/plugin-updates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,yGAAyG;AACzG,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE;AACvD,kFAAkF;GAChF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACvE,iEAAiE;GAC/D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACrF,mCAAmC;GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAY5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,cAAc,EACnB,YAAY,MAAM,GAAG,SAAS,KAC7B,OAAO,CAAC,YAAY,EAAE,CA6BxB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isPackageName } from '@stratusagent/plugins';
|
|
2
|
+
import { CLI_PACKAGE_NAME, compareVersions, defaultInstalledVersionReader } from "./npm.js";
|
|
3
|
+
import { FIRST_PARTY_CAPABILITY_PACKAGES, FIRST_PARTY_COMPANION_PACKAGES, } from "./plugin-catalog.js";
|
|
4
|
+
import { checkPluginReleases, currentPlatformHost, loadableRelease } from "./plugin-index.js";
|
|
5
|
+
import { loadServePlugins } from "./trusted-config.js";
|
|
6
|
+
/**
|
|
7
|
+
* The packages released with the CLI. `readCompanions` holds them to the
|
|
8
|
+
* CLI's own version, so they are never part of this sweep.
|
|
9
|
+
*/
|
|
10
|
+
const RELEASED_WITH_THE_CLI = new Set([
|
|
11
|
+
CLI_PACKAGE_NAME,
|
|
12
|
+
...FIRST_PARTY_COMPANION_PACKAGES,
|
|
13
|
+
...FIRST_PARTY_CAPABILITY_PACKAGES,
|
|
14
|
+
]);
|
|
15
|
+
/**
|
|
16
|
+
* The plugins this machine runs that release on their own (everything from
|
|
17
|
+
* `stratuslabs/plugins`, and anyone else's), and whether each lags its
|
|
18
|
+
* latest release.
|
|
19
|
+
*
|
|
20
|
+
* The inventory is the trusted config's `plugins` block, read the way the
|
|
21
|
+
* daemon reads it, narrowed to packages that are installed here: that is
|
|
22
|
+
* what the daemon loads. Not the curated index, so a plugin installed by
|
|
23
|
+
* hand, or later dropped from the index, is still kept current, and a
|
|
24
|
+
* package that moves out of the monorepo keeps upgrading where it is
|
|
25
|
+
* configured. A plugin installed but never configured is not loaded, and
|
|
26
|
+
* setup's enable path checks its installed copy before using it.
|
|
27
|
+
*
|
|
28
|
+
* A newer release counts only if this build would load it, judged as
|
|
29
|
+
* setup's More plugins judges one (`loadableRelease`), so an update never
|
|
30
|
+
* moves a plugin to a release the loader would then refuse. Only the
|
|
31
|
+
* latest release is asked about; one that fails is reported as held and
|
|
32
|
+
* the installed copy stays.
|
|
33
|
+
*
|
|
34
|
+
* A config that can't be read gives no inventory rather than an error:
|
|
35
|
+
* the daemon would load no plugins from it either, and `doctor` is the
|
|
36
|
+
* command that reports why.
|
|
37
|
+
*/
|
|
38
|
+
export const readPluginUpdates = async (env, configPath) => {
|
|
39
|
+
const configured = Object.keys(await loadServePlugins(env, configPath, () => { }).catch(() => ({})))
|
|
40
|
+
.filter((name) => isPackageName(name) && !RELEASED_WITH_THE_CLI.has(name));
|
|
41
|
+
const read = env.installedVersionReader ?? defaultInstalledVersionReader;
|
|
42
|
+
const installed = [];
|
|
43
|
+
for (const name of configured) {
|
|
44
|
+
const version = await read(name).catch(() => undefined);
|
|
45
|
+
if (version !== undefined) {
|
|
46
|
+
installed.push({ name, version });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (installed.length === 0) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const releases = await checkPluginReleases(installed.map((entry) => entry.name), env);
|
|
53
|
+
const host = currentPlatformHost();
|
|
54
|
+
return installed.map(({ name, version }) => {
|
|
55
|
+
const release = releases.get(name) ?? { status: 'unknown' };
|
|
56
|
+
if (release.status !== 'published') {
|
|
57
|
+
return { name, installed: version, state: 'unchecked', reason: release.status === 'unknown' ? 'npm did not answer' : 'not on npm' };
|
|
58
|
+
}
|
|
59
|
+
if (compareVersions(release.version, version) <= 0) {
|
|
60
|
+
return { name, installed: version, state: 'current' };
|
|
61
|
+
}
|
|
62
|
+
const loadable = loadableRelease(name, release, host);
|
|
63
|
+
return loadable.ok
|
|
64
|
+
? { name, installed: version, state: 'behind', version: loadable.version }
|
|
65
|
+
: { name, installed: version, state: 'held', version: release.version, reason: loadable.reason };
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=plugin-updates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-updates.js","sourceRoot":"","sources":["../src/plugin-updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAC5F,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAYvD;;;GAGG;AACH,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,gBAAgB;IAChB,GAAG,8BAA8B;IACjC,GAAG,+BAA+B;CACnC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,GAAmB,EACnB,UAA8B,EACL,EAAE;IAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,GAAE,C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O,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;QACtI,CAAC;QACD,IAAI,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACxD,CAAC;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,EAAE;YAChB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;YAC1E,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CliEnvironment, CliStreams } from './environment.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The provider packages (anthropic, claude-code, codex) that the agents
|
|
4
|
+
* this config serves run on and that are not installed here.
|
|
5
|
+
*
|
|
6
|
+
* None ships with the CLI: the harnesses each bring a native binary of a
|
|
7
|
+
* few hundred MB, and a fresh install carries no provider at all, so most
|
|
8
|
+
* machines have only the one they picked. Whatever decides a provider
|
|
9
|
+
* (setup) or replaces the CLI (update) has to put the one in use beside it.
|
|
10
|
+
* Read through `servedRuntimes`, the same resolution the daemon and doctor
|
|
11
|
+
* use, so a soul that pins its own provider counts; a runtime that does not
|
|
12
|
+
* resolve is left to the checks that report that.
|
|
13
|
+
*/
|
|
14
|
+
export declare const missingProviderPackages: (env: CliEnvironment, configPath?: string,
|
|
15
|
+
/** Setup and update, which install what a service started later runs on. */
|
|
16
|
+
options?: {
|
|
17
|
+
asService?: boolean;
|
|
18
|
+
}) => Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Installs `packages` at this CLI's own version (they ship in lockstep) and
|
|
21
|
+
* says so. Returns whether npm succeeded. Never throws: the caller has
|
|
22
|
+
* already saved what it saved, and a missing provider fails only the turns
|
|
23
|
+
* that need it, with the install command.
|
|
24
|
+
*/
|
|
25
|
+
export declare const installProviderPackages: (packages: readonly string[], streams: CliStreams, env: CliEnvironment) => Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* What doctor and serve say when an agent's provider package is not
|
|
28
|
+
* installed: a plain `npm install -g @stratusagent/cli` upgrade from a build
|
|
29
|
+
* that carried it drops it (the Anthropic adapter and, earlier, the
|
|
30
|
+
* harnesses were CLI dependencies), and every turn on that provider then
|
|
31
|
+
* fails.
|
|
32
|
+
*/
|
|
33
|
+
export declare const providerPackagesMissingMessage: (packages: readonly string[]) => string;
|
|
34
|
+
//# sourceMappingURL=provider-packages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-packages.d.ts","sourceRoot":"","sources":["../src/provider-packages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,cAAc,EACnB,aAAa,MAAM;AACnB,4EAA4E;AAC5E,UAAS;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,KACpC,OAAO,CAAC,MAAM,EAAE,CAuBlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,SAAS,MAAM,EAAE,EAC3B,SAAS,UAAU,EACnB,KAAK,cAAc,KAClB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GAAI,UAAU,SAAS,MAAM,EAAE,KAAG,MAI5E,CAAC"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PROVIDER_PACKAGE_NAMES, providerPackagesUsedBy, readProcessEnv, servedRuntimes } from '@stratusagent/state';
|
|
2
2
|
import { writeLine } from "./io.js";
|
|
3
3
|
import { packageInstalled } from "./loaders.js";
|
|
4
4
|
import { CLI_VERSION, defaultPackageInstaller } from "./npm.js";
|
|
5
5
|
/**
|
|
6
|
-
* The
|
|
7
|
-
* config serves run on and that are not installed here.
|
|
6
|
+
* The provider packages (anthropic, claude-code, codex) that the agents
|
|
7
|
+
* this config serves run on and that are not installed here.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* MB, and
|
|
9
|
+
* None ships with the CLI: the harnesses each bring a native binary of a
|
|
10
|
+
* few hundred MB, and a fresh install carries no provider at all, so most
|
|
11
|
+
* machines have only the one they picked. Whatever decides a provider
|
|
11
12
|
* (setup) or replaces the CLI (update) has to put the one in use beside it.
|
|
12
13
|
* Read through `servedRuntimes`, the same resolution the daemon and doctor
|
|
13
14
|
* use, so a soul that pins its own provider counts; a runtime that does not
|
|
14
15
|
* resolve is left to the checks that report that.
|
|
15
16
|
*/
|
|
16
|
-
export const
|
|
17
|
+
export const missingProviderPackages = async (env, configPath,
|
|
17
18
|
/** Setup and update, which install what a service started later runs on. */
|
|
18
19
|
options = {}) => {
|
|
19
20
|
// With asService, resolved twice: as this shell would run it, and as the
|
|
@@ -21,7 +22,7 @@ options = {}) => {
|
|
|
21
22
|
// The unit carries only PATH, so a provider key or STRATUS_* override
|
|
22
23
|
// exported here (ANTHROPIC_API_KEY beside a stored Claude sign-in, say)
|
|
23
24
|
// reaches a foreground run but never the daemon, which then needs the
|
|
24
|
-
//
|
|
25
|
+
// package this shell's view would skip. Installing one a shell override
|
|
25
26
|
// happens to avoid costs disk; missing one fails every turn.
|
|
26
27
|
const shellEnv = readProcessEnv(env);
|
|
27
28
|
const serviceEnv = {
|
|
@@ -32,18 +33,18 @@ options = {}) => {
|
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
const runtimes = (await Promise.all((options.asService ? [env, serviceEnv] : [env]).map((view) => servedRuntimes(view, configPath).catch(() => [])))).flat();
|
|
35
|
-
const used = new Set(runtimes.flatMap(({ runtime }) =>
|
|
36
|
+
const used = new Set(runtimes.flatMap(({ runtime }) => providerPackagesUsedBy(runtime)));
|
|
36
37
|
return [...used]
|
|
37
|
-
.map((
|
|
38
|
+
.map((pkg) => PROVIDER_PACKAGE_NAMES[pkg])
|
|
38
39
|
.filter((name) => !packageInstalled(name, env));
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
41
42
|
* Installs `packages` at this CLI's own version (they ship in lockstep) and
|
|
42
43
|
* says so. Returns whether npm succeeded. Never throws: the caller has
|
|
43
|
-
* already saved what it saved, and a missing
|
|
44
|
+
* already saved what it saved, and a missing provider fails only the turns
|
|
44
45
|
* that need it, with the install command.
|
|
45
46
|
*/
|
|
46
|
-
export const
|
|
47
|
+
export const installProviderPackages = async (packages, streams, env) => {
|
|
47
48
|
if (packages.length === 0) {
|
|
48
49
|
return true;
|
|
49
50
|
}
|
|
@@ -61,13 +62,15 @@ export const installHarnessPackages = async (packages, streams, env) => {
|
|
|
61
62
|
return false;
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
|
-
* What doctor and serve say when an agent's
|
|
65
|
-
* plain `npm install -g @stratusagent/cli` upgrade from a build
|
|
66
|
-
*
|
|
65
|
+
* What doctor and serve say when an agent's provider package is not
|
|
66
|
+
* installed: a plain `npm install -g @stratusagent/cli` upgrade from a build
|
|
67
|
+
* that carried it drops it (the Anthropic adapter and, earlier, the
|
|
68
|
+
* harnesses were CLI dependencies), and every turn on that provider then
|
|
69
|
+
* fails.
|
|
67
70
|
*/
|
|
68
|
-
export const
|
|
71
|
+
export const providerPackagesMissingMessage = (packages) => {
|
|
69
72
|
const one = packages.length === 1;
|
|
70
73
|
return `${packages.join(' and ')} ${one ? 'is' : 'are'} not installed, and ${one ? 'an agent runs on it' : 'agents run on them'}, so ${one ? 'its' : 'their'} turns fail. `
|
|
71
74
|
+ `Run \`stratus update\` or \`npm install -g ${packages.map((name) => `${name}@${CLI_VERSION}`).join(' ')}\`, then restart the daemon.`;
|
|
72
75
|
};
|
|
73
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=provider-packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-packages.js","sourceRoot":"","sources":["../src/provider-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,GAAmB,EACnB,UAAmB;AACnB,4EAA4E;AAC5E,UAAmC,EAAE,EAClB,EAAE;IACrB,yEAAyE;IACzE,iBAAiB;IACjB,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,wEAAwE;IACxE,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,UAAU,GAAmB;QACjC,GAAG,GAAG;QACN,UAAU,EAAE;YACV,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE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AG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,uBAAuB,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,oBAAoB,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,eAAe;UACvK,8CAA8C,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,8BAA8B,CAAC;AAC7I,CAAC,CAAC"}
|
package/dist/roster.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roster.d.ts","sourceRoot":"","sources":["../src/roster.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"roster.d.ts","sourceRoot":"","sources":["../src/roster.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AACnH,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,CAkDrF,CAAC"}
|
package/dist/roster.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { matchesToolAllowlist, toolScopesOverlap } from '@stratusagent/core';
|
|
2
|
-
import { DEFAULT_STRATUS_AGENT, loadRosterSouls, resolveConfiguredSoul } from '@stratusagent/state';
|
|
2
|
+
import { DEFAULT_STRATUS_AGENT, foldedAgentId, loadRosterSouls, resolveConfiguredSoul } from '@stratusagent/state';
|
|
3
3
|
/**
|
|
4
4
|
* npm's package-name grammar, and nothing else: an optional `@scope/`, then
|
|
5
5
|
* lowercase alphanumerics with `-`, `_` and `.`, no leading `.` or `_`, 214
|
|
@@ -53,7 +53,24 @@ export const rosterSoulsWithConfigured = async (env, warn, options = {}) => {
|
|
|
53
53
|
let complete = true;
|
|
54
54
|
try {
|
|
55
55
|
const configured = await resolveConfiguredSoul(configPath !== undefined ? { configPath } : {}, env);
|
|
56
|
-
|
|
56
|
+
// The gateway's rule for a default soul that never went through the
|
|
57
|
+
// roster's fold check (stateDirectoryPeer in defaultAgentId): an id
|
|
58
|
+
// that names another agent's state directory without being that id,
|
|
59
|
+
// `Stratus` beside the built-in or `Ava` beside roster `ava`, is
|
|
60
|
+
// dropped and default dispatches go to the built-in. The built-in is
|
|
61
|
+
// always registered there, so it is folded against here whether or not
|
|
62
|
+
// the caller lists it.
|
|
63
|
+
const id = configured?.soul.agent.id;
|
|
64
|
+
const peer = id === undefined
|
|
65
|
+
? undefined
|
|
66
|
+
: [DEFAULT_STRATUS_AGENT.id, ...entries.map((candidate) => candidate.soul.agent.id)]
|
|
67
|
+
.find((other) => other !== id && foldedAgentId(other) === foldedAgentId(id));
|
|
68
|
+
if (configured && peer !== undefined) {
|
|
69
|
+
warn(`the configured default soul at ${configured.path} declares the agent id ${id}, which names the same `
|
|
70
|
+
+ `state directory as ${peer}, so the daemon ignores it and routes to ${DEFAULT_STRATUS_AGENT.id}. `
|
|
71
|
+
+ 'Rename one of the two ids.');
|
|
72
|
+
}
|
|
73
|
+
else if (configured) {
|
|
57
74
|
const entry = { soul: configured.soul, path: configured.path };
|
|
58
75
|
const clash = entries.findIndex((candidate) => candidate.soul.agent.id === configured.soul.agent.id);
|
|
59
76
|
// Replaced, not skipped: a roster file claiming the configured
|
package/dist/roster.js.map
CHANGED
|
@@ -1 +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;
|
|
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,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGnH;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoC,EACpC,IAAY,EACZ,UAAmB,EACV,EAAE;IACX,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,UAAU;QACf,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,GAAmB,EACnB,IAA4B,EAC5B,UAiBI,EAAE,EACgF,EAAE;IACxF,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,KAAK,EAAE,GAAG,OAAO,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