@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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { lstat } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, extname, resolve } from "node:path";
|
|
3
|
+
import { CID } from "multiformats/cid";
|
|
4
|
+
import { CarBlockIterator } from "@ipld/car/iterator";
|
|
5
|
+
import { encodeBundleCar, memoryTree, readBytes } from "@ipab/bundle-builder";
|
|
6
|
+
import { filesystemTree } from "@ipab/bundle-builder/node";
|
|
7
|
+
import { bundleLimits } from "@ipab/bundle";
|
|
8
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
9
|
+
import { HostError } from "./errors.js";
|
|
10
|
+
import { importBundle, nodeError, selectedTree } from "./authoring.js";
|
|
11
|
+
import { captureSource, sourceFingerprint } from "./source-bundle.js";
|
|
12
|
+
import { exactCid } from "./state.js";
|
|
13
|
+
|
|
14
|
+
export async function publicationSource(
|
|
15
|
+
input: string,
|
|
16
|
+
store: IpfsStore,
|
|
17
|
+
): Promise<string> {
|
|
18
|
+
try {
|
|
19
|
+
CID.parse(input);
|
|
20
|
+
return exactCid(input);
|
|
21
|
+
} catch {
|
|
22
|
+
// Non-CID inputs must be explicit existing local sources.
|
|
23
|
+
}
|
|
24
|
+
const path = resolve(input);
|
|
25
|
+
let stat;
|
|
26
|
+
try {
|
|
27
|
+
stat = await lstat(path);
|
|
28
|
+
} catch (cause) {
|
|
29
|
+
if (nodeError(cause, "ENOENT"))
|
|
30
|
+
throw new HostError(
|
|
31
|
+
"Publication SOURCE must be an exact CID, a CAR, a regular file or a directory.",
|
|
32
|
+
);
|
|
33
|
+
throw cause;
|
|
34
|
+
}
|
|
35
|
+
if (stat.isSymbolicLink() || (!stat.isFile() && !stat.isDirectory()))
|
|
36
|
+
throw new HostError(
|
|
37
|
+
"Publication SOURCE must be a regular file or directory, never a symlink.",
|
|
38
|
+
);
|
|
39
|
+
if (stat.isFile() && extname(path).toLowerCase() === ".car")
|
|
40
|
+
return (await importBundle(path, () => Promise.resolve(store))).cid;
|
|
41
|
+
let tree;
|
|
42
|
+
let snapshot: Map<string, Uint8Array> | undefined;
|
|
43
|
+
if (stat.isDirectory()) {
|
|
44
|
+
try {
|
|
45
|
+
await lstat(resolve(path, ".bundle.yaml"));
|
|
46
|
+
tree = await selectedTree(path, undefined, resolve(path, "dist"), {});
|
|
47
|
+
} catch (cause) {
|
|
48
|
+
if (!nodeError(cause, "ENOENT")) throw cause;
|
|
49
|
+
snapshot = await captureSource(path, []);
|
|
50
|
+
tree = memoryTree(snapshot);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
const name = basename(path);
|
|
54
|
+
const types: Record<string, string> = {
|
|
55
|
+
".json": "application/json",
|
|
56
|
+
".yaml": "application/yaml",
|
|
57
|
+
".yml": "application/yaml",
|
|
58
|
+
".md": "text/markdown",
|
|
59
|
+
".txt": "text/plain",
|
|
60
|
+
};
|
|
61
|
+
const contentType = types[extname(path).toLowerCase()];
|
|
62
|
+
if (!contentType || name.startsWith("."))
|
|
63
|
+
throw new HostError(
|
|
64
|
+
"File entry/type is ambiguous. Put the file in a directory with an explicit .bundle.yaml and referenced type file; standalone .json, .yaml, .yml, .md and .txt files are supported.",
|
|
65
|
+
);
|
|
66
|
+
const data = await readBytes(
|
|
67
|
+
await filesystemTree(dirname(path)),
|
|
68
|
+
name,
|
|
69
|
+
bundleLimits.bytes,
|
|
70
|
+
{},
|
|
71
|
+
);
|
|
72
|
+
const bytes = (value: unknown) =>
|
|
73
|
+
new TextEncoder().encode(JSON.stringify(value));
|
|
74
|
+
tree = memoryTree(
|
|
75
|
+
new Map([
|
|
76
|
+
[
|
|
77
|
+
".bundle.yaml",
|
|
78
|
+
bytes({ title: name, entry: name, type: ".bundle-type.yaml" }),
|
|
79
|
+
],
|
|
80
|
+
[".bundle-type.yaml", bytes({ contentType })],
|
|
81
|
+
[name, data],
|
|
82
|
+
]),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const encoded = await encodeBundleCar(tree);
|
|
86
|
+
try {
|
|
87
|
+
for await (const block of await CarBlockIterator.fromIterable(
|
|
88
|
+
encoded.stream,
|
|
89
|
+
))
|
|
90
|
+
await store.put(block.cid, block.bytes);
|
|
91
|
+
if (
|
|
92
|
+
snapshot &&
|
|
93
|
+
sourceFingerprint(snapshot) !==
|
|
94
|
+
sourceFingerprint(await captureSource(path, []))
|
|
95
|
+
)
|
|
96
|
+
throw new HostError(
|
|
97
|
+
"Publication source changed while capturing its Bundle; retry.",
|
|
98
|
+
);
|
|
99
|
+
return encoded.cid.toString();
|
|
100
|
+
} finally {
|
|
101
|
+
await encoded.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/runtime.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ContextServer } from "./ipc.js";
|
|
|
10
10
|
import { loadApp, OutputSpace } from "./space.js";
|
|
11
11
|
import type { RunRecord, State } from "./state.js";
|
|
12
12
|
import { ExecutionLogs } from "./logs.js";
|
|
13
|
+
import type { BundleInspection } from "./context.js";
|
|
13
14
|
|
|
14
15
|
export interface Invocation {
|
|
15
16
|
origin: "exec" | "open";
|
|
@@ -23,6 +24,11 @@ export interface ExecutionOptions {
|
|
|
23
24
|
log?: boolean;
|
|
24
25
|
signal?: AbortSignal;
|
|
25
26
|
inputSchema?: string;
|
|
27
|
+
resolveBundleReference?: (
|
|
28
|
+
reference: string,
|
|
29
|
+
signal: AbortSignal,
|
|
30
|
+
swarm?: string,
|
|
31
|
+
) => Promise<Pick<BundleInspection, "cid" | "targetCid" | "swarm">>;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
export async function execute(
|
|
@@ -114,7 +120,9 @@ export async function execute(
|
|
|
114
120
|
"validation",
|
|
115
121
|
);
|
|
116
122
|
phase = "startup";
|
|
117
|
-
|
|
123
|
+
const runtime = join(state.directory, "runtime");
|
|
124
|
+
await mkdir(runtime, { recursive: true, mode: 0o700 });
|
|
125
|
+
await mkdir(directory, { mode: 0o700 });
|
|
118
126
|
directoryCreated = true;
|
|
119
127
|
await writeFile(entry, app.source, { flag: "wx", mode: 0o600 });
|
|
120
128
|
entryCreated = true;
|
|
@@ -161,7 +169,8 @@ export async function execute(
|
|
|
161
169
|
stop(error);
|
|
162
170
|
},
|
|
163
171
|
invocation.appCid,
|
|
164
|
-
|
|
172
|
+
options.resolveBundleReference,
|
|
173
|
+
app.supportedSchemas,
|
|
165
174
|
);
|
|
166
175
|
const result = await new Promise<{
|
|
167
176
|
code: number | null;
|
|
@@ -209,7 +218,9 @@ export async function execute(
|
|
|
209
218
|
"execution",
|
|
210
219
|
);
|
|
211
220
|
phase = "commit";
|
|
212
|
-
|
|
221
|
+
const outputCid = await output.finalize();
|
|
222
|
+
controller.signal.throwIfAborted();
|
|
223
|
+
record.outputCid = outputCid;
|
|
213
224
|
record.status = "succeeded";
|
|
214
225
|
exitCode = 0;
|
|
215
226
|
} catch (error) {
|
|
@@ -217,7 +228,8 @@ export async function execute(
|
|
|
217
228
|
error instanceof HostError
|
|
218
229
|
? error
|
|
219
230
|
: new HostError(message(error), 1, "EXECUTION_FAILED", phase);
|
|
220
|
-
record.status =
|
|
231
|
+
record.status =
|
|
232
|
+
cancellation || failure.code === "CANCELLED" ? "cancelled" : "failed";
|
|
221
233
|
record.error = {
|
|
222
234
|
phase: failure.phase === "state" ? phase : failure.phase,
|
|
223
235
|
code: failure.code,
|