@ipab/cli 0.1.0-rc.3 → 0.1.0-rc.5
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 +21 -10
- package/dist/cli.d.ts +3 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +188 -46
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +1 -1
- package/dist/config-secret.d.ts.map +1 -1
- package/dist/config-secret.js +2 -73
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -3
- package/dist/config.js.map +1 -1
- 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 +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +25 -0
- package/dist/context.js.map +1 -1
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +5 -0
- package/dist/identity.js.map +1 -1
- package/dist/ipc.d.ts +3 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +34 -1
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +9 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +361 -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 +118 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +3 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +12 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo.d.ts +14 -5
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +186 -206
- package/dist/kubo.js.map +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -2
- package/dist/runtime.js.map +1 -1
- package/dist/setup.d.ts +2 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +23 -18
- package/dist/setup.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 +3 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +299 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +5 -3
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +64 -30
- package/dist/state.js.map +1 -1
- package/dist/swarm-files.d.ts +3 -2
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +25 -9
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm.d.ts +10 -5
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +225 -79
- package/dist/swarm.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +224 -60
- package/src/config-secret.ts +2 -84
- package/src/config.ts +25 -3
- package/src/context-types.ts +11 -0
- package/src/context.ts +40 -0
- package/src/identity.ts +13 -0
- package/src/ipc.ts +50 -1
- package/src/kubo-install.ts +452 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +145 -0
- package/src/kubo-release.ts +17 -0
- package/src/kubo.ts +254 -275
- package/src/runtime.ts +12 -1
- package/src/setup.ts +30 -17
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +329 -0
- package/src/state.ts +76 -35
- package/src/swarm-files.ts +26 -6
- package/src/swarm.ts +316 -97
package/README.md
CHANGED
|
@@ -7,16 +7,19 @@ sandbox**: only execute Apps you trust.
|
|
|
7
7
|
protected HOME identity without contacting or starting a daemon. It is
|
|
8
8
|
idempotent; independent CID/local Store use still does not require Kubo.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
is published. Install this RC:
|
|
10
|
+
`0.1.0-rc.4` is published, with short Scope IDs, shared status queries and
|
|
11
|
+
configurable Swarm listeners. Install this RC:
|
|
13
12
|
|
|
14
13
|
```sh
|
|
15
|
-
npm install --global @ipab/cli@0.1.0-rc.
|
|
14
|
+
npm install --global @ipab/cli@0.1.0-rc.4
|
|
16
15
|
ipab --version
|
|
17
16
|
ipab --help
|
|
18
17
|
```
|
|
19
18
|
|
|
19
|
+
The current source prepares `0.1.0-rc.5` (not yet published), including Kubo
|
|
20
|
+
installation progress and cancellation, protected state storage, Scope request
|
|
21
|
+
retries and local alias references in search text output.
|
|
22
|
+
|
|
20
23
|
Node.js 22.15.0 or newer is required. Built-in Node and Web App project
|
|
21
24
|
templates are validated CAR assets shipped in this package; initialization works
|
|
22
25
|
offline and does not install dependencies or run hooks.
|
|
@@ -24,8 +27,8 @@ offline and does not install dependencies or run hooks.
|
|
|
24
27
|
The current source also ships `builtin:skill.ipab`, a validated Markdown Skill
|
|
25
28
|
Bundle about sharing information and Artifacts between people and Agents within
|
|
26
29
|
a Swarm. Export it offline with `ipab get builtin:skill.ipab`; its concise
|
|
27
|
-
`SKILL.md` links bundled usage references. It is
|
|
28
|
-
|
|
30
|
+
`SKILL.md` links bundled usage references. It is included starting with the rc.3
|
|
31
|
+
release. Shipping the Bundle does not install it into Agent directories or
|
|
29
32
|
configure automatic loading.
|
|
30
33
|
|
|
31
34
|
See the [user guide](https://github.com/silvermoon-work/ipab#readme) and
|
|
@@ -52,12 +55,20 @@ exists.
|
|
|
52
55
|
|
|
53
56
|
Shared references use `ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH`; `ipab:///PATH`
|
|
54
57
|
selects `--swarm` or the saved `swarm.default`, in that order. URI swarm
|
|
55
|
-
authorities take precedence and local aliases are case-sensitive. Search
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
authorities take precedence and local aliases are case-sensitive. Search text
|
|
59
|
+
uses local alias URIs when available, falling back to full configuration URLs.
|
|
60
|
+
JSON `reference` fields always use full configuration-URL-based URIs for sharing
|
|
61
|
+
across devices. Legacy `name:PATH` references and `IPAB_SWARM` are no longer
|
|
62
|
+
supported; remove the variable and use `--swarm` or `swarm use`.
|
|
59
63
|
|
|
60
64
|
Owner uses `swarm update` for organization information and `swarm exclude` /
|
|
61
65
|
`swarm resume` for irreversible, resumable member removal. Members change only
|
|
62
66
|
their own public profile using `swarm profile`. HEAD uses content-CID CAS, not a
|
|
63
67
|
history revision.
|
|
68
|
+
|
|
69
|
+
`swarm status` reads public configuration, Scope, HEAD and verified State
|
|
70
|
+
content. Available content needs no HOME identity or managed node; missing
|
|
71
|
+
content may activate the registered Swarm's private source, with an explicit
|
|
72
|
+
diagnostic. Use `swarm status --local` for membership/Owner-interruption checks,
|
|
73
|
+
node connection, account-specific HEAD-cache updates and local PeerID/addresses.
|
|
74
|
+
Default JSON omits `peerId` and `addresses`; `--local` retains those fields.
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type GlobalOptions } from "./config.js";
|
|
2
|
+
import { searchNames } from "./swarm.js";
|
|
2
3
|
export interface IO {
|
|
3
4
|
out(text: string): void;
|
|
4
|
-
err(text: string): void;
|
|
5
|
+
err(text: string, progress?: boolean): void;
|
|
5
6
|
tty: boolean;
|
|
6
7
|
columns?(): number | undefined;
|
|
7
8
|
confirm(text: string): Promise<boolean>;
|
|
@@ -9,6 +10,7 @@ export interface IO {
|
|
|
9
10
|
}
|
|
10
11
|
export declare const processIO: IO;
|
|
11
12
|
export declare function help(path?: string): string;
|
|
13
|
+
export declare function formatSearchResults(matches: Awaited<ReturnType<typeof searchNames>>["matches"]): string;
|
|
12
14
|
interface Parsed {
|
|
13
15
|
flags: GlobalOptions;
|
|
14
16
|
path: string;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAQL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAmBrB,OAAO,EAcL,WAAW,EAMZ,MAAM,YAAY,CAAC;AAOpB,MAAM,WAAW,EAAE;IACjB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,UAAU,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,SAAS,EAAE,EAwCvB,CAAC;AA6hBF,wBAAgB,IAAI,CAAC,IAAI,SAAK,GAAG,MAAM,CAqEtC;AAWD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,GAC1D,MAAM,CASR;AAgGD,UAAU,MAAM;IACd,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAkBD,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAqTrD;AA+kCD,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,EAAc,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { IpfsStore } from "@ipab/ipfs-store";
|
|
3
|
+
import { ContentError, IpfsStore } from "@ipab/ipfs-store";
|
|
4
|
+
import { ContentBundleError } from "@ipab/bundle";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
5
6
|
import { CID } from "multiformats/cid";
|
|
6
7
|
import stringWidth from "string-width";
|
|
@@ -16,18 +17,27 @@ import { assembleBundle } from "./assembly.js";
|
|
|
16
17
|
import { getBundle } from "./get.js";
|
|
17
18
|
import { setupDevice } from "./setup.js";
|
|
18
19
|
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
19
|
-
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, verifiedRequest, membershipRequestSummary, swarmHeader, addSwarm, updateSwarm, searchNames, resolveReference, publish, } from "./swarm.js";
|
|
20
|
+
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, verifiedRequest, membershipRequestSummary, swarmHeader, sharedSwarmStatus, addSwarm, updateSwarm, searchNames, formatNameReference, resolveReference, parseNameReference, publish, } from "./swarm.js";
|
|
20
21
|
import { schemaAlias } from "./app-definition.js";
|
|
21
22
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
22
23
|
import { logFiles } from "./logs.js";
|
|
23
24
|
import { builtinContent } from "./builtins.js";
|
|
24
25
|
import { readSecretStream } from "./config-secret.js";
|
|
26
|
+
let progressLine = false;
|
|
25
27
|
export const processIO = {
|
|
26
28
|
out(text) {
|
|
27
29
|
process.stdout.write(`${text}\n`);
|
|
28
30
|
},
|
|
29
|
-
err(text) {
|
|
30
|
-
process.stderr.
|
|
31
|
+
err(text, progress = false) {
|
|
32
|
+
if (progress && process.stderr.isTTY) {
|
|
33
|
+
const width = (process.stderr.columns > 1 ? process.stderr.columns : 80) - 1;
|
|
34
|
+
process.stderr.write(`\r\x1b[2K${text.slice(0, width)}`);
|
|
35
|
+
progressLine = true;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
process.stderr.write(`${progressLine ? "\n" : ""}${text}\n`);
|
|
39
|
+
progressLine = false;
|
|
40
|
+
}
|
|
31
41
|
},
|
|
32
42
|
tty: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
33
43
|
columns() {
|
|
@@ -53,7 +63,7 @@ export const processIO = {
|
|
|
53
63
|
},
|
|
54
64
|
};
|
|
55
65
|
const commands = {
|
|
56
|
-
setup: "setup [--yes]",
|
|
66
|
+
setup: "setup [--yes] [--kubo-archive FILE]",
|
|
57
67
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
58
68
|
"swarm request": "swarm request CONFIG_URL --owner-fingerprint FINGERPRINT [--output FILE] [--alias ALIAS]",
|
|
59
69
|
"swarm export": "swarm export URL_OR_ALIAS --output FILE",
|
|
@@ -109,6 +119,7 @@ const commandHelp = {
|
|
|
109
119
|
examples: ["ipab setup --yes", "ipab setup"],
|
|
110
120
|
options: [
|
|
111
121
|
"--yes Confirm installation and identity initialization outside a TTY.",
|
|
122
|
+
"--kubo-archive FILE Use a local official archive matching this CLI's pinned platform digest, without network access.",
|
|
112
123
|
],
|
|
113
124
|
notes: [
|
|
114
125
|
"Idempotent: reuse the same verified program and existing identity.",
|
|
@@ -148,6 +159,7 @@ const commandHelp = {
|
|
|
148
159
|
],
|
|
149
160
|
notes: [
|
|
150
161
|
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
162
|
+
"If the alias is taken, choose another to keep both Swarms. If you mean to replace only the local registration, run ipab swarm remove ALIAS and retry.",
|
|
151
163
|
],
|
|
152
164
|
},
|
|
153
165
|
"swarm approve": {
|
|
@@ -184,10 +196,18 @@ const commandHelp = {
|
|
|
184
196
|
],
|
|
185
197
|
},
|
|
186
198
|
"swarm status": {
|
|
187
|
-
summary: "
|
|
188
|
-
|
|
199
|
+
summary: "Read the current shared Swarm state",
|
|
200
|
+
options: [
|
|
201
|
+
"--local Also authenticate local membership, connect the node and diagnose interrupted Owner operations.",
|
|
202
|
+
],
|
|
203
|
+
examples: [
|
|
204
|
+
"ipab swarm status",
|
|
205
|
+
"ipab swarm status work",
|
|
206
|
+
"ipab swarm status work --local",
|
|
207
|
+
],
|
|
189
208
|
notes: [
|
|
190
|
-
"Always
|
|
209
|
+
"Always read public configuration, Scope and HEAD, and verify the State. Local content needs no HOME identity or node activation.",
|
|
210
|
+
"Missing local content may require the registered Swarm's private source. --local preserves the full local diagnostic and header-cache update.",
|
|
191
211
|
],
|
|
192
212
|
},
|
|
193
213
|
"swarm list": {
|
|
@@ -249,6 +269,7 @@ const commandHelp = {
|
|
|
249
269
|
"Searches all registered swarms unless --current or --swarm selects one.",
|
|
250
270
|
"Valid caches use local Names only; absent/expired caches refresh. No payload downloads.",
|
|
251
271
|
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
272
|
+
"Text uses local alias URIs when available; JSON references use full configuration URLs for cross-device sharing.",
|
|
252
273
|
],
|
|
253
274
|
},
|
|
254
275
|
publish: {
|
|
@@ -287,6 +308,7 @@ const commandHelp = {
|
|
|
287
308
|
"Stdout contains only the absolute directory path; --json also returns content and original target CIDs.",
|
|
288
309
|
"Temporary exports remain after exit; copy before cleanup, not symlink. Use --output for a persistent destination.",
|
|
289
310
|
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
311
|
+
"Copy the reference from ipab search, or percent-encode the entire configuration URL and each Name path segment separately.",
|
|
290
312
|
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
291
313
|
],
|
|
292
314
|
},
|
|
@@ -512,7 +534,7 @@ const commandHelp = {
|
|
|
512
534
|
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
513
535
|
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
514
536
|
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
515
|
-
"
|
|
537
|
+
"SQLite state is account-only even without a key. Reading or saving a nonempty key rechecks Unix modes or Windows ACLs.",
|
|
516
538
|
],
|
|
517
539
|
},
|
|
518
540
|
"config reset": {
|
|
@@ -565,7 +587,7 @@ const commandHelp = {
|
|
|
565
587
|
export function help(path = "") {
|
|
566
588
|
const globalOptions = `Global options (before COMMAND):
|
|
567
589
|
--swarm URL|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
568
|
-
--state-dir PATH Set
|
|
590
|
+
--state-dir PATH Set a dedicated, account-private local state directory
|
|
569
591
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
570
592
|
--json Output management/development metadata, not App stdio`;
|
|
571
593
|
const footer = "Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
|
|
@@ -636,6 +658,13 @@ function printable(text) {
|
|
|
636
658
|
: char)
|
|
637
659
|
.join("");
|
|
638
660
|
}
|
|
661
|
+
export function formatSearchResults(matches) {
|
|
662
|
+
return matches.length
|
|
663
|
+
? matches
|
|
664
|
+
.map((match) => `${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${formatNameReference(match.alias ?? match.swarm, match.name)}`)
|
|
665
|
+
.join("\n")
|
|
666
|
+
: "No matching Names.";
|
|
667
|
+
}
|
|
639
668
|
function runTime(value, field) {
|
|
640
669
|
const date = new Date(value);
|
|
641
670
|
if (!Number.isFinite(date.getTime()))
|
|
@@ -851,15 +880,17 @@ export function parse(argv) {
|
|
|
851
880
|
? ["current", "force", "no-force"]
|
|
852
881
|
: result.path === "swarm approve"
|
|
853
882
|
? ["yes", "again"]
|
|
854
|
-
: result.path === "swarm
|
|
855
|
-
? ["
|
|
856
|
-
: result.path === "
|
|
857
|
-
? ["
|
|
858
|
-
: result.path === "
|
|
859
|
-
? ["
|
|
860
|
-
: result.path === "
|
|
861
|
-
? ["
|
|
862
|
-
:
|
|
883
|
+
: result.path === "swarm status"
|
|
884
|
+
? ["local"]
|
|
885
|
+
: result.path === "swarm exclude"
|
|
886
|
+
? ["yes"]
|
|
887
|
+
: result.path === "register set"
|
|
888
|
+
? ["replace"]
|
|
889
|
+
: result.path === "history remove"
|
|
890
|
+
? ["yes"]
|
|
891
|
+
: result.path === "open"
|
|
892
|
+
? ["log", "raw", "force", "no-force"]
|
|
893
|
+
: [];
|
|
863
894
|
const values = result.path === "swarm create"
|
|
864
895
|
? ["service", "resume", "name", "description", "alias"]
|
|
865
896
|
: result.path === "swarm add"
|
|
@@ -897,6 +928,8 @@ export function parse(argv) {
|
|
|
897
928
|
: result.path === "pin list"
|
|
898
929
|
? ["type"]
|
|
899
930
|
: [];
|
|
931
|
+
if (result.path === "setup")
|
|
932
|
+
values.push("kubo-archive");
|
|
900
933
|
while (tokens.length) {
|
|
901
934
|
const value = tokens.shift();
|
|
902
935
|
if (result.path === "swarm exclude" &&
|
|
@@ -1024,6 +1057,7 @@ async function performCli(argv, io, env) {
|
|
|
1024
1057
|
let state;
|
|
1025
1058
|
let store;
|
|
1026
1059
|
let appExitCode;
|
|
1060
|
+
let readContext;
|
|
1027
1061
|
try {
|
|
1028
1062
|
const parsed = parse(argv);
|
|
1029
1063
|
if (parsed.help) {
|
|
@@ -1044,14 +1078,37 @@ async function performCli(argv, io, env) {
|
|
|
1044
1078
|
(!io.tty ||
|
|
1045
1079
|
!(await io.confirm("Install checksum-verified Kubo and initialize/reuse the protected HOME identity? No daemon will be contacted or started."))))
|
|
1046
1080
|
throw new HostError("Setup requires explicit --yes or interactive confirmation.");
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1081
|
+
const controller = new AbortController();
|
|
1082
|
+
const interrupt = () => {
|
|
1083
|
+
controller.abort(new HostError("Setup interrupted.", 130, "ABORTED"));
|
|
1084
|
+
};
|
|
1085
|
+
const terminate = () => {
|
|
1086
|
+
controller.abort(new HostError("Setup terminated.", 143, "ABORTED"));
|
|
1087
|
+
};
|
|
1088
|
+
process.once("SIGINT", interrupt);
|
|
1089
|
+
process.once("SIGTERM", terminate);
|
|
1090
|
+
try {
|
|
1091
|
+
const result = await setupDevice(stateLocation(parsed.flags, env).path, env, {
|
|
1092
|
+
diagnostic: (text, progress) => {
|
|
1093
|
+
io.err(text, progress);
|
|
1094
|
+
},
|
|
1095
|
+
signal: controller.signal,
|
|
1096
|
+
...(typeof parsed.options["kubo-archive"] === "string"
|
|
1097
|
+
? { archive: parsed.options["kubo-archive"] }
|
|
1098
|
+
: {}),
|
|
1099
|
+
});
|
|
1100
|
+
io.out(parsed.flags.json
|
|
1101
|
+
? JSON.stringify(result)
|
|
1102
|
+
: `Kubo ${result.kuboVersion}: ${result.binary}\nAccount fingerprint: ${result.fingerprint}\nReady. Nodes start only when a Swarm is used.`);
|
|
1103
|
+
return 0;
|
|
1104
|
+
}
|
|
1105
|
+
finally {
|
|
1106
|
+
process.removeListener("SIGINT", interrupt);
|
|
1107
|
+
process.removeListener("SIGTERM", terminate);
|
|
1108
|
+
}
|
|
1052
1109
|
}
|
|
1053
1110
|
const builtins = await builtinContent();
|
|
1054
|
-
state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
|
|
1111
|
+
state = new State(stateLocation(parsed.flags, env).path, builtins.pins, env);
|
|
1055
1112
|
if (parsed.path === "config reset" &&
|
|
1056
1113
|
parsed.positional[0] === "store.rpc") {
|
|
1057
1114
|
state.resetConfig("store.rpc");
|
|
@@ -1060,7 +1117,9 @@ async function performCli(argv, io, env) {
|
|
|
1060
1117
|
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.");
|
|
1061
1118
|
return 0;
|
|
1062
1119
|
}
|
|
1063
|
-
const items = effectiveConfig(state.config(
|
|
1120
|
+
const items = effectiveConfig(state.config({
|
|
1121
|
+
includeSecrets: parsed.path !== "swarm status" || Boolean(parsed.options.local),
|
|
1122
|
+
}), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
1064
1123
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
1065
1124
|
const emit = (result, human) => {
|
|
1066
1125
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
@@ -1080,6 +1139,7 @@ async function performCli(argv, io, env) {
|
|
|
1080
1139
|
env,
|
|
1081
1140
|
stateDir: stateLocation(parsed.flags, env).path,
|
|
1082
1141
|
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1142
|
+
listen: value("swarm.listen") === "loopback" ? "loopback" : "lan",
|
|
1083
1143
|
forceRefresh: parsed.options.force
|
|
1084
1144
|
? true
|
|
1085
1145
|
: parsed.options["no-force"]
|
|
@@ -1099,9 +1159,10 @@ async function performCli(argv, io, env) {
|
|
|
1099
1159
|
? filters(state, parsed.options)
|
|
1100
1160
|
: {};
|
|
1101
1161
|
const selection = () => {
|
|
1102
|
-
const
|
|
1162
|
+
const saved = state.config({ includeSecrets: false });
|
|
1163
|
+
const current = effectiveConfig(saved, parsed.flags, env, (reference) => state.resolveSwarm(reference)).find((item) => item.key === "swarm.default");
|
|
1103
1164
|
return {
|
|
1104
|
-
savedCurrent:
|
|
1165
|
+
savedCurrent: saved["swarm.default"] ?? null,
|
|
1105
1166
|
effectiveCurrent: current.value,
|
|
1106
1167
|
source: current.source,
|
|
1107
1168
|
};
|
|
@@ -1116,9 +1177,16 @@ async function performCli(argv, io, env) {
|
|
|
1116
1177
|
alias: entry.alias,
|
|
1117
1178
|
})),
|
|
1118
1179
|
}, [
|
|
1119
|
-
...result.swarms.map((entry) => `${entry.cid === result.
|
|
1120
|
-
|
|
1121
|
-
|
|
1180
|
+
...result.swarms.map((entry) => `${entry.cid === result.effectiveCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`),
|
|
1181
|
+
...(result.swarms.length ? [] : ["No registered Swarms."]),
|
|
1182
|
+
...(result.effectiveCurrent === null
|
|
1183
|
+
? ["Use ipab swarm use <alias> to select a default Swarm."]
|
|
1184
|
+
: []),
|
|
1185
|
+
...(result.effectiveCurrent !== result.savedCurrent
|
|
1186
|
+
? [
|
|
1187
|
+
`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)"))}.`,
|
|
1188
|
+
]
|
|
1189
|
+
: []),
|
|
1122
1190
|
].join("\n"));
|
|
1123
1191
|
break;
|
|
1124
1192
|
}
|
|
@@ -1132,7 +1200,10 @@ async function performCli(argv, io, env) {
|
|
|
1132
1200
|
}
|
|
1133
1201
|
case "swarm remove": {
|
|
1134
1202
|
const removed = state.removeSwarm(first);
|
|
1135
|
-
emit({
|
|
1203
|
+
emit({
|
|
1204
|
+
removed,
|
|
1205
|
+
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ?? null,
|
|
1206
|
+
}, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
|
|
1136
1207
|
break;
|
|
1137
1208
|
}
|
|
1138
1209
|
case "swarm add":
|
|
@@ -1211,7 +1282,8 @@ async function performCli(argv, io, env) {
|
|
|
1211
1282
|
emit({
|
|
1212
1283
|
configUrl: entry.cid,
|
|
1213
1284
|
alias: entry.alias,
|
|
1214
|
-
savedCurrent: state.config()["swarm.default"] ??
|
|
1285
|
+
savedCurrent: state.config({ includeSecrets: false })["swarm.default"] ??
|
|
1286
|
+
null,
|
|
1215
1287
|
}, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1216
1288
|
break;
|
|
1217
1289
|
}
|
|
@@ -1231,43 +1303,73 @@ async function performCli(argv, io, env) {
|
|
|
1231
1303
|
]
|
|
1232
1304
|
: registrations;
|
|
1233
1305
|
const result = await searchNames(context, first, scope);
|
|
1234
|
-
emit(result, result.matches
|
|
1235
|
-
? result.matches
|
|
1236
|
-
.map((match) => `${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`)
|
|
1237
|
-
.join("\n")
|
|
1238
|
-
: "No matching Names.");
|
|
1306
|
+
emit(result, formatSearchResults(result.matches));
|
|
1239
1307
|
break;
|
|
1240
1308
|
}
|
|
1241
1309
|
if (parsed.path === "swarm status") {
|
|
1242
1310
|
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1243
1311
|
if (!cid)
|
|
1244
1312
|
syntax("swarm status requires a configuration URL or swarm.default.");
|
|
1245
|
-
const
|
|
1313
|
+
const local = Boolean(parsed.options.local);
|
|
1314
|
+
const { head, config } = local
|
|
1315
|
+
? await swarmHeader(context, cid, true)
|
|
1316
|
+
: await sharedSwarmStatus(context, cid);
|
|
1317
|
+
const fingerprint = await keyId(config.owner);
|
|
1246
1318
|
store = context.store;
|
|
1247
1319
|
emit({
|
|
1248
1320
|
configUrl: cid,
|
|
1249
1321
|
owner: config.owner,
|
|
1250
|
-
ownerFingerprint:
|
|
1322
|
+
ownerFingerprint: fingerprint,
|
|
1251
1323
|
epoch: config.epoch,
|
|
1252
|
-
|
|
1253
|
-
|
|
1324
|
+
...(local
|
|
1325
|
+
? {
|
|
1326
|
+
peerId: context.node.peerId,
|
|
1327
|
+
addresses: context.node.addresses,
|
|
1328
|
+
}
|
|
1329
|
+
: {}),
|
|
1254
1330
|
root: head.root,
|
|
1255
1331
|
valueCid: head.cid,
|
|
1256
1332
|
properties: {
|
|
1257
1333
|
name: config.name,
|
|
1258
1334
|
description: config.description,
|
|
1259
1335
|
},
|
|
1260
|
-
},
|
|
1336
|
+
}, [
|
|
1337
|
+
"Swarm",
|
|
1338
|
+
` Name: ${printable(config.name)}`,
|
|
1339
|
+
` Description: ${config.description ? printable(config.description) : "(none)"}`,
|
|
1340
|
+
" Config URL:",
|
|
1341
|
+
` ${cid}`,
|
|
1342
|
+
"",
|
|
1343
|
+
"Identity",
|
|
1344
|
+
" Owner fingerprint:",
|
|
1345
|
+
` ${fingerprint}`,
|
|
1346
|
+
...(local
|
|
1347
|
+
? [
|
|
1348
|
+
" PeerID:",
|
|
1349
|
+
` ${context.node.peerId}`,
|
|
1350
|
+
"",
|
|
1351
|
+
"Local addresses",
|
|
1352
|
+
...context.node.addresses.map((address) => ` ${printable(address)}`),
|
|
1353
|
+
]
|
|
1354
|
+
: []),
|
|
1355
|
+
"",
|
|
1356
|
+
"Content",
|
|
1357
|
+
" HEAD (publication root):",
|
|
1358
|
+
` ${head.root}`,
|
|
1359
|
+
" Content CID (HEAD value):",
|
|
1360
|
+
` ${head.cid}`,
|
|
1361
|
+
].join("\n"));
|
|
1261
1362
|
break;
|
|
1262
1363
|
}
|
|
1263
1364
|
if (parsed.path === "get") {
|
|
1264
|
-
|
|
1365
|
+
readContext = context;
|
|
1366
|
+
const localCid = /^(ipab|name):/i.test(first)
|
|
1265
1367
|
? undefined
|
|
1266
1368
|
: state.resolve(first);
|
|
1267
1369
|
const builtin = builtins.pins.find((pin) => pin.cid === localCid);
|
|
1268
1370
|
const selected = builtin
|
|
1269
1371
|
? { cid: builtin.cid, targetCid: builtin.cid }
|
|
1270
|
-
: await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw));
|
|
1372
|
+
: await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw), "local-first");
|
|
1271
1373
|
const contentStore = context.store;
|
|
1272
1374
|
const source = IpfsStore.fromClient({
|
|
1273
1375
|
block: {
|
|
@@ -1358,7 +1460,7 @@ async function performCli(argv, io, env) {
|
|
|
1358
1460
|
}
|
|
1359
1461
|
store = context.store;
|
|
1360
1462
|
if (parsed.path === "swarm create")
|
|
1361
|
-
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`);
|
|
1463
|
+
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config({ includeSecrets: false })["swarm.default"] ?? "(none)"}.`);
|
|
1362
1464
|
emit(parsed.path === "swarm request"
|
|
1363
1465
|
? { requestId: cid }
|
|
1364
1466
|
: parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
@@ -1680,6 +1782,43 @@ async function performCli(argv, io, env) {
|
|
|
1680
1782
|
const context = swarmContext();
|
|
1681
1783
|
const target = (await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw))).cid;
|
|
1682
1784
|
store = context.store;
|
|
1785
|
+
const resolveBundleReference = async (reference, signal, preferredSwarm) => {
|
|
1786
|
+
signal.throwIfAborted();
|
|
1787
|
+
const lookup = {
|
|
1788
|
+
...swarmContext(),
|
|
1789
|
+
store: new IpfsStore(await storeConfiguration(value("store.gateway"))),
|
|
1790
|
+
};
|
|
1791
|
+
try {
|
|
1792
|
+
const named = parseNameReference(reference);
|
|
1793
|
+
const swarm = named?.swarm
|
|
1794
|
+
? state.resolveSwarm(named.swarm)
|
|
1795
|
+
: preferredSwarm
|
|
1796
|
+
? state.resolveSwarm(preferredSwarm)
|
|
1797
|
+
: selectedSwarm;
|
|
1798
|
+
const resolve = (source) => resolveReference(lookup, reference, source, (input) => state.resolve(input));
|
|
1799
|
+
let resolved;
|
|
1800
|
+
try {
|
|
1801
|
+
resolved = await resolve(named ? swarm : undefined);
|
|
1802
|
+
}
|
|
1803
|
+
catch (cause) {
|
|
1804
|
+
let failure = cause;
|
|
1805
|
+
for (let depth = 0; depth < 8 && failure instanceof ContentBundleError; depth++)
|
|
1806
|
+
failure = failure.cause;
|
|
1807
|
+
if (named ||
|
|
1808
|
+
!swarm ||
|
|
1809
|
+
!(failure instanceof ContentError) ||
|
|
1810
|
+
failure.code !== "missing_block")
|
|
1811
|
+
throw cause;
|
|
1812
|
+
signal.throwIfAborted();
|
|
1813
|
+
resolved = await resolve(swarm);
|
|
1814
|
+
}
|
|
1815
|
+
signal.throwIfAborted();
|
|
1816
|
+
return { ...resolved, ...(swarm ? { swarm } : {}) };
|
|
1817
|
+
}
|
|
1818
|
+
finally {
|
|
1819
|
+
await lookup.store.close();
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1683
1822
|
let appCid;
|
|
1684
1823
|
let appArgv;
|
|
1685
1824
|
if (parsed.path === "open") {
|
|
@@ -1696,6 +1835,7 @@ async function performCli(argv, io, env) {
|
|
|
1696
1835
|
// execute owns the App/input context before this validation owner's eventual release.
|
|
1697
1836
|
const result = await execute(state, store, { origin: "open", appCid, argv: appArgv }, {
|
|
1698
1837
|
inputSchema: schema,
|
|
1838
|
+
resolveBundleReference,
|
|
1699
1839
|
history: Boolean(value("history.enabled")),
|
|
1700
1840
|
retain: value("output.retention") === "history",
|
|
1701
1841
|
log: Boolean(parsed.options.log),
|
|
@@ -1715,6 +1855,7 @@ async function performCli(argv, io, env) {
|
|
|
1715
1855
|
appArgv = parsed.positional.slice(1);
|
|
1716
1856
|
}
|
|
1717
1857
|
appExitCode = (await execute(state, store, { origin: "exec", appCid, argv: appArgv }, {
|
|
1858
|
+
resolveBundleReference,
|
|
1718
1859
|
history: Boolean(value("history.enabled")),
|
|
1719
1860
|
retain: value("output.retention") === "history",
|
|
1720
1861
|
log: Boolean(parsed.options.log),
|
|
@@ -1735,6 +1876,7 @@ async function performCli(argv, io, env) {
|
|
|
1735
1876
|
}
|
|
1736
1877
|
finally {
|
|
1737
1878
|
try {
|
|
1879
|
+
await readContext?.finishRead?.();
|
|
1738
1880
|
await closeStore(store, appExitCode);
|
|
1739
1881
|
}
|
|
1740
1882
|
finally {
|