@ipab/cli 0.1.0-rc.10 → 0.1.0-rc.12
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 +24 -11
- package/dist/authoring.d.ts +7 -0
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +85 -5
- package/dist/authoring.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/bundled-skills.d.ts +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +904 -183
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.js +1 -1
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon-ui.d.ts +1 -0
- package/dist/daemon-ui.d.ts.map +1 -1
- package/dist/daemon-ui.js +2 -0
- package/dist/daemon-ui.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +7 -3
- package/dist/doctor.js.map +1 -1
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +1 -1
- package/dist/get.js.map +1 -1
- package/dist/history.d.ts +3 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +16 -1
- package/dist/history.js.map +1 -1
- package/dist/kubo-topology.d.ts +2 -0
- package/dist/kubo-topology.d.ts.map +1 -1
- package/dist/kubo-topology.js +17 -20
- package/dist/kubo-topology.js.map +1 -1
- package/dist/kubo.d.ts +5 -3
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +83 -13
- package/dist/kubo.js.map +1 -1
- package/dist/name-reference.d.ts +8 -0
- package/dist/name-reference.d.ts.map +1 -0
- package/dist/name-reference.js +63 -0
- package/dist/name-reference.js.map +1 -0
- package/dist/pivot-rpc.d.ts +37 -2
- package/dist/pivot-rpc.d.ts.map +1 -1
- package/dist/pivot-rpc.js +188 -8
- package/dist/pivot-rpc.js.map +1 -1
- package/dist/search-index.d.ts.map +1 -1
- package/dist/search-index.js +1 -0
- package/dist/search-index.js.map +1 -1
- package/dist/skill-definition.d.ts +9 -0
- package/dist/skill-definition.d.ts.map +1 -1
- package/dist/skill-definition.js +26 -2
- package/dist/skill-definition.js.map +1 -1
- package/dist/skill-source.d.ts +1 -0
- package/dist/skill-source.d.ts.map +1 -1
- package/dist/skill-source.js +10 -4
- package/dist/skill-source.js.map +1 -1
- package/dist/skills.d.ts +9 -3
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +31 -2
- package/dist/skills.js.map +1 -1
- package/dist/state.d.ts +20 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +87 -3
- package/dist/state.js.map +1 -1
- package/dist/swarm-fs-core.d.ts +217 -0
- package/dist/swarm-fs-core.d.ts.map +1 -0
- package/dist/swarm-fs-core.js +885 -0
- package/dist/swarm-fs-core.js.map +1 -0
- package/dist/swarm-fs-path.d.ts +17 -0
- package/dist/swarm-fs-path.d.ts.map +1 -0
- package/dist/swarm-fs-path.js +46 -0
- package/dist/swarm-fs-path.js.map +1 -0
- package/dist/swarm-fs.d.ts +9 -0
- package/dist/swarm-fs.d.ts.map +1 -0
- package/dist/swarm-fs.js +21 -0
- package/dist/swarm-fs.js.map +1 -0
- package/dist/swarm-observations.d.ts +6 -0
- package/dist/swarm-observations.d.ts.map +1 -1
- package/dist/swarm-observations.js +28 -8
- package/dist/swarm-observations.js.map +1 -1
- package/dist/swarm.d.ts +192 -17
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1360 -442
- package/dist/swarm.js.map +1 -1
- package/dist/unixfs-tree.d.ts +55 -0
- package/dist/unixfs-tree.d.ts.map +1 -1
- package/dist/unixfs-tree.js +361 -2
- package/dist/unixfs-tree.js.map +1 -1
- package/package.json +5 -5
- package/src/authoring.ts +125 -8
- package/src/cli.ts +1215 -281
- package/src/config-secret.ts +1 -1
- package/src/config.ts +20 -2
- package/src/daemon-ui.ts +3 -0
- package/src/doctor.ts +12 -2
- package/src/get.ts +2 -1
- package/src/history.ts +26 -1
- package/src/kubo-topology.ts +25 -22
- package/src/kubo.ts +127 -9
- package/src/name-reference.ts +91 -0
- package/src/pivot-rpc.ts +272 -14
- package/src/search-index.ts +1 -0
- package/src/skill-definition.ts +45 -3
- package/src/skill-source.ts +10 -4
- package/src/skills.ts +43 -2
- package/src/state.ts +117 -2
- package/src/swarm-fs-core.ts +1461 -0
- package/src/swarm-fs-path.ts +68 -0
- package/src/swarm-fs.ts +104 -0
- package/src/swarm-observations.ts +40 -14
- package/src/swarm.ts +1950 -727
- package/src/unixfs-tree.ts +447 -2
package/dist/cli.js
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
import { lstat, readFile } from "node:fs/promises";
|
|
3
|
-
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
|
-
import { ContentBundleError } from "@ipab/bundle";
|
|
5
3
|
import { randomUUID } from "node:crypto";
|
|
6
4
|
import { CID } from "multiformats/cid";
|
|
7
5
|
import stringWidth from "string-width";
|
|
8
|
-
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, swarmUrl, visibleConfig, } from "./config.js";
|
|
9
|
-
import { HostError,
|
|
10
|
-
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
11
|
-
import { execute } from "./runtime.js";
|
|
12
|
-
import { validatedBundle } from "./space.js";
|
|
6
|
+
import { LOCAL_SWARM_ALIAS, configKey, effectiveConfig, isLocalSwarm, parseValue, publicUrl, stateLocation, storeConfiguration, swarmUrl, visibleConfig, } from "./config.js";
|
|
7
|
+
import { HostError, object, syntax } from "./host-error.js";
|
|
13
8
|
import { createAssociation, exactCid, swarmAlias, State, } from "./state.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { assembleBundle } from "./assembly.js";
|
|
17
|
-
import { getBundle } from "./get.js";
|
|
18
|
-
import { doctorDevice, doctorText } from "./doctor.js";
|
|
19
|
-
import { daemonEndpoint, ensureDaemon, openLoopbackUrl, serveDaemon, } from "./daemon.js";
|
|
20
|
-
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
21
|
-
import { createSwarm, swarmDaemon, requestMembership, approveMembership, grantPivotAuthority, 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";
|
|
22
|
-
import { schemaAlias } from "./app-definition.js";
|
|
23
|
-
import { unpin, pinDetails } from "./pins.js";
|
|
24
|
-
import { publicationSource } from "./publish-source.js";
|
|
25
|
-
import { templateRenderExample, templateOutputTree, templateParameterRows, } from "./template-presentation.js";
|
|
26
|
-
import { logFiles } from "./logs.js";
|
|
27
|
-
import { builtinContent } from "./builtins.js";
|
|
9
|
+
import { formatNameReference, parseNameReference, formalName, templateName, } from "./name-reference.js";
|
|
10
|
+
import { normalizeSwarmFsPath } from "./swarm-fs-path.js";
|
|
28
11
|
import { readSecretStream } from "./config-secret.js";
|
|
29
|
-
import { manageSkills, syncDaemonSwarm } from "./skills.js";
|
|
30
12
|
let progressLine = false;
|
|
31
13
|
export const processIO = {
|
|
32
14
|
out(text) {
|
|
@@ -75,6 +57,9 @@ const commands = {
|
|
|
75
57
|
daemon: "daemon",
|
|
76
58
|
"daemon ui": "daemon ui [--open]",
|
|
77
59
|
"skills list": "skills list [--refresh | --no-refresh]",
|
|
60
|
+
"skills show": "skills show SCHEMA_OR_CONTENT [--refresh | --no-refresh]",
|
|
61
|
+
"skills set": "skills set SKILL [--global] [--type SCHEMA]... [--replace]",
|
|
62
|
+
"skills remove": "skills remove [--global NAME] [--type SCHEMA]...",
|
|
78
63
|
"skills sync": "skills sync [NAMES...] [--agent AGENT]... [--override-existing] [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
79
64
|
doctor: "doctor [--fix [--yes]]",
|
|
80
65
|
profile: "profile [--name NAME] [--description TEXT]",
|
|
@@ -87,6 +72,7 @@ const commands = {
|
|
|
87
72
|
"swarm resume": "swarm resume",
|
|
88
73
|
"swarm profile": "swarm profile [--address MULTIADDR] [--pivot true|false]",
|
|
89
74
|
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
75
|
+
"swarm replicate": "swarm replicate [--pivot MEMBER]",
|
|
90
76
|
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
91
77
|
"swarm list": "swarm list",
|
|
92
78
|
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
@@ -100,7 +86,7 @@ const commands = {
|
|
|
100
86
|
build: "build [SOURCE] [OPTIONS]",
|
|
101
87
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
102
88
|
"bundle inspect": "bundle inspect SOURCE",
|
|
103
|
-
"bundle import": "bundle import
|
|
89
|
+
"bundle import": "bundle import SOURCE",
|
|
104
90
|
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
105
91
|
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
106
92
|
pin: "pin REF [--refresh | --no-refresh]",
|
|
@@ -119,17 +105,22 @@ const commands = {
|
|
|
119
105
|
"config reset": "config reset KEY",
|
|
120
106
|
"store usage": "store usage",
|
|
121
107
|
"store gc": "store gc",
|
|
108
|
+
"fs ls": "fs ls [PATH] [--all] [--recursive] [--refresh | --no-refresh]",
|
|
109
|
+
"fs stat": "fs stat PATH [--refresh | --no-refresh]",
|
|
110
|
+
"fs set": "fs set PATH CID [--expect OLD_CID | --replace]",
|
|
111
|
+
"fs rm": "fs rm PATH [--expect OLD_CID]",
|
|
122
112
|
"history list": "history list [OPTIONS]",
|
|
123
113
|
"history show": "history show RUN_ID",
|
|
124
114
|
"history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
125
115
|
};
|
|
126
116
|
const groups = {
|
|
127
|
-
skills: "Discover and
|
|
117
|
+
skills: "Discover, associate, and synchronize Swarm Skills",
|
|
128
118
|
swarm: "Create, authorize, select and manage personal swarms",
|
|
129
119
|
bundle: "Create, inspect and import content bundles",
|
|
130
120
|
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
131
121
|
register: "Associate content types with Apps",
|
|
132
122
|
templates: "Inspect, render and manage Template Bundles",
|
|
123
|
+
fs: "Inspect and modify paths in a Swarm UnixFS tree",
|
|
133
124
|
config: "Manage local configuration",
|
|
134
125
|
store: "Query local storage and collect unreferenced blocks",
|
|
135
126
|
history: "View and remove execution history",
|
|
@@ -217,21 +208,79 @@ const commandHelp = {
|
|
|
217
208
|
],
|
|
218
209
|
},
|
|
219
210
|
"skills list": {
|
|
220
|
-
summary: "List
|
|
211
|
+
summary: "List Global Skills (with local status) and Type Skills from one Swarm",
|
|
221
212
|
options: [
|
|
222
213
|
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
223
|
-
"Global --json Emit machine-readable
|
|
214
|
+
"Global --json Emit machine-readable global items, typeSkills, CIDs and status.",
|
|
224
215
|
],
|
|
225
216
|
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
226
217
|
notes: [
|
|
227
218
|
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
228
|
-
"
|
|
219
|
+
"Reads <skillPath>/global/* and <skillPath>/types/*; missing subdirectories are treated as empty.",
|
|
220
|
+
"Requires skillPath in the exact root State Bundle or legacy Meta type. No silent upgrades.",
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
"skills show": {
|
|
224
|
+
summary: "Show the Skill associated with a Bundle type or content Bundle",
|
|
225
|
+
arguments: [
|
|
226
|
+
"SCHEMA_OR_CONTENT Canonical schema CID, builtin: alias, content Bundle CID, Swarm URI, or local .car/Bundle directory.",
|
|
227
|
+
],
|
|
228
|
+
options: [
|
|
229
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
230
|
+
"Global --json Emit machine-readable Skill association details.",
|
|
231
|
+
],
|
|
232
|
+
examples: [
|
|
233
|
+
"ipab skills show SCHEMA_CID",
|
|
234
|
+
"ipab skills show ipab://work/docs/spec",
|
|
235
|
+
"ipab --json skills show ./document.car",
|
|
236
|
+
],
|
|
237
|
+
notes: [
|
|
238
|
+
"Swarm URIs use the URI's Swarm ahead of --swarm and the default Swarm.",
|
|
239
|
+
"Content Bundle references automatically unwrap Artifacts and resolve their schema CID.",
|
|
240
|
+
"Exits with code 1 (SKILL_NOT_FOUND) when no Skill is associated with the schema.",
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
"skills set": {
|
|
244
|
+
summary: "Associate a Skill Bundle globally and/or with Bundle types",
|
|
245
|
+
arguments: [
|
|
246
|
+
"SKILL Skill Bundle CID, Swarm URI, local .car file, or assembled Skill Bundle directory containing .bundle.yaml.",
|
|
247
|
+
],
|
|
248
|
+
options: [
|
|
249
|
+
"--global Publish to <skillPath>/global/<skill-name> for global synchronization.",
|
|
250
|
+
"--type SCHEMA Repeatable target Bundle schema CID (writes <skillPath>/types/<schemaCid>).",
|
|
251
|
+
"--replace Overwrite existing targets that point to a different Skill CID.",
|
|
252
|
+
],
|
|
253
|
+
examples: [
|
|
254
|
+
"ipab skills set SKILL_CID --global",
|
|
255
|
+
"ipab skills set ./skill.car --type SCHEMA_CID",
|
|
256
|
+
"ipab skills set SKILL_CID --global --type SCHEMA_CID --replace",
|
|
257
|
+
],
|
|
258
|
+
notes: [
|
|
259
|
+
"Requires --global and/or at least one --type SCHEMA. All targets commit atomically in one HEAD CAS.",
|
|
260
|
+
"Writes direct Skill Bundle CIDs. Occupied targets with a different CID fail with exit code 3 unless --replace is set.",
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
"skills remove": {
|
|
264
|
+
summary: "Remove global and/or type Skill associations atomically",
|
|
265
|
+
options: [
|
|
266
|
+
"--global NAME Remove <skillPath>/global/NAME (at most once).",
|
|
267
|
+
"--type SCHEMA Repeatable target Bundle schema CID to remove from <skillPath>/types/.",
|
|
268
|
+
],
|
|
269
|
+
examples: [
|
|
270
|
+
"ipab skills remove --global my-skill",
|
|
271
|
+
"ipab skills remove --type SCHEMA_CID",
|
|
272
|
+
"ipab skills remove --global my-skill --type SCHEMA_CID",
|
|
273
|
+
],
|
|
274
|
+
notes: [
|
|
275
|
+
"Requires --global NAME and/or at least one --type SCHEMA. All removals commit atomically in one HEAD CAS.",
|
|
276
|
+
"If any target is missing, the entire batch fails with exit code 1 and nothing is modified.",
|
|
277
|
+
"Does not delete underlying content blocks or locally installed Agent Skill files.",
|
|
229
278
|
],
|
|
230
279
|
},
|
|
231
280
|
"skills sync": {
|
|
232
|
-
summary: "Install reviewed Swarm Skills using the pinned official npx installer",
|
|
281
|
+
summary: "Install reviewed Global Swarm Skills using the pinned official npx installer",
|
|
233
282
|
arguments: [
|
|
234
|
-
"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.",
|
|
283
|
+
"NAMES Install identities, e.g. ipab code-review, or full shared Names such as ipab/skills/global/ipab. Resolved from one verified snapshot; omit for all Global Skills.",
|
|
235
284
|
],
|
|
236
285
|
options: [
|
|
237
286
|
"--agent AGENT Repeatable globally supported agent ID; default is universal (~/.agents/skills).",
|
|
@@ -245,6 +294,7 @@ const commandHelp = {
|
|
|
245
294
|
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
246
295
|
],
|
|
247
296
|
notes: [
|
|
297
|
+
"Scans <skillPath>/global/* only; Type Skills under <skillPath>/types/* are never installed globally.",
|
|
248
298
|
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
249
299
|
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
250
300
|
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
@@ -385,6 +435,21 @@ const commandHelp = {
|
|
|
385
435
|
"Pivot provides backbone connectivity and durable published-content Pin service through daemon. Keep it online with sufficient storage.",
|
|
386
436
|
],
|
|
387
437
|
},
|
|
438
|
+
"swarm replicate": {
|
|
439
|
+
summary: "Replicate the complete local current HEAD to a remote Pivot",
|
|
440
|
+
options: [
|
|
441
|
+
"--pivot MEMBER Target one declared Pivot by exact member name, public key or PeerID.",
|
|
442
|
+
],
|
|
443
|
+
examples: [
|
|
444
|
+
"ipab --swarm work swarm replicate --pivot scott-office-ubuntu",
|
|
445
|
+
"ipab --json --swarm work swarm replicate",
|
|
446
|
+
],
|
|
447
|
+
notes: [
|
|
448
|
+
"Requires approved membership and the complete current HEAD locally. Works behind NAT; no source address publication is required.",
|
|
449
|
+
"Checks Pivot readiness and idempotently copies to an unready Pivot. Stops after the first ready replica; --pivot restricts all work to that member. Never changes HEAD or bypasses a write receipt.",
|
|
450
|
+
"Progress goes to stderr; --json returns the HEAD and per-Pivot results. At least one Pivot must confirm readiness for success.",
|
|
451
|
+
],
|
|
452
|
+
},
|
|
388
453
|
"swarm members": {
|
|
389
454
|
summary: "List every public member, including the Owner",
|
|
390
455
|
options: [
|
|
@@ -625,17 +690,24 @@ const commandHelp = {
|
|
|
625
690
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
626
691
|
},
|
|
627
692
|
"bundle import": {
|
|
628
|
-
summary: "Validate and import a CAR into the configured Store",
|
|
629
|
-
arguments: [
|
|
630
|
-
|
|
693
|
+
summary: "Validate and import a CAR or Bundle directory into the configured Store",
|
|
694
|
+
arguments: [
|
|
695
|
+
"SOURCE Self-contained single-root CAR or local Content Bundle directory.",
|
|
696
|
+
],
|
|
697
|
+
examples: [
|
|
698
|
+
"ipab bundle import hello\\dist\\app.car",
|
|
699
|
+
"ipab bundle import .",
|
|
700
|
+
],
|
|
631
701
|
notes: [
|
|
702
|
+
"Directories must contain valid Bundle metadata; .bundle-ignore is honored without writing CAR files.",
|
|
632
703
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
633
704
|
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
634
705
|
],
|
|
635
706
|
},
|
|
636
707
|
exec: {
|
|
637
|
-
summary: "Run an App by
|
|
708
|
+
summary: "Run an App by CID, Swarm IPAB URI, local CAR or Bundle directory",
|
|
638
709
|
arguments: [
|
|
710
|
+
"APP App CID, Swarm IPAB URI, local App .car file or assembled App Bundle directory.",
|
|
639
711
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
640
712
|
],
|
|
641
713
|
options: [
|
|
@@ -644,12 +716,13 @@ const commandHelp = {
|
|
|
644
716
|
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
645
717
|
],
|
|
646
718
|
examples: [
|
|
647
|
-
"ipab exec
|
|
648
|
-
"ipab exec --
|
|
719
|
+
"ipab exec APP_CID",
|
|
720
|
+
"ipab exec .\\dist\\app.car --help",
|
|
649
721
|
"ipab exec ipab://work/apps/hello --help",
|
|
650
722
|
],
|
|
651
723
|
notes: [
|
|
652
724
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
725
|
+
"Local App directories must already contain valid assembled Bundle metadata; exec does not compile source, pin or modify the directory.",
|
|
653
726
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
654
727
|
"History stores argv by default; do not put secrets in arguments.",
|
|
655
728
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
@@ -659,7 +732,7 @@ const commandHelp = {
|
|
|
659
732
|
open: {
|
|
660
733
|
summary: "Open content with its registered App",
|
|
661
734
|
arguments: [
|
|
662
|
-
"CONTENT Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
735
|
+
"CONTENT Local Bundle directory or .car file, Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
663
736
|
],
|
|
664
737
|
options: [
|
|
665
738
|
"--log Record stdout/stderr; requires history enabled.",
|
|
@@ -668,12 +741,13 @@ const commandHelp = {
|
|
|
668
741
|
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
669
742
|
],
|
|
670
743
|
examples: [
|
|
671
|
-
"ipab open
|
|
744
|
+
"ipab open .",
|
|
745
|
+
"ipab open .\\dist\\bundle.car",
|
|
672
746
|
"ipab open --log --refresh ipab:///documents/readme",
|
|
673
|
-
"ipab open ipab:///",
|
|
674
747
|
],
|
|
675
748
|
notes: [
|
|
676
749
|
"Requires a saved registration and App support for the exact content type.",
|
|
750
|
+
"Local directories and .car files must contain a valid Content Bundle; quote paths with spaces. Directory snapshots honor .bundle-ignore without compiling, publishing, pinning, writing CAR files or updating the source.",
|
|
677
751
|
"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.",
|
|
678
752
|
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
679
753
|
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
@@ -746,7 +820,7 @@ const commandHelp = {
|
|
|
746
820
|
summary: "Associate a content type with an App",
|
|
747
821
|
arguments: [
|
|
748
822
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
749
|
-
"APP App CID
|
|
823
|
+
"APP App CID, Swarm IPAB URI, local App .car file or assembled App Bundle directory.",
|
|
750
824
|
],
|
|
751
825
|
options: [
|
|
752
826
|
"--replace Allow changing an existing association.",
|
|
@@ -754,10 +828,12 @@ const commandHelp = {
|
|
|
754
828
|
],
|
|
755
829
|
examples: [
|
|
756
830
|
"ipab register set SCHEMA_CID APP_CID",
|
|
831
|
+
"ipab register set SCHEMA_CID .\\dist\\app.car --swarm work",
|
|
757
832
|
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
758
833
|
],
|
|
759
834
|
notes: [
|
|
760
835
|
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
836
|
+
"Local App .car files or assembled App Bundle directories are snapshotted into the local Store once and published into each selected Swarm registry without compiling or pinning.",
|
|
761
837
|
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
762
838
|
"Does not verify App type support; open checks it before execution.",
|
|
763
839
|
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
@@ -779,6 +855,79 @@ const commandHelp = {
|
|
|
779
855
|
"Does not remove Apps, pins or content.",
|
|
780
856
|
],
|
|
781
857
|
},
|
|
858
|
+
"fs ls": {
|
|
859
|
+
summary: "List entries under a path in the selected Swarm UnixFS tree",
|
|
860
|
+
arguments: [
|
|
861
|
+
"PATH Optional directory path inside the Swarm root (defaults to /).",
|
|
862
|
+
],
|
|
863
|
+
options: [
|
|
864
|
+
"--all Include protected v7 root metadata files when listing /.",
|
|
865
|
+
"--recursive Traverse subdirectories recursively (bounded depth/nodes).",
|
|
866
|
+
"--refresh Fetch the latest Swarm HEAD before listing.",
|
|
867
|
+
"--no-refresh Use only the cached Swarm HEAD without contacting network.",
|
|
868
|
+
],
|
|
869
|
+
examples: [
|
|
870
|
+
"ipab fs ls",
|
|
871
|
+
"ipab fs ls ipab/skills --recursive",
|
|
872
|
+
"ipab --json fs ls --all",
|
|
873
|
+
],
|
|
874
|
+
notes: [
|
|
875
|
+
"On legacy (v2-v6) Swarms, lists a read-only virtual view projected from snapshot names.",
|
|
876
|
+
],
|
|
877
|
+
},
|
|
878
|
+
"fs stat": {
|
|
879
|
+
summary: "Inspect metadata for a path in the selected Swarm UnixFS tree",
|
|
880
|
+
arguments: ["PATH Path inside the Swarm root (use / or . for root)."],
|
|
881
|
+
options: [
|
|
882
|
+
"--refresh Fetch the latest Swarm HEAD before inspecting.",
|
|
883
|
+
"--no-refresh Use only the cached Swarm HEAD without contacting network.",
|
|
884
|
+
],
|
|
885
|
+
examples: [
|
|
886
|
+
"ipab fs stat /",
|
|
887
|
+
"ipab fs stat ipab/skills",
|
|
888
|
+
"ipab --json fs stat docs/guide",
|
|
889
|
+
],
|
|
890
|
+
notes: [
|
|
891
|
+
"On legacy (v2-v6) Swarms, reports a read-only virtual view projected from snapshot names.",
|
|
892
|
+
],
|
|
893
|
+
},
|
|
894
|
+
"fs set": {
|
|
895
|
+
summary: "Mount an existing CID at a path in the selected Swarm UnixFS tree",
|
|
896
|
+
arguments: [
|
|
897
|
+
"PATH Relative path inside the Swarm root (root / and protected metadata are rejected).",
|
|
898
|
+
"CID Canonical CID already present in the local IPFS store.",
|
|
899
|
+
],
|
|
900
|
+
options: [
|
|
901
|
+
"--expect OLD_CID Require the current path CID to match OLD_CID before replacing.",
|
|
902
|
+
"--replace Allow replacing an existing different CID at PATH.",
|
|
903
|
+
],
|
|
904
|
+
examples: [
|
|
905
|
+
"ipab fs set docs/guide bafy...",
|
|
906
|
+
"ipab fs set docs/guide bafyNEW --expect bafyOLD",
|
|
907
|
+
"ipab --json fs set docs/guide bafyNEW --replace",
|
|
908
|
+
],
|
|
909
|
+
notes: [
|
|
910
|
+
"Requires a State v7 UnixFS Swarm root; legacy (v2-v6) Swarms are not implicitly migrated.",
|
|
911
|
+
"Protected v7 root metadata files (.bundle.yaml, typeFile, entryFile) cannot be overwritten.",
|
|
912
|
+
],
|
|
913
|
+
},
|
|
914
|
+
"fs rm": {
|
|
915
|
+
summary: "Remove a path from the selected Swarm UnixFS tree",
|
|
916
|
+
arguments: [
|
|
917
|
+
"PATH Relative path to remove (automatically prunes empty parent directories up to /).",
|
|
918
|
+
],
|
|
919
|
+
options: [
|
|
920
|
+
"--expect OLD_CID Require the current path CID to match OLD_CID before removing.",
|
|
921
|
+
],
|
|
922
|
+
examples: [
|
|
923
|
+
"ipab fs rm docs/guide",
|
|
924
|
+
"ipab fs rm docs/guide --expect bafyOLD",
|
|
925
|
+
"ipab --json fs rm docs/guide",
|
|
926
|
+
],
|
|
927
|
+
notes: [
|
|
928
|
+
"Requires a State v7 UnixFS Swarm root; protected root metadata files cannot be removed.",
|
|
929
|
+
],
|
|
930
|
+
},
|
|
782
931
|
"config get": {
|
|
783
932
|
summary: "Show effective configuration",
|
|
784
933
|
arguments: ["KEY Optional configuration key; omit to show all values."],
|
|
@@ -847,7 +996,7 @@ const commandHelp = {
|
|
|
847
996
|
};
|
|
848
997
|
export function help(path = "") {
|
|
849
998
|
const globalOptions = `Global options (before COMMAND):
|
|
850
|
-
--swarm URL|ALIAS Select
|
|
999
|
+
--swarm URL|ALIAS Select Swarm (defaults to built-in local Swarm or saved swarm.default; URI swarm takes precedence)
|
|
851
1000
|
--state-dir PATH Set a dedicated, account-private local state directory
|
|
852
1001
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
853
1002
|
--json Output management/development metadata, not App stdio`;
|
|
@@ -870,6 +1019,7 @@ Manage:
|
|
|
870
1019
|
doctor ${commandHelp.doctor.summary}
|
|
871
1020
|
profile ${commandHelp.profile.summary}
|
|
872
1021
|
swarm ${groups.swarm}
|
|
1022
|
+
fs ${groups.fs}
|
|
873
1023
|
skills ${groups.skills}
|
|
874
1024
|
search Search formal Names in the current swarm
|
|
875
1025
|
publish ${commandHelp.publish.summary}
|
|
@@ -906,6 +1056,7 @@ ${footer}`;
|
|
|
906
1056
|
...([
|
|
907
1057
|
"swarm status",
|
|
908
1058
|
"swarm members",
|
|
1059
|
+
"swarm replicate",
|
|
909
1060
|
"swarm update",
|
|
910
1061
|
"swarm resume",
|
|
911
1062
|
"swarm profile",
|
|
@@ -1052,6 +1203,7 @@ async function closeStore(store, appExitCode) {
|
|
|
1052
1203
|
await store?.close();
|
|
1053
1204
|
}
|
|
1054
1205
|
catch (error) {
|
|
1206
|
+
const { message } = await import("./errors.js");
|
|
1055
1207
|
throw new HostError(`Store cleanup failed: ${message(error)}`, appExitCode || 1, "CLEANUP_FAILED", "cleanup");
|
|
1056
1208
|
}
|
|
1057
1209
|
}
|
|
@@ -1163,6 +1315,7 @@ export function parse(argv) {
|
|
|
1163
1315
|
"store",
|
|
1164
1316
|
"swarm",
|
|
1165
1317
|
"skills",
|
|
1318
|
+
"fs",
|
|
1166
1319
|
].includes(group))
|
|
1167
1320
|
syntax(`Unknown command "${group}".${group === "setup" ? " Run ipab doctor to inspect, or ipab doctor --fix to prepare this device." : " Run ipab --help."}`);
|
|
1168
1321
|
if (group === "pin" && !["list", "show"].includes(tokens[0] ?? "")) {
|
|
@@ -1197,6 +1350,8 @@ export function parse(argv) {
|
|
|
1197
1350
|
syntax(`Unknown command "${result.path}".`);
|
|
1198
1351
|
if (group === "skills" && swarms.length > 1)
|
|
1199
1352
|
syntax("Skills operations select exactly one Swarm; repeated --swarm is not supported.");
|
|
1353
|
+
if (group === "fs" && swarms.length > 1)
|
|
1354
|
+
syntax("fs operations select at most one Swarm; repeated --swarm is not supported.");
|
|
1200
1355
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
1201
1356
|
if (separator >= 0)
|
|
1202
1357
|
result.template = tokens.splice(separator + 1);
|
|
@@ -1213,51 +1368,61 @@ export function parse(argv) {
|
|
|
1213
1368
|
const booleans = result.path.startsWith("skills ")
|
|
1214
1369
|
? result.path === "skills sync"
|
|
1215
1370
|
? ["dry-run", "yes", "override-existing", "force", "no-force"]
|
|
1216
|
-
:
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
? ["
|
|
1233
|
-
: result.path === "
|
|
1234
|
-
? ["
|
|
1235
|
-
: [
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
?
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
"
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
? ["
|
|
1250
|
-
: result.path === "
|
|
1251
|
-
? ["
|
|
1252
|
-
:
|
|
1253
|
-
? ["
|
|
1254
|
-
:
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1371
|
+
: result.path === "skills set"
|
|
1372
|
+
? ["global", "replace"]
|
|
1373
|
+
: result.path === "skills remove"
|
|
1374
|
+
? []
|
|
1375
|
+
: ["force", "no-force"]
|
|
1376
|
+
: result.path === "fs ls"
|
|
1377
|
+
? ["all", "recursive", "force", "no-force"]
|
|
1378
|
+
: result.path === "fs stat"
|
|
1379
|
+
? ["force", "no-force"]
|
|
1380
|
+
: result.path === "fs set"
|
|
1381
|
+
? ["replace"]
|
|
1382
|
+
: result.path === "doctor"
|
|
1383
|
+
? ["fix", "yes"]
|
|
1384
|
+
: result.path === "bundle build"
|
|
1385
|
+
? ["replace", "schema-only", "no-import"]
|
|
1386
|
+
: result.path === "build"
|
|
1387
|
+
? ["replace", "no-import"]
|
|
1388
|
+
: result.path === "publish"
|
|
1389
|
+
? ["snapshot"]
|
|
1390
|
+
: [
|
|
1391
|
+
"get",
|
|
1392
|
+
"templates render",
|
|
1393
|
+
"templates list",
|
|
1394
|
+
"templates show",
|
|
1395
|
+
].includes(result.path)
|
|
1396
|
+
? result.path === "templates render"
|
|
1397
|
+
? ["force", "no-force"]
|
|
1398
|
+
: result.path === "get"
|
|
1399
|
+
? ["raw", "force", "no-force"]
|
|
1400
|
+
: ["force", "no-force"]
|
|
1401
|
+
: result.path === "search"
|
|
1402
|
+
? ["all", "current", "force", "no-force"]
|
|
1403
|
+
: result.path === "swarm request"
|
|
1404
|
+
? ["pivot"]
|
|
1405
|
+
: result.path === "swarm approve"
|
|
1406
|
+
? ["yes", "again", "pivot"]
|
|
1407
|
+
: ["swarm status", "swarm members"].includes(result.path)
|
|
1408
|
+
? ["local", "force", "no-force"]
|
|
1409
|
+
: [
|
|
1410
|
+
"swarm exclude",
|
|
1411
|
+
"swarm set",
|
|
1412
|
+
"swarm pivot grant",
|
|
1413
|
+
].includes(result.path)
|
|
1414
|
+
? ["yes"]
|
|
1415
|
+
: result.path === "register set"
|
|
1416
|
+
? ["replace"]
|
|
1417
|
+
: result.path === "history remove"
|
|
1418
|
+
? ["yes"]
|
|
1419
|
+
: result.path === "open"
|
|
1420
|
+
? ["log", "raw", "force", "no-force"]
|
|
1421
|
+
: result.path === "pin"
|
|
1422
|
+
? ["force", "no-force"]
|
|
1423
|
+
: result.path === "daemon ui"
|
|
1424
|
+
? ["open"]
|
|
1425
|
+
: [];
|
|
1261
1426
|
if (booleans.includes("force"))
|
|
1262
1427
|
booleans.push("refresh", "no-refresh");
|
|
1263
1428
|
const values = result.path === "swarm create"
|
|
@@ -1268,33 +1433,43 @@ export function parse(argv) {
|
|
|
1268
1433
|
? ["output"]
|
|
1269
1434
|
: result.path === "swarm profile"
|
|
1270
1435
|
? ["address", "pivot"]
|
|
1271
|
-
: result.path === "swarm
|
|
1272
|
-
? ["
|
|
1273
|
-
: result.path === "swarm
|
|
1274
|
-
? []
|
|
1275
|
-
:
|
|
1276
|
-
? [
|
|
1277
|
-
:
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1436
|
+
: result.path === "swarm replicate"
|
|
1437
|
+
? ["pivot"]
|
|
1438
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1439
|
+
? ["name", "description"]
|
|
1440
|
+
: result.path === "swarm approve"
|
|
1441
|
+
? []
|
|
1442
|
+
: [
|
|
1443
|
+
"publish",
|
|
1444
|
+
"templates set",
|
|
1445
|
+
"templates remove",
|
|
1446
|
+
"fs set",
|
|
1447
|
+
"fs rm",
|
|
1448
|
+
].includes(result.path)
|
|
1449
|
+
? ["expect"]
|
|
1450
|
+
: result.path === "get"
|
|
1451
|
+
? ["output"]
|
|
1452
|
+
: result.path === "search"
|
|
1453
|
+
? ["prefix", "kind", "schema", "limit", "offset"]
|
|
1454
|
+
: result.path === "templates render"
|
|
1455
|
+
? ["description"]
|
|
1456
|
+
: result.path === "bundle build" ||
|
|
1457
|
+
result.path === "build"
|
|
1458
|
+
? ["output"]
|
|
1459
|
+
: result.path === "history list"
|
|
1460
|
+
? [
|
|
1461
|
+
"app",
|
|
1462
|
+
"status",
|
|
1463
|
+
"since",
|
|
1464
|
+
"until",
|
|
1465
|
+
"limit",
|
|
1466
|
+
"before",
|
|
1467
|
+
]
|
|
1468
|
+
: result.path === "history remove"
|
|
1469
|
+
? ["app", "status", "since", "until"]
|
|
1470
|
+
: result.path === "skills remove"
|
|
1471
|
+
? ["global"]
|
|
1472
|
+
: [];
|
|
1298
1473
|
while (tokens.length) {
|
|
1299
1474
|
const value = tokens.shift();
|
|
1300
1475
|
if (result.path === "swarm exclude" &&
|
|
@@ -1312,6 +1487,18 @@ export function parse(argv) {
|
|
|
1312
1487
|
(result.agents ??= []).push(input);
|
|
1313
1488
|
continue;
|
|
1314
1489
|
}
|
|
1490
|
+
if ((result.path === "skills set" || result.path === "skills remove") &&
|
|
1491
|
+
option === "type") {
|
|
1492
|
+
const input = tokens.shift();
|
|
1493
|
+
if (!input || input.startsWith("-"))
|
|
1494
|
+
syntax("--type needs a value.");
|
|
1495
|
+
(result.types ??= []).push(input);
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
if (result.path === "skills remove" &&
|
|
1499
|
+
option === "global" &&
|
|
1500
|
+
Object.hasOwn(result.options, "global"))
|
|
1501
|
+
syntax("--global may be specified at most once.");
|
|
1315
1502
|
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1316
1503
|
const input = tokens.shift();
|
|
1317
1504
|
if (!input || input.startsWith("-"))
|
|
@@ -1366,11 +1553,33 @@ export function parse(argv) {
|
|
|
1366
1553
|
if (result.path === "register list" &&
|
|
1367
1554
|
(result.registrySwarms?.length ?? 0) > 1)
|
|
1368
1555
|
syntax("register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.");
|
|
1556
|
+
if (result.path === "skills set") {
|
|
1557
|
+
if (!result.options.global && !(result.types?.length ?? 0))
|
|
1558
|
+
syntax("skills set requires --global and/or at least one --type SCHEMA.");
|
|
1559
|
+
for (const schema of result.types ?? [])
|
|
1560
|
+
if (!schema.startsWith("builtin:"))
|
|
1561
|
+
exactCid(schema, true);
|
|
1562
|
+
}
|
|
1563
|
+
if (result.path === "skills remove") {
|
|
1564
|
+
if (typeof result.options.global !== "string" &&
|
|
1565
|
+
!(result.types?.length ?? 0))
|
|
1566
|
+
syntax("skills remove requires --global NAME and/or at least one --type SCHEMA.");
|
|
1567
|
+
if (typeof result.options.global === "string" &&
|
|
1568
|
+
(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(result.options.global) ||
|
|
1569
|
+
result.options.global.length > 64))
|
|
1570
|
+
syntax(`Invalid global Skill name "${result.options.global}". Expected lowercase kebab-case (1..64 characters).`);
|
|
1571
|
+
for (const schema of result.types ?? [])
|
|
1572
|
+
if (!schema.startsWith("builtin:"))
|
|
1573
|
+
exactCid(schema, true);
|
|
1574
|
+
}
|
|
1369
1575
|
const counts = {
|
|
1370
1576
|
daemon: [0, 0],
|
|
1371
1577
|
"daemon ui": [0, 0],
|
|
1372
1578
|
doctor: [0, 0],
|
|
1373
1579
|
"skills list": [0, 0],
|
|
1580
|
+
"skills show": [1, 1],
|
|
1581
|
+
"skills set": [1, 1],
|
|
1582
|
+
"skills remove": [0, 0],
|
|
1374
1583
|
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1375
1584
|
profile: [0, 0],
|
|
1376
1585
|
"swarm create": [0, 0],
|
|
@@ -1382,6 +1591,7 @@ export function parse(argv) {
|
|
|
1382
1591
|
"swarm resume": [0, 0],
|
|
1383
1592
|
"swarm profile": [0, 0],
|
|
1384
1593
|
"swarm status": [0, 0],
|
|
1594
|
+
"swarm replicate": [0, 0],
|
|
1385
1595
|
"swarm members": [0, 0],
|
|
1386
1596
|
"swarm list": [0, 0],
|
|
1387
1597
|
"swarm set": [2, 2],
|
|
@@ -1408,6 +1618,10 @@ export function parse(argv) {
|
|
|
1408
1618
|
"templates show": [1, 1],
|
|
1409
1619
|
"templates set": [2, 2],
|
|
1410
1620
|
"templates remove": [1, 1],
|
|
1621
|
+
"fs ls": [0, 1],
|
|
1622
|
+
"fs stat": [1, 1],
|
|
1623
|
+
"fs set": [2, 2],
|
|
1624
|
+
"fs rm": [1, 1],
|
|
1411
1625
|
"config get": [0, 1],
|
|
1412
1626
|
"config set": [2, 2],
|
|
1413
1627
|
"config reset": [1, 1],
|
|
@@ -1467,6 +1681,37 @@ export function parse(argv) {
|
|
|
1467
1681
|
if (result.path === "templates remove" && !result.options.expect)
|
|
1468
1682
|
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1469
1683
|
}
|
|
1684
|
+
if (result.path === "fs ls" && result.positional[0] !== undefined) {
|
|
1685
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1686
|
+
allowRoot: true,
|
|
1687
|
+
allowTrailingSlash: true,
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
if (result.path === "fs stat") {
|
|
1691
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1692
|
+
allowRoot: true,
|
|
1693
|
+
allowTrailingSlash: true,
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
if (result.path === "fs set") {
|
|
1697
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1698
|
+
allowRoot: false,
|
|
1699
|
+
allowTrailingSlash: false,
|
|
1700
|
+
});
|
|
1701
|
+
exactCid(result.positional[1]);
|
|
1702
|
+
if (typeof result.options.expect === "string")
|
|
1703
|
+
exactCid(result.options.expect);
|
|
1704
|
+
if (result.options.expect !== undefined && result.options.replace)
|
|
1705
|
+
syntax("--expect and --replace are mutually exclusive.");
|
|
1706
|
+
}
|
|
1707
|
+
if (result.path === "fs rm") {
|
|
1708
|
+
normalizeSwarmFsPath(result.positional[0], {
|
|
1709
|
+
allowRoot: false,
|
|
1710
|
+
allowTrailingSlash: false,
|
|
1711
|
+
});
|
|
1712
|
+
if (typeof result.options.expect === "string")
|
|
1713
|
+
exactCid(result.options.expect);
|
|
1714
|
+
}
|
|
1470
1715
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
1471
1716
|
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
1472
1717
|
!(result.path === "config reset" && result.positional[0] === "store.rpc"))
|
|
@@ -1509,6 +1754,7 @@ async function performCli(argv, io, env) {
|
|
|
1509
1754
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
1510
1755
|
syntax("Non-interactive history remove requires --yes.");
|
|
1511
1756
|
if (parsed.path === "doctor") {
|
|
1757
|
+
const { doctorDevice, doctorText } = await import("./doctor.js");
|
|
1512
1758
|
const controller = new AbortController();
|
|
1513
1759
|
const interrupt = () => {
|
|
1514
1760
|
controller.abort(new HostError("Doctor interrupted.", 130, "ABORTED"));
|
|
@@ -1538,6 +1784,7 @@ async function performCli(argv, io, env) {
|
|
|
1538
1784
|
}
|
|
1539
1785
|
}
|
|
1540
1786
|
if (parsed.path === "daemon ui") {
|
|
1787
|
+
const { daemonEndpoint, openLoopbackUrl } = await import("./daemon.js");
|
|
1541
1788
|
const stateDir = stateLocation(parsed.flags, env).path;
|
|
1542
1789
|
const endpoint = await daemonEndpoint(stateDir);
|
|
1543
1790
|
if (!endpoint)
|
|
@@ -1552,7 +1799,9 @@ async function performCli(argv, io, env) {
|
|
|
1552
1799
|
: endpoint.url);
|
|
1553
1800
|
return 0;
|
|
1554
1801
|
}
|
|
1555
|
-
const builtins =
|
|
1802
|
+
const builtins = parsed.path === "swarm list"
|
|
1803
|
+
? { pins: [], blocks: new Map() }
|
|
1804
|
+
: await (await import("./builtins.js")).builtinContent();
|
|
1556
1805
|
state = new State(stateLocation(parsed.flags, env).path, builtins.pins, env);
|
|
1557
1806
|
if (parsed.path === "config reset" &&
|
|
1558
1807
|
parsed.positional[0] === "store.rpc") {
|
|
@@ -1627,9 +1876,6 @@ async function performCli(argv, io, env) {
|
|
|
1627
1876
|
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1628
1877
|
: {}),
|
|
1629
1878
|
});
|
|
1630
|
-
const filter = parsed.path.startsWith("history ")
|
|
1631
|
-
? filters(state, parsed.options)
|
|
1632
|
-
: {};
|
|
1633
1879
|
const selection = () => {
|
|
1634
1880
|
const saved = state.config({ includeSecrets: false });
|
|
1635
1881
|
const current = effectiveConfig(saved, parsed.flags, env, (reference) => state.resolveSwarm(reference)).find((item) => item.key === "swarm.default");
|
|
@@ -1645,6 +1891,53 @@ async function performCli(argv, io, env) {
|
|
|
1645
1891
|
}
|
|
1646
1892
|
if (state.legacyPinCount)
|
|
1647
1893
|
io.err(`Legacy local pin names are inactive: ${state.legacyPinCount} records are preserved in legacy_named_pins under ${state.directory}. Retention and original Store owners are unchanged; inspect ipab pin list and release intended archived holders with ipab unpin EXACT_CID.`);
|
|
1894
|
+
if (parsed.path === "swarm list") {
|
|
1895
|
+
const result = { swarms: state.allSwarms(), ...selection() };
|
|
1896
|
+
emit({
|
|
1897
|
+
...result,
|
|
1898
|
+
swarms: result.swarms.map((entry) => ({
|
|
1899
|
+
configUrl: entry.cid,
|
|
1900
|
+
alias: entry.alias,
|
|
1901
|
+
local: Boolean(entry.local),
|
|
1902
|
+
})),
|
|
1903
|
+
}, [
|
|
1904
|
+
...alignedRows(result.swarms.map((entry) => [
|
|
1905
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}${entry.local ? " [local]" : ""}`,
|
|
1906
|
+
entry.cid,
|
|
1907
|
+
])),
|
|
1908
|
+
...(result.source === "flag" &&
|
|
1909
|
+
result.effectiveCurrent !== result.savedCurrent
|
|
1910
|
+
? [
|
|
1911
|
+
`Selected via --swarm: ${printable(String(result.swarms.find((entry) => entry.cid === result.effectiveCurrent)?.alias ?? result.effectiveCurrent ?? "(none)"))}; saved default: ${printable(String(result.swarms.find((entry) => entry.cid === result.savedCurrent)?.alias ?? result.savedCurrent ?? "(none)"))}.`,
|
|
1912
|
+
]
|
|
1913
|
+
: []),
|
|
1914
|
+
].join("\n"));
|
|
1915
|
+
return 0;
|
|
1916
|
+
}
|
|
1917
|
+
const [{ ContentError, IpfsStore }, { ContentBundleError, openBundle }, { message }, { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, }, { execute }, { validatedBundle }, { buildBundle, inspectBundle, importBundle, nodeError, resolveLocalBundleInput, snapshotLocalBundle, }, { initApp }, { assembleBundle }, { getBundle }, { ensureDaemon, serveDaemon }, { keyId }, { createSwarm, swarmDaemon, requestMembership, approveMembership, grantPivotAuthority, exportRequest, removeMember, resumeRemoval, updateProfile, accountProfile, updateAccountProfile, swarmMembers, inspectSwarmStatus, verifiedRequest, verifiedRequestStream, membershipRequestSummary, updateSwarm, searchNames, resolveReference, publish, pinNameSubscription, pinReference, swarmRegistrations, swarmAssociation, setSwarmAssociation, removeSwarmAssociation, resolveTemplateSelector, swarmTemplates, setSwarmTemplate, removeSwarmTemplate, artifactValue, swarmTypeSkills, swarmTypeSkill, setSwarmSkill, removeSwarmSkill, }, { schemaAlias }, { unpin, pinDetails }, { publicationSource }, { templateRenderExample, templateOutputTree, templateParameterRows }, { logFiles }, { manageSkills, syncDaemonSwarm },] = await Promise.all([
|
|
1918
|
+
import("@ipab/ipfs-store"),
|
|
1919
|
+
import("@ipab/bundle"),
|
|
1920
|
+
import("./errors.js"),
|
|
1921
|
+
import("./history.js"),
|
|
1922
|
+
import("./runtime.js"),
|
|
1923
|
+
import("./space.js"),
|
|
1924
|
+
import("./authoring.js"),
|
|
1925
|
+
import("./app-authoring.js"),
|
|
1926
|
+
import("./assembly.js"),
|
|
1927
|
+
import("./get.js"),
|
|
1928
|
+
import("./daemon.js"),
|
|
1929
|
+
import("@ipab/bundle/pointer/crypto"),
|
|
1930
|
+
import("./swarm.js"),
|
|
1931
|
+
import("./app-definition.js"),
|
|
1932
|
+
import("./pins.js"),
|
|
1933
|
+
import("./publish-source.js"),
|
|
1934
|
+
import("./template-presentation.js"),
|
|
1935
|
+
import("./logs.js"),
|
|
1936
|
+
import("./skills.js"),
|
|
1937
|
+
]);
|
|
1938
|
+
const filter = parsed.path.startsWith("history ")
|
|
1939
|
+
? filters(state, parsed.options)
|
|
1940
|
+
: {};
|
|
1648
1941
|
if (parsed.path.startsWith("templates ") &&
|
|
1649
1942
|
parsed.path !== "templates render") {
|
|
1650
1943
|
const configUrl = requireSwarm();
|
|
@@ -1657,7 +1950,7 @@ async function performCli(argv, io, env) {
|
|
|
1657
1950
|
if (parsed.path === "templates list") {
|
|
1658
1951
|
const items = await swarmTemplates(context, configUrl);
|
|
1659
1952
|
const alias = state
|
|
1660
|
-
.
|
|
1953
|
+
.allSwarms()
|
|
1661
1954
|
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1662
1955
|
emit({ items }, `Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nTemplates: ${items.length}\n\n${table(["NAME", "TITLE", "TARGET CID", "TEMPLATE CID"], items.map((item) => [
|
|
1663
1956
|
item.selector,
|
|
@@ -1672,7 +1965,7 @@ async function performCli(argv, io, env) {
|
|
|
1672
1965
|
io.out(JSON.stringify(item));
|
|
1673
1966
|
else {
|
|
1674
1967
|
const alias = state
|
|
1675
|
-
.
|
|
1968
|
+
.allSwarms()
|
|
1676
1969
|
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1677
1970
|
const swarm = alias ?? configUrl;
|
|
1678
1971
|
const reference = formatNameReference(swarm, item.name);
|
|
@@ -1746,41 +2039,61 @@ async function performCli(argv, io, env) {
|
|
|
1746
2039
|
const completed = [];
|
|
1747
2040
|
const human = [];
|
|
1748
2041
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
2042
|
+
const localApp = parsed.path === "register set" && !parseNameReference(second)
|
|
2043
|
+
? await resolveLocalBundleInput(second)
|
|
2044
|
+
: undefined;
|
|
2045
|
+
let registerOwner;
|
|
2046
|
+
let localAppCid;
|
|
2047
|
+
try {
|
|
2048
|
+
if (localApp) {
|
|
2049
|
+
const session = `register:${randomUUID()}`;
|
|
2050
|
+
registerOwner = await Ownership.create(state, store, `register:${randomUUID()}`, session);
|
|
2051
|
+
localAppCid = await snapshotLocalBundle(localApp, registerOwner, session, {
|
|
2052
|
+
diagnostic: (text) => {
|
|
2053
|
+
io.err(text);
|
|
2054
|
+
},
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
for (const configUrl of targets) {
|
|
2058
|
+
const context = swarmContext();
|
|
2059
|
+
try {
|
|
2060
|
+
if (parsed.path === "register list") {
|
|
2061
|
+
const items = await swarmRegistrations(context, configUrl);
|
|
2062
|
+
const alias = state
|
|
2063
|
+
.allSwarms()
|
|
2064
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
2065
|
+
results.push({ items });
|
|
2066
|
+
human.push(`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(["TYPE CID", "APP CID"], items.map((item) => [item.schemaCid, item.appCid]), "No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS")}`);
|
|
2067
|
+
}
|
|
2068
|
+
else if (parsed.path === "register set") {
|
|
2069
|
+
const appCid = localAppCid ??
|
|
2070
|
+
(parseNameReference(second)
|
|
2071
|
+
? (await resolveReference(context, second, configUrl, (reference) => state.resolve(reference))).cid
|
|
2072
|
+
: state.resolve(second));
|
|
2073
|
+
const association = await setSwarmAssociation(context, configUrl, createAssociation(schema, appCid, parsed.template ?? ["%"]), Boolean(parsed.options.replace));
|
|
2074
|
+
results.push({ association });
|
|
2075
|
+
human.push(`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`);
|
|
2076
|
+
}
|
|
2077
|
+
else {
|
|
2078
|
+
const removed = await removeSwarmAssociation(context, configUrl, schema);
|
|
2079
|
+
results.push({ removed: [removed] });
|
|
2080
|
+
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
2081
|
+
}
|
|
2082
|
+
completed.push(configUrl);
|
|
1759
2083
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
?
|
|
1763
|
-
:
|
|
1764
|
-
const association = await setSwarmAssociation(context, configUrl, createAssociation(schema, appCid, parsed.template ?? ["%"]), Boolean(parsed.options.replace));
|
|
1765
|
-
results.push({ association });
|
|
1766
|
-
human.push(`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`);
|
|
2084
|
+
catch (cause) {
|
|
2085
|
+
throw new HostError(parsed.path === "register list"
|
|
2086
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
2087
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`, cause instanceof HostError ? cause.exitCode : 1, cause instanceof HostError ? cause.code : "REGISTRY_FAILED", "publication");
|
|
1767
2088
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
results.push({ removed: [removed] });
|
|
1771
|
-
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
2089
|
+
finally {
|
|
2090
|
+
await context.finishRead?.();
|
|
1772
2091
|
}
|
|
1773
|
-
completed.push(configUrl);
|
|
1774
|
-
}
|
|
1775
|
-
catch (cause) {
|
|
1776
|
-
throw new HostError(parsed.path === "register list"
|
|
1777
|
-
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
1778
|
-
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`, cause instanceof HostError ? cause.exitCode : 1, cause instanceof HostError ? cause.code : "REGISTRY_FAILED", "publication");
|
|
1779
|
-
}
|
|
1780
|
-
finally {
|
|
1781
|
-
await context.finishRead?.();
|
|
1782
2092
|
}
|
|
1783
2093
|
}
|
|
2094
|
+
finally {
|
|
2095
|
+
await registerOwner?.release();
|
|
2096
|
+
}
|
|
1784
2097
|
emit({
|
|
1785
2098
|
swarms: results.map((result, index) => ({
|
|
1786
2099
|
configUrl: targets[index],
|
|
@@ -1820,31 +2133,6 @@ async function performCli(argv, io, env) {
|
|
|
1820
2133
|
}
|
|
1821
2134
|
break;
|
|
1822
2135
|
}
|
|
1823
|
-
case "swarm list": {
|
|
1824
|
-
const result = { swarms: state.swarms(), ...selection() };
|
|
1825
|
-
emit({
|
|
1826
|
-
...result,
|
|
1827
|
-
swarms: result.swarms.map((entry) => ({
|
|
1828
|
-
configUrl: entry.cid,
|
|
1829
|
-
alias: entry.alias,
|
|
1830
|
-
})),
|
|
1831
|
-
}, [
|
|
1832
|
-
...alignedRows(result.swarms.map((entry) => [
|
|
1833
|
-
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
1834
|
-
entry.cid,
|
|
1835
|
-
])),
|
|
1836
|
-
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
1837
|
-
...(result.effectiveCurrent === null
|
|
1838
|
-
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
1839
|
-
: []),
|
|
1840
|
-
...(result.effectiveCurrent !== result.savedCurrent
|
|
1841
|
-
? [
|
|
1842
|
-
`Selected via --swarm: ${printable(String(result.swarms.find((entry) => entry.cid === result.effectiveCurrent)?.alias ?? result.effectiveCurrent ?? "(none)"))}; saved default: ${printable(String(result.swarms.find((entry) => entry.cid === result.savedCurrent)?.alias ?? result.savedCurrent ?? "(none)"))}.`,
|
|
1843
|
-
]
|
|
1844
|
-
: []),
|
|
1845
|
-
].join("\n"));
|
|
1846
|
-
break;
|
|
1847
|
-
}
|
|
1848
2136
|
case "swarm use": {
|
|
1849
2137
|
state.useSwarm(first);
|
|
1850
2138
|
const result = selection();
|
|
@@ -1906,6 +2194,9 @@ async function performCli(argv, io, env) {
|
|
|
1906
2194
|
case "swarm update":
|
|
1907
2195
|
case "search":
|
|
1908
2196
|
case "skills list":
|
|
2197
|
+
case "skills show":
|
|
2198
|
+
case "skills set":
|
|
2199
|
+
case "skills remove":
|
|
1909
2200
|
case "skills sync":
|
|
1910
2201
|
case "swarm create":
|
|
1911
2202
|
case "swarm request":
|
|
@@ -1917,15 +2208,361 @@ async function performCli(argv, io, env) {
|
|
|
1917
2208
|
case "swarm profile":
|
|
1918
2209
|
case "swarm members":
|
|
1919
2210
|
case "swarm status":
|
|
2211
|
+
case "swarm replicate":
|
|
2212
|
+
case "fs ls":
|
|
2213
|
+
case "fs stat":
|
|
2214
|
+
case "fs set":
|
|
2215
|
+
case "fs rm":
|
|
1920
2216
|
case "publish":
|
|
1921
2217
|
case "pin":
|
|
1922
2218
|
case "get": {
|
|
1923
2219
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1924
2220
|
const context = swarmContext();
|
|
1925
2221
|
readContext = context;
|
|
2222
|
+
if (parsed.path.startsWith("fs ")) {
|
|
2223
|
+
const { listSwarmFsPath, removeSwarmFsPath, setSwarmFsPath, statSwarmFsPath, } = await import("./swarm-fs.js");
|
|
2224
|
+
const swarmUrlSelected = requireSwarm();
|
|
2225
|
+
const explicitRefresh = parsed.options.refresh || parsed.options.force
|
|
2226
|
+
? true
|
|
2227
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
2228
|
+
? false
|
|
2229
|
+
: value("swarm.forceRefresh")
|
|
2230
|
+
? true
|
|
2231
|
+
: undefined;
|
|
2232
|
+
if (parsed.path === "fs ls") {
|
|
2233
|
+
const result = await listSwarmFsPath(context, swarmUrlSelected, first, {
|
|
2234
|
+
all: Boolean(parsed.options.all),
|
|
2235
|
+
recursive: Boolean(parsed.options.recursive),
|
|
2236
|
+
mode: "local-first",
|
|
2237
|
+
...(explicitRefresh !== undefined
|
|
2238
|
+
? { forceRefresh: explicitRefresh }
|
|
2239
|
+
: {}),
|
|
2240
|
+
});
|
|
2241
|
+
store = context.store;
|
|
2242
|
+
const text = result.entries.length
|
|
2243
|
+
? result.entries
|
|
2244
|
+
.map((entry) => `${result.recursive ? entry.path : entry.name}\t${entry.cid ?? "<dir>"}\t${entry.size !== null ? String(entry.size) : entry.kind}`)
|
|
2245
|
+
.join("\n")
|
|
2246
|
+
: "No entries.";
|
|
2247
|
+
emit(result, text);
|
|
2248
|
+
if (result.truncated || result.skippedSubtrees > 0) {
|
|
2249
|
+
io.err(`Listing incomplete: truncated=${String(result.truncated)}, skippedSubtrees=${String(result.skippedSubtrees)}.`);
|
|
2250
|
+
}
|
|
2251
|
+
break;
|
|
2252
|
+
}
|
|
2253
|
+
if (parsed.path === "fs stat") {
|
|
2254
|
+
const result = await statSwarmFsPath(context, swarmUrlSelected, first, {
|
|
2255
|
+
mode: "local-first",
|
|
2256
|
+
...(explicitRefresh !== undefined
|
|
2257
|
+
? { forceRefresh: explicitRefresh }
|
|
2258
|
+
: {}),
|
|
2259
|
+
});
|
|
2260
|
+
store = context.store;
|
|
2261
|
+
const lines = [
|
|
2262
|
+
`Path: ${result.path || "/"}`,
|
|
2263
|
+
`CID: ${result.cid ?? "(virtual)"}`,
|
|
2264
|
+
`Kind: ${result.kind}`,
|
|
2265
|
+
`Size: ${result.size !== null ? String(result.size) : "unavailable"}`,
|
|
2266
|
+
...(result.kind === "directory" && result.isBundle !== undefined
|
|
2267
|
+
? [`Bundle: ${result.isBundle ? "yes" : "no"}`]
|
|
2268
|
+
: []),
|
|
2269
|
+
...(result.kind === "directory" && result.entryCount !== undefined
|
|
2270
|
+
? [`Entries: ${result.entryCount}`]
|
|
2271
|
+
: []),
|
|
2272
|
+
`Swarm: ${result.swarm}`,
|
|
2273
|
+
`Snapshot: ${result.snapshotVersion === "legacy" ? "legacy (read-only virtual)" : "v7"}`,
|
|
2274
|
+
];
|
|
2275
|
+
emit(result, lines.join("\n"));
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
if (parsed.path === "fs set") {
|
|
2279
|
+
const result = await setSwarmFsPath(context, swarmUrlSelected, first, second, {
|
|
2280
|
+
...(typeof parsed.options.expect === "string"
|
|
2281
|
+
? { expect: parsed.options.expect }
|
|
2282
|
+
: {}),
|
|
2283
|
+
...(parsed.options.replace ? { replace: true } : {}),
|
|
2284
|
+
});
|
|
2285
|
+
store = context.store;
|
|
2286
|
+
emit(result, result.changed
|
|
2287
|
+
? `Set ${result.path} -> ${result.cid} (HEAD ${result.headCid})`
|
|
2288
|
+
: `Unchanged ${result.path} -> ${result.cid} (HEAD ${result.headCid})`);
|
|
2289
|
+
break;
|
|
2290
|
+
}
|
|
2291
|
+
const result = await removeSwarmFsPath(context, swarmUrlSelected, first, {
|
|
2292
|
+
...(typeof parsed.options.expect === "string"
|
|
2293
|
+
? { expect: parsed.options.expect }
|
|
2294
|
+
: {}),
|
|
2295
|
+
});
|
|
2296
|
+
store = context.store;
|
|
2297
|
+
emit(result, `Removed ${result.path} (was ${result.removedCid}, HEAD ${result.headCid})`);
|
|
2298
|
+
break;
|
|
2299
|
+
}
|
|
2300
|
+
if (parsed.path === "swarm replicate") {
|
|
2301
|
+
const { replicateSwarm } = await import("./swarm.js");
|
|
2302
|
+
context.diagnostic = (text) => {
|
|
2303
|
+
io.err(text);
|
|
2304
|
+
};
|
|
2305
|
+
const result = await replicateSwarm(context, requireSwarm(), undefined, {
|
|
2306
|
+
...(typeof parsed.options.pivot === "string"
|
|
2307
|
+
? { pivot: parsed.options.pivot }
|
|
2308
|
+
: {}),
|
|
2309
|
+
});
|
|
2310
|
+
store = context.store;
|
|
2311
|
+
emit(result, [
|
|
2312
|
+
`HEAD: ${result.headCid}`,
|
|
2313
|
+
...result.results.map((entry) => `${entry.peerId}: ${entry.status}${entry.error ? ` (${entry.error})` : ""}`),
|
|
2314
|
+
].join("\n"));
|
|
2315
|
+
break;
|
|
2316
|
+
}
|
|
1926
2317
|
if (parsed.path.startsWith("skills ")) {
|
|
2318
|
+
const explicitRefresh = parsed.options.refresh || parsed.options.force
|
|
2319
|
+
? true
|
|
2320
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
2321
|
+
? false
|
|
2322
|
+
: value("swarm.forceRefresh")
|
|
2323
|
+
? true
|
|
2324
|
+
: undefined;
|
|
2325
|
+
const refreshOption = explicitRefresh !== undefined
|
|
2326
|
+
? { forceRefresh: explicitRefresh }
|
|
2327
|
+
: {};
|
|
2328
|
+
if (parsed.path === "skills show") {
|
|
2329
|
+
const named = parseNameReference(first);
|
|
2330
|
+
let targetSwarm;
|
|
2331
|
+
let schemaCid;
|
|
2332
|
+
let resolvedFrom;
|
|
2333
|
+
let contentCid;
|
|
2334
|
+
let reference;
|
|
2335
|
+
let association;
|
|
2336
|
+
if (named) {
|
|
2337
|
+
targetSwarm = named.swarm
|
|
2338
|
+
? state.resolveSwarm(named.swarm)
|
|
2339
|
+
: requireSwarm();
|
|
2340
|
+
const resolved = await resolveReference(context, first, targetSwarm, (ref) => state.resolve(ref), false, "local-first");
|
|
2341
|
+
store = context.store;
|
|
2342
|
+
contentCid = resolved.cid;
|
|
2343
|
+
reference = first;
|
|
2344
|
+
const bundle = await openBundle(CID.parse(contentCid), {
|
|
2345
|
+
resolveCid: (key) => context.store.block.get(key.toString()),
|
|
2346
|
+
});
|
|
2347
|
+
schemaCid = bundle.schemaKey;
|
|
2348
|
+
resolvedFrom = "uri";
|
|
2349
|
+
association = await swarmTypeSkill(context, targetSwarm, schemaCid, {
|
|
2350
|
+
mode: "local-first",
|
|
2351
|
+
...refreshOption,
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
else {
|
|
2355
|
+
targetSwarm = requireSwarm();
|
|
2356
|
+
const localInput = await resolveLocalBundleInput(first);
|
|
2357
|
+
if (localInput) {
|
|
2358
|
+
const session = `skills-show:${randomUUID()}`;
|
|
2359
|
+
const owner = await Ownership.create(state, store, `skills-show:${randomUUID()}`, session);
|
|
2360
|
+
try {
|
|
2361
|
+
const root = await snapshotLocalBundle(localInput, owner, session, {
|
|
2362
|
+
diagnostic: (text) => {
|
|
2363
|
+
io.err(text);
|
|
2364
|
+
},
|
|
2365
|
+
});
|
|
2366
|
+
contentCid = await artifactValue(store, root);
|
|
2367
|
+
const bundle = await openBundle(CID.parse(contentCid), {
|
|
2368
|
+
resolveCid: (key) => store.block.get(key.toString()),
|
|
2369
|
+
});
|
|
2370
|
+
schemaCid = bundle.schemaKey;
|
|
2371
|
+
resolvedFrom = "local";
|
|
2372
|
+
association = await swarmTypeSkill(context, targetSwarm, schemaCid, {
|
|
2373
|
+
mode: "local-first",
|
|
2374
|
+
...refreshOption,
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
finally {
|
|
2378
|
+
await owner.release();
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
else {
|
|
2382
|
+
const resolved = state.resolve(schemaAlias(first));
|
|
2383
|
+
const parsedCid = CID.parse(resolved);
|
|
2384
|
+
const isSchemaCid = parsedCid.code === 0x71 && parsedCid.multihash.code === 0x12;
|
|
2385
|
+
schemaCid = resolved;
|
|
2386
|
+
resolvedFrom = "schema";
|
|
2387
|
+
if (isSchemaCid) {
|
|
2388
|
+
association = await swarmTypeSkill(context, targetSwarm, resolved, {
|
|
2389
|
+
mode: "local-first",
|
|
2390
|
+
...refreshOption,
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
else {
|
|
2394
|
+
const refResolved = await resolveReference(context, resolved, targetSwarm, (ref) => state.resolve(ref), false, "local-first");
|
|
2395
|
+
store = context.store;
|
|
2396
|
+
const bundle = await openBundle(CID.parse(refResolved.cid), {
|
|
2397
|
+
resolveCid: (key) => context.store.block.get(key.toString()),
|
|
2398
|
+
});
|
|
2399
|
+
schemaCid = bundle.schemaKey;
|
|
2400
|
+
contentCid = refResolved.cid;
|
|
2401
|
+
resolvedFrom = "content";
|
|
2402
|
+
association = await swarmTypeSkill(context, targetSwarm, schemaCid, {
|
|
2403
|
+
mode: "local-first",
|
|
2404
|
+
...refreshOption,
|
|
2405
|
+
});
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
store = context.store;
|
|
2410
|
+
if (!association)
|
|
2411
|
+
throw new HostError(`No Skill associated with Schema ${schemaCid} in Swarm ${targetSwarm}. Associate one with: ipab skills set SKILL --type ${schemaCid}`, 1, "SKILL_NOT_FOUND", "state");
|
|
2412
|
+
const payload = {
|
|
2413
|
+
swarm: targetSwarm,
|
|
2414
|
+
schemaCid,
|
|
2415
|
+
resolvedFrom,
|
|
2416
|
+
...(contentCid ? { contentCid } : {}),
|
|
2417
|
+
...(reference ? { reference } : {}),
|
|
2418
|
+
name: association.name,
|
|
2419
|
+
cid: association.cid,
|
|
2420
|
+
identity: association.identity,
|
|
2421
|
+
description: association.description,
|
|
2422
|
+
};
|
|
2423
|
+
const lines = [
|
|
2424
|
+
`Swarm: ${targetSwarm}`,
|
|
2425
|
+
`Schema: ${schemaCid}`,
|
|
2426
|
+
...(contentCid ? [`Content CID: ${contentCid}`] : []),
|
|
2427
|
+
`Skill: ${association.identity}`,
|
|
2428
|
+
`Skill CID: ${association.cid}`,
|
|
2429
|
+
`Path: ${association.name}`,
|
|
2430
|
+
`Description: ${association.description}`,
|
|
2431
|
+
];
|
|
2432
|
+
emit(payload, lines.join("\n"));
|
|
2433
|
+
break;
|
|
2434
|
+
}
|
|
2435
|
+
if (parsed.path === "skills set") {
|
|
2436
|
+
const targetSwarm = requireSwarm();
|
|
2437
|
+
const types = (parsed.types ?? []).map((schema) => state.resolve(schemaAlias(schema), true));
|
|
2438
|
+
const localSkill = !parseNameReference(first)
|
|
2439
|
+
? await resolveLocalBundleInput(first)
|
|
2440
|
+
: undefined;
|
|
2441
|
+
let skillOwner;
|
|
2442
|
+
try {
|
|
2443
|
+
let skillCid;
|
|
2444
|
+
if (localSkill) {
|
|
2445
|
+
const session = `skills-set:${randomUUID()}`;
|
|
2446
|
+
skillOwner = await Ownership.create(state, store, `skills-set:${randomUUID()}`, session);
|
|
2447
|
+
skillCid = await snapshotLocalBundle(localSkill, skillOwner, session, {
|
|
2448
|
+
diagnostic: (text) => {
|
|
2449
|
+
io.err(text);
|
|
2450
|
+
},
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
else if (parseNameReference(first)) {
|
|
2454
|
+
skillCid = (await resolveReference(context, first, targetSwarm, (ref) => state.resolve(ref), false)).cid;
|
|
2455
|
+
store = context.store;
|
|
2456
|
+
}
|
|
2457
|
+
else {
|
|
2458
|
+
skillCid = state.resolve(first);
|
|
2459
|
+
}
|
|
2460
|
+
const result = await setSwarmSkill(context, targetSwarm, {
|
|
2461
|
+
skillCid,
|
|
2462
|
+
global: Boolean(parsed.options.global),
|
|
2463
|
+
types,
|
|
2464
|
+
replace: Boolean(parsed.options.replace),
|
|
2465
|
+
});
|
|
2466
|
+
store = context.store;
|
|
2467
|
+
const text = result.changed
|
|
2468
|
+
? [
|
|
2469
|
+
`Skill: ${result.identity} (${result.cid})`,
|
|
2470
|
+
`HEAD: ${result.headCid}`,
|
|
2471
|
+
...result.targets.map((target) => {
|
|
2472
|
+
const status = !target.changed
|
|
2473
|
+
? "unchanged"
|
|
2474
|
+
: target.previousCid
|
|
2475
|
+
? "updated"
|
|
2476
|
+
: "created";
|
|
2477
|
+
return target.scope === "global"
|
|
2478
|
+
? ` global -> ${target.name} (${status})`
|
|
2479
|
+
: ` type ${target.schemaCid} -> ${target.name} (${status})`;
|
|
2480
|
+
}),
|
|
2481
|
+
].join("\n")
|
|
2482
|
+
: `Unchanged: ${result.identity} (${result.cid}) (HEAD ${result.headCid})`;
|
|
2483
|
+
emit(result, text);
|
|
2484
|
+
}
|
|
2485
|
+
finally {
|
|
2486
|
+
await skillOwner?.release();
|
|
2487
|
+
}
|
|
2488
|
+
break;
|
|
2489
|
+
}
|
|
2490
|
+
if (parsed.path === "skills remove") {
|
|
2491
|
+
const targetSwarm = requireSwarm();
|
|
2492
|
+
const types = (parsed.types ?? []).map((schema) => state.resolve(schemaAlias(schema), true));
|
|
2493
|
+
const globalName = typeof parsed.options.global === "string"
|
|
2494
|
+
? parsed.options.global
|
|
2495
|
+
: undefined;
|
|
2496
|
+
const result = await removeSwarmSkill(context, targetSwarm, {
|
|
2497
|
+
...(globalName !== undefined ? { globalName } : {}),
|
|
2498
|
+
types,
|
|
2499
|
+
});
|
|
2500
|
+
store = context.store;
|
|
2501
|
+
const lines = [
|
|
2502
|
+
`Removed ${result.removed.length} Skill association(s) (HEAD ${result.headCid}):`,
|
|
2503
|
+
...result.removed.map((entry) => entry.scope === "global"
|
|
2504
|
+
? ` global ${entry.name} (was ${entry.removedCid})`
|
|
2505
|
+
: ` type ${entry.schemaCid} ${entry.name} (was ${entry.removedCid})`),
|
|
2506
|
+
];
|
|
2507
|
+
emit(result, lines.join("\n"));
|
|
2508
|
+
break;
|
|
2509
|
+
}
|
|
2510
|
+
if (parsed.path === "skills list") {
|
|
2511
|
+
const targetSwarm = requireSwarm();
|
|
2512
|
+
const managed = await manageSkills(context, targetSwarm, {
|
|
2513
|
+
sync: false,
|
|
2514
|
+
names: parsed.positional,
|
|
2515
|
+
agents: parsed.agents ?? [],
|
|
2516
|
+
overrideExisting: false,
|
|
2517
|
+
dryRun: false,
|
|
2518
|
+
yes: false,
|
|
2519
|
+
tty: io.tty,
|
|
2520
|
+
confirm: (text) => io.confirm(text),
|
|
2521
|
+
preview: (text) => {
|
|
2522
|
+
io.err(text);
|
|
2523
|
+
},
|
|
2524
|
+
});
|
|
2525
|
+
const typeSkills = await swarmTypeSkills(context, targetSwarm, {
|
|
2526
|
+
mode: "local-first",
|
|
2527
|
+
...refreshOption,
|
|
2528
|
+
});
|
|
2529
|
+
const result = {
|
|
2530
|
+
swarm: managed.swarm,
|
|
2531
|
+
installer: managed.installer,
|
|
2532
|
+
agents: managed.agents,
|
|
2533
|
+
dryRun: managed.dryRun,
|
|
2534
|
+
items: managed.items,
|
|
2535
|
+
typeSkills,
|
|
2536
|
+
orphaned: managed.orphaned,
|
|
2537
|
+
results: managed.results,
|
|
2538
|
+
ok: managed.ok,
|
|
2539
|
+
};
|
|
2540
|
+
store = context.store;
|
|
2541
|
+
const globalLines = [
|
|
2542
|
+
table(["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"], result.items.map((skill) => [
|
|
2543
|
+
skill.name,
|
|
2544
|
+
skill.cid,
|
|
2545
|
+
skill.identity,
|
|
2546
|
+
skill.status,
|
|
2547
|
+
]), "No Global Skills."),
|
|
2548
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
2549
|
+
...result.orphaned.map((skill) => `Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`),
|
|
2550
|
+
];
|
|
2551
|
+
const typeLines = [
|
|
2552
|
+
"Type Skills:",
|
|
2553
|
+
table(["TYPE CID", "SKILL NAME", "SKILL CID"], result.typeSkills.map((entry) => [
|
|
2554
|
+
entry.schemaCid,
|
|
2555
|
+
entry.identity,
|
|
2556
|
+
entry.cid,
|
|
2557
|
+
]), "No Type Skills."),
|
|
2558
|
+
];
|
|
2559
|
+
emit(result, [...globalLines, "", ...typeLines].join("\n"));
|
|
2560
|
+
if (!result.ok)
|
|
2561
|
+
return 1;
|
|
2562
|
+
break;
|
|
2563
|
+
}
|
|
1927
2564
|
const result = await manageSkills(context, requireSwarm(), {
|
|
1928
|
-
sync:
|
|
2565
|
+
sync: true,
|
|
1929
2566
|
names: parsed.positional,
|
|
1930
2567
|
agents: parsed.agents ?? [],
|
|
1931
2568
|
overrideExisting: Boolean(parsed.options["override-existing"]),
|
|
@@ -1962,6 +2599,14 @@ async function performCli(argv, io, env) {
|
|
|
1962
2599
|
}
|
|
1963
2600
|
if (parsed.path === "swarm members") {
|
|
1964
2601
|
const result = await swarmMembers(context, requireSwarm(), Boolean(parsed.options.refresh || parsed.options.force));
|
|
2602
|
+
if (result.mode === "local") {
|
|
2603
|
+
emit(result, [
|
|
2604
|
+
"Swarm: local (Built-in single-machine Swarm)",
|
|
2605
|
+
"Mode: local",
|
|
2606
|
+
"Members: local user only (single-machine; no remote collaborators or HOME identity required)",
|
|
2607
|
+
].join("\n"));
|
|
2608
|
+
break;
|
|
2609
|
+
}
|
|
1965
2610
|
emit(result, [
|
|
1966
2611
|
`Directory: ${result.cache.source} (${result.cache.freshness}), observed ${result.cache.updatedAt}`,
|
|
1967
2612
|
`Daemon: ${result.local.status}, observed ${result.local.updatedAt ?? "unknown"}; control-plane verified ${result.local.verifiedAt ?? "unknown"}`,
|
|
@@ -2033,7 +2678,7 @@ async function performCli(argv, io, env) {
|
|
|
2033
2678
|
break;
|
|
2034
2679
|
}
|
|
2035
2680
|
if (parsed.path === "search") {
|
|
2036
|
-
const registrations = state.
|
|
2681
|
+
const registrations = state.allSwarms();
|
|
2037
2682
|
const scope = parsed.options.all
|
|
2038
2683
|
? registrations
|
|
2039
2684
|
: [
|
|
@@ -2066,9 +2711,38 @@ async function performCli(argv, io, env) {
|
|
|
2066
2711
|
}
|
|
2067
2712
|
if (parsed.path === "swarm status") {
|
|
2068
2713
|
const cid = requireSwarm();
|
|
2069
|
-
const
|
|
2070
|
-
const fingerprint = await keyId(config.owner);
|
|
2714
|
+
const status = await inspectSwarmStatus(context, cid, Boolean(parsed.options.refresh || parsed.options.force));
|
|
2071
2715
|
store = context.store;
|
|
2716
|
+
if (status.mode === "local") {
|
|
2717
|
+
emit({
|
|
2718
|
+
mode: "local",
|
|
2719
|
+
configUrl: cid,
|
|
2720
|
+
root: status.head.root,
|
|
2721
|
+
valueCid: status.head.cid,
|
|
2722
|
+
properties: {
|
|
2723
|
+
name: status.config.name,
|
|
2724
|
+
description: status.config.description,
|
|
2725
|
+
},
|
|
2726
|
+
local: status.local,
|
|
2727
|
+
}, [
|
|
2728
|
+
"Swarm",
|
|
2729
|
+
" Mode: local (built-in single-machine Swarm)",
|
|
2730
|
+
` Name: ${printable(status.config.name)}`,
|
|
2731
|
+
` Description: ${printable(status.config.description)}`,
|
|
2732
|
+
" Config URL:",
|
|
2733
|
+
` ${cid}`,
|
|
2734
|
+
"",
|
|
2735
|
+
"Content",
|
|
2736
|
+
" HEAD (publication root):",
|
|
2737
|
+
` ${status.head.root}`,
|
|
2738
|
+
" Content CID (HEAD value):",
|
|
2739
|
+
` ${status.head.cid}`,
|
|
2740
|
+
` Names: ${status.local.names} (Templates: ${status.local.templates}, Skills: ${status.local.skills} [global: ${status.local.globalSkills}, types: ${status.local.typeSkills}], Registrations: ${status.local.registrations})`,
|
|
2741
|
+
].join("\n"));
|
|
2742
|
+
break;
|
|
2743
|
+
}
|
|
2744
|
+
const { head, config, networking, cache, lastWriter, state: contentState, } = status;
|
|
2745
|
+
const fingerprint = await keyId(config.owner);
|
|
2072
2746
|
emit({
|
|
2073
2747
|
configUrl: cid,
|
|
2074
2748
|
owner: config.owner,
|
|
@@ -2137,6 +2811,7 @@ async function performCli(argv, io, env) {
|
|
|
2137
2811
|
"FAILURES",
|
|
2138
2812
|
"RETRY AT",
|
|
2139
2813
|
"CONNECTION",
|
|
2814
|
+
"READINESS",
|
|
2140
2815
|
], networking.pivots.map((pivot) => [
|
|
2141
2816
|
pivot.peerId,
|
|
2142
2817
|
pivot.localStatus ?? "unknown",
|
|
@@ -2145,6 +2820,7 @@ async function performCli(argv, io, env) {
|
|
|
2145
2820
|
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2146
2821
|
pivot.retryAt ?? "-",
|
|
2147
2822
|
pivot.connection.status,
|
|
2823
|
+
pivot.readiness.status,
|
|
2148
2824
|
]), "No declared Pivots."),
|
|
2149
2825
|
...networking.pivots.flatMap((pivot) => pivot.probe.error
|
|
2150
2826
|
? [
|
|
@@ -2250,6 +2926,8 @@ async function performCli(argv, io, env) {
|
|
|
2250
2926
|
}
|
|
2251
2927
|
else if (parsed.path === "swarm approve") {
|
|
2252
2928
|
const selected = requireSwarm();
|
|
2929
|
+
if (isLocalSwarm(selected))
|
|
2930
|
+
throw new HostError(`The built-in "${LOCAL_SWARM_ALIAS}" Swarm is a single-machine Swarm and does not support swarm approve.`);
|
|
2253
2931
|
if (first === "-" && !parsed.options.yes)
|
|
2254
2932
|
syntax("Reading a Request from stdin requires explicit --yes; no interactive confirmation is available.");
|
|
2255
2933
|
const request = first === "-"
|
|
@@ -2280,8 +2958,10 @@ async function performCli(argv, io, env) {
|
|
|
2280
2958
|
});
|
|
2281
2959
|
}
|
|
2282
2960
|
store = context.store;
|
|
2283
|
-
if (parsed.path === "swarm create")
|
|
2961
|
+
if (parsed.path === "swarm create") {
|
|
2284
2962
|
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`);
|
|
2963
|
+
io.err("Pivot replication is not yet confirmed. Keep this member online until a Pivot is ready; daemon will replicate automatically. Manual retry: ipab swarm replicate. Inspect readiness with ipab swarm status.");
|
|
2964
|
+
}
|
|
2285
2965
|
if (contentCid)
|
|
2286
2966
|
io.err(`Locally protected payload: ${contentCid}. Use ipab unpin ${contentCid} to release this CID pin only; Name subscriptions and publication/history owners remain. --snapshot links payloads directly into retained publication history, so unpin cannot release that protection.`);
|
|
2287
2967
|
emit(parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
@@ -2394,7 +3074,9 @@ async function performCli(argv, io, env) {
|
|
|
2394
3074
|
? "Assembling and validating Bundle (no compilation)..."
|
|
2395
3075
|
: "Validating and building bundle...");
|
|
2396
3076
|
if (parsed.path === "bundle import")
|
|
2397
|
-
io.err("
|
|
3077
|
+
io.err(first.toLowerCase().endsWith(".car")
|
|
3078
|
+
? "Validating and importing CAR into Store..."
|
|
3079
|
+
: "Validating and importing Bundle into Store...");
|
|
2398
3080
|
const result = parsed.path === "templates render"
|
|
2399
3081
|
? await initApp(second, parsed.positional[2], {
|
|
2400
3082
|
...request,
|
|
@@ -2447,7 +3129,7 @@ async function performCli(argv, io, env) {
|
|
|
2447
3129
|
if ("output" in result)
|
|
2448
3130
|
emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
|
|
2449
3131
|
else if (result.kind === "bundle-import")
|
|
2450
|
-
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\
|
|
3132
|
+
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\n${result.source.toLowerCase().endsWith(".car") ? "CAR" : "Source"}: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`);
|
|
2451
3133
|
else if (result.kind === "project-init") {
|
|
2452
3134
|
emit(result, `Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`);
|
|
2453
3135
|
if (result.files.includes("package.json") &&
|
|
@@ -2629,7 +3311,10 @@ async function performCli(argv, io, env) {
|
|
|
2629
3311
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2630
3312
|
const context = swarmContext();
|
|
2631
3313
|
readContext = context;
|
|
2632
|
-
const
|
|
3314
|
+
const localInput = await resolveLocalBundleInput(first);
|
|
3315
|
+
const target = localInput
|
|
3316
|
+
? undefined
|
|
3317
|
+
: (await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw), "local-first")).cid;
|
|
2633
3318
|
store = context.store;
|
|
2634
3319
|
const resolveBundleReference = async (reference, signal, preferredSwarm) => {
|
|
2635
3320
|
signal.throwIfAborted();
|
|
@@ -2676,9 +3361,16 @@ async function performCli(argv, io, env) {
|
|
|
2676
3361
|
let appCid;
|
|
2677
3362
|
let appArgv;
|
|
2678
3363
|
if (parsed.path === "open") {
|
|
2679
|
-
const
|
|
2680
|
-
const owner = await Ownership.create(state, store, `open:${randomUUID()}`,
|
|
3364
|
+
const session = localInput ? `open:${randomUUID()}` : null;
|
|
3365
|
+
const owner = await Ownership.create(state, store, `open:${randomUUID()}`, session);
|
|
2681
3366
|
try {
|
|
3367
|
+
const root = localInput
|
|
3368
|
+
? await snapshotLocalBundle(localInput, owner, session, {
|
|
3369
|
+
diagnostic: (text) => {
|
|
3370
|
+
io.err(text);
|
|
3371
|
+
},
|
|
3372
|
+
})
|
|
3373
|
+
: target;
|
|
2682
3374
|
const content = await validatedBundle(root, store, owner);
|
|
2683
3375
|
const schema = content.schemaKey;
|
|
2684
3376
|
let association;
|
|
@@ -2705,6 +3397,7 @@ async function performCli(argv, io, env) {
|
|
|
2705
3397
|
if (association.argv.length !== 1 || association.argv[0] !== "%")
|
|
2706
3398
|
throw new HostError("Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.");
|
|
2707
3399
|
appArgv = [root];
|
|
3400
|
+
io.err("Starting App...");
|
|
2708
3401
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
2709
3402
|
const result = await execute(state, store, { origin: "open", appCid, argv: appArgv }, {
|
|
2710
3403
|
inputSchema: schema,
|
|
@@ -2723,6 +3416,32 @@ async function performCli(argv, io, env) {
|
|
|
2723
3416
|
await owner.release();
|
|
2724
3417
|
}
|
|
2725
3418
|
}
|
|
3419
|
+
else if (localInput) {
|
|
3420
|
+
const session = `exec:${randomUUID()}`;
|
|
3421
|
+
const owner = await Ownership.create(state, store, `exec:${randomUUID()}`, session);
|
|
3422
|
+
try {
|
|
3423
|
+
appCid = await snapshotLocalBundle(localInput, owner, session, {
|
|
3424
|
+
diagnostic: (text) => {
|
|
3425
|
+
io.err(text);
|
|
3426
|
+
},
|
|
3427
|
+
});
|
|
3428
|
+
appArgv = parsed.positional.slice(1);
|
|
3429
|
+
io.err("Starting App...");
|
|
3430
|
+
appExitCode = (await execute(state, store, { origin: "exec", appCid, argv: appArgv }, {
|
|
3431
|
+
resolveBundleReference,
|
|
3432
|
+
history: Boolean(value("history.enabled")),
|
|
3433
|
+
retain: value("output.retention") === "history",
|
|
3434
|
+
log: Boolean(parsed.options.log),
|
|
3435
|
+
diagnostic: (text) => {
|
|
3436
|
+
io.err(text);
|
|
3437
|
+
},
|
|
3438
|
+
})).exitCode;
|
|
3439
|
+
return appExitCode;
|
|
3440
|
+
}
|
|
3441
|
+
finally {
|
|
3442
|
+
await owner.release();
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
2726
3445
|
else {
|
|
2727
3446
|
appCid = target;
|
|
2728
3447
|
appArgv = parsed.positional.slice(1);
|
|
@@ -2744,6 +3463,7 @@ async function performCli(argv, io, env) {
|
|
|
2744
3463
|
return 0;
|
|
2745
3464
|
}
|
|
2746
3465
|
catch (error) {
|
|
3466
|
+
const { message } = await import("./errors.js");
|
|
2747
3467
|
io.err(`Error: ${message(error)}`);
|
|
2748
3468
|
return error instanceof HostError ? error.exitCode : 1;
|
|
2749
3469
|
}
|
|
@@ -2766,6 +3486,7 @@ export async function runCli(argv, io = processIO, env = process.env) {
|
|
|
2766
3486
|
return await performCli(argv, io, env);
|
|
2767
3487
|
}
|
|
2768
3488
|
catch (error) {
|
|
3489
|
+
const { message } = await import("./errors.js");
|
|
2769
3490
|
io.err(`Error: ${message(error)}`);
|
|
2770
3491
|
return error instanceof HostError ? error.exitCode : 1;
|
|
2771
3492
|
}
|