buckyos 0.7.165 → 0.7.169
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/cli/core/app.ts +2 -0
- package/cli/dist/cli.mjs +873 -180
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/app.ts +16 -2
- package/cli/modules/ext_tools.ts +71 -0
- package/cli/modules/pikg.ts +257 -5
- package/cli/modules/pikg_archive.ts +147 -34
- package/cli/modules/pikg_protocol.ts +218 -3
- package/cli/modules/skill.ts +31 -6
- package/cli/runtime/host.ts +2 -0
- package/cli/version.ts +1 -1
- package/dist/aicc_client.d.ts +1 -1
- package/dist/aicc_client.d.ts.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.mjs +2 -2
- package/dist/{executor_client-f9908517.mjs → executor_client-a32bc377.mjs} +4 -1
- package/dist/executor_client-a32bc377.mjs.map +1 -0
- package/dist/{executor_client-c8ff5698.js → executor_client-e026942b.js} +2 -2
- package/dist/executor_client-e026942b.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +2 -2
- package/dist/workflow_client.d.ts +11 -2
- package/dist/workflow_client.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/executor_client-c8ff5698.js.map +0 -1
- package/dist/executor_client-f9908517.mjs.map +0 -1
package/cli/dist/cli.mjs
CHANGED
|
@@ -546,7 +546,7 @@ function resolveInputPath(value, cwd, path) {
|
|
|
546
546
|
return path.isAbsolute(value) ? path.resolve(value) : path.resolve(cwd, value);
|
|
547
547
|
}
|
|
548
548
|
function collectArgumentPaths(argv) {
|
|
549
|
-
const
|
|
549
|
+
const read2 = [];
|
|
550
550
|
const readParents = [];
|
|
551
551
|
const write = [];
|
|
552
552
|
const writeParents = [];
|
|
@@ -607,27 +607,29 @@ function collectArgumentPaths(argv) {
|
|
|
607
607
|
if (value === void 0)
|
|
608
608
|
continue;
|
|
609
609
|
if (name === "config-dir") {
|
|
610
|
-
|
|
610
|
+
read2.push(value);
|
|
611
611
|
write.push(value);
|
|
612
612
|
} else if (name === "allow-read") {
|
|
613
|
-
|
|
613
|
+
read2.push(value);
|
|
614
614
|
} else if (["input", "session-token-file", "pikg"].includes(name)) {
|
|
615
615
|
if (value !== "-")
|
|
616
|
-
|
|
616
|
+
read2.push(value);
|
|
617
|
+
} else if (name === "catalog" && module === "pikg") {
|
|
618
|
+
read2.push(value);
|
|
617
619
|
} else if (name === "source" && module === "pikg") {
|
|
618
|
-
|
|
620
|
+
read2.push(value);
|
|
619
621
|
} else if (name === "plan") {
|
|
620
|
-
|
|
622
|
+
read2.push(value);
|
|
621
623
|
if (module === "app" && verb === "fetch")
|
|
622
624
|
write.push(value);
|
|
623
625
|
} else if (name === "path")
|
|
624
626
|
write.push(value);
|
|
625
627
|
else if (name === "app-doc" && module === "app" && verb === "publish")
|
|
626
|
-
|
|
628
|
+
read2.push(value);
|
|
627
629
|
else if (name === "file" && module === "system-config" && verb === "set-file") {
|
|
628
|
-
|
|
630
|
+
read2.push(value);
|
|
629
631
|
} else if (name === "root" && module === "provision") {
|
|
630
|
-
|
|
632
|
+
read2.push(value);
|
|
631
633
|
if (verb === "activate")
|
|
632
634
|
write.push(value);
|
|
633
635
|
} else if (name === "owner-key-backup" && module === "provision") {
|
|
@@ -640,18 +642,18 @@ function collectArgumentPaths(argv) {
|
|
|
640
642
|
}
|
|
641
643
|
if (module === "app" && ["fetch", "install"].includes(verb ?? "") && positional++ === 0) {
|
|
642
644
|
if (!/^https?:\/\//i.test(token))
|
|
643
|
-
|
|
645
|
+
read2.push(token);
|
|
644
646
|
} else if (module === "skill" && verb === "install" && positional++ === 0) {
|
|
645
|
-
|
|
647
|
+
read2.push(token);
|
|
646
648
|
} else if (module === "pikg" && positional++ === 0) {
|
|
647
|
-
|
|
649
|
+
read2.push(token);
|
|
648
650
|
if (verb === "init" || verb === "pack")
|
|
649
651
|
write.push(token);
|
|
650
652
|
else if (verb === "build" || verb === "clean")
|
|
651
653
|
writeParents.push(token);
|
|
652
654
|
}
|
|
653
655
|
}
|
|
654
|
-
return { read, readParents, write, writeParents, module, verb };
|
|
656
|
+
return { read: read2, readParents, write, writeParents, module, verb };
|
|
655
657
|
}
|
|
656
658
|
function policyView(host2) {
|
|
657
659
|
return {
|
|
@@ -2498,7 +2500,7 @@ function replPrompt(config) {
|
|
|
2498
2500
|
return `buckyos[${profile}|${zone}|${identity}]> `;
|
|
2499
2501
|
}
|
|
2500
2502
|
const EMPTY_INPUT$3 = { type: "object", properties: {}, additionalProperties: false };
|
|
2501
|
-
const OBJECT_OUTPUT$
|
|
2503
|
+
const OBJECT_OUTPUT$g = { type: "object", additionalProperties: true };
|
|
2502
2504
|
function createAuthModule() {
|
|
2503
2505
|
return {
|
|
2504
2506
|
name: "auth",
|
|
@@ -2508,7 +2510,7 @@ function createAuthModule() {
|
|
|
2508
2510
|
verb: "whoami",
|
|
2509
2511
|
summary: "Show the effective principal and application identity",
|
|
2510
2512
|
inputSchema: EMPTY_INPUT$3,
|
|
2511
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2513
|
+
outputSchema: OBJECT_OUTPUT$g,
|
|
2512
2514
|
resultSchemaVersion: 1,
|
|
2513
2515
|
access: { mode: "fixed", level: "read" },
|
|
2514
2516
|
asyncMode: "sync",
|
|
@@ -2526,7 +2528,7 @@ function createAuthModule() {
|
|
|
2526
2528
|
verb: "session-status",
|
|
2527
2529
|
summary: "Show the in-memory session state without exposing credentials",
|
|
2528
2530
|
inputSchema: EMPTY_INPUT$3,
|
|
2529
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2531
|
+
outputSchema: OBJECT_OUTPUT$g,
|
|
2530
2532
|
resultSchemaVersion: 1,
|
|
2531
2533
|
access: { mode: "fixed", level: "read" },
|
|
2532
2534
|
asyncMode: "sync",
|
|
@@ -2547,7 +2549,7 @@ const EMPTY_INPUT$2 = {
|
|
|
2547
2549
|
properties: {},
|
|
2548
2550
|
additionalProperties: false
|
|
2549
2551
|
};
|
|
2550
|
-
const OBJECT_OUTPUT$
|
|
2552
|
+
const OBJECT_OUTPUT$f = { type: "object", additionalProperties: true };
|
|
2551
2553
|
function createCoreModules(registry) {
|
|
2552
2554
|
return [createCommandModule(registry), createConfigModule(), createCompletionModule(registry)];
|
|
2553
2555
|
}
|
|
@@ -2560,7 +2562,7 @@ function createCommandModule(registry) {
|
|
|
2560
2562
|
verb: "list",
|
|
2561
2563
|
summary: "List registered modules and commands",
|
|
2562
2564
|
inputSchema: EMPTY_INPUT$2,
|
|
2563
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2565
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2564
2566
|
resultSchemaVersion: 1,
|
|
2565
2567
|
access: { mode: "fixed", level: "read" },
|
|
2566
2568
|
asyncMode: "sync",
|
|
@@ -2593,7 +2595,7 @@ function createCommandModule(registry) {
|
|
|
2593
2595
|
required: ["target_module", "target_verb"],
|
|
2594
2596
|
additionalProperties: false
|
|
2595
2597
|
},
|
|
2596
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2598
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2597
2599
|
resultSchemaVersion: 1,
|
|
2598
2600
|
access: { mode: "fixed", level: "read" },
|
|
2599
2601
|
asyncMode: "sync",
|
|
@@ -2615,7 +2617,7 @@ function createConfigModule() {
|
|
|
2615
2617
|
verb: "list",
|
|
2616
2618
|
summary: "List the global configuration and available profiles",
|
|
2617
2619
|
inputSchema: EMPTY_INPUT$2,
|
|
2618
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2620
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2619
2621
|
resultSchemaVersion: 1,
|
|
2620
2622
|
access: { mode: "fixed", level: "read" },
|
|
2621
2623
|
asyncMode: "sync",
|
|
@@ -2646,7 +2648,7 @@ function createConfigModule() {
|
|
|
2646
2648
|
},
|
|
2647
2649
|
additionalProperties: false
|
|
2648
2650
|
},
|
|
2649
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2651
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2650
2652
|
resultSchemaVersion: 1,
|
|
2651
2653
|
access: { mode: "fixed", level: "read" },
|
|
2652
2654
|
asyncMode: "sync",
|
|
@@ -2692,7 +2694,7 @@ function createConfigModule() {
|
|
|
2692
2694
|
required: ["key", "value"],
|
|
2693
2695
|
additionalProperties: false
|
|
2694
2696
|
},
|
|
2695
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2697
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2696
2698
|
resultSchemaVersion: 1,
|
|
2697
2699
|
access: { mode: "fixed", level: "write" },
|
|
2698
2700
|
asyncMode: "sync",
|
|
@@ -2732,7 +2734,7 @@ function createConfigModule() {
|
|
|
2732
2734
|
required: ["profile_name"],
|
|
2733
2735
|
additionalProperties: false
|
|
2734
2736
|
},
|
|
2735
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2737
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2736
2738
|
resultSchemaVersion: 1,
|
|
2737
2739
|
access: { mode: "fixed", level: "write" },
|
|
2738
2740
|
asyncMode: "sync",
|
|
@@ -2764,7 +2766,7 @@ function createConfigModule() {
|
|
|
2764
2766
|
properties: { effective: { type: "boolean" } },
|
|
2765
2767
|
additionalProperties: false
|
|
2766
2768
|
},
|
|
2767
|
-
outputSchema: OBJECT_OUTPUT$
|
|
2769
|
+
outputSchema: OBJECT_OUTPUT$f,
|
|
2768
2770
|
resultSchemaVersion: 1,
|
|
2769
2771
|
access: { mode: "fixed", level: "read" },
|
|
2770
2772
|
asyncMode: "sync",
|
|
@@ -3006,7 +3008,7 @@ async function buckyosInfo(ctx) {
|
|
|
3006
3008
|
);
|
|
3007
3009
|
}
|
|
3008
3010
|
const SERVICE_NAME = "system_config";
|
|
3009
|
-
const OBJECT_OUTPUT$
|
|
3011
|
+
const OBJECT_OUTPUT$e = { type: "object", additionalProperties: false };
|
|
3010
3012
|
const KEY_INPUT = {
|
|
3011
3013
|
type: "object",
|
|
3012
3014
|
properties: { key: { type: "string", minLength: 1 } },
|
|
@@ -3024,7 +3026,7 @@ function createSystemConfigModule() {
|
|
|
3024
3026
|
positionals: [{ name: "key", description: "System-config key" }],
|
|
3025
3027
|
inputSchema: KEY_INPUT,
|
|
3026
3028
|
outputSchema: {
|
|
3027
|
-
...OBJECT_OUTPUT$
|
|
3029
|
+
...OBJECT_OUTPUT$e,
|
|
3028
3030
|
properties: {
|
|
3029
3031
|
key: { type: "string" },
|
|
3030
3032
|
value: { type: "string" },
|
|
@@ -3067,7 +3069,7 @@ function createSystemConfigModule() {
|
|
|
3067
3069
|
additionalProperties: false
|
|
3068
3070
|
},
|
|
3069
3071
|
outputSchema: {
|
|
3070
|
-
...OBJECT_OUTPUT$
|
|
3072
|
+
...OBJECT_OUTPUT$e,
|
|
3071
3073
|
properties: {
|
|
3072
3074
|
key: { type: "string" },
|
|
3073
3075
|
items: { type: "array", items: { type: "string" } }
|
|
@@ -3121,7 +3123,7 @@ function setCommand() {
|
|
|
3121
3123
|
additionalProperties: false
|
|
3122
3124
|
},
|
|
3123
3125
|
outputSchema: {
|
|
3124
|
-
...OBJECT_OUTPUT$
|
|
3126
|
+
...OBJECT_OUTPUT$e,
|
|
3125
3127
|
properties: { key: { type: "string" }, updated: { type: "boolean" } },
|
|
3126
3128
|
required: ["key", "updated"]
|
|
3127
3129
|
},
|
|
@@ -3160,7 +3162,7 @@ function setFileCommand() {
|
|
|
3160
3162
|
additionalProperties: false
|
|
3161
3163
|
},
|
|
3162
3164
|
outputSchema: {
|
|
3163
|
-
...OBJECT_OUTPUT$
|
|
3165
|
+
...OBJECT_OUTPUT$e,
|
|
3164
3166
|
properties: { key: { type: "string" }, updated: { type: "boolean" } },
|
|
3165
3167
|
required: ["key", "updated"]
|
|
3166
3168
|
},
|
|
@@ -3197,7 +3199,7 @@ function mutationCommand(options) {
|
|
|
3197
3199
|
additionalProperties: false
|
|
3198
3200
|
},
|
|
3199
3201
|
outputSchema: {
|
|
3200
|
-
...OBJECT_OUTPUT$
|
|
3202
|
+
...OBJECT_OUTPUT$e,
|
|
3201
3203
|
properties: {
|
|
3202
3204
|
key: { type: "string" },
|
|
3203
3205
|
[options.resultProperty]: { type: "boolean" }
|
|
@@ -3275,13 +3277,13 @@ async function digestFile(path) {
|
|
|
3275
3277
|
try {
|
|
3276
3278
|
const buffer = new Uint8Array(256 * 1024);
|
|
3277
3279
|
while (true) {
|
|
3278
|
-
const
|
|
3279
|
-
if (
|
|
3280
|
+
const read2 = await file.read(buffer);
|
|
3281
|
+
if (read2 === null)
|
|
3280
3282
|
break;
|
|
3281
|
-
const chunk = buffer.subarray(0,
|
|
3283
|
+
const chunk = buffer.subarray(0, read2);
|
|
3282
3284
|
sha.update(chunk);
|
|
3283
3285
|
crc = updateCrc32(crc, chunk);
|
|
3284
|
-
size +=
|
|
3286
|
+
size += read2;
|
|
3285
3287
|
if (!Number.isSafeInteger(size))
|
|
3286
3288
|
throw new UsageError("FILE_TOO_LARGE", "file is too large");
|
|
3287
3289
|
}
|
|
@@ -3331,47 +3333,145 @@ async function gzipFile(source, destination) {
|
|
|
3331
3333
|
}
|
|
3332
3334
|
async function readTarGz(bytes, limit) {
|
|
3333
3335
|
const tar = await gunzipBytes(bytes, limit);
|
|
3334
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
3335
|
-
const text2 = (offset2, length) => decoder.decode(tar.subarray(offset2, offset2 + length)).replace(/\0.*$/s, "");
|
|
3336
3336
|
const files = [];
|
|
3337
3337
|
const seen = /* @__PURE__ */ new Set();
|
|
3338
3338
|
let offset = 0;
|
|
3339
3339
|
while (offset + BLOCK_SIZE <= tar.length && tar.subarray(offset, offset + BLOCK_SIZE).some(Boolean)) {
|
|
3340
|
-
|
|
3341
|
-
let size;
|
|
3342
|
-
let mode;
|
|
3343
|
-
try {
|
|
3344
|
-
const prefix = text2(offset + 257, 6) === "ustar" ? text2(offset + 345, 155) : "";
|
|
3345
|
-
raw = prefix ? `${prefix}/${text2(offset, 100)}` : text2(offset, 100);
|
|
3346
|
-
size = Number.parseInt(text2(offset + 124, 12).trim() || "0", 8);
|
|
3347
|
-
mode = Number.parseInt(text2(offset + 100, 8).trim() || "0", 8);
|
|
3348
|
-
} catch {
|
|
3349
|
-
throw invalidZip("payload", "tar header is not valid UTF-8");
|
|
3350
|
-
}
|
|
3351
|
-
const type = String.fromCharCode(tar[offset + 156] || 48);
|
|
3352
|
-
const path = raw.replace(/^(?:\.\/)+/, "").replace(/\/$/, "");
|
|
3340
|
+
const header = parseTarHeader(tar.subarray(offset, offset + BLOCK_SIZE));
|
|
3353
3341
|
const start = offset + BLOCK_SIZE;
|
|
3354
|
-
if (
|
|
3355
|
-
throw invalidZip("payload", `tar entry is truncated: ${
|
|
3356
|
-
}
|
|
3357
|
-
offset = start + Math.ceil(size / BLOCK_SIZE) * BLOCK_SIZE;
|
|
3358
|
-
if (type === "5" && (path === "" || path === "."))
|
|
3359
|
-
continue;
|
|
3360
|
-
if (!path || path.startsWith("/") || /^[A-Za-z]:/.test(path) || path.includes("\\") || path.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
3361
|
-
throw invalidZip("payload", `unsafe tar entry path: ${JSON.stringify(raw)}`);
|
|
3342
|
+
if (start + header.size > tar.length) {
|
|
3343
|
+
throw invalidZip("payload", `tar entry is truncated: ${header.path}`);
|
|
3362
3344
|
}
|
|
3363
|
-
|
|
3345
|
+
offset = start + Math.ceil(header.size / BLOCK_SIZE) * BLOCK_SIZE;
|
|
3346
|
+
if (header.kind !== "file")
|
|
3364
3347
|
continue;
|
|
3365
|
-
if (
|
|
3366
|
-
throw invalidZip("payload", `tar entry
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
throw invalidZip("payload", `duplicate tar entry: ${path}`);
|
|
3370
|
-
seen.add(path);
|
|
3371
|
-
files.push({ path, executable: (mode & 73) !== 0, bytes: tar.slice(start, start + size) });
|
|
3348
|
+
if (seen.has(header.path))
|
|
3349
|
+
throw invalidZip("payload", `duplicate tar entry: ${header.path}`);
|
|
3350
|
+
seen.add(header.path);
|
|
3351
|
+
files.push({ path: header.path, executable: header.executable, bytes: tar.slice(start, start + header.size) });
|
|
3372
3352
|
}
|
|
3373
3353
|
return files;
|
|
3374
3354
|
}
|
|
3355
|
+
function parseTarHeader(block) {
|
|
3356
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
3357
|
+
const text2 = (offset, length) => decoder.decode(block.subarray(offset, offset + length)).replace(/\0.*$/s, "");
|
|
3358
|
+
let raw;
|
|
3359
|
+
let size;
|
|
3360
|
+
let mode;
|
|
3361
|
+
try {
|
|
3362
|
+
const prefix = text2(257, 6) === "ustar" ? text2(345, 155) : "";
|
|
3363
|
+
raw = prefix ? `${prefix}/${text2(0, 100)}` : text2(0, 100);
|
|
3364
|
+
size = Number.parseInt(text2(124, 12).trim() || "0", 8);
|
|
3365
|
+
mode = Number.parseInt(text2(100, 8).trim() || "0", 8);
|
|
3366
|
+
} catch {
|
|
3367
|
+
throw invalidZip("payload", "tar header is not valid UTF-8");
|
|
3368
|
+
}
|
|
3369
|
+
if (!Number.isSafeInteger(size) || size < 0) {
|
|
3370
|
+
throw invalidZip("payload", `tar entry is truncated: ${raw}`);
|
|
3371
|
+
}
|
|
3372
|
+
const type = String.fromCharCode(block[156] || 48);
|
|
3373
|
+
const path = raw.replace(/^(?:\.\/)+/, "").replace(/\/$/, "");
|
|
3374
|
+
if (type === "5" && (path === "" || path === ".")) {
|
|
3375
|
+
return { path, kind: "root", size, executable: false };
|
|
3376
|
+
}
|
|
3377
|
+
if (!path || path.startsWith("/") || /^[A-Za-z]:/.test(path) || path.includes("\\") || path.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
3378
|
+
throw invalidZip("payload", `unsafe tar entry path: ${JSON.stringify(raw)}`);
|
|
3379
|
+
}
|
|
3380
|
+
if (type !== "5" && type !== "0") {
|
|
3381
|
+
throw invalidZip("payload", `tar entry is not a regular file or directory: ${path}`);
|
|
3382
|
+
}
|
|
3383
|
+
return { path, kind: type === "5" ? "directory" : "file", size, executable: (mode & 73) !== 0 };
|
|
3384
|
+
}
|
|
3385
|
+
async function listTarGzStream(gzip, limit, capture2) {
|
|
3386
|
+
const listing = { files: /* @__PURE__ */ new Map(), directories: /* @__PURE__ */ new Set(), captured: /* @__PURE__ */ new Map() };
|
|
3387
|
+
const header = new Uint8Array(BLOCK_SIZE);
|
|
3388
|
+
let headerFill = 0;
|
|
3389
|
+
let skip = 0;
|
|
3390
|
+
let body;
|
|
3391
|
+
let ended = false;
|
|
3392
|
+
let total = 0;
|
|
3393
|
+
try {
|
|
3394
|
+
const stream = gzip.pipeThrough(
|
|
3395
|
+
new DecompressionStream("gzip")
|
|
3396
|
+
);
|
|
3397
|
+
for await (const chunk of stream) {
|
|
3398
|
+
total += chunk.length;
|
|
3399
|
+
if (total > limit)
|
|
3400
|
+
throw invalidZip("limits", "payload expands beyond the size limit");
|
|
3401
|
+
let offset = 0;
|
|
3402
|
+
while (offset < chunk.length && !ended) {
|
|
3403
|
+
if (skip > 0) {
|
|
3404
|
+
const take2 = Math.min(skip, chunk.length - offset);
|
|
3405
|
+
if (body && body.fill < body.bytes.length) {
|
|
3406
|
+
const part = Math.min(take2, body.bytes.length - body.fill);
|
|
3407
|
+
body.bytes.set(chunk.subarray(offset, offset + part), body.fill);
|
|
3408
|
+
body.fill += part;
|
|
3409
|
+
if (body.fill === body.bytes.length) {
|
|
3410
|
+
listing.captured.set(body.path, body.bytes);
|
|
3411
|
+
body = void 0;
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
skip -= take2;
|
|
3415
|
+
offset += take2;
|
|
3416
|
+
continue;
|
|
3417
|
+
}
|
|
3418
|
+
const take = Math.min(BLOCK_SIZE - headerFill, chunk.length - offset);
|
|
3419
|
+
header.set(chunk.subarray(offset, offset + take), headerFill);
|
|
3420
|
+
headerFill += take;
|
|
3421
|
+
offset += take;
|
|
3422
|
+
if (headerFill < BLOCK_SIZE)
|
|
3423
|
+
break;
|
|
3424
|
+
headerFill = 0;
|
|
3425
|
+
if (!header.some(Boolean)) {
|
|
3426
|
+
ended = true;
|
|
3427
|
+
break;
|
|
3428
|
+
}
|
|
3429
|
+
const entry = parseTarHeader(header);
|
|
3430
|
+
skip = Math.ceil(entry.size / BLOCK_SIZE) * BLOCK_SIZE;
|
|
3431
|
+
if (entry.kind === "directory")
|
|
3432
|
+
listing.directories.add(entry.path);
|
|
3433
|
+
if (entry.kind !== "file")
|
|
3434
|
+
continue;
|
|
3435
|
+
if (listing.files.has(entry.path)) {
|
|
3436
|
+
throw invalidZip("payload", `duplicate tar entry: ${entry.path}`);
|
|
3437
|
+
}
|
|
3438
|
+
listing.files.set(entry.path, { size: entry.size, executable: entry.executable });
|
|
3439
|
+
if (capture2(entry.path, entry.size)) {
|
|
3440
|
+
if (entry.size === 0)
|
|
3441
|
+
listing.captured.set(entry.path, new Uint8Array());
|
|
3442
|
+
else
|
|
3443
|
+
body = { path: entry.path, bytes: new Uint8Array(entry.size), fill: 0 };
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
} catch (error) {
|
|
3448
|
+
if (error instanceof ToolError)
|
|
3449
|
+
throw error;
|
|
3450
|
+
throw invalidZip("compression", "payload is not a valid gzip stream");
|
|
3451
|
+
}
|
|
3452
|
+
if (skip > 0 || headerFill > 0 || body)
|
|
3453
|
+
throw invalidZip("payload", "tar stream is truncated");
|
|
3454
|
+
return listing;
|
|
3455
|
+
}
|
|
3456
|
+
function fileReadableStream(path) {
|
|
3457
|
+
let file;
|
|
3458
|
+
return new ReadableStream({
|
|
3459
|
+
async pull(controller) {
|
|
3460
|
+
file ??= await getHost().open(path, { read: true });
|
|
3461
|
+
const buffer = new Uint8Array(256 * 1024);
|
|
3462
|
+
const read2 = await file.read(buffer);
|
|
3463
|
+
if (read2 === null) {
|
|
3464
|
+
await file.close();
|
|
3465
|
+
controller.close();
|
|
3466
|
+
return;
|
|
3467
|
+
}
|
|
3468
|
+
controller.enqueue(buffer.subarray(0, read2));
|
|
3469
|
+
},
|
|
3470
|
+
async cancel() {
|
|
3471
|
+
await file?.close();
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3474
|
+
}
|
|
3375
3475
|
async function gunzipBytes(bytes, limit) {
|
|
3376
3476
|
const stream = new ReadableStream({
|
|
3377
3477
|
start(controller) {
|
|
@@ -3810,14 +3910,14 @@ function zipEntryStream(path, entry) {
|
|
|
3810
3910
|
return;
|
|
3811
3911
|
}
|
|
3812
3912
|
const buffer = new Uint8Array(Math.min(256 * 1024, remaining));
|
|
3813
|
-
const
|
|
3814
|
-
if (
|
|
3913
|
+
const read2 = await file.read(buffer);
|
|
3914
|
+
if (read2 === null) {
|
|
3815
3915
|
void file.close();
|
|
3816
3916
|
controller.error(invalidZip("container", `truncated entry: ${entry.name}`));
|
|
3817
3917
|
return;
|
|
3818
3918
|
}
|
|
3819
|
-
remaining -=
|
|
3820
|
-
controller.enqueue(buffer.subarray(0,
|
|
3919
|
+
remaining -= read2;
|
|
3920
|
+
controller.enqueue(buffer.subarray(0, read2));
|
|
3821
3921
|
},
|
|
3822
3922
|
cancel() {
|
|
3823
3923
|
void file?.close();
|
|
@@ -4009,10 +4109,10 @@ async function copyFileToWriter(path, output) {
|
|
|
4009
4109
|
try {
|
|
4010
4110
|
const buffer = new Uint8Array(256 * 1024);
|
|
4011
4111
|
while (true) {
|
|
4012
|
-
const
|
|
4013
|
-
if (
|
|
4112
|
+
const read2 = await input.read(buffer);
|
|
4113
|
+
if (read2 === null)
|
|
4014
4114
|
break;
|
|
4015
|
-
await writeAll(output, buffer.subarray(0,
|
|
4115
|
+
await writeAll(output, buffer.subarray(0, read2));
|
|
4016
4116
|
}
|
|
4017
4117
|
} finally {
|
|
4018
4118
|
await input.close();
|
|
@@ -4026,10 +4126,10 @@ async function readAt(file, offset, length) {
|
|
|
4026
4126
|
const output = new Uint8Array(length);
|
|
4027
4127
|
let position = 0;
|
|
4028
4128
|
while (position < length) {
|
|
4029
|
-
const
|
|
4030
|
-
if (
|
|
4129
|
+
const read2 = await file.read(output.subarray(position));
|
|
4130
|
+
if (read2 === null)
|
|
4031
4131
|
throw invalidZip("container", "ZIP file is truncated");
|
|
4032
|
-
position +=
|
|
4132
|
+
position += read2;
|
|
4033
4133
|
}
|
|
4034
4134
|
return output;
|
|
4035
4135
|
}
|
|
@@ -4163,11 +4263,10 @@ function derivedSelector(key) {
|
|
|
4163
4263
|
web: {},
|
|
4164
4264
|
agent: {},
|
|
4165
4265
|
agent_skills: {},
|
|
4166
|
-
agent_tools: {},
|
|
4167
4266
|
aiws: {},
|
|
4168
4267
|
script: {}
|
|
4169
4268
|
};
|
|
4170
|
-
return selectors[key];
|
|
4269
|
+
return selectors[key] ?? extToolsPlatformOfKey(key)?.selector;
|
|
4171
4270
|
}
|
|
4172
4271
|
function canonicalSelector(value, label) {
|
|
4173
4272
|
if (value === void 0)
|
|
@@ -4505,6 +4604,204 @@ async function verifyAiwsPayload(tarGz) {
|
|
|
4505
4604
|
templates: checked.manifest.workspace_templates.map((t) => ({ id: t.id, title: t.title, digest: t.digest, requires: t.requires }))
|
|
4506
4605
|
};
|
|
4507
4606
|
}
|
|
4607
|
+
const EXT_TOOLS_APP_TYPE = "ext_tools";
|
|
4608
|
+
const EXT_TOOLS_MANIFEST_FILE = "ext-manifest.json";
|
|
4609
|
+
const EXT_TOOLS_MANIFEST_SCHEMA = "buckyos.ext_tools/1";
|
|
4610
|
+
const MAX_EXT_TOOLS_PAYLOAD_BYTES = 64 * 1024 * 1024 * 1024;
|
|
4611
|
+
const EXT_TOOLS_RESERVED_COMMANDS = [
|
|
4612
|
+
"agent-session",
|
|
4613
|
+
"agent_tool",
|
|
4614
|
+
"ai_provider",
|
|
4615
|
+
"ai_provider_test",
|
|
4616
|
+
"ai_quota",
|
|
4617
|
+
"aicc-tool",
|
|
4618
|
+
"ask_user",
|
|
4619
|
+
"buckyos",
|
|
4620
|
+
"caption_image",
|
|
4621
|
+
"detect_image",
|
|
4622
|
+
"edit_image",
|
|
4623
|
+
"edit_video",
|
|
4624
|
+
"enhance_audio",
|
|
4625
|
+
"extend_video",
|
|
4626
|
+
"gen_image",
|
|
4627
|
+
"gen_music",
|
|
4628
|
+
"gen_video",
|
|
4629
|
+
"import_office",
|
|
4630
|
+
"import_table",
|
|
4631
|
+
"inpaint_image",
|
|
4632
|
+
"llm_understand_media",
|
|
4633
|
+
"materialize_resource",
|
|
4634
|
+
"ocr_image",
|
|
4635
|
+
"remove_bg",
|
|
4636
|
+
"resume_aicc_task",
|
|
4637
|
+
"segment_image",
|
|
4638
|
+
"speech_to_text",
|
|
4639
|
+
"text_to_speech",
|
|
4640
|
+
"upscale_image",
|
|
4641
|
+
"upscale_video",
|
|
4642
|
+
"xagent"
|
|
4643
|
+
];
|
|
4644
|
+
const MAX_EXT_TOOLS_LAUNCHER_BYTES = 1024 * 1024;
|
|
4645
|
+
const EXT_TOOLS_ID = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
4646
|
+
const EXT_TOOLS_COMMAND = /^[A-Za-z0-9_+-][A-Za-z0-9._+-]*$/;
|
|
4647
|
+
const EXT_TOOLS_WINDOWS_SUFFIXES = ["", ".exe", ".cmd", ".bat", ".ps1"];
|
|
4648
|
+
const BUILD_MACHINE_PATH = /(?:^|[\s"'=:(])(\/home\/|\/Users\/|\/root\/|\/tmp\/|\/var\/folders\/|\/opt\/buckyos\/|[A-Za-z]:\\\\?Users\\)/;
|
|
4649
|
+
const EXT_TOOLS_PLATFORMS = [
|
|
4650
|
+
{ name: "linux-x86_64", key: "ext_tools_linux_x86_64", selector: { os: "linux", arch: "x86_64" } },
|
|
4651
|
+
{ name: "linux-aarch64", key: "ext_tools_linux_aarch64", selector: { os: "linux", arch: "aarch64" } },
|
|
4652
|
+
{ name: "darwin-arm64", key: "ext_tools_darwin_arm64", selector: { os: "macos", arch: "aarch64" } },
|
|
4653
|
+
{ name: "darwin-x86_64", key: "ext_tools_darwin_x86_64", selector: { os: "macos", arch: "x86_64" } },
|
|
4654
|
+
{ name: "windows-x86_64", key: "ext_tools_windows_x86_64", selector: { os: "windows", arch: "x86_64" } }
|
|
4655
|
+
];
|
|
4656
|
+
function extToolsPlatformOfKey(key) {
|
|
4657
|
+
return EXT_TOOLS_PLATFORMS.find((platform) => platform.key === key);
|
|
4658
|
+
}
|
|
4659
|
+
function extToolsManifestErrors(value) {
|
|
4660
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4661
|
+
return ["must be a JSON object"];
|
|
4662
|
+
const manifest = value;
|
|
4663
|
+
const errors = [];
|
|
4664
|
+
const allowed = ["schema", "id", "version", "requires", "conflicts", "provides", "platforms", "size_bytes", "license", "desc"];
|
|
4665
|
+
for (const key of Object.keys(manifest))
|
|
4666
|
+
if (!allowed.includes(key))
|
|
4667
|
+
errors.push(`${key} is not a field of the manifest`);
|
|
4668
|
+
if (manifest.schema !== EXT_TOOLS_MANIFEST_SCHEMA)
|
|
4669
|
+
errors.push(`schema must be ${EXT_TOOLS_MANIFEST_SCHEMA}`);
|
|
4670
|
+
if (typeof manifest.id !== "string" || !EXT_TOOLS_ID.test(manifest.id))
|
|
4671
|
+
errors.push("id must be lowercase letters, digits and -");
|
|
4672
|
+
if (typeof manifest.version !== "string" || !/^[A-Za-z0-9._+-]+$/.test(manifest.version))
|
|
4673
|
+
errors.push("version must be letters, digits and ._+-");
|
|
4674
|
+
if (!Array.isArray(manifest.provides) || manifest.provides.length === 0)
|
|
4675
|
+
errors.push("provides must not be empty");
|
|
4676
|
+
const commands = /* @__PURE__ */ new Set();
|
|
4677
|
+
for (const raw of Array.isArray(manifest.provides) ? manifest.provides : []) {
|
|
4678
|
+
const entry = raw ?? {};
|
|
4679
|
+
const command = entry.command;
|
|
4680
|
+
if (typeof command !== "string" || !EXT_TOOLS_COMMAND.test(command)) {
|
|
4681
|
+
errors.push(`provides: ${JSON.stringify(command)} is not a command name`);
|
|
4682
|
+
continue;
|
|
4683
|
+
}
|
|
4684
|
+
if (commands.has(command))
|
|
4685
|
+
errors.push(`provides: command ${command} is listed twice`);
|
|
4686
|
+
if (EXT_TOOLS_RESERVED_COMMANDS.includes(command))
|
|
4687
|
+
errors.push(`provides: ${command} is a standard command and cannot be provided by a package`);
|
|
4688
|
+
commands.add(command);
|
|
4689
|
+
if (typeof entry.version_probe !== "string" || !entry.version_probe.trim())
|
|
4690
|
+
errors.push(`provides: ${command} has no version_probe`);
|
|
4691
|
+
const smoke = entry.smoke;
|
|
4692
|
+
if (smoke !== void 0 && (typeof smoke !== "string" || !isSafeRelativePath(smoke))) {
|
|
4693
|
+
errors.push(`provides: the smoke of ${command} must be a relative path inside the payload`);
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
if (!Array.isArray(manifest.platforms) || manifest.platforms.length === 0)
|
|
4697
|
+
errors.push("platforms must not be empty");
|
|
4698
|
+
for (const platform of Array.isArray(manifest.platforms) ? manifest.platforms : []) {
|
|
4699
|
+
if (!EXT_TOOLS_PLATFORMS.some((known) => known.name === platform))
|
|
4700
|
+
errors.push(`unknown platform ${JSON.stringify(platform)}`);
|
|
4701
|
+
}
|
|
4702
|
+
for (const raw of Array.isArray(manifest.requires) ? manifest.requires : manifest.requires === void 0 ? [] : [null]) {
|
|
4703
|
+
const required = raw ?? {};
|
|
4704
|
+
if (typeof required.id !== "string" || !EXT_TOOLS_ID.test(required.id) || required.id === manifest.id || typeof required.version !== "string") {
|
|
4705
|
+
errors.push(`requires: ${JSON.stringify(raw)} is not another package's {id, version}`);
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
if (manifest.conflicts !== void 0 && !(Array.isArray(manifest.conflicts) && manifest.conflicts.every((id) => typeof id === "string" && id !== manifest.id))) {
|
|
4709
|
+
errors.push("conflicts must list other packages by id");
|
|
4710
|
+
}
|
|
4711
|
+
return errors;
|
|
4712
|
+
}
|
|
4713
|
+
function isSafeRelativePath(path) {
|
|
4714
|
+
return !path.includes("\\") && !path.startsWith("/") && path.split("/").every((part) => part && part !== "." && part !== "..");
|
|
4715
|
+
}
|
|
4716
|
+
function parseExtToolsManifest(bytes) {
|
|
4717
|
+
let value;
|
|
4718
|
+
try {
|
|
4719
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
4720
|
+
} catch (error) {
|
|
4721
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
4722
|
+
}
|
|
4723
|
+
const errors = extToolsManifestErrors(value);
|
|
4724
|
+
if (errors.length > 0)
|
|
4725
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE}: ${errors.join("; ")}`);
|
|
4726
|
+
const manifest = value;
|
|
4727
|
+
manifest.requires ??= [];
|
|
4728
|
+
manifest.conflicts ??= [];
|
|
4729
|
+
return manifest;
|
|
4730
|
+
}
|
|
4731
|
+
function extToolsPayloadErrors(manifest, platform, tree, buildPaths = []) {
|
|
4732
|
+
const errors = [];
|
|
4733
|
+
const windows = platform.startsWith("windows-");
|
|
4734
|
+
const suffixes = windows ? EXT_TOOLS_WINDOWS_SUFFIXES : [""];
|
|
4735
|
+
for (const path of [...tree.files.keys(), ...tree.directories]) {
|
|
4736
|
+
const [top, second] = path.split("/");
|
|
4737
|
+
const isTop = !path.includes("/");
|
|
4738
|
+
const known = top === EXT_TOOLS_MANIFEST_FILE && isTop || top === "bin" || top === "smoke" || top === "store";
|
|
4739
|
+
if (!known)
|
|
4740
|
+
errors.push(`${path}: a package only holds ${EXT_TOOLS_MANIFEST_FILE}, bin/, smoke/ and store/${manifest.id}/`);
|
|
4741
|
+
if (top === "store" && second !== void 0 && second !== manifest.id)
|
|
4742
|
+
errors.push(`${path}: a package only writes store/${manifest.id}/`);
|
|
4743
|
+
}
|
|
4744
|
+
const declared = new Set(manifest.provides.map((provided) => provided.command));
|
|
4745
|
+
for (const provided of manifest.provides) {
|
|
4746
|
+
const launcher = suffixes.map((suffix) => tree.files.get(`bin/${provided.command}${suffix}`)).find(Boolean);
|
|
4747
|
+
if (!launcher)
|
|
4748
|
+
errors.push(`bin/${provided.command}: the launcher of a provided command is missing`);
|
|
4749
|
+
else if (!windows && !launcher.executable)
|
|
4750
|
+
errors.push(`bin/${provided.command}: the launcher is not executable`);
|
|
4751
|
+
const smoke = provided.smoke && windows ? provided.smoke.replace(/\.[^./]+$/, ".ps1") : provided.smoke;
|
|
4752
|
+
if (smoke && !tree.files.has(smoke))
|
|
4753
|
+
errors.push(`${smoke}: the smoke script of ${provided.command} is missing`);
|
|
4754
|
+
}
|
|
4755
|
+
for (const path of tree.files.keys()) {
|
|
4756
|
+
if (!path.startsWith("bin/"))
|
|
4757
|
+
continue;
|
|
4758
|
+
const name = path.slice("bin/".length);
|
|
4759
|
+
const command = suffixes.map((suffix) => suffix && name.endsWith(suffix) ? name.slice(0, -suffix.length) : name).find((candidate) => declared.has(candidate));
|
|
4760
|
+
if (!command)
|
|
4761
|
+
errors.push(`${path}: not in provides, so nothing knows this package provides it`);
|
|
4762
|
+
}
|
|
4763
|
+
const decoder = new TextDecoder();
|
|
4764
|
+
for (const [path, bytes] of tree.launchers) {
|
|
4765
|
+
const text2 = decoder.decode(bytes);
|
|
4766
|
+
const named = buildPaths.find((dir) => text2.includes(dir));
|
|
4767
|
+
if (named)
|
|
4768
|
+
errors.push(`${path}: names ${named} on the machine that built it`);
|
|
4769
|
+
else if (BUILD_MACHINE_PATH.test(text2))
|
|
4770
|
+
errors.push(`${path}: names an absolute path of the machine that built it (${BUILD_MACHINE_PATH.exec(text2)?.[1]})`);
|
|
4771
|
+
}
|
|
4772
|
+
return errors;
|
|
4773
|
+
}
|
|
4774
|
+
function assertExtToolsOf(appDoc, manifest, platform, platforms) {
|
|
4775
|
+
if (manifest.id !== appDoc.name)
|
|
4776
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE} id ${manifest.id} is not the App name ${appDoc.name}`);
|
|
4777
|
+
if (manifest.version !== appDoc.version)
|
|
4778
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE} version ${manifest.version} is not the App version ${appDoc.version}`);
|
|
4779
|
+
if (!manifest.platforms.includes(platform))
|
|
4780
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE} does not list the payload's platform ${platform}`);
|
|
4781
|
+
const missing = manifest.platforms.filter((name) => !platforms.includes(name));
|
|
4782
|
+
if (missing.length > 0)
|
|
4783
|
+
throw invalid("ext_tools", `${EXT_TOOLS_MANIFEST_FILE} lists platforms without a payload: ${missing.join(", ")}`);
|
|
4784
|
+
}
|
|
4785
|
+
async function verifyExtToolsPayload(gzip, key, appDoc) {
|
|
4786
|
+
const platform = extToolsPlatformOfKey(key);
|
|
4787
|
+
if (!platform)
|
|
4788
|
+
throw invalid("appdoc", `an ext_tools package has no sub package ${key}`);
|
|
4789
|
+
const listing = await listTarGzStream(
|
|
4790
|
+
gzip,
|
|
4791
|
+
MAX_EXT_TOOLS_PAYLOAD_BYTES,
|
|
4792
|
+
(path, size) => path === EXT_TOOLS_MANIFEST_FILE || path.startsWith("bin/") && size <= MAX_EXT_TOOLS_LAUNCHER_BYTES
|
|
4793
|
+
);
|
|
4794
|
+
const raw = listing.captured.get(EXT_TOOLS_MANIFEST_FILE);
|
|
4795
|
+
if (!raw)
|
|
4796
|
+
throw invalid("ext_tools", `${key}: ${EXT_TOOLS_MANIFEST_FILE} is not at the root of the payload`);
|
|
4797
|
+
const manifest = parseExtToolsManifest(raw);
|
|
4798
|
+
assertExtToolsOf(appDoc, manifest, platform.name, Object.keys(expectObject$3(appDoc.pkg_list, "APPDOC.pkg_list")).flatMap((k) => extToolsPlatformOfKey(k)?.name ?? []));
|
|
4799
|
+
const launchers = new Map([...listing.captured].filter(([path]) => path.startsWith("bin/")));
|
|
4800
|
+
const errors = extToolsPayloadErrors(manifest, platform.name, { files: listing.files, directories: listing.directories, launchers });
|
|
4801
|
+
if (errors.length > 0)
|
|
4802
|
+
throw invalid("ext_tools", `${key}: ${errors.join("; ")}`);
|
|
4803
|
+
return manifest;
|
|
4804
|
+
}
|
|
4508
4805
|
async function validateSnapshot(distDir, appDoc, packageMeta) {
|
|
4509
4806
|
const payloads = /* @__PURE__ */ new Map();
|
|
4510
4807
|
for (const entryValue of Object.values(packageMeta.content_index)) {
|
|
@@ -4518,6 +4815,10 @@ async function validateSnapshot(distDir, appDoc, packageMeta) {
|
|
|
4518
4815
|
for (const sub of validated.subpackages)
|
|
4519
4816
|
await verifyAiwsPayload(await getHost().readFile(join$1(distDir, sub.payload_path)));
|
|
4520
4817
|
}
|
|
4818
|
+
if (appDoc.app_type === EXT_TOOLS_APP_TYPE) {
|
|
4819
|
+
for (const sub of validated.subpackages)
|
|
4820
|
+
await verifyExtToolsPayload(fileReadableStream(join$1(distDir, sub.payload_path)), sub.key, appDoc);
|
|
4821
|
+
}
|
|
4521
4822
|
return validated;
|
|
4522
4823
|
}
|
|
4523
4824
|
async function packSnapshot(distDir, destination, appDoc, packageMeta) {
|
|
@@ -4628,10 +4929,18 @@ async function inspectPikg(path) {
|
|
|
4628
4929
|
const sub = validated.subpackages[0];
|
|
4629
4930
|
aiws2 = await verifyAiwsPayload(await readZipEntry(archive, archive.byName.get(sub.payload_path), MAX_AIWS_PAYLOAD_BYTES));
|
|
4630
4931
|
}
|
|
4932
|
+
let extTools;
|
|
4933
|
+
if (appDoc.app_type === EXT_TOOLS_APP_TYPE) {
|
|
4934
|
+
for (const sub of validated.subpackages) {
|
|
4935
|
+
const manifest = await verifyExtToolsPayload(zipEntryStream(archive.path, archive.byName.get(sub.payload_path)), sub.key, appDoc);
|
|
4936
|
+
extTools ??= { ...manifest };
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4631
4939
|
const pikgDigest = await digestFile(path);
|
|
4632
4940
|
return {
|
|
4633
4941
|
schema_version: 1,
|
|
4634
4942
|
...aiws2 ? { aiws: aiws2 } : {},
|
|
4943
|
+
...extTools ? { ext_tools: extTools } : {},
|
|
4635
4944
|
protocol: PACKAGE_META_SCHEMA,
|
|
4636
4945
|
pikg_path: resolve$2(path),
|
|
4637
4946
|
size: pikgDigest.size,
|
|
@@ -4928,7 +5237,7 @@ function validateAppDocShape(appDoc) {
|
|
|
4928
5237
|
}
|
|
4929
5238
|
if (appDoc.doc_type !== "app")
|
|
4930
5239
|
throw invalid("appdoc", "APPDOC.doc_type must be app");
|
|
4931
|
-
if (!["service", "dapp", "web", "agent", "agent_skills", "aiws"].includes(String(appDoc.app_type))) {
|
|
5240
|
+
if (!["service", "dapp", "web", "agent", "agent_skills", "aiws", EXT_TOOLS_APP_TYPE].includes(String(appDoc.app_type))) {
|
|
4932
5241
|
throw invalid("appdoc", "APPDOC.app_type is invalid");
|
|
4933
5242
|
}
|
|
4934
5243
|
if (appDoc.name !== void 0)
|
|
@@ -4989,6 +5298,16 @@ function validateAppDocShape(appDoc) {
|
|
|
4989
5298
|
if (appDoc.app_type === "aiws" && Object.keys(pkgList).join() !== AIWS_SUB_PACKAGE) {
|
|
4990
5299
|
throw invalid("appdoc", "an aiws package must contain only the aiws sub package");
|
|
4991
5300
|
}
|
|
5301
|
+
if (appDoc.app_type === EXT_TOOLS_APP_TYPE) {
|
|
5302
|
+
expectNonEmptyString(appDoc.name, "APPDOC.name");
|
|
5303
|
+
const unknown = Object.keys(pkgList).find((key) => !extToolsPlatformOfKey(key));
|
|
5304
|
+
if (unknown)
|
|
5305
|
+
throw invalid("appdoc", `an ext_tools package must contain only ext_tools_<os>_<arch> sub packages, not ${unknown}`);
|
|
5306
|
+
} else {
|
|
5307
|
+
const stray = Object.keys(pkgList).find((key) => extToolsPlatformOfKey(key));
|
|
5308
|
+
if (stray)
|
|
5309
|
+
throw invalid("appdoc", `${stray} belongs to an ext_tools package`);
|
|
5310
|
+
}
|
|
4992
5311
|
deriveNamespaceForPackage(appDoc);
|
|
4993
5312
|
}
|
|
4994
5313
|
function deriveNamespaceForPackage(appDoc) {
|
|
@@ -5242,7 +5561,7 @@ function validateContentHandlers(value, permissions) {
|
|
|
5242
5561
|
}
|
|
5243
5562
|
return value;
|
|
5244
5563
|
}
|
|
5245
|
-
const PACKAGE_VERSION = "0.7.
|
|
5564
|
+
const PACKAGE_VERSION = "0.7.169";
|
|
5246
5565
|
const TOOL_VERSION = PACKAGE_VERSION;
|
|
5247
5566
|
const SDK_VERSION = PACKAGE_VERSION;
|
|
5248
5567
|
const PROTOCOL_VERSION = "1";
|
|
@@ -5259,15 +5578,18 @@ const VERSION$1 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
|
5259
5578
|
const SHA256_ID = /^sha256:[0-9a-f]{64}$/;
|
|
5260
5579
|
const OBJECT_ID = /^(?:appdoc|pkg):[0-9a-f]{64}$/;
|
|
5261
5580
|
const SAFE_GENERATED_FILE = /^[A-Za-z0-9._-]+$/;
|
|
5262
|
-
const OBJECT_OUTPUT$
|
|
5263
|
-
const APP_KINDS = ["static-web", "script", "docker", "agent-skills", "aiws-controls"];
|
|
5581
|
+
const OBJECT_OUTPUT$d = { type: "object", additionalProperties: true };
|
|
5582
|
+
const APP_KINDS = ["static-web", "script", "docker", "agent-skills", "aiws-controls", "ext-tools"];
|
|
5264
5583
|
const PATH_KINDS = {
|
|
5265
5584
|
"static-web": { key: "web", category: "web", selectorType: "static" },
|
|
5266
5585
|
script: { key: "script", category: "dapp", selectorType: "single" },
|
|
5267
5586
|
"agent-skills": { key: "agent_skills", category: "agent_skills", selectorType: "single" },
|
|
5268
5587
|
// AI Workspace controls: one bundle (aiws-manifest.json + controls/<dir>/), installed into the AI Workspace library
|
|
5269
|
-
"aiws-controls": { key: "aiws", category: "aiws", selectorType: "single" }
|
|
5588
|
+
"aiws-controls": { key: "aiws", category: "aiws", selectorType: "single" },
|
|
5589
|
+
// Extension tools: ext-manifest.json + payload/<platform>/, one sub package per platform, enabled for the Zone
|
|
5590
|
+
"ext-tools": { key: "ext_tools", category: "ext_tools", selectorType: "single" }
|
|
5270
5591
|
};
|
|
5592
|
+
const EXT_TOOLS_LAUNCHER_LIMIT = 1024 * 1024;
|
|
5271
5593
|
function packageEnvironmentQualifier(key, selector) {
|
|
5272
5594
|
const effective = selector ?? derivedSelector(key);
|
|
5273
5595
|
const os = effective?.os;
|
|
@@ -5299,19 +5621,33 @@ function createPikgModule(dependencies = {}) {
|
|
|
5299
5621
|
positionals: [
|
|
5300
5622
|
{ name: "meta_dir", description: "dapp_meta directory", required: false }
|
|
5301
5623
|
],
|
|
5624
|
+
options: [
|
|
5625
|
+
{
|
|
5626
|
+
name: "catalog",
|
|
5627
|
+
description: "ext-tools: a directory of other packages (<id>/ext-manifest.json) to check requires and same-named commands against",
|
|
5628
|
+
type: "string"
|
|
5629
|
+
}
|
|
5630
|
+
],
|
|
5302
5631
|
inputSchema: {
|
|
5303
5632
|
type: "object",
|
|
5304
|
-
properties: {
|
|
5633
|
+
properties: {
|
|
5634
|
+
meta_dir: { type: "string", minLength: 1 },
|
|
5635
|
+
catalog: { type: "string", minLength: 1 }
|
|
5636
|
+
},
|
|
5305
5637
|
additionalProperties: false
|
|
5306
5638
|
},
|
|
5307
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5639
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5308
5640
|
resultSchemaVersion: 1,
|
|
5309
5641
|
access: { mode: "fixed", level: "read" },
|
|
5310
5642
|
asyncMode: "sync",
|
|
5311
5643
|
requiresSession: false,
|
|
5312
5644
|
execution: "local",
|
|
5313
5645
|
networkAccess: false,
|
|
5314
|
-
examples: [
|
|
5646
|
+
examples: [
|
|
5647
|
+
"buckyos pikg doctor",
|
|
5648
|
+
"buckyos pikg doctor ./dapp_meta",
|
|
5649
|
+
"buckyos pikg doctor ./dapp_meta --catalog ../publish/exttool"
|
|
5650
|
+
],
|
|
5315
5651
|
handler: async (ctx, input) => await doctorCommand(ctx, input)
|
|
5316
5652
|
},
|
|
5317
5653
|
{
|
|
@@ -5357,7 +5693,7 @@ function createPikgModule(dependencies = {}) {
|
|
|
5357
5693
|
},
|
|
5358
5694
|
additionalProperties: false
|
|
5359
5695
|
},
|
|
5360
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5696
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5361
5697
|
resultSchemaVersion: 1,
|
|
5362
5698
|
access: { mode: "fixed", level: "write" },
|
|
5363
5699
|
asyncMode: "sync",
|
|
@@ -5369,7 +5705,8 @@ function createPikgModule(dependencies = {}) {
|
|
|
5369
5705
|
"buckyos --non-interactive pikg init . --owner did:bns:root --kind static-web --source ./web/dist",
|
|
5370
5706
|
"buckyos --non-interactive pikg init . --owner did:bns:root --kind agent-skills --source ./skills",
|
|
5371
5707
|
"buckyos --non-interactive pikg init . --owner did:bns:alice --kind aiws-controls --source ./aiws",
|
|
5372
|
-
"buckyos --non-interactive pikg init . --owner did:bns:alice --kind aiws-controls --source ./aiws --composite"
|
|
5708
|
+
"buckyos --non-interactive pikg init . --owner did:bns:alice --kind aiws-controls --source ./aiws --composite",
|
|
5709
|
+
"buckyos --non-interactive pikg init . --name ext-media --owner did:bns:root --kind ext-tools --source ./ext-media"
|
|
5373
5710
|
],
|
|
5374
5711
|
handler: async (ctx, input) => await initCommand(ctx, input, docker)
|
|
5375
5712
|
},
|
|
@@ -5384,7 +5721,7 @@ function createPikgModule(dependencies = {}) {
|
|
|
5384
5721
|
properties: { meta_dir: { type: "string", minLength: 1 } },
|
|
5385
5722
|
additionalProperties: false
|
|
5386
5723
|
},
|
|
5387
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5724
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5388
5725
|
resultSchemaVersion: 1,
|
|
5389
5726
|
access: { mode: "fixed", level: "write" },
|
|
5390
5727
|
asyncMode: "sync",
|
|
@@ -5405,7 +5742,7 @@ function createPikgModule(dependencies = {}) {
|
|
|
5405
5742
|
properties: { dist_dir: { type: "string", minLength: 1 } },
|
|
5406
5743
|
additionalProperties: false
|
|
5407
5744
|
},
|
|
5408
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5745
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5409
5746
|
resultSchemaVersion: 1,
|
|
5410
5747
|
access: { mode: "fixed", level: "write" },
|
|
5411
5748
|
asyncMode: "sync",
|
|
@@ -5425,7 +5762,7 @@ function createPikgModule(dependencies = {}) {
|
|
|
5425
5762
|
required: ["pikg_path"],
|
|
5426
5763
|
additionalProperties: false
|
|
5427
5764
|
},
|
|
5428
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5765
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5429
5766
|
resultSchemaVersion: 1,
|
|
5430
5767
|
access: { mode: "fixed", level: "read" },
|
|
5431
5768
|
asyncMode: "sync",
|
|
@@ -5446,7 +5783,7 @@ function createPikgModule(dependencies = {}) {
|
|
|
5446
5783
|
properties: { meta_dir: { type: "string", minLength: 1 } },
|
|
5447
5784
|
additionalProperties: false
|
|
5448
5785
|
},
|
|
5449
|
-
outputSchema: OBJECT_OUTPUT$
|
|
5786
|
+
outputSchema: OBJECT_OUTPUT$d,
|
|
5450
5787
|
resultSchemaVersion: 1,
|
|
5451
5788
|
access: { mode: "fixed", level: "destructive" },
|
|
5452
5789
|
asyncMode: "sync",
|
|
@@ -5527,6 +5864,10 @@ async function doctorCommand(ctx, input) {
|
|
|
5527
5864
|
status: missingSources.length === 0 ? "ok" : "missing",
|
|
5528
5865
|
missing: missingSources
|
|
5529
5866
|
});
|
|
5867
|
+
if (app.categories[0] === PATH_KINDS["ext-tools"].category) {
|
|
5868
|
+
const catalog = optionalInputString(input, "catalog");
|
|
5869
|
+
checks.push(...await extToolsChecks(app, pikg, metaDir, catalog ? resolveFromCwd$1(ctx, catalog) : void 0));
|
|
5870
|
+
}
|
|
5530
5871
|
} catch (error) {
|
|
5531
5872
|
checks.push({
|
|
5532
5873
|
name: "metadata_schema",
|
|
@@ -5540,7 +5881,7 @@ async function doctorCommand(ctx, input) {
|
|
|
5540
5881
|
const profile = profileName ? await ctx.configStore.readProfile(profileName) : void 0;
|
|
5541
5882
|
const host2 = getHost();
|
|
5542
5883
|
return {
|
|
5543
|
-
healthy: checks.every((check) => check.status === "ok"),
|
|
5884
|
+
healthy: checks.every((check) => check.status === "ok" || check.status === "skipped"),
|
|
5544
5885
|
tool_version: TOOL_VERSION,
|
|
5545
5886
|
sdk_version: SDK_VERSION,
|
|
5546
5887
|
protocol_version: PROTOCOL_VERSION,
|
|
@@ -5591,7 +5932,25 @@ async function initCommand(ctx, input, docker) {
|
|
|
5591
5932
|
let sourceValue;
|
|
5592
5933
|
let selector;
|
|
5593
5934
|
let sourceSummary2;
|
|
5594
|
-
if (kind === "
|
|
5935
|
+
if (kind === "ext-tools") {
|
|
5936
|
+
const platform = hostExtToolsPlatform();
|
|
5937
|
+
const absoluteSource = resolve$1(projectDir, source);
|
|
5938
|
+
subpackageKey = platform.key;
|
|
5939
|
+
selector = platform.selector;
|
|
5940
|
+
sourceValue = {
|
|
5941
|
+
type: "path",
|
|
5942
|
+
path: toPortablePath(relative(join(projectDir, "dapp_meta"), join(absoluteSource, "payload", platform.name)))
|
|
5943
|
+
};
|
|
5944
|
+
sourceSummary2 = { type: "path", path: displaySource(projectDir, absoluteSource), platform: platform.name };
|
|
5945
|
+
try {
|
|
5946
|
+
await getHost().lstat(join(absoluteSource, EXT_TOOLS_MANIFEST_FILE));
|
|
5947
|
+
} catch (error) {
|
|
5948
|
+
if (!isHostError(error, "NotFound"))
|
|
5949
|
+
throw error;
|
|
5950
|
+
await writeExtToolsSkeleton(absoluteSource, name, version, platform.name);
|
|
5951
|
+
sourceSummary2.skeleton = true;
|
|
5952
|
+
}
|
|
5953
|
+
} else if (kind === "docker") {
|
|
5595
5954
|
const image = await docker.inspect(source);
|
|
5596
5955
|
const arch = normalizeArch$1(image.architecture);
|
|
5597
5956
|
subpackageKey = arch === "x86_64" ? "amd64_docker_image" : arch === "aarch64" ? "aarch64_docker_image" : (() => {
|
|
@@ -5696,6 +6055,228 @@ async function writeAiwsSkeleton(dir, ownerDid, name, composite) {
|
|
|
5696
6055
|
await host2.writeTextFile(join(dir, AIWS_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
5697
6056
|
`);
|
|
5698
6057
|
}
|
|
6058
|
+
function hostExtToolsPlatform() {
|
|
6059
|
+
const host2 = getHost();
|
|
6060
|
+
const os = host2.platform === "darwin" ? "macos" : host2.platform === "win32" ? "windows" : host2.platform;
|
|
6061
|
+
const arch = normalizeArch$1(host2.arch);
|
|
6062
|
+
const platform = EXT_TOOLS_PLATFORMS.find((known) => known.selector.os === os && known.selector.arch === arch);
|
|
6063
|
+
if (!platform) {
|
|
6064
|
+
throw new UsageError("UNSUPPORTED_PLATFORM", `extension packages have no payload for ${os}/${arch}`);
|
|
6065
|
+
}
|
|
6066
|
+
return platform;
|
|
6067
|
+
}
|
|
6068
|
+
async function writeExtToolsSkeleton(dir, id, version, platform) {
|
|
6069
|
+
const host2 = getHost();
|
|
6070
|
+
const manifest = {
|
|
6071
|
+
schema: EXT_TOOLS_MANIFEST_SCHEMA,
|
|
6072
|
+
id,
|
|
6073
|
+
version,
|
|
6074
|
+
requires: [],
|
|
6075
|
+
conflicts: [],
|
|
6076
|
+
provides: [{ command: id, version_probe: `${id} --version`, smoke: `smoke/${id}.sh` }],
|
|
6077
|
+
platforms: [platform],
|
|
6078
|
+
license: "",
|
|
6079
|
+
desc: ""
|
|
6080
|
+
};
|
|
6081
|
+
const text2 = `${JSON.stringify(manifest, null, 2)}
|
|
6082
|
+
`;
|
|
6083
|
+
const payload = join(dir, "payload", platform);
|
|
6084
|
+
for (const sub of ["bin", "smoke", join("store", id)])
|
|
6085
|
+
await host2.mkdir(join(payload, sub), { recursive: true });
|
|
6086
|
+
await host2.writeTextFile(join(dir, EXT_TOOLS_MANIFEST_FILE), text2);
|
|
6087
|
+
await host2.writeTextFile(join(payload, EXT_TOOLS_MANIFEST_FILE), text2);
|
|
6088
|
+
const windows = platform.startsWith("windows-");
|
|
6089
|
+
await host2.writeTextFile(
|
|
6090
|
+
join(payload, "bin", windows ? `${id}.cmd` : id),
|
|
6091
|
+
windows ? `@echo off\r
|
|
6092
|
+
echo ${id} ${version}\r
|
|
6093
|
+
` : `#!/bin/sh
|
|
6094
|
+
echo "${id} ${version}"
|
|
6095
|
+
`,
|
|
6096
|
+
{ mode: 493 }
|
|
6097
|
+
);
|
|
6098
|
+
await host2.writeTextFile(
|
|
6099
|
+
join(payload, "smoke", windows ? `${id}.ps1` : `${id}.sh`),
|
|
6100
|
+
windows ? `$ErrorActionPreference = 'Continue'
|
|
6101
|
+
& ${id} --version | Out-Null
|
|
6102
|
+
if ($LASTEXITCODE -ne 0) { exit 1 }
|
|
6103
|
+
` : `#!/bin/sh
|
|
6104
|
+
set -eu
|
|
6105
|
+
${id} --version >/dev/null
|
|
6106
|
+
`,
|
|
6107
|
+
{ mode: 493 }
|
|
6108
|
+
);
|
|
6109
|
+
}
|
|
6110
|
+
async function readExtToolsManifestFile(path) {
|
|
6111
|
+
let text2;
|
|
6112
|
+
try {
|
|
6113
|
+
text2 = await getHost().readTextFile(path);
|
|
6114
|
+
} catch (error) {
|
|
6115
|
+
if (isHostError(error, "NotFound"))
|
|
6116
|
+
return { text: "", errors: ["not found"] };
|
|
6117
|
+
throw error;
|
|
6118
|
+
}
|
|
6119
|
+
let value;
|
|
6120
|
+
try {
|
|
6121
|
+
value = JSON.parse(text2);
|
|
6122
|
+
} catch {
|
|
6123
|
+
return { text: text2, errors: ["not valid JSON"] };
|
|
6124
|
+
}
|
|
6125
|
+
const errors = extToolsManifestErrors(value);
|
|
6126
|
+
if (errors.length > 0)
|
|
6127
|
+
return { text: text2, errors };
|
|
6128
|
+
const manifest = value;
|
|
6129
|
+
manifest.requires ??= [];
|
|
6130
|
+
manifest.conflicts ??= [];
|
|
6131
|
+
return { text: text2, manifest, errors };
|
|
6132
|
+
}
|
|
6133
|
+
async function readExtToolsPayloadTree(root) {
|
|
6134
|
+
const host2 = getHost();
|
|
6135
|
+
const tree = { files: /* @__PURE__ */ new Map(), directories: /* @__PURE__ */ new Set(), launchers: /* @__PURE__ */ new Map() };
|
|
6136
|
+
const errors = [];
|
|
6137
|
+
const realRoot = await host2.realPath(root);
|
|
6138
|
+
const walk = async (directory, prefix) => {
|
|
6139
|
+
const children = await host2.readDir(directory);
|
|
6140
|
+
for (const child of children) {
|
|
6141
|
+
const archivePath = prefix ? `${prefix}/${child.name}` : child.name;
|
|
6142
|
+
const path = join(directory, child.name);
|
|
6143
|
+
const link = await host2.lstat(path);
|
|
6144
|
+
let physical = path;
|
|
6145
|
+
if (link.isSymlink) {
|
|
6146
|
+
try {
|
|
6147
|
+
physical = await host2.realPath(path);
|
|
6148
|
+
} catch (error) {
|
|
6149
|
+
errors.push(`${archivePath}: ${isHostError(error, "NotFound") ? "a dangling symlink" : "a symlink out of the payload"}`);
|
|
6150
|
+
continue;
|
|
6151
|
+
}
|
|
6152
|
+
const inside = relative(realRoot, physical);
|
|
6153
|
+
if (inside === ".." || inside.startsWith(`..${host2.path.sep}`) || isAbsolute$1(inside)) {
|
|
6154
|
+
errors.push(`${archivePath}: a symlink out of the payload`);
|
|
6155
|
+
continue;
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
const info = link.isSymlink ? await host2.stat(physical) : link;
|
|
6159
|
+
if (info.isDirectory) {
|
|
6160
|
+
tree.directories.add(archivePath);
|
|
6161
|
+
await walk(physical, archivePath);
|
|
6162
|
+
} else if (info.isFile) {
|
|
6163
|
+
tree.files.set(archivePath, { executable: ((info.mode ?? 0) & 73) !== 0 });
|
|
6164
|
+
if (archivePath.startsWith("bin/") && info.size <= EXT_TOOLS_LAUNCHER_LIMIT) {
|
|
6165
|
+
tree.launchers.set(archivePath, await host2.readFile(physical));
|
|
6166
|
+
}
|
|
6167
|
+
} else {
|
|
6168
|
+
errors.push(`${archivePath}: not a regular file`);
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
};
|
|
6172
|
+
await walk(realRoot, "");
|
|
6173
|
+
return { tree, errors };
|
|
6174
|
+
}
|
|
6175
|
+
async function extToolsChecks(app, pikg, metaDir, catalogDir) {
|
|
6176
|
+
const checks = [];
|
|
6177
|
+
const platforms = /* @__PURE__ */ new Map();
|
|
6178
|
+
const stray = [];
|
|
6179
|
+
for (const [key, subpackage] of Object.entries(pikg.sub_pkgs)) {
|
|
6180
|
+
const platform = extToolsPlatformOfKey(key);
|
|
6181
|
+
if (!platform || subpackage.source.type !== "path") {
|
|
6182
|
+
stray.push(key);
|
|
6183
|
+
continue;
|
|
6184
|
+
}
|
|
6185
|
+
platforms.set(platform.name, resolve$1(metaDir, subpackage.source.path));
|
|
6186
|
+
}
|
|
6187
|
+
const sources = [...platforms.values()];
|
|
6188
|
+
const source = sources.length > 0 ? dirname(dirname(sources[0])) : dirname(metaDir);
|
|
6189
|
+
const master = await readExtToolsManifestFile(join(source, EXT_TOOLS_MANIFEST_FILE));
|
|
6190
|
+
const manifestErrors = [...master.errors];
|
|
6191
|
+
if (stray.length > 0)
|
|
6192
|
+
manifestErrors.push(`sub packages must be ext_tools_<os>_<arch> from a directory: ${stray.join(", ")}`);
|
|
6193
|
+
const manifest = master.manifest;
|
|
6194
|
+
if (manifest) {
|
|
6195
|
+
if (manifest.id !== app.name)
|
|
6196
|
+
manifestErrors.push(`id ${manifest.id} is not the App name ${app.name}`);
|
|
6197
|
+
if (manifest.version !== app.version)
|
|
6198
|
+
manifestErrors.push(`version ${manifest.version} is not the App version ${app.version}`);
|
|
6199
|
+
const without = manifest.platforms.filter((name) => !platforms.has(name));
|
|
6200
|
+
if (without.length > 0)
|
|
6201
|
+
manifestErrors.push(`platforms without a sub package: ${without.join(", ")}`);
|
|
6202
|
+
const unlisted = [...platforms.keys()].filter((name) => !manifest.platforms.includes(name));
|
|
6203
|
+
if (unlisted.length > 0)
|
|
6204
|
+
manifestErrors.push(`sub packages of platforms it does not list: ${unlisted.join(", ")}`);
|
|
6205
|
+
}
|
|
6206
|
+
checks.push({
|
|
6207
|
+
name: "ext_tools_manifest",
|
|
6208
|
+
status: manifestErrors.length === 0 ? "ok" : "error",
|
|
6209
|
+
path: join(source, EXT_TOOLS_MANIFEST_FILE),
|
|
6210
|
+
...manifestErrors.length > 0 ? { errors: manifestErrors } : {}
|
|
6211
|
+
});
|
|
6212
|
+
if (!manifest)
|
|
6213
|
+
return checks;
|
|
6214
|
+
for (const [platform, dir] of platforms) {
|
|
6215
|
+
const errors = [];
|
|
6216
|
+
try {
|
|
6217
|
+
const { tree, errors: walkErrors } = await readExtToolsPayloadTree(dir);
|
|
6218
|
+
errors.push(...walkErrors);
|
|
6219
|
+
const copy = await readExtToolsManifestFile(join(dir, EXT_TOOLS_MANIFEST_FILE));
|
|
6220
|
+
if (copy.errors.length > 0)
|
|
6221
|
+
errors.push(`${EXT_TOOLS_MANIFEST_FILE}: ${copy.errors.join("; ")}`);
|
|
6222
|
+
else if (copy.text !== master.text)
|
|
6223
|
+
errors.push(`${EXT_TOOLS_MANIFEST_FILE}: differs from the package's manifest`);
|
|
6224
|
+
errors.push(...extToolsPayloadErrors(manifest, platform, tree, [source, metaDir]));
|
|
6225
|
+
} catch (error) {
|
|
6226
|
+
if (!isHostError(error, "NotFound"))
|
|
6227
|
+
throw error;
|
|
6228
|
+
errors.push(`${dir}: not found`);
|
|
6229
|
+
}
|
|
6230
|
+
checks.push({
|
|
6231
|
+
name: "ext_tools_payload",
|
|
6232
|
+
platform,
|
|
6233
|
+
status: errors.length === 0 ? "ok" : "error",
|
|
6234
|
+
path: dir,
|
|
6235
|
+
...errors.length > 0 ? { errors } : {}
|
|
6236
|
+
});
|
|
6237
|
+
}
|
|
6238
|
+
if (!catalogDir) {
|
|
6239
|
+
checks.push({
|
|
6240
|
+
name: "ext_tools_catalog",
|
|
6241
|
+
status: "skipped",
|
|
6242
|
+
detail: "no --catalog: requires and commands other packages also provide are not checked"
|
|
6243
|
+
});
|
|
6244
|
+
return checks;
|
|
6245
|
+
}
|
|
6246
|
+
const others = /* @__PURE__ */ new Map();
|
|
6247
|
+
const catalogErrors = [];
|
|
6248
|
+
for (const entry of await getHost().readDir(catalogDir)) {
|
|
6249
|
+
if (entry.isFile)
|
|
6250
|
+
continue;
|
|
6251
|
+
const candidate = await readExtToolsManifestFile(join(catalogDir, entry.name, EXT_TOOLS_MANIFEST_FILE));
|
|
6252
|
+
if (candidate.errors.includes("not found"))
|
|
6253
|
+
continue;
|
|
6254
|
+
if (!candidate.manifest)
|
|
6255
|
+
catalogErrors.push(`${entry.name}: ${candidate.errors.join("; ")}`);
|
|
6256
|
+
else if (candidate.manifest.id !== manifest.id)
|
|
6257
|
+
others.set(candidate.manifest.id, candidate.manifest);
|
|
6258
|
+
}
|
|
6259
|
+
for (const required of manifest.requires) {
|
|
6260
|
+
if (!others.has(required.id))
|
|
6261
|
+
catalogErrors.push(`requires ${required.id}: not in the catalog`);
|
|
6262
|
+
}
|
|
6263
|
+
const commands = new Set(manifest.provides.map((provided) => provided.command));
|
|
6264
|
+
for (const other of others.values()) {
|
|
6265
|
+
if (manifest.conflicts.includes(other.id) || other.conflicts.includes(manifest.id))
|
|
6266
|
+
continue;
|
|
6267
|
+
const shared = other.provides.map((provided) => provided.command).filter((command) => commands.has(command));
|
|
6268
|
+
if (shared.length > 0)
|
|
6269
|
+
catalogErrors.push(`${other.id} also provides ${shared.join(", ")}: one of the two must list the other in conflicts`);
|
|
6270
|
+
}
|
|
6271
|
+
checks.push({
|
|
6272
|
+
name: "ext_tools_catalog",
|
|
6273
|
+
status: catalogErrors.length === 0 ? "ok" : "error",
|
|
6274
|
+
path: catalogDir,
|
|
6275
|
+
packages: [...others.keys()],
|
|
6276
|
+
...catalogErrors.length > 0 ? { errors: catalogErrors } : {}
|
|
6277
|
+
});
|
|
6278
|
+
return checks;
|
|
6279
|
+
}
|
|
5699
6280
|
async function buildCommand$1(ctx, input, docker, now) {
|
|
5700
6281
|
const metaInput = optionalInputString(input, "meta_dir") ?? "./dapp_meta";
|
|
5701
6282
|
const metaDir = await realDirectory(resolveFromCwd$1(ctx, metaInput), "dapp_meta");
|
|
@@ -6739,7 +7320,7 @@ const CONTROL_PANEL_SERVICE = "control-panel";
|
|
|
6739
7320
|
const PLAN_SCHEMA_VERSION = 4;
|
|
6740
7321
|
const STAGING_RELEASE_TIMEOUT_MS = 5e3;
|
|
6741
7322
|
const ZIP_LOCAL_MAGIC = [80, 75, 3, 4];
|
|
6742
|
-
const OBJECT_OUTPUT$
|
|
7323
|
+
const OBJECT_OUTPUT$c = { type: "object", additionalProperties: true };
|
|
6743
7324
|
const INSTALL_POLICIES = [
|
|
6744
7325
|
"strict-public",
|
|
6745
7326
|
"normal",
|
|
@@ -6790,7 +7371,7 @@ function cancelCommand$1() {
|
|
|
6790
7371
|
required: ["task_id"],
|
|
6791
7372
|
additionalProperties: false
|
|
6792
7373
|
},
|
|
6793
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7374
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
6794
7375
|
resultSchemaVersion: 1,
|
|
6795
7376
|
access: { mode: "fixed", level: "write" },
|
|
6796
7377
|
asyncMode: "sync",
|
|
@@ -6825,7 +7406,7 @@ function fetchCommand(dependencies) {
|
|
|
6825
7406
|
target: { type: "object", additionalProperties: true },
|
|
6826
7407
|
install_params: { type: "object", additionalProperties: true }
|
|
6827
7408
|
}),
|
|
6828
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7409
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
6829
7410
|
resultSchemaVersion: 1,
|
|
6830
7411
|
access: { mode: "fixed", level: "read" },
|
|
6831
7412
|
asyncMode: "sync",
|
|
@@ -6842,7 +7423,7 @@ function listCommand$2() {
|
|
|
6842
7423
|
verb: "list",
|
|
6843
7424
|
summary: "List visible installed Apps",
|
|
6844
7425
|
inputSchema: emptyInputSchema(),
|
|
6845
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7426
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
6846
7427
|
resultSchemaVersion: 1,
|
|
6847
7428
|
access: { mode: "fixed", level: "read" },
|
|
6848
7429
|
asyncMode: "sync",
|
|
@@ -6900,7 +7481,7 @@ function installCommand(dependencies) {
|
|
|
6900
7481
|
no_wait: { type: "boolean" },
|
|
6901
7482
|
policy: { type: "string", enum: [...INSTALL_POLICIES] }
|
|
6902
7483
|
}),
|
|
6903
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7484
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
6904
7485
|
resultSchemaVersion: 1,
|
|
6905
7486
|
access: { mode: "fixed", level: "write" },
|
|
6906
7487
|
asyncMode: "either",
|
|
@@ -6944,7 +7525,7 @@ function upgradeCommand(dependencies) {
|
|
|
6944
7525
|
},
|
|
6945
7526
|
additionalProperties: false
|
|
6946
7527
|
},
|
|
6947
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7528
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
6948
7529
|
resultSchemaVersion: 1,
|
|
6949
7530
|
access: { mode: "fixed", level: "write" },
|
|
6950
7531
|
asyncMode: "either",
|
|
@@ -7073,7 +7654,7 @@ function statusCommand$1() {
|
|
|
7073
7654
|
properties: { app_name: { type: "string", minLength: 1 } },
|
|
7074
7655
|
additionalProperties: false
|
|
7075
7656
|
},
|
|
7076
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7657
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
7077
7658
|
resultSchemaVersion: 1,
|
|
7078
7659
|
access: { mode: "fixed", level: "read" },
|
|
7079
7660
|
asyncMode: "sync",
|
|
@@ -7131,7 +7712,7 @@ function publishCommand() {
|
|
|
7131
7712
|
property: "app_type",
|
|
7132
7713
|
description: "App type; defaults to the template app_type",
|
|
7133
7714
|
type: "string",
|
|
7134
|
-
enum: ["dapp", "web", "agent"]
|
|
7715
|
+
enum: ["dapp", "web", "agent", "ext_tools"]
|
|
7135
7716
|
}
|
|
7136
7717
|
],
|
|
7137
7718
|
inputSchema: {
|
|
@@ -7139,19 +7720,20 @@ function publishCommand() {
|
|
|
7139
7720
|
properties: {
|
|
7140
7721
|
local_dir: { type: "string", minLength: 1 },
|
|
7141
7722
|
app_doc: { type: "string", minLength: 1 },
|
|
7142
|
-
app_type: { type: "string", enum: ["dapp", "web", "agent"] }
|
|
7723
|
+
app_type: { type: "string", enum: ["dapp", "web", "agent", "ext_tools"] }
|
|
7143
7724
|
},
|
|
7144
7725
|
required: ["local_dir", "app_doc"],
|
|
7145
7726
|
additionalProperties: false
|
|
7146
7727
|
},
|
|
7147
|
-
outputSchema: OBJECT_OUTPUT$
|
|
7728
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
7148
7729
|
resultSchemaVersion: 1,
|
|
7149
7730
|
access: { mode: "fixed", level: "write" },
|
|
7150
7731
|
asyncMode: "sync",
|
|
7151
7732
|
requiresSession: true,
|
|
7152
7733
|
examples: [
|
|
7153
7734
|
"buckyos app publish /srv/build/demo-web --app-doc ./demo-web.appdoc.json",
|
|
7154
|
-
"buckyos app publish /srv/build/demo-agent --app-doc ./demo-agent.appdoc.json --app-type agent"
|
|
7735
|
+
"buckyos app publish /srv/build/demo-agent --app-doc ./demo-agent.appdoc.json --app-type agent",
|
|
7736
|
+
"buckyos app publish /srv/build/ext-media --app-doc ./dapp_dist/APPDOC.json"
|
|
7155
7737
|
],
|
|
7156
7738
|
handler: async (ctx, input) => {
|
|
7157
7739
|
const localDir = expectString(input, "local_dir");
|
|
@@ -7227,6 +7809,12 @@ async function installApp(ctx, input, dependencies) {
|
|
|
7227
7809
|
try {
|
|
7228
7810
|
let inspection = submittedPlan ? await recomputePlan(ctx, source, input, submittedPlan) : await inspectSource(ctx, source, input);
|
|
7229
7811
|
verifyPikgBinding(source, submittedPlan ?? inspection.plan);
|
|
7812
|
+
if (inspection.plan.app_doc?.app_type === "ext_tools") {
|
|
7813
|
+
throw new ToolError(
|
|
7814
|
+
"EXT_TOOLS_NOT_AN_APP",
|
|
7815
|
+
"an extension tool package is not installed as an App: publish it to the Repo with `buckyos app publish`, then enable it for the Zone on the management page"
|
|
7816
|
+
);
|
|
7817
|
+
}
|
|
7230
7818
|
const app = expectObject$1(inspection.plan.app, "inspection.plan.app");
|
|
7231
7819
|
const appDid = expectString(app, "did");
|
|
7232
7820
|
const plannedOwner = submittedPlan ? expectString(submittedPlan, "owner_user_id") : void 0;
|
|
@@ -7406,6 +7994,12 @@ async function mutateLifecycle(ctx, input, verb) {
|
|
|
7406
7994
|
const task = await waitForTask(ctx, taskId);
|
|
7407
7995
|
return { ...submitted, status: task };
|
|
7408
7996
|
}
|
|
7997
|
+
async function stageLocalPikg(ctx, path) {
|
|
7998
|
+
const prepared = await prepareSource(ctx, { pikg: path }, "inspect", {});
|
|
7999
|
+
if (prepared.kind === "catalog")
|
|
8000
|
+
throw new UsageError("INVALID_PIKG_SOURCE", "not a local PIKG");
|
|
8001
|
+
return prepared.staging;
|
|
8002
|
+
}
|
|
7409
8003
|
async function prepareSource(ctx, input, purpose, dependencies) {
|
|
7410
8004
|
const classified = await classifySource(ctx, input);
|
|
7411
8005
|
if (classified.kind === "catalog")
|
|
@@ -7542,12 +8136,12 @@ async function* fileChunks(file, size) {
|
|
|
7542
8136
|
while (true) {
|
|
7543
8137
|
let used = 0;
|
|
7544
8138
|
while (used < buffer.length) {
|
|
7545
|
-
const
|
|
7546
|
-
if (
|
|
8139
|
+
const read2 = await file.read(buffer.subarray(used));
|
|
8140
|
+
if (read2 === null)
|
|
7547
8141
|
break;
|
|
7548
|
-
if (
|
|
8142
|
+
if (read2 === 0)
|
|
7549
8143
|
throw new UsageError("PIKG_READ_FAILED", "PIKG read made no progress");
|
|
7550
|
-
used +=
|
|
8144
|
+
used += read2;
|
|
7551
8145
|
}
|
|
7552
8146
|
if (used === 0)
|
|
7553
8147
|
break;
|
|
@@ -8270,7 +8864,7 @@ function selectorCommand(options) {
|
|
|
8270
8864
|
required: ["app_name"],
|
|
8271
8865
|
additionalProperties: false
|
|
8272
8866
|
},
|
|
8273
|
-
outputSchema: OBJECT_OUTPUT$
|
|
8867
|
+
outputSchema: OBJECT_OUTPUT$c,
|
|
8274
8868
|
resultSchemaVersion: 1,
|
|
8275
8869
|
access: { mode: "fixed", level: options.access },
|
|
8276
8870
|
asyncMode: options.asyncMode,
|
|
@@ -8434,7 +9028,7 @@ function toHex(bytes) {
|
|
|
8434
9028
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
8435
9029
|
}
|
|
8436
9030
|
const CONTROL_PANEL$3 = "control-panel";
|
|
8437
|
-
const OBJECT_OUTPUT$
|
|
9031
|
+
const OBJECT_OUTPUT$b = { type: "object", additionalProperties: true };
|
|
8438
9032
|
function createDiagnosticModule(dependencies = {}) {
|
|
8439
9033
|
return {
|
|
8440
9034
|
name: "diagnostic",
|
|
@@ -8473,7 +9067,7 @@ function collectCommand() {
|
|
|
8473
9067
|
required: ["services"],
|
|
8474
9068
|
additionalProperties: false
|
|
8475
9069
|
},
|
|
8476
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9070
|
+
outputSchema: OBJECT_OUTPUT$b,
|
|
8477
9071
|
resultSchemaVersion: 1,
|
|
8478
9072
|
access: { mode: "fixed", level: "privileged" },
|
|
8479
9073
|
asyncMode: "task",
|
|
@@ -8527,7 +9121,7 @@ function exportCommand$2(dependencies) {
|
|
|
8527
9121
|
required: ["bundle_id", "path"],
|
|
8528
9122
|
additionalProperties: false
|
|
8529
9123
|
},
|
|
8530
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9124
|
+
outputSchema: OBJECT_OUTPUT$b,
|
|
8531
9125
|
resultSchemaVersion: 1,
|
|
8532
9126
|
access: { mode: "fixed", level: "privileged" },
|
|
8533
9127
|
asyncMode: "sync",
|
|
@@ -8569,7 +9163,7 @@ function compact$2(value) {
|
|
|
8569
9163
|
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
|
|
8570
9164
|
}
|
|
8571
9165
|
const CONTROL_PANEL$2 = "control-panel";
|
|
8572
|
-
const OBJECT_OUTPUT$
|
|
9166
|
+
const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
|
|
8573
9167
|
const LOG_LEVELS = ["error", "warning", "info", "debug", "trace"];
|
|
8574
9168
|
function createLogModule(dependencies = {}) {
|
|
8575
9169
|
return {
|
|
@@ -8590,7 +9184,7 @@ function servicesCommand() {
|
|
|
8590
9184
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
8591
9185
|
outputSchema: {
|
|
8592
9186
|
type: "object",
|
|
8593
|
-
properties: { services: { type: "array", items: OBJECT_OUTPUT$
|
|
9187
|
+
properties: { services: { type: "array", items: OBJECT_OUTPUT$a } },
|
|
8594
9188
|
required: ["services"],
|
|
8595
9189
|
additionalProperties: false
|
|
8596
9190
|
},
|
|
@@ -8663,7 +9257,7 @@ function tailCommand(dependencies) {
|
|
|
8663
9257
|
}
|
|
8664
9258
|
],
|
|
8665
9259
|
inputSchema: filterSchema({ from: { type: "string", enum: ["start", "end"] } }),
|
|
8666
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9260
|
+
outputSchema: OBJECT_OUTPUT$a,
|
|
8667
9261
|
resultSchemaVersion: 1,
|
|
8668
9262
|
access: { mode: "fixed", level: "read" },
|
|
8669
9263
|
asyncMode: "stream",
|
|
@@ -8719,7 +9313,7 @@ function exportCommand$1(dependencies) {
|
|
|
8719
9313
|
...filterSchema({ path: { type: "string", minLength: 1 } }),
|
|
8720
9314
|
required: ["path"]
|
|
8721
9315
|
},
|
|
8722
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9316
|
+
outputSchema: OBJECT_OUTPUT$a,
|
|
8723
9317
|
resultSchemaVersion: 1,
|
|
8724
9318
|
access: { mode: "fixed", level: "read" },
|
|
8725
9319
|
asyncMode: "sync",
|
|
@@ -8871,7 +9465,7 @@ function abortableSleep(milliseconds, signal) {
|
|
|
8871
9465
|
}
|
|
8872
9466
|
const TASK_MANAGER = "task-manager";
|
|
8873
9467
|
const CONTROL_PANEL$1 = "control-panel";
|
|
8874
|
-
const OBJECT_OUTPUT$
|
|
9468
|
+
const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
|
|
8875
9469
|
function createTaskModule() {
|
|
8876
9470
|
return {
|
|
8877
9471
|
name: "task",
|
|
@@ -8974,7 +9568,7 @@ function getCommand$2() {
|
|
|
8974
9568
|
required: ["task_id"],
|
|
8975
9569
|
additionalProperties: false
|
|
8976
9570
|
},
|
|
8977
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9571
|
+
outputSchema: OBJECT_OUTPUT$9,
|
|
8978
9572
|
resultSchemaVersion: 1,
|
|
8979
9573
|
access: { mode: "fixed", level: "read" },
|
|
8980
9574
|
asyncMode: "sync",
|
|
@@ -9015,7 +9609,7 @@ function waitCommand() {
|
|
|
9015
9609
|
summary: "Stream changes until a Task becomes terminal",
|
|
9016
9610
|
positionals: [{ name: "task_id", description: "Opaque Task ID", required: true }],
|
|
9017
9611
|
inputSchema: taskIdSchema(),
|
|
9018
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9612
|
+
outputSchema: OBJECT_OUTPUT$9,
|
|
9019
9613
|
resultSchemaVersion: 1,
|
|
9020
9614
|
access: { mode: "fixed", level: "read" },
|
|
9021
9615
|
asyncMode: "stream",
|
|
@@ -9066,7 +9660,7 @@ function cancelCommand() {
|
|
|
9066
9660
|
required: ["task_id"],
|
|
9067
9661
|
additionalProperties: false
|
|
9068
9662
|
},
|
|
9069
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9663
|
+
outputSchema: OBJECT_OUTPUT$9,
|
|
9070
9664
|
resultSchemaVersion: 1,
|
|
9071
9665
|
access: { mode: "fixed", level: "write" },
|
|
9072
9666
|
asyncMode: "sync",
|
|
@@ -9109,7 +9703,7 @@ function retryCommand() {
|
|
|
9109
9703
|
required: ["task_id"],
|
|
9110
9704
|
additionalProperties: false
|
|
9111
9705
|
},
|
|
9112
|
-
outputSchema: OBJECT_OUTPUT$
|
|
9706
|
+
outputSchema: OBJECT_OUTPUT$9,
|
|
9113
9707
|
resultSchemaVersion: 1,
|
|
9114
9708
|
access: { mode: "fixed", level: "write" },
|
|
9115
9709
|
asyncMode: "either",
|
|
@@ -9183,7 +9777,7 @@ function invalidResponse$1(label) {
|
|
|
9183
9777
|
throw new ToolError("INVALID_SERVICE_RESPONSE", `${label} is invalid`, EXIT_INTERNAL);
|
|
9184
9778
|
}
|
|
9185
9779
|
const sdk = provisionSdk;
|
|
9186
|
-
const OBJECT_OUTPUT$
|
|
9780
|
+
const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
|
|
9187
9781
|
const ROOT_OPTION = {
|
|
9188
9782
|
name: "root",
|
|
9189
9783
|
description: "Installed BuckyOS root on this machine (BUCKYOS_ROOT); read by status/check, written by activate",
|
|
@@ -9267,7 +9861,7 @@ function statusCommand(deps) {
|
|
|
9267
9861
|
additionalProperties: false
|
|
9268
9862
|
},
|
|
9269
9863
|
outputSchema: {
|
|
9270
|
-
...OBJECT_OUTPUT$
|
|
9864
|
+
...OBJECT_OUTPUT$8,
|
|
9271
9865
|
properties: {
|
|
9272
9866
|
root: { type: "string" },
|
|
9273
9867
|
state: {
|
|
@@ -9305,7 +9899,7 @@ function checkCommand(deps) {
|
|
|
9305
9899
|
additionalProperties: false
|
|
9306
9900
|
},
|
|
9307
9901
|
outputSchema: {
|
|
9308
|
-
...OBJECT_OUTPUT$
|
|
9902
|
+
...OBJECT_OUTPUT$8,
|
|
9309
9903
|
properties: {
|
|
9310
9904
|
ready: { type: "boolean" },
|
|
9311
9905
|
root: { type: "string" },
|
|
@@ -9353,7 +9947,7 @@ function activateCommand(deps) {
|
|
|
9353
9947
|
additionalProperties: false
|
|
9354
9948
|
},
|
|
9355
9949
|
outputSchema: {
|
|
9356
|
-
...OBJECT_OUTPUT$
|
|
9950
|
+
...OBJECT_OUTPUT$8,
|
|
9357
9951
|
properties: {
|
|
9358
9952
|
root: { type: "string" },
|
|
9359
9953
|
state: { type: "string", enum: ["configured"] },
|
|
@@ -9635,7 +10229,7 @@ function inputFingerprint(input) {
|
|
|
9635
10229
|
hash.update(new TextEncoder().encode(JSON.stringify(material)));
|
|
9636
10230
|
return hash.digestHex();
|
|
9637
10231
|
}
|
|
9638
|
-
const OBJECT_OUTPUT$
|
|
10232
|
+
const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
|
|
9639
10233
|
const SKILL_KINDS = ["cmd", "goal"];
|
|
9640
10234
|
const SKILLS_SUB_PKG = "agent_skills";
|
|
9641
10235
|
const SKILL_DIRS = ["cmd_skills", "goal_skills", "tools"];
|
|
@@ -9672,7 +10266,7 @@ function createSkillModule() {
|
|
|
9672
10266
|
required: ["agent_id"],
|
|
9673
10267
|
additionalProperties: false
|
|
9674
10268
|
},
|
|
9675
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10269
|
+
outputSchema: OBJECT_OUTPUT$7,
|
|
9676
10270
|
resultSchemaVersion: 1,
|
|
9677
10271
|
access: { mode: "fixed", level: "read" },
|
|
9678
10272
|
asyncMode: "sync",
|
|
@@ -9688,6 +10282,27 @@ function createSkillModule() {
|
|
|
9688
10282
|
return { agent_id: agentId, ...kind ? { kind } : {}, total: skills.length, skills };
|
|
9689
10283
|
}
|
|
9690
10284
|
},
|
|
10285
|
+
{
|
|
10286
|
+
verb: "status",
|
|
10287
|
+
summary: "The commands each cmd skill relies on, on a runtime of the Agent, and the extension package that would bring what is missing",
|
|
10288
|
+
options: [
|
|
10289
|
+
AGENT_OPTION,
|
|
10290
|
+
{ name: "runtime", property: "runtime_id", description: "Runtime id (default: the private runtime)", type: "string" }
|
|
10291
|
+
],
|
|
10292
|
+
inputSchema: {
|
|
10293
|
+
type: "object",
|
|
10294
|
+
properties: { agent_id: { type: "string", minLength: 1 }, runtime_id: { type: "string", minLength: 1 } },
|
|
10295
|
+
required: ["agent_id"],
|
|
10296
|
+
additionalProperties: false
|
|
10297
|
+
},
|
|
10298
|
+
outputSchema: OBJECT_OUTPUT$7,
|
|
10299
|
+
resultSchemaVersion: 1,
|
|
10300
|
+
access: { mode: "fixed", level: "read" },
|
|
10301
|
+
asyncMode: "sync",
|
|
10302
|
+
requiresSession: true,
|
|
10303
|
+
examples: ["buckyos skill status --agent jarvis.example.zone --runtime host"],
|
|
10304
|
+
handler: async (ctx, input) => await callService(ctx, agentIdFrom(input), "skills.status", { runtime_id: input.runtime_id ?? null })
|
|
10305
|
+
},
|
|
9691
10306
|
{
|
|
9692
10307
|
verb: "install",
|
|
9693
10308
|
summary: "Install the skills of a skill PIKG into an Agent",
|
|
@@ -9711,7 +10326,7 @@ function createSkillModule() {
|
|
|
9711
10326
|
required: ["pikg_path", "agent_id"],
|
|
9712
10327
|
additionalProperties: false
|
|
9713
10328
|
},
|
|
9714
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10329
|
+
outputSchema: OBJECT_OUTPUT$7,
|
|
9715
10330
|
resultSchemaVersion: 1,
|
|
9716
10331
|
access: { mode: "fixed", level: "write" },
|
|
9717
10332
|
asyncMode: "sync",
|
|
@@ -9738,7 +10353,7 @@ function createSkillModule() {
|
|
|
9738
10353
|
required: ["name", "agent_id"],
|
|
9739
10354
|
additionalProperties: false
|
|
9740
10355
|
},
|
|
9741
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10356
|
+
outputSchema: OBJECT_OUTPUT$7,
|
|
9742
10357
|
resultSchemaVersion: 1,
|
|
9743
10358
|
access: { mode: "fixed", level: "destructive" },
|
|
9744
10359
|
asyncMode: "sync",
|
|
@@ -9779,21 +10394,24 @@ async function installSkills(ctx, input) {
|
|
|
9779
10394
|
}
|
|
9780
10395
|
files[entry.path] = { content: base64(entry.bytes), executable: entry.executable };
|
|
9781
10396
|
}
|
|
10397
|
+
const skillPackage = {
|
|
10398
|
+
package: inspection.app.name,
|
|
10399
|
+
version: inspection.app.version,
|
|
10400
|
+
pikg_digest: inspection.pikg_digest,
|
|
10401
|
+
files
|
|
10402
|
+
};
|
|
9782
10403
|
const result = await callService(ctx, agentId, "skills.install", {
|
|
9783
|
-
package:
|
|
9784
|
-
package: inspection.app.name,
|
|
9785
|
-
version: inspection.app.version,
|
|
9786
|
-
pikg_digest: inspection.pikg_digest,
|
|
9787
|
-
files
|
|
9788
|
-
},
|
|
10404
|
+
package: skillPackage,
|
|
9789
10405
|
replace: input.replace === true
|
|
9790
10406
|
});
|
|
10407
|
+
const commands = await callService(ctx, agentId, "skills.install_plan", { package: skillPackage }).catch(() => null);
|
|
9791
10408
|
return {
|
|
9792
10409
|
agent_id: agentId,
|
|
9793
10410
|
pikg_path: inspection.pikg_path,
|
|
9794
10411
|
pikg_digest: inspection.pikg_digest,
|
|
9795
10412
|
...expectObject(result, "skills.install"),
|
|
9796
|
-
...ignored.length ? { ignored_files: ignored } : {}
|
|
10413
|
+
...ignored.length ? { ignored_files: ignored } : {},
|
|
10414
|
+
...commands ? { commands } : {}
|
|
9797
10415
|
};
|
|
9798
10416
|
}
|
|
9799
10417
|
async function removeSkill(ctx, input) {
|
|
@@ -9859,7 +10477,7 @@ function base64(bytes) {
|
|
|
9859
10477
|
return btoa(binary);
|
|
9860
10478
|
}
|
|
9861
10479
|
const CONTROL_PANEL = "control-panel";
|
|
9862
|
-
const OBJECT_OUTPUT$
|
|
10480
|
+
const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
|
|
9863
10481
|
const AGENT_POSITIONAL = {
|
|
9864
10482
|
name: "agent_id",
|
|
9865
10483
|
description: "Agent ID as `agent list` prints it (raw host name, e.g. jarvis.example.zone)"
|
|
@@ -9883,7 +10501,7 @@ function createAgentModule() {
|
|
|
9883
10501
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
9884
10502
|
outputSchema: {
|
|
9885
10503
|
type: "object",
|
|
9886
|
-
properties: { agents: { type: "array", items: OBJECT_OUTPUT$
|
|
10504
|
+
properties: { agents: { type: "array", items: OBJECT_OUTPUT$6 } },
|
|
9887
10505
|
required: ["agents"],
|
|
9888
10506
|
additionalProperties: false
|
|
9889
10507
|
},
|
|
@@ -9909,7 +10527,7 @@ function createAgentModule() {
|
|
|
9909
10527
|
summary: "Get one Agent: profile, settings, install state, template, and runtime",
|
|
9910
10528
|
positionals: [AGENT_POSITIONAL],
|
|
9911
10529
|
inputSchema: AGENT_INPUT,
|
|
9912
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10530
|
+
outputSchema: OBJECT_OUTPUT$6,
|
|
9913
10531
|
resultSchemaVersion: 1,
|
|
9914
10532
|
access: { mode: "fixed", level: "read" },
|
|
9915
10533
|
asyncMode: "sync",
|
|
@@ -9922,7 +10540,7 @@ function createAgentModule() {
|
|
|
9922
10540
|
summary: "Get the public profile (display name, bio, avatar) of an Agent",
|
|
9923
10541
|
positionals: [AGENT_POSITIONAL],
|
|
9924
10542
|
inputSchema: AGENT_INPUT,
|
|
9925
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10543
|
+
outputSchema: OBJECT_OUTPUT$6,
|
|
9926
10544
|
resultSchemaVersion: 1,
|
|
9927
10545
|
access: { mode: "fixed", level: "read" },
|
|
9928
10546
|
asyncMode: "sync",
|
|
@@ -9963,8 +10581,8 @@ function createAgentModule() {
|
|
|
9963
10581
|
type: "object",
|
|
9964
10582
|
properties: {
|
|
9965
10583
|
agent_id: { type: "string" },
|
|
9966
|
-
before: OBJECT_OUTPUT$
|
|
9967
|
-
profile: OBJECT_OUTPUT$
|
|
10584
|
+
before: OBJECT_OUTPUT$6,
|
|
10585
|
+
profile: OBJECT_OUTPUT$6
|
|
9968
10586
|
},
|
|
9969
10587
|
required: ["agent_id", "before", "profile"],
|
|
9970
10588
|
additionalProperties: false
|
|
@@ -10009,7 +10627,7 @@ async function callAgent(ctx, method, params) {
|
|
|
10009
10627
|
}
|
|
10010
10628
|
}
|
|
10011
10629
|
const AICC = "aicc";
|
|
10012
|
-
const OBJECT_OUTPUT$
|
|
10630
|
+
const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
|
|
10013
10631
|
const EMPTY_INPUT = { type: "object", properties: {}, additionalProperties: false };
|
|
10014
10632
|
const RANGES = ["last1d", "last7d", "last30d"];
|
|
10015
10633
|
const GROUPS = [
|
|
@@ -10057,7 +10675,7 @@ function quotaCommand() {
|
|
|
10057
10675
|
properties: { app: { type: "string", minLength: 1 } },
|
|
10058
10676
|
additionalProperties: false
|
|
10059
10677
|
},
|
|
10060
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10678
|
+
outputSchema: OBJECT_OUTPUT$5,
|
|
10061
10679
|
resultSchemaVersion: 1,
|
|
10062
10680
|
access: { mode: "fixed", level: "read" },
|
|
10063
10681
|
asyncMode: "sync",
|
|
@@ -10075,7 +10693,7 @@ function readCommand$2(options) {
|
|
|
10075
10693
|
summary: options.summary,
|
|
10076
10694
|
description: options.description,
|
|
10077
10695
|
inputSchema: EMPTY_INPUT,
|
|
10078
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10696
|
+
outputSchema: OBJECT_OUTPUT$5,
|
|
10079
10697
|
resultSchemaVersion: 1,
|
|
10080
10698
|
access: { mode: "fixed", level: "read" },
|
|
10081
10699
|
asyncMode: "sync",
|
|
@@ -10127,7 +10745,7 @@ function usageCommand() {
|
|
|
10127
10745
|
},
|
|
10128
10746
|
additionalProperties: false
|
|
10129
10747
|
},
|
|
10130
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10748
|
+
outputSchema: OBJECT_OUTPUT$5,
|
|
10131
10749
|
resultSchemaVersion: 1,
|
|
10132
10750
|
access: { mode: "fixed", level: "read" },
|
|
10133
10751
|
asyncMode: "sync",
|
|
@@ -10172,7 +10790,7 @@ function timeRange(input) {
|
|
|
10172
10790
|
}
|
|
10173
10791
|
return { kind: "explicit", start_time_ms: since, end_time_ms: until ?? Date.now() };
|
|
10174
10792
|
}
|
|
10175
|
-
const OBJECT_OUTPUT$
|
|
10793
|
+
const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
|
|
10176
10794
|
const DAY_MS$1 = 864e5;
|
|
10177
10795
|
const EXPIRES_HELP = "1d, 7d (default), 30d, none, or an RFC 3339 time";
|
|
10178
10796
|
function createShareModule() {
|
|
@@ -10283,7 +10901,7 @@ function createCommand() {
|
|
|
10283
10901
|
required: ["path"],
|
|
10284
10902
|
additionalProperties: false
|
|
10285
10903
|
},
|
|
10286
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10904
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10287
10905
|
resultSchemaVersion: 1,
|
|
10288
10906
|
access: { mode: "fixed", level: "write" },
|
|
10289
10907
|
asyncMode: "either",
|
|
@@ -10352,7 +10970,7 @@ function listCommand() {
|
|
|
10352
10970
|
},
|
|
10353
10971
|
additionalProperties: false
|
|
10354
10972
|
},
|
|
10355
|
-
outputSchema: OBJECT_OUTPUT$
|
|
10973
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10356
10974
|
resultSchemaVersion: 1,
|
|
10357
10975
|
access: { mode: "fixed", level: "read" },
|
|
10358
10976
|
asyncMode: "sync",
|
|
@@ -10384,7 +11002,7 @@ function getCommand$1() {
|
|
|
10384
11002
|
required: ["share_id"],
|
|
10385
11003
|
additionalProperties: false
|
|
10386
11004
|
},
|
|
10387
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11005
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10388
11006
|
resultSchemaVersion: 1,
|
|
10389
11007
|
access: { mode: "fixed", level: "read" },
|
|
10390
11008
|
asyncMode: "sync",
|
|
@@ -10421,7 +11039,7 @@ function updateCommand() {
|
|
|
10421
11039
|
required: ["share_id"],
|
|
10422
11040
|
additionalProperties: false
|
|
10423
11041
|
},
|
|
10424
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11042
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10425
11043
|
resultSchemaVersion: 1,
|
|
10426
11044
|
access: { mode: "fixed", level: "write" },
|
|
10427
11045
|
asyncMode: "sync",
|
|
@@ -10465,7 +11083,7 @@ function stopCommand() {
|
|
|
10465
11083
|
required: ["share_id"],
|
|
10466
11084
|
additionalProperties: false
|
|
10467
11085
|
},
|
|
10468
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11086
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10469
11087
|
resultSchemaVersion: 1,
|
|
10470
11088
|
access: { mode: "fixed", level: "destructive" },
|
|
10471
11089
|
asyncMode: "sync",
|
|
@@ -10497,7 +11115,7 @@ function statsCommand() {
|
|
|
10497
11115
|
},
|
|
10498
11116
|
additionalProperties: false
|
|
10499
11117
|
},
|
|
10500
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11118
|
+
outputSchema: OBJECT_OUTPUT$4,
|
|
10501
11119
|
resultSchemaVersion: 1,
|
|
10502
11120
|
access: { mode: "fixed", level: "read" },
|
|
10503
11121
|
asyncMode: "sync",
|
|
@@ -10516,7 +11134,7 @@ function statsCommand() {
|
|
|
10516
11134
|
}
|
|
10517
11135
|
};
|
|
10518
11136
|
}
|
|
10519
|
-
const OBJECT_OUTPUT$
|
|
11137
|
+
const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
|
|
10520
11138
|
const SERVICE$1 = "nfs-server";
|
|
10521
11139
|
const MAX_PUT_BYTES = 32 * 1024 * 1024;
|
|
10522
11140
|
const DAY_MS = 864e5;
|
|
@@ -10560,7 +11178,7 @@ function parseBucketTarget(value, keyRequired) {
|
|
|
10560
11178
|
throw new UsageError("INVALID_ARGUMENT", `'${value}' names no key`);
|
|
10561
11179
|
return { bucketId: parts.slice(0, 4).join("/"), key };
|
|
10562
11180
|
}
|
|
10563
|
-
async function call$
|
|
11181
|
+
async function call$2(ctx, method, params) {
|
|
10564
11182
|
try {
|
|
10565
11183
|
return await callService(ctx, SERVICE$1, method, params);
|
|
10566
11184
|
} catch (error) {
|
|
@@ -10621,7 +11239,7 @@ function lsCommand() {
|
|
|
10621
11239
|
},
|
|
10622
11240
|
additionalProperties: false
|
|
10623
11241
|
},
|
|
10624
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11242
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10625
11243
|
resultSchemaVersion: 1,
|
|
10626
11244
|
access: { mode: "fixed", level: "read" },
|
|
10627
11245
|
asyncMode: "sync",
|
|
@@ -10630,9 +11248,9 @@ function lsCommand() {
|
|
|
10630
11248
|
handler: async (ctx, input) => {
|
|
10631
11249
|
const raw = inputString(input, "target");
|
|
10632
11250
|
if (!raw)
|
|
10633
|
-
return { buckets: await call$
|
|
11251
|
+
return { buckets: await call$2(ctx, "bucket.list", { appid: inputString(input, "appid") }) };
|
|
10634
11252
|
const target = parseBucketTarget(raw, false);
|
|
10635
|
-
return await call$
|
|
11253
|
+
return await call$2(ctx, "bucket.list_objects", {
|
|
10636
11254
|
bucket_id: target.bucketId,
|
|
10637
11255
|
prefix: target.key,
|
|
10638
11256
|
delimiter: inputString(input, "delimiter"),
|
|
@@ -10654,7 +11272,7 @@ function statCommand() {
|
|
|
10654
11272
|
required: ["target"],
|
|
10655
11273
|
additionalProperties: false
|
|
10656
11274
|
},
|
|
10657
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11275
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10658
11276
|
resultSchemaVersion: 1,
|
|
10659
11277
|
access: { mode: "fixed", level: "read" },
|
|
10660
11278
|
asyncMode: "sync",
|
|
@@ -10664,12 +11282,12 @@ function statCommand() {
|
|
|
10664
11282
|
const target = parseBucketTarget(requiredInputString(input, "target"), false);
|
|
10665
11283
|
if (!target.key) {
|
|
10666
11284
|
const [bucket, quota] = await Promise.all([
|
|
10667
|
-
call$
|
|
10668
|
-
call$
|
|
11285
|
+
call$2(ctx, "bucket.stat", { bucket_id: target.bucketId }),
|
|
11286
|
+
call$2(ctx, "bucket.get_quota", { bucket_id: target.bucketId })
|
|
10669
11287
|
]);
|
|
10670
11288
|
return { bucket, quota };
|
|
10671
11289
|
}
|
|
10672
|
-
return await call$
|
|
11290
|
+
return await call$2(ctx, "bucket.head", { bucket_id: target.bucketId, key: target.key, version: input.version });
|
|
10673
11291
|
}
|
|
10674
11292
|
};
|
|
10675
11293
|
}
|
|
@@ -10695,7 +11313,7 @@ function putCommand() {
|
|
|
10695
11313
|
required: ["target", "file"],
|
|
10696
11314
|
additionalProperties: false
|
|
10697
11315
|
},
|
|
10698
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11316
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10699
11317
|
resultSchemaVersion: 1,
|
|
10700
11318
|
access: { mode: "fixed", level: "write" },
|
|
10701
11319
|
asyncMode: "sync",
|
|
@@ -10744,7 +11362,7 @@ function getCommand() {
|
|
|
10744
11362
|
required: ["target", "output"],
|
|
10745
11363
|
additionalProperties: false
|
|
10746
11364
|
},
|
|
10747
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11365
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10748
11366
|
resultSchemaVersion: 1,
|
|
10749
11367
|
access: { mode: "fixed", level: "read" },
|
|
10750
11368
|
asyncMode: "sync",
|
|
@@ -10782,7 +11400,7 @@ function rmCommand() {
|
|
|
10782
11400
|
required: ["target"],
|
|
10783
11401
|
additionalProperties: false
|
|
10784
11402
|
},
|
|
10785
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11403
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10786
11404
|
resultSchemaVersion: 1,
|
|
10787
11405
|
access: { mode: "fixed", level: "write" },
|
|
10788
11406
|
asyncMode: "sync",
|
|
@@ -10790,7 +11408,7 @@ function rmCommand() {
|
|
|
10790
11408
|
examples: ["buckyos bucket rm obj://bucket/user/photos/alice/library/2026/a.jpg"],
|
|
10791
11409
|
handler: async (ctx, input) => {
|
|
10792
11410
|
const target = parseBucketTarget(requiredInputString(input, "target"), true);
|
|
10793
|
-
return await call$
|
|
11411
|
+
return await call$2(ctx, "bucket.delete", { bucket_id: target.bucketId, key: target.key, version: input.version });
|
|
10794
11412
|
}
|
|
10795
11413
|
};
|
|
10796
11414
|
}
|
|
@@ -10813,7 +11431,7 @@ function linkCommand() {
|
|
|
10813
11431
|
required: ["target"],
|
|
10814
11432
|
additionalProperties: false
|
|
10815
11433
|
},
|
|
10816
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11434
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10817
11435
|
resultSchemaVersion: 1,
|
|
10818
11436
|
access: { mode: "fixed", level: "write" },
|
|
10819
11437
|
asyncMode: "sync",
|
|
@@ -10826,7 +11444,7 @@ function linkCommand() {
|
|
|
10826
11444
|
const expiresAt = days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
|
|
10827
11445
|
if (expiresAt === void 0)
|
|
10828
11446
|
throw new UsageError("INVALID_ARGUMENT", "expires is required");
|
|
10829
|
-
const issued = await call$
|
|
11447
|
+
const issued = await call$2(ctx, "bucket.create_access_token", {
|
|
10830
11448
|
bucket_id: target.bucketId,
|
|
10831
11449
|
key: target.key,
|
|
10832
11450
|
actions: ["read"],
|
|
@@ -10842,13 +11460,13 @@ function s3KeysCommand() {
|
|
|
10842
11460
|
verb: "s3-keys",
|
|
10843
11461
|
summary: "List your S3 access keys (secrets are shown only when created)",
|
|
10844
11462
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
10845
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11463
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10846
11464
|
resultSchemaVersion: 1,
|
|
10847
11465
|
access: { mode: "fixed", level: "read" },
|
|
10848
11466
|
asyncMode: "sync",
|
|
10849
11467
|
requiresSession: true,
|
|
10850
11468
|
examples: ["buckyos bucket s3-keys"],
|
|
10851
|
-
handler: async (ctx) => ({ keys: await call$
|
|
11469
|
+
handler: async (ctx) => ({ keys: await call$2(ctx, "bucket.list_s3_keys", {}) })
|
|
10852
11470
|
};
|
|
10853
11471
|
}
|
|
10854
11472
|
function s3KeyCreateCommand() {
|
|
@@ -10866,7 +11484,7 @@ function s3KeyCreateCommand() {
|
|
|
10866
11484
|
required: ["app"],
|
|
10867
11485
|
additionalProperties: false
|
|
10868
11486
|
},
|
|
10869
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11487
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10870
11488
|
resultSchemaVersion: 1,
|
|
10871
11489
|
access: { mode: "fixed", level: "write" },
|
|
10872
11490
|
asyncMode: "sync",
|
|
@@ -10877,7 +11495,7 @@ function s3KeyCreateCommand() {
|
|
|
10877
11495
|
const days = text2?.match(/^(\d+)d$/);
|
|
10878
11496
|
const expiresAt = !text2 ? void 0 : days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
|
|
10879
11497
|
const prefix = inputString(input, "prefix");
|
|
10880
|
-
const key = await call$
|
|
11498
|
+
const key = await call$2(ctx, "bucket.create_s3_key", {
|
|
10881
11499
|
appid: requiredInputString(input, "app"),
|
|
10882
11500
|
scope: prefix ? { prefix } : void 0,
|
|
10883
11501
|
expires_at: expiresAt
|
|
@@ -10897,16 +11515,16 @@ function s3KeyRevokeCommand() {
|
|
|
10897
11515
|
required: ["access_key_id"],
|
|
10898
11516
|
additionalProperties: false
|
|
10899
11517
|
},
|
|
10900
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11518
|
+
outputSchema: OBJECT_OUTPUT$3,
|
|
10901
11519
|
resultSchemaVersion: 1,
|
|
10902
11520
|
access: { mode: "fixed", level: "write" },
|
|
10903
11521
|
asyncMode: "sync",
|
|
10904
11522
|
requiresSession: true,
|
|
10905
11523
|
examples: ["buckyos bucket s3-key-revoke BKABCDEFGHIJKLMNOPQR"],
|
|
10906
|
-
handler: async (ctx, input) => await call$
|
|
11524
|
+
handler: async (ctx, input) => await call$2(ctx, "bucket.revoke_s3_key", { access_key_id: requiredInputString(input, "access_key_id") })
|
|
10907
11525
|
};
|
|
10908
11526
|
}
|
|
10909
|
-
const OBJECT_OUTPUT$
|
|
11527
|
+
const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
|
|
10910
11528
|
const URL_ARG = { name: "url", description: "obj:// cyfs:// file:// https:// url, or //<service>/... /abs/path shorthand", required: true };
|
|
10911
11529
|
function createObjModule() {
|
|
10912
11530
|
return {
|
|
@@ -10957,7 +11575,7 @@ function resolveCommand() {
|
|
|
10957
11575
|
summary: "Normalize a URL and show its identity, RBAC key, events and endpoint (no access check)",
|
|
10958
11576
|
positionals: [URL_ARG],
|
|
10959
11577
|
inputSchema: { type: "object", properties: { url: { type: "string", minLength: 1 } }, required: ["url"], additionalProperties: false },
|
|
10960
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11578
|
+
outputSchema: OBJECT_OUTPUT$2,
|
|
10961
11579
|
resultSchemaVersion: 1,
|
|
10962
11580
|
access: { mode: "fixed", level: "read" },
|
|
10963
11581
|
asyncMode: "sync",
|
|
@@ -10994,7 +11612,7 @@ function readCommand$1() {
|
|
|
10994
11612
|
required: ["url"],
|
|
10995
11613
|
additionalProperties: false
|
|
10996
11614
|
},
|
|
10997
|
-
outputSchema: OBJECT_OUTPUT$
|
|
11615
|
+
outputSchema: OBJECT_OUTPUT$2,
|
|
10998
11616
|
resultSchemaVersion: 1,
|
|
10999
11617
|
access: { mode: "fixed", level: "read" },
|
|
11000
11618
|
asyncMode: "sync",
|
|
@@ -11046,7 +11664,7 @@ const targetProperties = {
|
|
|
11046
11664
|
store_id: text,
|
|
11047
11665
|
locator: text
|
|
11048
11666
|
};
|
|
11049
|
-
function call(ctx, method, params) {
|
|
11667
|
+
function call$1(ctx, method, params) {
|
|
11050
11668
|
return ctx.clients.call("control-panel", method, params, {
|
|
11051
11669
|
traceId: ctx.traceId,
|
|
11052
11670
|
signal: ctx.signal,
|
|
@@ -11070,7 +11688,7 @@ function management(verb, method, properties, required, write = false) {
|
|
|
11070
11688
|
type: schema.type === "integer" ? "integer" : "string",
|
|
11071
11689
|
required: required.includes(name)
|
|
11072
11690
|
})),
|
|
11073
|
-
handler: (ctx, input) => call(ctx, method, input)
|
|
11691
|
+
handler: (ctx, input) => call$1(ctx, method, input)
|
|
11074
11692
|
};
|
|
11075
11693
|
}
|
|
11076
11694
|
function createExecutorModule() {
|
|
@@ -11126,7 +11744,7 @@ function operation(verb, extra, required) {
|
|
|
11126
11744
|
if (!ctx.session)
|
|
11127
11745
|
throw new ToolError("AUTH_REQUIRED", "An authenticated App session is required");
|
|
11128
11746
|
const { token } = await ctx.session.ensureValid();
|
|
11129
|
-
const route = await call(ctx, "executor.stream.open", { executor_id: target.executor_id, generation: target.generation, profile_id: target.profile_id });
|
|
11747
|
+
const route = await call$1(ctx, "executor.stream.open", { executor_id: target.executor_id, generation: target.generation, profile_id: target.profile_id });
|
|
11130
11748
|
const stream = await ExecutorCommandStream.connect(route, target, token, "buckyos-cli", locator.run_id);
|
|
11131
11749
|
if (!stream)
|
|
11132
11750
|
throw new ToolError("INVALID_SERVICE_RESPONSE", "Executor stream did not initialize");
|
|
@@ -11154,6 +11772,80 @@ function operation(verb, extra, required) {
|
|
|
11154
11772
|
}
|
|
11155
11773
|
};
|
|
11156
11774
|
}
|
|
11775
|
+
const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
|
|
11776
|
+
const ID = { type: "string", minLength: 1 };
|
|
11777
|
+
function call(ctx, method, params) {
|
|
11778
|
+
return ctx.clients.call("control-panel", method, params, {
|
|
11779
|
+
traceId: ctx.traceId,
|
|
11780
|
+
signal: ctx.signal,
|
|
11781
|
+
timeoutMs: Math.max(1, (ctx.deadline ?? Date.now() + 6e4) - Date.now())
|
|
11782
|
+
});
|
|
11783
|
+
}
|
|
11784
|
+
function requestOf(input, enabled) {
|
|
11785
|
+
const id = typeof input.id === "string" ? input.id : "";
|
|
11786
|
+
if (!id)
|
|
11787
|
+
throw new UsageError("MISSING_ARGUMENT", "a package id is required");
|
|
11788
|
+
return { id, enabled, ...typeof input.version === "string" ? { version: input.version } : {} };
|
|
11789
|
+
}
|
|
11790
|
+
function read(verb, summary2, method) {
|
|
11791
|
+
return {
|
|
11792
|
+
verb,
|
|
11793
|
+
summary: summary2,
|
|
11794
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
11795
|
+
outputSchema: OBJECT_OUTPUT$1,
|
|
11796
|
+
resultSchemaVersion: 1,
|
|
11797
|
+
access: { mode: "fixed", level: "read" },
|
|
11798
|
+
asyncMode: "sync",
|
|
11799
|
+
requiresSession: true,
|
|
11800
|
+
handler: (ctx) => call(ctx, method, {})
|
|
11801
|
+
};
|
|
11802
|
+
}
|
|
11803
|
+
function desired(verb, summary2, enabled) {
|
|
11804
|
+
const properties = { id: ID, ...enabled ? { version: { type: "string", minLength: 1 } } : {}, dry_run: { type: "boolean" } };
|
|
11805
|
+
return {
|
|
11806
|
+
verb,
|
|
11807
|
+
summary: summary2,
|
|
11808
|
+
positionals: [{ name: "id", description: "Package id, e.g. ext-core" }],
|
|
11809
|
+
options: [
|
|
11810
|
+
...enabled ? [{ name: "version", description: "A published version; the newest without it", type: "string" }] : [],
|
|
11811
|
+
{ name: "dry-run", property: "dry_run", description: "Only show what would change", type: "boolean" }
|
|
11812
|
+
],
|
|
11813
|
+
inputSchema: { type: "object", properties, required: ["id"], additionalProperties: false },
|
|
11814
|
+
outputSchema: OBJECT_OUTPUT$1,
|
|
11815
|
+
resultSchemaVersion: 1,
|
|
11816
|
+
access: { mode: "fixed", level: "write" },
|
|
11817
|
+
asyncMode: "sync",
|
|
11818
|
+
requiresSession: true,
|
|
11819
|
+
handler: (ctx, input) => call(ctx, input.dry_run === true ? "ext_tools.plan" : "ext_tools.set_desired", requestOf(input, enabled))
|
|
11820
|
+
};
|
|
11821
|
+
}
|
|
11822
|
+
function createExtToolsModule() {
|
|
11823
|
+
return {
|
|
11824
|
+
name: "ext-tools",
|
|
11825
|
+
summary: "Manage the extension tool packages every Agent of the Zone shares",
|
|
11826
|
+
commands: [
|
|
11827
|
+
read("list", "The packages published in the Repo, and what each provides", "ext_tools.catalog"),
|
|
11828
|
+
read("status", "Package by node: what is asked for and where each node got to", "ext_tools.status"),
|
|
11829
|
+
desired("enable", "Enable or upgrade a package, with the packages it requires", true),
|
|
11830
|
+
desired("disable", "Disable a package; refused while an enabled package requires it", false),
|
|
11831
|
+
{
|
|
11832
|
+
verb: "import",
|
|
11833
|
+
summary: "Put an already built .pikg (an official release asset) into the Repo unchanged",
|
|
11834
|
+
positionals: [{ name: "pikg", description: "Local .pikg file" }],
|
|
11835
|
+
inputSchema: { type: "object", properties: { pikg: { type: "string", minLength: 1 } }, required: ["pikg"], additionalProperties: false },
|
|
11836
|
+
outputSchema: OBJECT_OUTPUT$1,
|
|
11837
|
+
resultSchemaVersion: 1,
|
|
11838
|
+
access: { mode: "fixed", level: "write" },
|
|
11839
|
+
asyncMode: "sync",
|
|
11840
|
+
requiresSession: true,
|
|
11841
|
+
handler: async (ctx, input) => {
|
|
11842
|
+
const staging = await stageLocalPikg(ctx, String(input.pikg));
|
|
11843
|
+
return await call(ctx, "ext_tools.import", { handle: staging.handle });
|
|
11844
|
+
}
|
|
11845
|
+
}
|
|
11846
|
+
]
|
|
11847
|
+
};
|
|
11848
|
+
}
|
|
11157
11849
|
const SERVICE = "aiworkspace";
|
|
11158
11850
|
const OBJECT_OUTPUT = { type: "object", additionalProperties: true };
|
|
11159
11851
|
const WORKSPACE_OPTION = { name: "workspace", property: "workspace_id", description: "Workspace id (ws_…)", type: "string", required: true };
|
|
@@ -12542,6 +13234,7 @@ function createRegistry(pikgDependencies, appDependencies, logDependencies, diag
|
|
|
12542
13234
|
registry.register(createBucketModule());
|
|
12543
13235
|
registry.register(createObjModule());
|
|
12544
13236
|
registry.register(createExecutorModule());
|
|
13237
|
+
registry.register(createExtToolsModule());
|
|
12545
13238
|
registry.register(createAiwsModule());
|
|
12546
13239
|
return registry;
|
|
12547
13240
|
}
|