@ipab/cli 0.1.0-rc.1 → 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 +226 -9
- package/dist/app-authoring.d.ts +15 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +144 -58
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -57
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -38
- 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 +8 -46
- 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 +4 -8
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +25 -15
- 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 +1 -23
- 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 +1919 -256
- 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 +7 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +151 -8
- 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 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +54 -10
- 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 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +124 -12
- 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 +16 -18
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +144 -106
- 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 -8
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +17 -12
- 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 +115 -13
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +492 -91
- 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 +47 -52
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +36 -41
- 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 +14 -7
- package/src/app-authoring.ts +240 -76
- package/src/app-definition.ts +33 -39
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +17 -73
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +41 -17
- package/src/builtins.ts +2 -27
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +2399 -320
- package/src/config-secret.ts +14 -0
- package/src/config.ts +196 -8
- package/src/content-provider.ts +299 -0
- package/src/context-types.ts +11 -0
- package/src/context.ts +98 -10
- 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 +160 -11
- 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 +188 -126
- 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 -4
- 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 -13
- 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 +759 -107
- 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 +36 -41
- 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,40 +27,135 @@ import {
|
|
|
24
27
|
} from "./history.js";
|
|
25
28
|
import { execute } from "./runtime.js";
|
|
26
29
|
import { validatedBundle } from "./space.js";
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
import {
|
|
31
|
+
createAssociation,
|
|
32
|
+
exactCid,
|
|
33
|
+
swarmAlias,
|
|
34
|
+
State,
|
|
35
|
+
type Association,
|
|
36
|
+
type RunRecord,
|
|
37
|
+
} from "./state.js";
|
|
38
|
+
import {
|
|
39
|
+
buildBundle,
|
|
40
|
+
inspectBundle,
|
|
41
|
+
importBundle,
|
|
42
|
+
nodeError,
|
|
43
|
+
} from "./authoring.js";
|
|
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";
|
|
30
92
|
import { schemaAlias } from "./app-definition.js";
|
|
31
|
-
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";
|
|
32
100
|
import { logFiles } from "./logs.js";
|
|
33
101
|
import { builtinContent } from "./builtins.js";
|
|
102
|
+
import { readSecretStream } from "./config-secret.js";
|
|
103
|
+
import { manageSkills, syncDaemonSwarm } from "./skills.js";
|
|
34
104
|
|
|
35
105
|
export interface IO {
|
|
36
106
|
out(text: string): void;
|
|
37
|
-
err(text: string): void;
|
|
107
|
+
err(text: string, progress?: boolean): void;
|
|
38
108
|
tty: boolean;
|
|
39
109
|
columns?(): number | undefined;
|
|
40
|
-
confirm(text: string): Promise<boolean>;
|
|
110
|
+
confirm(text: string, signal?: AbortSignal): Promise<boolean>;
|
|
111
|
+
readSecret?(): Promise<string>;
|
|
112
|
+
requestInput?(): AsyncIterable<string | Uint8Array>;
|
|
41
113
|
}
|
|
114
|
+
let progressLine = false;
|
|
42
115
|
export const processIO: IO = {
|
|
43
116
|
out(text) {
|
|
44
117
|
process.stdout.write(`${text}\n`);
|
|
45
118
|
},
|
|
46
|
-
err(text) {
|
|
47
|
-
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
|
+
}
|
|
48
129
|
},
|
|
49
130
|
tty: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
50
131
|
columns() {
|
|
51
132
|
return process.stdout.columns;
|
|
52
133
|
},
|
|
53
|
-
|
|
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) {
|
|
54
150
|
const reader = createInterface({
|
|
55
151
|
input: process.stdin,
|
|
56
152
|
output: process.stderr,
|
|
57
153
|
});
|
|
58
154
|
try {
|
|
59
155
|
return /^(y|yes)$/i.test(
|
|
60
|
-
(
|
|
156
|
+
(
|
|
157
|
+
await reader.question(`${text} [y/N] `, signal ? { signal } : {})
|
|
158
|
+
).trim(),
|
|
61
159
|
);
|
|
62
160
|
} finally {
|
|
63
161
|
reader.close();
|
|
@@ -65,23 +163,54 @@ export const processIO: IO = {
|
|
|
65
163
|
},
|
|
66
164
|
};
|
|
67
165
|
const commands: Record<string, string> = {
|
|
68
|
-
|
|
69
|
-
|
|
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]",
|
|
70
194
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
71
195
|
"bundle inspect": "bundle inspect SOURCE",
|
|
72
196
|
"bundle import": "bundle import FILE.car",
|
|
73
|
-
exec: "exec [--log] APP [APP_ARGS...]",
|
|
74
|
-
open: "open [--log] CONTENT",
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"pin list": "pin list
|
|
78
|
-
"pin show": "pin show
|
|
79
|
-
"
|
|
80
|
-
"register
|
|
81
|
-
|
|
82
|
-
"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",
|
|
83
211
|
"config get": "config get [KEY]",
|
|
84
|
-
"config set":
|
|
212
|
+
"config set":
|
|
213
|
+
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
85
214
|
"config reset": "config reset KEY",
|
|
86
215
|
"store usage": "store usage",
|
|
87
216
|
"store gc": "store gc",
|
|
@@ -91,9 +220,12 @@ const commands: Record<string, string> = {
|
|
|
91
220
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
92
221
|
};
|
|
93
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",
|
|
94
225
|
bundle: "Create, inspect and import content bundles",
|
|
95
|
-
pin: "Retain
|
|
226
|
+
pin: "Retain an exact CID or follow a shared Swarm Name",
|
|
96
227
|
register: "Associate content types with Apps",
|
|
228
|
+
templates: "Inspect, render and manage Template Bundles",
|
|
97
229
|
config: "Manage local configuration",
|
|
98
230
|
store: "Query local storage and collect unreferenced blocks",
|
|
99
231
|
history: "View and remove execution history",
|
|
@@ -108,6 +240,412 @@ const commandHelp: Record<
|
|
|
108
240
|
notes?: string[];
|
|
109
241
|
}
|
|
110
242
|
> = {
|
|
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",
|
|
629
|
+
options: [
|
|
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
|
+
},
|
|
111
649
|
"store usage": {
|
|
112
650
|
summary: "Query cached and recursively pinned block bytes",
|
|
113
651
|
examples: ["ipab store usage", "ipab --json store usage"],
|
|
@@ -124,37 +662,48 @@ const commandHelp: Record<
|
|
|
124
662
|
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
125
663
|
],
|
|
126
664
|
},
|
|
127
|
-
|
|
128
|
-
summary: "
|
|
129
|
-
arguments: [
|
|
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
|
+
],
|
|
130
671
|
options: [
|
|
131
|
-
"--
|
|
672
|
+
"--description TEXT Set the declared description parameter.",
|
|
673
|
+
"--refresh / --no-refresh Refresh Swarm HEAD now / allow its valid cached snapshot.",
|
|
132
674
|
"--param KEY=VALUE Template parameter; repeatable. Strings are literal;",
|
|
133
675
|
" other parameter types use JSON.",
|
|
134
676
|
],
|
|
135
677
|
examples: [
|
|
136
|
-
"ipab
|
|
137
|
-
"ipab
|
|
138
|
-
"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.",
|
|
139
686
|
],
|
|
140
|
-
notes: ["Does not install dependencies or execute template code."],
|
|
141
687
|
},
|
|
142
688
|
build: {
|
|
143
|
-
summary: "
|
|
144
|
-
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
|
+
],
|
|
145
693
|
options: [
|
|
146
|
-
"-o, --output FILE Destination (default: dist/
|
|
694
|
+
"-o, --output FILE Destination (default: dist/bundle.car).",
|
|
147
695
|
"--replace Allow replacing existing regular artifacts.",
|
|
148
|
-
"--no-import Write CAR
|
|
149
|
-
|
|
150
|
-
|
|
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",
|
|
151
701
|
],
|
|
152
|
-
examples: ["ipab build", "ipab build hello --replace --without-source"],
|
|
153
702
|
notes: [
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
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.",
|
|
158
707
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
159
708
|
],
|
|
160
709
|
},
|
|
@@ -169,7 +718,7 @@ const commandHelp: Record<
|
|
|
169
718
|
],
|
|
170
719
|
examples: [
|
|
171
720
|
"ipab bundle build note",
|
|
172
|
-
"ipab bundle build types\\.bundle.yaml --schema-only",
|
|
721
|
+
"ipab bundle build types\\.bundle-type.yaml --schema-only",
|
|
173
722
|
],
|
|
174
723
|
notes: [
|
|
175
724
|
"Imports into the configured Store without pinning or executing Apps.",
|
|
@@ -178,7 +727,9 @@ const commandHelp: Record<
|
|
|
178
727
|
},
|
|
179
728
|
"bundle inspect": {
|
|
180
729
|
summary: "Inspect a Bundle or type definition",
|
|
181
|
-
arguments: [
|
|
730
|
+
arguments: [
|
|
731
|
+
"SOURCE Directory, definition file, CAR, CID or packaged builtin reference.",
|
|
732
|
+
],
|
|
182
733
|
examples: ["ipab bundle inspect note\\dist\\bundle.car"],
|
|
183
734
|
notes: ["Does not execute Apps, import content or create pins."],
|
|
184
735
|
},
|
|
@@ -188,24 +739,27 @@ const commandHelp: Record<
|
|
|
188
739
|
examples: ["ipab bundle import hello\\dist\\app.car"],
|
|
189
740
|
notes: [
|
|
190
741
|
"Repeated imports are safe; no App execution or daemon startup.",
|
|
191
|
-
"Does not pin or retain content. Use pin
|
|
742
|
+
"Does not pin or retain content. Use pin CID for persistent retention.",
|
|
192
743
|
],
|
|
193
744
|
},
|
|
194
745
|
exec: {
|
|
195
|
-
summary: "Run an App by CID or
|
|
746
|
+
summary: "Run an App by exact CID or Swarm IPAB URI",
|
|
196
747
|
arguments: [
|
|
197
748
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
198
749
|
],
|
|
199
750
|
options: [
|
|
200
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.",
|
|
201
754
|
],
|
|
202
755
|
examples: [
|
|
203
756
|
"ipab exec reader",
|
|
204
|
-
"ipab exec reader --help",
|
|
205
757
|
"ipab exec --log reader",
|
|
758
|
+
"ipab exec ipab://work/apps/hello --help",
|
|
206
759
|
],
|
|
207
760
|
notes: [
|
|
208
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.",
|
|
209
763
|
"History stores argv by default; do not put secrets in arguments.",
|
|
210
764
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
211
765
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -213,90 +767,126 @@ const commandHelp: Record<
|
|
|
213
767
|
},
|
|
214
768
|
open: {
|
|
215
769
|
summary: "Open content with its registered App",
|
|
216
|
-
arguments: [
|
|
217
|
-
|
|
218
|
-
|
|
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
|
+
],
|
|
219
784
|
notes: [
|
|
220
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.",
|
|
221
791
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
222
792
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
223
793
|
"--json is not supported; App stdio is passed through.",
|
|
224
794
|
],
|
|
225
795
|
},
|
|
226
|
-
|
|
227
|
-
summary: "
|
|
796
|
+
pin: {
|
|
797
|
+
summary: "Retain an immutable CID or follow a shared Swarm Name",
|
|
228
798
|
arguments: [
|
|
229
|
-
"
|
|
230
|
-
|
|
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",
|
|
231
808
|
],
|
|
232
|
-
examples: ["ipab pin add reader APP_CID"],
|
|
233
809
|
notes: [
|
|
234
810
|
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
235
|
-
"
|
|
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.",
|
|
236
814
|
"The builtin namespace is read-only.",
|
|
237
815
|
],
|
|
238
816
|
},
|
|
239
|
-
|
|
240
|
-
summary: "
|
|
241
|
-
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"],
|
|
242
820
|
notes: [
|
|
243
821
|
"Releases only this pin's ownership on its original backend; no block deletion or GC.",
|
|
244
|
-
"
|
|
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.",
|
|
245
825
|
],
|
|
246
826
|
},
|
|
247
827
|
"pin list": {
|
|
248
|
-
summary: "List
|
|
249
|
-
|
|
250
|
-
"--type TYPE Exact type CID or the name of a Bundle pin of that type.",
|
|
251
|
-
],
|
|
252
|
-
examples: ["ipab pin list", "ipab pin list --type reader"],
|
|
828
|
+
summary: "List local retention, following Names and packaged built-ins",
|
|
829
|
+
examples: ["ipab pin list"],
|
|
253
830
|
notes: [
|
|
254
|
-
"
|
|
255
|
-
"Legacy retention is preserved; use
|
|
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.",
|
|
256
833
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
257
834
|
],
|
|
258
835
|
},
|
|
259
836
|
"pin show": {
|
|
260
|
-
summary: "Show
|
|
261
|
-
examples: ["ipab pin show
|
|
837
|
+
summary: "Show saved retention and following status",
|
|
838
|
+
examples: ["ipab pin show APP_CID"],
|
|
262
839
|
notes: [
|
|
263
840
|
"Reads local metadata; built-in pins do not claim user Store retention.",
|
|
264
841
|
],
|
|
265
842
|
},
|
|
266
|
-
"
|
|
267
|
-
summary: "
|
|
268
|
-
|
|
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"],
|
|
269
849
|
notes: [
|
|
270
|
-
"
|
|
271
|
-
"
|
|
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.",
|
|
272
852
|
],
|
|
273
853
|
},
|
|
274
|
-
"register list": {
|
|
275
|
-
summary: "List saved content-type associations",
|
|
276
|
-
examples: ["ipab register list"],
|
|
277
|
-
},
|
|
278
854
|
"register set": {
|
|
279
855
|
summary: "Associate a content type with an App",
|
|
280
856
|
arguments: [
|
|
281
857
|
"SCHEMA Exact type CID or builtin:node-app.v1.",
|
|
282
|
-
"APP App CID or
|
|
283
|
-
|
|
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.",
|
|
284
863
|
],
|
|
285
|
-
options: ["--replace Allow changing an existing association."],
|
|
286
864
|
examples: [
|
|
287
|
-
"ipab register set SCHEMA_CID
|
|
288
|
-
"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",
|
|
289
867
|
],
|
|
290
868
|
notes: [
|
|
291
|
-
"
|
|
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.",
|
|
292
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.",
|
|
293
874
|
],
|
|
294
875
|
},
|
|
295
876
|
"register remove": {
|
|
296
877
|
summary: "Remove a saved content-type association",
|
|
297
878
|
arguments: ["SCHEMA Exact type CID or builtin:node-app.v1."],
|
|
298
|
-
|
|
299
|
-
|
|
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
|
+
],
|
|
300
890
|
},
|
|
301
891
|
"config get": {
|
|
302
892
|
summary: "Show effective configuration",
|
|
@@ -306,11 +896,15 @@ const commandHelp: Record<
|
|
|
306
896
|
"config set": {
|
|
307
897
|
summary: "Save a local configuration value",
|
|
308
898
|
examples: [
|
|
899
|
+
"ipab config set pointers.apiKey -",
|
|
309
900
|
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
310
901
|
"ipab config set history.enabled false",
|
|
311
902
|
],
|
|
312
903
|
notes: [
|
|
313
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.",
|
|
314
908
|
],
|
|
315
909
|
},
|
|
316
910
|
"config reset": {
|
|
@@ -320,7 +914,7 @@ const commandHelp: Record<
|
|
|
320
914
|
"history list": {
|
|
321
915
|
summary: "List execution history",
|
|
322
916
|
options: [
|
|
323
|
-
"--app APP Filter by App CID
|
|
917
|
+
"--app APP Filter by exact App CID.",
|
|
324
918
|
"--status STATUS succeeded, failed or cancelled.",
|
|
325
919
|
"--since TIME Include runs ended at or after TIME.",
|
|
326
920
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -343,7 +937,7 @@ const commandHelp: Record<
|
|
|
343
937
|
"history remove": {
|
|
344
938
|
summary: "Remove execution records and their logs",
|
|
345
939
|
options: [
|
|
346
|
-
"--app APP Filter by App CID
|
|
940
|
+
"--app APP Filter by exact App CID.",
|
|
347
941
|
"--status STATUS succeeded, failed or cancelled.",
|
|
348
942
|
"--since TIME Include runs ended at or after TIME.",
|
|
349
943
|
"--until TIME Include runs ended before TIME.",
|
|
@@ -363,7 +957,8 @@ const commandHelp: Record<
|
|
|
363
957
|
|
|
364
958
|
export function help(path = ""): string {
|
|
365
959
|
const globalOptions = `Global options (before COMMAND):
|
|
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
|
|
367
962
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
368
963
|
--json Output management/development metadata, not App stdio`;
|
|
369
964
|
const footer =
|
|
@@ -378,12 +973,20 @@ Run Apps:
|
|
|
378
973
|
open ${commandHelp.open!.summary}
|
|
379
974
|
|
|
380
975
|
Create:
|
|
381
|
-
|
|
976
|
+
templates ${groups.templates}
|
|
382
977
|
build ${commandHelp.build!.summary}
|
|
383
978
|
bundle ${groups.bundle}
|
|
384
979
|
|
|
385
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}
|
|
386
988
|
pin ${groups.pin}
|
|
989
|
+
unpin ${commandHelp.unpin!.summary}
|
|
387
990
|
register ${groups.register}
|
|
388
991
|
config ${groups.config}
|
|
389
992
|
store ${groups.store}
|
|
@@ -404,9 +1007,39 @@ ${footer}`;
|
|
|
404
1007
|
return [
|
|
405
1008
|
`${topic.summary}.\n\nUsage: ipab [GLOBAL_OPTIONS] ${usage}`,
|
|
406
1009
|
...(topic.arguments ? [section("Arguments", topic.arguments)] : []),
|
|
407
|
-
...(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
|
+
: []),
|
|
408
1022
|
section("Examples", topic.examples),
|
|
409
|
-
...(
|
|
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
|
+
: []),
|
|
410
1043
|
`\n\n-h, --help shows this help. Global options: see 'ipab --help'.\n${footer}`,
|
|
411
1044
|
].join("");
|
|
412
1045
|
}
|
|
@@ -435,6 +1068,25 @@ function printable(text: string): string {
|
|
|
435
1068
|
.join("");
|
|
436
1069
|
}
|
|
437
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
|
+
|
|
438
1090
|
function runTime(value: string, field: "start" | "end"): string {
|
|
439
1091
|
const date = new Date(value);
|
|
440
1092
|
if (!Number.isFinite(date.getTime()))
|
|
@@ -477,26 +1129,24 @@ function storageBytes(bytes: number): string {
|
|
|
477
1129
|
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
478
1130
|
}
|
|
479
1131
|
|
|
480
|
-
function
|
|
481
|
-
if (!rows.length) return empty;
|
|
1132
|
+
function alignedRows(rows: string[][]): string[] {
|
|
482
1133
|
const cells = rows.map((row) => row.map(printable));
|
|
483
|
-
const widths =
|
|
484
|
-
cells.reduce(
|
|
485
|
-
(width, row) => Math.max(width, stringWidth(row[column]!)),
|
|
486
|
-
stringWidth(header),
|
|
487
|
-
),
|
|
1134
|
+
const widths = (cells[0] ?? []).map((_, column) =>
|
|
1135
|
+
cells.reduce((width, row) => Math.max(width, stringWidth(row[column]!)), 0),
|
|
488
1136
|
);
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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;
|
|
500
1150
|
}
|
|
501
1151
|
|
|
502
1152
|
function runDetails(record: RunRecord): string {
|
|
@@ -536,9 +1186,17 @@ interface Parsed {
|
|
|
536
1186
|
options: Record<string, string | boolean>;
|
|
537
1187
|
template?: string[];
|
|
538
1188
|
parameters?: string[];
|
|
1189
|
+
registrySwarms?: string[];
|
|
1190
|
+
agents?: string[];
|
|
539
1191
|
help: boolean;
|
|
540
1192
|
version: boolean;
|
|
541
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
|
+
}
|
|
542
1200
|
|
|
543
1201
|
async function closeStore(
|
|
544
1202
|
store: IpfsStore | undefined,
|
|
@@ -559,6 +1217,7 @@ async function closeStore(
|
|
|
559
1217
|
export function parse(argv: readonly string[]): Parsed {
|
|
560
1218
|
const tokens = [...argv];
|
|
561
1219
|
const flags: GlobalOptions = { json: false };
|
|
1220
|
+
const swarms: string[] = [];
|
|
562
1221
|
while (tokens[0]?.startsWith("-")) {
|
|
563
1222
|
const flag = tokens.shift()!;
|
|
564
1223
|
if (flag === "-h" || flag === "--help")
|
|
@@ -586,16 +1245,31 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
586
1245
|
syntax(
|
|
587
1246
|
"Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.",
|
|
588
1247
|
);
|
|
589
|
-
else if (
|
|
1248
|
+
else if (
|
|
1249
|
+
flag === "--state-dir" ||
|
|
1250
|
+
flag === "--store-gateway" ||
|
|
1251
|
+
flag === "--swarm"
|
|
1252
|
+
) {
|
|
590
1253
|
const value = tokens.shift();
|
|
591
1254
|
if (!value || value.startsWith("-")) syntax(`${flag} needs a value.`);
|
|
592
1255
|
if (flag === "--state-dir") flags.stateDir = value;
|
|
593
|
-
else {
|
|
1256
|
+
else if (flag === "--swarm") {
|
|
1257
|
+
flags.swarm = value;
|
|
1258
|
+
swarms.push(value);
|
|
1259
|
+
} else {
|
|
594
1260
|
flags.storeGateway = publicUrl(value);
|
|
595
1261
|
}
|
|
596
1262
|
} else syntax(`Unknown global option "${flag}".`);
|
|
597
1263
|
}
|
|
598
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.");
|
|
599
1273
|
const result: Parsed = {
|
|
600
1274
|
flags,
|
|
601
1275
|
path: group,
|
|
@@ -603,14 +1277,22 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
603
1277
|
options: {},
|
|
604
1278
|
help: !group,
|
|
605
1279
|
version: false,
|
|
1280
|
+
...(group === "register" ? { registrySwarms: swarms } : {}),
|
|
606
1281
|
};
|
|
607
1282
|
if (!group) return result;
|
|
608
1283
|
if (group === "exec") {
|
|
609
1284
|
if (flags.json) syntax("--json is not supported for exec/open.");
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
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;
|
|
613
1294
|
}
|
|
1295
|
+
validateRefreshOptions(result.options);
|
|
614
1296
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
615
1297
|
result.help = true;
|
|
616
1298
|
return result;
|
|
@@ -620,21 +1302,66 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
620
1302
|
result.positional = tokens;
|
|
621
1303
|
return result;
|
|
622
1304
|
}
|
|
623
|
-
if (
|
|
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
|
+
) {
|
|
624
1318
|
if (
|
|
625
|
-
![
|
|
626
|
-
|
|
627
|
-
|
|
1319
|
+
![
|
|
1320
|
+
"bundle",
|
|
1321
|
+
"pin",
|
|
1322
|
+
"register",
|
|
1323
|
+
"templates",
|
|
1324
|
+
"config",
|
|
1325
|
+
"history",
|
|
1326
|
+
"store",
|
|
1327
|
+
"swarm",
|
|
1328
|
+
"skills",
|
|
1329
|
+
].includes(group)
|
|
628
1330
|
)
|
|
629
|
-
syntax(
|
|
630
|
-
|
|
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") {
|
|
631
1340
|
result.help = true;
|
|
632
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()!}`;
|
|
633
1349
|
}
|
|
634
|
-
result.path = `${group} ${tokens.shift()!}`;
|
|
635
1350
|
} else if (group === "open" && flags.json)
|
|
636
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
|
+
);
|
|
637
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
|
+
);
|
|
638
1365
|
const separator = result.path === "register set" ? tokens.indexOf("--") : -1;
|
|
639
1366
|
if (separator >= 0) result.template = tokens.splice(separator + 1);
|
|
640
1367
|
if (separator >= 0) tokens.splice(separator);
|
|
@@ -642,66 +1369,230 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
642
1369
|
result.help = true;
|
|
643
1370
|
return result;
|
|
644
1371
|
}
|
|
645
|
-
|
|
646
|
-
result.path === "
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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");
|
|
657
1429
|
const values =
|
|
658
|
-
result.path === "
|
|
659
|
-
? ["
|
|
660
|
-
: result.path === "
|
|
1430
|
+
result.path === "swarm create"
|
|
1431
|
+
? ["service", "resume", "name", "description", "alias"]
|
|
1432
|
+
: result.path === "swarm request"
|
|
661
1433
|
? ["output"]
|
|
662
|
-
: result.path === "
|
|
663
|
-
? ["
|
|
664
|
-
: result.path === "
|
|
665
|
-
? ["
|
|
666
|
-
: result.path === "
|
|
667
|
-
? ["
|
|
668
|
-
:
|
|
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
|
+
: [];
|
|
669
1467
|
while (tokens.length) {
|
|
670
1468
|
const value = tokens.shift()!;
|
|
671
|
-
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") {
|
|
672
1475
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
673
|
-
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") {
|
|
674
1498
|
const input = tokens.shift();
|
|
675
1499
|
if (!input || input.startsWith("--") || input.indexOf("=") < 1)
|
|
676
1500
|
syntax("--param requires KEY=VALUE.");
|
|
677
1501
|
(result.parameters ??= []).push(input);
|
|
678
1502
|
continue;
|
|
679
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
|
+
);
|
|
680
1508
|
if (Object.hasOwn(result.options, option))
|
|
681
1509
|
syntax(`Duplicate option ${value}.`);
|
|
682
1510
|
if (booleans.includes(option)) result.options[option] = true;
|
|
683
1511
|
else if (values.includes(option)) {
|
|
684
1512
|
const input = tokens.shift();
|
|
685
|
-
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.`);
|
|
686
1523
|
result.options[option] = input;
|
|
687
|
-
} 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}".`);
|
|
688
1532
|
} else result.positional.push(value);
|
|
689
1533
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
+
);
|
|
1554
|
+
const counts: Record<string, [number, number]> = {
|
|
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],
|
|
1580
|
+
build: [0, 1],
|
|
1581
|
+
"bundle build": [1, 1],
|
|
1582
|
+
"bundle inspect": [1, 1],
|
|
1583
|
+
"bundle import": [1, 1],
|
|
1584
|
+
open: [1, 1],
|
|
1585
|
+
pin: [1, 1],
|
|
1586
|
+
unpin: [1, 1],
|
|
699
1587
|
"pin list": [0, 0],
|
|
700
1588
|
"pin show": [1, 1],
|
|
701
|
-
"pin rename": [2, 2],
|
|
702
1589
|
"register list": [0, 0],
|
|
703
1590
|
"register set": [2, 2],
|
|
704
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],
|
|
705
1596
|
"config get": [0, 1],
|
|
706
1597
|
"config set": [2, 2],
|
|
707
1598
|
"config reset": [1, 1],
|
|
@@ -714,13 +1605,28 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
714
1605
|
if (result.options["with-source"] && result.options["without-source"])
|
|
715
1606
|
syntax("--with-source and --without-source are mutually exclusive.");
|
|
716
1607
|
const [minimum, maximum] = counts[result.path]!;
|
|
717
|
-
if (result.
|
|
718
|
-
syntax(
|
|
1608
|
+
if (result.path === "profile" && flags.swarm !== undefined)
|
|
1609
|
+
syntax("Personal profile is account-wide; do not pass --swarm.");
|
|
719
1610
|
if (
|
|
720
|
-
result.
|
|
721
|
-
|
|
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)
|
|
722
1620
|
)
|
|
723
|
-
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
|
+
);
|
|
724
1630
|
if (result.path === "history remove") {
|
|
725
1631
|
const selected = values.some((value) =>
|
|
726
1632
|
Object.hasOwn(result.options, value),
|
|
@@ -732,10 +1638,36 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
732
1638
|
syntax("history remove requires explicit IDs OR filters, not both.");
|
|
733
1639
|
}
|
|
734
1640
|
// Validate syntactic values before state access, let alone a backend connection.
|
|
735
|
-
if (
|
|
736
|
-
|
|
737
|
-
if (result.path
|
|
738
|
-
|
|
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
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
if (
|
|
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.");
|
|
739
1671
|
}
|
|
740
1672
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
741
1673
|
if (
|
|
@@ -743,13 +1675,22 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
743
1675
|
!(result.path === "config reset" && result.positional[0] === "store.rpc")
|
|
744
1676
|
)
|
|
745
1677
|
configKey(result.positional[0]);
|
|
746
|
-
if (result.path === "config set")
|
|
747
|
-
|
|
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
|
+
}
|
|
748
1687
|
}
|
|
749
1688
|
if (typeof result.options.limit === "string")
|
|
750
1689
|
parseValue("history.limit", result.options.limit, true);
|
|
751
1690
|
if (result.options.output === "-")
|
|
752
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.");
|
|
753
1694
|
return result;
|
|
754
1695
|
}
|
|
755
1696
|
|
|
@@ -761,6 +1702,7 @@ async function performCli(
|
|
|
761
1702
|
let state: State | undefined;
|
|
762
1703
|
let store: IpfsStore | undefined;
|
|
763
1704
|
let appExitCode: number | undefined;
|
|
1705
|
+
let readContext: SwarmContext | undefined;
|
|
764
1706
|
try {
|
|
765
1707
|
const parsed = parse(argv);
|
|
766
1708
|
if (parsed.help) {
|
|
@@ -781,8 +1723,62 @@ async function performCli(
|
|
|
781
1723
|
}
|
|
782
1724
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
783
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
|
+
}
|
|
784
1776
|
const builtins = await builtinContent();
|
|
785
|
-
state = new State(
|
|
1777
|
+
state = new State(
|
|
1778
|
+
stateLocation(parsed.flags, env).path,
|
|
1779
|
+
builtins.pins,
|
|
1780
|
+
env,
|
|
1781
|
+
);
|
|
786
1782
|
if (
|
|
787
1783
|
parsed.path === "config reset" &&
|
|
788
1784
|
parsed.positional[0] === "store.rpc"
|
|
@@ -795,17 +1791,985 @@ async function performCli(
|
|
|
795
1791
|
);
|
|
796
1792
|
return 0;
|
|
797
1793
|
}
|
|
798
|
-
const items = effectiveConfig(
|
|
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
|
+
);
|
|
799
1807
|
const value = (key: string) =>
|
|
800
1808
|
items.find((item) => item.key === key)!.value;
|
|
801
1809
|
const emit = (result: unknown, human: string) => {
|
|
802
1810
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
803
1811
|
};
|
|
804
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
|
+
});
|
|
805
1875
|
const filter = parsed.path.startsWith("history ")
|
|
806
1876
|
? filters(state, parsed.options)
|
|
807
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
|
+
}
|
|
808
2119
|
switch (parsed.path) {
|
|
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
|
+
}
|
|
809
2773
|
case "store usage":
|
|
810
2774
|
case "store gc": {
|
|
811
2775
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
@@ -824,7 +2788,7 @@ async function performCli(
|
|
|
824
2788
|
}
|
|
825
2789
|
break;
|
|
826
2790
|
}
|
|
827
|
-
case "
|
|
2791
|
+
case "templates render":
|
|
828
2792
|
case "build":
|
|
829
2793
|
case "bundle build":
|
|
830
2794
|
case "bundle inspect":
|
|
@@ -861,7 +2825,10 @@ async function performCli(
|
|
|
861
2825
|
options.signal?.throwIfAborted();
|
|
862
2826
|
const builtin = builtins.blocks.get(cid.toV1().toString());
|
|
863
2827
|
if (builtin) return builtin.slice();
|
|
864
|
-
return (await getStore()).block.get(
|
|
2828
|
+
return (store ?? (await getStore())).block.get(
|
|
2829
|
+
cid.toString(),
|
|
2830
|
+
options,
|
|
2831
|
+
);
|
|
865
2832
|
},
|
|
866
2833
|
};
|
|
867
2834
|
const builtinSource = first ? state.pin(first) : undefined;
|
|
@@ -869,40 +2836,88 @@ async function performCli(
|
|
|
869
2836
|
builtinSource?.builtin && builtinSource.metadata?.kind === "bundle"
|
|
870
2837
|
? builtinSource.cid
|
|
871
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
|
+
}
|
|
872
2897
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
873
2898
|
io.err(
|
|
874
2899
|
parsed.path === "build"
|
|
875
|
-
? "
|
|
2900
|
+
? "Assembling and validating Bundle (no compilation)..."
|
|
876
2901
|
: "Validating and building bundle...",
|
|
877
2902
|
);
|
|
878
2903
|
if (parsed.path === "bundle import")
|
|
879
2904
|
io.err("Validating and importing CAR into Store...");
|
|
880
2905
|
const result =
|
|
881
|
-
parsed.path === "
|
|
882
|
-
? await initApp(
|
|
2906
|
+
parsed.path === "templates render"
|
|
2907
|
+
? await initApp(second!, parsed.positional[2], {
|
|
883
2908
|
...request,
|
|
884
|
-
...(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
: {}),
|
|
893
|
-
...(parsed.parameters
|
|
894
|
-
? { parameters: parsed.parameters }
|
|
895
|
-
: {}),
|
|
2909
|
+
...(selectedTemplate ? { template: selectedTemplate } : {}),
|
|
2910
|
+
parameters: [
|
|
2911
|
+
...(parsed.parameters ?? []),
|
|
2912
|
+
...(typeof parsed.options.description === "string"
|
|
2913
|
+
? [`description=${parsed.options.description}`]
|
|
2914
|
+
: []),
|
|
2915
|
+
],
|
|
896
2916
|
})
|
|
897
2917
|
: parsed.path === "build"
|
|
898
|
-
? await
|
|
2918
|
+
? await assembleBundle(first, {
|
|
899
2919
|
...request,
|
|
900
2920
|
replace: Boolean(parsed.options.replace),
|
|
901
|
-
...(parsed.options["with-source"]
|
|
902
|
-
? { includeSource: true }
|
|
903
|
-
: parsed.options["without-source"]
|
|
904
|
-
? { includeSource: false }
|
|
905
|
-
: {}),
|
|
906
2921
|
...(typeof parsed.options.output === "string"
|
|
907
2922
|
? { output: parsed.options.output }
|
|
908
2923
|
: {}),
|
|
@@ -944,7 +2959,7 @@ async function performCli(
|
|
|
944
2959
|
if ("output" in result)
|
|
945
2960
|
emit(
|
|
946
2961
|
{ ...result, imported: importing },
|
|
947
|
-
`CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}
|
|
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)"}`,
|
|
948
2963
|
);
|
|
949
2964
|
else if (result.kind === "bundle-import")
|
|
950
2965
|
emit(
|
|
@@ -962,7 +2977,7 @@ async function performCli(
|
|
|
962
2977
|
result.files.includes("ipab.json"))
|
|
963
2978
|
)
|
|
964
2979
|
io.err(
|
|
965
|
-
`Next: install declared dependencies in ${JSON.stringify(result.directory)};
|
|
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.`,
|
|
966
2981
|
);
|
|
967
2982
|
else if (result.files.includes(".bundle.yaml"))
|
|
968
2983
|
io.err(
|
|
@@ -971,7 +2986,7 @@ async function performCli(
|
|
|
971
2986
|
} else
|
|
972
2987
|
emit(
|
|
973
2988
|
result,
|
|
974
|
-
`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"}`,
|
|
975
2990
|
);
|
|
976
2991
|
} catch (cause) {
|
|
977
2992
|
if (cancelled)
|
|
@@ -989,133 +3004,80 @@ async function performCli(
|
|
|
989
3004
|
break;
|
|
990
3005
|
}
|
|
991
3006
|
case "pin list": {
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
: undefined;
|
|
996
|
-
const pins = state.pins();
|
|
997
|
-
const listed = pins
|
|
998
|
-
.filter(
|
|
999
|
-
(pin) => pin.status === "ready" && pin.metadata?.kind === "bundle",
|
|
1000
|
-
)
|
|
1001
|
-
.map(pinDetails)
|
|
1002
|
-
.filter((pin) => type === undefined || pin.schemaCid === type);
|
|
1003
|
-
const invalid = pins
|
|
1004
|
-
.filter(
|
|
1005
|
-
(pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle",
|
|
1006
|
-
)
|
|
1007
|
-
.map(({ name, cid, metadata }) => ({
|
|
1008
|
-
name,
|
|
1009
|
-
cid,
|
|
1010
|
-
kind: metadata?.kind,
|
|
1011
|
-
reason:
|
|
1012
|
-
"Not a Bundle pin; retention is preserved. Use pin delete to release it.",
|
|
1013
|
-
}));
|
|
1014
|
-
const pending = pins
|
|
1015
|
-
.filter((pin) => pin.status !== "ready")
|
|
1016
|
-
.map(({ name, cid, status }) => ({ name, cid, status }));
|
|
1017
|
-
if (pending.length)
|
|
1018
|
-
io.err(
|
|
1019
|
-
`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`,
|
|
1020
|
-
);
|
|
1021
|
-
if (invalid.length)
|
|
1022
|
-
io.err(
|
|
1023
|
-
`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`,
|
|
1024
|
-
);
|
|
3007
|
+
const listed = state.contentPins();
|
|
3008
|
+
const archived = state.archivedPins();
|
|
3009
|
+
const builtins = state.pins().map(pinDetails);
|
|
1025
3010
|
emit(
|
|
1026
|
-
{ items: listed,
|
|
3011
|
+
{ items: listed, builtins, archived },
|
|
1027
3012
|
table(
|
|
1028
|
-
["
|
|
1029
|
-
|
|
1030
|
-
pin
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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.",
|
|
1037
3035
|
),
|
|
1038
3036
|
);
|
|
1039
3037
|
break;
|
|
1040
3038
|
}
|
|
1041
|
-
case "
|
|
1042
|
-
|
|
1043
|
-
const result = await
|
|
1044
|
-
state,
|
|
1045
|
-
first!,
|
|
1046
|
-
second!,
|
|
1047
|
-
await storeConfiguration(value("store.gateway")),
|
|
1048
|
-
);
|
|
3039
|
+
case "unpin": {
|
|
3040
|
+
const canonical = pinReference(state, first!, selectedSwarm);
|
|
3041
|
+
const result = await unpin(state, canonical.reference);
|
|
1049
3042
|
emit(
|
|
1050
3043
|
result,
|
|
1051
|
-
|
|
1052
|
-
);
|
|
1053
|
-
break;
|
|
1054
|
-
}
|
|
1055
|
-
case "pin delete": {
|
|
1056
|
-
const result = await deletePin(state, first!);
|
|
1057
|
-
emit(
|
|
1058
|
-
result,
|
|
1059
|
-
`Deleted ${first}; released only its retention responsibility. No blocks deleted or GC requested.`,
|
|
3044
|
+
`Unpinned ${canonical.reference}; released only its saved retention responsibility. No blocks deleted or GC requested.`,
|
|
1060
3045
|
);
|
|
1061
3046
|
break;
|
|
1062
3047
|
}
|
|
1063
3048
|
case "pin show": {
|
|
1064
|
-
const
|
|
1065
|
-
|
|
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)
|
|
1066
3064
|
throw new HostError(
|
|
1067
3065
|
`Pin "${first}" does not exist. Run ipab pin list.`,
|
|
1068
3066
|
);
|
|
1069
|
-
const result =
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
const result = renamePin(state, first!, second!);
|
|
1078
|
-
emit(result, `${first} → ${result.name} (${result.cid})`);
|
|
1079
|
-
break;
|
|
1080
|
-
}
|
|
1081
|
-
case "register list": {
|
|
1082
|
-
const associations = state.registrations();
|
|
1083
|
-
emit(
|
|
1084
|
-
{ items: associations },
|
|
1085
|
-
table(
|
|
1086
|
-
["SCHEMA CID", "APP CID", "ARGV"],
|
|
1087
|
-
associations.map((association) => [
|
|
1088
|
-
association.schemaCid,
|
|
1089
|
-
association.appCid,
|
|
1090
|
-
JSON.stringify(association.argv),
|
|
1091
|
-
]),
|
|
1092
|
-
"No associations.",
|
|
1093
|
-
),
|
|
1094
|
-
);
|
|
1095
|
-
break;
|
|
1096
|
-
}
|
|
1097
|
-
case "register set": {
|
|
1098
|
-
const association = state.setAssociation(
|
|
1099
|
-
schemaAlias(first!),
|
|
1100
|
-
second!,
|
|
1101
|
-
parsed.template ?? ["%"],
|
|
1102
|
-
Boolean(parsed.options.replace),
|
|
1103
|
-
);
|
|
1104
|
-
emit(
|
|
1105
|
-
association,
|
|
1106
|
-
`${association.schemaCid} → ${association.appCid} ${JSON.stringify(association.argv)}`,
|
|
1107
|
-
);
|
|
1108
|
-
break;
|
|
1109
|
-
}
|
|
1110
|
-
case "register remove": {
|
|
1111
|
-
const removed = state.removeAssociation(schemaAlias(first!));
|
|
1112
|
-
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));
|
|
1113
3075
|
break;
|
|
1114
3076
|
}
|
|
1115
3077
|
case "config get": {
|
|
1116
|
-
const selected =
|
|
1117
|
-
? items.filter((item) => item.key === first)
|
|
1118
|
-
|
|
3078
|
+
const selected = (
|
|
3079
|
+
first ? items.filter((item) => item.key === first) : items
|
|
3080
|
+
).map(visibleConfig);
|
|
1119
3081
|
emit(
|
|
1120
3082
|
{ items: selected },
|
|
1121
3083
|
table(
|
|
@@ -1128,14 +3090,21 @@ async function performCli(
|
|
|
1128
3090
|
}
|
|
1129
3091
|
case "config set": {
|
|
1130
3092
|
const key = configKey(first!);
|
|
1131
|
-
const saved = parseValue(
|
|
3093
|
+
const saved = parseValue(
|
|
3094
|
+
key,
|
|
3095
|
+
key === "pointers.apiKey"
|
|
3096
|
+
? await (io.readSecret ?? processIO.readSecret!)()
|
|
3097
|
+
: second,
|
|
3098
|
+
true,
|
|
3099
|
+
);
|
|
1132
3100
|
state.setConfig(key, saved);
|
|
1133
3101
|
const source = items.find((item) => item.key === key)!.source;
|
|
1134
3102
|
if (source === "env" || source === "flag")
|
|
1135
3103
|
io.err(`Warning: saved user value is masked by ${source}.`);
|
|
3104
|
+
const display = visibleConfig({ key, value: saved, source: "user" });
|
|
1136
3105
|
emit(
|
|
1137
|
-
|
|
1138
|
-
`Saved ${key} = ${printable(String(
|
|
3106
|
+
display,
|
|
3107
|
+
`Saved ${key} = ${printable(String(display.value))} (user).`,
|
|
1139
3108
|
);
|
|
1140
3109
|
break;
|
|
1141
3110
|
}
|
|
@@ -1230,13 +3199,93 @@ async function performCli(
|
|
|
1230
3199
|
}
|
|
1231
3200
|
case "exec":
|
|
1232
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
|
+
);
|
|
1233
3211
|
if (parsed.options.log && !value("history.enabled"))
|
|
1234
3212
|
throw new HostError(
|
|
1235
3213
|
"Execution logging requires history.enabled=true.",
|
|
1236
3214
|
);
|
|
1237
|
-
const target = state.resolve(first!);
|
|
1238
3215
|
await recoverInactive(state);
|
|
1239
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
|
+
};
|
|
1240
3289
|
let appCid: string;
|
|
1241
3290
|
let appArgv: string[];
|
|
1242
3291
|
if (parsed.path === "open") {
|
|
@@ -1250,15 +3299,39 @@ async function performCli(
|
|
|
1250
3299
|
try {
|
|
1251
3300
|
const content = await validatedBundle(root, store, owner);
|
|
1252
3301
|
const schema = content.schemaKey;
|
|
1253
|
-
|
|
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
|
+
}
|
|
1254
3325
|
if (!association)
|
|
1255
3326
|
throw new HostError(
|
|
1256
|
-
`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.`,
|
|
1257
3328
|
);
|
|
1258
3329
|
appCid = association.appCid;
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
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];
|
|
1262
3335
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
1263
3336
|
const result = await execute(
|
|
1264
3337
|
state,
|
|
@@ -1266,6 +3339,7 @@ async function performCli(
|
|
|
1266
3339
|
{ origin: "open", appCid, argv: appArgv },
|
|
1267
3340
|
{
|
|
1268
3341
|
inputSchema: schema,
|
|
3342
|
+
resolveBundleReference,
|
|
1269
3343
|
history: Boolean(value("history.enabled")),
|
|
1270
3344
|
retain: value("output.retention") === "history",
|
|
1271
3345
|
log: Boolean(parsed.options.log),
|
|
@@ -1289,6 +3363,7 @@ async function performCli(
|
|
|
1289
3363
|
store,
|
|
1290
3364
|
{ origin: "exec", appCid, argv: appArgv },
|
|
1291
3365
|
{
|
|
3366
|
+
resolveBundleReference,
|
|
1292
3367
|
history: Boolean(value("history.enabled")),
|
|
1293
3368
|
retain: value("output.retention") === "history",
|
|
1294
3369
|
log: Boolean(parsed.options.log),
|
|
@@ -1309,7 +3384,11 @@ async function performCli(
|
|
|
1309
3384
|
return error instanceof HostError ? error.exitCode : 1;
|
|
1310
3385
|
} finally {
|
|
1311
3386
|
try {
|
|
1312
|
-
|
|
3387
|
+
try {
|
|
3388
|
+
await readContext?.finishRead?.();
|
|
3389
|
+
} finally {
|
|
3390
|
+
await closeStore(store, appExitCode);
|
|
3391
|
+
}
|
|
1313
3392
|
} finally {
|
|
1314
3393
|
state?.close();
|
|
1315
3394
|
}
|