@ipab/cli 0.1.0-rc.10 → 0.1.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -11
- package/dist/authoring.d.ts +7 -0
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +85 -5
- package/dist/authoring.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/bundled-skills.d.ts +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +904 -183
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.js +1 -1
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon-ui.d.ts +1 -0
- package/dist/daemon-ui.d.ts.map +1 -1
- package/dist/daemon-ui.js +2 -0
- package/dist/daemon-ui.js.map +1 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +7 -3
- package/dist/doctor.js.map +1 -1
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +1 -1
- package/dist/get.js.map +1 -1
- package/dist/history.d.ts +3 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +16 -1
- package/dist/history.js.map +1 -1
- package/dist/kubo-topology.d.ts +2 -0
- package/dist/kubo-topology.d.ts.map +1 -1
- package/dist/kubo-topology.js +17 -20
- package/dist/kubo-topology.js.map +1 -1
- package/dist/kubo.d.ts +5 -3
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +83 -13
- package/dist/kubo.js.map +1 -1
- package/dist/name-reference.d.ts +8 -0
- package/dist/name-reference.d.ts.map +1 -0
- package/dist/name-reference.js +63 -0
- package/dist/name-reference.js.map +1 -0
- package/dist/pivot-rpc.d.ts +37 -2
- package/dist/pivot-rpc.d.ts.map +1 -1
- package/dist/pivot-rpc.js +188 -8
- package/dist/pivot-rpc.js.map +1 -1
- package/dist/search-index.d.ts.map +1 -1
- package/dist/search-index.js +1 -0
- package/dist/search-index.js.map +1 -1
- package/dist/skill-definition.d.ts +9 -0
- package/dist/skill-definition.d.ts.map +1 -1
- package/dist/skill-definition.js +26 -2
- package/dist/skill-definition.js.map +1 -1
- package/dist/skill-source.d.ts +1 -0
- package/dist/skill-source.d.ts.map +1 -1
- package/dist/skill-source.js +10 -4
- package/dist/skill-source.js.map +1 -1
- package/dist/skills.d.ts +9 -3
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +31 -2
- package/dist/skills.js.map +1 -1
- package/dist/state.d.ts +20 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +87 -3
- package/dist/state.js.map +1 -1
- package/dist/swarm-fs-core.d.ts +217 -0
- package/dist/swarm-fs-core.d.ts.map +1 -0
- package/dist/swarm-fs-core.js +885 -0
- package/dist/swarm-fs-core.js.map +1 -0
- package/dist/swarm-fs-path.d.ts +17 -0
- package/dist/swarm-fs-path.d.ts.map +1 -0
- package/dist/swarm-fs-path.js +46 -0
- package/dist/swarm-fs-path.js.map +1 -0
- package/dist/swarm-fs.d.ts +9 -0
- package/dist/swarm-fs.d.ts.map +1 -0
- package/dist/swarm-fs.js +21 -0
- package/dist/swarm-fs.js.map +1 -0
- package/dist/swarm-observations.d.ts +6 -0
- package/dist/swarm-observations.d.ts.map +1 -1
- package/dist/swarm-observations.js +28 -8
- package/dist/swarm-observations.js.map +1 -1
- package/dist/swarm.d.ts +192 -17
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1360 -442
- package/dist/swarm.js.map +1 -1
- package/dist/unixfs-tree.d.ts +55 -0
- package/dist/unixfs-tree.d.ts.map +1 -1
- package/dist/unixfs-tree.js +361 -2
- package/dist/unixfs-tree.js.map +1 -1
- package/package.json +5 -5
- package/src/authoring.ts +125 -8
- package/src/cli.ts +1215 -281
- package/src/config-secret.ts +1 -1
- package/src/config.ts +20 -2
- package/src/daemon-ui.ts +3 -0
- package/src/doctor.ts +12 -2
- package/src/get.ts +2 -1
- package/src/history.ts +26 -1
- package/src/kubo-topology.ts +25 -22
- package/src/kubo.ts +127 -9
- package/src/name-reference.ts +91 -0
- package/src/pivot-rpc.ts +272 -14
- package/src/search-index.ts +1 -0
- package/src/skill-definition.ts +45 -3
- package/src/skill-source.ts +10 -4
- package/src/skills.ts +43 -2
- package/src/state.ts +117 -2
- package/src/swarm-fs-core.ts +1461 -0
- package/src/swarm-fs-path.ts +68 -0
- package/src/swarm-fs.ts +104 -0
- package/src/swarm-observations.ts +40 -14
- package/src/swarm.ts +1950 -727
- package/src/unixfs-tree.ts +447 -2
package/src/authoring.ts
CHANGED
|
@@ -45,8 +45,9 @@ import {
|
|
|
45
45
|
} from "@ipab/bundle-builder";
|
|
46
46
|
import type { EncodedBundleCar } from "@ipab/bundle-builder";
|
|
47
47
|
import { filesystemTree } from "@ipab/bundle-builder/node";
|
|
48
|
-
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
49
|
-
import { HostError } from "./errors.js";
|
|
48
|
+
import type { IpfsStore, StagedBlock } from "@ipab/ipfs-store";
|
|
49
|
+
import { HostError, message } from "./errors.js";
|
|
50
|
+
import type { Ownership } from "./history.js";
|
|
50
51
|
import { builtinAppSchema, schemaAlias } from "./app-definition.js";
|
|
51
52
|
import {
|
|
52
53
|
builtinTemplateSchema,
|
|
@@ -249,6 +250,87 @@ function cidInput(source: string): CID | undefined {
|
|
|
249
250
|
return undefined;
|
|
250
251
|
}
|
|
251
252
|
}
|
|
253
|
+
export interface LocalBundleInput {
|
|
254
|
+
kind: "directory" | "car";
|
|
255
|
+
path: string;
|
|
256
|
+
}
|
|
257
|
+
export async function resolveLocalBundleInput(
|
|
258
|
+
source: string,
|
|
259
|
+
): Promise<LocalBundleInput | undefined> {
|
|
260
|
+
if (
|
|
261
|
+
/^(ipab|name):/i.test(source) ||
|
|
262
|
+
source.startsWith("builtin:") ||
|
|
263
|
+
cidInput(source)
|
|
264
|
+
)
|
|
265
|
+
return undefined;
|
|
266
|
+
const path = resolve(source);
|
|
267
|
+
const stat = await existing(path);
|
|
268
|
+
if (!stat)
|
|
269
|
+
throw new HostError(
|
|
270
|
+
`Local bundle input does not exist: ${path}. Pass a Bundle directory containing .bundle.yaml, a .car file, a Bundle CID or an IPAB URI.`,
|
|
271
|
+
);
|
|
272
|
+
if (stat.isSymbolicLink())
|
|
273
|
+
throw new HostError(
|
|
274
|
+
`Local bundle input must be a regular Bundle directory or .car file, not a symbolic link: ${path}.`,
|
|
275
|
+
);
|
|
276
|
+
if (stat.isDirectory()) return { kind: "directory", path };
|
|
277
|
+
if (stat.isFile() && path.toLowerCase().endsWith(".car"))
|
|
278
|
+
return { kind: "car", path };
|
|
279
|
+
throw new HostError(
|
|
280
|
+
`Local bundle input must be a regular Bundle directory or .car file, not a file: ${path}.`,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
export async function snapshotLocalBundle(
|
|
284
|
+
input: LocalBundleInput,
|
|
285
|
+
owner: Ownership,
|
|
286
|
+
session: string,
|
|
287
|
+
options: AuthoringOptions = {},
|
|
288
|
+
): Promise<string> {
|
|
289
|
+
try {
|
|
290
|
+
if (input.kind === "car") {
|
|
291
|
+
options.diagnostic?.("Validating local Bundle CAR...");
|
|
292
|
+
const car = await readCar(input.path, options);
|
|
293
|
+
const loaded = await fromRoot(car.root, car.resolveCid, "car", options);
|
|
294
|
+
if (loaded.kind !== "content-bundle")
|
|
295
|
+
throw new HostError(
|
|
296
|
+
"CAR contains a Bundle type schema, not a Content or App Bundle.",
|
|
297
|
+
);
|
|
298
|
+
const blocks: StagedBlock[] = [];
|
|
299
|
+
for (const [key, blockBytes] of car.blocks)
|
|
300
|
+
blocks.push({ cid: CID.parse(key), bytes: blockBytes });
|
|
301
|
+
options.diagnostic?.("Importing local Bundle snapshot...");
|
|
302
|
+
return await owner.importBlocks(
|
|
303
|
+
session,
|
|
304
|
+
blocks,
|
|
305
|
+
car.root.toV1(),
|
|
306
|
+
options,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
options.diagnostic?.("Validating and packing local Bundle directory...");
|
|
310
|
+
const encoded = await encodeBundleCar(
|
|
311
|
+
await selectedTree(input.path, undefined, undefined, options),
|
|
312
|
+
options,
|
|
313
|
+
);
|
|
314
|
+
try {
|
|
315
|
+
const iterator = await CarBlockIterator.fromIterable(
|
|
316
|
+
streamChunks(encoded.stream, options),
|
|
317
|
+
);
|
|
318
|
+
const blocks: StagedBlock[] = [];
|
|
319
|
+
for await (const block of iterator)
|
|
320
|
+
blocks.push({ cid: block.cid, bytes: block.bytes });
|
|
321
|
+
options.diagnostic?.("Importing local Bundle snapshot...");
|
|
322
|
+
return await owner.importBlocks(session, blocks, encoded.cid, options);
|
|
323
|
+
} finally {
|
|
324
|
+
await encoded.close();
|
|
325
|
+
}
|
|
326
|
+
} catch (cause) {
|
|
327
|
+
throw new HostError(
|
|
328
|
+
input.kind === "car"
|
|
329
|
+
? `Cannot load local Bundle CAR ${input.path}: ${message(cause)} Ensure the CAR contains a valid single-root Content or App Bundle.`
|
|
330
|
+
: `Cannot load local Bundle directory ${input.path}: ${message(cause)} Ensure .bundle.yaml, its type definition and entry form a valid Content or App Bundle.`,
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
252
334
|
async function artifact(source: string, options: AuthoringOptions) {
|
|
253
335
|
if (source.startsWith("builtin:")) {
|
|
254
336
|
schemaAlias(source);
|
|
@@ -376,12 +458,47 @@ export async function importBundle(
|
|
|
376
458
|
): Promise<ImportResult> {
|
|
377
459
|
const path = resolve(source);
|
|
378
460
|
const stat = await lstat(path);
|
|
379
|
-
if (
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
)
|
|
384
|
-
|
|
461
|
+
if (stat.isSymbolicLink())
|
|
462
|
+
throw new HostError(
|
|
463
|
+
"Import requires a regular .car file or Bundle directory, not a symbolic link.",
|
|
464
|
+
);
|
|
465
|
+
if (stat.isDirectory()) {
|
|
466
|
+
const encoded = await encodeBundleCar(
|
|
467
|
+
await selectedTree(path, undefined, undefined, options),
|
|
468
|
+
options,
|
|
469
|
+
);
|
|
470
|
+
try {
|
|
471
|
+
options.signal?.throwIfAborted();
|
|
472
|
+
const store = await getStore();
|
|
473
|
+
let blocks = 0;
|
|
474
|
+
let bytes = 0;
|
|
475
|
+
const iterator = await CarBlockIterator.fromIterable(
|
|
476
|
+
streamChunks(encoded.stream, options),
|
|
477
|
+
);
|
|
478
|
+
for await (const block of iterator) {
|
|
479
|
+
options.signal?.throwIfAborted();
|
|
480
|
+
await store.put(block.cid.toV1(), block.bytes, options);
|
|
481
|
+
blocks++;
|
|
482
|
+
bytes += block.bytes.length;
|
|
483
|
+
}
|
|
484
|
+
options.signal?.throwIfAborted();
|
|
485
|
+
return {
|
|
486
|
+
kind: "bundle-import",
|
|
487
|
+
cid: encoded.cid.toV1().toString(),
|
|
488
|
+
schemaCid: encoded.schema.cid.toString(),
|
|
489
|
+
source: path,
|
|
490
|
+
validation: encoded.validation,
|
|
491
|
+
blocks,
|
|
492
|
+
bytes,
|
|
493
|
+
};
|
|
494
|
+
} finally {
|
|
495
|
+
await encoded.close();
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (!stat.isFile() || !path.toLowerCase().endsWith(".car"))
|
|
499
|
+
throw new HostError(
|
|
500
|
+
"Import requires a regular .car file or Bundle directory.",
|
|
501
|
+
);
|
|
385
502
|
const car = await readCar(path, options);
|
|
386
503
|
const loaded = await fromRoot(car.root, car.resolveCid, "car", options);
|
|
387
504
|
options.signal?.throwIfAborted();
|