@ipab/cli 0.1.0-rc.7 → 0.1.0-rc.9
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 +70 -30
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +2 -44
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/bundled-skills.d.ts +14 -0
- package/dist/bundled-skills.d.ts.map +1 -0
- package/dist/bundled-skills.js +34 -0
- package/dist/bundled-skills.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +309 -157
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -4
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +4 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +11 -2
- package/dist/context.js.map +1 -1
- package/dist/daemon.d.ts +4 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +200 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +18 -4
- package/dist/doctor.js.map +1 -1
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +17 -0
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.js +1 -1
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-peers.d.ts.map +1 -1
- package/dist/kubo-peers.js +2 -1
- package/dist/kubo-peers.js.map +1 -1
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +105 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +10 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +96 -15
- package/dist/kubo.js.map +1 -1
- package/dist/skill-source.d.ts +4 -0
- package/dist/skill-source.d.ts.map +1 -1
- package/dist/skill-source.js +14 -2
- package/dist/skill-source.js.map +1 -1
- package/dist/skills.d.ts +18 -1
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +137 -39
- package/dist/skills.js.map +1 -1
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +1 -2
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +2 -15
- package/dist/space.js.map +1 -1
- package/dist/state-storage.js +1 -1
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +31 -12
- package/dist/state.js.map +1 -1
- package/dist/swarm-files.d.ts +1 -1
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +10 -4
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +1 -4
- package/dist/swarm-meta.d.ts.map +1 -1
- package/dist/swarm-meta.js +3 -34
- package/dist/swarm-meta.js.map +1 -1
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +262 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +121 -6
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +672 -81
- package/dist/swarm.js.map +1 -1
- package/package.json +4 -4
- package/src/app-authoring.ts +12 -53
- package/src/app-prebuild.ts +61 -0
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +398 -195
- package/src/config.ts +12 -4
- package/src/context.ts +15 -2
- package/src/daemon.ts +237 -0
- package/src/doctor.ts +42 -5
- package/src/errors.ts +1 -25
- package/src/host-error.ts +26 -0
- package/src/ipc.ts +19 -0
- package/src/kubo-install.ts +1 -1
- package/src/kubo-peers.ts +2 -3
- package/src/kubo-topology.ts +135 -0
- package/src/kubo.ts +134 -25
- package/src/skill-source.ts +16 -2
- package/src/skills.ts +195 -53
- package/src/space-path.ts +30 -0
- package/src/space.ts +2 -28
- package/src/state-storage.ts +1 -1
- package/src/state.ts +37 -12
- package/src/swarm-files.ts +8 -3
- package/src/swarm-meta.ts +15 -34
- package/src/swarm-observations.ts +374 -0
- package/src/swarm.ts +953 -92
package/dist/cli.js
CHANGED
|
@@ -5,19 +5,20 @@ import { ContentBundleError } from "@ipab/bundle";
|
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { CID } from "multiformats/cid";
|
|
7
7
|
import stringWidth from "string-width";
|
|
8
|
-
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
|
|
8
|
+
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, swarmUrl, visibleConfig, } from "./config.js";
|
|
9
9
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
10
10
|
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
11
11
|
import { execute } from "./runtime.js";
|
|
12
12
|
import { validatedBundle } from "./space.js";
|
|
13
|
-
import { createAssociation, exactCid, State, } from "./state.js";
|
|
13
|
+
import { createAssociation, exactCid, swarmAlias, State, } from "./state.js";
|
|
14
14
|
import { buildBundle, inspectBundle, importBundle, nodeError, } from "./authoring.js";
|
|
15
15
|
import { initApp } from "./app-authoring.js";
|
|
16
16
|
import { assembleBundle } from "./assembly.js";
|
|
17
17
|
import { getBundle } from "./get.js";
|
|
18
18
|
import { doctorDevice, doctorText } from "./doctor.js";
|
|
19
|
+
import { ensureDaemon, serveDaemon } from "./daemon.js";
|
|
19
20
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
20
|
-
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, verifiedRequest, verifiedRequestStream, membershipRequestSummary,
|
|
21
|
+
import { createSwarm, swarmDaemon, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, inspectSwarmStatus, verifiedRequest, verifiedRequestStream, membershipRequestSummary, updateSwarm, searchNames, formatNameReference, resolveReference, parseNameReference, formalName, publish, pinNameSubscription, pinReference, swarmRegistrations, swarmAssociation, setSwarmAssociation, removeSwarmAssociation, resolveTemplateSelector, templateName, swarmTemplates, setSwarmTemplate, removeSwarmTemplate, } from "./swarm.js";
|
|
21
22
|
import { schemaAlias } from "./app-definition.js";
|
|
22
23
|
import { unpin, pinDetails } from "./pins.js";
|
|
23
24
|
import { publicationSource } from "./publish-source.js";
|
|
@@ -71,43 +72,44 @@ export const processIO = {
|
|
|
71
72
|
},
|
|
72
73
|
};
|
|
73
74
|
const commands = {
|
|
74
|
-
|
|
75
|
-
"skills
|
|
75
|
+
daemon: "daemon [--swarm URL_OR_ALIAS]",
|
|
76
|
+
"skills list": "skills list [--refresh | --no-refresh]",
|
|
77
|
+
"skills sync": "skills sync [NAMES...] [--agent AGENT]... [--override-existing] [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
76
78
|
doctor: "doctor [--fix [--yes]]",
|
|
77
79
|
profile: "profile [--name NAME] [--description TEXT]",
|
|
78
80
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
79
|
-
"swarm request": "swarm request
|
|
81
|
+
"swarm request": "swarm request URL_OR_ALIAS [--output FILE]",
|
|
80
82
|
"swarm export": "swarm export --output FILE",
|
|
81
83
|
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
82
84
|
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
83
85
|
"swarm resume": "swarm resume",
|
|
84
86
|
"swarm profile": "swarm profile --address MULTIADDR",
|
|
85
|
-
"swarm status": "swarm status [--
|
|
86
|
-
"swarm members": "swarm members",
|
|
87
|
+
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
88
|
+
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
87
89
|
"swarm list": "swarm list",
|
|
88
|
-
"swarm
|
|
90
|
+
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
89
91
|
"swarm use": "swarm use URL_OR_ALIAS",
|
|
90
92
|
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
91
93
|
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
92
94
|
publish: "publish NAME SOURCE [--expect OLD_CID | --snapshot]",
|
|
93
|
-
get: "get REF [--raw] [--
|
|
94
|
-
search: "search QUERY [--all | --current] [--
|
|
95
|
+
get: "get REF [--raw] [--refresh | --no-refresh] [-o DIRECTORY]",
|
|
96
|
+
search: "search QUERY [--all | --current] [--refresh | --no-refresh]",
|
|
95
97
|
"templates render": "templates render TEMPLATE NAME [DIR] [OPTIONS]",
|
|
96
98
|
build: "build [SOURCE] [OPTIONS]",
|
|
97
99
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
98
100
|
"bundle inspect": "bundle inspect SOURCE",
|
|
99
101
|
"bundle import": "bundle import FILE.car",
|
|
100
|
-
exec: "exec [--log] [--
|
|
101
|
-
open: "open [--log] [--raw] [--
|
|
102
|
-
pin: "pin REF",
|
|
102
|
+
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
103
|
+
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
104
|
+
pin: "pin REF [--refresh | --no-refresh]",
|
|
103
105
|
unpin: "unpin REF",
|
|
104
106
|
"pin list": "pin list",
|
|
105
107
|
"pin show": "pin show REF",
|
|
106
108
|
"register list": "register list [--swarm URL_OR_ALIAS]",
|
|
107
109
|
"register set": "register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]",
|
|
108
110
|
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
109
|
-
"templates list": "templates list [--
|
|
110
|
-
"templates show": "templates show NAME [--
|
|
111
|
+
"templates list": "templates list [--refresh | --no-refresh]",
|
|
112
|
+
"templates show": "templates show NAME [--refresh | --no-refresh]",
|
|
111
113
|
"templates set": "templates set NAME SOURCE [--expect OLD_TARGET_CID]",
|
|
112
114
|
"templates remove": "templates remove NAME --expect OLD_TARGET_CID",
|
|
113
115
|
"config get": "config get [KEY]",
|
|
@@ -131,10 +133,21 @@ const groups = {
|
|
|
131
133
|
history: "View and remove execution history",
|
|
132
134
|
};
|
|
133
135
|
const commandHelp = {
|
|
136
|
+
daemon: {
|
|
137
|
+
summary: "Manage existing private Swarm nodes in the foreground",
|
|
138
|
+
examples: ["ipab daemon", "ipab daemon --swarm work"],
|
|
139
|
+
notes: [
|
|
140
|
+
"Manages all registered Swarms independently, or only the explicitly selected --swarm; ignores the saved default.",
|
|
141
|
+
"Probes pivot candidates, refreshes approved profiles and retries with cooldown. Diagnostics go to stderr.",
|
|
142
|
+
"Swarm network operations start one background daemon on demand per state-dir; local commands, doctor and status/members inspections do not. No OS startup service is installed.",
|
|
143
|
+
"Ctrl-C / TERM drains foreground operations and releases the device/state-dir lock; Kubo stays running. An existing background daemon already owns this lock.",
|
|
144
|
+
"Role and relay candidate changes restart only the verified managed Kubo node.",
|
|
145
|
+
],
|
|
146
|
+
},
|
|
134
147
|
"templates list": {
|
|
135
148
|
summary: "List templates under the selected Swarm Meta templatePath",
|
|
136
149
|
options: [
|
|
137
|
-
"--
|
|
150
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
138
151
|
],
|
|
139
152
|
examples: [
|
|
140
153
|
"ipab --swarm work templates list",
|
|
@@ -150,7 +163,7 @@ const commandHelp = {
|
|
|
150
163
|
"NAME Safe relative template Name; nested names are supported.",
|
|
151
164
|
],
|
|
152
165
|
options: [
|
|
153
|
-
"--
|
|
166
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
154
167
|
],
|
|
155
168
|
examples: ["ipab --swarm work templates show node"],
|
|
156
169
|
},
|
|
@@ -187,7 +200,7 @@ const commandHelp = {
|
|
|
187
200
|
"skills list": {
|
|
188
201
|
summary: "List typed Skills and local installation status from one Swarm",
|
|
189
202
|
options: [
|
|
190
|
-
"--
|
|
203
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
191
204
|
"Global --json Emit machine-readable names, exact payload CIDs and status.",
|
|
192
205
|
],
|
|
193
206
|
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
@@ -202,10 +215,11 @@ const commandHelp = {
|
|
|
202
215
|
"NAMES Install identities, e.g. ipab code-review, or full shared Names such as ipab/skills/ipab. Resolved from one verified snapshot; omit for all Skills.",
|
|
203
216
|
],
|
|
204
217
|
options: [
|
|
205
|
-
"--agent AGENT Repeatable globally supported agent ID; default is
|
|
218
|
+
"--agent AGENT Repeatable globally supported agent ID; default is universal (~/.agents/skills).",
|
|
219
|
+
"--override-existing Replace non-IPAB-managed Skills and local edits at selected targets.",
|
|
206
220
|
"--dry-run Preview without invoking npx or changing installed Skills.",
|
|
207
|
-
"--yes Skip IPAB consent only;
|
|
208
|
-
"--
|
|
221
|
+
"--yes Skip IPAB consent only; does not imply --override-existing.",
|
|
222
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
209
223
|
],
|
|
210
224
|
examples: [
|
|
211
225
|
"ipab --swarm work skills sync --dry-run",
|
|
@@ -215,7 +229,7 @@ const commandHelp = {
|
|
|
215
229
|
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
216
230
|
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
217
231
|
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
218
|
-
"Non-IPAB installs
|
|
232
|
+
"Non-IPAB installs and local edits require --override-existing. Cross-Swarm collisions and symlink/junction aliases remain protected. Removed sources are reported, not deleted.",
|
|
219
233
|
"Partial failures report individual results, preserve pending attribution and exit nonzero; retry the same sync.",
|
|
220
234
|
],
|
|
221
235
|
},
|
|
@@ -250,7 +264,8 @@ const commandHelp = {
|
|
|
250
264
|
"--yes Authorize planned repairs without prompting; requires --fix.",
|
|
251
265
|
],
|
|
252
266
|
notes: [
|
|
253
|
-
"Always checks local state/configuration, managed Kubo, HOME identity, local Swarm registry and
|
|
267
|
+
"Always checks local state/configuration, managed Kubo, HOME identity, local Swarm registry, compatible updates and the CLI-bundled IPAB Skill for detected Agents.",
|
|
268
|
+
"--fix also installs/updates the bundled IPAB Skill globally using the pinned official installer, without joining a Swarm. Custom content and Swarm-managed Skills are never overwritten.",
|
|
254
269
|
"Inspection never creates state, locks, credentials or caches. Official release metadata may be queried; unavailable updates are not claimed current.",
|
|
255
270
|
"Healthy current components are reused without download or confirmation. Fixed protected archive cache is automatic.",
|
|
256
271
|
"Unverified existing Kubo: --fix may download/cache its exact-version official archive for byte comparison only; never execute it to authenticate itself or overwrite a mismatch.",
|
|
@@ -280,11 +295,10 @@ const commandHelp = {
|
|
|
280
295
|
"swarm request": {
|
|
281
296
|
summary: "Save and export a signed self-contained membership Request",
|
|
282
297
|
examples: [
|
|
283
|
-
"ipab swarm request
|
|
284
|
-
"ipab swarm request CONFIG_URL --output request.json
|
|
298
|
+
"ipab swarm request work",
|
|
299
|
+
"ipab swarm request CONFIG_URL --output request.json",
|
|
285
300
|
],
|
|
286
301
|
options: [
|
|
287
|
-
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
288
302
|
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
289
303
|
],
|
|
290
304
|
notes: [
|
|
@@ -294,7 +308,7 @@ const commandHelp = {
|
|
|
294
308
|
"Retries export the exact saved Request without expiry or a new PeerID.",
|
|
295
309
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
296
310
|
"Set your account-wide personal name with ipab profile --name NAME before requesting membership.",
|
|
297
|
-
"
|
|
311
|
+
"Accepts a local alias or a configuration URL. Never changes local registrations, aliases or the saved default; use ipab swarm set ALIAS CONFIG_URL separately.",
|
|
298
312
|
],
|
|
299
313
|
},
|
|
300
314
|
"swarm approve": {
|
|
@@ -338,24 +352,35 @@ const commandHelp = {
|
|
|
338
352
|
},
|
|
339
353
|
"swarm members": {
|
|
340
354
|
summary: "List every public member, including the Owner",
|
|
341
|
-
|
|
355
|
+
options: [
|
|
356
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
357
|
+
"--local Deprecated no-op; local daemon observations are always included.",
|
|
358
|
+
],
|
|
359
|
+
examples: [
|
|
360
|
+
"ipab --swarm work swarm members",
|
|
361
|
+
"ipab --json swarm members --refresh",
|
|
362
|
+
],
|
|
342
363
|
notes: [
|
|
343
|
-
"
|
|
364
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Includes Pivot declarations and existing daemon observations; no HOME identity access, node activation or probes.",
|
|
365
|
+
"PIVOT: - for ordinary members; selected, cooldown, unknown, self or candidate for declared Pivots. Selected means applied configuration, not connectivity.",
|
|
344
366
|
],
|
|
345
367
|
},
|
|
346
368
|
"swarm status": {
|
|
347
|
-
summary: "
|
|
369
|
+
summary: "Inspect cached Swarm directory, HEAD and local networking",
|
|
348
370
|
options: [
|
|
349
|
-
"--
|
|
371
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
372
|
+
"--local Deprecated no-op; never activates a node.",
|
|
350
373
|
],
|
|
351
374
|
examples: [
|
|
352
375
|
"ipab swarm status",
|
|
353
376
|
"ipab --swarm work swarm status",
|
|
354
|
-
"ipab --swarm work swarm status --
|
|
377
|
+
"ipab --swarm work swarm status --refresh",
|
|
355
378
|
],
|
|
356
379
|
notes: [
|
|
357
|
-
"
|
|
358
|
-
"
|
|
380
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Refresh verifies Config, Scope, members, Profiles and HEAD, not connectivity or State content.",
|
|
381
|
+
"Always shows daemon freshness, Pivot selection, probes/cooldown and separately timestamped daemon connection snapshots. Never contacts Kubo, initializes HOME identity, changes remote profiles or activates a node.",
|
|
382
|
+
"State content is explicitly unavailable in inspection; use get ipab:/// to obtain the State Bundle.",
|
|
383
|
+
"Local connectivity is not global availability; a relay connection does not guarantee content transfer.",
|
|
359
384
|
],
|
|
360
385
|
},
|
|
361
386
|
"swarm list": {
|
|
@@ -363,13 +388,19 @@ const commandHelp = {
|
|
|
363
388
|
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
364
389
|
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
365
390
|
},
|
|
366
|
-
"swarm
|
|
367
|
-
summary: "
|
|
391
|
+
"swarm set": {
|
|
392
|
+
summary: "Set a local alias for a swarm configuration URL",
|
|
368
393
|
options: [
|
|
369
|
-
"--
|
|
394
|
+
"--yes Authorize retargeting an existing alias without prompting.",
|
|
395
|
+
],
|
|
396
|
+
examples: [
|
|
397
|
+
"ipab swarm set work CONFIG_URL",
|
|
398
|
+
"ipab swarm set work OTHER_CONFIG_URL --yes",
|
|
370
399
|
],
|
|
371
|
-
examples: ["ipab swarm add CONFIG_URL --alias work"],
|
|
372
400
|
notes: [
|
|
401
|
+
"Local only; no network, account identity or approved membership required.",
|
|
402
|
+
"Setting the same mapping is idempotent. One alias per URL; a new alias for that URL replaces its old alias.",
|
|
403
|
+
"Retargeting an alias requires confirmation or --yes. Keeps the old URL registered without that alias; credentials, caches and the saved default URL are unchanged.",
|
|
373
404
|
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
374
405
|
],
|
|
375
406
|
},
|
|
@@ -409,13 +440,13 @@ const commandHelp = {
|
|
|
409
440
|
options: [
|
|
410
441
|
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
411
442
|
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
412
|
-
"--
|
|
413
|
-
"--no-
|
|
443
|
+
"--refresh Refresh HEAD for every swarm in the search scope.",
|
|
444
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
414
445
|
],
|
|
415
446
|
examples: [
|
|
416
447
|
"ipab search hello",
|
|
417
448
|
"ipab search hello --all",
|
|
418
|
-
"ipab --swarm work search hello --
|
|
449
|
+
"ipab --swarm work search hello --refresh",
|
|
419
450
|
],
|
|
420
451
|
notes: [
|
|
421
452
|
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
@@ -448,8 +479,8 @@ const commandHelp = {
|
|
|
448
479
|
summary: "Verify and unpack Bundle content without executing it",
|
|
449
480
|
options: [
|
|
450
481
|
"--raw Select the Artifact node instead of its value.",
|
|
451
|
-
"--
|
|
452
|
-
"--no-
|
|
482
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
483
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
453
484
|
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
454
485
|
],
|
|
455
486
|
examples: [
|
|
@@ -490,7 +521,7 @@ const commandHelp = {
|
|
|
490
521
|
],
|
|
491
522
|
options: [
|
|
492
523
|
"--description TEXT Set the declared description parameter.",
|
|
493
|
-
"--
|
|
524
|
+
"--refresh / --no-refresh Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
494
525
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
495
526
|
" other parameter types use JSON.",
|
|
496
527
|
],
|
|
@@ -569,8 +600,8 @@ const commandHelp = {
|
|
|
569
600
|
],
|
|
570
601
|
options: [
|
|
571
602
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
572
|
-
"--
|
|
573
|
-
"--no-
|
|
603
|
+
"--refresh Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
604
|
+
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
574
605
|
],
|
|
575
606
|
examples: [
|
|
576
607
|
"ipab exec reader",
|
|
@@ -593,16 +624,17 @@ const commandHelp = {
|
|
|
593
624
|
options: [
|
|
594
625
|
"--log Record stdout/stderr; requires history enabled.",
|
|
595
626
|
"--raw Open the Artifact node rather than its value.",
|
|
596
|
-
"--
|
|
597
|
-
"--no-
|
|
627
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
628
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
598
629
|
],
|
|
599
630
|
examples: [
|
|
600
631
|
"ipab open CONTENT_CID",
|
|
601
|
-
"ipab open --log
|
|
602
|
-
"ipab open ipab:///
|
|
632
|
+
"ipab open --log --refresh ipab:///documents/readme",
|
|
633
|
+
"ipab open ipab:///",
|
|
603
634
|
],
|
|
604
635
|
notes: [
|
|
605
636
|
"Requires a saved registration and App support for the exact content type.",
|
|
637
|
+
"An empty URI Name (ipab:/// or ipab://ALIAS/) resolves to that Swarm's verified root State CID, not its publication CID. The root binding cannot be overwritten.",
|
|
606
638
|
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
607
639
|
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
608
640
|
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
@@ -617,6 +649,9 @@ const commandHelp = {
|
|
|
617
649
|
arguments: [
|
|
618
650
|
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
619
651
|
],
|
|
652
|
+
options: [
|
|
653
|
+
"--refresh / --no-refresh Refresh shared HEAD now / allow its valid cached snapshot.",
|
|
654
|
+
],
|
|
620
655
|
examples: [
|
|
621
656
|
"ipab pin APP_CID",
|
|
622
657
|
"ipab pin ipab://work/apps/reader",
|
|
@@ -820,7 +855,13 @@ ${footer}`;
|
|
|
820
855
|
return [
|
|
821
856
|
`${topic.summary}.\n\nUsage: ipab [GLOBAL_OPTIONS] ${usage}`,
|
|
822
857
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
823
|
-
...(topic.options
|
|
858
|
+
...(topic.options
|
|
859
|
+
? [
|
|
860
|
+
section("Options", topic.options.map((line) => line.startsWith("--refresh")
|
|
861
|
+
? `${line} Legacy aliases: --force/--no-force.`
|
|
862
|
+
: line)),
|
|
863
|
+
]
|
|
864
|
+
: []),
|
|
824
865
|
section("Examples", topic.examples),
|
|
825
866
|
...([
|
|
826
867
|
"swarm status",
|
|
@@ -867,8 +908,15 @@ function printable(text) {
|
|
|
867
908
|
}
|
|
868
909
|
export function formatSearchResults(matches) {
|
|
869
910
|
return matches.length
|
|
870
|
-
? matches
|
|
871
|
-
|
|
911
|
+
? alignedRows(matches.map((match) => [
|
|
912
|
+
match.alias ?? match.swarm,
|
|
913
|
+
match.name,
|
|
914
|
+
match.targetCid,
|
|
915
|
+
]))
|
|
916
|
+
.map((row, index) => {
|
|
917
|
+
const match = matches[index];
|
|
918
|
+
return `${row}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`;
|
|
919
|
+
})
|
|
872
920
|
.join("\n")
|
|
873
921
|
: "No matching Names.";
|
|
874
922
|
}
|
|
@@ -911,18 +959,17 @@ function storageBytes(bytes) {
|
|
|
911
959
|
? `${exact} bytes`
|
|
912
960
|
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
913
961
|
}
|
|
914
|
-
function
|
|
915
|
-
if (!rows.length)
|
|
916
|
-
return empty;
|
|
962
|
+
function alignedRows(rows) {
|
|
917
963
|
const cells = rows.map((row) => row.map(printable));
|
|
918
|
-
const widths =
|
|
919
|
-
return
|
|
920
|
-
.map((
|
|
921
|
-
.map((cell, column) => column === headers.length - 1
|
|
964
|
+
const widths = (cells[0] ?? []).map((_, column) => cells.reduce((width, row) => Math.max(width, stringWidth(row[column])), 0));
|
|
965
|
+
return cells.map((row) => row
|
|
966
|
+
.map((cell, column) => column === widths.length - 1
|
|
922
967
|
? cell
|
|
923
968
|
: cell.padEnd(cell.length + widths[column] - stringWidth(cell)))
|
|
924
|
-
.join(" "))
|
|
925
|
-
|
|
969
|
+
.join(" "));
|
|
970
|
+
}
|
|
971
|
+
function table(headers, rows, empty) {
|
|
972
|
+
return rows.length ? alignedRows([headers, ...rows]).join("\n") : empty;
|
|
926
973
|
}
|
|
927
974
|
function runDetails(record) {
|
|
928
975
|
const fields = [
|
|
@@ -953,6 +1000,12 @@ function runDetails(record) {
|
|
|
953
1000
|
fields.push(["Retention owner", record.retention.owner]);
|
|
954
1001
|
return fields.map(([key, value]) => `${key}: ${printable(value)}`).join("\n");
|
|
955
1002
|
}
|
|
1003
|
+
function validateRefreshOptions(options) {
|
|
1004
|
+
const positive = ["refresh", "force"].find((key) => options[key]);
|
|
1005
|
+
const negative = ["no-refresh", "no-force"].find((key) => options[key]);
|
|
1006
|
+
if (positive && negative)
|
|
1007
|
+
syntax(`--${positive} and --${negative} are mutually exclusive.`);
|
|
1008
|
+
}
|
|
956
1009
|
async function closeStore(store, appExitCode) {
|
|
957
1010
|
try {
|
|
958
1011
|
await store?.close();
|
|
@@ -1030,14 +1083,13 @@ export function parse(argv) {
|
|
|
1030
1083
|
if (group === "exec") {
|
|
1031
1084
|
if (flags.json)
|
|
1032
1085
|
syntax("--json is not supported for exec/open.");
|
|
1033
|
-
while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
|
|
1086
|
+
while (["--log", "--force", "--no-force", "--refresh", "--no-refresh"].includes(tokens[0] ?? "")) {
|
|
1034
1087
|
const option = tokens.shift().slice(2);
|
|
1035
1088
|
if (Object.hasOwn(result.options, option))
|
|
1036
1089
|
syntax(`Duplicate option --${option}.`);
|
|
1037
1090
|
result.options[option] = true;
|
|
1038
1091
|
}
|
|
1039
|
-
|
|
1040
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1092
|
+
validateRefreshOptions(result.options);
|
|
1041
1093
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
1042
1094
|
result.help = true;
|
|
1043
1095
|
return result;
|
|
@@ -1054,6 +1106,7 @@ export function parse(argv) {
|
|
|
1054
1106
|
"get",
|
|
1055
1107
|
"search",
|
|
1056
1108
|
"doctor",
|
|
1109
|
+
"daemon",
|
|
1057
1110
|
"profile",
|
|
1058
1111
|
"unpin",
|
|
1059
1112
|
].includes(group)) {
|
|
@@ -1084,6 +1137,8 @@ export function parse(argv) {
|
|
|
1084
1137
|
}
|
|
1085
1138
|
else if (group === "open" && flags.json)
|
|
1086
1139
|
syntax("--json is not supported for exec/open.");
|
|
1140
|
+
if (result.path === "swarm add")
|
|
1141
|
+
syntax("swarm add was removed. Use ipab swarm set ALIAS CONFIG_URL for local naming, then ipab swarm request ALIAS to request membership.");
|
|
1087
1142
|
if (!commands[result.path])
|
|
1088
1143
|
syntax(`Unknown command "${result.path}".`);
|
|
1089
1144
|
if (group === "skills" && swarms.length > 1)
|
|
@@ -1103,7 +1158,7 @@ export function parse(argv) {
|
|
|
1103
1158
|
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
1104
1159
|
const booleans = result.path.startsWith("skills ")
|
|
1105
1160
|
? result.path === "skills sync"
|
|
1106
|
-
? ["dry-run", "yes", "force", "no-force"]
|
|
1161
|
+
? ["dry-run", "yes", "override-existing", "force", "no-force"]
|
|
1107
1162
|
: ["force", "no-force"]
|
|
1108
1163
|
: result.path === "doctor"
|
|
1109
1164
|
? ["fix", "yes"]
|
|
@@ -1128,9 +1183,9 @@ export function parse(argv) {
|
|
|
1128
1183
|
? ["all", "current", "force", "no-force"]
|
|
1129
1184
|
: result.path === "swarm approve"
|
|
1130
1185
|
? ["yes", "again"]
|
|
1131
|
-
:
|
|
1132
|
-
? ["local"]
|
|
1133
|
-
:
|
|
1186
|
+
: ["swarm status", "swarm members"].includes(result.path)
|
|
1187
|
+
? ["local", "force", "no-force"]
|
|
1188
|
+
: ["swarm exclude", "swarm set"].includes(result.path)
|
|
1134
1189
|
? ["yes"]
|
|
1135
1190
|
: result.path === "register set"
|
|
1136
1191
|
? ["replace"]
|
|
@@ -1138,42 +1193,44 @@ export function parse(argv) {
|
|
|
1138
1193
|
? ["yes"]
|
|
1139
1194
|
: result.path === "open"
|
|
1140
1195
|
? ["log", "raw", "force", "no-force"]
|
|
1141
|
-
:
|
|
1196
|
+
: result.path === "pin"
|
|
1197
|
+
? ["force", "no-force"]
|
|
1198
|
+
: [];
|
|
1199
|
+
if (booleans.includes("force"))
|
|
1200
|
+
booleans.push("refresh", "no-refresh");
|
|
1142
1201
|
const values = result.path === "swarm create"
|
|
1143
1202
|
? ["service", "resume", "name", "description", "alias"]
|
|
1144
|
-
: result.path === "swarm
|
|
1145
|
-
? ["
|
|
1146
|
-
: result.path === "swarm
|
|
1147
|
-
? ["
|
|
1148
|
-
: result.path === "swarm
|
|
1149
|
-
? ["
|
|
1150
|
-
: result.path === "swarm profile"
|
|
1151
|
-
? ["
|
|
1152
|
-
: result.path === "swarm
|
|
1153
|
-
? [
|
|
1154
|
-
:
|
|
1155
|
-
? []
|
|
1156
|
-
:
|
|
1157
|
-
? ["
|
|
1158
|
-
: result.path === "
|
|
1159
|
-
? ["
|
|
1160
|
-
: result.path === "
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
? [
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
]
|
|
1174
|
-
:
|
|
1175
|
-
? ["app", "status", "since", "until"]
|
|
1176
|
-
: [];
|
|
1203
|
+
: result.path === "swarm request"
|
|
1204
|
+
? ["output"]
|
|
1205
|
+
: result.path === "swarm export"
|
|
1206
|
+
? ["output"]
|
|
1207
|
+
: result.path === "swarm profile"
|
|
1208
|
+
? ["address"]
|
|
1209
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1210
|
+
? ["name", "description"]
|
|
1211
|
+
: result.path === "swarm approve"
|
|
1212
|
+
? []
|
|
1213
|
+
: ["publish", "templates set", "templates remove"].includes(result.path)
|
|
1214
|
+
? ["expect"]
|
|
1215
|
+
: result.path === "get"
|
|
1216
|
+
? ["output"]
|
|
1217
|
+
: result.path === "templates render"
|
|
1218
|
+
? ["description"]
|
|
1219
|
+
: result.path === "bundle build" ||
|
|
1220
|
+
result.path === "build"
|
|
1221
|
+
? ["output"]
|
|
1222
|
+
: result.path === "history list"
|
|
1223
|
+
? [
|
|
1224
|
+
"app",
|
|
1225
|
+
"status",
|
|
1226
|
+
"since",
|
|
1227
|
+
"until",
|
|
1228
|
+
"limit",
|
|
1229
|
+
"before",
|
|
1230
|
+
]
|
|
1231
|
+
: result.path === "history remove"
|
|
1232
|
+
? ["app", "status", "since", "until"]
|
|
1233
|
+
: [];
|
|
1177
1234
|
while (tokens.length) {
|
|
1178
1235
|
const value = tokens.shift();
|
|
1179
1236
|
if (result.path === "swarm exclude" &&
|
|
@@ -1182,6 +1239,15 @@ export function parse(argv) {
|
|
|
1182
1239
|
}
|
|
1183
1240
|
else if (value.startsWith("--") || value === "-o") {
|
|
1184
1241
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
1242
|
+
if (result.path === "daemon" && option === "swarm") {
|
|
1243
|
+
const input = tokens.shift();
|
|
1244
|
+
if (!input || input.startsWith("-"))
|
|
1245
|
+
syntax("--swarm needs a value.");
|
|
1246
|
+
if (flags.swarm !== undefined)
|
|
1247
|
+
syntax("daemon accepts --swarm at most once.");
|
|
1248
|
+
flags.swarm = input;
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1185
1251
|
if (result.path === "skills sync" && option === "agent") {
|
|
1186
1252
|
const input = tokens.shift();
|
|
1187
1253
|
if (!input || input.startsWith("-"))
|
|
@@ -1206,6 +1272,8 @@ export function parse(argv) {
|
|
|
1206
1272
|
(result.parameters ??= []).push(input);
|
|
1207
1273
|
continue;
|
|
1208
1274
|
}
|
|
1275
|
+
if (result.path === "swarm request" && option === "alias")
|
|
1276
|
+
syntax("swarm request --alias was removed. First run ipab swarm set ALIAS CONFIG_URL, then ipab swarm request ALIAS.");
|
|
1209
1277
|
if (Object.hasOwn(result.options, option))
|
|
1210
1278
|
syntax(`Duplicate option ${value}.`);
|
|
1211
1279
|
if (booleans.includes(option))
|
|
@@ -1229,8 +1297,7 @@ export function parse(argv) {
|
|
|
1229
1297
|
else
|
|
1230
1298
|
result.positional.push(value);
|
|
1231
1299
|
}
|
|
1232
|
-
|
|
1233
|
-
syntax("--force and --no-force are mutually exclusive.");
|
|
1300
|
+
validateRefreshOptions(result.options);
|
|
1234
1301
|
if (result.path === "search" &&
|
|
1235
1302
|
result.options.current &&
|
|
1236
1303
|
flags.swarm !== undefined)
|
|
@@ -1243,6 +1310,7 @@ export function parse(argv) {
|
|
|
1243
1310
|
(result.registrySwarms?.length ?? 0) > 1)
|
|
1244
1311
|
syntax("register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.");
|
|
1245
1312
|
const counts = {
|
|
1313
|
+
daemon: [0, 0],
|
|
1246
1314
|
doctor: [0, 0],
|
|
1247
1315
|
"skills list": [0, 0],
|
|
1248
1316
|
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
@@ -1257,7 +1325,7 @@ export function parse(argv) {
|
|
|
1257
1325
|
"swarm status": [0, 0],
|
|
1258
1326
|
"swarm members": [0, 0],
|
|
1259
1327
|
"swarm list": [0, 0],
|
|
1260
|
-
"swarm
|
|
1328
|
+
"swarm set": [2, 2],
|
|
1261
1329
|
"swarm use": [1, 1],
|
|
1262
1330
|
"swarm remove": [1, 1],
|
|
1263
1331
|
"swarm update": [0, 0],
|
|
@@ -1421,8 +1489,12 @@ async function performCli(argv, io, env) {
|
|
|
1421
1489
|
return 0;
|
|
1422
1490
|
}
|
|
1423
1491
|
const items = effectiveConfig(state.config({
|
|
1424
|
-
includeSecrets: ![
|
|
1425
|
-
|
|
1492
|
+
includeSecrets: ![
|
|
1493
|
+
"swarm members",
|
|
1494
|
+
"profile",
|
|
1495
|
+
"swarm status",
|
|
1496
|
+
"swarm set",
|
|
1497
|
+
].includes(parsed.path),
|
|
1426
1498
|
}), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
1427
1499
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
1428
1500
|
const emit = (result, human) => {
|
|
@@ -1449,9 +1521,19 @@ async function performCli(argv, io, env) {
|
|
|
1449
1521
|
stateDir: stateLocation(parsed.flags, env).path,
|
|
1450
1522
|
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1451
1523
|
listen: value("swarm.listen") === "loopback" ? "loopback" : "lan",
|
|
1452
|
-
|
|
1524
|
+
pivot: Boolean(value("swarm.pivot")),
|
|
1525
|
+
...(parsed.path === "daemon"
|
|
1526
|
+
? {
|
|
1527
|
+
daemonReady: () => serveDaemon(stateLocation(parsed.flags, env).path, parsed.flags.swarm === undefined ? undefined : requireSwarm()),
|
|
1528
|
+
}
|
|
1529
|
+
: {
|
|
1530
|
+
ensureDaemon: () => ensureDaemon(stateLocation(parsed.flags, env).path, env, (text) => {
|
|
1531
|
+
io.err(text);
|
|
1532
|
+
}),
|
|
1533
|
+
}),
|
|
1534
|
+
forceRefresh: parsed.options.refresh || parsed.options.force
|
|
1453
1535
|
? true
|
|
1454
|
-
: parsed.options["no-force"]
|
|
1536
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
1455
1537
|
? false
|
|
1456
1538
|
: Boolean(value("swarm.forceRefresh")),
|
|
1457
1539
|
diagnostic: (text) => {
|
|
@@ -1666,7 +1748,10 @@ async function performCli(argv, io, env) {
|
|
|
1666
1748
|
alias: entry.alias,
|
|
1667
1749
|
})),
|
|
1668
1750
|
}, [
|
|
1669
|
-
...result.swarms.map((entry) =>
|
|
1751
|
+
...alignedRows(result.swarms.map((entry) => [
|
|
1752
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
1753
|
+
entry.cid,
|
|
1754
|
+
])),
|
|
1670
1755
|
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
1671
1756
|
...(result.effectiveCurrent === null
|
|
1672
1757
|
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
@@ -1695,7 +1780,48 @@ async function performCli(argv, io, env) {
|
|
|
1695
1780
|
}, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
|
|
1696
1781
|
break;
|
|
1697
1782
|
}
|
|
1698
|
-
case "swarm
|
|
1783
|
+
case "swarm set": {
|
|
1784
|
+
swarmAlias(first);
|
|
1785
|
+
const cid = swarmUrl(second);
|
|
1786
|
+
const previous = state.swarms().find((entry) => entry.alias === first);
|
|
1787
|
+
if (previous && previous.cid !== cid) {
|
|
1788
|
+
io.err(`Swarm alias ${first}: ${previous.cid} -> ${cid}`);
|
|
1789
|
+
if (!parsed.options.yes &&
|
|
1790
|
+
(!io.tty ||
|
|
1791
|
+
!(await io.confirm(`Retarget local Swarm alias "${first}" from ${previous.cid} to ${cid}?`))))
|
|
1792
|
+
throw new HostError("Alias unchanged. Retargeting requires --yes or interactive confirmation.");
|
|
1793
|
+
}
|
|
1794
|
+
const entry = state.setSwarm(first, cid, previous?.cid ?? null);
|
|
1795
|
+
emit({
|
|
1796
|
+
configUrl: entry.cid,
|
|
1797
|
+
alias: entry.alias,
|
|
1798
|
+
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
1799
|
+
}, `Set local swarm alias ${entry.alias} (${cid}).`);
|
|
1800
|
+
break;
|
|
1801
|
+
}
|
|
1802
|
+
case "daemon": {
|
|
1803
|
+
if (parsed.flags.json)
|
|
1804
|
+
syntax("--json is not supported for daemon; diagnostics are written to stderr.");
|
|
1805
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1806
|
+
const controller = new AbortController();
|
|
1807
|
+
const interrupt = () => {
|
|
1808
|
+
controller.abort();
|
|
1809
|
+
};
|
|
1810
|
+
process.once("SIGINT", interrupt);
|
|
1811
|
+
process.once("SIGTERM", interrupt);
|
|
1812
|
+
try {
|
|
1813
|
+
await swarmDaemon(swarmContext(), parsed.flags.swarm === undefined ? undefined : requireSwarm(), controller.signal);
|
|
1814
|
+
}
|
|
1815
|
+
catch (cause) {
|
|
1816
|
+
if (!controller.signal.aborted)
|
|
1817
|
+
throw cause;
|
|
1818
|
+
}
|
|
1819
|
+
finally {
|
|
1820
|
+
process.removeListener("SIGINT", interrupt);
|
|
1821
|
+
process.removeListener("SIGTERM", interrupt);
|
|
1822
|
+
}
|
|
1823
|
+
break;
|
|
1824
|
+
}
|
|
1699
1825
|
case "swarm update":
|
|
1700
1826
|
case "search":
|
|
1701
1827
|
case "skills list":
|
|
@@ -1720,6 +1846,7 @@ async function performCli(argv, io, env) {
|
|
|
1720
1846
|
sync: parsed.path === "skills sync",
|
|
1721
1847
|
names: parsed.positional,
|
|
1722
1848
|
agents: parsed.agents ?? [],
|
|
1849
|
+
overrideExisting: Boolean(parsed.options["override-existing"]),
|
|
1723
1850
|
dryRun: Boolean(parsed.options["dry-run"]),
|
|
1724
1851
|
yes: Boolean(parsed.options.yes),
|
|
1725
1852
|
tty: io.tty,
|
|
@@ -1752,13 +1879,20 @@ async function performCli(argv, io, env) {
|
|
|
1752
1879
|
break;
|
|
1753
1880
|
}
|
|
1754
1881
|
if (parsed.path === "swarm members") {
|
|
1755
|
-
const result = await swarmMembers(context, requireSwarm());
|
|
1756
|
-
emit(result,
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
member
|
|
1760
|
-
|
|
1761
|
-
|
|
1882
|
+
const result = await swarmMembers(context, requireSwarm(), Boolean(parsed.options.refresh || parsed.options.force));
|
|
1883
|
+
emit(result, [
|
|
1884
|
+
`Directory: ${result.cache.source} (${result.cache.freshness}), observed ${result.cache.updatedAt}`,
|
|
1885
|
+
`Daemon: ${result.local.status}, observed ${result.local.updatedAt ?? "unknown"}; control-plane verified ${result.local.verifiedAt ?? "unknown"}`,
|
|
1886
|
+
table(["NAME", "DESCRIPTION", "ROLE", "PIVOT", "PUBLIC KEY"], result.members.map((member) => [
|
|
1887
|
+
member.name,
|
|
1888
|
+
member.description,
|
|
1889
|
+
member.role,
|
|
1890
|
+
member.pivot ? (member.localStatus ?? "candidate") : "-",
|
|
1891
|
+
member.publicKey,
|
|
1892
|
+
]), "No members."),
|
|
1893
|
+
].join("\n"));
|
|
1894
|
+
if (result.local.error)
|
|
1895
|
+
io.err(`Local Pivot observations (${result.local.status}): ${printable(result.local.error)}`);
|
|
1762
1896
|
break;
|
|
1763
1897
|
}
|
|
1764
1898
|
if (parsed.path === "swarm export") {
|
|
@@ -1802,20 +1936,6 @@ async function performCli(argv, io, env) {
|
|
|
1802
1936
|
emit(result, `Swarm: ${result.configUrl}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD ID: ${result.headId}\nConfig content CID: ${result.valueCid}`);
|
|
1803
1937
|
break;
|
|
1804
1938
|
}
|
|
1805
|
-
if (parsed.path === "swarm add") {
|
|
1806
|
-
const cid = state.resolveSwarm(first);
|
|
1807
|
-
await addSwarm(context, cid, typeof parsed.options.alias === "string"
|
|
1808
|
-
? parsed.options.alias
|
|
1809
|
-
: undefined);
|
|
1810
|
-
const entry = state.registeredSwarm(cid);
|
|
1811
|
-
emit({
|
|
1812
|
-
configUrl: entry.cid,
|
|
1813
|
-
alias: entry.alias,
|
|
1814
|
-
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ??
|
|
1815
|
-
null,
|
|
1816
|
-
}, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1817
|
-
break;
|
|
1818
|
-
}
|
|
1819
1939
|
if (parsed.path === "search") {
|
|
1820
1940
|
const registrations = state.swarms();
|
|
1821
1941
|
const scope = parsed.options.all
|
|
@@ -1833,10 +1953,7 @@ async function performCli(argv, io, env) {
|
|
|
1833
1953
|
}
|
|
1834
1954
|
if (parsed.path === "swarm status") {
|
|
1835
1955
|
const cid = requireSwarm();
|
|
1836
|
-
const
|
|
1837
|
-
const { head, config } = local
|
|
1838
|
-
? await swarmHeader(context, cid, true)
|
|
1839
|
-
: await sharedSwarmStatus(context, cid);
|
|
1956
|
+
const { head, config, networking, cache, state: contentState, } = await inspectSwarmStatus(context, cid, Boolean(parsed.options.refresh || parsed.options.force));
|
|
1840
1957
|
const fingerprint = await keyId(config.owner);
|
|
1841
1958
|
store = context.store;
|
|
1842
1959
|
emit({
|
|
@@ -1844,12 +1961,11 @@ async function performCli(argv, io, env) {
|
|
|
1844
1961
|
owner: config.owner,
|
|
1845
1962
|
ownerFingerprint: fingerprint,
|
|
1846
1963
|
epoch: config.epoch,
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
: {}),
|
|
1964
|
+
scopeId: config.scopeId,
|
|
1965
|
+
headId: config.headId,
|
|
1966
|
+
cache,
|
|
1967
|
+
state: contentState,
|
|
1968
|
+
networking,
|
|
1853
1969
|
root: head.root,
|
|
1854
1970
|
valueCid: head.cid,
|
|
1855
1971
|
properties: {
|
|
@@ -1858,6 +1974,7 @@ async function performCli(argv, io, env) {
|
|
|
1858
1974
|
},
|
|
1859
1975
|
}, [
|
|
1860
1976
|
"Swarm",
|
|
1977
|
+
` Directory: ${cache.source} (${cache.freshness}), observed ${cache.updatedAt}`,
|
|
1861
1978
|
` Name: ${printable(config.name)}`,
|
|
1862
1979
|
` Description: ${config.description ? printable(config.description) : "(none)"}`,
|
|
1863
1980
|
" Config URL:",
|
|
@@ -1866,21 +1983,59 @@ async function performCli(argv, io, env) {
|
|
|
1866
1983
|
"Identity",
|
|
1867
1984
|
" Owner fingerprint:",
|
|
1868
1985
|
` ${fingerprint}`,
|
|
1869
|
-
...(local
|
|
1870
|
-
? [
|
|
1871
|
-
" PeerID:",
|
|
1872
|
-
` ${context.node.peerId}`,
|
|
1873
|
-
"",
|
|
1874
|
-
"Local addresses",
|
|
1875
|
-
...context.node.addresses.map((address) => ` ${printable(address)}`),
|
|
1876
|
-
]
|
|
1877
|
-
: []),
|
|
1878
1986
|
"",
|
|
1879
1987
|
"Content",
|
|
1880
1988
|
" HEAD (publication root):",
|
|
1881
1989
|
` ${head.root}`,
|
|
1882
1990
|
" Content CID (HEAD value):",
|
|
1883
1991
|
` ${head.cid}`,
|
|
1992
|
+
` State: ${contentState.status}. ${contentState.error}`,
|
|
1993
|
+
"",
|
|
1994
|
+
"Local networking",
|
|
1995
|
+
` Daemon observations: ${networking.daemon.status}`,
|
|
1996
|
+
` Updated: ${networking.daemon.updatedAt ?? "unknown"}`,
|
|
1997
|
+
` Control-plane verified: ${networking.daemon.verifiedAt ?? "unknown"}`,
|
|
1998
|
+
...(networking.daemon.error
|
|
1999
|
+
? [` Observation error: ${printable(networking.daemon.error)}`]
|
|
2000
|
+
: []),
|
|
2001
|
+
` Connections observed: ${networking.connections.observedAt ?? "unknown"} (${networking.connections.freshness})`,
|
|
2002
|
+
...(networking.connections.error
|
|
2003
|
+
? [
|
|
2004
|
+
` Connection error: ${printable(networking.connections.error)}`,
|
|
2005
|
+
]
|
|
2006
|
+
: []),
|
|
2007
|
+
table([
|
|
2008
|
+
"PIVOT PEER ID",
|
|
2009
|
+
"LOCAL",
|
|
2010
|
+
"PROBE",
|
|
2011
|
+
"PROBED AT",
|
|
2012
|
+
"FAILURES",
|
|
2013
|
+
"RETRY AT",
|
|
2014
|
+
"CONNECTION",
|
|
2015
|
+
], networking.pivots.map((pivot) => [
|
|
2016
|
+
pivot.peerId,
|
|
2017
|
+
pivot.localStatus ?? "unknown",
|
|
2018
|
+
`${pivot.probe.result} (${pivot.probe.freshness})`,
|
|
2019
|
+
pivot.probe.at ?? "-",
|
|
2020
|
+
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2021
|
+
pivot.retryAt ?? "-",
|
|
2022
|
+
pivot.connection.status,
|
|
2023
|
+
]), "No declared Pivots."),
|
|
2024
|
+
...networking.pivots.flatMap((pivot) => pivot.probe.error
|
|
2025
|
+
? [
|
|
2026
|
+
` ${pivot.peerId} probe error: ${printable(pivot.probe.error)}`,
|
|
2027
|
+
]
|
|
2028
|
+
: []),
|
|
2029
|
+
...(networking.connections.error
|
|
2030
|
+
? []
|
|
2031
|
+
: [
|
|
2032
|
+
table(["CONNECTED PEER ID", "TRANSPORT", "ADDRESS"], networking.connections.peers.map((peer) => [
|
|
2033
|
+
peer.peerId,
|
|
2034
|
+
peer.transport,
|
|
2035
|
+
peer.address,
|
|
2036
|
+
]), "No observed peer connections."),
|
|
2037
|
+
]),
|
|
2038
|
+
" Selected is configuration, not connection success. Relay connectivity does not guarantee content availability.",
|
|
1884
2039
|
].join("\n"));
|
|
1885
2040
|
break;
|
|
1886
2041
|
}
|
|
@@ -1947,10 +2102,7 @@ async function performCli(argv, io, env) {
|
|
|
1947
2102
|
});
|
|
1948
2103
|
}
|
|
1949
2104
|
else if (parsed.path === "swarm request") {
|
|
1950
|
-
const result = await requestMembership(context, first, {
|
|
1951
|
-
...(typeof parsed.options.alias === "string"
|
|
1952
|
-
? { alias: parsed.options.alias }
|
|
1953
|
-
: {}),
|
|
2105
|
+
const result = await requestMembership(context, state.resolveSwarm(first), {
|
|
1954
2106
|
...(typeof parsed.options.output === "string"
|
|
1955
2107
|
? { output: parsed.options.output }
|
|
1956
2108
|
: {}),
|