@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.10
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 +230 -7
- package/dist/app-authoring.d.ts +16 -2
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +151 -66
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -63
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -44
- package/dist/app-definition.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/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +15 -45
- package/dist/app-templates.js.map +1 -1
- package/dist/assembly.d.ts +7 -0
- package/dist/assembly.d.ts.map +1 -0
- package/dist/assembly.js +130 -0
- package/dist/assembly.js.map +1 -0
- package/dist/authoring.d.ts +8 -21
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +35 -54
- 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/builtins.d.ts.map +1 -1
- package/dist/builtins.js +5 -32
- package/dist/builtins.js.map +1 -1
- 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 +8 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2009 -308
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +3 -0
- package/dist/config-secret.d.ts.map +1 -0
- package/dist/config-secret.js +12 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +9 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +164 -23
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +32 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +222 -0
- package/dist/content-provider.js.map +1 -0
- package/dist/context-types.d.ts +12 -0
- package/dist/context-types.d.ts.map +1 -0
- package/dist/context-types.js +2 -0
- package/dist/context-types.js.map +1 -0
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +56 -2
- package/dist/context.js.map +1 -1
- package/dist/daemon-ui.d.ts +93 -0
- package/dist/daemon-ui.d.ts.map +1 -0
- package/dist/daemon-ui.js +713 -0
- package/dist/daemon-ui.js.map +1 -0
- package/dist/daemon.d.ts +21 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +317 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +32 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +684 -0
- package/dist/doctor.js.map +1 -0
- 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/get.d.ts +3 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +80 -0
- package/dist/get.js.map +1 -0
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +6 -14
- package/dist/history.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/identity.d.ts +16 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/ipc.d.ts +5 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +125 -4
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +26 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +724 -0
- package/dist/kubo-install.js.map +1 -0
- package/dist/kubo-peering.d.ts +11 -0
- package/dist/kubo-peering.d.ts.map +1 -0
- package/dist/kubo-peering.js +93 -0
- package/dist/kubo-peering.js.map +1 -0
- package/dist/kubo-peers.d.ts +12 -0
- package/dist/kubo-peers.d.ts.map +1 -0
- package/dist/kubo-peers.js +119 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +22 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +176 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +113 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +85 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +755 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +18 -20
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +146 -126
- package/dist/pins.js.map +1 -1
- package/dist/pivot-rpc.d.ts +62 -0
- package/dist/pivot-rpc.d.ts.map +1 -0
- package/dist/pivot-rpc.js +407 -0
- package/dist/pivot-rpc.js.map +1 -0
- package/dist/pivot-service.d.ts +16 -0
- package/dist/pivot-service.d.ts.map +1 -0
- package/dist/pivot-service.js +50 -0
- package/dist/pivot-service.js.map +1 -0
- package/dist/publish-source.d.ts +3 -0
- package/dist/publish-source.d.ts.map +1 -0
- package/dist/publish-source.js +85 -0
- package/dist/publish-source.js.map +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +9 -4
- package/dist/runtime.js.map +1 -1
- package/dist/search-index.d.ts +64 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +409 -0
- package/dist/search-index.js.map +1 -0
- package/dist/search-service.d.ts +23 -0
- package/dist/search-service.d.ts.map +1 -0
- package/dist/search-service.js +116 -0
- package/dist/search-service.js.map +1 -0
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +9 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +24 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +104 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +894 -0
- package/dist/skills.js.map +1 -0
- package/dist/source-bundle.d.ts +3 -9
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +17 -13
- package/dist/source-bundle.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 +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +170 -24
- package/dist/space.js.map +1 -1
- package/dist/state-storage-windows.d.ts +2 -0
- package/dist/state-storage-windows.d.ts.map +1 -0
- package/dist/state-storage-windows.js +114 -0
- package/dist/state-storage-windows.js.map +1 -0
- package/dist/state-storage.d.ts +5 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +333 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +128 -16
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +506 -94
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +57 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +299 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +6 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +116 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm-meta.d.ts +15 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +68 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +271 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +469 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +4708 -0
- package/dist/swarm.js.map +1 -0
- package/dist/template-definition.d.ts +45 -67
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +35 -49
- package/dist/template-definition.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +4 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +11 -4
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/dist/unixfs-tree.d.ts +67 -0
- package/dist/unixfs-tree.d.ts.map +1 -0
- package/dist/unixfs-tree.js +329 -0
- package/dist/unixfs-tree.js.map +1 -0
- package/package.json +18 -11
- package/src/app-authoring.ts +254 -88
- package/src/app-definition.ts +33 -45
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +28 -71
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +63 -72
- package/src/builtins.ts +7 -38
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +2500 -376
- package/src/config-secret.ts +14 -0
- package/src/config.ts +215 -26
- package/src/content-provider.ts +299 -0
- package/src/context-types.ts +11 -0
- package/src/context.ts +100 -2
- package/src/daemon-ui.ts +812 -0
- package/src/daemon.ts +386 -0
- package/src/doctor.ts +1082 -0
- package/src/errors.ts +1 -25
- package/src/get.ts +90 -0
- package/src/history.ts +5 -15
- package/src/host-error.ts +26 -0
- package/src/identity.ts +175 -0
- package/src/ipc.ts +161 -4
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +144 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo-topology.ts +148 -0
- package/src/kubo.ts +1088 -0
- package/src/pins.ts +190 -142
- package/src/pivot-rpc.ts +601 -0
- package/src/pivot-service.ts +87 -0
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +16 -3
- package/src/search-index.ts +560 -0
- package/src/search-service.ts +152 -0
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +29 -0
- package/src/skills.ts +1236 -0
- package/src/source-bundle.ts +26 -14
- package/src/space-path.ts +30 -0
- package/src/space.ts +230 -42
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +378 -0
- package/src/state.ts +782 -116
- package/src/swarm-envelope.ts +461 -0
- package/src/swarm-files.ts +126 -0
- package/src/swarm-meta.ts +98 -0
- package/src/swarm-observations.ts +393 -0
- package/src/swarm.ts +7051 -0
- package/src/template-definition.ts +35 -49
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +19 -5
- package/src/templates.ts +77 -0
- package/src/unixfs-tree.ts +401 -0
package/src/cli.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { IpfsStore } from "@ipab/ipfs-store";
|
|
2
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
3
|
+
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
|
+
import { ContentBundleError } from "@ipab/bundle";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
5
|
-
import
|
|
6
|
+
import { CID } from "multiformats/cid";
|
|
6
7
|
import stringWidth from "string-width";
|
|
7
8
|
import {
|
|
8
9
|
configKey,
|
|
@@ -11,6 +12,8 @@ import {
|
|
|
11
12
|
publicUrl,
|
|
12
13
|
stateLocation,
|
|
13
14
|
storeConfiguration,
|
|
15
|
+
swarmUrl,
|
|
16
|
+
visibleConfig,
|
|
14
17
|
type GlobalOptions,
|
|
15
18
|
} from "./config.js";
|
|
16
19
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
@@ -24,45 +27,135 @@ import {
|
|
|
24
27
|
} from "./history.js";
|
|
25
28
|
import { execute } from "./runtime.js";
|
|
26
29
|
import { validatedBundle } from "./space.js";
|
|
27
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
createAssociation,
|
|
32
|
+
exactCid,
|
|
33
|
+
swarmAlias,
|
|
34
|
+
State,
|
|
35
|
+
type Association,
|
|
36
|
+
type RunRecord,
|
|
37
|
+
} from "./state.js";
|
|
28
38
|
import {
|
|
29
39
|
buildBundle,
|
|
30
|
-
initBundle,
|
|
31
40
|
inspectBundle,
|
|
32
41
|
importBundle,
|
|
42
|
+
nodeError,
|
|
33
43
|
} from "./authoring.js";
|
|
34
|
-
import {
|
|
44
|
+
import { initApp } from "./app-authoring.js";
|
|
45
|
+
import { assembleBundle } from "./assembly.js";
|
|
46
|
+
import { getBundle } from "./get.js";
|
|
47
|
+
import { doctorDevice, doctorText } from "./doctor.js";
|
|
48
|
+
import {
|
|
49
|
+
daemonEndpoint,
|
|
50
|
+
ensureDaemon,
|
|
51
|
+
openLoopbackUrl,
|
|
52
|
+
serveDaemon,
|
|
53
|
+
} from "./daemon.js";
|
|
54
|
+
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
55
|
+
import {
|
|
56
|
+
createSwarm,
|
|
57
|
+
swarmDaemon,
|
|
58
|
+
requestMembership,
|
|
59
|
+
approveMembership,
|
|
60
|
+
grantPivotAuthority,
|
|
61
|
+
exportRequest,
|
|
62
|
+
removeMember,
|
|
63
|
+
resumeRemoval,
|
|
64
|
+
updateProfile,
|
|
65
|
+
accountProfile,
|
|
66
|
+
updateAccountProfile,
|
|
67
|
+
swarmMembers,
|
|
68
|
+
inspectSwarmStatus,
|
|
69
|
+
verifiedRequest,
|
|
70
|
+
verifiedRequestStream,
|
|
71
|
+
membershipRequestSummary,
|
|
72
|
+
updateSwarm,
|
|
73
|
+
searchNames,
|
|
74
|
+
formatNameReference,
|
|
75
|
+
resolveReference,
|
|
76
|
+
parseNameReference,
|
|
77
|
+
formalName,
|
|
78
|
+
publish,
|
|
79
|
+
pinNameSubscription,
|
|
80
|
+
pinReference,
|
|
81
|
+
swarmRegistrations,
|
|
82
|
+
swarmAssociation,
|
|
83
|
+
setSwarmAssociation,
|
|
84
|
+
removeSwarmAssociation,
|
|
85
|
+
resolveTemplateSelector,
|
|
86
|
+
templateName,
|
|
87
|
+
swarmTemplates,
|
|
88
|
+
setSwarmTemplate,
|
|
89
|
+
removeSwarmTemplate,
|
|
90
|
+
type SwarmContext,
|
|
91
|
+
} from "./swarm.js";
|
|
35
92
|
import { schemaAlias } from "./app-definition.js";
|
|
36
|
-
import {
|
|
93
|
+
import { unpin, pinDetails } from "./pins.js";
|
|
94
|
+
import { publicationSource } from "./publish-source.js";
|
|
95
|
+
import {
|
|
96
|
+
templateRenderExample,
|
|
97
|
+
templateOutputTree,
|
|
98
|
+
templateParameterRows,
|
|
99
|
+
} from "./template-presentation.js";
|
|
37
100
|
import { logFiles } from "./logs.js";
|
|
38
101
|
import { builtinContent } from "./builtins.js";
|
|
102
|
+
import { readSecretStream } from "./config-secret.js";
|
|
103
|
+
import { manageSkills, syncDaemonSwarm } from "./skills.js";
|
|
39
104
|
|
|
40
105
|
export interface IO {
|
|
41
106
|
out(text: string): void;
|
|
42
|
-
err(text: string): void;
|
|
107
|
+
err(text: string, progress?: boolean): void;
|
|
43
108
|
tty: boolean;
|
|
44
109
|
columns?(): number | undefined;
|
|
45
|
-
confirm(text: string): Promise<boolean>;
|
|
110
|
+
confirm(text: string, signal?: AbortSignal): Promise<boolean>;
|
|
111
|
+
readSecret?(): Promise<string>;
|
|
112
|
+
requestInput?(): AsyncIterable<string | Uint8Array>;
|
|
46
113
|
}
|
|
114
|
+
let progressLine = false;
|
|
47
115
|
export const processIO: IO = {
|
|
48
116
|
out(text) {
|
|
49
117
|
process.stdout.write(`${text}\n`);
|
|
50
118
|
},
|
|
51
|
-
err(text) {
|
|
52
|
-
process.stderr.
|
|
119
|
+
err(text, progress = false) {
|
|
120
|
+
if (progress && process.stderr.isTTY) {
|
|
121
|
+
const width =
|
|
122
|
+
(process.stderr.columns > 1 ? process.stderr.columns : 80) - 1;
|
|
123
|
+
process.stderr.write(`\r\x1b[2K${text.slice(0, width)}`);
|
|
124
|
+
progressLine = true;
|
|
125
|
+
} else {
|
|
126
|
+
process.stderr.write(`${progressLine ? "\n" : ""}${text}\n`);
|
|
127
|
+
progressLine = false;
|
|
128
|
+
}
|
|
53
129
|
},
|
|
54
130
|
tty: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
55
131
|
columns() {
|
|
56
132
|
return process.stdout.columns;
|
|
57
133
|
},
|
|
58
|
-
|
|
134
|
+
requestInput() {
|
|
135
|
+
if (process.stdin.isTTY)
|
|
136
|
+
syntax(
|
|
137
|
+
"Pipe Request JSON into swarm approve - --yes, or pass a Request file.",
|
|
138
|
+
);
|
|
139
|
+
return process.stdin;
|
|
140
|
+
},
|
|
141
|
+
async readSecret() {
|
|
142
|
+
if (process.stdin.isTTY)
|
|
143
|
+
syntax(
|
|
144
|
+
"Pipe the API key through stdin; interactive echo is not permitted.",
|
|
145
|
+
);
|
|
146
|
+
process.stdin.setEncoding("utf8");
|
|
147
|
+
return readSecretStream(process.stdin as AsyncIterable<string>);
|
|
148
|
+
},
|
|
149
|
+
async confirm(text, signal) {
|
|
59
150
|
const reader = createInterface({
|
|
60
151
|
input: process.stdin,
|
|
61
152
|
output: process.stderr,
|
|
62
153
|
});
|
|
63
154
|
try {
|
|
64
155
|
return /^(y|yes)$/i.test(
|
|
65
|
-
(
|
|
156
|
+
(
|
|
157
|
+
await reader.question(`${text} [y/N] `, signal ? { signal } : {})
|
|
158
|
+
).trim(),
|
|
66
159
|
);
|
|
67
160
|
} finally {
|
|
68
161
|
reader.close();
|
|
@@ -70,35 +163,71 @@ export const processIO: IO = {
|
|
|
70
163
|
},
|
|
71
164
|
};
|
|
72
165
|
const commands: Record<string, string> = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
166
|
+
daemon: "daemon",
|
|
167
|
+
"daemon ui": "daemon ui [--open]",
|
|
168
|
+
"skills list": "skills list [--refresh | --no-refresh]",
|
|
169
|
+
"skills sync":
|
|
170
|
+
"skills sync [NAMES...] [--agent AGENT]... [--override-existing] [--dry-run] [--yes] [--refresh | --no-refresh]",
|
|
171
|
+
doctor: "doctor [--fix [--yes]]",
|
|
172
|
+
profile: "profile [--name NAME] [--description TEXT]",
|
|
173
|
+
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
174
|
+
"swarm request": "swarm request URL_OR_ALIAS [--pivot] [--output FILE]",
|
|
175
|
+
"swarm export": "swarm export --output FILE",
|
|
176
|
+
"swarm approve": "swarm approve REQUEST_FILE [--pivot] [--again] --yes",
|
|
177
|
+
"swarm pivot grant": "swarm pivot grant MEMBER_PUBLIC_KEY --yes",
|
|
178
|
+
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY --yes",
|
|
179
|
+
"swarm resume": "swarm resume",
|
|
180
|
+
"swarm profile": "swarm profile [--address MULTIADDR] [--pivot true|false]",
|
|
181
|
+
"swarm status": "swarm status [--refresh | --no-refresh]",
|
|
182
|
+
"swarm members": "swarm members [--refresh | --no-refresh]",
|
|
183
|
+
"swarm list": "swarm list",
|
|
184
|
+
"swarm set": "swarm set ALIAS CONFIG_URL [--yes]",
|
|
185
|
+
"swarm use": "swarm use URL_OR_ALIAS",
|
|
186
|
+
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
187
|
+
"swarm update": "swarm update [--name TEXT] [--description TEXT]",
|
|
188
|
+
publish: "publish NAME SOURCE [--expect OLD_CID | --snapshot]",
|
|
189
|
+
get: "get REF [--raw] [--refresh | --no-refresh] [-o DIRECTORY]",
|
|
190
|
+
search:
|
|
191
|
+
"search QUERY [--all | --current] [--prefix PATH] [--kind all|bundle|dir|file] [--schema CID] [--limit N] [--offset N] [--refresh | --no-refresh]",
|
|
192
|
+
"templates render": "templates render TEMPLATE NAME [DIR] [OPTIONS]",
|
|
193
|
+
build: "build [SOURCE] [OPTIONS]",
|
|
76
194
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
77
195
|
"bundle inspect": "bundle inspect SOURCE",
|
|
78
196
|
"bundle import": "bundle import FILE.car",
|
|
79
|
-
exec: "exec [--log] APP [APP_ARGS...]",
|
|
80
|
-
open: "open [--log] CONTENT",
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"pin list": "pin list
|
|
84
|
-
"pin show": "pin show
|
|
85
|
-
"
|
|
86
|
-
"register
|
|
87
|
-
|
|
88
|
-
"register remove": "register remove SCHEMA",
|
|
197
|
+
exec: "exec [--log] [--refresh | --no-refresh] APP [APP_ARGS...]",
|
|
198
|
+
open: "open [--log] [--raw] [--refresh | --no-refresh] CONTENT",
|
|
199
|
+
pin: "pin REF [--refresh | --no-refresh]",
|
|
200
|
+
unpin: "unpin REF",
|
|
201
|
+
"pin list": "pin list",
|
|
202
|
+
"pin show": "pin show REF",
|
|
203
|
+
"register list": "register list [--swarm URL_OR_ALIAS]",
|
|
204
|
+
"register set":
|
|
205
|
+
"register set SCHEMA APP [--swarm URL_OR_ALIAS]... [--replace]",
|
|
206
|
+
"register remove": "register remove SCHEMA [--swarm URL_OR_ALIAS]...",
|
|
207
|
+
"templates list": "templates list [--refresh | --no-refresh]",
|
|
208
|
+
"templates show": "templates show NAME [--refresh | --no-refresh]",
|
|
209
|
+
"templates set": "templates set NAME SOURCE [--expect OLD_TARGET_CID]",
|
|
210
|
+
"templates remove": "templates remove NAME --expect OLD_TARGET_CID",
|
|
89
211
|
"config get": "config get [KEY]",
|
|
90
|
-
"config set":
|
|
212
|
+
"config set":
|
|
213
|
+
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
91
214
|
"config reset": "config reset KEY",
|
|
215
|
+
"store usage": "store usage",
|
|
216
|
+
"store gc": "store gc",
|
|
92
217
|
"history list": "history list [OPTIONS]",
|
|
93
218
|
"history show": "history show RUN_ID",
|
|
94
219
|
"history remove":
|
|
95
220
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
96
221
|
};
|
|
97
222
|
const groups: Record<string, string> = {
|
|
223
|
+
skills: "Discover and explicitly synchronize selected Swarm Skills globally",
|
|
224
|
+
swarm: "Create, authorize, select and manage personal swarms",
|
|
98
225
|
bundle: "Create, inspect and import content bundles",
|
|
99
|
-
pin: "Retain
|
|
226
|
+
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
100
227
|
register: "Associate content types with Apps",
|
|
228
|
+
templates: "Inspect, render and manage Template Bundles",
|
|
101
229
|
config: "Manage local configuration",
|
|
230
|
+
store: "Query local storage and collect unreferenced blocks",
|
|
102
231
|
history: "View and remove execution history",
|
|
103
232
|
};
|
|
104
233
|
const commandHelp: Record<
|
|
@@ -111,49 +240,473 @@ const commandHelp: Record<
|
|
|
111
240
|
notes?: string[];
|
|
112
241
|
}
|
|
113
242
|
> = {
|
|
114
|
-
|
|
115
|
-
summary: "
|
|
116
|
-
|
|
243
|
+
daemon: {
|
|
244
|
+
summary: "Manage all registered private Swarm nodes in the foreground",
|
|
245
|
+
examples: ["ipab daemon", "ipab daemon ui --open"],
|
|
246
|
+
notes: [
|
|
247
|
+
"Manages all registered Swarms independently and does not accept --swarm; ignores the saved default.",
|
|
248
|
+
"Maintains membership and network topology: probes pivot candidates, refreshes approved profiles and retries with cooldown. Diagnostics go to stderr.",
|
|
249
|
+
"Synchronizes the latest HEAD/State and automatically syncs Skills (to universal), Templates and Registry App Bundles for each activated Swarm on startup and every swarm.syncInterval seconds (default 60; IPAB_SWARM_SYNC_INTERVAL). Preserves local edits and other sources.",
|
|
250
|
+
"Serves a read-only loopback status WebUI on 127.0.0.1 (automatic port by default; configurable via daemon.uiPort / IPAB_DAEMON_UI_PORT). Inspect or open it with `ipab daemon ui [--open]`.",
|
|
251
|
+
"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.",
|
|
252
|
+
"Ctrl-C / TERM drains foreground operations and releases the device/state-dir lock; Kubo stays running. An existing background daemon already owns this lock.",
|
|
253
|
+
"Role and relay candidate changes restart only the verified managed Kubo node.",
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
"daemon ui": {
|
|
257
|
+
summary:
|
|
258
|
+
"Show or open the running daemon's read-only loopback status WebUI",
|
|
259
|
+
options: [
|
|
260
|
+
"--open Open the 127.0.0.1 status WebUI URL in the default browser.",
|
|
261
|
+
],
|
|
262
|
+
examples: [
|
|
263
|
+
"ipab daemon ui",
|
|
264
|
+
"ipab daemon ui --open",
|
|
265
|
+
"ipab --json daemon ui",
|
|
266
|
+
],
|
|
267
|
+
notes: [
|
|
268
|
+
"Inspects the protected loopback endpoint for the selected state-dir without starting a daemon.",
|
|
269
|
+
"The WebUI binds strictly to 127.0.0.1, validates Host/Origin headers against DNS rebinding, and never exposes private keys, swarm.key or Kubo Bearer tokens.",
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
"templates list": {
|
|
273
|
+
summary: "List templates under the selected Swarm Meta templatePath",
|
|
274
|
+
options: [
|
|
275
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
276
|
+
],
|
|
277
|
+
examples: [
|
|
278
|
+
"ipab --swarm work templates list",
|
|
279
|
+
"ipab --json templates list",
|
|
280
|
+
],
|
|
281
|
+
notes: [
|
|
282
|
+
"Uses only global --swarm (once, before the command), otherwise the saved default. No builtin or other Swarm fallback.",
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
"templates show": {
|
|
286
|
+
summary: "Show one template, its exact targets and declared parameters",
|
|
287
|
+
arguments: [
|
|
288
|
+
"NAME Safe relative template Name; nested names are supported.",
|
|
289
|
+
],
|
|
290
|
+
options: [
|
|
291
|
+
"--refresh / --no-refresh Refresh HEAD now / allow a valid cached snapshot.",
|
|
292
|
+
],
|
|
293
|
+
examples: ["ipab --swarm work templates show node"],
|
|
294
|
+
},
|
|
295
|
+
"templates set": {
|
|
296
|
+
summary:
|
|
297
|
+
"Publish one validated Template Bundle with exact Name conflict checks",
|
|
298
|
+
arguments: [
|
|
299
|
+
"NAME Safe relative template Name.",
|
|
300
|
+
"SOURCE Exact Template CID, self-contained CAR or explicit manifest directory; no URI, build or hooks.",
|
|
301
|
+
],
|
|
302
|
+
options: [
|
|
303
|
+
"--expect OLD_TARGET_CID Required to replace an occupied Name; use its exact target CID, including an Artifact wrapper.",
|
|
304
|
+
],
|
|
305
|
+
examples: [
|
|
306
|
+
"ipab --swarm work templates set team/node ./template.car",
|
|
307
|
+
"ipab templates set node TEMPLATE_CID --expect OLD_TARGET_CID",
|
|
308
|
+
],
|
|
309
|
+
notes: [
|
|
310
|
+
"Publishes an ordinary Artifact and preserves publication history and content retention.",
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
"templates remove": {
|
|
314
|
+
summary: "Remove only one template Name, without deleting content",
|
|
315
|
+
arguments: ["NAME Safe relative template Name."],
|
|
316
|
+
options: [
|
|
317
|
+
"--expect OLD_TARGET_CID Required exact current Name target CID.",
|
|
318
|
+
],
|
|
319
|
+
examples: [
|
|
320
|
+
"ipab --swarm work templates remove team/node --expect OLD_TARGET_CID",
|
|
321
|
+
],
|
|
322
|
+
notes: [
|
|
323
|
+
"Missing Names are errors. Does not unpin, GC or delete content or history.",
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
"skills list": {
|
|
327
|
+
summary: "List typed Skills and local installation status from one Swarm",
|
|
328
|
+
options: [
|
|
329
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
330
|
+
"Global --json Emit machine-readable names, exact payload CIDs and status.",
|
|
331
|
+
],
|
|
332
|
+
examples: ["ipab --swarm work skills list", "ipab --json skills list"],
|
|
333
|
+
notes: [
|
|
334
|
+
"Select one Swarm with global --swarm or swarm use; there is no --all.",
|
|
335
|
+
"Requires skillPath in the exact root State Bundle or legacy Meta type. Older v5 roots require a new seeded Swarm; only legacy v2/v3/v4 Meta can be explicitly replaced with --expect. No silent upgrades.",
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
"skills sync": {
|
|
339
|
+
summary:
|
|
340
|
+
"Install reviewed Swarm Skills using the pinned official npx installer",
|
|
341
|
+
arguments: [
|
|
342
|
+
"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.",
|
|
343
|
+
],
|
|
344
|
+
options: [
|
|
345
|
+
"--agent AGENT Repeatable globally supported agent ID; default is universal (~/.agents/skills).",
|
|
346
|
+
"--override-existing Replace non-IPAB-managed Skills and local edits at selected targets.",
|
|
347
|
+
"--dry-run Preview without invoking npx or changing installed Skills.",
|
|
348
|
+
"--yes Skip IPAB consent only; does not imply --override-existing.",
|
|
349
|
+
"--refresh / --no-refresh Refresh HEAD now / reuse a valid verified snapshot.",
|
|
350
|
+
],
|
|
351
|
+
examples: [
|
|
352
|
+
"ipab --swarm work skills sync --dry-run",
|
|
353
|
+
"ipab skills sync ipab code-review --agent github-copilot --yes",
|
|
354
|
+
],
|
|
355
|
+
notes: [
|
|
356
|
+
"Global installs only, through official skills@1.9.1 with --copy. Requires Node >=22.20.0.",
|
|
357
|
+
"Non-interactive execution requires --yes. Installer version, source, paths and agents are shown first.",
|
|
358
|
+
"No Skill hooks/scripts run. The trusted installer is not sandboxed. Telemetry and remote audits are disabled.",
|
|
359
|
+
"Non-IPAB installs and local edits require --override-existing. Cross-Swarm collisions and symlink/junction aliases remain protected. Removed sources are reported, not deleted.",
|
|
360
|
+
"Partial failures report individual results, preserve pending attribution and exit nonzero; retry the same sync.",
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
profile: {
|
|
364
|
+
summary: "Read or update your account-wide public name and description",
|
|
365
|
+
examples: [
|
|
366
|
+
"ipab profile",
|
|
367
|
+
'ipab profile --name Wei --description "Developer"',
|
|
368
|
+
'ipab profile --description ""',
|
|
369
|
+
],
|
|
370
|
+
options: [
|
|
371
|
+
"--name NAME Replace only your personal name.",
|
|
372
|
+
"--description TEXT Replace only your description; empty text clears it.",
|
|
373
|
+
],
|
|
374
|
+
notes: [
|
|
375
|
+
"Independent of Swarm selection. Reading never creates an identity, persists a profile or activates a node.",
|
|
376
|
+
"An explicit update prepares a missing account identity without starting Kubo.",
|
|
377
|
+
"Updates persist locally first, then synchronize all registered memberships without changing network addresses. Partial failure exits nonzero and reports every result.",
|
|
378
|
+
"Retry the same profile update, or normally activate a failed membership to synchronize the saved profile.",
|
|
379
|
+
"First use preserves unanimous legacy values; conflicting fields require an explicit choice. New memberships adopt this same profile.",
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
doctor: {
|
|
383
|
+
summary:
|
|
384
|
+
"Inspect device readiness without writes; explicitly authorize safe repairs",
|
|
385
|
+
examples: [
|
|
386
|
+
"ipab doctor",
|
|
387
|
+
"ipab doctor --fix",
|
|
388
|
+
"ipab --json doctor --fix --yes",
|
|
389
|
+
],
|
|
390
|
+
options: [
|
|
391
|
+
"--fix Repair missing components, cache official archives to verify existing Kubo without reinstall, and authorize healthy compatible upgrades within ^0.43.2.",
|
|
392
|
+
"--yes Authorize planned repairs without prompting; requires --fix.",
|
|
393
|
+
],
|
|
394
|
+
notes: [
|
|
395
|
+
"Always checks local state/configuration, managed Kubo, HOME identity, local Swarm registry, compatible updates and the CLI-bundled IPAB Skill for detected Agents.",
|
|
396
|
+
"--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.",
|
|
397
|
+
"Inspection never creates state, locks, credentials or caches. Official release metadata may be queried; unavailable updates are not claimed current.",
|
|
398
|
+
"Healthy current components are reused without download or confirmation. Fixed protected archive cache is automatic.",
|
|
399
|
+
"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.",
|
|
400
|
+
"Does not create Swarm repos, start or contact any daemon, deploy services or install login startup.",
|
|
401
|
+
],
|
|
402
|
+
},
|
|
403
|
+
"swarm create": {
|
|
404
|
+
summary: "Create a swarm using the account HOME identity",
|
|
405
|
+
options: [
|
|
406
|
+
"--service URL Must match the protected pointers.service origin.",
|
|
407
|
+
"--resume OPERATION Recover the same saved create/idempotency result.",
|
|
408
|
+
"--name TEXT Initial mutable swarm name.",
|
|
409
|
+
"--description TEXT Initial mutable description.",
|
|
410
|
+
"--alias ALIAS Optional local registry alias (not the shared name).",
|
|
411
|
+
],
|
|
412
|
+
examples: [
|
|
413
|
+
"ipab config set pointers.service https://service.example",
|
|
414
|
+
"ipab config set pointers.apiKey -",
|
|
415
|
+
"ipab swarm create",
|
|
416
|
+
],
|
|
417
|
+
notes: [
|
|
418
|
+
"Creation uses the protected, origin-bound API key and owner possession proof.",
|
|
419
|
+
"Installs checksum-verified Kubo on demand; each Swarm has its own protected repo and ports.",
|
|
420
|
+
"Returns the public organization configuration URL; owner needs no certificate.",
|
|
421
|
+
],
|
|
422
|
+
},
|
|
423
|
+
"swarm request": {
|
|
424
|
+
summary: "Save and export a signed self-contained membership Request",
|
|
425
|
+
examples: [
|
|
426
|
+
"ipab swarm request work",
|
|
427
|
+
"ipab swarm request CONFIG_URL --output request.json",
|
|
428
|
+
],
|
|
429
|
+
options: [
|
|
430
|
+
"--pivot Request Pivot Member role (HEAD write + ScopeWriteReceipt issuer); defaults to ordinary.",
|
|
431
|
+
"--output FILE Export to a new file instead of stdout; never overwrites.",
|
|
432
|
+
],
|
|
433
|
+
notes: [
|
|
434
|
+
"Verify the printed Owner fingerprint through an independent trusted channel before manually sending the Request file to the Owner.",
|
|
435
|
+
"Without --output, stdout is the signed Request JSON, including in --json mode.",
|
|
436
|
+
"With --output, reports the file on stderr; --json returns file, member and ownerFingerprint.",
|
|
437
|
+
"Retries export the exact saved Request without expiry.",
|
|
438
|
+
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
439
|
+
"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.",
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
"swarm approve": {
|
|
443
|
+
summary: "Owner signs a certificate for an exact request",
|
|
444
|
+
options: [
|
|
445
|
+
"--yes Explicit approval; required outside a TTY.",
|
|
446
|
+
"--pivot Also authorize this member to sign HEAD write receipts as a Pivot.",
|
|
447
|
+
"--again Explicit fresh approval of an old Request; history is advisory.",
|
|
448
|
+
],
|
|
449
|
+
examples: [
|
|
450
|
+
"ipab --swarm work swarm approve request.json --yes",
|
|
451
|
+
"ipab --swarm work swarm approve request.json --pivot --yes",
|
|
452
|
+
"ipab --swarm work swarm approve - --yes < request.json",
|
|
453
|
+
],
|
|
454
|
+
notes: [
|
|
455
|
+
"Use '-' to read Request JSON from stdin (maximum 16 KiB); --yes is required and no confirmation prompt reads stdin.",
|
|
456
|
+
"Ordinary approval grants only the member's profile write access; --pivot also grants current HEAD write authority. Exact-ID certificates have no expiry; revoking Pivot HEAD authority requires swarm exclude.",
|
|
457
|
+
],
|
|
458
|
+
},
|
|
459
|
+
"swarm pivot grant": {
|
|
460
|
+
summary: "Owner grants an approved member Pivot HEAD receipt authority",
|
|
461
|
+
options: ["--yes Explicit confirmation; required."],
|
|
462
|
+
examples: ["ipab --swarm work swarm pivot grant MEMBER_PUBLIC_KEY --yes"],
|
|
463
|
+
notes: [
|
|
464
|
+
"Re-issues the approved member's ScopeCertificate with current HEAD and profile write access and updates their approval envelope without rotating the epoch.",
|
|
465
|
+
"Exact-ID certificates are stateless with no expiry; revoking Pivot HEAD authority requires swarm exclude (epoch/HEAD rotation).",
|
|
466
|
+
],
|
|
467
|
+
},
|
|
468
|
+
"swarm export": {
|
|
469
|
+
summary: "Re-export the same persisted Request",
|
|
470
|
+
examples: ["ipab --swarm work swarm export --output request.json"],
|
|
471
|
+
},
|
|
472
|
+
"swarm exclude": {
|
|
473
|
+
summary: "Owner removes a member with irreversible HEAD/key rotation",
|
|
474
|
+
examples: ["ipab --swarm work swarm exclude MEMBER_PUBLIC_KEY --yes"],
|
|
475
|
+
notes: [
|
|
476
|
+
"Freezes the old HEAD atomically, preserves its final committed publication, rotates the key and remaining packages, deletes the leaving profile and retires the old HEAD.",
|
|
477
|
+
],
|
|
478
|
+
},
|
|
479
|
+
"swarm resume": {
|
|
480
|
+
summary: "Owner resumes an interrupted organization switch",
|
|
481
|
+
examples: ["ipab --swarm work swarm resume"],
|
|
482
|
+
},
|
|
483
|
+
"swarm profile": {
|
|
484
|
+
summary: "Configure your selected Swarm's address and Pivot role",
|
|
485
|
+
options: [
|
|
486
|
+
"--pivot true|false Declare or withdraw this member's Pivot backbone role.",
|
|
487
|
+
],
|
|
488
|
+
examples: [
|
|
489
|
+
"ipab --swarm work swarm profile --address /ip4/192.168.1.12/tcp/4001/p2p/PEER_ID",
|
|
490
|
+
"ipab --swarm work swarm profile --pivot true",
|
|
491
|
+
],
|
|
492
|
+
notes: [
|
|
493
|
+
"Personal name/description are managed only by ipab profile, not this network configuration command.",
|
|
494
|
+
"Pivot provides backbone connectivity and durable published-content Pin service through daemon. Keep it online with sufficient storage.",
|
|
495
|
+
],
|
|
496
|
+
},
|
|
497
|
+
"swarm members": {
|
|
498
|
+
summary: "List every public member, including the Owner",
|
|
499
|
+
options: [
|
|
500
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
501
|
+
"--local Deprecated no-op; local daemon observations are always included.",
|
|
502
|
+
],
|
|
503
|
+
examples: [
|
|
504
|
+
"ipab --swarm work swarm members",
|
|
505
|
+
"ipab --json swarm members --refresh",
|
|
506
|
+
],
|
|
507
|
+
notes: [
|
|
508
|
+
"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.",
|
|
509
|
+
"PIVOT: - for ordinary members; selected, cooldown, unknown, self or candidate for declared Pivots. Selected means applied configuration, not connectivity.",
|
|
510
|
+
],
|
|
511
|
+
},
|
|
512
|
+
"swarm status": {
|
|
513
|
+
summary: "Inspect cached Swarm directory, HEAD and local networking",
|
|
514
|
+
options: [
|
|
515
|
+
"--refresh / --no-refresh Fetch public Variables now / reuse the saved inspection, fetching if missing.",
|
|
516
|
+
"--local Deprecated no-op; never activates a node.",
|
|
517
|
+
],
|
|
518
|
+
examples: [
|
|
519
|
+
"ipab swarm status",
|
|
520
|
+
"ipab --swarm work swarm status",
|
|
521
|
+
"ipab --swarm work swarm status --refresh",
|
|
522
|
+
],
|
|
523
|
+
notes: [
|
|
524
|
+
"Default: reuse the inspection cache, fetching public Variables if missing. Refresh verifies Config, Scope, members, Profiles and HEAD, not connectivity or State content.",
|
|
525
|
+
"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.",
|
|
526
|
+
"State content is explicitly unavailable in inspection; use get ipab:/// to obtain the State Bundle.",
|
|
527
|
+
"Local connectivity is not global availability; a relay connection does not guarantee content transfer.",
|
|
528
|
+
],
|
|
529
|
+
},
|
|
530
|
+
"swarm list": {
|
|
531
|
+
summary: "List local swarm registrations and the effective selection",
|
|
532
|
+
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
533
|
+
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
534
|
+
},
|
|
535
|
+
"swarm set": {
|
|
536
|
+
summary: "Set a local alias for a swarm configuration URL",
|
|
537
|
+
options: [
|
|
538
|
+
"--yes Authorize retargeting an existing alias without prompting.",
|
|
539
|
+
],
|
|
540
|
+
examples: [
|
|
541
|
+
"ipab swarm set work CONFIG_URL",
|
|
542
|
+
"ipab swarm set work OTHER_CONFIG_URL --yes",
|
|
543
|
+
],
|
|
544
|
+
notes: [
|
|
545
|
+
"Local only; no network, account identity or approved membership required.",
|
|
546
|
+
"Setting the same mapping is idempotent. One alias per URL; a new alias for that URL replaces its old alias.",
|
|
547
|
+
"Retargeting an alias requires confirmation or --yes. Keeps the old URL registered without that alias; credentials, caches and the saved default URL are unchanged.",
|
|
548
|
+
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
549
|
+
],
|
|
550
|
+
},
|
|
551
|
+
"swarm use": {
|
|
552
|
+
summary: "Save a registered swarm as the current default",
|
|
553
|
+
examples: ["ipab swarm use work"],
|
|
554
|
+
notes: ["Local only. --swarm still overrides the saved default."],
|
|
555
|
+
},
|
|
556
|
+
"swarm remove": {
|
|
557
|
+
summary: "Forget a local registration without revoking membership",
|
|
558
|
+
examples: ["ipab swarm remove work"],
|
|
559
|
+
notes: [
|
|
560
|
+
"Preserves credentials, content and remote membership. Clears a matching saved default without selecting a replacement.",
|
|
561
|
+
],
|
|
562
|
+
},
|
|
563
|
+
"swarm update": {
|
|
564
|
+
summary: "Owner updates public organization information",
|
|
565
|
+
options: [
|
|
566
|
+
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
567
|
+
"--description TEXT Replace the shared description; empty text clears it.",
|
|
568
|
+
],
|
|
569
|
+
examples: [
|
|
570
|
+
'ipab --swarm work swarm update --name "Team" --description "Shared workspace"',
|
|
571
|
+
'ipab swarm update --description ""',
|
|
572
|
+
],
|
|
573
|
+
notes: [
|
|
574
|
+
"Requires at least one field. Members can change only their own profile.",
|
|
575
|
+
"Content-CID CAS prevents overwriting concurrent organization changes.",
|
|
576
|
+
"Shared name changes do not rename local registry aliases.",
|
|
577
|
+
],
|
|
578
|
+
},
|
|
579
|
+
search: {
|
|
580
|
+
summary: "Search formal Names in the current swarm",
|
|
581
|
+
arguments: [
|
|
582
|
+
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
583
|
+
],
|
|
584
|
+
options: [
|
|
585
|
+
"--all Search all registered swarms; conflicts with --current and --swarm.",
|
|
586
|
+
"--current Explicitly select the default search scope; conflicts with --swarm.",
|
|
587
|
+
"--prefix PATH Restrict v7 search results to paths under PATH.",
|
|
588
|
+
"--kind KIND Filter v7 search results by kind: all, bundle, dir, or file.",
|
|
589
|
+
"--schema CID Filter v7 search results to Bundles with exact schema CID.",
|
|
590
|
+
"--limit N Maximum number of results per v7 swarm (1..100, default 20).",
|
|
591
|
+
"--offset N Zero-based result offset for v7 pagination (default 0).",
|
|
592
|
+
"--refresh Refresh HEAD for every swarm in the search scope.",
|
|
593
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
594
|
+
],
|
|
595
|
+
examples: [
|
|
596
|
+
"ipab search hello",
|
|
597
|
+
"ipab search hello --all",
|
|
598
|
+
"ipab --swarm work search hello --refresh",
|
|
599
|
+
],
|
|
600
|
+
notes: [
|
|
601
|
+
"Searches only --swarm or the saved current swarm by default. Use --all to search every registration.",
|
|
602
|
+
"Valid caches use local Names; absent/expired caches refresh. Active Name pins may synchronize content.",
|
|
603
|
+
"Refresh reads public configuration and HEAD; private networking is activated only for missing content.",
|
|
604
|
+
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
605
|
+
"Text uses local alias URIs when available; JSON references use full configuration URLs for cross-device sharing.",
|
|
606
|
+
],
|
|
607
|
+
},
|
|
608
|
+
publish: {
|
|
609
|
+
summary: "Protect content locally and publish a shared Swarm Name",
|
|
610
|
+
options: [
|
|
611
|
+
"--expect CID Exact old Name target CID, required for iteration.",
|
|
612
|
+
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
613
|
+
],
|
|
614
|
+
examples: [
|
|
615
|
+
"ipab --swarm work publish apps/hello app.car",
|
|
616
|
+
"ipab publish apps/hello APP_CID --expect OLD_APP_CID",
|
|
617
|
+
"ipab publish notes/readme ./README.md",
|
|
618
|
+
],
|
|
619
|
+
notes: [
|
|
620
|
+
"SOURCE is an exact Bundle CID, CAR, regular file or directory. No compiler, hooks, install or App execution.",
|
|
621
|
+
"Directories require .bundle.yaml/type, or a package.json source snapshot. Standalone .json/.yaml/.yml/.md/.txt entries get a standard Bundle; other file types require explicit metadata.",
|
|
622
|
+
"App and Meta Bundles publish direct CID links; other content uses Artifact records. Occupied Names require --expect EXACT_OLD_CID (the old Artifact CID when applicable). Published payloads are local CID pins; unpin CID releases that protection, not history holders.",
|
|
623
|
+
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
624
|
+
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
625
|
+
],
|
|
626
|
+
},
|
|
627
|
+
get: {
|
|
628
|
+
summary: "Verify and unpack Bundle content without executing it",
|
|
117
629
|
options: [
|
|
118
|
-
"--
|
|
630
|
+
"--raw Select the Artifact node instead of its value.",
|
|
631
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
632
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
633
|
+
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
634
|
+
],
|
|
635
|
+
examples: [
|
|
636
|
+
"ipab --json get ipab:///apps/hello -o hello-app",
|
|
637
|
+
"ipab get ipab://work/apps/hello -o hello-app",
|
|
638
|
+
"ipab get CONTENT_CID",
|
|
639
|
+
"ipab get --raw RELEASE_CID",
|
|
640
|
+
],
|
|
641
|
+
notes: [
|
|
642
|
+
"Stdout contains only the absolute directory path; --json also returns content and original target CIDs.",
|
|
643
|
+
"Temporary exports remain after exit; copy before cleanup, not symlink. Use --output for a persistent destination.",
|
|
644
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
645
|
+
"Copy the reference from ipab search, or percent-encode the entire configuration URL and each Name path segment separately.",
|
|
646
|
+
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
647
|
+
],
|
|
648
|
+
},
|
|
649
|
+
"store usage": {
|
|
650
|
+
summary: "Query cached and recursively pinned block bytes",
|
|
651
|
+
examples: ["ipab store usage", "ipab --json store usage"],
|
|
652
|
+
notes: [
|
|
653
|
+
"Local Store only; excludes metadata, temporary files and disk allocation overhead.",
|
|
654
|
+
"Pinned DAGs include all descendants, with shared blocks counted once.",
|
|
655
|
+
],
|
|
656
|
+
},
|
|
657
|
+
"store gc": {
|
|
658
|
+
summary: "Delete unprotected blocks from the entire selected local Store",
|
|
659
|
+
examples: ["ipab store gc", "ipab --json store gc"],
|
|
660
|
+
notes: [
|
|
661
|
+
"Preserves pins, all participating owners, pending operations and staged imports.",
|
|
662
|
+
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
663
|
+
],
|
|
664
|
+
},
|
|
665
|
+
"templates render": {
|
|
666
|
+
summary: "Render a template's project files into a new or empty folder",
|
|
667
|
+
arguments: [
|
|
668
|
+
"TEMPLATE Explicit Swarm selector, directory, CAR, exact CID or IPAB URI.",
|
|
669
|
+
"NAME Project name parameter; DIR defaults to NAME (new/empty only).",
|
|
670
|
+
],
|
|
671
|
+
options: [
|
|
672
|
+
"--description TEXT Set the declared description parameter.",
|
|
673
|
+
"--refresh / --no-refresh Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
119
674
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
120
675
|
" other parameter types use JSON.",
|
|
121
676
|
],
|
|
122
677
|
examples: [
|
|
123
|
-
"ipab
|
|
124
|
-
"ipab
|
|
125
|
-
"ipab
|
|
678
|
+
"ipab templates render node hello",
|
|
679
|
+
"ipab templates render web-app dashboard --param webAppDependency=0.1.0-rc.2",
|
|
680
|
+
"ipab templates render ./template.car hello --description Demo",
|
|
681
|
+
],
|
|
682
|
+
notes: [
|
|
683
|
+
"Short selectors resolve through the selected Swarm's typed root configuration (legacy v2/v3/v4 use Meta Name ipab); no builtin fallback.",
|
|
684
|
+
"Explicit directory, CAR and available exact CID work offline without a Swarm.",
|
|
685
|
+
"Does not install dependencies or execute template code.",
|
|
126
686
|
],
|
|
127
|
-
notes: ["Does not install dependencies or execute template code."],
|
|
128
687
|
},
|
|
129
688
|
build: {
|
|
130
|
-
summary: "
|
|
131
|
-
arguments: [
|
|
689
|
+
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
690
|
+
arguments: [
|
|
691
|
+
"SOURCE Recipe file or Bundle directory (default: current directory).",
|
|
692
|
+
],
|
|
132
693
|
options: [
|
|
133
|
-
"-o, --output FILE Destination (default: dist/
|
|
694
|
+
"-o, --output FILE Destination (default: dist/bundle.car).",
|
|
134
695
|
"--replace Allow replacing existing regular artifacts.",
|
|
135
|
-
"--no-import Write CAR
|
|
136
|
-
|
|
137
|
-
|
|
696
|
+
"--no-import Write the CAR without importing the Bundle into Store.",
|
|
697
|
+
],
|
|
698
|
+
examples: [
|
|
699
|
+
"ipab build prepared-app",
|
|
700
|
+
"ipab build ipab.build.yaml --replace",
|
|
138
701
|
],
|
|
139
|
-
examples: ["ipab build", "ipab build hello --replace --without-source"],
|
|
140
702
|
notes: [
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
703
|
+
"Recipe explicitly maps source files and exact CID imports to target paths.",
|
|
704
|
+
"Instance paths come from .bundle.yaml; the referenced file defines the type. Imported DAG identities are preserved.",
|
|
705
|
+
"Legacy App ipab.yaml is rejected; use project preparation tools separately.",
|
|
706
|
+
"Select explicit files; review private files before providing Bundles.",
|
|
145
707
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
146
708
|
],
|
|
147
709
|
},
|
|
148
|
-
"bundle init": {
|
|
149
|
-
summary: "Create content from a Bundle type",
|
|
150
|
-
arguments: [
|
|
151
|
-
"TYPE Definition file, type CAR, exact type CID or Schema pin.",
|
|
152
|
-
"DIR New or empty destination directory.",
|
|
153
|
-
],
|
|
154
|
-
examples: ["ipab bundle init types\\dist\\schema.car note"],
|
|
155
|
-
notes: ["Writes .bundle.yaml, .bundle-ignore and the default entry."],
|
|
156
|
-
},
|
|
157
710
|
"bundle build": {
|
|
158
711
|
summary: "Build a content or type CAR without compiling code",
|
|
159
712
|
arguments: ["SOURCE Bundle directory or definition file."],
|
|
@@ -165,7 +718,7 @@ const commandHelp: Record<
|
|
|
165
718
|
],
|
|
166
719
|
examples: [
|
|
167
720
|
"ipab bundle build note",
|
|
168
|
-
"ipab bundle build types\\.bundle.yaml --schema-only",
|
|
721
|
+
"ipab bundle build types\\.bundle-type.yaml --schema-only",
|
|
169
722
|
],
|
|
170
723
|
notes: [
|
|
171
724
|
"Imports into the configured Store without pinning or executing Apps.",
|
|
@@ -174,7 +727,9 @@ const commandHelp: Record<
|
|
|
174
727
|
},
|
|
175
728
|
"bundle inspect": {
|
|
176
729
|
summary: "Inspect a Bundle or type definition",
|
|
177
|
-
arguments: [
|
|
730
|
+
arguments: [
|
|
731
|
+
"SOURCE Directory, definition file, CAR, CID or packaged builtin reference.",
|
|
732
|
+
],
|
|
178
733
|
examples: ["ipab bundle inspect note\\dist\\bundle.car"],
|
|
179
734
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
180
735
|
},
|
|
@@ -184,24 +739,27 @@ const commandHelp: Record<
|
|
|
184
739
|
examples: ["ipab bundle import hello\\dist\\app.car"],
|
|
185
740
|
notes: [
|
|
186
741
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
187
|
-
"Does not pin or retain content. Use pin
|
|
742
|
+
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
188
743
|
],
|
|
189
744
|
},
|
|
190
745
|
exec: {
|
|
191
|
-
summary: "Run an App by CID or
|
|
746
|
+
summary: "Run an App by exact CID or Swarm IPAB URI",
|
|
192
747
|
arguments: [
|
|
193
748
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
194
749
|
],
|
|
195
750
|
options: [
|
|
196
751
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
752
|
+
"--refresh Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
753
|
+
"--no-refresh Override swarm.forceRefresh; must precede APP.",
|
|
197
754
|
],
|
|
198
755
|
examples: [
|
|
199
756
|
"ipab exec reader",
|
|
200
|
-
"ipab exec reader --help",
|
|
201
757
|
"ipab exec --log reader",
|
|
758
|
+
"ipab exec ipab://work/apps/hello --help",
|
|
202
759
|
],
|
|
203
760
|
notes: [
|
|
204
761
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
762
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
205
763
|
"History stores argv by default; do not put secrets in arguments.",
|
|
206
764
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
207
765
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -209,117 +767,154 @@ const commandHelp: Record<
|
|
|
209
767
|
},
|
|
210
768
|
open: {
|
|
211
769
|
summary: "Open content with its registered App",
|
|
212
|
-
arguments: [
|
|
213
|
-
|
|
214
|
-
|
|
770
|
+
arguments: [
|
|
771
|
+
"CONTENT Bundle CID, packaged builtin reference or Swarm IPAB URI.",
|
|
772
|
+
],
|
|
773
|
+
options: [
|
|
774
|
+
"--log Record stdout/stderr; requires history enabled.",
|
|
775
|
+
"--raw Open the Artifact node rather than its value.",
|
|
776
|
+
"--refresh Refresh the shared Name's swarm HEAD.",
|
|
777
|
+
"--no-refresh Override swarm.forceRefresh and use valid cached headers.",
|
|
778
|
+
],
|
|
779
|
+
examples: [
|
|
780
|
+
"ipab open CONTENT_CID",
|
|
781
|
+
"ipab open --log --refresh ipab:///documents/readme",
|
|
782
|
+
"ipab open ipab:///",
|
|
783
|
+
],
|
|
215
784
|
notes: [
|
|
216
785
|
"Requires a saved registration and App support for the exact content type.",
|
|
786
|
+
"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.",
|
|
787
|
+
"Uses only the content URI's Swarm, otherwise --swarm, otherwise swarm.default. A selected Swarm is required.",
|
|
788
|
+
"A registered App's retrieval, compatibility or execution failure never triggers fallback.",
|
|
789
|
+
"Legacy User registrations are inactive and preserved in the state database's legacy_user_registrations table; review them before explicit Swarm registration.",
|
|
790
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
217
791
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
218
792
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
219
793
|
"--json is not supported; App stdio is passed through.",
|
|
220
794
|
],
|
|
221
795
|
},
|
|
222
|
-
|
|
223
|
-
summary: "
|
|
796
|
+
pin: {
|
|
797
|
+
summary: "Retain an immutable CID or follow a shared Swarm Name",
|
|
224
798
|
arguments: [
|
|
225
|
-
"
|
|
226
|
-
|
|
799
|
+
"REF Exact Bundle CID or ipab://SWARM/NAME; no local content aliases.",
|
|
800
|
+
],
|
|
801
|
+
options: [
|
|
802
|
+
"--refresh / --no-refresh Refresh shared HEAD now / allow its valid cached snapshot.",
|
|
803
|
+
],
|
|
804
|
+
examples: [
|
|
805
|
+
"ipab pin APP_CID",
|
|
806
|
+
"ipab pin ipab://work/apps/reader",
|
|
807
|
+
"ipab pin list",
|
|
227
808
|
],
|
|
228
|
-
examples: ["ipab pin add reader APP_CID"],
|
|
229
809
|
notes: [
|
|
230
|
-
"
|
|
231
|
-
"
|
|
810
|
+
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
811
|
+
"A CID stays fixed. A shared Name saves its canonical configuration URL and exact Name, refreshing on related Swarm HEAD reads/sync, not continuously.",
|
|
812
|
+
"New content is verified and retained before the previous subscription version is released. Failures keep the last good version marked stale; deleted Names keep it marked missing.",
|
|
813
|
+
"Does not execute Apps or install dependencies. Shared Names connect to their Swarm content source only as needed.",
|
|
232
814
|
"The builtin namespace is read-only.",
|
|
233
815
|
],
|
|
234
816
|
},
|
|
235
|
-
|
|
236
|
-
summary: "
|
|
237
|
-
examples: ["ipab
|
|
817
|
+
unpin: {
|
|
818
|
+
summary: "Release a CID pin or stop following a shared Name",
|
|
819
|
+
examples: ["ipab unpin APP_CID", "ipab unpin ipab://work/apps/reader"],
|
|
238
820
|
notes: [
|
|
239
821
|
"Releases only this pin's ownership on its original backend; no block deletion or GC.",
|
|
240
|
-
"
|
|
822
|
+
"Never re-resolves a shared Name to release content. Uses only saved actual roots. Missing pins are success.",
|
|
823
|
+
"Exact CID also releases archived legacy named-pin holders for that CID. Does not change shared Names, registrations or history. Built-ins are read-only.",
|
|
824
|
+
"Publication/history owners are independent; --snapshot payloads remain recursively retained by publication history after ordinary unpin.",
|
|
241
825
|
],
|
|
242
826
|
},
|
|
243
827
|
"pin list": {
|
|
244
|
-
summary: "List
|
|
245
|
-
|
|
246
|
-
"--kind bundle|schema Filter by kind; omit to include ordinary content.",
|
|
247
|
-
"--type TYPE Exact schema CID, Schema pin or builtin shortcut.",
|
|
248
|
-
],
|
|
249
|
-
examples: [
|
|
250
|
-
"ipab pin list",
|
|
251
|
-
"ipab pin list --kind bundle --type builtin:node-app.v1",
|
|
252
|
-
],
|
|
828
|
+
summary: "List local retention, following Names and packaged built-ins",
|
|
829
|
+
examples: ["ipab pin list"],
|
|
253
830
|
notes: [
|
|
254
|
-
"
|
|
831
|
+
"Includes pending/stale/missing records and inactive archived local pin names.",
|
|
832
|
+
"Legacy retention is preserved; use unpin EXACT_CID to explicitly release its archived holders.",
|
|
255
833
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
256
834
|
],
|
|
257
835
|
},
|
|
258
836
|
"pin show": {
|
|
259
|
-
summary: "Show
|
|
260
|
-
examples: ["ipab pin show
|
|
837
|
+
summary: "Show saved retention and following status",
|
|
838
|
+
examples: ["ipab pin show APP_CID"],
|
|
261
839
|
notes: [
|
|
262
840
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
263
841
|
],
|
|
264
842
|
},
|
|
265
|
-
"
|
|
266
|
-
summary: "
|
|
267
|
-
|
|
843
|
+
"register list": {
|
|
844
|
+
summary: "List content-type associations in the current or selected Swarm",
|
|
845
|
+
options: [
|
|
846
|
+
"--swarm URL_OR_ALIAS Read only this Swarm registry; specify at most once.",
|
|
847
|
+
],
|
|
848
|
+
examples: ["ipab register list", "ipab register list --swarm work"],
|
|
268
849
|
notes: [
|
|
269
|
-
"
|
|
270
|
-
"
|
|
850
|
+
"Without explicit --swarm, reads the saved default Swarm. Select one with --swarm or ipab swarm use.",
|
|
851
|
+
"Legacy User registrations are inactive and preserved in legacy_user_registrations; no automatic upload or deletion.",
|
|
271
852
|
],
|
|
272
853
|
},
|
|
273
|
-
"register list": {
|
|
274
|
-
summary: "List saved content-type associations",
|
|
275
|
-
examples: ["ipab register list"],
|
|
276
|
-
},
|
|
277
854
|
"register set": {
|
|
278
855
|
summary: "Associate a content type with an App",
|
|
279
856
|
arguments: [
|
|
280
857
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
281
|
-
"APP App CID or
|
|
282
|
-
|
|
858
|
+
"APP App CID or Swarm IPAB URI; the exact CID is saved.",
|
|
859
|
+
],
|
|
860
|
+
options: [
|
|
861
|
+
"--replace Allow changing an existing association.",
|
|
862
|
+
"--swarm URL_OR_ALIAS Write this Swarm registry; repeat for multiple Swarms.",
|
|
283
863
|
],
|
|
284
|
-
options: ["--replace Allow changing an existing association."],
|
|
285
864
|
examples: [
|
|
286
|
-
"ipab register set SCHEMA_CID
|
|
287
|
-
"ipab register set SCHEMA_CID reader
|
|
865
|
+
"ipab register set SCHEMA_CID APP_CID",
|
|
866
|
+
"ipab register set SCHEMA_CID ipab:///apps/reader --swarm work --swarm team",
|
|
288
867
|
],
|
|
289
868
|
notes: [
|
|
290
|
-
"
|
|
869
|
+
"Writes the Name META.registryPath/TYPE_CID directly to the App CID. Open passes only the content CID.",
|
|
870
|
+
"Custom per-association argv is unsupported; adapt the App or use ipab exec APP_CID ARGS.",
|
|
291
871
|
"Does not verify App type support; open checks it before execution.",
|
|
872
|
+
"Without explicit --swarm, writes the saved default Swarm. Swarm writes require HEAD write access.",
|
|
873
|
+
"Multiple Swarms commit sequentially, not atomically; failures report completed targets.",
|
|
292
874
|
],
|
|
293
875
|
},
|
|
294
876
|
"register remove": {
|
|
295
877
|
summary: "Remove a saved content-type association",
|
|
296
878
|
arguments: ["SCHEMA Exact type CID or builtin:node-app.v1."],
|
|
297
|
-
|
|
298
|
-
|
|
879
|
+
options: [
|
|
880
|
+
"--swarm URL_OR_ALIAS Remove from this Swarm registry; repeat for multiple Swarms.",
|
|
881
|
+
],
|
|
882
|
+
examples: [
|
|
883
|
+
"ipab register remove SCHEMA_CID",
|
|
884
|
+
"ipab register remove SCHEMA_CID --swarm work",
|
|
885
|
+
],
|
|
886
|
+
notes: [
|
|
887
|
+
"Without explicit --swarm, removes from the saved default Swarm. Multiple Swarm edits are not atomic.",
|
|
888
|
+
"Does not remove Apps, pins or content.",
|
|
889
|
+
],
|
|
299
890
|
},
|
|
300
891
|
"config get": {
|
|
301
892
|
summary: "Show effective configuration",
|
|
302
893
|
arguments: ["KEY Optional configuration key; omit to show all values."],
|
|
303
|
-
examples: ["ipab config get", "ipab config get store.
|
|
894
|
+
examples: ["ipab config get", "ipab config get store.gateway"],
|
|
304
895
|
},
|
|
305
896
|
"config set": {
|
|
306
897
|
summary: "Save a local configuration value",
|
|
307
898
|
examples: [
|
|
308
|
-
"ipab config set
|
|
899
|
+
"ipab config set pointers.apiKey -",
|
|
900
|
+
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
309
901
|
"ipab config set history.enabled false",
|
|
310
902
|
],
|
|
311
903
|
notes: [
|
|
312
|
-
"store.
|
|
904
|
+
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
905
|
+
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
906
|
+
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
907
|
+
"SQLite state is account-only even without a key. Reading or saving a nonempty key rechecks Unix modes or Windows ACLs.",
|
|
313
908
|
],
|
|
314
909
|
},
|
|
315
910
|
"config reset": {
|
|
316
911
|
summary: "Remove a saved configuration override",
|
|
317
|
-
examples: ["ipab config reset store.
|
|
912
|
+
examples: ["ipab config reset store.gateway"],
|
|
318
913
|
},
|
|
319
914
|
"history list": {
|
|
320
915
|
summary: "List execution history",
|
|
321
916
|
options: [
|
|
322
|
-
"--app APP Filter by App CID
|
|
917
|
+
"--app APP Filter by exact App CID.",
|
|
323
918
|
"--status STATUS succeeded, failed or cancelled.",
|
|
324
919
|
"--since TIME Include runs ended at or after TIME.",
|
|
325
920
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -342,7 +937,7 @@ const commandHelp: Record<
|
|
|
342
937
|
"history remove": {
|
|
343
938
|
summary: "Remove execution records and their logs",
|
|
344
939
|
options: [
|
|
345
|
-
"--app APP Filter by App CID
|
|
940
|
+
"--app APP Filter by exact App CID.",
|
|
346
941
|
"--status STATUS succeeded, failed or cancelled.",
|
|
347
942
|
"--since TIME Include runs ended at or after TIME.",
|
|
348
943
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -362,8 +957,9 @@ const commandHelp: Record<
|
|
|
362
957
|
|
|
363
958
|
export function help(path = ""): string {
|
|
364
959
|
const globalOptions = `Global options (before COMMAND):
|
|
365
|
-
--
|
|
366
|
-
--
|
|
960
|
+
--swarm URL|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
961
|
+
--state-dir PATH Set a dedicated, account-private local state directory
|
|
962
|
+
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
367
963
|
--json Output management/development metadata, not App stdio`;
|
|
368
964
|
const footer =
|
|
369
965
|
"Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
|
|
@@ -377,14 +973,23 @@ Run Apps:
|
|
|
377
973
|
open ${commandHelp.open!.summary}
|
|
378
974
|
|
|
379
975
|
Create:
|
|
380
|
-
|
|
976
|
+
templates ${groups.templates}
|
|
381
977
|
build ${commandHelp.build!.summary}
|
|
382
978
|
bundle ${groups.bundle}
|
|
383
979
|
|
|
384
980
|
Manage:
|
|
981
|
+
doctor ${commandHelp.doctor!.summary}
|
|
982
|
+
profile ${commandHelp.profile!.summary}
|
|
983
|
+
swarm ${groups.swarm}
|
|
984
|
+
skills ${groups.skills}
|
|
985
|
+
search Search formal Names in the current swarm
|
|
986
|
+
publish ${commandHelp.publish!.summary}
|
|
987
|
+
get ${commandHelp.get!.summary}
|
|
385
988
|
pin ${groups.pin}
|
|
989
|
+
unpin ${commandHelp.unpin!.summary}
|
|
386
990
|
register ${groups.register}
|
|
387
991
|
config ${groups.config}
|
|
992
|
+
store ${groups.store}
|
|
388
993
|
history ${groups.history}
|
|
389
994
|
|
|
390
995
|
${globalOptions}
|
|
@@ -402,9 +1007,39 @@ ${footer}`;
|
|
|
402
1007
|
return [
|
|
403
1008
|
`${topic.summary}.\n\nUsage: ipab [GLOBAL_OPTIONS] ${usage}`,
|
|
404
1009
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
405
|
-
...(topic.options
|
|
1010
|
+
...(topic.options
|
|
1011
|
+
? [
|
|
1012
|
+
section(
|
|
1013
|
+
"Options",
|
|
1014
|
+
topic.options.map((line) =>
|
|
1015
|
+
line.startsWith("--refresh")
|
|
1016
|
+
? `${line} Legacy aliases: --force/--no-force.`
|
|
1017
|
+
: line,
|
|
1018
|
+
),
|
|
1019
|
+
),
|
|
1020
|
+
]
|
|
1021
|
+
: []),
|
|
406
1022
|
section("Examples", topic.examples),
|
|
407
|
-
...(
|
|
1023
|
+
...([
|
|
1024
|
+
"swarm status",
|
|
1025
|
+
"swarm members",
|
|
1026
|
+
"swarm update",
|
|
1027
|
+
"swarm resume",
|
|
1028
|
+
"swarm profile",
|
|
1029
|
+
"swarm export",
|
|
1030
|
+
"swarm approve",
|
|
1031
|
+
"swarm pivot grant",
|
|
1032
|
+
"swarm exclude",
|
|
1033
|
+
].includes(path)
|
|
1034
|
+
? [
|
|
1035
|
+
section("Notes", [
|
|
1036
|
+
...(topic.notes ?? []),
|
|
1037
|
+
"Select only with global --swarm URL_OR_ALIAS (before the command), or the saved swarm.default. Neither means an error.",
|
|
1038
|
+
]),
|
|
1039
|
+
]
|
|
1040
|
+
: topic.notes
|
|
1041
|
+
? [section("Notes", topic.notes)]
|
|
1042
|
+
: []),
|
|
408
1043
|
`\n\n-h, --help shows this help. Global options: see 'ipab --help'.\n${footer}`,
|
|
409
1044
|
].join("");
|
|
410
1045
|
}
|
|
@@ -433,6 +1068,25 @@ function printable(text: string): string {
|
|
|
433
1068
|
.join("");
|
|
434
1069
|
}
|
|
435
1070
|
|
|
1071
|
+
export function formatSearchResults(
|
|
1072
|
+
matches: Awaited<ReturnType<typeof searchNames>>["matches"],
|
|
1073
|
+
): string {
|
|
1074
|
+
return matches.length
|
|
1075
|
+
? alignedRows(
|
|
1076
|
+
matches.map((match) => [
|
|
1077
|
+
match.alias ?? match.swarm,
|
|
1078
|
+
match.name,
|
|
1079
|
+
match.targetCid,
|
|
1080
|
+
]),
|
|
1081
|
+
)
|
|
1082
|
+
.map((row, index) => {
|
|
1083
|
+
const match = matches[index]!;
|
|
1084
|
+
return `${row}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`;
|
|
1085
|
+
})
|
|
1086
|
+
.join("\n")
|
|
1087
|
+
: "No matching Names.";
|
|
1088
|
+
}
|
|
1089
|
+
|
|
436
1090
|
function runTime(value: string, field: "start" | "end"): string {
|
|
437
1091
|
const date = new Date(value);
|
|
438
1092
|
if (!Number.isFinite(date.getTime()))
|
|
@@ -461,26 +1115,38 @@ function runDuration(record: Pick<RunRecord, "startedAt" | "endedAt">): string {
|
|
|
461
1115
|
return `${Math.floor(duration / 1000)}s`;
|
|
462
1116
|
}
|
|
463
1117
|
|
|
464
|
-
function
|
|
465
|
-
|
|
1118
|
+
function storageBytes(bytes: number): string {
|
|
1119
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
1120
|
+
let scaled = bytes;
|
|
1121
|
+
let unit = 0;
|
|
1122
|
+
while (scaled >= 1000 && unit < units.length - 1) {
|
|
1123
|
+
scaled /= 1000;
|
|
1124
|
+
unit++;
|
|
1125
|
+
}
|
|
1126
|
+
const exact = bytes.toLocaleString("en-US");
|
|
1127
|
+
return unit === 0
|
|
1128
|
+
? `${exact} bytes`
|
|
1129
|
+
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function alignedRows(rows: string[][]): string[] {
|
|
466
1133
|
const cells = rows.map((row) => row.map(printable));
|
|
467
|
-
const widths =
|
|
468
|
-
cells.reduce(
|
|
469
|
-
(width, row) => Math.max(width, stringWidth(row[column]!)),
|
|
470
|
-
stringWidth(header),
|
|
471
|
-
),
|
|
1134
|
+
const widths = (cells[0] ?? []).map((_, column) =>
|
|
1135
|
+
cells.reduce((width, row) => Math.max(width, stringWidth(row[column]!)), 0),
|
|
472
1136
|
);
|
|
473
|
-
return
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
1137
|
+
return cells.map((row) =>
|
|
1138
|
+
row
|
|
1139
|
+
.map((cell, column) =>
|
|
1140
|
+
column === widths.length - 1
|
|
1141
|
+
? cell
|
|
1142
|
+
: cell.padEnd(cell.length + widths[column]! - stringWidth(cell)),
|
|
1143
|
+
)
|
|
1144
|
+
.join(" "),
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function table(headers: string[], rows: string[][], empty: string): string {
|
|
1149
|
+
return rows.length ? alignedRows([headers, ...rows]).join("\n") : empty;
|
|
484
1150
|
}
|
|
485
1151
|
|
|
486
1152
|
function runDetails(record: RunRecord): string {
|
|
@@ -520,9 +1186,17 @@ interface Parsed {
|
|
|
520
1186
|
options: Record<string, string | boolean>;
|
|
521
1187
|
template?: string[];
|
|
522
1188
|
parameters?: string[];
|
|
1189
|
+
registrySwarms?: string[];
|
|
1190
|
+
agents?: string[];
|
|
523
1191
|
help: boolean;
|
|
524
1192
|
version: boolean;
|
|
525
1193
|
}
|
|
1194
|
+
function validateRefreshOptions(options: Parsed["options"]): void {
|
|
1195
|
+
const positive = ["refresh", "force"].find((key) => options[key]);
|
|
1196
|
+
const negative = ["no-refresh", "no-force"].find((key) => options[key]);
|
|
1197
|
+
if (positive && negative)
|
|
1198
|
+
syntax(`--${positive} and --${negative} are mutually exclusive.`);
|
|
1199
|
+
}
|
|
526
1200
|
|
|
527
1201
|
async function closeStore(
|
|
528
1202
|
store: IpfsStore | undefined,
|
|
@@ -543,6 +1217,7 @@ async function closeStore(
|
|
|
543
1217
|
export function parse(argv: readonly string[]): Parsed {
|
|
544
1218
|
const tokens = [...argv];
|
|
545
1219
|
const flags: GlobalOptions = { json: false };
|
|
1220
|
+
const swarms: string[] = [];
|
|
546
1221
|
while (tokens[0]?.startsWith("-")) {
|
|
547
1222
|
const flag = tokens.shift()!;
|
|
548
1223
|
if (flag === "-h" || flag === "--help")
|
|
@@ -566,16 +1241,35 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
566
1241
|
};
|
|
567
1242
|
}
|
|
568
1243
|
if (flag === "--json") flags.json = true;
|
|
569
|
-
else if (flag === "--
|
|
1244
|
+
else if (flag === "--store-rpc")
|
|
1245
|
+
syntax(
|
|
1246
|
+
"Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.",
|
|
1247
|
+
);
|
|
1248
|
+
else if (
|
|
1249
|
+
flag === "--state-dir" ||
|
|
1250
|
+
flag === "--store-gateway" ||
|
|
1251
|
+
flag === "--swarm"
|
|
1252
|
+
) {
|
|
570
1253
|
const value = tokens.shift();
|
|
571
1254
|
if (!value || value.startsWith("-")) syntax(`${flag} needs a value.`);
|
|
572
1255
|
if (flag === "--state-dir") flags.stateDir = value;
|
|
573
|
-
else {
|
|
574
|
-
flags.
|
|
1256
|
+
else if (flag === "--swarm") {
|
|
1257
|
+
flags.swarm = value;
|
|
1258
|
+
swarms.push(value);
|
|
1259
|
+
} else {
|
|
1260
|
+
flags.storeGateway = publicUrl(value);
|
|
575
1261
|
}
|
|
576
1262
|
} else syntax(`Unknown global option "${flag}".`);
|
|
577
1263
|
}
|
|
578
1264
|
const group = tokens.shift() ?? "";
|
|
1265
|
+
if (group === "init")
|
|
1266
|
+
syntax(
|
|
1267
|
+
"Root init was removed. Use ipab templates render TEMPLATE NAME [DIR]; TEMPLATE is the first positional argument, not --template.",
|
|
1268
|
+
);
|
|
1269
|
+
if (group === "templates" && swarms.length > 1)
|
|
1270
|
+
syntax("Templates accepts only one global --swarm, before the command.");
|
|
1271
|
+
if (group === "daemon" && swarms.length)
|
|
1272
|
+
syntax("daemon manages all registered Swarms and does not accept --swarm.");
|
|
579
1273
|
const result: Parsed = {
|
|
580
1274
|
flags,
|
|
581
1275
|
path: group,
|
|
@@ -583,14 +1277,22 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
583
1277
|
options: {},
|
|
584
1278
|
help: !group,
|
|
585
1279
|
version: false,
|
|
1280
|
+
...(group === "register" ? { registrySwarms: swarms } : {}),
|
|
586
1281
|
};
|
|
587
1282
|
if (!group) return result;
|
|
588
1283
|
if (group === "exec") {
|
|
589
1284
|
if (flags.json) syntax("--json is not supported for exec/open.");
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
1285
|
+
while (
|
|
1286
|
+
["--log", "--force", "--no-force", "--refresh", "--no-refresh"].includes(
|
|
1287
|
+
tokens[0] ?? "",
|
|
1288
|
+
)
|
|
1289
|
+
) {
|
|
1290
|
+
const option = tokens.shift()!.slice(2);
|
|
1291
|
+
if (Object.hasOwn(result.options, option))
|
|
1292
|
+
syntax(`Duplicate option --${option}.`);
|
|
1293
|
+
result.options[option] = true;
|
|
593
1294
|
}
|
|
1295
|
+
validateRefreshOptions(result.options);
|
|
594
1296
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
595
1297
|
result.help = true;
|
|
596
1298
|
return result;
|
|
@@ -600,17 +1302,66 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
600
1302
|
result.positional = tokens;
|
|
601
1303
|
return result;
|
|
602
1304
|
}
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
1305
|
+
if (
|
|
1306
|
+
![
|
|
1307
|
+
"open",
|
|
1308
|
+
"build",
|
|
1309
|
+
"publish",
|
|
1310
|
+
"get",
|
|
1311
|
+
"search",
|
|
1312
|
+
"doctor",
|
|
1313
|
+
"daemon",
|
|
1314
|
+
"profile",
|
|
1315
|
+
"unpin",
|
|
1316
|
+
].includes(group)
|
|
1317
|
+
) {
|
|
1318
|
+
if (
|
|
1319
|
+
![
|
|
1320
|
+
"bundle",
|
|
1321
|
+
"pin",
|
|
1322
|
+
"register",
|
|
1323
|
+
"templates",
|
|
1324
|
+
"config",
|
|
1325
|
+
"history",
|
|
1326
|
+
"store",
|
|
1327
|
+
"swarm",
|
|
1328
|
+
"skills",
|
|
1329
|
+
].includes(group)
|
|
1330
|
+
)
|
|
1331
|
+
syntax(
|
|
1332
|
+
`Unknown command "${group}".${group === "setup" ? " Run ipab doctor to inspect, or ipab doctor --fix to prepare this device." : " Run ipab --help."}`,
|
|
1333
|
+
);
|
|
1334
|
+
if (group === "pin" && !["list", "show"].includes(tokens[0] ?? "")) {
|
|
1335
|
+
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
1336
|
+
result.help = true;
|
|
1337
|
+
return result;
|
|
1338
|
+
}
|
|
1339
|
+
} else if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
607
1340
|
result.help = true;
|
|
608
1341
|
return result;
|
|
1342
|
+
} else result.path = `${group} ${tokens.shift()!}`;
|
|
1343
|
+
if (result.path === "swarm pivot") {
|
|
1344
|
+
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
1345
|
+
result.help = true;
|
|
1346
|
+
return result;
|
|
1347
|
+
}
|
|
1348
|
+
result.path = `swarm pivot ${tokens.shift()!}`;
|
|
609
1349
|
}
|
|
610
|
-
result.path = `${group} ${tokens.shift()!}`;
|
|
611
1350
|
} else if (group === "open" && flags.json)
|
|
612
1351
|
syntax("--json is not supported for exec/open.");
|
|
1352
|
+
else if (group === "daemon" && tokens[0] === "ui") {
|
|
1353
|
+
tokens.shift();
|
|
1354
|
+
result.path = "daemon ui";
|
|
1355
|
+
}
|
|
1356
|
+
if (result.path === "swarm add")
|
|
1357
|
+
syntax(
|
|
1358
|
+
"swarm add was removed. Use ipab swarm set ALIAS CONFIG_URL for local naming, then ipab swarm request ALIAS to request membership.",
|
|
1359
|
+
);
|
|
613
1360
|
if (!commands[result.path]) syntax(`Unknown command "${result.path}".`);
|
|
1361
|
+
if (group === "skills" && swarms.length > 1)
|
|
1362
|
+
syntax(
|
|
1363
|
+
"Skills operations select exactly one Swarm; repeated --swarm is not supported.",
|
|
1364
|
+
);
|
|
614
1365
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
615
1366
|
if (separator >= 0) result.template = tokens.splice(separator + 1);
|
|
616
1367
|
if (separator >= 0) tokens.splice(separator);
|
|
@@ -618,70 +1369,235 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
618
1369
|
result.help = true;
|
|
619
1370
|
return result;
|
|
620
1371
|
}
|
|
621
|
-
|
|
622
|
-
result.path === "
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
1372
|
+
if (
|
|
1373
|
+
result.path === "config set" &&
|
|
1374
|
+
tokens.includes("pointers.apiKey") &&
|
|
1375
|
+
!(tokens.length === 2 && tokens[1] === "-")
|
|
1376
|
+
)
|
|
1377
|
+
syntax(
|
|
1378
|
+
"API key must be provided through '-' and piped stdin; never pass it in command arguments.",
|
|
1379
|
+
);
|
|
1380
|
+
const booleans = result.path.startsWith("skills ")
|
|
1381
|
+
? result.path === "skills sync"
|
|
1382
|
+
? ["dry-run", "yes", "override-existing", "force", "no-force"]
|
|
1383
|
+
: ["force", "no-force"]
|
|
1384
|
+
: result.path === "doctor"
|
|
1385
|
+
? ["fix", "yes"]
|
|
1386
|
+
: result.path === "bundle build"
|
|
1387
|
+
? ["replace", "schema-only", "no-import"]
|
|
1388
|
+
: result.path === "build"
|
|
1389
|
+
? ["replace", "no-import"]
|
|
1390
|
+
: result.path === "publish"
|
|
1391
|
+
? ["snapshot"]
|
|
1392
|
+
: [
|
|
1393
|
+
"get",
|
|
1394
|
+
"templates render",
|
|
1395
|
+
"templates list",
|
|
1396
|
+
"templates show",
|
|
1397
|
+
].includes(result.path)
|
|
1398
|
+
? result.path === "templates render"
|
|
1399
|
+
? ["force", "no-force"]
|
|
1400
|
+
: result.path === "get"
|
|
1401
|
+
? ["raw", "force", "no-force"]
|
|
1402
|
+
: ["force", "no-force"]
|
|
1403
|
+
: result.path === "search"
|
|
1404
|
+
? ["all", "current", "force", "no-force"]
|
|
1405
|
+
: result.path === "swarm request"
|
|
1406
|
+
? ["pivot"]
|
|
1407
|
+
: result.path === "swarm approve"
|
|
1408
|
+
? ["yes", "again", "pivot"]
|
|
1409
|
+
: ["swarm status", "swarm members"].includes(result.path)
|
|
1410
|
+
? ["local", "force", "no-force"]
|
|
1411
|
+
: [
|
|
1412
|
+
"swarm exclude",
|
|
1413
|
+
"swarm set",
|
|
1414
|
+
"swarm pivot grant",
|
|
1415
|
+
].includes(result.path)
|
|
1416
|
+
? ["yes"]
|
|
1417
|
+
: result.path === "register set"
|
|
1418
|
+
? ["replace"]
|
|
1419
|
+
: result.path === "history remove"
|
|
1420
|
+
? ["yes"]
|
|
1421
|
+
: result.path === "open"
|
|
1422
|
+
? ["log", "raw", "force", "no-force"]
|
|
1423
|
+
: result.path === "pin"
|
|
1424
|
+
? ["force", "no-force"]
|
|
1425
|
+
: result.path === "daemon ui"
|
|
1426
|
+
? ["open"]
|
|
1427
|
+
: [];
|
|
1428
|
+
if (booleans.includes("force")) booleans.push("refresh", "no-refresh");
|
|
633
1429
|
const values =
|
|
634
|
-
result.path === "
|
|
635
|
-
? ["
|
|
636
|
-
: result.path === "
|
|
1430
|
+
result.path === "swarm create"
|
|
1431
|
+
? ["service", "resume", "name", "description", "alias"]
|
|
1432
|
+
: result.path === "swarm request"
|
|
637
1433
|
? ["output"]
|
|
638
|
-
: result.path === "
|
|
639
|
-
? ["
|
|
640
|
-
: result.path === "
|
|
641
|
-
? ["
|
|
642
|
-
: result.path === "
|
|
643
|
-
? ["
|
|
644
|
-
:
|
|
1434
|
+
: result.path === "swarm export"
|
|
1435
|
+
? ["output"]
|
|
1436
|
+
: result.path === "swarm profile"
|
|
1437
|
+
? ["address", "pivot"]
|
|
1438
|
+
: result.path === "swarm update" || result.path === "profile"
|
|
1439
|
+
? ["name", "description"]
|
|
1440
|
+
: result.path === "swarm approve"
|
|
1441
|
+
? []
|
|
1442
|
+
: ["publish", "templates set", "templates remove"].includes(
|
|
1443
|
+
result.path,
|
|
1444
|
+
)
|
|
1445
|
+
? ["expect"]
|
|
1446
|
+
: result.path === "get"
|
|
1447
|
+
? ["output"]
|
|
1448
|
+
: result.path === "search"
|
|
1449
|
+
? ["prefix", "kind", "schema", "limit", "offset"]
|
|
1450
|
+
: result.path === "templates render"
|
|
1451
|
+
? ["description"]
|
|
1452
|
+
: result.path === "bundle build" ||
|
|
1453
|
+
result.path === "build"
|
|
1454
|
+
? ["output"]
|
|
1455
|
+
: result.path === "history list"
|
|
1456
|
+
? [
|
|
1457
|
+
"app",
|
|
1458
|
+
"status",
|
|
1459
|
+
"since",
|
|
1460
|
+
"until",
|
|
1461
|
+
"limit",
|
|
1462
|
+
"before",
|
|
1463
|
+
]
|
|
1464
|
+
: result.path === "history remove"
|
|
1465
|
+
? ["app", "status", "since", "until"]
|
|
1466
|
+
: [];
|
|
645
1467
|
while (tokens.length) {
|
|
646
1468
|
const value = tokens.shift()!;
|
|
647
|
-
if (
|
|
1469
|
+
if (
|
|
1470
|
+
result.path === "swarm exclude" &&
|
|
1471
|
+
/^--[A-Za-z0-9_-]{41}$/.test(value)
|
|
1472
|
+
) {
|
|
1473
|
+
result.positional.push(value);
|
|
1474
|
+
} else if (value.startsWith("--") || value === "-o") {
|
|
648
1475
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
649
|
-
if (result.path
|
|
1476
|
+
if (result.path.startsWith("daemon") && option === "swarm")
|
|
1477
|
+
syntax(
|
|
1478
|
+
"daemon manages all registered Swarms and does not accept --swarm.",
|
|
1479
|
+
);
|
|
1480
|
+
if (result.path === "skills sync" && option === "agent") {
|
|
1481
|
+
const input = tokens.shift();
|
|
1482
|
+
if (!input || input.startsWith("-")) syntax("--agent needs a value.");
|
|
1483
|
+
(result.agents ??= []).push(input);
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
if (result.path.startsWith("register ") && option === "swarm") {
|
|
1487
|
+
const input = tokens.shift();
|
|
1488
|
+
if (!input || input.startsWith("-")) syntax("--swarm needs a value.");
|
|
1489
|
+
result.registrySwarms!.push(input);
|
|
1490
|
+
flags.swarm = input;
|
|
1491
|
+
continue;
|
|
1492
|
+
}
|
|
1493
|
+
if (result.path === "templates render" && option === "template")
|
|
1494
|
+
syntax(
|
|
1495
|
+
"--template was removed. Use ipab templates render TEMPLATE NAME [DIR], with TEMPLATE first.",
|
|
1496
|
+
);
|
|
1497
|
+
if (result.path === "templates render" && option === "param") {
|
|
650
1498
|
const input = tokens.shift();
|
|
651
1499
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
652
1500
|
syntax("--param requires KEY=VALUE.");
|
|
653
1501
|
(result.parameters ??= []).push(input);
|
|
654
1502
|
continue;
|
|
655
1503
|
}
|
|
1504
|
+
if (result.path === "swarm request" && option === "alias")
|
|
1505
|
+
syntax(
|
|
1506
|
+
"swarm request --alias was removed. First run ipab swarm set ALIAS CONFIG_URL, then ipab swarm request ALIAS.",
|
|
1507
|
+
);
|
|
656
1508
|
if (Object.hasOwn(result.options, option))
|
|
657
1509
|
syntax(`Duplicate option ${value}.`);
|
|
658
1510
|
if (booleans.includes(option)) result.options[option] = true;
|
|
659
1511
|
else if (values.includes(option)) {
|
|
660
1512
|
const input = tokens.shift();
|
|
661
|
-
if (
|
|
1513
|
+
if (
|
|
1514
|
+
input === undefined ||
|
|
1515
|
+
(input.startsWith("--") &&
|
|
1516
|
+
!(option === "resume" && /^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
1517
|
+
(input === "" &&
|
|
1518
|
+
!["swarm update", "profile", "templates render"].includes(
|
|
1519
|
+
result.path,
|
|
1520
|
+
))
|
|
1521
|
+
)
|
|
1522
|
+
syntax(`${value} needs a value.`);
|
|
662
1523
|
result.options[option] = input;
|
|
663
|
-
} else
|
|
1524
|
+
} else if (
|
|
1525
|
+
option === "name" &&
|
|
1526
|
+
["swarm profile", "swarm request"].includes(result.path)
|
|
1527
|
+
)
|
|
1528
|
+
syntax(
|
|
1529
|
+
`Personal names are account-wide. Use ipab profile --name NAME instead.${result.path === "swarm profile" ? " For network configuration, use ipab --swarm URL_OR_ALIAS swarm profile --address MULTIADDR." : ""}`,
|
|
1530
|
+
);
|
|
1531
|
+
else syntax(`Unknown option "${value}".`);
|
|
664
1532
|
} else result.positional.push(value);
|
|
665
1533
|
}
|
|
1534
|
+
validateRefreshOptions(result.options);
|
|
1535
|
+
if (
|
|
1536
|
+
result.path === "search" &&
|
|
1537
|
+
result.options.current &&
|
|
1538
|
+
flags.swarm !== undefined
|
|
1539
|
+
)
|
|
1540
|
+
syntax("--current and --swarm are mutually exclusive.");
|
|
1541
|
+
if (
|
|
1542
|
+
result.path === "search" &&
|
|
1543
|
+
result.options.all &&
|
|
1544
|
+
(result.options.current || flags.swarm !== undefined)
|
|
1545
|
+
)
|
|
1546
|
+
syntax("--all is mutually exclusive with --current and --swarm.");
|
|
1547
|
+
if (
|
|
1548
|
+
result.path === "register list" &&
|
|
1549
|
+
(result.registrySwarms?.length ?? 0) > 1
|
|
1550
|
+
)
|
|
1551
|
+
syntax(
|
|
1552
|
+
"register list accepts --swarm at most once. Select one Swarm or omit it to use the current Swarm.",
|
|
1553
|
+
);
|
|
666
1554
|
const counts: Record<string, [number, number]> = {
|
|
667
|
-
|
|
1555
|
+
daemon: [0, 0],
|
|
1556
|
+
"daemon ui": [0, 0],
|
|
1557
|
+
doctor: [0, 0],
|
|
1558
|
+
"skills list": [0, 0],
|
|
1559
|
+
"skills sync": [0, Number.MAX_SAFE_INTEGER],
|
|
1560
|
+
profile: [0, 0],
|
|
1561
|
+
"swarm create": [0, 0],
|
|
1562
|
+
"swarm request": [1, 1],
|
|
1563
|
+
"swarm approve": [1, 1],
|
|
1564
|
+
"swarm pivot grant": [1, 1],
|
|
1565
|
+
"swarm export": [0, 0],
|
|
1566
|
+
"swarm exclude": [1, 1],
|
|
1567
|
+
"swarm resume": [0, 0],
|
|
1568
|
+
"swarm profile": [0, 0],
|
|
1569
|
+
"swarm status": [0, 0],
|
|
1570
|
+
"swarm members": [0, 0],
|
|
1571
|
+
"swarm list": [0, 0],
|
|
1572
|
+
"swarm set": [2, 2],
|
|
1573
|
+
"swarm use": [1, 1],
|
|
1574
|
+
"swarm remove": [1, 1],
|
|
1575
|
+
"swarm update": [0, 0],
|
|
1576
|
+
publish: [2, 2],
|
|
1577
|
+
get: [1, 1],
|
|
1578
|
+
search: [1, 1],
|
|
1579
|
+
"templates render": [2, 3],
|
|
668
1580
|
build: [0, 1],
|
|
669
|
-
"bundle init": [2, 2],
|
|
670
1581
|
"bundle build": [1, 1],
|
|
671
1582
|
"bundle inspect": [1, 1],
|
|
672
1583
|
"bundle import": [1, 1],
|
|
673
1584
|
open: [1, 1],
|
|
674
|
-
|
|
675
|
-
|
|
1585
|
+
pin: [1, 1],
|
|
1586
|
+
unpin: [1, 1],
|
|
676
1587
|
"pin list": [0, 0],
|
|
677
1588
|
"pin show": [1, 1],
|
|
678
|
-
"pin rename": [2, 2],
|
|
679
1589
|
"register list": [0, 0],
|
|
680
1590
|
"register set": [2, 2],
|
|
681
1591
|
"register remove": [1, 1],
|
|
1592
|
+
"templates list": [0, 0],
|
|
1593
|
+
"templates show": [1, 1],
|
|
1594
|
+
"templates set": [2, 2],
|
|
1595
|
+
"templates remove": [1, 1],
|
|
682
1596
|
"config get": [0, 1],
|
|
683
1597
|
"config set": [2, 2],
|
|
684
1598
|
"config reset": [1, 1],
|
|
1599
|
+
"store usage": [0, 0],
|
|
1600
|
+
"store gc": [0, 0],
|
|
685
1601
|
"history list": [0, 0],
|
|
686
1602
|
"history show": [1, 1],
|
|
687
1603
|
"history remove": [0, Number.MAX_SAFE_INTEGER],
|
|
@@ -689,13 +1605,28 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
689
1605
|
if (result.options["with-source"] && result.options["without-source"])
|
|
690
1606
|
syntax("--with-source and --without-source are mutually exclusive.");
|
|
691
1607
|
const [minimum, maximum] = counts[result.path]!;
|
|
692
|
-
if (result.
|
|
693
|
-
syntax(
|
|
1608
|
+
if (result.path === "profile" && flags.swarm !== undefined)
|
|
1609
|
+
syntax("Personal profile is account-wide; do not pass --swarm.");
|
|
694
1610
|
if (
|
|
695
|
-
result.
|
|
696
|
-
|
|
1611
|
+
result.positional.length &&
|
|
1612
|
+
[
|
|
1613
|
+
"swarm status",
|
|
1614
|
+
"swarm update",
|
|
1615
|
+
"swarm resume",
|
|
1616
|
+
"swarm profile",
|
|
1617
|
+
"swarm export",
|
|
1618
|
+
"swarm members",
|
|
1619
|
+
].includes(result.path)
|
|
697
1620
|
)
|
|
698
|
-
syntax(
|
|
1621
|
+
syntax(
|
|
1622
|
+
`Swarm target positionals are no longer supported. Use ipab --swarm URL_OR_ALIAS ${result.path} instead.`,
|
|
1623
|
+
);
|
|
1624
|
+
if (result.positional.length < minimum || result.positional.length > maximum)
|
|
1625
|
+
syntax(`Invalid arguments.\n${help(result.path)}`);
|
|
1626
|
+
if (result.template)
|
|
1627
|
+
syntax(
|
|
1628
|
+
'Custom per-association argv is unsupported. Remove "-- TEMPLATE..."; open passes only the content CID. Adapt the App or use ipab exec APP_CID ARGS.',
|
|
1629
|
+
);
|
|
699
1630
|
if (result.path === "history remove") {
|
|
700
1631
|
const selected = values.some((value) =>
|
|
701
1632
|
Object.hasOwn(result.options, value),
|
|
@@ -707,26 +1638,59 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
707
1638
|
syntax("history remove requires explicit IDs OR filters, not both.");
|
|
708
1639
|
}
|
|
709
1640
|
// Validate syntactic values before state access, let alone a backend connection.
|
|
710
|
-
if (
|
|
711
|
-
|
|
712
|
-
if (result.path
|
|
713
|
-
|
|
1641
|
+
if (["pin", "unpin", "pin show"].includes(result.path)) {
|
|
1642
|
+
const reference = result.positional[0]!;
|
|
1643
|
+
if (reference.startsWith("builtin:") && result.path !== "pin show")
|
|
1644
|
+
syntax(
|
|
1645
|
+
"Packaged builtin references are read-only; they cannot be pinned or unpinned.",
|
|
1646
|
+
);
|
|
1647
|
+
if (
|
|
1648
|
+
!(result.path === "pin show" && reference.startsWith("builtin:")) &&
|
|
1649
|
+
!parseNameReference(reference)
|
|
1650
|
+
)
|
|
1651
|
+
exactCid(reference);
|
|
1652
|
+
}
|
|
1653
|
+
if (result.path === "publish") {
|
|
1654
|
+
formalName(result.positional[0]!);
|
|
1655
|
+
if (typeof result.options.expect === "string")
|
|
1656
|
+
exactCid(result.options.expect);
|
|
1657
|
+
if (result.options.expect && result.options.snapshot)
|
|
1658
|
+
syntax(
|
|
1659
|
+
"--snapshot is initial-only and cannot be combined with --expect.",
|
|
1660
|
+
);
|
|
714
1661
|
}
|
|
715
1662
|
if (
|
|
716
|
-
result.
|
|
717
|
-
|
|
718
|
-
)
|
|
719
|
-
|
|
1663
|
+
result.path.startsWith("templates ") &&
|
|
1664
|
+
result.path !== "templates render"
|
|
1665
|
+
) {
|
|
1666
|
+
if (result.positional[0] !== undefined) templateName(result.positional[0]);
|
|
1667
|
+
if (typeof result.options.expect === "string")
|
|
1668
|
+
exactCid(result.options.expect);
|
|
1669
|
+
if (result.path === "templates remove" && !result.options.expect)
|
|
1670
|
+
syntax("templates remove requires --expect OLD_TARGET_CID.");
|
|
1671
|
+
}
|
|
720
1672
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
721
|
-
if (
|
|
1673
|
+
if (
|
|
1674
|
+
!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
1675
|
+
!(result.path === "config reset" && result.positional[0] === "store.rpc")
|
|
1676
|
+
)
|
|
722
1677
|
configKey(result.positional[0]);
|
|
723
|
-
if (result.path === "config set")
|
|
724
|
-
|
|
1678
|
+
if (result.path === "config set") {
|
|
1679
|
+
if (result.positional[0] === "pointers.apiKey") {
|
|
1680
|
+
if (result.positional[1] !== "-")
|
|
1681
|
+
syntax(
|
|
1682
|
+
"Set pointers.apiKey using '-' and piped stdin; never put the key in command-line arguments.",
|
|
1683
|
+
);
|
|
1684
|
+
} else
|
|
1685
|
+
parseValue(configKey(result.positional[0]), result.positional[1], true);
|
|
1686
|
+
}
|
|
725
1687
|
}
|
|
726
1688
|
if (typeof result.options.limit === "string")
|
|
727
1689
|
parseValue("history.limit", result.options.limit, true);
|
|
728
1690
|
if (result.options.output === "-")
|
|
729
1691
|
syntax("CAR output requires a file path; binary stdout is not supported.");
|
|
1692
|
+
if (result.path === "doctor" && result.options.yes && !result.options.fix)
|
|
1693
|
+
syntax("doctor --yes requires --fix.");
|
|
730
1694
|
return result;
|
|
731
1695
|
}
|
|
732
1696
|
|
|
@@ -738,6 +1702,7 @@ async function performCli(
|
|
|
738
1702
|
let state: State | undefined;
|
|
739
1703
|
let store: IpfsStore | undefined;
|
|
740
1704
|
let appExitCode: number | undefined;
|
|
1705
|
+
let readContext: SwarmContext | undefined;
|
|
741
1706
|
try {
|
|
742
1707
|
const parsed = parse(argv);
|
|
743
1708
|
if (parsed.help) {
|
|
@@ -758,22 +1723,1073 @@ async function performCli(
|
|
|
758
1723
|
}
|
|
759
1724
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
760
1725
|
syntax("Non-interactive history remove requires --yes.");
|
|
1726
|
+
if (parsed.path === "doctor") {
|
|
1727
|
+
const controller = new AbortController();
|
|
1728
|
+
const interrupt = () => {
|
|
1729
|
+
controller.abort(new HostError("Doctor interrupted.", 130, "ABORTED"));
|
|
1730
|
+
};
|
|
1731
|
+
const terminate = () => {
|
|
1732
|
+
controller.abort(new HostError("Doctor terminated.", 143, "ABORTED"));
|
|
1733
|
+
};
|
|
1734
|
+
process.once("SIGINT", interrupt);
|
|
1735
|
+
process.once("SIGTERM", terminate);
|
|
1736
|
+
try {
|
|
1737
|
+
const result = await doctorDevice(
|
|
1738
|
+
stateLocation(parsed.flags, env).path,
|
|
1739
|
+
env,
|
|
1740
|
+
{
|
|
1741
|
+
diagnostic: (text, progress) => {
|
|
1742
|
+
io.err(text, progress);
|
|
1743
|
+
},
|
|
1744
|
+
signal: controller.signal,
|
|
1745
|
+
fix: Boolean(parsed.options.fix),
|
|
1746
|
+
yes: Boolean(parsed.options.yes),
|
|
1747
|
+
tty: io.tty,
|
|
1748
|
+
confirm: (text, signal) => io.confirm(text, signal),
|
|
1749
|
+
},
|
|
1750
|
+
);
|
|
1751
|
+
io.out(parsed.flags.json ? JSON.stringify(result) : doctorText(result));
|
|
1752
|
+
return result.ready ? 0 : 1;
|
|
1753
|
+
} finally {
|
|
1754
|
+
process.removeListener("SIGINT", interrupt);
|
|
1755
|
+
process.removeListener("SIGTERM", terminate);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
if (parsed.path === "daemon ui") {
|
|
1759
|
+
const stateDir = stateLocation(parsed.flags, env).path;
|
|
1760
|
+
const endpoint = await daemonEndpoint(stateDir);
|
|
1761
|
+
if (!endpoint)
|
|
1762
|
+
throw new HostError(
|
|
1763
|
+
"IPAB daemon is not running for this state directory. Start it with `ipab daemon` or run a Swarm network command.",
|
|
1764
|
+
);
|
|
1765
|
+
const opened = Boolean(parsed.options.open);
|
|
1766
|
+
if (opened) openLoopbackUrl(endpoint.url);
|
|
1767
|
+
io.out(
|
|
1768
|
+
parsed.flags.json
|
|
1769
|
+
? JSON.stringify({ ...endpoint, opened })
|
|
1770
|
+
: opened
|
|
1771
|
+
? `Opened daemon status UI: ${endpoint.url}`
|
|
1772
|
+
: endpoint.url,
|
|
1773
|
+
);
|
|
1774
|
+
return 0;
|
|
1775
|
+
}
|
|
761
1776
|
const builtins = await builtinContent();
|
|
762
|
-
state = new State(
|
|
763
|
-
|
|
1777
|
+
state = new State(
|
|
1778
|
+
stateLocation(parsed.flags, env).path,
|
|
1779
|
+
builtins.pins,
|
|
1780
|
+
env,
|
|
1781
|
+
);
|
|
1782
|
+
if (
|
|
1783
|
+
parsed.path === "config reset" &&
|
|
1784
|
+
parsed.positional[0] === "store.rpc"
|
|
1785
|
+
) {
|
|
1786
|
+
state.resetConfig("store.rpc");
|
|
1787
|
+
io.out(
|
|
1788
|
+
parsed.flags.json
|
|
1789
|
+
? JSON.stringify({ reset: ["store.rpc"] })
|
|
1790
|
+
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.",
|
|
1791
|
+
);
|
|
1792
|
+
return 0;
|
|
1793
|
+
}
|
|
1794
|
+
const items = effectiveConfig(
|
|
1795
|
+
state.config({
|
|
1796
|
+
includeSecrets: ![
|
|
1797
|
+
"swarm members",
|
|
1798
|
+
"profile",
|
|
1799
|
+
"swarm status",
|
|
1800
|
+
"swarm set",
|
|
1801
|
+
].includes(parsed.path),
|
|
1802
|
+
}),
|
|
1803
|
+
parsed.flags,
|
|
1804
|
+
env,
|
|
1805
|
+
(reference) => state!.resolveSwarm(reference),
|
|
1806
|
+
);
|
|
764
1807
|
const value = (key: string) =>
|
|
765
1808
|
items.find((item) => item.key === key)!.value;
|
|
766
1809
|
const emit = (result: unknown, human: string) => {
|
|
767
1810
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
768
1811
|
};
|
|
769
1812
|
const [first, second] = parsed.positional;
|
|
1813
|
+
const selectedSwarm =
|
|
1814
|
+
value("swarm.default") === null
|
|
1815
|
+
? undefined
|
|
1816
|
+
: String(value("swarm.default"));
|
|
1817
|
+
const requireSwarm = () => {
|
|
1818
|
+
if (!selectedSwarm)
|
|
1819
|
+
syntax(
|
|
1820
|
+
"Select a Swarm with ipab --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.",
|
|
1821
|
+
);
|
|
1822
|
+
return selectedSwarm;
|
|
1823
|
+
};
|
|
1824
|
+
const swarmContext = (): SwarmContext => ({
|
|
1825
|
+
get store() {
|
|
1826
|
+
return store!;
|
|
1827
|
+
},
|
|
1828
|
+
set store(next) {
|
|
1829
|
+
store = next;
|
|
1830
|
+
},
|
|
1831
|
+
state: state!,
|
|
1832
|
+
env,
|
|
1833
|
+
stateDir: stateLocation(parsed.flags, env).path,
|
|
1834
|
+
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1835
|
+
syncInterval: Number(value("swarm.syncInterval")),
|
|
1836
|
+
listen: value("swarm.listen") === "loopback" ? "loopback" : "lan",
|
|
1837
|
+
...(items.find((item) => item.key === "swarm.pivot")!.source === "default"
|
|
1838
|
+
? {}
|
|
1839
|
+
: { pivot: Boolean(value("swarm.pivot")) }),
|
|
1840
|
+
...(parsed.path === "daemon"
|
|
1841
|
+
? {
|
|
1842
|
+
daemonReady: (status, onListen) =>
|
|
1843
|
+
serveDaemon(stateLocation(parsed.flags, env).path, {
|
|
1844
|
+
port: Number(value("daemon.uiPort")),
|
|
1845
|
+
...(status ? { status } : {}),
|
|
1846
|
+
...(onListen ? { onListen } : {}),
|
|
1847
|
+
}),
|
|
1848
|
+
}
|
|
1849
|
+
: {
|
|
1850
|
+
ensureDaemon: () =>
|
|
1851
|
+
ensureDaemon(
|
|
1852
|
+
stateLocation(parsed.flags, env).path,
|
|
1853
|
+
env,
|
|
1854
|
+
(text) => {
|
|
1855
|
+
io.err(text);
|
|
1856
|
+
},
|
|
1857
|
+
),
|
|
1858
|
+
}),
|
|
1859
|
+
forceRefresh:
|
|
1860
|
+
parsed.options.refresh || parsed.options.force
|
|
1861
|
+
? true
|
|
1862
|
+
: parsed.options["no-refresh"] || parsed.options["no-force"]
|
|
1863
|
+
? false
|
|
1864
|
+
: Boolean(value("swarm.forceRefresh")),
|
|
1865
|
+
diagnostic: (text) => {
|
|
1866
|
+
io.err(text);
|
|
1867
|
+
},
|
|
1868
|
+
...(typeof value("pointers.service") === "string"
|
|
1869
|
+
? { pointerService: String(value("pointers.service")) }
|
|
1870
|
+
: {}),
|
|
1871
|
+
...(typeof value("pointers.apiKey") === "string"
|
|
1872
|
+
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1873
|
+
: {}),
|
|
1874
|
+
});
|
|
770
1875
|
const filter = parsed.path.startsWith("history ")
|
|
771
1876
|
? filters(state, parsed.options)
|
|
772
1877
|
: {};
|
|
1878
|
+
const selection = () => {
|
|
1879
|
+
const saved = state!.config({ includeSecrets: false });
|
|
1880
|
+
const current = effectiveConfig(saved, parsed.flags, env, (reference) =>
|
|
1881
|
+
state!.resolveSwarm(reference),
|
|
1882
|
+
).find((item) => item.key === "swarm.default")!;
|
|
1883
|
+
return {
|
|
1884
|
+
savedCurrent: saved["swarm.default"] ?? null,
|
|
1885
|
+
effectiveCurrent: current.value,
|
|
1886
|
+
source: current.source,
|
|
1887
|
+
};
|
|
1888
|
+
};
|
|
1889
|
+
if (parsed.path === "open" || parsed.path.startsWith("register ")) {
|
|
1890
|
+
if (state.legacyRegistrationCount)
|
|
1891
|
+
io.err(
|
|
1892
|
+
`Legacy User registrations are inactive. ${state.legacyRegistrationCount} entries are preserved in legacy_user_registrations in the state database under ${state.directory}; nothing was uploaded or deleted. Custom per-association argv is unsupported. Review the archived values and explicitly run ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS to publish only intended associations.`,
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
if (state.legacyPinCount)
|
|
1896
|
+
io.err(
|
|
1897
|
+
`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.`,
|
|
1898
|
+
);
|
|
1899
|
+
if (
|
|
1900
|
+
parsed.path.startsWith("templates ") &&
|
|
1901
|
+
parsed.path !== "templates render"
|
|
1902
|
+
) {
|
|
1903
|
+
const configUrl = requireSwarm();
|
|
1904
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1905
|
+
const context = swarmContext();
|
|
1906
|
+
const expected =
|
|
1907
|
+
typeof parsed.options.expect === "string"
|
|
1908
|
+
? parsed.options.expect
|
|
1909
|
+
: undefined;
|
|
1910
|
+
try {
|
|
1911
|
+
if (parsed.path === "templates list") {
|
|
1912
|
+
const items = await swarmTemplates(context, configUrl);
|
|
1913
|
+
const alias = state
|
|
1914
|
+
.swarms()
|
|
1915
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1916
|
+
emit(
|
|
1917
|
+
{ items },
|
|
1918
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nTemplates: ${items.length}\n\n${table(
|
|
1919
|
+
["NAME", "TITLE", "TARGET CID", "TEMPLATE CID"],
|
|
1920
|
+
items.map((item) => [
|
|
1921
|
+
item.selector,
|
|
1922
|
+
item.title,
|
|
1923
|
+
item.targetCid,
|
|
1924
|
+
item.templateCid,
|
|
1925
|
+
]),
|
|
1926
|
+
"No templates registered in this Swarm.\nAdd a template: ipab templates set NAME SOURCE",
|
|
1927
|
+
)}`,
|
|
1928
|
+
);
|
|
1929
|
+
} else if (parsed.path === "templates show") {
|
|
1930
|
+
const item = (await swarmTemplates(context, configUrl, first))[0]!;
|
|
1931
|
+
if (parsed.flags.json) io.out(JSON.stringify(item));
|
|
1932
|
+
else {
|
|
1933
|
+
const alias = state
|
|
1934
|
+
.swarms()
|
|
1935
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
1936
|
+
const swarm = alias ?? configUrl;
|
|
1937
|
+
const reference = formatNameReference(swarm, item.name);
|
|
1938
|
+
const tree = await templateOutputTree(
|
|
1939
|
+
context.store,
|
|
1940
|
+
item.templateCid,
|
|
1941
|
+
);
|
|
1942
|
+
const shell = process.platform === "win32" ? "powershell" : "posix";
|
|
1943
|
+
io.out(
|
|
1944
|
+
[
|
|
1945
|
+
`${printable(item.selector)} — ${printable(item.title)}`,
|
|
1946
|
+
printable(item.description) || "(No description.)",
|
|
1947
|
+
"",
|
|
1948
|
+
"Location",
|
|
1949
|
+
` Swarm: ${printable(swarm)}`,
|
|
1950
|
+
` Name: ${printable(item.name)}`,
|
|
1951
|
+
"",
|
|
1952
|
+
`Create a project (${shell === "powershell" ? "PowerShell" : "POSIX shell"})`,
|
|
1953
|
+
` ${templateRenderExample(reference, swarm, item.definition, shell)}`,
|
|
1954
|
+
" Replace example parameter values as needed. No code is run by show.",
|
|
1955
|
+
"",
|
|
1956
|
+
"Parameters",
|
|
1957
|
+
table(
|
|
1958
|
+
["NAME", "TYPE", "REQUIRED", "DEFAULT", "INPUT"],
|
|
1959
|
+
templateParameterRows(item.definition),
|
|
1960
|
+
"No parameters declared.",
|
|
1961
|
+
),
|
|
1962
|
+
"Required means an input is needed when no default is declared.",
|
|
1963
|
+
"",
|
|
1964
|
+
"Output files (from project/)",
|
|
1965
|
+
" my-project/",
|
|
1966
|
+
...tree.entries.map(
|
|
1967
|
+
(entry) =>
|
|
1968
|
+
`${" ".repeat(entry.path.split("/").length + 1)}${printable(entry.path.split("/").at(-1)!)}${entry.kind === "directory" ? "/" : ""}`,
|
|
1969
|
+
),
|
|
1970
|
+
...(tree.truncated
|
|
1971
|
+
? [
|
|
1972
|
+
` ... truncated: ${tree.truncated}; more files may exist.`,
|
|
1973
|
+
]
|
|
1974
|
+
: tree.entries.length
|
|
1975
|
+
? []
|
|
1976
|
+
: [" (no output files)"]),
|
|
1977
|
+
"",
|
|
1978
|
+
"Versions",
|
|
1979
|
+
` Template CID: ${item.templateCid}`,
|
|
1980
|
+
` Reference: ${reference}`,
|
|
1981
|
+
...(item.targetCid !== item.templateCid
|
|
1982
|
+
? [` Target CID (--expect): ${item.targetCid}`]
|
|
1983
|
+
: []),
|
|
1984
|
+
].join("\n"),
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1987
|
+
} else if (parsed.path === "templates set") {
|
|
1988
|
+
const item = await setSwarmTemplate(
|
|
1989
|
+
context,
|
|
1990
|
+
configUrl,
|
|
1991
|
+
first!,
|
|
1992
|
+
second!,
|
|
1993
|
+
expected,
|
|
1994
|
+
);
|
|
1995
|
+
emit(
|
|
1996
|
+
item,
|
|
1997
|
+
`${item.reference} → ${item.targetCid} (Template ${item.templateCid})`,
|
|
1998
|
+
);
|
|
1999
|
+
} else {
|
|
2000
|
+
const item = await removeSwarmTemplate(
|
|
2001
|
+
context,
|
|
2002
|
+
configUrl,
|
|
2003
|
+
first!,
|
|
2004
|
+
expected!,
|
|
2005
|
+
);
|
|
2006
|
+
emit(
|
|
2007
|
+
{ removed: item },
|
|
2008
|
+
`Removed ${item.reference}; content and history are retained.`,
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
} finally {
|
|
2012
|
+
await context.finishRead?.();
|
|
2013
|
+
}
|
|
2014
|
+
return 0;
|
|
2015
|
+
}
|
|
2016
|
+
if (parsed.path.startsWith("register ")) {
|
|
2017
|
+
const references = parsed.registrySwarms?.length
|
|
2018
|
+
? parsed.registrySwarms
|
|
2019
|
+
: selectedSwarm
|
|
2020
|
+
? [selectedSwarm]
|
|
2021
|
+
: [];
|
|
2022
|
+
if (!references.length)
|
|
2023
|
+
throw new HostError(
|
|
2024
|
+
"Register requires a selected Swarm. Pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS.",
|
|
2025
|
+
);
|
|
2026
|
+
const targets = [
|
|
2027
|
+
...new Set(
|
|
2028
|
+
references.map((reference) => state!.resolveSwarm(reference)),
|
|
2029
|
+
),
|
|
2030
|
+
];
|
|
2031
|
+
const schema = first
|
|
2032
|
+
? state.resolve(schemaAlias(first), true)
|
|
2033
|
+
: undefined;
|
|
2034
|
+
const results: (
|
|
2035
|
+
| {
|
|
2036
|
+
items: Association[];
|
|
2037
|
+
}
|
|
2038
|
+
| {
|
|
2039
|
+
association: Association;
|
|
2040
|
+
}
|
|
2041
|
+
| {
|
|
2042
|
+
removed: string[];
|
|
2043
|
+
}
|
|
2044
|
+
)[] = [];
|
|
2045
|
+
const completed: string[] = [];
|
|
2046
|
+
const human: string[] = [];
|
|
2047
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2048
|
+
for (const configUrl of targets) {
|
|
2049
|
+
const context = swarmContext();
|
|
2050
|
+
try {
|
|
2051
|
+
if (parsed.path === "register list") {
|
|
2052
|
+
const items = await swarmRegistrations(context, configUrl);
|
|
2053
|
+
const alias = state
|
|
2054
|
+
.swarms()
|
|
2055
|
+
.find((swarm) => swarm.cid === configUrl)?.alias;
|
|
2056
|
+
results.push({ items });
|
|
2057
|
+
human.push(
|
|
2058
|
+
`Swarm: ${alias ? printable(alias) : "(no local alias)"}\nConfig URL: ${configUrl}\nAssociations: ${items.length}\n\n${table(
|
|
2059
|
+
["TYPE CID", "APP CID"],
|
|
2060
|
+
items.map((item) => [item.schemaCid, item.appCid]),
|
|
2061
|
+
"No associations registered in this Swarm.\nRegister an App: ipab register set TYPE_CID APP_CID --swarm URL_OR_ALIAS",
|
|
2062
|
+
)}`,
|
|
2063
|
+
);
|
|
2064
|
+
} else if (parsed.path === "register set") {
|
|
2065
|
+
const appCid = parseNameReference(second!)
|
|
2066
|
+
? (
|
|
2067
|
+
await resolveReference(
|
|
2068
|
+
context,
|
|
2069
|
+
second!,
|
|
2070
|
+
configUrl,
|
|
2071
|
+
(reference) => state!.resolve(reference),
|
|
2072
|
+
)
|
|
2073
|
+
).cid
|
|
2074
|
+
: state.resolve(second!);
|
|
2075
|
+
const association = await setSwarmAssociation(
|
|
2076
|
+
context,
|
|
2077
|
+
configUrl,
|
|
2078
|
+
createAssociation(schema!, appCid, parsed.template ?? ["%"]),
|
|
2079
|
+
Boolean(parsed.options.replace),
|
|
2080
|
+
);
|
|
2081
|
+
results.push({ association });
|
|
2082
|
+
human.push(
|
|
2083
|
+
`${configUrl}: ${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
2084
|
+
);
|
|
2085
|
+
} else {
|
|
2086
|
+
const removed = await removeSwarmAssociation(
|
|
2087
|
+
context,
|
|
2088
|
+
configUrl,
|
|
2089
|
+
schema!,
|
|
2090
|
+
);
|
|
2091
|
+
results.push({ removed: [removed] });
|
|
2092
|
+
human.push(`${configUrl}: removed association for ${removed}.`);
|
|
2093
|
+
}
|
|
2094
|
+
completed.push(configUrl);
|
|
2095
|
+
} catch (cause) {
|
|
2096
|
+
throw new HostError(
|
|
2097
|
+
parsed.path === "register list"
|
|
2098
|
+
? `Cannot list associations for Swarm ${configUrl}: ${message(cause)}`
|
|
2099
|
+
: `Registry operation failed for ${configUrl}: ${message(cause)}. Completed Swarms: ${completed.length ? completed.join(", ") : "(none)"}. Multiple Swarm edits are not atomic.`,
|
|
2100
|
+
cause instanceof HostError ? cause.exitCode : 1,
|
|
2101
|
+
cause instanceof HostError ? cause.code : "REGISTRY_FAILED",
|
|
2102
|
+
"publication",
|
|
2103
|
+
);
|
|
2104
|
+
} finally {
|
|
2105
|
+
await context.finishRead?.();
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
emit(
|
|
2109
|
+
{
|
|
2110
|
+
swarms: results.map((result, index) => ({
|
|
2111
|
+
configUrl: targets[index],
|
|
2112
|
+
...result,
|
|
2113
|
+
})),
|
|
2114
|
+
},
|
|
2115
|
+
human.join("\n\n"),
|
|
2116
|
+
);
|
|
2117
|
+
return 0;
|
|
2118
|
+
}
|
|
773
2119
|
switch (parsed.path) {
|
|
774
|
-
case "
|
|
2120
|
+
case "profile": {
|
|
2121
|
+
const context = swarmContext();
|
|
2122
|
+
readContext = context;
|
|
2123
|
+
const changes = {
|
|
2124
|
+
...(typeof parsed.options.name === "string"
|
|
2125
|
+
? { name: parsed.options.name }
|
|
2126
|
+
: {}),
|
|
2127
|
+
...(typeof parsed.options.description === "string"
|
|
2128
|
+
? { description: parsed.options.description }
|
|
2129
|
+
: {}),
|
|
2130
|
+
};
|
|
2131
|
+
if (!Object.keys(changes).length) {
|
|
2132
|
+
const profile = await accountProfile(context);
|
|
2133
|
+
emit(
|
|
2134
|
+
{ profile, localPersisted: profile.updatedAt !== null },
|
|
2135
|
+
`Name: ${printable(profile.name)}\nDescription: ${printable(profile.description)}\nPublic key: ${profile.publicKey}`,
|
|
2136
|
+
);
|
|
2137
|
+
} else {
|
|
2138
|
+
const result = await updateAccountProfile(context, changes);
|
|
2139
|
+
emit(
|
|
2140
|
+
result,
|
|
2141
|
+
[
|
|
2142
|
+
`Name: ${printable(result.profile.name)}`,
|
|
2143
|
+
`Description: ${printable(result.profile.description)}`,
|
|
2144
|
+
"Personal profile saved locally.",
|
|
2145
|
+
...result.swarms.map(
|
|
2146
|
+
(entry) =>
|
|
2147
|
+
`${entry.configUrl}: ${entry.synchronized ? "synchronized" : `FAILED: ${entry.error}`}`,
|
|
2148
|
+
),
|
|
2149
|
+
].join("\n"),
|
|
2150
|
+
);
|
|
2151
|
+
if (result.swarms.some((entry) => !entry.synchronized)) {
|
|
2152
|
+
io.err(
|
|
2153
|
+
"Profile saved locally, but some Swarms failed. Retry the profile update or normally activate each failed membership to synchronize it.",
|
|
2154
|
+
);
|
|
2155
|
+
return 1;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
break;
|
|
2159
|
+
}
|
|
2160
|
+
case "swarm list": {
|
|
2161
|
+
const result = { swarms: state.swarms(), ...selection() };
|
|
2162
|
+
emit(
|
|
2163
|
+
{
|
|
2164
|
+
...result,
|
|
2165
|
+
swarms: result.swarms.map((entry) => ({
|
|
2166
|
+
configUrl: entry.cid,
|
|
2167
|
+
alias: entry.alias,
|
|
2168
|
+
})),
|
|
2169
|
+
},
|
|
2170
|
+
[
|
|
2171
|
+
...alignedRows(
|
|
2172
|
+
result.swarms.map((entry) => [
|
|
2173
|
+
`${entry.cid === result.effectiveCurrent ? "*" : " "} ${entry.alias ?? entry.cid}`,
|
|
2174
|
+
entry.cid,
|
|
2175
|
+
]),
|
|
2176
|
+
),
|
|
2177
|
+
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
2178
|
+
...(result.effectiveCurrent === null
|
|
2179
|
+
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
2180
|
+
: []),
|
|
2181
|
+
...(result.effectiveCurrent !== result.savedCurrent
|
|
2182
|
+
? [
|
|
2183
|
+
`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)"))}.`,
|
|
2184
|
+
]
|
|
2185
|
+
: []),
|
|
2186
|
+
].join("\n"),
|
|
2187
|
+
);
|
|
2188
|
+
break;
|
|
2189
|
+
}
|
|
2190
|
+
case "swarm use": {
|
|
2191
|
+
state.useSwarm(first!);
|
|
2192
|
+
const result = selection();
|
|
2193
|
+
emit(result, `Saved current swarm: ${result.savedCurrent}`);
|
|
2194
|
+
if (result.source === "flag" || result.source === "env")
|
|
2195
|
+
io.err(
|
|
2196
|
+
`The saved default is overridden by ${result.source}: ${result.effectiveCurrent}.`,
|
|
2197
|
+
);
|
|
2198
|
+
break;
|
|
2199
|
+
}
|
|
2200
|
+
case "swarm remove": {
|
|
2201
|
+
const removed = state.removeSwarm(first!);
|
|
2202
|
+
emit(
|
|
2203
|
+
{
|
|
2204
|
+
removed,
|
|
2205
|
+
savedCurrent:
|
|
2206
|
+
state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
2207
|
+
},
|
|
2208
|
+
`Removed registration ${removed}. Credentials, content and remote membership are unchanged.`,
|
|
2209
|
+
);
|
|
2210
|
+
break;
|
|
2211
|
+
}
|
|
2212
|
+
case "swarm set": {
|
|
2213
|
+
swarmAlias(first!);
|
|
2214
|
+
const cid = swarmUrl(second!);
|
|
2215
|
+
const previous = state.swarms().find((entry) => entry.alias === first);
|
|
2216
|
+
if (previous && previous.cid !== cid) {
|
|
2217
|
+
io.err(`Swarm alias ${first}: ${previous.cid} -> ${cid}`);
|
|
2218
|
+
if (
|
|
2219
|
+
!parsed.options.yes &&
|
|
2220
|
+
(!io.tty ||
|
|
2221
|
+
!(await io.confirm(
|
|
2222
|
+
`Retarget local Swarm alias "${first}" from ${previous.cid} to ${cid}?`,
|
|
2223
|
+
)))
|
|
2224
|
+
)
|
|
2225
|
+
throw new HostError(
|
|
2226
|
+
"Alias unchanged. Retargeting requires --yes or interactive confirmation.",
|
|
2227
|
+
);
|
|
2228
|
+
}
|
|
2229
|
+
const entry = state.setSwarm(first!, cid, previous?.cid ?? null);
|
|
2230
|
+
emit(
|
|
2231
|
+
{
|
|
2232
|
+
configUrl: entry.cid,
|
|
2233
|
+
alias: entry.alias,
|
|
2234
|
+
savedCurrent:
|
|
2235
|
+
state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
2236
|
+
},
|
|
2237
|
+
`Set local swarm alias ${entry.alias} (${cid}).`,
|
|
2238
|
+
);
|
|
2239
|
+
break;
|
|
2240
|
+
}
|
|
2241
|
+
case "daemon": {
|
|
2242
|
+
if (parsed.flags.json)
|
|
2243
|
+
syntax(
|
|
2244
|
+
"--json is not supported for daemon; diagnostics are written to stderr.",
|
|
2245
|
+
);
|
|
2246
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2247
|
+
const controller = new AbortController();
|
|
2248
|
+
const interrupt = () => {
|
|
2249
|
+
controller.abort();
|
|
2250
|
+
};
|
|
2251
|
+
process.once("SIGINT", interrupt);
|
|
2252
|
+
process.once("SIGTERM", interrupt);
|
|
2253
|
+
try {
|
|
2254
|
+
await swarmDaemon(
|
|
2255
|
+
swarmContext(),
|
|
2256
|
+
controller.signal,
|
|
2257
|
+
(ctx, url, report) => syncDaemonSwarm(ctx, url, undefined, report),
|
|
2258
|
+
);
|
|
2259
|
+
} catch (cause) {
|
|
2260
|
+
if (!controller.signal.aborted) throw cause;
|
|
2261
|
+
} finally {
|
|
2262
|
+
process.removeListener("SIGINT", interrupt);
|
|
2263
|
+
process.removeListener("SIGTERM", interrupt);
|
|
2264
|
+
}
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
case "swarm update":
|
|
2268
|
+
case "search":
|
|
2269
|
+
case "skills list":
|
|
2270
|
+
case "skills sync":
|
|
2271
|
+
case "swarm create":
|
|
2272
|
+
case "swarm request":
|
|
2273
|
+
case "swarm approve":
|
|
2274
|
+
case "swarm pivot grant":
|
|
2275
|
+
case "swarm export":
|
|
2276
|
+
case "swarm exclude":
|
|
2277
|
+
case "swarm resume":
|
|
2278
|
+
case "swarm profile":
|
|
2279
|
+
case "swarm members":
|
|
2280
|
+
case "swarm status":
|
|
2281
|
+
case "publish":
|
|
2282
|
+
case "pin":
|
|
2283
|
+
case "get": {
|
|
2284
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2285
|
+
const context = swarmContext();
|
|
2286
|
+
readContext = context;
|
|
2287
|
+
if (parsed.path.startsWith("skills ")) {
|
|
2288
|
+
const result = await manageSkills(context, requireSwarm(), {
|
|
2289
|
+
sync: parsed.path === "skills sync",
|
|
2290
|
+
names: parsed.positional,
|
|
2291
|
+
agents: parsed.agents ?? [],
|
|
2292
|
+
overrideExisting: Boolean(parsed.options["override-existing"]),
|
|
2293
|
+
dryRun: Boolean(parsed.options["dry-run"]),
|
|
2294
|
+
yes: Boolean(parsed.options.yes),
|
|
2295
|
+
tty: io.tty,
|
|
2296
|
+
confirm: (text) => io.confirm(text),
|
|
2297
|
+
preview: (text) => {
|
|
2298
|
+
io.err(text);
|
|
2299
|
+
},
|
|
2300
|
+
});
|
|
2301
|
+
store = context.store;
|
|
2302
|
+
emit(
|
|
2303
|
+
result,
|
|
2304
|
+
[
|
|
2305
|
+
table(
|
|
2306
|
+
["NAME", "PAYLOAD CID", "INSTALL NAME", "STATUS"],
|
|
2307
|
+
result.items.map((skill) => [
|
|
2308
|
+
skill.name,
|
|
2309
|
+
skill.cid,
|
|
2310
|
+
skill.identity,
|
|
2311
|
+
skill.status,
|
|
2312
|
+
]),
|
|
2313
|
+
"No Skills.",
|
|
2314
|
+
),
|
|
2315
|
+
...result.items.flatMap((skill) => skill.problems),
|
|
2316
|
+
...result.orphaned.map(
|
|
2317
|
+
(skill) =>
|
|
2318
|
+
`Source removed: ${skill.name} ${skill.cid} (${skill.path}); installation retained.`,
|
|
2319
|
+
),
|
|
2320
|
+
...result.results.map(
|
|
2321
|
+
(entry) =>
|
|
2322
|
+
`${entry.name} / ${entry.agent}: ${entry.status}${entry.error ? `: ${entry.error}` : ""}`,
|
|
2323
|
+
),
|
|
2324
|
+
].join("\n"),
|
|
2325
|
+
);
|
|
2326
|
+
if (!result.ok) return 1;
|
|
2327
|
+
break;
|
|
2328
|
+
}
|
|
2329
|
+
if (parsed.path === "pin") {
|
|
2330
|
+
io.err("Fetching, verifying and retaining content...");
|
|
2331
|
+
const result = await pinNameSubscription(
|
|
2332
|
+
context,
|
|
2333
|
+
first!,
|
|
2334
|
+
selectedSwarm,
|
|
2335
|
+
);
|
|
2336
|
+
store = context.store;
|
|
2337
|
+
emit(
|
|
2338
|
+
result,
|
|
2339
|
+
`${result.reference} → ${result.cid}\nStatus: ${result.freshness}`,
|
|
2340
|
+
);
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
if (parsed.path === "swarm members") {
|
|
2344
|
+
const result = await swarmMembers(
|
|
2345
|
+
context,
|
|
2346
|
+
requireSwarm(),
|
|
2347
|
+
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2348
|
+
);
|
|
2349
|
+
emit(
|
|
2350
|
+
result,
|
|
2351
|
+
[
|
|
2352
|
+
`Directory: ${result.cache.source} (${result.cache.freshness}), observed ${result.cache.updatedAt}`,
|
|
2353
|
+
`Daemon: ${result.local.status}, observed ${result.local.updatedAt ?? "unknown"}; control-plane verified ${result.local.verifiedAt ?? "unknown"}`,
|
|
2354
|
+
table(
|
|
2355
|
+
["NAME", "DESCRIPTION", "ROLE", "PIVOT", "PUBLIC KEY"],
|
|
2356
|
+
result.members.map((member) => [
|
|
2357
|
+
member.name,
|
|
2358
|
+
member.description,
|
|
2359
|
+
member.role,
|
|
2360
|
+
member.pivot ? (member.localStatus ?? "candidate") : "-",
|
|
2361
|
+
member.publicKey,
|
|
2362
|
+
]),
|
|
2363
|
+
"No members.",
|
|
2364
|
+
),
|
|
2365
|
+
].join("\n"),
|
|
2366
|
+
);
|
|
2367
|
+
if (result.local.error)
|
|
2368
|
+
io.err(
|
|
2369
|
+
`Local Pivot observations (${result.local.status}): ${printable(result.local.error)}`,
|
|
2370
|
+
);
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
if (parsed.path === "swarm export") {
|
|
2374
|
+
const member = await exportRequest(
|
|
2375
|
+
context,
|
|
2376
|
+
requireSwarm(),
|
|
2377
|
+
String(parsed.options.output ?? ""),
|
|
2378
|
+
);
|
|
2379
|
+
emit({ member }, member);
|
|
2380
|
+
break;
|
|
2381
|
+
}
|
|
2382
|
+
if (parsed.path === "swarm pivot grant") {
|
|
2383
|
+
const url = requireSwarm();
|
|
2384
|
+
if (!parsed.options.yes)
|
|
2385
|
+
syntax(
|
|
2386
|
+
"Granting Pivot HEAD receipt authority requires --yes; revoking it requires swarm exclude.",
|
|
2387
|
+
);
|
|
2388
|
+
const result = await grantPivotAuthority(context, url, first!);
|
|
2389
|
+
store = context.store;
|
|
2390
|
+
emit(
|
|
2391
|
+
result,
|
|
2392
|
+
`Granted Pivot HEAD authority to ${result.member} on ${result.configUrl} (HEAD ${result.headId}). Revoking Pivot HEAD authority requires swarm exclude.`,
|
|
2393
|
+
);
|
|
2394
|
+
break;
|
|
2395
|
+
}
|
|
2396
|
+
if (
|
|
2397
|
+
["swarm exclude", "swarm resume", "swarm profile"].includes(
|
|
2398
|
+
parsed.path,
|
|
2399
|
+
)
|
|
2400
|
+
) {
|
|
2401
|
+
const url = requireSwarm();
|
|
2402
|
+
if (parsed.path === "swarm exclude") {
|
|
2403
|
+
if (!parsed.options.yes)
|
|
2404
|
+
syntax("Member removal is irreversible; --yes required.");
|
|
2405
|
+
await removeMember(context, url, first!);
|
|
2406
|
+
} else if (parsed.path === "swarm resume")
|
|
2407
|
+
await resumeRemoval(context, url);
|
|
2408
|
+
else {
|
|
2409
|
+
const profile = await updateProfile(context, url, {
|
|
2410
|
+
...(typeof parsed.options.address === "string"
|
|
2411
|
+
? { addresses: [parsed.options.address] }
|
|
2412
|
+
: {}),
|
|
2413
|
+
...(typeof parsed.options.pivot === "string"
|
|
2414
|
+
? {
|
|
2415
|
+
pivot: Boolean(
|
|
2416
|
+
parseValue("swarm.pivot", parsed.options.pivot, true),
|
|
2417
|
+
),
|
|
2418
|
+
}
|
|
2419
|
+
: {}),
|
|
2420
|
+
});
|
|
2421
|
+
emit(profile, JSON.stringify(profile));
|
|
2422
|
+
store = context.store;
|
|
2423
|
+
break;
|
|
2424
|
+
}
|
|
2425
|
+
store = context.store;
|
|
2426
|
+
emit(
|
|
2427
|
+
{ url, completed: true },
|
|
2428
|
+
`Organization switch complete: ${url}`,
|
|
2429
|
+
);
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
if (parsed.path === "swarm update") {
|
|
2433
|
+
const cid = requireSwarm();
|
|
2434
|
+
const result = await updateSwarm(context, cid, {
|
|
2435
|
+
...(typeof parsed.options.name === "string"
|
|
2436
|
+
? { name: parsed.options.name }
|
|
2437
|
+
: {}),
|
|
2438
|
+
...(typeof parsed.options.description === "string"
|
|
2439
|
+
? { description: parsed.options.description }
|
|
2440
|
+
: {}),
|
|
2441
|
+
});
|
|
2442
|
+
emit(
|
|
2443
|
+
result,
|
|
2444
|
+
`Swarm: ${result.configUrl}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD ID: ${result.headId}\nConfig content CID: ${result.valueCid}`,
|
|
2445
|
+
);
|
|
2446
|
+
break;
|
|
2447
|
+
}
|
|
2448
|
+
if (parsed.path === "search") {
|
|
2449
|
+
const registrations = state.swarms();
|
|
2450
|
+
const scope = parsed.options.all
|
|
2451
|
+
? registrations
|
|
2452
|
+
: [
|
|
2453
|
+
{
|
|
2454
|
+
cid: requireSwarm(),
|
|
2455
|
+
alias:
|
|
2456
|
+
registrations.find((entry) => entry.cid === selectedSwarm)
|
|
2457
|
+
?.alias ?? null,
|
|
2458
|
+
},
|
|
2459
|
+
];
|
|
2460
|
+
const searchOptions: Parameters<typeof searchNames>[3] = {};
|
|
2461
|
+
if (typeof parsed.options.prefix === "string")
|
|
2462
|
+
searchOptions.prefix = parsed.options.prefix;
|
|
2463
|
+
if (typeof parsed.options.kind === "string")
|
|
2464
|
+
searchOptions.kind = parsed.options.kind as Exclude<
|
|
2465
|
+
NonNullable<Parameters<typeof searchNames>[3]>["kind"],
|
|
2466
|
+
undefined
|
|
2467
|
+
>;
|
|
2468
|
+
if (typeof parsed.options.schema === "string")
|
|
2469
|
+
searchOptions.schemaCid = parsed.options.schema;
|
|
2470
|
+
if (typeof parsed.options.limit === "string")
|
|
2471
|
+
searchOptions.limit = /^\d+$/.test(parsed.options.limit)
|
|
2472
|
+
? Number(parsed.options.limit)
|
|
2473
|
+
: Number.NaN;
|
|
2474
|
+
if (typeof parsed.options.offset === "string")
|
|
2475
|
+
searchOptions.offset = /^\d+$/.test(parsed.options.offset)
|
|
2476
|
+
? Number(parsed.options.offset)
|
|
2477
|
+
: Number.NaN;
|
|
2478
|
+
const result = Object.keys(searchOptions).length
|
|
2479
|
+
? await searchNames(context, first!, scope, searchOptions)
|
|
2480
|
+
: await searchNames(context, first!, scope);
|
|
2481
|
+
emit(result, formatSearchResults(result.matches));
|
|
2482
|
+
break;
|
|
2483
|
+
}
|
|
2484
|
+
if (parsed.path === "swarm status") {
|
|
2485
|
+
const cid = requireSwarm();
|
|
2486
|
+
const {
|
|
2487
|
+
head,
|
|
2488
|
+
config,
|
|
2489
|
+
networking,
|
|
2490
|
+
cache,
|
|
2491
|
+
lastWriter,
|
|
2492
|
+
state: contentState,
|
|
2493
|
+
} = await inspectSwarmStatus(
|
|
2494
|
+
context,
|
|
2495
|
+
cid,
|
|
2496
|
+
Boolean(parsed.options.refresh || parsed.options.force),
|
|
2497
|
+
);
|
|
2498
|
+
const fingerprint = await keyId(config.owner);
|
|
2499
|
+
store = context.store;
|
|
2500
|
+
emit(
|
|
2501
|
+
{
|
|
2502
|
+
configUrl: cid,
|
|
2503
|
+
owner: config.owner,
|
|
2504
|
+
ownerFingerprint: fingerprint,
|
|
2505
|
+
epoch: config.epoch,
|
|
2506
|
+
scopeId: config.scopeId,
|
|
2507
|
+
headId: config.headId,
|
|
2508
|
+
cache,
|
|
2509
|
+
state: contentState,
|
|
2510
|
+
networking,
|
|
2511
|
+
root: head.root,
|
|
2512
|
+
valueCid: head.cid,
|
|
2513
|
+
lastWriter,
|
|
2514
|
+
properties: {
|
|
2515
|
+
name: config.name,
|
|
2516
|
+
description: config.description,
|
|
2517
|
+
},
|
|
2518
|
+
},
|
|
2519
|
+
[
|
|
2520
|
+
"Swarm",
|
|
2521
|
+
` Directory: ${cache.source} (${cache.freshness}), observed ${cache.updatedAt}`,
|
|
2522
|
+
` Name: ${printable(config.name)}`,
|
|
2523
|
+
` Description: ${config.description ? printable(config.description) : "(none)"}`,
|
|
2524
|
+
" Config URL:",
|
|
2525
|
+
` ${cid}`,
|
|
2526
|
+
"",
|
|
2527
|
+
"Identity",
|
|
2528
|
+
" Owner fingerprint:",
|
|
2529
|
+
` ${fingerprint}`,
|
|
2530
|
+
"",
|
|
2531
|
+
"Content",
|
|
2532
|
+
" HEAD (publication root):",
|
|
2533
|
+
` ${head.root}`,
|
|
2534
|
+
" Content CID (HEAD value):",
|
|
2535
|
+
` ${head.cid}`,
|
|
2536
|
+
...(lastWriter
|
|
2537
|
+
? [
|
|
2538
|
+
` Last HEAD writer: ${lastWriter.name ? printable(lastWriter.name) : "(profile name unavailable)"}`,
|
|
2539
|
+
` Public key: ${lastWriter.subject}`,
|
|
2540
|
+
` PeerID: ${lastWriter.peerId ?? "unknown"}`,
|
|
2541
|
+
` Updated: ${lastWriter.updatedAt} (service time)`,
|
|
2542
|
+
" Last writer is not a confirmed content holder or the only copy.",
|
|
2543
|
+
]
|
|
2544
|
+
: [
|
|
2545
|
+
" Last HEAD writer/time: unknown (legacy record or service without update metadata).",
|
|
2546
|
+
]),
|
|
2547
|
+
` State: ${contentState.status}. ${contentState.error}`,
|
|
2548
|
+
"",
|
|
2549
|
+
"Local networking",
|
|
2550
|
+
` Daemon observations: ${networking.daemon.status}`,
|
|
2551
|
+
` Updated: ${networking.daemon.updatedAt ?? "unknown"}`,
|
|
2552
|
+
` Control-plane verified: ${networking.daemon.verifiedAt ?? "unknown"}`,
|
|
2553
|
+
...(networking.daemon.error
|
|
2554
|
+
? [` Observation error: ${printable(networking.daemon.error)}`]
|
|
2555
|
+
: []),
|
|
2556
|
+
` Connections observed: ${networking.connections.observedAt ?? "unknown"} (${networking.connections.freshness})`,
|
|
2557
|
+
...(networking.connections.error
|
|
2558
|
+
? [
|
|
2559
|
+
` Connection error: ${printable(networking.connections.error)}`,
|
|
2560
|
+
]
|
|
2561
|
+
: []),
|
|
2562
|
+
table(
|
|
2563
|
+
[
|
|
2564
|
+
"PIVOT PEER ID",
|
|
2565
|
+
"LOCAL",
|
|
2566
|
+
"PROBE",
|
|
2567
|
+
"PROBED AT",
|
|
2568
|
+
"FAILURES",
|
|
2569
|
+
"RETRY AT",
|
|
2570
|
+
"CONNECTION",
|
|
2571
|
+
],
|
|
2572
|
+
networking.pivots.map((pivot) => [
|
|
2573
|
+
pivot.peerId,
|
|
2574
|
+
pivot.localStatus ?? "unknown",
|
|
2575
|
+
`${pivot.probe.result} (${pivot.probe.freshness})`,
|
|
2576
|
+
pivot.probe.at ?? "-",
|
|
2577
|
+
pivot.failures === null ? "-" : String(pivot.failures),
|
|
2578
|
+
pivot.retryAt ?? "-",
|
|
2579
|
+
pivot.connection.status,
|
|
2580
|
+
]),
|
|
2581
|
+
"No declared Pivots.",
|
|
2582
|
+
),
|
|
2583
|
+
...networking.pivots.flatMap((pivot) =>
|
|
2584
|
+
pivot.probe.error
|
|
2585
|
+
? [
|
|
2586
|
+
` ${pivot.peerId} probe error: ${printable(pivot.probe.error)}`,
|
|
2587
|
+
]
|
|
2588
|
+
: [],
|
|
2589
|
+
),
|
|
2590
|
+
...(networking.connections.error
|
|
2591
|
+
? []
|
|
2592
|
+
: [
|
|
2593
|
+
table(
|
|
2594
|
+
["CONNECTED PEER ID", "TRANSPORT", "ADDRESS"],
|
|
2595
|
+
networking.connections.peers.map((peer) => [
|
|
2596
|
+
peer.peerId,
|
|
2597
|
+
peer.transport,
|
|
2598
|
+
peer.address,
|
|
2599
|
+
]),
|
|
2600
|
+
"No observed peer connections.",
|
|
2601
|
+
),
|
|
2602
|
+
]),
|
|
2603
|
+
" Selected is configuration, not connection success. Relay connectivity does not guarantee content availability.",
|
|
2604
|
+
].join("\n"),
|
|
2605
|
+
);
|
|
2606
|
+
break;
|
|
2607
|
+
}
|
|
2608
|
+
if (parsed.path === "get") {
|
|
2609
|
+
const localCid = /^(ipab|name):/i.test(first!)
|
|
2610
|
+
? undefined
|
|
2611
|
+
: state.resolve(first!);
|
|
2612
|
+
const builtin = builtins.pins.find((pin) => pin.cid === localCid);
|
|
2613
|
+
const selected = builtin
|
|
2614
|
+
? { cid: builtin.cid, targetCid: builtin.cid }
|
|
2615
|
+
: await resolveReference(
|
|
2616
|
+
context,
|
|
2617
|
+
first!,
|
|
2618
|
+
selectedSwarm,
|
|
2619
|
+
(reference) => state!.resolve(reference),
|
|
2620
|
+
Boolean(parsed.options.raw),
|
|
2621
|
+
"local-first",
|
|
2622
|
+
);
|
|
2623
|
+
const contentStore = context.store;
|
|
2624
|
+
const source = IpfsStore.fromClient(
|
|
2625
|
+
{
|
|
2626
|
+
block: {
|
|
2627
|
+
get: (key, options) => {
|
|
2628
|
+
options?.signal?.throwIfAborted();
|
|
2629
|
+
const builtin = builtins.blocks.get(
|
|
2630
|
+
CID.parse(key).toV1().toString(),
|
|
2631
|
+
);
|
|
2632
|
+
return builtin
|
|
2633
|
+
? Promise.resolve(builtin.slice())
|
|
2634
|
+
: contentStore.block.get(key, options);
|
|
2635
|
+
},
|
|
2636
|
+
},
|
|
2637
|
+
},
|
|
2638
|
+
contentStore.limits,
|
|
2639
|
+
);
|
|
2640
|
+
let directory: string;
|
|
2641
|
+
try {
|
|
2642
|
+
directory = await getBundle(
|
|
2643
|
+
source,
|
|
2644
|
+
selected.cid,
|
|
2645
|
+
typeof parsed.options.output === "string"
|
|
2646
|
+
? parsed.options.output
|
|
2647
|
+
: undefined,
|
|
2648
|
+
);
|
|
2649
|
+
} finally {
|
|
2650
|
+
await source.close();
|
|
2651
|
+
}
|
|
2652
|
+
try {
|
|
2653
|
+
await context.finishRead?.();
|
|
2654
|
+
} finally {
|
|
2655
|
+
readContext = undefined;
|
|
2656
|
+
}
|
|
2657
|
+
const closing = store;
|
|
2658
|
+
store = undefined;
|
|
2659
|
+
await closeStore(closing, undefined);
|
|
2660
|
+
state.close();
|
|
2661
|
+
state = undefined;
|
|
2662
|
+
emit({ ...selected, directory }, directory);
|
|
2663
|
+
break;
|
|
2664
|
+
}
|
|
2665
|
+
let cid: string;
|
|
2666
|
+
let contentCid: string | undefined;
|
|
2667
|
+
if (parsed.path === "swarm create") {
|
|
2668
|
+
cid = await createSwarm(context, {
|
|
2669
|
+
...(typeof parsed.options.service === "string"
|
|
2670
|
+
? { service: parsed.options.service }
|
|
2671
|
+
: {}),
|
|
2672
|
+
...(typeof parsed.options.resume === "string"
|
|
2673
|
+
? { resume: parsed.options.resume }
|
|
2674
|
+
: {}),
|
|
2675
|
+
properties: {
|
|
2676
|
+
name: String(parsed.options.name ?? ""),
|
|
2677
|
+
description: String(parsed.options.description ?? ""),
|
|
2678
|
+
},
|
|
2679
|
+
...(typeof parsed.options.alias === "string"
|
|
2680
|
+
? { alias: parsed.options.alias }
|
|
2681
|
+
: {}),
|
|
2682
|
+
});
|
|
2683
|
+
} else if (parsed.path === "swarm request") {
|
|
2684
|
+
const result = await requestMembership(
|
|
2685
|
+
context,
|
|
2686
|
+
state.resolveSwarm(first!),
|
|
2687
|
+
{
|
|
2688
|
+
...(typeof parsed.options.output === "string"
|
|
2689
|
+
? { output: parsed.options.output }
|
|
2690
|
+
: {}),
|
|
2691
|
+
...(parsed.options.pivot ? { role: "pivot" as const } : {}),
|
|
2692
|
+
},
|
|
2693
|
+
);
|
|
2694
|
+
store = context.store;
|
|
2695
|
+
io.err(
|
|
2696
|
+
`Owner fingerprint: ${result.ownerFingerprint}\nVerify this fingerprint through an independent trusted channel before manually sending the Request file to the Owner.`,
|
|
2697
|
+
);
|
|
2698
|
+
if (result.file === undefined)
|
|
2699
|
+
io.out(JSON.stringify(result.request, null, 2));
|
|
2700
|
+
else {
|
|
2701
|
+
io.err(`Request saved to: ${result.file}`);
|
|
2702
|
+
if (parsed.flags.json)
|
|
2703
|
+
emit(
|
|
2704
|
+
{
|
|
2705
|
+
file: result.file,
|
|
2706
|
+
member: result.request.member,
|
|
2707
|
+
ownerFingerprint: result.ownerFingerprint,
|
|
2708
|
+
},
|
|
2709
|
+
"",
|
|
2710
|
+
);
|
|
2711
|
+
}
|
|
2712
|
+
break;
|
|
2713
|
+
} else if (parsed.path === "swarm approve") {
|
|
2714
|
+
const selected = requireSwarm();
|
|
2715
|
+
if (first === "-" && !parsed.options.yes)
|
|
2716
|
+
syntax(
|
|
2717
|
+
"Reading a Request from stdin requires explicit --yes; no interactive confirmation is available.",
|
|
2718
|
+
);
|
|
2719
|
+
const request =
|
|
2720
|
+
first === "-"
|
|
2721
|
+
? await verifiedRequestStream(
|
|
2722
|
+
(io.requestInput ?? processIO.requestInput!)(),
|
|
2723
|
+
)
|
|
2724
|
+
: await verifiedRequest(first!);
|
|
2725
|
+
if (request.configUrl !== selected)
|
|
2726
|
+
syntax(
|
|
2727
|
+
`Request belongs to ${request.configUrl}, not the selected Swarm. Use ipab --swarm ${request.configUrl} swarm approve REQUEST_FILE --yes.`,
|
|
2728
|
+
);
|
|
2729
|
+
io.err(await membershipRequestSummary(request));
|
|
2730
|
+
if (
|
|
2731
|
+
!parsed.options.yes &&
|
|
2732
|
+
(!io.tty ||
|
|
2733
|
+
!(await io.confirm(
|
|
2734
|
+
`Approve the verified ${parsed.options.pivot || request.role === "pivot" ? "pivot" : "ordinary"} Request from ${request.member} above? This grants ${parsed.options.pivot || request.role === "pivot" ? "current HEAD and " : ""}the member's profile write access; all reads are public.`,
|
|
2735
|
+
)))
|
|
2736
|
+
)
|
|
2737
|
+
throw new HostError(
|
|
2738
|
+
"Approval requires explicit --yes or interactive confirmation.",
|
|
2739
|
+
);
|
|
2740
|
+
cid = await approveMembership(context, request, {
|
|
2741
|
+
again: Boolean(parsed.options.again),
|
|
2742
|
+
pivot: Boolean(parsed.options.pivot),
|
|
2743
|
+
});
|
|
2744
|
+
} else {
|
|
2745
|
+
const content = await publicationSource(second!, store);
|
|
2746
|
+
contentCid = content;
|
|
2747
|
+
cid = await publish(context, content, {
|
|
2748
|
+
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
2749
|
+
name: first!,
|
|
2750
|
+
...(typeof parsed.options.expect === "string"
|
|
2751
|
+
? { expect: parsed.options.expect }
|
|
2752
|
+
: {}),
|
|
2753
|
+
snapshot: Boolean(parsed.options.snapshot),
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
store = context.store;
|
|
2757
|
+
if (parsed.path === "swarm create")
|
|
2758
|
+
io.err(
|
|
2759
|
+
`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`,
|
|
2760
|
+
);
|
|
2761
|
+
if (contentCid)
|
|
2762
|
+
io.err(
|
|
2763
|
+
`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.`,
|
|
2764
|
+
);
|
|
2765
|
+
emit(
|
|
2766
|
+
parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
2767
|
+
? { configUrl: cid }
|
|
2768
|
+
: { cid, ...(contentCid ? { contentCid } : {}) },
|
|
2769
|
+
cid,
|
|
2770
|
+
);
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
case "store usage":
|
|
2774
|
+
case "store gc": {
|
|
2775
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
2776
|
+
if (parsed.path === "store usage") {
|
|
2777
|
+
const result = await store.usage();
|
|
2778
|
+
emit(
|
|
2779
|
+
result,
|
|
2780
|
+
`Cached blocks: ${storageBytes(result.cachedBytes)}\nPinned blocks (deduplicated): ${storageBytes(result.pinnedBytes)}`,
|
|
2781
|
+
);
|
|
2782
|
+
} else {
|
|
2783
|
+
const result = await store.gc();
|
|
2784
|
+
emit(
|
|
2785
|
+
result,
|
|
2786
|
+
`Removed ${result.removedBlocks} blocks; reclaimed ${storageBytes(result.reclaimedBytes)}.`,
|
|
2787
|
+
);
|
|
2788
|
+
}
|
|
2789
|
+
break;
|
|
2790
|
+
}
|
|
2791
|
+
case "templates render":
|
|
775
2792
|
case "build":
|
|
776
|
-
case "bundle init":
|
|
777
2793
|
case "bundle build":
|
|
778
2794
|
case "bundle inspect":
|
|
779
2795
|
case "bundle import": {
|
|
@@ -792,7 +2808,7 @@ async function performCli(
|
|
|
792
2808
|
try {
|
|
793
2809
|
let pendingStore: Promise<IpfsStore> | undefined;
|
|
794
2810
|
const getStore = () => {
|
|
795
|
-
pendingStore ??= storeConfiguration(value("store.
|
|
2811
|
+
pendingStore ??= storeConfiguration(value("store.gateway")).then(
|
|
796
2812
|
(configuration) => {
|
|
797
2813
|
store = new IpfsStore(configuration);
|
|
798
2814
|
return store;
|
|
@@ -809,7 +2825,10 @@ async function performCli(
|
|
|
809
2825
|
options.signal?.throwIfAborted();
|
|
810
2826
|
const builtin = builtins.blocks.get(cid.toV1().toString());
|
|
811
2827
|
if (builtin) return builtin.slice();
|
|
812
|
-
return (await getStore()).block.get(
|
|
2828
|
+
return (store ?? (await getStore())).block.get(
|
|
2829
|
+
cid.toString(),
|
|
2830
|
+
options,
|
|
2831
|
+
);
|
|
813
2832
|
},
|
|
814
2833
|
};
|
|
815
2834
|
const builtinSource = first ? state.pin(first) : undefined;
|
|
@@ -817,60 +2836,106 @@ async function performCli(
|
|
|
817
2836
|
builtinSource?.builtin && builtinSource.metadata?.kind === "bundle"
|
|
818
2837
|
? builtinSource.cid
|
|
819
2838
|
: first;
|
|
2839
|
+
let selectedTemplate: string | undefined;
|
|
2840
|
+
if (parsed.path === "templates render") {
|
|
2841
|
+
const selector = first!;
|
|
2842
|
+
selectedTemplate = selector;
|
|
2843
|
+
if (parseNameReference(selector)) {
|
|
2844
|
+
await getStore();
|
|
2845
|
+
const context = swarmContext();
|
|
2846
|
+
readContext = context;
|
|
2847
|
+
selectedTemplate = (
|
|
2848
|
+
await resolveReference(
|
|
2849
|
+
context,
|
|
2850
|
+
selector,
|
|
2851
|
+
selectedSwarm,
|
|
2852
|
+
(reference) => state!.resolve(reference),
|
|
2853
|
+
false,
|
|
2854
|
+
"local-first",
|
|
2855
|
+
)
|
|
2856
|
+
).cid;
|
|
2857
|
+
store = context.store;
|
|
2858
|
+
} else {
|
|
2859
|
+
let explicit = false;
|
|
2860
|
+
try {
|
|
2861
|
+
CID.parse(selector);
|
|
2862
|
+
explicit = true;
|
|
2863
|
+
} catch {
|
|
2864
|
+
/* Not a CID. */
|
|
2865
|
+
}
|
|
2866
|
+
explicit ||= selector.toLowerCase().endsWith(".car");
|
|
2867
|
+
if (!explicit) {
|
|
2868
|
+
try {
|
|
2869
|
+
await lstat(selector);
|
|
2870
|
+
explicit = true;
|
|
2871
|
+
} catch (cause) {
|
|
2872
|
+
if (
|
|
2873
|
+
!nodeError(cause, "ENOENT") &&
|
|
2874
|
+
!nodeError(cause, "ENOTDIR")
|
|
2875
|
+
)
|
|
2876
|
+
throw cause;
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
if (!explicit) {
|
|
2880
|
+
templateName(selector);
|
|
2881
|
+
if (!selectedSwarm)
|
|
2882
|
+
throw new HostError(
|
|
2883
|
+
"Template selectors require a selected Swarm. Use --swarm or swarm use, or supply an explicit Bundle directory, CAR, exact CID or IPAB URI.",
|
|
2884
|
+
);
|
|
2885
|
+
await getStore();
|
|
2886
|
+
const context = swarmContext();
|
|
2887
|
+
readContext = context;
|
|
2888
|
+
selectedTemplate = await resolveTemplateSelector(
|
|
2889
|
+
context,
|
|
2890
|
+
selector,
|
|
2891
|
+
selectedSwarm,
|
|
2892
|
+
);
|
|
2893
|
+
store = context.store;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
820
2897
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
821
2898
|
io.err(
|
|
822
2899
|
parsed.path === "build"
|
|
823
|
-
? "
|
|
2900
|
+
? "Assembling and validating Bundle (no compilation)..."
|
|
824
2901
|
: "Validating and building bundle...",
|
|
825
2902
|
);
|
|
826
2903
|
if (parsed.path === "bundle import")
|
|
827
2904
|
io.err("Validating and importing CAR into Store...");
|
|
828
2905
|
const result =
|
|
829
|
-
parsed.path === "
|
|
830
|
-
? await initApp(
|
|
2906
|
+
parsed.path === "templates render"
|
|
2907
|
+
? await initApp(second!, parsed.positional[2], {
|
|
831
2908
|
...request,
|
|
832
|
-
...(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
: {}),
|
|
841
|
-
...(parsed.parameters
|
|
842
|
-
? { parameters: parsed.parameters }
|
|
843
|
-
: {}),
|
|
2909
|
+
...(selectedTemplate ? { template: selectedTemplate } : {}),
|
|
2910
|
+
parameters: [
|
|
2911
|
+
...(parsed.parameters ?? []),
|
|
2912
|
+
...(typeof parsed.options.description === "string"
|
|
2913
|
+
? [`description=${parsed.options.description}`]
|
|
2914
|
+
: []),
|
|
2915
|
+
],
|
|
844
2916
|
})
|
|
845
2917
|
: parsed.path === "build"
|
|
846
|
-
? await
|
|
2918
|
+
? await assembleBundle(first, {
|
|
847
2919
|
...request,
|
|
848
2920
|
replace: Boolean(parsed.options.replace),
|
|
849
|
-
...(parsed.options["with-source"]
|
|
850
|
-
? { includeSource: true }
|
|
851
|
-
: parsed.options["without-source"]
|
|
852
|
-
? { includeSource: false }
|
|
853
|
-
: {}),
|
|
854
2921
|
...(typeof parsed.options.output === "string"
|
|
855
2922
|
? { output: parsed.options.output }
|
|
856
2923
|
: {}),
|
|
857
2924
|
outputDir: String(value("bundle.outputDir")),
|
|
858
2925
|
})
|
|
859
|
-
: parsed.path === "bundle
|
|
860
|
-
? await
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
:
|
|
872
|
-
? await importBundle(first!, getStore, request)
|
|
873
|
-
: await inspectBundle(source!, request);
|
|
2926
|
+
: parsed.path === "bundle build"
|
|
2927
|
+
? await buildBundle(source!, {
|
|
2928
|
+
...request,
|
|
2929
|
+
schemaOnly: Boolean(parsed.options["schema-only"]),
|
|
2930
|
+
replace: Boolean(parsed.options.replace),
|
|
2931
|
+
...(typeof parsed.options.output === "string"
|
|
2932
|
+
? { output: parsed.options.output }
|
|
2933
|
+
: {}),
|
|
2934
|
+
outputDir: String(value("bundle.outputDir")),
|
|
2935
|
+
})
|
|
2936
|
+
: parsed.path === "bundle import"
|
|
2937
|
+
? await importBundle(first!, getStore, request)
|
|
2938
|
+
: await inspectBundle(source!, request);
|
|
874
2939
|
const importing = "output" in result && !parsed.options["no-import"];
|
|
875
2940
|
if (importing) {
|
|
876
2941
|
io.err("Importing build result into Store (without pinning)...");
|
|
@@ -894,33 +2959,34 @@ async function performCli(
|
|
|
894
2959
|
if ("output" in result)
|
|
895
2960
|
emit(
|
|
896
2961
|
{ ...result, imported: importing },
|
|
897
|
-
`CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${
|
|
2962
|
+
`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)"}`,
|
|
898
2963
|
);
|
|
899
2964
|
else if (result.kind === "bundle-import")
|
|
900
2965
|
emit(
|
|
901
2966
|
result,
|
|
902
|
-
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}`,
|
|
903
|
-
);
|
|
904
|
-
else if (result.kind === "app-init") {
|
|
905
|
-
emit(
|
|
906
|
-
result,
|
|
907
|
-
`Created App project: ${result.directory}\nSchema CID: ${result.schemaCid}`,
|
|
908
|
-
);
|
|
909
|
-
io.err(
|
|
910
|
-
`Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`,
|
|
2967
|
+
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`,
|
|
911
2968
|
);
|
|
912
|
-
|
|
2969
|
+
else if (result.kind === "project-init") {
|
|
913
2970
|
emit(
|
|
914
2971
|
result,
|
|
915
|
-
`Created: ${result.directory}
|
|
916
|
-
);
|
|
917
|
-
io.err(
|
|
918
|
-
`Next: ipab bundle build ${JSON.stringify(result.directory)}`,
|
|
2972
|
+
`Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`,
|
|
919
2973
|
);
|
|
2974
|
+
if (
|
|
2975
|
+
result.files.includes("package.json") &&
|
|
2976
|
+
(result.files.includes("ipab.yaml") ||
|
|
2977
|
+
result.files.includes("ipab.json"))
|
|
2978
|
+
)
|
|
2979
|
+
io.err(
|
|
2980
|
+
`Next: install declared dependencies in ${JSON.stringify(result.directory)}; if your template does not declare @ipab/cli, add or link it as a development dependency. Run pnpm build to prepare and package the App. Root ipab build does not compile.`,
|
|
2981
|
+
);
|
|
2982
|
+
else if (result.files.includes(".bundle.yaml"))
|
|
2983
|
+
io.err(
|
|
2984
|
+
`Next: ipab bundle build ${JSON.stringify(result.directory)}`,
|
|
2985
|
+
);
|
|
920
2986
|
} else
|
|
921
2987
|
emit(
|
|
922
2988
|
result,
|
|
923
|
-
`Kind: ${result.kind}\
|
|
2989
|
+
`Kind: ${result.kind}\n${result.manifest ? `Title: ${printable(result.manifest.title)}\nEntry: ${result.manifest.entry}\nType file: ${result.manifest.type}\n` : ""}Type CID: ${result.schemaCid}\nContent type: ${result.type.contentType}\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`,
|
|
924
2990
|
);
|
|
925
2991
|
} catch (cause) {
|
|
926
2992
|
if (cancelled)
|
|
@@ -938,139 +3004,80 @@ async function performCli(
|
|
|
938
3004
|
break;
|
|
939
3005
|
}
|
|
940
3006
|
case "pin list": {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
throw new HostError(
|
|
945
|
-
"--type short names must identify a Schema pin.",
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
|
-
const type =
|
|
949
|
-
typeof parsed.options.type === "string"
|
|
950
|
-
? state.resolve(schemaAlias(parsed.options.type), true)
|
|
951
|
-
: undefined;
|
|
952
|
-
const pins = state.pins();
|
|
953
|
-
const listed = pins
|
|
954
|
-
.filter((pin) => pin.status === "ready")
|
|
955
|
-
.map(pinDetails)
|
|
956
|
-
.filter(
|
|
957
|
-
(pin) =>
|
|
958
|
-
(!parsed.options.kind || pin.kind === parsed.options.kind) &&
|
|
959
|
-
(type === undefined || pin.schemaCid === type),
|
|
960
|
-
);
|
|
961
|
-
const pending = pins
|
|
962
|
-
.filter((pin) => pin.status !== "ready")
|
|
963
|
-
.map(({ name, cid, status }) => ({ name, cid, status }));
|
|
964
|
-
const legacyAliases = state.aliases();
|
|
965
|
-
if (pending.length)
|
|
966
|
-
io.err(
|
|
967
|
-
`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`,
|
|
968
|
-
);
|
|
969
|
-
if (legacyAliases.length)
|
|
970
|
-
io.err(
|
|
971
|
-
"Legacy Alias metadata is preserved but is not pinned. Use the listed exact CIDs with pin add to migrate.",
|
|
972
|
-
);
|
|
3007
|
+
const listed = state.contentPins();
|
|
3008
|
+
const archived = state.archivedPins();
|
|
3009
|
+
const builtins = state.pins().map(pinDetails);
|
|
973
3010
|
emit(
|
|
974
|
-
{ items: listed,
|
|
3011
|
+
{ items: listed, builtins, archived },
|
|
975
3012
|
table(
|
|
976
|
-
["
|
|
977
|
-
|
|
978
|
-
pin
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
state,
|
|
1000
|
-
first!,
|
|
1001
|
-
second!,
|
|
1002
|
-
await storeConfiguration(value("store.rpc")),
|
|
1003
|
-
);
|
|
1004
|
-
emit(
|
|
1005
|
-
result,
|
|
1006
|
-
`${result.name} → ${result.cid}\nKind: ${result.kind}\nBundle type: ${printable(result.typeName ?? "(no Bundle type metadata)")}`,
|
|
3013
|
+
["REFERENCE", "CID", "STATUS", "SOURCE"],
|
|
3014
|
+
[
|
|
3015
|
+
...listed.map((pin) => [
|
|
3016
|
+
pin.reference,
|
|
3017
|
+
pin.cid ?? "(none)",
|
|
3018
|
+
`${pin.status}/${pin.freshness}${pin.error ? `: ${pin.error}` : ""}`,
|
|
3019
|
+
pin.swarm ? "following shared Name" : "fixed CID",
|
|
3020
|
+
]),
|
|
3021
|
+
...builtins.map((pin) => [
|
|
3022
|
+
pin.name,
|
|
3023
|
+
pin.cid,
|
|
3024
|
+
"read-only",
|
|
3025
|
+
"built-in",
|
|
3026
|
+
]),
|
|
3027
|
+
...archived.map((pin) => [
|
|
3028
|
+
pin.cid,
|
|
3029
|
+
pin.cid,
|
|
3030
|
+
pin.status,
|
|
3031
|
+
`inactive archive (${pin.name}); unpin exact CID`,
|
|
3032
|
+
]),
|
|
3033
|
+
],
|
|
3034
|
+
"No pins.",
|
|
3035
|
+
),
|
|
1007
3036
|
);
|
|
1008
3037
|
break;
|
|
1009
3038
|
}
|
|
1010
|
-
case "
|
|
1011
|
-
const
|
|
3039
|
+
case "unpin": {
|
|
3040
|
+
const canonical = pinReference(state, first!, selectedSwarm);
|
|
3041
|
+
const result = await unpin(state, canonical.reference);
|
|
1012
3042
|
emit(
|
|
1013
3043
|
result,
|
|
1014
|
-
`
|
|
3044
|
+
`Unpinned ${canonical.reference}; released only its saved retention responsibility. No blocks deleted or GC requested.`,
|
|
1015
3045
|
);
|
|
1016
3046
|
break;
|
|
1017
3047
|
}
|
|
1018
3048
|
case "pin show": {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
3049
|
+
const builtin = first!.startsWith("builtin:")
|
|
3050
|
+
? state.pin(first!)
|
|
3051
|
+
: undefined;
|
|
3052
|
+
const canonical = builtin
|
|
3053
|
+
? undefined
|
|
3054
|
+
: pinReference(state, first!, selectedSwarm);
|
|
3055
|
+
const pin = canonical
|
|
3056
|
+
? state.contentPin(canonical.reference)
|
|
3057
|
+
: undefined;
|
|
3058
|
+
const archived = canonical
|
|
3059
|
+
? state
|
|
3060
|
+
.archivedPins()
|
|
3061
|
+
.filter((pin) => pin.cid === canonical.reference)
|
|
3062
|
+
: [];
|
|
3063
|
+
if (!pin && !builtin && !archived.length)
|
|
1021
3064
|
throw new HostError(
|
|
1022
3065
|
`Pin "${first}" does not exist. Run ipab pin list.`,
|
|
1023
3066
|
);
|
|
1024
|
-
const result =
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
const result = renamePin(state, first!, second!);
|
|
1033
|
-
emit(result, `${first} → ${result.name} (${result.cid})`);
|
|
1034
|
-
break;
|
|
1035
|
-
}
|
|
1036
|
-
case "register list": {
|
|
1037
|
-
const associations = state.registrations();
|
|
1038
|
-
emit(
|
|
1039
|
-
{ items: associations },
|
|
1040
|
-
table(
|
|
1041
|
-
["SCHEMA CID", "APP CID", "ARGV"],
|
|
1042
|
-
associations.map((association) => [
|
|
1043
|
-
association.schemaCid,
|
|
1044
|
-
association.appCid,
|
|
1045
|
-
JSON.stringify(association.argv),
|
|
1046
|
-
]),
|
|
1047
|
-
"No associations.",
|
|
1048
|
-
),
|
|
1049
|
-
);
|
|
1050
|
-
break;
|
|
1051
|
-
}
|
|
1052
|
-
case "register set": {
|
|
1053
|
-
const association = state.setAssociation(
|
|
1054
|
-
schemaAlias(first!),
|
|
1055
|
-
second!,
|
|
1056
|
-
parsed.template ?? ["%"],
|
|
1057
|
-
Boolean(parsed.options.replace),
|
|
1058
|
-
);
|
|
1059
|
-
emit(
|
|
1060
|
-
association,
|
|
1061
|
-
`${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
1062
|
-
);
|
|
1063
|
-
break;
|
|
1064
|
-
}
|
|
1065
|
-
case "register remove": {
|
|
1066
|
-
const removed = state.removeAssociation(schemaAlias(first!));
|
|
1067
|
-
emit({ removed: [removed] }, `Removed association for ${removed}.`);
|
|
3067
|
+
const result = builtin
|
|
3068
|
+
? pinDetails(builtin)
|
|
3069
|
+
: {
|
|
3070
|
+
pin: pin ?? null,
|
|
3071
|
+
roots: pin ? state.hold(pin.owner)?.roots : [],
|
|
3072
|
+
archived,
|
|
3073
|
+
};
|
|
3074
|
+
emit(result, JSON.stringify(result, null, 2));
|
|
1068
3075
|
break;
|
|
1069
3076
|
}
|
|
1070
3077
|
case "config get": {
|
|
1071
|
-
const selected =
|
|
1072
|
-
? items.filter((item) => item.key === first)
|
|
1073
|
-
|
|
3078
|
+
const selected = (
|
|
3079
|
+
first ? items.filter((item) => item.key === first) : items
|
|
3080
|
+
).map(visibleConfig);
|
|
1074
3081
|
emit(
|
|
1075
3082
|
{ items: selected },
|
|
1076
3083
|
table(
|
|
@@ -1083,14 +3090,21 @@ async function performCli(
|
|
|
1083
3090
|
}
|
|
1084
3091
|
case "config set": {
|
|
1085
3092
|
const key = configKey(first!);
|
|
1086
|
-
const saved = parseValue(
|
|
3093
|
+
const saved = parseValue(
|
|
3094
|
+
key,
|
|
3095
|
+
key === "pointers.apiKey"
|
|
3096
|
+
? await (io.readSecret ?? processIO.readSecret!)()
|
|
3097
|
+
: second,
|
|
3098
|
+
true,
|
|
3099
|
+
);
|
|
1087
3100
|
state.setConfig(key, saved);
|
|
1088
3101
|
const source = items.find((item) => item.key === key)!.source;
|
|
1089
3102
|
if (source === "env" || source === "flag")
|
|
1090
3103
|
io.err(`Warning: saved user value is masked by ${source}.`);
|
|
3104
|
+
const display = visibleConfig({ key, value: saved, source: "user" });
|
|
1091
3105
|
emit(
|
|
1092
|
-
|
|
1093
|
-
`Saved ${key} = ${printable(String(
|
|
3106
|
+
display,
|
|
3107
|
+
`Saved ${key} = ${printable(String(display.value))} (user).`,
|
|
1094
3108
|
);
|
|
1095
3109
|
break;
|
|
1096
3110
|
}
|
|
@@ -1185,13 +3199,93 @@ async function performCli(
|
|
|
1185
3199
|
}
|
|
1186
3200
|
case "exec":
|
|
1187
3201
|
case "open": {
|
|
3202
|
+
const named =
|
|
3203
|
+
parsed.path === "open" ? parseNameReference(first!) : undefined;
|
|
3204
|
+
const registrySwarm = named?.swarm
|
|
3205
|
+
? state.resolveSwarm(named.swarm)
|
|
3206
|
+
: selectedSwarm;
|
|
3207
|
+
if (parsed.path === "open" && !registrySwarm)
|
|
3208
|
+
throw new HostError(
|
|
3209
|
+
"Open requires a selected Swarm. Use ipab://URL_OR_ALIAS/PATH, pass --swarm URL_OR_ALIAS, or save a default with ipab swarm use URL_OR_ALIAS. To select an App directly, use ipab exec.",
|
|
3210
|
+
);
|
|
1188
3211
|
if (parsed.options.log && !value("history.enabled"))
|
|
1189
3212
|
throw new HostError(
|
|
1190
3213
|
"Execution logging requires history.enabled=true.",
|
|
1191
3214
|
);
|
|
1192
|
-
const target = state.resolve(first!);
|
|
1193
3215
|
await recoverInactive(state);
|
|
1194
|
-
store = new IpfsStore(await storeConfiguration(value("store.
|
|
3216
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
3217
|
+
const context = swarmContext();
|
|
3218
|
+
readContext = context;
|
|
3219
|
+
const target = (
|
|
3220
|
+
await resolveReference(
|
|
3221
|
+
context,
|
|
3222
|
+
first!,
|
|
3223
|
+
selectedSwarm,
|
|
3224
|
+
(reference) => state!.resolve(reference),
|
|
3225
|
+
Boolean(parsed.options.raw),
|
|
3226
|
+
"local-first",
|
|
3227
|
+
)
|
|
3228
|
+
).cid;
|
|
3229
|
+
store = context.store;
|
|
3230
|
+
const resolveBundleReference = async (
|
|
3231
|
+
reference: string,
|
|
3232
|
+
signal: AbortSignal,
|
|
3233
|
+
preferredSwarm?: string,
|
|
3234
|
+
) => {
|
|
3235
|
+
signal.throwIfAborted();
|
|
3236
|
+
const lookup: SwarmContext = {
|
|
3237
|
+
...swarmContext(),
|
|
3238
|
+
store: new IpfsStore(
|
|
3239
|
+
await storeConfiguration(value("store.gateway")),
|
|
3240
|
+
),
|
|
3241
|
+
};
|
|
3242
|
+
try {
|
|
3243
|
+
const named = parseNameReference(reference);
|
|
3244
|
+
const swarm = named?.swarm
|
|
3245
|
+
? state!.resolveSwarm(named.swarm)
|
|
3246
|
+
: preferredSwarm
|
|
3247
|
+
? state!.resolveSwarm(preferredSwarm)
|
|
3248
|
+
: selectedSwarm;
|
|
3249
|
+
const resolve = (source: string | undefined) =>
|
|
3250
|
+
resolveReference(
|
|
3251
|
+
lookup,
|
|
3252
|
+
reference,
|
|
3253
|
+
source,
|
|
3254
|
+
(input) => state!.resolve(input),
|
|
3255
|
+
false,
|
|
3256
|
+
"local-first",
|
|
3257
|
+
);
|
|
3258
|
+
let resolved;
|
|
3259
|
+
try {
|
|
3260
|
+
resolved = await resolve(named ? swarm : undefined);
|
|
3261
|
+
} catch (cause) {
|
|
3262
|
+
let failure: unknown = cause;
|
|
3263
|
+
for (
|
|
3264
|
+
let depth = 0;
|
|
3265
|
+
depth < 8 && failure instanceof ContentBundleError;
|
|
3266
|
+
depth++
|
|
3267
|
+
)
|
|
3268
|
+
failure = failure.cause;
|
|
3269
|
+
if (
|
|
3270
|
+
named ||
|
|
3271
|
+
!swarm ||
|
|
3272
|
+
!(failure instanceof ContentError) ||
|
|
3273
|
+
failure.code !== "missing_block"
|
|
3274
|
+
)
|
|
3275
|
+
throw cause;
|
|
3276
|
+
signal.throwIfAborted();
|
|
3277
|
+
resolved = await resolve(swarm);
|
|
3278
|
+
}
|
|
3279
|
+
signal.throwIfAborted();
|
|
3280
|
+
return { ...resolved, ...(swarm ? { swarm } : {}) };
|
|
3281
|
+
} finally {
|
|
3282
|
+
try {
|
|
3283
|
+
await lookup.finishRead?.();
|
|
3284
|
+
} finally {
|
|
3285
|
+
await lookup.store.close();
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
};
|
|
1195
3289
|
let appCid: string;
|
|
1196
3290
|
let appArgv: string[];
|
|
1197
3291
|
if (parsed.path === "open") {
|
|
@@ -1205,15 +3299,39 @@ async function performCli(
|
|
|
1205
3299
|
try {
|
|
1206
3300
|
const content = await validatedBundle(root, store, owner);
|
|
1207
3301
|
const schema = content.schemaKey;
|
|
1208
|
-
|
|
3302
|
+
let association: Association | undefined;
|
|
3303
|
+
if (registrySwarm) {
|
|
3304
|
+
const lookup: SwarmContext = {
|
|
3305
|
+
...swarmContext(),
|
|
3306
|
+
store: new IpfsStore(
|
|
3307
|
+
await storeConfiguration(value("store.gateway")),
|
|
3308
|
+
),
|
|
3309
|
+
};
|
|
3310
|
+
try {
|
|
3311
|
+
association = await swarmAssociation(
|
|
3312
|
+
lookup,
|
|
3313
|
+
registrySwarm,
|
|
3314
|
+
schema,
|
|
3315
|
+
"local-first",
|
|
3316
|
+
);
|
|
3317
|
+
} finally {
|
|
3318
|
+
try {
|
|
3319
|
+
await lookup.finishRead?.();
|
|
3320
|
+
} finally {
|
|
3321
|
+
await lookup.store.close();
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
1209
3325
|
if (!association)
|
|
1210
3326
|
throw new HostError(
|
|
1211
|
-
`No App registered for Schema ${schema}. Use ipab register set or ipab exec.`,
|
|
3327
|
+
`No App registered for Schema ${schema} in Swarm ${registrySwarm}. Use ipab register set ${schema} APP_CID --swarm ${registrySwarm} or ipab exec.`,
|
|
1212
3328
|
);
|
|
1213
3329
|
appCid = association.appCid;
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
3330
|
+
if (association.argv.length !== 1 || association.argv[0] !== "%")
|
|
3331
|
+
throw new HostError(
|
|
3332
|
+
"Custom per-association argv is unsupported; adapt the App to accept only the content CID or use ipab exec APP_CID ARGS.",
|
|
3333
|
+
);
|
|
3334
|
+
appArgv = [root];
|
|
1217
3335
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
1218
3336
|
const result = await execute(
|
|
1219
3337
|
state,
|
|
@@ -1221,6 +3339,7 @@ async function performCli(
|
|
|
1221
3339
|
{ origin: "open", appCid, argv: appArgv },
|
|
1222
3340
|
{
|
|
1223
3341
|
inputSchema: schema,
|
|
3342
|
+
resolveBundleReference,
|
|
1224
3343
|
history: Boolean(value("history.enabled")),
|
|
1225
3344
|
retain: value("output.retention") === "history",
|
|
1226
3345
|
log: Boolean(parsed.options.log),
|
|
@@ -1244,6 +3363,7 @@ async function performCli(
|
|
|
1244
3363
|
store,
|
|
1245
3364
|
{ origin: "exec", appCid, argv: appArgv },
|
|
1246
3365
|
{
|
|
3366
|
+
resolveBundleReference,
|
|
1247
3367
|
history: Boolean(value("history.enabled")),
|
|
1248
3368
|
retain: value("output.retention") === "history",
|
|
1249
3369
|
log: Boolean(parsed.options.log),
|
|
@@ -1264,7 +3384,11 @@ async function performCli(
|
|
|
1264
3384
|
return error instanceof HostError ? error.exitCode : 1;
|
|
1265
3385
|
} finally {
|
|
1266
3386
|
try {
|
|
1267
|
-
|
|
3387
|
+
try {
|
|
3388
|
+
await readContext?.finishRead?.();
|
|
3389
|
+
} finally {
|
|
3390
|
+
await closeStore(store, appExitCode);
|
|
3391
|
+
}
|
|
1268
3392
|
} finally {
|
|
1269
3393
|
state?.close();
|
|
1270
3394
|
}
|