@stratusagent/cli 0.11.2 → 0.11.3

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.
Files changed (158) hide show
  1. package/README.md +13 -7
  2. package/dist/approvals.d.ts +87 -0
  3. package/dist/approvals.d.ts.map +1 -0
  4. package/dist/approvals.js +315 -0
  5. package/dist/approvals.js.map +1 -0
  6. package/dist/commands/agent-new.d.ts +22 -0
  7. package/dist/commands/agent-new.d.ts.map +1 -0
  8. package/dist/commands/agent-new.js +154 -0
  9. package/dist/commands/agent-new.js.map +1 -0
  10. package/dist/commands/agents.d.ts +4 -0
  11. package/dist/commands/agents.d.ts.map +1 -0
  12. package/dist/commands/agents.js +90 -0
  13. package/dist/commands/agents.js.map +1 -0
  14. package/dist/commands/chat.d.ts +4 -0
  15. package/dist/commands/chat.d.ts.map +1 -0
  16. package/dist/commands/chat.js +224 -0
  17. package/dist/commands/chat.js.map +1 -0
  18. package/dist/commands/credential.d.ts +22 -0
  19. package/dist/commands/credential.d.ts.map +1 -0
  20. package/dist/commands/credential.js +93 -0
  21. package/dist/commands/credential.js.map +1 -0
  22. package/dist/commands/dashboard.d.ts +14 -0
  23. package/dist/commands/dashboard.d.ts.map +1 -0
  24. package/dist/commands/dashboard.js +195 -0
  25. package/dist/commands/dashboard.js.map +1 -0
  26. package/dist/commands/doctor.d.ts +40 -0
  27. package/dist/commands/doctor.d.ts.map +1 -0
  28. package/dist/commands/doctor.js +357 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/grants.d.ts +19 -0
  31. package/dist/commands/grants.d.ts.map +1 -0
  32. package/dist/commands/grants.js +128 -0
  33. package/dist/commands/grants.js.map +1 -0
  34. package/dist/commands/logs.d.ts +9 -0
  35. package/dist/commands/logs.d.ts.map +1 -0
  36. package/dist/commands/logs.js +58 -0
  37. package/dist/commands/logs.js.map +1 -0
  38. package/dist/commands/memory.d.ts +20 -0
  39. package/dist/commands/memory.d.ts.map +1 -0
  40. package/dist/commands/memory.js +110 -0
  41. package/dist/commands/memory.js.map +1 -0
  42. package/dist/commands/plugins.d.ts +91 -0
  43. package/dist/commands/plugins.d.ts.map +1 -0
  44. package/dist/commands/plugins.js +359 -0
  45. package/dist/commands/plugins.js.map +1 -0
  46. package/dist/commands/restart.d.ts +4 -0
  47. package/dist/commands/restart.d.ts.map +1 -0
  48. package/dist/commands/restart.js +25 -0
  49. package/dist/commands/restart.js.map +1 -0
  50. package/dist/commands/schedules.d.ts +11 -0
  51. package/dist/commands/schedules.d.ts.map +1 -0
  52. package/dist/commands/schedules.js +50 -0
  53. package/dist/commands/schedules.js.map +1 -0
  54. package/dist/commands/serve.d.ts +4 -0
  55. package/dist/commands/serve.d.ts.map +1 -0
  56. package/dist/commands/serve.js +612 -0
  57. package/dist/commands/serve.js.map +1 -0
  58. package/dist/commands/service.d.ts +9 -0
  59. package/dist/commands/service.d.ts.map +1 -0
  60. package/dist/commands/service.js +97 -0
  61. package/dist/commands/service.js.map +1 -0
  62. package/dist/commands/session.d.ts +9 -0
  63. package/dist/commands/session.d.ts.map +1 -0
  64. package/dist/commands/session.js +25 -0
  65. package/dist/commands/session.js.map +1 -0
  66. package/dist/commands/setup.d.ts +5 -0
  67. package/dist/commands/setup.d.ts.map +1 -0
  68. package/dist/commands/setup.js +2412 -0
  69. package/dist/commands/setup.js.map +1 -0
  70. package/dist/commands/skills.d.ts +15 -0
  71. package/dist/commands/skills.d.ts.map +1 -0
  72. package/dist/commands/skills.js +272 -0
  73. package/dist/commands/skills.js.map +1 -0
  74. package/dist/commands/template.d.ts +4 -0
  75. package/dist/commands/template.d.ts.map +1 -0
  76. package/dist/commands/template.js +575 -0
  77. package/dist/commands/template.js.map +1 -0
  78. package/dist/commands/update.d.ts +21 -0
  79. package/dist/commands/update.d.ts.map +1 -0
  80. package/dist/commands/update.js +291 -0
  81. package/dist/commands/update.js.map +1 -0
  82. package/dist/daemon.d.ts +74 -0
  83. package/dist/daemon.d.ts.map +1 -0
  84. package/dist/daemon.js +192 -0
  85. package/dist/daemon.js.map +1 -0
  86. package/dist/environment.d.ts +108 -0
  87. package/dist/environment.d.ts.map +1 -0
  88. package/dist/environment.js +2 -0
  89. package/dist/environment.js.map +1 -0
  90. package/dist/events.d.ts +17 -0
  91. package/dist/events.d.ts.map +1 -0
  92. package/dist/events.js +87 -0
  93. package/dist/events.js.map +1 -0
  94. package/dist/help.d.ts +2 -0
  95. package/dist/help.d.ts.map +1 -0
  96. package/dist/help.js +266 -0
  97. package/dist/help.js.map +1 -0
  98. package/dist/index.d.ts +31 -624
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +38 -6981
  101. package/dist/index.js.map +1 -1
  102. package/dist/io.d.ts +16 -0
  103. package/dist/io.d.ts.map +1 -0
  104. package/dist/io.js +45 -0
  105. package/dist/io.js.map +1 -0
  106. package/dist/loaders.d.ts +31 -0
  107. package/dist/loaders.d.ts.map +1 -0
  108. package/dist/loaders.js +56 -0
  109. package/dist/loaders.js.map +1 -0
  110. package/dist/main.d.ts +8 -0
  111. package/dist/main.d.ts.map +1 -0
  112. package/dist/main.js +214 -0
  113. package/dist/main.js.map +1 -0
  114. package/dist/npm.d.ts +66 -0
  115. package/dist/npm.d.ts.map +1 -0
  116. package/dist/npm.js +201 -0
  117. package/dist/npm.js.map +1 -0
  118. package/dist/parse.d.ts +231 -0
  119. package/dist/parse.d.ts.map +1 -0
  120. package/dist/parse.js +1082 -0
  121. package/dist/parse.js.map +1 -0
  122. package/dist/plugin-catalog.d.ts +35 -0
  123. package/dist/plugin-catalog.d.ts.map +1 -0
  124. package/dist/plugin-catalog.js +58 -0
  125. package/dist/plugin-catalog.js.map +1 -0
  126. package/dist/preflight.d.ts +60 -0
  127. package/dist/preflight.d.ts.map +1 -0
  128. package/dist/preflight.js +102 -0
  129. package/dist/preflight.js.map +1 -0
  130. package/dist/prompter.d.ts +84 -0
  131. package/dist/prompter.d.ts.map +1 -0
  132. package/dist/prompter.js +347 -0
  133. package/dist/prompter.js.map +1 -0
  134. package/dist/roster.d.ts +57 -0
  135. package/dist/roster.d.ts.map +1 -0
  136. package/dist/roster.js +78 -0
  137. package/dist/roster.js.map +1 -0
  138. package/dist/runtime.d.ts +59 -0
  139. package/dist/runtime.d.ts.map +1 -0
  140. package/dist/runtime.js +266 -0
  141. package/dist/runtime.js.map +1 -0
  142. package/dist/slack.d.ts +26 -0
  143. package/dist/slack.d.ts.map +1 -0
  144. package/dist/slack.js +113 -0
  145. package/dist/slack.js.map +1 -0
  146. package/dist/source.d.ts +24 -0
  147. package/dist/source.d.ts.map +1 -0
  148. package/dist/source.js +80 -0
  149. package/dist/source.js.map +1 -0
  150. package/dist/supervisor.d.ts +69 -0
  151. package/dist/supervisor.d.ts.map +1 -0
  152. package/dist/supervisor.js +218 -0
  153. package/dist/supervisor.js.map +1 -0
  154. package/dist/trusted-config.d.ts +71 -0
  155. package/dist/trusted-config.d.ts.map +1 -0
  156. package/dist/trusted-config.js +118 -0
  157. package/dist/trusted-config.js.map +1 -0
  158. package/package.json +25 -23
@@ -0,0 +1,291 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import { newerStateMessage, pendingStateMigrations, readStateStamp, runStateMigrations, STATE_SCHEMA_VERSION, } from '@stratusagent/state';
3
+ import { installService, readServiceCommand, readServiceStatus, serviceUnitPath, startService, stopService, } from "../service.js";
4
+ import { serviceEnvFor } from "../daemon.js";
5
+ import { writeLine, pathExists } from "../io.js";
6
+ import { defaultPackageVersionFetcher, compareVersions, defaultPackageInstaller, defaultInstalledVersionReader, CLI_VERSION, CLI_PACKAGE_NAME, } from "../npm.js";
7
+ import { FIRST_PARTY_CAPABILITY_PACKAGES, FIRST_PARTY_COMPANION_PACKAGES, } from "../plugin-catalog.js";
8
+ /**
9
+ * The first-party packages installed beside the CLI, and whether each one
10
+ * lags the version the CLI is heading for.
11
+ *
12
+ * The gap this closes: the CLI and its companions are separate global
13
+ * installs, so upgrading `@stratusagent/cli` left every one of them at
14
+ * whatever version was installed the day setup first ran. A Slack adapter
15
+ * two releases behind the daemon loading it is not a configuration anyone
16
+ * chose, and nothing reported it — `doctor` says "installed", which was
17
+ * true of the stale one too.
18
+ *
19
+ * Read from each package's own manifest rather than asked of npm: the
20
+ * question is what this machine has, one registry round trip per package
21
+ * would answer a different one, and they ship in lockstep so the CLI's
22
+ * target version is theirs.
23
+ */
24
+ const readCompanions = async (target, env) => {
25
+ const read = env.installedVersionReader ?? defaultInstalledVersionReader;
26
+ const found = [];
27
+ for (const name of [...FIRST_PARTY_COMPANION_PACKAGES, ...FIRST_PARTY_CAPABILITY_PACKAGES]) {
28
+ const version = await read(name);
29
+ if (version !== undefined) {
30
+ found.push({ name, version, stale: compareVersions(target, version) > 0 });
31
+ }
32
+ }
33
+ return found;
34
+ };
35
+ /**
36
+ * `stratus update` — the whole upgrade dance, in the order that cannot lose
37
+ * data: stop the service (so no daemon holds the session database while
38
+ * state migrates), upgrade the package, run pending migrations, rewrite the
39
+ * service unit with current paths, restart.
40
+ *
41
+ * The unit rewrite is the step that repairs the failure nothing else
42
+ * surfaces: the unit embeds absolute node and entrypoint paths (a service
43
+ * manager loads no shell profile, so it must), and upgrading node — under
44
+ * nvm, a whole new version directory — leaves the unit pointing at an
45
+ * interpreter that no longer exists. The service stops working and nothing
46
+ * says so; the agents just stop answering.
47
+ *
48
+ * Each step degrades independently: an unreachable npm skips the version
49
+ * check and package upgrade but still migrates and rewrites the unit —
50
+ * which is exactly the repair the offline case needs.
51
+ */
52
+ export const runUpdate = async (command, streams, env) => {
53
+ const serviceEnv = serviceEnvFor(env);
54
+ const out = (line) => writeLine(streams.stdout, line);
55
+ const latest = await (env.packageVersionFetcher ?? defaultPackageVersionFetcher)(CLI_PACKAGE_NAME);
56
+ const upgradeAvailable = latest !== undefined && compareVersions(latest, CLI_VERSION) > 0;
57
+ // A stamp from a newer build makes every later step wrong, not just the
58
+ // migration one: this build would migrate — and stop the daemon to do it —
59
+ // against a format it does not understand. Checked here, before anything
60
+ // has a side effect.
61
+ const stamp = await readStateStamp(env);
62
+ const stateNewer = stamp.schemaVersion > STATE_SCHEMA_VERSION;
63
+ const status = await readServiceStatus(serviceEnv).catch(() => undefined);
64
+ const unit = status?.installed ? await readServiceCommand(serviceEnv) : undefined;
65
+ const unitNotes = [];
66
+ if (status?.installed && unit?.execPath !== undefined) {
67
+ if (!(await pathExists(unit.execPath))) {
68
+ unitNotes.push(`the unit's interpreter no longer exists: ${unit.execPath} — stratusd cannot start until the unit is rewritten`);
69
+ }
70
+ else if (unit.execPath !== process.execPath) {
71
+ unitNotes.push(`the unit runs ${unit.execPath}; this shell runs ${process.execPath}`);
72
+ }
73
+ if (unit.scriptPath !== undefined && !(await pathExists(unit.scriptPath))) {
74
+ unitNotes.push(`the unit's entrypoint no longer exists: ${unit.scriptPath}`);
75
+ }
76
+ else if (unit.scriptPath !== undefined && process.argv[1] !== undefined && unit.scriptPath !== process.argv[1]) {
77
+ // A versioned package directory can keep the old file alive after an
78
+ // upgrade — the daemon then runs the old CLI indefinitely with
79
+ // nothing missing on disk to notice.
80
+ unitNotes.push(`the unit runs entrypoint ${unit.scriptPath}; this shell runs ${process.argv[1]}`);
81
+ }
82
+ }
83
+ const pending = await pendingStateMigrations(env);
84
+ // The newer of what npm offers and what this build already is, never just
85
+ // the registry's answer: a dist-tag rollback, a stale mirror, or a CLI
86
+ // installed by explicit version all answer with something older, and a
87
+ // companion matching *that* would read as current while the process
88
+ // loading it is newer — the exact mismatch this exists to end. Held to
89
+ // this build, which is also why the target needs no network to be right.
90
+ const target = latest !== undefined && compareVersions(latest, CLI_VERSION) > 0
91
+ ? latest
92
+ : CLI_VERSION;
93
+ // Against the version this run is heading for, not the one it is on: a
94
+ // CLI already current still leaves a companion behind, which is the whole
95
+ // case this reports.
96
+ const companions = await readCompanions(target, env);
97
+ const stale = companions.filter((entry) => entry.stale);
98
+ out(`stratus ${CLI_VERSION}`);
99
+ out(latest === undefined
100
+ ? ' latest unknown — npm did not answer'
101
+ : ` latest ${latest}${upgradeAvailable ? ' — update available' : ' — up to date'}`);
102
+ out(` state schema ${stamp.schemaVersion}${stateNewer
103
+ ? ` — written by a NEWER build than this one (which understands ${STATE_SCHEMA_VERSION})`
104
+ : `, ${pending.length === 0 ? 'no pending migrations' : `${pending.length} pending migration${pending.length === 1 ? '' : 's'}`}`}`);
105
+ out(` service ${status === undefined
106
+ ? `no service manager for ${process.platform}`
107
+ : status.installed
108
+ ? (status.running === undefined ? 'installed, state unknown' : status.running ? 'installed, running' : 'installed, not running')
109
+ : 'not installed'}`);
110
+ for (const note of unitNotes) {
111
+ out(` unit ${note}`);
112
+ }
113
+ if (companions.length > 0) {
114
+ // A count and then only what would change, like every other line here:
115
+ // this reports state, not an inventory — `stratus plugins` is the
116
+ // command that lists what is installed.
117
+ out(` packages ${companions.length} first-party alongside the CLI, ${stale.length === 0 ? 'none behind' : `${stale.length} behind`}`);
118
+ for (const entry of stale) {
119
+ out(` ${entry.name} ${entry.version} → ${target}`);
120
+ }
121
+ }
122
+ if (command.check) {
123
+ for (const migration of pending) {
124
+ out(` pending ${migration.id} — ${migration.description}`);
125
+ }
126
+ if (stateNewer) {
127
+ out('This build cannot update that state — upgrade the package itself (`npm install -g @stratusagent/cli`).');
128
+ return 1;
129
+ }
130
+ const actionable = upgradeAvailable || pending.length > 0 || unitNotes.length > 0 || stale.length > 0;
131
+ out(actionable
132
+ ? 'Run `stratus update` to apply the above.'
133
+ : 'Nothing to do.');
134
+ // Actionable exits 1, so a cron job or script can notice.
135
+ return actionable ? 1 : 0;
136
+ }
137
+ if (stateNewer) {
138
+ writeLine(streams.stderr, newerStateMessage(stamp.schemaVersion));
139
+ return 1;
140
+ }
141
+ if (status?.installed && (status.runAtLogin === undefined || status.running === undefined)) {
142
+ // The rewrite has to re-state the login setting and restore the prior
143
+ // run state, and the manager could not say what either currently is.
144
+ // Guessing would let a transient status failure convert a deliberate
145
+ // --no-login install, or rewrite-and-stop a daemon that was actually
146
+ // running — refuse instead, before anything has been stopped.
147
+ writeLine(streams.stderr, `Not updating: whether stratusd ${status.running === undefined ? 'is running' : 'starts at login'} could not be determined (the service manager did not answer), and the unit rewrite would have to guess. Check \`stratus service status\` and retry.`);
148
+ return 1;
149
+ }
150
+ const wasRunning = status?.running === true;
151
+ if (wasRunning) {
152
+ // No daemon may hold the session database while state migrates — this
153
+ // bracket is the one place an update could otherwise lose data.
154
+ out('Stopping stratusd for the update…');
155
+ const stopped = await stopService(serviceEnv);
156
+ for (const message of stopped.messages) {
157
+ writeLine(stopped.ok ? streams.stdout : streams.stderr, message);
158
+ }
159
+ if (!stopped.ok) {
160
+ writeLine(streams.stderr, 'Not updating while the daemon may still be running.');
161
+ return 1;
162
+ }
163
+ }
164
+ let upgradeFailed = false;
165
+ // The CLI and every companion that lags it, in one npm call: they are
166
+ // one release, and installing them separately leaves a window where the
167
+ // daemon and the adapter it loads disagree about their own version.
168
+ //
169
+ // Nothing at all when the registry did not answer, companions included:
170
+ // `@latest` cannot resolve without it, so the install would fail after
171
+ // printing a line promising a version npm never confirmed. Staleness is
172
+ // still *reported* offline — it is measured against this build, which
173
+ // needs no network — so `--check` says what an online update would fix.
174
+ const upgrading = latest === undefined ? [] : [
175
+ ...(upgradeAvailable ? [`${CLI_PACKAGE_NAME}@latest`] : []),
176
+ // `@latest` only where latest IS the target. Where this build is the
177
+ // newer one, `@latest` would install the very version the target just
178
+ // refused to be, so the companion is asked for by exact version — the
179
+ // one this CLI shipped alongside.
180
+ ...stale.map((entry) => `${entry.name}@${target === latest ? 'latest' : target}`),
181
+ ];
182
+ if (upgrading.length > 0) {
183
+ if (upgradeAvailable) {
184
+ out(`Upgrading ${CLI_PACKAGE_NAME} ${CLI_VERSION} → ${latest}…`);
185
+ }
186
+ for (const entry of stale) {
187
+ out(`Upgrading ${entry.name} ${entry.version} → ${target}…`);
188
+ }
189
+ const installed = await (env.packageInstaller ?? defaultPackageInstaller)(upgrading);
190
+ if (installed.ok) {
191
+ // This process is still the old build; migrations the new version
192
+ // adds run when it first starts — which the restart below is.
193
+ out('Upgraded. Migrations the new version adds run on its first start.');
194
+ }
195
+ else {
196
+ upgradeFailed = true;
197
+ writeLine(streams.stderr, `npm install failed: ${installed.message || 'unknown error'} — continuing with migrations and the unit rewrite.`);
198
+ }
199
+ }
200
+ else {
201
+ out(latest === undefined
202
+ ? 'Skipping the package upgrade — npm did not answer.'
203
+ : 'Package already up to date.');
204
+ }
205
+ let applied;
206
+ try {
207
+ applied = await runStateMigrations(env);
208
+ }
209
+ catch (error) {
210
+ // A daemon stopped for an update that then failed must not stay down:
211
+ // the old unit is still in place (the rewrite has not happened), so
212
+ // restarting restores the world the update found. The failure is still
213
+ // a failure — but an offline fleet on top of it is not.
214
+ writeLine(streams.stderr, `State migration failed: ${error instanceof Error ? error.message : String(error)}`);
215
+ if (wasRunning) {
216
+ const restarted = await startService(serviceEnv);
217
+ for (const message of restarted.messages) {
218
+ writeLine(restarted.ok ? streams.stdout : streams.stderr, message);
219
+ }
220
+ writeLine(streams.stderr, restarted.ok
221
+ ? 'stratusd was restarted on its previous unit. Fix the migration failure and run `stratus update` again.'
222
+ : 'stratusd could not be restarted either — bring it back with `stratus service start` once the failure is fixed.');
223
+ }
224
+ return 1;
225
+ }
226
+ if (applied.length === 0) {
227
+ out('No pending state migrations.');
228
+ }
229
+ for (const migration of applied) {
230
+ out(`Migrated: ${migration.description}${migration.detail !== undefined ? ` — ${migration.detail}` : ''}`);
231
+ }
232
+ if (status?.installed) {
233
+ out('Rewriting the service unit with current node and entrypoint paths…');
234
+ // The rewrite overwrites the unit before it bootstraps, so a failure
235
+ // in between must be able to put the old definition back — otherwise
236
+ // a stopped daemon is left with neither unit to start from.
237
+ const previousUnit = await readFile(serviceUnitPath(serviceEnv), 'utf8').catch(() => undefined);
238
+ const install = await installService(
239
+ // The unit's own working directory survives the rewrite: relative
240
+ // paths in the pinned config (a `soul`) resolve against it, so a
241
+ // rewrite run from some other directory must not substitute its own.
242
+ unit?.workingDirectory !== undefined ? { ...serviceEnv, cwd: unit.workingDirectory } : serviceEnv, {
243
+ ...(status.runAtLogin === false ? { runAtLogin: false } : {}),
244
+ // The config the existing unit was pinned to survives the rewrite —
245
+ // a unit rewritten onto a different roster is its own outage.
246
+ ...(unit?.configPath !== undefined ? { configPath: unit.configPath } : {}),
247
+ });
248
+ for (const message of install.messages) {
249
+ writeLine(install.ok ? streams.stdout : streams.stderr, message);
250
+ }
251
+ if (!install.ok) {
252
+ if (wasRunning) {
253
+ // The fleet was up when the update began and must not stay down
254
+ // over a failed rewrite: restore the previous unit definition and
255
+ // start it again. The exit code stays 1 — the update failed — but
256
+ // the world it found is put back.
257
+ if (previousUnit !== undefined) {
258
+ await writeFile(serviceUnitPath(serviceEnv), previousUnit, { mode: 0o644 }).catch((error) => {
259
+ writeLine(streams.stderr, `Could not restore the previous unit either: ${error instanceof Error ? error.message : String(error)}`);
260
+ });
261
+ }
262
+ const restarted = await startService(serviceEnv);
263
+ for (const message of restarted.messages) {
264
+ writeLine(restarted.ok ? streams.stdout : streams.stderr, message);
265
+ }
266
+ writeLine(streams.stderr, restarted.ok
267
+ ? 'The unit rewrite failed, so stratusd was restarted on its previous unit. Fix the failure above and run `stratus update` again.'
268
+ : 'The unit rewrite failed AND stratusd could not be restarted — bring it back with `stratus service start`, or `stratus service install` to rewrite the unit by hand.');
269
+ }
270
+ return 1;
271
+ }
272
+ if (!wasRunning) {
273
+ // installService starts the daemon; a service that was deliberately
274
+ // stopped before the update stays that way.
275
+ const stopped = await stopService(serviceEnv);
276
+ if (!stopped.ok) {
277
+ // The update itself succeeded, but the user's prior state was not
278
+ // restored: an intentionally stopped daemon is now running. That
279
+ // is a failure a script must see, not a footnote.
280
+ writeLine(streams.stderr, 'stratusd was not running before the update, and stopping it again failed — it is now RUNNING. Stop it with `stratus service stop`.');
281
+ return 1;
282
+ }
283
+ out('stratusd was not running before the update, so it was left stopped.');
284
+ }
285
+ }
286
+ else if (status !== undefined) {
287
+ out('No service installed — nothing to rewrite. `stratus service install` sets one up.');
288
+ }
289
+ return upgradeFailed ? 1 : 0;
290
+ };
291
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,uBAAuB,EACvB,6BAA6B,EAC7B,WAAW,EACX,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAS9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,GAAmB,EACU,EAAE;IAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,sBAAsB,IAAI,6BAA6B,CAAC;IACzE,MAAM,KAAK,GAAuB,EAAE,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,8BAA8B,EAAE,GAAG,+BAA+B,CAAC,EAAE,CAAC;QAC3F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,OAAO,C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C,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;oBACrI,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;gBACjD,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;oBACzC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACrE,CAAC;gBACD,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE;oBACpC,CAAC,CAAC,gIAAgI;oBAClI,CAAC,CAAC,qKAAqK,CAAC,CAAC;YAC7K,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,oEAAoE;YACpE,4CAA4C;YAC5C,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;gBAChB,kEAAkE;gBAClE,iEAAiE;gBACjE,kDAAkD;gBAClD,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,oIAAoI,CAAC,CAAC;gBAChK,OAAO,CAAC,CAAC;YACX,CAAC;YACD,GAAG,CAAC,qEAAqE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,GAAG,CAAC,mFAAmF,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import type { ServiceEnvironment } from './service.ts';
2
+ import type { CliEnvironment } from './environment.ts';
3
+ /**
4
+ * The bearer token for a gateway: an explicit flag, the environment, or the
5
+ * token file this machine's daemon wrote.
6
+ *
7
+ * The file is the normal case and the reason `--gateway` needs no ceremony
8
+ * locally. It is not always right, though: a gateway reached through a tunnel
9
+ * has its own token, which is what the flag and the variable are for.
10
+ */
11
+ export declare const gatewayToken: (env: CliEnvironment, explicit: string | undefined) => Promise<string>;
12
+ /** Builds the service view of the CLI environment (home, exec paths, runner). */
13
+ export declare const serviceEnvFor: (env: CliEnvironment) => ServiceEnvironment;
14
+ /** Where a command aimed at "the running daemon" is pointed. */
15
+ interface RunningGatewayTarget {
16
+ gateway?: string;
17
+ token?: string;
18
+ }
19
+ /**
20
+ * The control API base a command should talk to: `--gateway` when given,
21
+ * else whatever daemon `~/.stratus/gateway.json` says is serving, else
22
+ * nothing — the file is written when the API binds and removed when it
23
+ * stops, so its absence means no daemon has said where it is.
24
+ */
25
+ export declare const runningGatewayBase: (env: CliEnvironment, target: RunningGatewayTarget) => Promise<string | undefined>;
26
+ /** One authenticated call to a daemon's control API, with the network and auth failures said plainly. */
27
+ export declare const callRunningGateway: (env: CliEnvironment, target: RunningGatewayTarget, base: string, pathname: string, body?: Record<string, unknown>, method?: "GET" | "POST") => Promise<Response>;
28
+ /** The API's own sentence for a failure, or the status when it sent none. */
29
+ export declare const gatewayErrorMessage: (response: Response) => Promise<string>;
30
+ export declare const noRunningDaemonMessage: (env: CliEnvironment) => string;
31
+ /** What a running daemon published about itself, if one is running. */
32
+ interface GatewayInfo {
33
+ url: string;
34
+ pid?: number;
35
+ }
36
+ export declare const readGatewayInfo: (env: CliEnvironment) => Promise<GatewayInfo | undefined>;
37
+ /** Whether something is actually answering there, as opposed to a stale file. */
38
+ export declare const gatewayAnswering: (env: CliEnvironment, base: string, fetchImpl: typeof fetch) => Promise<boolean>;
39
+ /**
40
+ * The error for a home another daemon holds (see `claimHome` in
41
+ * @stratusagent/gateway — the claim is what decides; this only says who).
42
+ *
43
+ * The discovery file names the holder when it has one to name: a daemon
44
+ * that has bound its API. Read for the message alone, and only trusted as
45
+ * far as a live pid — a daemon still starting has not written it, a
46
+ * daemon draining its last turn has already removed it, and a SIGKILLed
47
+ * one leaves it behind for the next pid to inherit. Not probed over HTTP:
48
+ * a `STRATUS_GATEWAY_TOKEN` exported for some remote gateway would answer
49
+ * 401 for the local one, and the claim needs no second opinion.
50
+ */
51
+ /**
52
+ * `stratus serve` refused because another daemon holds the home. Its own
53
+ * type so `stratus dashboard` can tell "a daemon is there, wait for it to
54
+ * publish" from "the daemon could not start".
55
+ */
56
+ export declare class HomeHeldError extends Error {
57
+ constructor(message: string);
58
+ }
59
+ /**
60
+ * Whether a daemon from before the lock existed is serving this home.
61
+ *
62
+ * Such a daemon — alive across an upgrade that did not stop it — never
63
+ * took the claim, so the claim alone cannot see it. The discovery file it
64
+ * published is its only trace, held to the two proofs the lock made
65
+ * unnecessary for everything since: the pid it names is alive, and its
66
+ * URL answers `/health` with this home's own token file — never the
67
+ * `STRATUS_GATEWAY_TOKEN` override, which names some other gateway and
68
+ * would make a live daemon read as absent. A stale file fails either
69
+ * proof and refuses nothing.
70
+ */
71
+ export declare const legacyDaemonServing: (env: CliEnvironment) => Promise<boolean>;
72
+ export declare const describeHeldHome: (env: CliEnvironment) => Promise<string>;
73
+ export {};
74
+ //# sourceMappingURL=daemon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,cAAc,EACnB,UAAU,MAAM,GAAG,SAAS,KAC3B,OAAO,CAAC,MAAM,CAgBhB,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa,GAAI,KAAK,cAAc,KAAG,kBAKlD,CAAC;AAEH,gEAAgE;AAChE,UAAU,oBA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1E,CAAC"}
package/dist/daemon.js ADDED
@@ -0,0 +1,192 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { readNonEmptyString, readProcessEnv, readWorkingDirectory, gatewayInfoPath, gatewayTokenPath, } from '@stratusagent/state';
3
+ /**
4
+ * The bearer token for a gateway: an explicit flag, the environment, or the
5
+ * token file this machine's daemon wrote.
6
+ *
7
+ * The file is the normal case and the reason `--gateway` needs no ceremony
8
+ * locally. It is not always right, though: a gateway reached through a tunnel
9
+ * has its own token, which is what the flag and the variable are for.
10
+ */
11
+ export const gatewayToken = async (env, explicit) => {
12
+ const fromEnv = readNonEmptyString(readProcessEnv(env).STRATUS_GATEWAY_TOKEN);
13
+ if (explicit || fromEnv) {
14
+ return String(explicit ?? fromEnv);
15
+ }
16
+ try {
17
+ return (await readFile(gatewayTokenPath(env), 'utf8')).trim();
18
+ }
19
+ catch (error) {
20
+ if (error.code !== 'ENOENT') {
21
+ throw error;
22
+ }
23
+ throw new Error(`No gateway token: ${gatewayTokenPath(env)} does not exist, and neither --token nor STRATUS_GATEWAY_TOKEN was set. `
24
+ + 'Start the daemon with `stratus serve` (or `stratus service install`) to create one, or pass the remote gateway\'s token.');
25
+ }
26
+ };
27
+ /** Builds the service view of the CLI environment (home, exec paths, runner). */
28
+ export const serviceEnvFor = (env) => ({
29
+ ...(env.homeDir !== undefined ? { homeDir: env.homeDir } : {}),
30
+ cwd: readWorkingDirectory(env),
31
+ ...(env.serviceRunner !== undefined ? { run: env.serviceRunner } : {}),
32
+ ...(env.servicePlatform !== undefined ? { platform: env.servicePlatform } : {}),
33
+ });
34
+ /**
35
+ * The control API base a command should talk to: `--gateway` when given,
36
+ * else whatever daemon `~/.stratus/gateway.json` says is serving, else
37
+ * nothing — the file is written when the API binds and removed when it
38
+ * stops, so its absence means no daemon has said where it is.
39
+ */
40
+ export const runningGatewayBase = async (env, target) => {
41
+ if (target.gateway) {
42
+ return target.gateway.replace(/\/+$/, '');
43
+ }
44
+ const info = await readGatewayInfo(env);
45
+ return info?.url.replace(/\/+$/, '');
46
+ };
47
+ /** One authenticated call to a daemon's control API, with the network and auth failures said plainly. */
48
+ export const callRunningGateway = async (env, target, base, pathname, body, method = 'POST') => {
49
+ const token = await gatewayToken(env, target.token);
50
+ const fetchImpl = env.fetch ?? globalThis.fetch;
51
+ if (typeof fetchImpl !== 'function') {
52
+ throw new Error('fetch is unavailable, so this runtime cannot reach a daemon.');
53
+ }
54
+ let response;
55
+ try {
56
+ response = await fetchImpl(`${base}${pathname}`, {
57
+ method,
58
+ headers: {
59
+ authorization: `Bearer ${token}`,
60
+ ...(body ? { 'content-type': 'application/json' } : {}),
61
+ },
62
+ ...(body ? { body: JSON.stringify(body) } : {}),
63
+ });
64
+ }
65
+ catch (error) {
66
+ throw new Error(`Could not reach the gateway at ${base} (${error instanceof Error ? error.message : String(error)}). `
67
+ + 'Is stratusd running, and does it have @stratusagent/control-api installed?');
68
+ }
69
+ if (response.status === 401 || response.status === 403) {
70
+ throw new Error(`The gateway at ${base} rejected this token. Check --token, STRATUS_GATEWAY_TOKEN, or ~/.stratus/gateway-token.`);
71
+ }
72
+ return response;
73
+ };
74
+ /** The API's own sentence for a failure, or the status when it sent none. */
75
+ export const gatewayErrorMessage = async (response) => {
76
+ try {
77
+ const payload = await response.json();
78
+ if (payload.error?.message) {
79
+ return payload.error.message;
80
+ }
81
+ }
82
+ catch {
83
+ // Not JSON; the status is all there is to say.
84
+ }
85
+ return `HTTP ${response.status}`;
86
+ };
87
+ export const noRunningDaemonMessage = (env) => `no running daemon found — ${gatewayInfoPath(env)} does not exist, and no --gateway was given. `
88
+ + 'Start one with `stratus serve` or `stratus service start`; a daemon loads ~/.stratus/skills at start.';
89
+ export const readGatewayInfo = async (env) => {
90
+ try {
91
+ const parsed = JSON.parse(await readFile(gatewayInfoPath(env), 'utf8'));
92
+ return typeof parsed.url === 'string' ? { url: parsed.url, ...(parsed.pid ? { pid: parsed.pid } : {}) } : undefined;
93
+ }
94
+ catch {
95
+ // No file, or one left behind by a daemon that died without cleaning up.
96
+ // Either way there is nothing to talk to until the health check says so.
97
+ return undefined;
98
+ }
99
+ };
100
+ /** Whether something is actually answering there, as opposed to a stale file. */
101
+ export const gatewayAnswering = async (env, base, fetchImpl) => {
102
+ try {
103
+ const token = await gatewayToken(env, undefined);
104
+ const response = await fetchImpl(`${base}/api/v1/health`, {
105
+ headers: { authorization: `Bearer ${token}` },
106
+ });
107
+ return response.ok;
108
+ }
109
+ catch {
110
+ return false;
111
+ }
112
+ };
113
+ /**
114
+ * Whether a process with this pid exists. EPERM is an answer — the process
115
+ * is there, it is just not ours to signal.
116
+ */
117
+ const processAlive = (pid) => {
118
+ try {
119
+ process.kill(pid, 0);
120
+ return true;
121
+ }
122
+ catch (error) {
123
+ return error.code === 'EPERM';
124
+ }
125
+ };
126
+ /**
127
+ * The error for a home another daemon holds (see `claimHome` in
128
+ * @stratusagent/gateway — the claim is what decides; this only says who).
129
+ *
130
+ * The discovery file names the holder when it has one to name: a daemon
131
+ * that has bound its API. Read for the message alone, and only trusted as
132
+ * far as a live pid — a daemon still starting has not written it, a
133
+ * daemon draining its last turn has already removed it, and a SIGKILLed
134
+ * one leaves it behind for the next pid to inherit. Not probed over HTTP:
135
+ * a `STRATUS_GATEWAY_TOKEN` exported for some remote gateway would answer
136
+ * 401 for the local one, and the claim needs no second opinion.
137
+ */
138
+ /**
139
+ * `stratus serve` refused because another daemon holds the home. Its own
140
+ * type so `stratus dashboard` can tell "a daemon is there, wait for it to
141
+ * publish" from "the daemon could not start".
142
+ */
143
+ export class HomeHeldError extends Error {
144
+ constructor(message) {
145
+ super(message);
146
+ this.name = 'HomeHeldError';
147
+ }
148
+ }
149
+ /**
150
+ * Whether a daemon from before the lock existed is serving this home.
151
+ *
152
+ * Such a daemon — alive across an upgrade that did not stop it — never
153
+ * took the claim, so the claim alone cannot see it. The discovery file it
154
+ * published is its only trace, held to the two proofs the lock made
155
+ * unnecessary for everything since: the pid it names is alive, and its
156
+ * URL answers `/health` with this home's own token file — never the
157
+ * `STRATUS_GATEWAY_TOKEN` override, which names some other gateway and
158
+ * would make a live daemon read as absent. A stale file fails either
159
+ * proof and refuses nothing.
160
+ */
161
+ export const legacyDaemonServing = async (env) => {
162
+ const info = await readGatewayInfo(env);
163
+ if (info?.pid === undefined || info.pid === process.pid || !processAlive(info.pid)) {
164
+ return false;
165
+ }
166
+ const fetchImpl = env.fetch ?? globalThis.fetch;
167
+ if (typeof fetchImpl !== 'function') {
168
+ return false;
169
+ }
170
+ try {
171
+ const token = (await readFile(gatewayTokenPath(env), 'utf8')).trim();
172
+ const response = await fetchImpl(`${info.url}/api/v1/health`, {
173
+ headers: { authorization: `Bearer ${token}` },
174
+ signal: AbortSignal.timeout(2_000),
175
+ });
176
+ return response.ok;
177
+ }
178
+ catch {
179
+ return false;
180
+ }
181
+ };
182
+ export const describeHeldHome = async (env) => {
183
+ const info = await readGatewayInfo(env);
184
+ const holder = info?.pid !== undefined && processAlive(info.pid)
185
+ ? ` (pid ${info.pid}, ${info.url})`
186
+ : ' — one that is still starting, or still draining its last turns';
187
+ return `stratusd is already running for this home${holder}. Two daemons on one ~/.stratus `
188
+ + 'would each fire the other\'s schedules and re-ask its approvals. Stop it first: `stratus service stop` '
189
+ + 'if it is the installed service, otherwise Ctrl+C where it runs — and let it finish; it holds the home until '
190
+ + 'its last turn is written.';
191
+ };
192
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.js","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAI7B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,GAAmB,EACnB,QAA4B,EACX,EAAE;IACnB,MAAM,OAAO,G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