buckyos 0.7.138 → 0.7.140

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.
Files changed (73) hide show
  1. package/cli/core/app.ts +4 -0
  2. package/cli/dist/cli.mjs +545 -124
  3. package/cli/dist/cli.mjs.map +1 -1
  4. package/cli/modules/aiws.ts +294 -0
  5. package/cli/modules/executor.ts +98 -0
  6. package/cli/version.ts +1 -1
  7. package/dist/aiworkspace_client.d.ts +91 -0
  8. package/dist/aiworkspace_client.d.ts.map +1 -0
  9. package/dist/app-frame.cjs +1 -1
  10. package/dist/app-frame.cjs.map +1 -1
  11. package/dist/app-frame.d.ts +103 -3
  12. package/dist/app-frame.d.ts.map +1 -1
  13. package/dist/app-frame.mjs +189 -8
  14. package/dist/app-frame.mjs.map +1 -1
  15. package/dist/browser.cjs +1 -1
  16. package/dist/browser.cjs.map +1 -1
  17. package/dist/browser.d.ts +2 -0
  18. package/dist/browser.d.ts.map +1 -1
  19. package/dist/browser.mjs +7 -3
  20. package/dist/browser.mjs.map +1 -1
  21. package/dist/content.cjs +1 -1
  22. package/dist/content.cjs.map +1 -1
  23. package/dist/content.d.ts +18 -0
  24. package/dist/content.d.ts.map +1 -1
  25. package/dist/content.mjs +61 -1
  26. package/dist/content.mjs.map +1 -1
  27. package/dist/executor_client-978a8e1b.js +13 -0
  28. package/dist/executor_client-978a8e1b.js.map +1 -0
  29. package/dist/{ndm_proxy-6b03b9ec.mjs → executor_client-d2c9e854.mjs} +848 -247
  30. package/dist/executor_client-d2c9e854.mjs.map +1 -0
  31. package/dist/executor_client.d.ts +138 -0
  32. package/dist/executor_client.d.ts.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +4 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.mjs +12 -3
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/internal/hash_worker.d.ts +2 -1
  40. package/dist/internal/hash_worker.d.ts.map +1 -1
  41. package/dist/internal/tus_client.d.ts +3 -0
  42. package/dist/internal/tus_client.d.ts.map +1 -1
  43. package/dist/ndm_client.d.ts +56 -7
  44. package/dist/ndm_client.d.ts.map +1 -1
  45. package/dist/{ndn_types-ac9c1e48.mjs → ndn_types-dcb74613.mjs} +3 -3
  46. package/dist/{ndn_types-ac9c1e48.mjs.map → ndn_types-dcb74613.mjs.map} +1 -1
  47. package/dist/nfsp.cjs +1 -1
  48. package/dist/nfsp.cjs.map +1 -1
  49. package/dist/nfsp.d.ts +16 -0
  50. package/dist/nfsp.d.ts.map +1 -1
  51. package/dist/nfsp.mjs +6 -0
  52. package/dist/nfsp.mjs.map +1 -1
  53. package/dist/node.cjs +1 -1
  54. package/dist/node.cjs.map +1 -1
  55. package/dist/node.d.ts +2 -0
  56. package/dist/node.d.ts.map +1 -1
  57. package/dist/node.mjs +7 -3
  58. package/dist/node.mjs.map +1 -1
  59. package/dist/provision.mjs +1 -1
  60. package/dist/runtime.d.ts +2 -0
  61. package/dist/runtime.d.ts.map +1 -1
  62. package/dist/sdk_core.d.ts +4 -0
  63. package/dist/sdk_core.d.ts.map +1 -1
  64. package/dist/{tus_client-19baa342.mjs → tus_client-8fd4d937.mjs} +40 -2
  65. package/dist/tus_client-8fd4d937.mjs.map +1 -0
  66. package/dist/{tus_client-2b915a81.js → tus_client-a2f73d53.js} +4 -4
  67. package/dist/tus_client-a2f73d53.js.map +1 -0
  68. package/package.json +1 -1
  69. package/dist/ndm_proxy-67651066.js +0 -13
  70. package/dist/ndm_proxy-67651066.js.map +0 -1
  71. package/dist/ndm_proxy-6b03b9ec.mjs.map +0 -1
  72. package/dist/tus_client-19baa342.mjs.map +0 -1
  73. package/dist/tus_client-2b915a81.js.map +0 -1
package/cli/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import process from "node:process";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import * as nodePath from "node:path";
4
4
  import { resolve as resolve$5, dirname as dirname$3 } from "node:path";
5
- import { BuckyOSSDK, RuntimeType, buckyos, namelib, VerifyHubClient, createAppInstanceId, parseSessionTokenClaims, ndn, ndm_proxy } from "buckyos/node";
5
+ import { BuckyOSSDK, RuntimeType, buckyos, namelib, VerifyHubClient, createAppInstanceId, parseSessionTokenClaims, ndn, ndm_proxy, ExecutorCommandStream } from "buckyos/node";
6
6
  import * as provisionSdk from "buckyos/provision";
7
7
  import { createHash } from "node:crypto";
8
8
  import { readFile, writeFile, readdir, stat, lstat, realpath, mkdtemp, rename, rm, mkdir, chmod, symlink, copyFile, open } from "node:fs/promises";
@@ -345,20 +345,20 @@ function validateSchema(value, schema, path) {
345
345
  if (!value || typeof value !== "object" || Array.isArray(value)) {
346
346
  throw new UsageError("SCHEMA_VALIDATION_FAILED", `${path} must be an object`);
347
347
  }
348
- const object = value;
348
+ const object2 = value;
349
349
  for (const required of schema.required ?? []) {
350
- if (!Object.hasOwn(object, required)) {
350
+ if (!Object.hasOwn(object2, required)) {
351
351
  throw new UsageError("SCHEMA_VALIDATION_FAILED", `${path}.${required} is required`);
352
352
  }
353
353
  }
354
354
  if (schema.additionalProperties === false) {
355
- for (const key of Object.keys(object)) {
355
+ for (const key of Object.keys(object2)) {
356
356
  if (!Object.hasOwn(schema.properties ?? {}, key)) {
357
357
  throw new UsageError("SCHEMA_VALIDATION_FAILED", `${path}.${key} is not allowed`);
358
358
  }
359
359
  }
360
360
  }
361
- for (const [key, propertyValue] of Object.entries(object)) {
361
+ for (const [key, propertyValue] of Object.entries(object2)) {
362
362
  const propertySchema = schema.properties?.[key];
363
363
  if (propertySchema)
364
364
  validateSchema(propertyValue, propertySchema, `${path}.${key}`);
@@ -2057,11 +2057,11 @@ function renderText(data) {
2057
2057
  if (typeof data === "string")
2058
2058
  return data;
2059
2059
  if (data && typeof data === "object" && !Array.isArray(data)) {
2060
- const object = data;
2061
- if (typeof object.script === "string")
2062
- return object.script;
2063
- if (typeof object.text === "string")
2064
- return object.text;
2060
+ const object2 = data;
2061
+ if (typeof object2.script === "string")
2062
+ return object2.script;
2063
+ if (typeof object2.text === "string")
2064
+ return object2.text;
2065
2065
  }
2066
2066
  return JSON.stringify(data, null, 2);
2067
2067
  }
@@ -2069,11 +2069,11 @@ function renderTable(data) {
2069
2069
  if (Array.isArray(data))
2070
2070
  return renderRows(data);
2071
2071
  if (data && typeof data === "object") {
2072
- const object = data;
2073
- const arrayEntry = Object.entries(object).find(([, value]) => Array.isArray(value));
2072
+ const object2 = data;
2073
+ const arrayEntry = Object.entries(object2).find(([, value]) => Array.isArray(value));
2074
2074
  if (arrayEntry)
2075
2075
  return renderRows(arrayEntry[1]);
2076
- const rows = Object.entries(object).map(([key, value]) => ({ key, value: displayValue(value) }));
2076
+ const rows = Object.entries(object2).map(([key, value]) => ({ key, value: displayValue(value) }));
2077
2077
  return renderRows(rows);
2078
2078
  }
2079
2079
  return String(data ?? "");
@@ -2499,7 +2499,7 @@ function replPrompt(config) {
2499
2499
  return `buckyos[${profile}|${zone}|${identity}]> `;
2500
2500
  }
2501
2501
  const EMPTY_INPUT$3 = { type: "object", properties: {}, additionalProperties: false };
2502
- const OBJECT_OUTPUT$c = { type: "object", additionalProperties: true };
2502
+ const OBJECT_OUTPUT$d = { type: "object", additionalProperties: true };
2503
2503
  function createAuthModule() {
2504
2504
  return {
2505
2505
  name: "auth",
@@ -2509,7 +2509,7 @@ function createAuthModule() {
2509
2509
  verb: "whoami",
2510
2510
  summary: "Show the effective principal and application identity",
2511
2511
  inputSchema: EMPTY_INPUT$3,
2512
- outputSchema: OBJECT_OUTPUT$c,
2512
+ outputSchema: OBJECT_OUTPUT$d,
2513
2513
  resultSchemaVersion: 1,
2514
2514
  access: { mode: "fixed", level: "read" },
2515
2515
  asyncMode: "sync",
@@ -2527,7 +2527,7 @@ function createAuthModule() {
2527
2527
  verb: "session-status",
2528
2528
  summary: "Show the in-memory session state without exposing credentials",
2529
2529
  inputSchema: EMPTY_INPUT$3,
2530
- outputSchema: OBJECT_OUTPUT$c,
2530
+ outputSchema: OBJECT_OUTPUT$d,
2531
2531
  resultSchemaVersion: 1,
2532
2532
  access: { mode: "fixed", level: "read" },
2533
2533
  asyncMode: "sync",
@@ -2548,7 +2548,7 @@ const EMPTY_INPUT$2 = {
2548
2548
  properties: {},
2549
2549
  additionalProperties: false
2550
2550
  };
2551
- const OBJECT_OUTPUT$b = { type: "object", additionalProperties: true };
2551
+ const OBJECT_OUTPUT$c = { type: "object", additionalProperties: true };
2552
2552
  function createCoreModules(registry) {
2553
2553
  return [createCommandModule(registry), createConfigModule(), createCompletionModule(registry)];
2554
2554
  }
@@ -2561,7 +2561,7 @@ function createCommandModule(registry) {
2561
2561
  verb: "list",
2562
2562
  summary: "List registered modules and commands",
2563
2563
  inputSchema: EMPTY_INPUT$2,
2564
- outputSchema: OBJECT_OUTPUT$b,
2564
+ outputSchema: OBJECT_OUTPUT$c,
2565
2565
  resultSchemaVersion: 1,
2566
2566
  access: { mode: "fixed", level: "read" },
2567
2567
  asyncMode: "sync",
@@ -2594,7 +2594,7 @@ function createCommandModule(registry) {
2594
2594
  required: ["target_module", "target_verb"],
2595
2595
  additionalProperties: false
2596
2596
  },
2597
- outputSchema: OBJECT_OUTPUT$b,
2597
+ outputSchema: OBJECT_OUTPUT$c,
2598
2598
  resultSchemaVersion: 1,
2599
2599
  access: { mode: "fixed", level: "read" },
2600
2600
  asyncMode: "sync",
@@ -2616,7 +2616,7 @@ function createConfigModule() {
2616
2616
  verb: "list",
2617
2617
  summary: "List the global configuration and available profiles",
2618
2618
  inputSchema: EMPTY_INPUT$2,
2619
- outputSchema: OBJECT_OUTPUT$b,
2619
+ outputSchema: OBJECT_OUTPUT$c,
2620
2620
  resultSchemaVersion: 1,
2621
2621
  access: { mode: "fixed", level: "read" },
2622
2622
  asyncMode: "sync",
@@ -2647,7 +2647,7 @@ function createConfigModule() {
2647
2647
  },
2648
2648
  additionalProperties: false
2649
2649
  },
2650
- outputSchema: OBJECT_OUTPUT$b,
2650
+ outputSchema: OBJECT_OUTPUT$c,
2651
2651
  resultSchemaVersion: 1,
2652
2652
  access: { mode: "fixed", level: "read" },
2653
2653
  asyncMode: "sync",
@@ -2693,7 +2693,7 @@ function createConfigModule() {
2693
2693
  required: ["key", "value"],
2694
2694
  additionalProperties: false
2695
2695
  },
2696
- outputSchema: OBJECT_OUTPUT$b,
2696
+ outputSchema: OBJECT_OUTPUT$c,
2697
2697
  resultSchemaVersion: 1,
2698
2698
  access: { mode: "fixed", level: "write" },
2699
2699
  asyncMode: "sync",
@@ -2733,7 +2733,7 @@ function createConfigModule() {
2733
2733
  required: ["profile_name"],
2734
2734
  additionalProperties: false
2735
2735
  },
2736
- outputSchema: OBJECT_OUTPUT$b,
2736
+ outputSchema: OBJECT_OUTPUT$c,
2737
2737
  resultSchemaVersion: 1,
2738
2738
  access: { mode: "fixed", level: "write" },
2739
2739
  asyncMode: "sync",
@@ -2765,7 +2765,7 @@ function createConfigModule() {
2765
2765
  properties: { effective: { type: "boolean" } },
2766
2766
  additionalProperties: false
2767
2767
  },
2768
- outputSchema: OBJECT_OUTPUT$b,
2768
+ outputSchema: OBJECT_OUTPUT$c,
2769
2769
  resultSchemaVersion: 1,
2770
2770
  access: { mode: "fixed", level: "read" },
2771
2771
  asyncMode: "sync",
@@ -3007,7 +3007,7 @@ async function buckyosInfo(ctx) {
3007
3007
  );
3008
3008
  }
3009
3009
  const SERVICE_NAME = "system_config";
3010
- const OBJECT_OUTPUT$a = { type: "object", additionalProperties: false };
3010
+ const OBJECT_OUTPUT$b = { type: "object", additionalProperties: false };
3011
3011
  const KEY_INPUT = {
3012
3012
  type: "object",
3013
3013
  properties: { key: { type: "string", minLength: 1 } },
@@ -3025,7 +3025,7 @@ function createSystemConfigModule() {
3025
3025
  positionals: [{ name: "key", description: "System-config key" }],
3026
3026
  inputSchema: KEY_INPUT,
3027
3027
  outputSchema: {
3028
- ...OBJECT_OUTPUT$a,
3028
+ ...OBJECT_OUTPUT$b,
3029
3029
  properties: {
3030
3030
  key: { type: "string" },
3031
3031
  value: { type: "string" },
@@ -3068,7 +3068,7 @@ function createSystemConfigModule() {
3068
3068
  additionalProperties: false
3069
3069
  },
3070
3070
  outputSchema: {
3071
- ...OBJECT_OUTPUT$a,
3071
+ ...OBJECT_OUTPUT$b,
3072
3072
  properties: {
3073
3073
  key: { type: "string" },
3074
3074
  items: { type: "array", items: { type: "string" } }
@@ -3122,7 +3122,7 @@ function setCommand() {
3122
3122
  additionalProperties: false
3123
3123
  },
3124
3124
  outputSchema: {
3125
- ...OBJECT_OUTPUT$a,
3125
+ ...OBJECT_OUTPUT$b,
3126
3126
  properties: { key: { type: "string" }, updated: { type: "boolean" } },
3127
3127
  required: ["key", "updated"]
3128
3128
  },
@@ -3161,7 +3161,7 @@ function setFileCommand() {
3161
3161
  additionalProperties: false
3162
3162
  },
3163
3163
  outputSchema: {
3164
- ...OBJECT_OUTPUT$a,
3164
+ ...OBJECT_OUTPUT$b,
3165
3165
  properties: { key: { type: "string" }, updated: { type: "boolean" } },
3166
3166
  required: ["key", "updated"]
3167
3167
  },
@@ -3198,7 +3198,7 @@ function mutationCommand(options) {
3198
3198
  additionalProperties: false
3199
3199
  },
3200
3200
  outputSchema: {
3201
- ...OBJECT_OUTPUT$a,
3201
+ ...OBJECT_OUTPUT$b,
3202
3202
  properties: {
3203
3203
  key: { type: "string" },
3204
3204
  [options.resultProperty]: { type: "boolean" }
@@ -3240,8 +3240,8 @@ async function readValueFile(path) {
3240
3240
  function isConfigValue(value) {
3241
3241
  if (!value || typeof value !== "object" || Array.isArray(value))
3242
3242
  return false;
3243
- const object = value;
3244
- return typeof object.value === "string" && Number.isSafeInteger(object.version) && Number(object.version) >= 0;
3243
+ const object2 = value;
3244
+ return typeof object2.value === "string" && Number.isSafeInteger(object2.version) && Number(object2.version) >= 0;
3245
3245
  }
3246
3246
  function invalidResponse$3(method) {
3247
3247
  throw new ToolError(
@@ -3333,7 +3333,7 @@ async function gzipFile(source, destination) {
3333
3333
  async function readTarGz(bytes, limit) {
3334
3334
  const tar = await gunzipBytes(bytes, limit);
3335
3335
  const decoder = new TextDecoder("utf-8", { fatal: true });
3336
- const text = (offset2, length) => decoder.decode(tar.subarray(offset2, offset2 + length)).replace(/\0.*$/s, "");
3336
+ const text2 = (offset2, length) => decoder.decode(tar.subarray(offset2, offset2 + length)).replace(/\0.*$/s, "");
3337
3337
  const files = [];
3338
3338
  const seen = /* @__PURE__ */ new Set();
3339
3339
  let offset = 0;
@@ -3342,10 +3342,10 @@ async function readTarGz(bytes, limit) {
3342
3342
  let size;
3343
3343
  let mode;
3344
3344
  try {
3345
- const prefix = text(offset + 257, 6) === "ustar" ? text(offset + 345, 155) : "";
3346
- raw = prefix ? `${prefix}/${text(offset, 100)}` : text(offset, 100);
3347
- size = Number.parseInt(text(offset + 124, 12).trim() || "0", 8);
3348
- mode = Number.parseInt(text(offset + 100, 8).trim() || "0", 8);
3345
+ const prefix = text2(offset + 257, 6) === "ustar" ? text2(offset + 345, 155) : "";
3346
+ raw = prefix ? `${prefix}/${text2(offset, 100)}` : text2(offset, 100);
3347
+ size = Number.parseInt(text2(offset + 124, 12).trim() || "0", 8);
3348
+ mode = Number.parseInt(text2(offset + 100, 8).trim() || "0", 8);
3349
3349
  } catch {
3350
3350
  throw invalidZip("payload", "tar header is not valid UTF-8");
3351
3351
  }
@@ -3961,14 +3961,14 @@ function writeString(target, offset, length, value) {
3961
3961
  target.set(bytes, offset);
3962
3962
  }
3963
3963
  function writeOctal(target, offset, length, value) {
3964
- const text = value.toString(8).padStart(length - 1, "0");
3965
- if (text.length >= length)
3964
+ const text2 = value.toString(8).padStart(length - 1, "0");
3965
+ if (text2.length >= length)
3966
3966
  throw new UsageError("FILE_TOO_LARGE", "tar field overflows");
3967
- writeString(target, offset, length, `${text}\0`);
3967
+ writeString(target, offset, length, `${text2}\0`);
3968
3968
  }
3969
3969
  function writeChecksum(target, value) {
3970
- const text = value.toString(8).padStart(6, "0");
3971
- writeString(target, 148, 8, `${text}\0 `);
3970
+ const text2 = value.toString(8).padStart(6, "0");
3971
+ writeString(target, 148, 8, `${text2}\0 `);
3972
3972
  }
3973
3973
  function validateZipEntryName(name) {
3974
3974
  if (!name || name.includes("\0") || name.includes("\\") || name.startsWith("/")) {
@@ -5106,7 +5106,7 @@ function validateContentHandlers(value, permissions) {
5106
5106
  }
5107
5107
  return value;
5108
5108
  }
5109
- const PACKAGE_VERSION = "0.7.138";
5109
+ const PACKAGE_VERSION = "0.7.140";
5110
5110
  const TOOL_VERSION = PACKAGE_VERSION;
5111
5111
  const SDK_VERSION = PACKAGE_VERSION;
5112
5112
  const PROTOCOL_VERSION = "1";
@@ -5123,7 +5123,7 @@ const VERSION$1 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
5123
5123
  const SHA256_ID = /^sha256:[0-9a-f]{64}$/;
5124
5124
  const OBJECT_ID = /^(?:appdoc|pkg):[0-9a-f]{64}$/;
5125
5125
  const SAFE_GENERATED_FILE = /^[A-Za-z0-9._-]+$/;
5126
- const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
5126
+ const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
5127
5127
  const APP_KINDS = ["static-web", "script", "docker", "agent-skills"];
5128
5128
  const PATH_KINDS = {
5129
5129
  "static-web": { key: "web", category: "web", selectorType: "static" },
@@ -5166,7 +5166,7 @@ function createPikgModule(dependencies = {}) {
5166
5166
  properties: { meta_dir: { type: "string", minLength: 1 } },
5167
5167
  additionalProperties: false
5168
5168
  },
5169
- outputSchema: OBJECT_OUTPUT$9,
5169
+ outputSchema: OBJECT_OUTPUT$a,
5170
5170
  resultSchemaVersion: 1,
5171
5171
  access: { mode: "fixed", level: "read" },
5172
5172
  asyncMode: "sync",
@@ -5213,7 +5213,7 @@ function createPikgModule(dependencies = {}) {
5213
5213
  },
5214
5214
  additionalProperties: false
5215
5215
  },
5216
- outputSchema: OBJECT_OUTPUT$9,
5216
+ outputSchema: OBJECT_OUTPUT$a,
5217
5217
  resultSchemaVersion: 1,
5218
5218
  access: { mode: "fixed", level: "write" },
5219
5219
  asyncMode: "sync",
@@ -5238,7 +5238,7 @@ function createPikgModule(dependencies = {}) {
5238
5238
  properties: { meta_dir: { type: "string", minLength: 1 } },
5239
5239
  additionalProperties: false
5240
5240
  },
5241
- outputSchema: OBJECT_OUTPUT$9,
5241
+ outputSchema: OBJECT_OUTPUT$a,
5242
5242
  resultSchemaVersion: 1,
5243
5243
  access: { mode: "fixed", level: "write" },
5244
5244
  asyncMode: "sync",
@@ -5259,7 +5259,7 @@ function createPikgModule(dependencies = {}) {
5259
5259
  properties: { dist_dir: { type: "string", minLength: 1 } },
5260
5260
  additionalProperties: false
5261
5261
  },
5262
- outputSchema: OBJECT_OUTPUT$9,
5262
+ outputSchema: OBJECT_OUTPUT$a,
5263
5263
  resultSchemaVersion: 1,
5264
5264
  access: { mode: "fixed", level: "write" },
5265
5265
  asyncMode: "sync",
@@ -5279,7 +5279,7 @@ function createPikgModule(dependencies = {}) {
5279
5279
  required: ["pikg_path"],
5280
5280
  additionalProperties: false
5281
5281
  },
5282
- outputSchema: OBJECT_OUTPUT$9,
5282
+ outputSchema: OBJECT_OUTPUT$a,
5283
5283
  resultSchemaVersion: 1,
5284
5284
  access: { mode: "fixed", level: "read" },
5285
5285
  asyncMode: "sync",
@@ -5300,7 +5300,7 @@ function createPikgModule(dependencies = {}) {
5300
5300
  properties: { meta_dir: { type: "string", minLength: 1 } },
5301
5301
  additionalProperties: false
5302
5302
  },
5303
- outputSchema: OBJECT_OUTPUT$9,
5303
+ outputSchema: OBJECT_OUTPUT$a,
5304
5304
  resultSchemaVersion: 1,
5305
5305
  access: { mode: "fixed", level: "destructive" },
5306
5306
  asyncMode: "sync",
@@ -6394,8 +6394,8 @@ function toPortablePath(path) {
6394
6394
  return path.split(getHost().path.sep).join("/") || ".";
6395
6395
  }
6396
6396
  function safeDockerError(bytes) {
6397
- const text = new TextDecoder().decode(bytes).trim().replaceAll(/[\r\n]+/g, " ");
6398
- return text.slice(0, 500) || "unknown Docker error";
6397
+ const text2 = new TextDecoder().decode(bytes).trim().replaceAll(/[\r\n]+/g, " ");
6398
+ return text2.slice(0, 500) || "unknown Docker error";
6399
6399
  }
6400
6400
  async function removeTreeIfExists(path) {
6401
6401
  try {
@@ -6563,7 +6563,7 @@ const CONTROL_PANEL_SERVICE = "control-panel";
6563
6563
  const PLAN_SCHEMA_VERSION = 4;
6564
6564
  const STAGING_RELEASE_TIMEOUT_MS = 5e3;
6565
6565
  const ZIP_LOCAL_MAGIC = [80, 75, 3, 4];
6566
- const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
6566
+ const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
6567
6567
  const INSTALL_POLICIES = [
6568
6568
  "strict-public",
6569
6569
  "normal",
@@ -6614,7 +6614,7 @@ function cancelCommand$1() {
6614
6614
  required: ["task_id"],
6615
6615
  additionalProperties: false
6616
6616
  },
6617
- outputSchema: OBJECT_OUTPUT$8,
6617
+ outputSchema: OBJECT_OUTPUT$9,
6618
6618
  resultSchemaVersion: 1,
6619
6619
  access: { mode: "fixed", level: "write" },
6620
6620
  asyncMode: "sync",
@@ -6649,7 +6649,7 @@ function fetchCommand(dependencies) {
6649
6649
  target: { type: "object", additionalProperties: true },
6650
6650
  install_params: { type: "object", additionalProperties: true }
6651
6651
  }),
6652
- outputSchema: OBJECT_OUTPUT$8,
6652
+ outputSchema: OBJECT_OUTPUT$9,
6653
6653
  resultSchemaVersion: 1,
6654
6654
  access: { mode: "fixed", level: "read" },
6655
6655
  asyncMode: "sync",
@@ -6666,7 +6666,7 @@ function listCommand$2() {
6666
6666
  verb: "list",
6667
6667
  summary: "List visible installed Apps",
6668
6668
  inputSchema: emptyInputSchema(),
6669
- outputSchema: OBJECT_OUTPUT$8,
6669
+ outputSchema: OBJECT_OUTPUT$9,
6670
6670
  resultSchemaVersion: 1,
6671
6671
  access: { mode: "fixed", level: "read" },
6672
6672
  asyncMode: "sync",
@@ -6724,7 +6724,7 @@ function installCommand(dependencies) {
6724
6724
  no_wait: { type: "boolean" },
6725
6725
  policy: { type: "string", enum: [...INSTALL_POLICIES] }
6726
6726
  }),
6727
- outputSchema: OBJECT_OUTPUT$8,
6727
+ outputSchema: OBJECT_OUTPUT$9,
6728
6728
  resultSchemaVersion: 1,
6729
6729
  access: { mode: "fixed", level: "write" },
6730
6730
  asyncMode: "either",
@@ -6768,7 +6768,7 @@ function upgradeCommand(dependencies) {
6768
6768
  },
6769
6769
  additionalProperties: false
6770
6770
  },
6771
- outputSchema: OBJECT_OUTPUT$8,
6771
+ outputSchema: OBJECT_OUTPUT$9,
6772
6772
  resultSchemaVersion: 1,
6773
6773
  access: { mode: "fixed", level: "write" },
6774
6774
  asyncMode: "either",
@@ -6897,7 +6897,7 @@ function statusCommand$1() {
6897
6897
  properties: { app_name: { type: "string", minLength: 1 } },
6898
6898
  additionalProperties: false
6899
6899
  },
6900
- outputSchema: OBJECT_OUTPUT$8,
6900
+ outputSchema: OBJECT_OUTPUT$9,
6901
6901
  resultSchemaVersion: 1,
6902
6902
  access: { mode: "fixed", level: "read" },
6903
6903
  asyncMode: "sync",
@@ -6968,7 +6968,7 @@ function publishCommand() {
6968
6968
  required: ["local_dir", "app_doc"],
6969
6969
  additionalProperties: false
6970
6970
  },
6971
- outputSchema: OBJECT_OUTPUT$8,
6971
+ outputSchema: OBJECT_OUTPUT$9,
6972
6972
  resultSchemaVersion: 1,
6973
6973
  access: { mode: "fixed", level: "write" },
6974
6974
  asyncMode: "sync",
@@ -7937,8 +7937,8 @@ async function releaseStaging(ctx, source) {
7937
7937
  }
7938
7938
  }
7939
7939
  function expectInspection(value) {
7940
- const object = expectObject$1(value, "apps.inspect response");
7941
- const schemaVersion = expectNumber(object, "schema_version");
7940
+ const object2 = expectObject$1(value, "apps.inspect response");
7941
+ const schemaVersion = expectNumber(object2, "schema_version");
7942
7942
  if (schemaVersion !== PLAN_SCHEMA_VERSION) {
7943
7943
  throw new ToolError(
7944
7944
  "UNSUPPORTED_SCHEMA_VERSION",
@@ -7947,9 +7947,9 @@ function expectInspection(value) {
7947
7947
  }
7948
7948
  const inspection = {
7949
7949
  schema_version: schemaVersion,
7950
- plan: expectObject$1(object.plan, "inspection.plan"),
7951
- resolution_status: expectObject$1(object.resolution_status, "inspection.resolution_status"),
7952
- status: expectObject$1(object.status, "inspection.status")
7950
+ plan: expectObject$1(object2.plan, "inspection.plan"),
7951
+ resolution_status: expectObject$1(object2.resolution_status, "inspection.resolution_status"),
7952
+ status: expectObject$1(object2.status, "inspection.status")
7953
7953
  };
7954
7954
  assertPortablePlan(inspection.plan);
7955
7955
  if (inspection.status.plan_fingerprint !== inspection.plan.plan_fingerprint) {
@@ -8094,7 +8094,7 @@ function selectorCommand(options) {
8094
8094
  required: ["app_name"],
8095
8095
  additionalProperties: false
8096
8096
  },
8097
- outputSchema: OBJECT_OUTPUT$8,
8097
+ outputSchema: OBJECT_OUTPUT$9,
8098
8098
  resultSchemaVersion: 1,
8099
8099
  access: { mode: "fixed", level: options.access },
8100
8100
  asyncMode: options.asyncMode,
@@ -8169,8 +8169,8 @@ function expectString(value, property) {
8169
8169
  }
8170
8170
  return candidate;
8171
8171
  }
8172
- function expectNumber(object, property) {
8173
- const value = object[property];
8172
+ function expectNumber(object2, property) {
8173
+ const value = object2[property];
8174
8174
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
8175
8175
  throw new ToolError("INVALID_SERVICE_RESPONSE", `${property} must be a non-negative integer`, 9);
8176
8176
  }
@@ -8258,7 +8258,7 @@ function toHex(bytes) {
8258
8258
  return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
8259
8259
  }
8260
8260
  const CONTROL_PANEL$3 = "control-panel";
8261
- const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8261
+ const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
8262
8262
  function createDiagnosticModule(dependencies = {}) {
8263
8263
  return {
8264
8264
  name: "diagnostic",
@@ -8297,7 +8297,7 @@ function collectCommand() {
8297
8297
  required: ["services"],
8298
8298
  additionalProperties: false
8299
8299
  },
8300
- outputSchema: OBJECT_OUTPUT$7,
8300
+ outputSchema: OBJECT_OUTPUT$8,
8301
8301
  resultSchemaVersion: 1,
8302
8302
  access: { mode: "fixed", level: "privileged" },
8303
8303
  asyncMode: "task",
@@ -8351,7 +8351,7 @@ function exportCommand$1(dependencies) {
8351
8351
  required: ["bundle_id", "path"],
8352
8352
  additionalProperties: false
8353
8353
  },
8354
- outputSchema: OBJECT_OUTPUT$7,
8354
+ outputSchema: OBJECT_OUTPUT$8,
8355
8355
  resultSchemaVersion: 1,
8356
8356
  access: { mode: "fixed", level: "privileged" },
8357
8357
  asyncMode: "sync",
@@ -8393,7 +8393,7 @@ function compact$2(value) {
8393
8393
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
8394
8394
  }
8395
8395
  const CONTROL_PANEL$2 = "control-panel";
8396
- const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
8396
+ const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8397
8397
  const LOG_LEVELS = ["error", "warning", "info", "debug", "trace"];
8398
8398
  function createLogModule(dependencies = {}) {
8399
8399
  return {
@@ -8401,7 +8401,7 @@ function createLogModule(dependencies = {}) {
8401
8401
  summary: "List services, query, follow, and export redacted system logs",
8402
8402
  commands: [
8403
8403
  servicesCommand(),
8404
- queryCommand(),
8404
+ queryCommand$1(),
8405
8405
  tailCommand(dependencies),
8406
8406
  exportCommand(dependencies)
8407
8407
  ]
@@ -8414,7 +8414,7 @@ function servicesCommand() {
8414
8414
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
8415
8415
  outputSchema: {
8416
8416
  type: "object",
8417
- properties: { services: { type: "array", items: OBJECT_OUTPUT$6 } },
8417
+ properties: { services: { type: "array", items: OBJECT_OUTPUT$7 } },
8418
8418
  required: ["services"],
8419
8419
  additionalProperties: false
8420
8420
  },
@@ -8434,7 +8434,7 @@ function servicesCommand() {
8434
8434
  }
8435
8435
  };
8436
8436
  }
8437
- function queryCommand() {
8437
+ function queryCommand$1() {
8438
8438
  return {
8439
8439
  verb: "query",
8440
8440
  summary: "Query structured redacted log entries",
@@ -8487,7 +8487,7 @@ function tailCommand(dependencies) {
8487
8487
  }
8488
8488
  ],
8489
8489
  inputSchema: filterSchema({ from: { type: "string", enum: ["start", "end"] } }),
8490
- outputSchema: OBJECT_OUTPUT$6,
8490
+ outputSchema: OBJECT_OUTPUT$7,
8491
8491
  resultSchemaVersion: 1,
8492
8492
  access: { mode: "fixed", level: "read" },
8493
8493
  asyncMode: "stream",
@@ -8543,7 +8543,7 @@ function exportCommand(dependencies) {
8543
8543
  ...filterSchema({ path: { type: "string", minLength: 1 } }),
8544
8544
  required: ["path"]
8545
8545
  },
8546
- outputSchema: OBJECT_OUTPUT$6,
8546
+ outputSchema: OBJECT_OUTPUT$7,
8547
8547
  resultSchemaVersion: 1,
8548
8548
  access: { mode: "fixed", level: "read" },
8549
8549
  asyncMode: "sync",
@@ -8695,7 +8695,7 @@ function abortableSleep(milliseconds, signal) {
8695
8695
  }
8696
8696
  const TASK_MANAGER = "task-manager";
8697
8697
  const CONTROL_PANEL$1 = "control-panel";
8698
- const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
8698
+ const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
8699
8699
  function createTaskModule() {
8700
8700
  return {
8701
8701
  name: "task",
@@ -8798,7 +8798,7 @@ function getCommand$1() {
8798
8798
  required: ["task_id"],
8799
8799
  additionalProperties: false
8800
8800
  },
8801
- outputSchema: OBJECT_OUTPUT$5,
8801
+ outputSchema: OBJECT_OUTPUT$6,
8802
8802
  resultSchemaVersion: 1,
8803
8803
  access: { mode: "fixed", level: "read" },
8804
8804
  asyncMode: "sync",
@@ -8839,7 +8839,7 @@ function waitCommand() {
8839
8839
  summary: "Stream changes until a Task becomes terminal",
8840
8840
  positionals: [{ name: "task_id", description: "Opaque Task ID", required: true }],
8841
8841
  inputSchema: taskIdSchema(),
8842
- outputSchema: OBJECT_OUTPUT$5,
8842
+ outputSchema: OBJECT_OUTPUT$6,
8843
8843
  resultSchemaVersion: 1,
8844
8844
  access: { mode: "fixed", level: "read" },
8845
8845
  asyncMode: "stream",
@@ -8890,7 +8890,7 @@ function cancelCommand() {
8890
8890
  required: ["task_id"],
8891
8891
  additionalProperties: false
8892
8892
  },
8893
- outputSchema: OBJECT_OUTPUT$5,
8893
+ outputSchema: OBJECT_OUTPUT$6,
8894
8894
  resultSchemaVersion: 1,
8895
8895
  access: { mode: "fixed", level: "write" },
8896
8896
  asyncMode: "sync",
@@ -8933,7 +8933,7 @@ function retryCommand() {
8933
8933
  required: ["task_id"],
8934
8934
  additionalProperties: false
8935
8935
  },
8936
- outputSchema: OBJECT_OUTPUT$5,
8936
+ outputSchema: OBJECT_OUTPUT$6,
8937
8937
  resultSchemaVersion: 1,
8938
8938
  access: { mode: "fixed", level: "write" },
8939
8939
  asyncMode: "either",
@@ -9007,7 +9007,7 @@ function invalidResponse$1(label) {
9007
9007
  throw new ToolError("INVALID_SERVICE_RESPONSE", `${label} is invalid`, EXIT_INTERNAL);
9008
9008
  }
9009
9009
  const sdk = provisionSdk;
9010
- const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9010
+ const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
9011
9011
  const ROOT_OPTION = {
9012
9012
  name: "root",
9013
9013
  description: "Installed BuckyOS root on this machine (BUCKYOS_ROOT); read by status/check, written by activate",
@@ -9091,7 +9091,7 @@ function statusCommand(deps) {
9091
9091
  additionalProperties: false
9092
9092
  },
9093
9093
  outputSchema: {
9094
- ...OBJECT_OUTPUT$4,
9094
+ ...OBJECT_OUTPUT$5,
9095
9095
  properties: {
9096
9096
  root: { type: "string" },
9097
9097
  state: {
@@ -9129,7 +9129,7 @@ function checkCommand(deps) {
9129
9129
  additionalProperties: false
9130
9130
  },
9131
9131
  outputSchema: {
9132
- ...OBJECT_OUTPUT$4,
9132
+ ...OBJECT_OUTPUT$5,
9133
9133
  properties: {
9134
9134
  ready: { type: "boolean" },
9135
9135
  root: { type: "string" },
@@ -9177,7 +9177,7 @@ function activateCommand(deps) {
9177
9177
  additionalProperties: false
9178
9178
  },
9179
9179
  outputSchema: {
9180
- ...OBJECT_OUTPUT$4,
9180
+ ...OBJECT_OUTPUT$5,
9181
9181
  properties: {
9182
9182
  root: { type: "string" },
9183
9183
  state: { type: "string", enum: ["configured"] },
@@ -9239,9 +9239,9 @@ function resolvePath(ctx, value) {
9239
9239
  const path = getHost().path;
9240
9240
  return path.isAbsolute(value) ? path.resolve(value) : path.resolve(ctx.cwd, value);
9241
9241
  }
9242
- async function assertHostAccess(path, operation) {
9242
+ async function assertHostAccess(path, operation2) {
9243
9243
  try {
9244
- await getHost().assertAccess(path, operation);
9244
+ await getHost().assertAccess(path, operation2);
9245
9245
  } catch (error) {
9246
9246
  if (isHostError(error, "PermissionDenied")) {
9247
9247
  throw new ToolError(
@@ -9249,7 +9249,7 @@ async function assertHostAccess(path, operation) {
9249
9249
  `${error.message}; pass the path on the command line (--root / --owner-key-backup) so the launcher can grant it`,
9250
9250
  EXIT_PERMISSION,
9251
9251
  false,
9252
- { path, operation }
9252
+ { path, operation: operation2 }
9253
9253
  );
9254
9254
  }
9255
9255
  throw error;
@@ -9459,7 +9459,7 @@ function inputFingerprint(input) {
9459
9459
  hash.update(new TextEncoder().encode(JSON.stringify(material)));
9460
9460
  return hash.digestHex();
9461
9461
  }
9462
- const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9462
+ const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9463
9463
  const SKILL_KINDS = ["cmd", "goal"];
9464
9464
  const SKILLS_SUB_PKG = "agent_skills";
9465
9465
  const SKILL_DIRS = ["cmd_skills", "goal_skills", "tools"];
@@ -9496,7 +9496,7 @@ function createSkillModule() {
9496
9496
  required: ["agent_id"],
9497
9497
  additionalProperties: false
9498
9498
  },
9499
- outputSchema: OBJECT_OUTPUT$3,
9499
+ outputSchema: OBJECT_OUTPUT$4,
9500
9500
  resultSchemaVersion: 1,
9501
9501
  access: { mode: "fixed", level: "read" },
9502
9502
  asyncMode: "sync",
@@ -9535,7 +9535,7 @@ function createSkillModule() {
9535
9535
  required: ["pikg_path", "agent_id"],
9536
9536
  additionalProperties: false
9537
9537
  },
9538
- outputSchema: OBJECT_OUTPUT$3,
9538
+ outputSchema: OBJECT_OUTPUT$4,
9539
9539
  resultSchemaVersion: 1,
9540
9540
  access: { mode: "fixed", level: "write" },
9541
9541
  asyncMode: "sync",
@@ -9562,7 +9562,7 @@ function createSkillModule() {
9562
9562
  required: ["name", "agent_id"],
9563
9563
  additionalProperties: false
9564
9564
  },
9565
- outputSchema: OBJECT_OUTPUT$3,
9565
+ outputSchema: OBJECT_OUTPUT$4,
9566
9566
  resultSchemaVersion: 1,
9567
9567
  access: { mode: "fixed", level: "destructive" },
9568
9568
  asyncMode: "sync",
@@ -9683,7 +9683,7 @@ function base64(bytes) {
9683
9683
  return btoa(binary);
9684
9684
  }
9685
9685
  const CONTROL_PANEL = "control-panel";
9686
- const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
9686
+ const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9687
9687
  const AGENT_POSITIONAL = {
9688
9688
  name: "agent_id",
9689
9689
  description: "Agent ID as `agent list` prints it (raw host name, e.g. jarvis.example.zone)"
@@ -9707,7 +9707,7 @@ function createAgentModule() {
9707
9707
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
9708
9708
  outputSchema: {
9709
9709
  type: "object",
9710
- properties: { agents: { type: "array", items: OBJECT_OUTPUT$2 } },
9710
+ properties: { agents: { type: "array", items: OBJECT_OUTPUT$3 } },
9711
9711
  required: ["agents"],
9712
9712
  additionalProperties: false
9713
9713
  },
@@ -9733,7 +9733,7 @@ function createAgentModule() {
9733
9733
  summary: "Get one Agent: profile, settings, install state, template, and runtime",
9734
9734
  positionals: [AGENT_POSITIONAL],
9735
9735
  inputSchema: AGENT_INPUT,
9736
- outputSchema: OBJECT_OUTPUT$2,
9736
+ outputSchema: OBJECT_OUTPUT$3,
9737
9737
  resultSchemaVersion: 1,
9738
9738
  access: { mode: "fixed", level: "read" },
9739
9739
  asyncMode: "sync",
@@ -9746,7 +9746,7 @@ function createAgentModule() {
9746
9746
  summary: "Get the public profile (display name, bio, avatar) of an Agent",
9747
9747
  positionals: [AGENT_POSITIONAL],
9748
9748
  inputSchema: AGENT_INPUT,
9749
- outputSchema: OBJECT_OUTPUT$2,
9749
+ outputSchema: OBJECT_OUTPUT$3,
9750
9750
  resultSchemaVersion: 1,
9751
9751
  access: { mode: "fixed", level: "read" },
9752
9752
  asyncMode: "sync",
@@ -9787,8 +9787,8 @@ function createAgentModule() {
9787
9787
  type: "object",
9788
9788
  properties: {
9789
9789
  agent_id: { type: "string" },
9790
- before: OBJECT_OUTPUT$2,
9791
- profile: OBJECT_OUTPUT$2
9790
+ before: OBJECT_OUTPUT$3,
9791
+ profile: OBJECT_OUTPUT$3
9792
9792
  },
9793
9793
  required: ["agent_id", "before", "profile"],
9794
9794
  additionalProperties: false
@@ -9833,7 +9833,7 @@ async function callAgent(ctx, method, params) {
9833
9833
  }
9834
9834
  }
9835
9835
  const AICC = "aicc";
9836
- const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
9836
+ const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
9837
9837
  const EMPTY_INPUT = { type: "object", properties: {}, additionalProperties: false };
9838
9838
  const RANGES = ["last1d", "last7d", "last30d"];
9839
9839
  const GROUPS = [
@@ -9851,13 +9851,13 @@ function createAiModule() {
9851
9851
  name: "ai",
9852
9852
  summary: "Read AI provider, routing, usage and token quota state of the AICC service",
9853
9853
  commands: [
9854
- readCommand({
9854
+ readCommand$1({
9855
9855
  verb: "providers",
9856
9856
  summary: "List configured AI provider instances with auth, health, and model inventory",
9857
9857
  method: "provider.list",
9858
9858
  description: "Credentials are reported only as configured/kind; secrets are never returned."
9859
9859
  }),
9860
- readCommand({
9860
+ readCommand$1({
9861
9861
  verb: "routing",
9862
9862
  summary: "Get the AICC routing overlay and its settings revision",
9863
9863
  method: "routing.get",
@@ -9881,7 +9881,7 @@ function quotaCommand() {
9881
9881
  properties: { app: { type: "string", minLength: 1 } },
9882
9882
  additionalProperties: false
9883
9883
  },
9884
- outputSchema: OBJECT_OUTPUT$1,
9884
+ outputSchema: OBJECT_OUTPUT$2,
9885
9885
  resultSchemaVersion: 1,
9886
9886
  access: { mode: "fixed", level: "read" },
9887
9887
  asyncMode: "sync",
@@ -9893,13 +9893,13 @@ function quotaCommand() {
9893
9893
  )
9894
9894
  };
9895
9895
  }
9896
- function readCommand(options) {
9896
+ function readCommand$1(options) {
9897
9897
  return {
9898
9898
  verb: options.verb,
9899
9899
  summary: options.summary,
9900
9900
  description: options.description,
9901
9901
  inputSchema: EMPTY_INPUT,
9902
- outputSchema: OBJECT_OUTPUT$1,
9902
+ outputSchema: OBJECT_OUTPUT$2,
9903
9903
  resultSchemaVersion: 1,
9904
9904
  access: { mode: "fixed", level: "read" },
9905
9905
  asyncMode: "sync",
@@ -9951,7 +9951,7 @@ function usageCommand() {
9951
9951
  },
9952
9952
  additionalProperties: false
9953
9953
  },
9954
- outputSchema: OBJECT_OUTPUT$1,
9954
+ outputSchema: OBJECT_OUTPUT$2,
9955
9955
  resultSchemaVersion: 1,
9956
9956
  access: { mode: "fixed", level: "read" },
9957
9957
  asyncMode: "sync",
@@ -9996,7 +9996,7 @@ function timeRange(input) {
9996
9996
  }
9997
9997
  return { kind: "explicit", start_time_ms: since, end_time_ms: until ?? Date.now() };
9998
9998
  }
9999
- const OBJECT_OUTPUT = { type: "object", additionalProperties: true };
9999
+ const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
10000
10000
  const DAY_MS = 864e5;
10001
10001
  const EXPIRES_HELP = "1d, 7d (default), 30d, none, or an RFC 3339 time";
10002
10002
  function createShareModule() {
@@ -10060,10 +10060,10 @@ function gatewayOrigin(endpoint) {
10060
10060
  function parseExpires(value) {
10061
10061
  if (value === void 0)
10062
10062
  return void 0;
10063
- const text = String(value).trim().toLowerCase();
10064
- if (text === "none" || text === "never")
10063
+ const text2 = String(value).trim().toLowerCase();
10064
+ if (text2 === "none" || text2 === "never")
10065
10065
  return null;
10066
- const days = text.match(/^(\d+)d$/);
10066
+ const days = text2.match(/^(\d+)d$/);
10067
10067
  if (days)
10068
10068
  return Math.floor((Date.now() + Number(days[1]) * DAY_MS) / 1e3);
10069
10069
  const at = parseTimestamp(value, "expires");
@@ -10107,7 +10107,7 @@ function createCommand() {
10107
10107
  required: ["path"],
10108
10108
  additionalProperties: false
10109
10109
  },
10110
- outputSchema: OBJECT_OUTPUT,
10110
+ outputSchema: OBJECT_OUTPUT$1,
10111
10111
  resultSchemaVersion: 1,
10112
10112
  access: { mode: "fixed", level: "write" },
10113
10113
  asyncMode: "either",
@@ -10176,7 +10176,7 @@ function listCommand() {
10176
10176
  },
10177
10177
  additionalProperties: false
10178
10178
  },
10179
- outputSchema: OBJECT_OUTPUT,
10179
+ outputSchema: OBJECT_OUTPUT$1,
10180
10180
  resultSchemaVersion: 1,
10181
10181
  access: { mode: "fixed", level: "read" },
10182
10182
  asyncMode: "sync",
@@ -10208,7 +10208,7 @@ function getCommand() {
10208
10208
  required: ["share_id"],
10209
10209
  additionalProperties: false
10210
10210
  },
10211
- outputSchema: OBJECT_OUTPUT,
10211
+ outputSchema: OBJECT_OUTPUT$1,
10212
10212
  resultSchemaVersion: 1,
10213
10213
  access: { mode: "fixed", level: "read" },
10214
10214
  asyncMode: "sync",
@@ -10245,7 +10245,7 @@ function updateCommand() {
10245
10245
  required: ["share_id"],
10246
10246
  additionalProperties: false
10247
10247
  },
10248
- outputSchema: OBJECT_OUTPUT,
10248
+ outputSchema: OBJECT_OUTPUT$1,
10249
10249
  resultSchemaVersion: 1,
10250
10250
  access: { mode: "fixed", level: "write" },
10251
10251
  asyncMode: "sync",
@@ -10289,7 +10289,7 @@ function stopCommand() {
10289
10289
  required: ["share_id"],
10290
10290
  additionalProperties: false
10291
10291
  },
10292
- outputSchema: OBJECT_OUTPUT,
10292
+ outputSchema: OBJECT_OUTPUT$1,
10293
10293
  resultSchemaVersion: 1,
10294
10294
  access: { mode: "fixed", level: "destructive" },
10295
10295
  asyncMode: "sync",
@@ -10321,7 +10321,7 @@ function statsCommand() {
10321
10321
  },
10322
10322
  additionalProperties: false
10323
10323
  },
10324
- outputSchema: OBJECT_OUTPUT,
10324
+ outputSchema: OBJECT_OUTPUT$1,
10325
10325
  resultSchemaVersion: 1,
10326
10326
  access: { mode: "fixed", level: "read" },
10327
10327
  asyncMode: "sync",
@@ -10340,6 +10340,425 @@ function statsCommand() {
10340
10340
  }
10341
10341
  };
10342
10342
  }
10343
+ const text = { type: "string", minLength: 1 };
10344
+ const object = { type: "object", additionalProperties: true };
10345
+ const targetProperties = {
10346
+ executor_id: text,
10347
+ generation: { type: "integer", minimum: 1 },
10348
+ profile_id: text,
10349
+ store_id: text,
10350
+ locator: text
10351
+ };
10352
+ function call(ctx, method, params) {
10353
+ return ctx.clients.call("control-panel", method, params, {
10354
+ traceId: ctx.traceId,
10355
+ signal: ctx.signal,
10356
+ timeoutMs: Math.max(1, (ctx.deadline ?? Date.now() + 3e4) - Date.now())
10357
+ });
10358
+ }
10359
+ function management(verb, method, properties, required, write = false) {
10360
+ return {
10361
+ verb,
10362
+ summary: `Executor ${verb}`,
10363
+ inputSchema: { ...object, properties, required, additionalProperties: false },
10364
+ outputSchema: object,
10365
+ resultSchemaVersion: 1,
10366
+ access: { mode: "fixed", level: write ? "write" : "read" },
10367
+ asyncMode: "sync",
10368
+ requiresSession: true,
10369
+ options: Object.entries(properties).filter(([, schema]) => schema.type !== "object").map(([name, schema]) => ({
10370
+ name: name.replaceAll("_", "-"),
10371
+ property: name,
10372
+ description: name,
10373
+ type: schema.type === "integer" ? "integer" : "string",
10374
+ required: required.includes(name)
10375
+ })),
10376
+ handler: (ctx, input) => call(ctx, method, input)
10377
+ };
10378
+ }
10379
+ function createExecutorModule() {
10380
+ return {
10381
+ name: "executor",
10382
+ summary: "Manage lightweight devices and explicitly target online command/file executors",
10383
+ commands: [
10384
+ management("create", "executor.device.create", { name: text, profiles: object, limits: object, expires_at_ms: { type: "integer" } }, ["name", "profiles"], true),
10385
+ management("list", "executor.device.list", {}, []),
10386
+ management("issue", "executor.device.issue", { executor_id: text, expires_at_ms: { type: "integer" } }, ["executor_id"], true),
10387
+ management("revoke", "executor.device.revoke", { executor_id: text }, ["executor_id"], true),
10388
+ management("delete", "executor.device.delete", { executor_id: text }, ["executor_id"], true),
10389
+ management("online", "executor.online.list", {}, []),
10390
+ operation("exec", { cmd: text, cwd: text, env: object, execution_timeout_ms: { type: "integer", minimum: 1 } }, ["cmd", "cwd"]),
10391
+ operation("read", { path: text }, ["path"]),
10392
+ operation("write", { path: text, content: { type: "string" }, mode: { type: "string", enum: ["replace", "append", "create_new"] } }, ["path", "content"]),
10393
+ operation("edit", { path: text, old_string: text, new_string: { type: "string" } }, ["path", "old_string", "new_string"]),
10394
+ operation("query", { channel: { type: "string", enum: ["stdout", "stderr", "content"] }, offset: { type: "integer", minimum: 0 }, wait_ms: { type: "integer", minimum: 0 } }, []),
10395
+ operation("cancel", {}, [])
10396
+ ]
10397
+ };
10398
+ }
10399
+ function operation(verb, extra, required) {
10400
+ const recovery = verb === "query" || verb === "cancel";
10401
+ const properties = { ...targetProperties, ...extra };
10402
+ return {
10403
+ verb,
10404
+ summary: `${verb} on an explicit executor; persist --locator before dispatch and query it after disconnection`,
10405
+ inputSchema: { ...object, properties, required: [...Object.keys(targetProperties), ...required], additionalProperties: false },
10406
+ outputSchema: object,
10407
+ resultSchemaVersion: 1,
10408
+ access: { mode: "fixed", level: ["read", "query"].includes(verb) ? "read" : "write" },
10409
+ asyncMode: "sync",
10410
+ requiresSession: true,
10411
+ options: Object.entries(properties).filter(([, schema]) => schema.type !== "object").map(([name, schema]) => ({
10412
+ name: name.replaceAll("_", "-"),
10413
+ property: name,
10414
+ description: name,
10415
+ type: schema.type === "integer" ? "integer" : "string",
10416
+ required: Object.keys(targetProperties).includes(name) || required.includes(name)
10417
+ })),
10418
+ handler: async (ctx, input) => {
10419
+ const target = { executor_id: String(input.executor_id), generation: Number(input.generation), profile_id: String(input.profile_id), store_id: String(input.store_id) };
10420
+ const path = String(input.locator);
10421
+ const host2 = getHost();
10422
+ let locator;
10423
+ if (recovery)
10424
+ locator = JSON.parse(await host2.readTextFile(path));
10425
+ else {
10426
+ locator = { ...target, op_id: crypto.randomUUID(), run_id: ctx.traceId, call_id: ctx.idempotencyKey ?? crypto.randomUUID() };
10427
+ await host2.writeTextFile(path, JSON.stringify(locator) + "\n", { createNew: true, mode: 384 });
10428
+ }
10429
+ if (!ctx.session)
10430
+ throw new ToolError("AUTH_REQUIRED", "An authenticated App session is required");
10431
+ const { token } = await ctx.session.ensureValid();
10432
+ const route = await call(ctx, "executor.stream.open", { executor_id: target.executor_id, generation: target.generation, profile_id: target.profile_id });
10433
+ const stream = await ExecutorCommandStream.connect(route, target, token, "buckyos-cli", locator.run_id);
10434
+ if (!stream)
10435
+ throw new ToolError("INVALID_SERVICE_RESPONSE", "Executor stream did not initialize");
10436
+ const abort = () => stream.close();
10437
+ ctx.signal.addEventListener("abort", abort, { once: true });
10438
+ try {
10439
+ let reply;
10440
+ if (verb === "exec")
10441
+ reply = await stream.exec(locator, String(input.cmd), String(input.cwd), input.env ?? {}, Number(input.execution_timeout_ms ?? 6e4));
10442
+ else if (verb === "read")
10443
+ reply = await stream.read(locator, String(input.path));
10444
+ else if (verb === "write")
10445
+ reply = await stream.write(locator, String(input.path), new TextEncoder().encode(String(input.content)), input.mode ?? "replace");
10446
+ else if (verb === "edit")
10447
+ reply = await stream.edit(locator, String(input.path), [{ old_string: String(input.old_string), new_string: String(input.new_string) }]);
10448
+ else if (verb === "cancel")
10449
+ reply = await stream.cancel(locator);
10450
+ else
10451
+ reply = await stream.query(locator, input.channel, Number(input.offset ?? 0), Number(input.wait_ms ?? 0));
10452
+ return { locator, reply };
10453
+ } finally {
10454
+ ctx.signal.removeEventListener("abort", abort);
10455
+ stream.close();
10456
+ }
10457
+ }
10458
+ };
10459
+ }
10460
+ const SERVICE = "aiworkspace";
10461
+ const OBJECT_OUTPUT = { type: "object", additionalProperties: true };
10462
+ const WORKSPACE_OPTION = { name: "workspace", property: "workspace_id", description: "Workspace id (ws_…)", type: "string", required: true };
10463
+ const RUN_OPTION = { name: "run", property: "run_id", description: "Run id (run_…)", type: "string", required: true };
10464
+ const ATTEMPT_OPTION = { name: "attempt", property: "attempt", description: "The attempt number `run-claim` answered", type: "integer", required: true };
10465
+ function workspaceInput(extra, required = []) {
10466
+ return { type: "object", properties: { workspace_id: { type: "string", minLength: 1 }, ...extra }, required: ["workspace_id", ...required], additionalProperties: false };
10467
+ }
10468
+ async function aiws(ctx, method, params) {
10469
+ const result = expectObject$4(await callService(ctx, SERVICE, method, params), method);
10470
+ if (result.ok === false) {
10471
+ const error = expectObject$4(result.error, `${method}.error`);
10472
+ const code = typeof error.code === "string" ? error.code : "AIWS_ERROR";
10473
+ const detail = typeof error.detail === "string" ? error.detail : code;
10474
+ throw new ToolError(code, `${code}${typeof error.sub_code === "string" ? `/${error.sub_code}` : ""}: ${detail}`);
10475
+ }
10476
+ return result;
10477
+ }
10478
+ async function jsonInput(input, textKey, fileKey, label) {
10479
+ const text2 = inputString(input, textKey);
10480
+ const file = inputString(input, fileKey);
10481
+ if (text2 && file)
10482
+ throw new UsageError("AIWS_USAGE", `${textKey} and ${fileKey} are exclusive`);
10483
+ if (file)
10484
+ return JSON.parse(await getHost().readTextFile(file));
10485
+ if (text2)
10486
+ return JSON.parse(text2);
10487
+ throw new UsageError("AIWS_USAGE", `${label}: pass --${textKey.replace(/_/g, "-")} or --${fileKey.replace(/_/g, "-")}`);
10488
+ }
10489
+ const readCommand = {
10490
+ verb: "read",
10491
+ summary: "Read one entity of a workspace (envelope and content)",
10492
+ positionals: [{ name: "entity_id", description: "Entity id", required: true }],
10493
+ options: [WORKSPACE_OPTION, { name: "selector", property: "selector", description: 'Selector JSON, e.g. {"kind":"table_record","record_id":"r1"}', type: "string" }],
10494
+ inputSchema: workspaceInput({ entity_id: { type: "string", minLength: 1 }, selector: { type: "string" } }, ["entity_id"]),
10495
+ outputSchema: OBJECT_OUTPUT,
10496
+ resultSchemaVersion: 1,
10497
+ access: { mode: "fixed", level: "read" },
10498
+ asyncMode: "sync",
10499
+ requiresSession: true,
10500
+ examples: ["buckyos aiws read orders --workspace ws_abc"],
10501
+ handler: (ctx, input) => {
10502
+ const selector = inputString(input, "selector");
10503
+ return aiws(ctx, "doc.read", { workspace_id: requiredInputString(input, "workspace_id"), entity_id: requiredInputString(input, "entity_id"), ...selector ? { selector: JSON.parse(selector) } : {} });
10504
+ }
10505
+ };
10506
+ const queryCommand = {
10507
+ verb: "query",
10508
+ summary: "Query the rows of a table (or through a saved view)",
10509
+ options: [
10510
+ WORKSPACE_OPTION,
10511
+ { name: "source", property: "source_id", description: "Table entity id", type: "string" },
10512
+ { name: "view", property: "view_id", description: "Table view (Block) id", type: "string" },
10513
+ { name: "filter", property: "filter", description: "Filter JSON (README: doc.query)", type: "string" },
10514
+ { name: "limit", property: "limit", description: "Rows per page (≤ 1000)", type: "integer" },
10515
+ { name: "cursor", property: "cursor", description: "Continue from a previous page", type: "string" }
10516
+ ],
10517
+ inputSchema: workspaceInput({ source_id: { type: "string" }, view_id: { type: "string" }, filter: { type: "string" }, limit: { type: "integer" }, cursor: { type: "string" } }),
10518
+ outputSchema: OBJECT_OUTPUT,
10519
+ resultSchemaVersion: 1,
10520
+ access: { mode: "fixed", level: "read" },
10521
+ asyncMode: "sync",
10522
+ requiresSession: true,
10523
+ examples: ["buckyos aiws query --workspace ws_abc --source orders --limit 100"],
10524
+ handler: (ctx, input) => {
10525
+ const params = { workspace_id: requiredInputString(input, "workspace_id") };
10526
+ for (const key of ["source_id", "view_id", "cursor"]) {
10527
+ const value = inputString(input, key);
10528
+ if (value)
10529
+ params[key] = value;
10530
+ }
10531
+ const filter = inputString(input, "filter");
10532
+ if (filter)
10533
+ params.filter = JSON.parse(filter);
10534
+ if (typeof input.limit === "number")
10535
+ params.limit = input.limit;
10536
+ if (!params.source_id && !params.view_id)
10537
+ throw new UsageError("AIWS_USAGE", "pass --source or --view");
10538
+ return aiws(ctx, "doc.query", params);
10539
+ }
10540
+ };
10541
+ const infoCommand = {
10542
+ verb: "info",
10543
+ summary: "Workspace info: versions, capabilities of the caller, usage, hosted execution configuration",
10544
+ options: [WORKSPACE_OPTION],
10545
+ inputSchema: workspaceInput({}),
10546
+ outputSchema: OBJECT_OUTPUT,
10547
+ resultSchemaVersion: 1,
10548
+ access: { mode: "fixed", level: "read" },
10549
+ asyncMode: "sync",
10550
+ requiresSession: true,
10551
+ examples: ["buckyos aiws info --workspace ws_abc"],
10552
+ handler: (ctx, input) => aiws(ctx, "ws.get_info", { workspace_id: requiredInputString(input, "workspace_id") })
10553
+ };
10554
+ const runGetCommand = {
10555
+ verb: "run-get",
10556
+ summary: "A wish run: state, execution context, the brief an executor starts from, candidate and preview",
10557
+ options: [WORKSPACE_OPTION, RUN_OPTION],
10558
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 } }, ["run_id"]),
10559
+ outputSchema: OBJECT_OUTPUT,
10560
+ resultSchemaVersion: 1,
10561
+ access: { mode: "fixed", level: "read" },
10562
+ asyncMode: "sync",
10563
+ requiresSession: true,
10564
+ examples: ["buckyos aiws run-get --workspace ws_abc --run run_xyz"],
10565
+ handler: (ctx, input) => aiws(ctx, "proc.get", { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id") })
10566
+ };
10567
+ const runClaimCommand = {
10568
+ verb: "run-claim",
10569
+ summary: "Take a run as its executor: starts an attempt, answers the attempt number, a run token and the lease",
10570
+ options: [WORKSPACE_OPTION, RUN_OPTION, { name: "claim-token", property: "claim_token", description: "The claim token the run was dispatched with (ct_…)", type: "string", required: true, secret: true }],
10571
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, claim_token: { type: "string", minLength: 1 } }, ["run_id", "claim_token"]),
10572
+ outputSchema: OBJECT_OUTPUT,
10573
+ resultSchemaVersion: 1,
10574
+ access: { mode: "fixed", level: "write" },
10575
+ asyncMode: "sync",
10576
+ requiresSession: true,
10577
+ examples: ["buckyos aiws run-claim --workspace ws_abc --run run_xyz --claim-token ct_…"],
10578
+ handler: (ctx, input) => aiws(ctx, "proc.claim", {
10579
+ workspace_id: requiredInputString(input, "workspace_id"),
10580
+ run_id: requiredInputString(input, "run_id"),
10581
+ claim_token: requiredInputString(input, "claim_token"),
10582
+ executor: { kind: "agent", principal: ctx.principal.id }
10583
+ })
10584
+ };
10585
+ const runHeartbeatCommand = {
10586
+ verb: "run-heartbeat",
10587
+ summary: "Keep the lease of a claimed run alive (every minute while working); optionally report progress",
10588
+ options: [WORKSPACE_OPTION, RUN_OPTION, ATTEMPT_OPTION, { name: "phase", property: "phase", description: 'A short progress phase, e.g. "reading inputs"', type: "string" }],
10589
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, attempt: { type: "integer", minimum: 1 }, phase: { type: "string" } }, ["run_id", "attempt"]),
10590
+ outputSchema: OBJECT_OUTPUT,
10591
+ resultSchemaVersion: 1,
10592
+ access: { mode: "fixed", level: "write" },
10593
+ asyncMode: "sync",
10594
+ requiresSession: true,
10595
+ examples: ['buckyos aiws run-heartbeat --workspace ws_abc --run run_xyz --attempt 1 --phase "reading inputs"'],
10596
+ handler: (ctx, input) => {
10597
+ const phase = inputString(input, "phase");
10598
+ return aiws(ctx, "proc.heartbeat", { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id"), attempt: input.attempt, ...phase ? { progress: { phase } } : {} });
10599
+ }
10600
+ };
10601
+ const runFilesCommand = {
10602
+ verb: "run-files",
10603
+ summary: "Write the stage of a claimed run into a directory: the snapshot (context/), request.json, the Renderer catalog and the program host (lib/)",
10604
+ description: "Run the program there the way the service does: `deno run -A lib/run.js` reads program/main.js and writes output/.aiws/results.json.",
10605
+ options: [WORKSPACE_OPTION, RUN_OPTION, ATTEMPT_OPTION, { name: "dir", property: "dir", description: "Directory to write into (created)", type: "string", required: true }],
10606
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, attempt: { type: "integer", minimum: 1 }, dir: { type: "string", minLength: 1 } }, ["run_id", "attempt", "dir"]),
10607
+ outputSchema: { type: "object", properties: { dir: { type: "string" }, files: { type: "array", items: { type: "string" } } }, required: ["dir", "files"], additionalProperties: true },
10608
+ resultSchemaVersion: 1,
10609
+ access: { mode: "fixed", level: "read" },
10610
+ asyncMode: "sync",
10611
+ requiresSession: true,
10612
+ examples: ["buckyos aiws run-files --workspace ws_abc --run run_xyz --attempt 1 --dir work"],
10613
+ handler: async (ctx, input) => {
10614
+ const result = await aiws(ctx, "proc.files", { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id"), attempt: input.attempt });
10615
+ const dir = requiredInputString(input, "dir");
10616
+ const host2 = getHost();
10617
+ const written = [];
10618
+ for (const [path, file] of Object.entries(expectObject$4(result.files, "proc.files.files"))) {
10619
+ const f = expectObject$4(file, path);
10620
+ if (typeof f.text !== "string" && typeof f.base64 !== "string")
10621
+ continue;
10622
+ const target = `${dir}/${path}`;
10623
+ await host2.mkdir(target.slice(0, target.lastIndexOf("/")), { recursive: true });
10624
+ if (typeof f.text === "string")
10625
+ await host2.writeTextFile(target, f.text);
10626
+ else
10627
+ await host2.writeFile(target, Uint8Array.from(atob(f.base64), (c) => c.charCodeAt(0)));
10628
+ written.push(path);
10629
+ }
10630
+ await host2.mkdir(`${dir}/output`, { recursive: true });
10631
+ await host2.mkdir(`${dir}/program`, { recursive: true });
10632
+ return { dir, files: written };
10633
+ }
10634
+ };
10635
+ const runToolCommand = {
10636
+ verb: "run-tool",
10637
+ summary: "Call one stage tool of a claimed run (ws_profile, ws_read, ws_query, submit_analysis, put_result, check_results, finish, …): the service answers as it answers the model",
10638
+ options: [WORKSPACE_OPTION, RUN_OPTION, ATTEMPT_OPTION, { name: "name", property: "name", description: "Tool name (the claim answered the list, with their argument schemas)", type: "string", required: true }, { name: "args", property: "args", description: "Arguments JSON", type: "string" }, { name: "args-file", property: "args_file", description: "Path of a JSON file holding the arguments", type: "string" }],
10639
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, attempt: { type: "integer", minimum: 1 }, name: { type: "string", minLength: 1 }, args: { type: "string" }, args_file: { type: "string" } }, ["run_id", "attempt", "name"]),
10640
+ outputSchema: OBJECT_OUTPUT,
10641
+ resultSchemaVersion: 1,
10642
+ access: { mode: "fixed", level: "write" },
10643
+ asyncMode: "sync",
10644
+ requiresSession: true,
10645
+ examples: [`buckyos aiws run-tool --workspace ws_abc --run run_xyz --attempt 1 --name ws_profile --args '{"target":"@B1"}'`, `buckyos aiws run-tool --workspace ws_abc --run run_xyz --attempt 1 --name finish --args '{"summary":"done"}'`],
10646
+ handler: async (ctx, input) => {
10647
+ const args = inputString(input, "args") || inputString(input, "args_file") ? await jsonInput(input, "args", "args_file", "arguments") : {};
10648
+ return aiws(ctx, "proc.tool", { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id"), attempt: input.attempt, name: requiredInputString(input, "name"), args });
10649
+ }
10650
+ };
10651
+ const runProgramCommand = {
10652
+ verb: "run-program",
10653
+ summary: "Hand in a program run: the program source, what lib/run.js wrote to output/.aiws/results.json, the files under output/ and the log; the service validates it like its own run_program",
10654
+ options: [
10655
+ WORKSPACE_OPTION,
10656
+ RUN_OPTION,
10657
+ ATTEMPT_OPTION,
10658
+ { name: "dir", property: "dir", description: "The stage directory written by run-files (program/main.js, output/)", type: "string", required: true },
10659
+ { name: "log-file", property: "log_file", description: "Path of the program log to attach (stdout/stderr of deno run)", type: "string" }
10660
+ ],
10661
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, attempt: { type: "integer", minimum: 1 }, dir: { type: "string", minLength: 1 }, log_file: { type: "string" } }, ["run_id", "attempt", "dir"]),
10662
+ outputSchema: OBJECT_OUTPUT,
10663
+ resultSchemaVersion: 1,
10664
+ access: { mode: "fixed", level: "write" },
10665
+ asyncMode: "sync",
10666
+ requiresSession: true,
10667
+ examples: ["buckyos aiws run-program --workspace ws_abc --run run_xyz --attempt 1 --dir work --log-file work/run.log"],
10668
+ handler: async (ctx, input) => {
10669
+ const dir = requiredInputString(input, "dir");
10670
+ const host2 = getHost();
10671
+ const source = await host2.readTextFile(`${dir}/program/main.js`);
10672
+ let results = null;
10673
+ try {
10674
+ results = JSON.parse(await host2.readTextFile(`${dir}/output/.aiws/results.json`));
10675
+ } catch {
10676
+ results = null;
10677
+ }
10678
+ const logFile = inputString(input, "log_file");
10679
+ const log = logFile ? await host2.readTextFile(logFile).catch(() => "") : "";
10680
+ const files = {};
10681
+ const walk = async (rel) => {
10682
+ for (const entry of await host2.readDir(`${dir}/output${rel ? `/${rel}` : ""}`)) {
10683
+ const name = rel ? `${rel}/${entry.name}` : entry.name;
10684
+ if (name === ".aiws" || name.startsWith(".aiws/"))
10685
+ continue;
10686
+ if (entry.isDirectory)
10687
+ await walk(name);
10688
+ else {
10689
+ const bytes = await host2.readFile(`${dir}/output/${name}`);
10690
+ let text2 = null;
10691
+ try {
10692
+ text2 = bytes.includes(0) ? null : new TextDecoder("utf-8", { fatal: true }).decode(bytes);
10693
+ } catch {
10694
+ text2 = null;
10695
+ }
10696
+ files[`output/${name}`] = text2 ?? { base64: btoa(Array.from(bytes, (b) => String.fromCharCode(b)).join("")) };
10697
+ }
10698
+ }
10699
+ };
10700
+ await walk("");
10701
+ return aiws(ctx, "proc.program", { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id"), attempt: input.attempt, source, results, log, files });
10702
+ }
10703
+ };
10704
+ const runReportCommand = {
10705
+ verb: "run-report",
10706
+ summary: "End a claimed run: --finished after the stage tools accepted the work (submit_analysis / finish), or the candidate itself (results / analysis), or a failure",
10707
+ description: "The service validates and plans what is reported; the user confirms it in the workspace. A superseded attempt or a cancelled run gets RUN_REVOKED.",
10708
+ options: [
10709
+ WORKSPACE_OPTION,
10710
+ RUN_OPTION,
10711
+ ATTEMPT_OPTION,
10712
+ { name: "finished", property: "finished", description: "The stage is done: what the tools collected becomes the candidate", type: "boolean" },
10713
+ { name: "results", property: "results", description: "Results JSON array (execute runs): [{ name, type, title?, content, config? }]", type: "string" },
10714
+ { name: "results-file", property: "results_file", description: "Path of a JSON file holding the results array", type: "string" },
10715
+ { name: "analysis", property: "analysis", description: "Analysis JSON (analyze runs, wish.analysis.v2)", type: "string" },
10716
+ { name: "analysis-file", property: "analysis_file", description: "Path of a JSON file holding the analysis", type: "string" },
10717
+ { name: "summary", property: "summary", description: "One paragraph on what was done", type: "string" },
10718
+ { name: "warning", property: "warnings", description: "A warning for the user (repeatable)", type: "string" },
10719
+ { name: "error", property: "error", description: "Report a failure instead: its reason", type: "string" }
10720
+ ],
10721
+ inputSchema: workspaceInput({ run_id: { type: "string", minLength: 1 }, attempt: { type: "integer", minimum: 1 }, finished: { type: "boolean" }, results: { type: "string" }, results_file: { type: "string" }, analysis: { type: "string" }, analysis_file: { type: "string" }, summary: { type: "string" }, warnings: { type: "string" }, error: { type: "string" } }, ["run_id", "attempt"]),
10722
+ outputSchema: OBJECT_OUTPUT,
10723
+ resultSchemaVersion: 1,
10724
+ access: { mode: "fixed", level: "write" },
10725
+ asyncMode: "sync",
10726
+ requiresSession: true,
10727
+ examples: [
10728
+ "buckyos aiws run-report --workspace ws_abc --run run_xyz --attempt 1 --finished",
10729
+ 'buckyos aiws run-report --workspace ws_abc --run run_xyz --attempt 1 --results-file out/results.json --summary "monthly totals and a commentary"',
10730
+ "buckyos aiws run-report --workspace ws_abc --run run_xyz --attempt 1 --analysis-file out/analysis.json",
10731
+ 'buckyos aiws run-report --workspace ws_abc --run run_xyz --attempt 1 --error "the input table is empty"'
10732
+ ],
10733
+ handler: async (ctx, input) => {
10734
+ const params = { workspace_id: requiredInputString(input, "workspace_id"), run_id: requiredInputString(input, "run_id"), attempt: input.attempt };
10735
+ const error = inputString(input, "error");
10736
+ if (error) {
10737
+ params.error = { code: "EXECUTOR_FAILED", detail: error };
10738
+ } else if (input.finished === true) {
10739
+ params.finished = true;
10740
+ } else if (inputString(input, "analysis") || inputString(input, "analysis_file")) {
10741
+ params.analysis = await jsonInput(input, "analysis", "analysis_file", "an analysis");
10742
+ } else {
10743
+ params.results = await jsonInput(input, "results", "results_file", "results");
10744
+ params.read_set = [];
10745
+ }
10746
+ const summary2 = inputString(input, "summary");
10747
+ if (summary2)
10748
+ params.summary = summary2;
10749
+ const warning = inputString(input, "warnings");
10750
+ if (warning)
10751
+ params.warnings = [warning];
10752
+ return aiws(ctx, "proc.report", params);
10753
+ }
10754
+ };
10755
+ function createAiwsModule() {
10756
+ return {
10757
+ name: "aiws",
10758
+ summary: "AI Workspace: read a workspace, and execute wish runs as their executor (claim, heartbeat, report)",
10759
+ commands: [infoCommand, readCommand, queryCommand, runGetCommand, runClaimCommand, runHeartbeatCommand, runFilesCommand, runToolCommand, runProgramCommand, runReportCommand]
10760
+ };
10761
+ }
10343
10762
  const VERSION = TOOL_VERSION;
10344
10763
  class BuckyOSToolApplication {
10345
10764
  #environment;
@@ -10707,6 +11126,8 @@ function createRegistry(pikgDependencies, appDependencies, logDependencies, diag
10707
11126
  registry.register(createAgentModule());
10708
11127
  registry.register(createAiModule());
10709
11128
  registry.register(createShareModule());
11129
+ registry.register(createExecutorModule());
11130
+ registry.register(createAiwsModule());
10710
11131
  return registry;
10711
11132
  }
10712
11133
  function assertNoSessionOptions(global, command) {
@@ -10812,8 +11233,8 @@ async function runCli(host2, argv) {
10812
11233
  installHost(host2);
10813
11234
  return await new BuckyOSToolApplication().run(argv);
10814
11235
  }
10815
- async function assertPathAccess(policy2, path, realPath, candidate, operation, resolveLinks = true) {
10816
- const roots = operation === "read" ? policy2.readPaths : policy2.writePaths;
11236
+ async function assertPathAccess(policy2, path, realPath, candidate, operation2, resolveLinks = true) {
11237
+ const roots = operation2 === "read" ? policy2.readPaths : policy2.writePaths;
10817
11238
  const absolute = path.resolve(candidate);
10818
11239
  const physicalRoots = [];
10819
11240
  for (const root of roots) {
@@ -10827,7 +11248,7 @@ async function assertPathAccess(policy2, path, realPath, candidate, operation, r
10827
11248
  if (!insideAny(absolute, roots, path) && !insideAny(absolute, physicalRoots, path)) {
10828
11249
  throw new HostError(
10829
11250
  "PermissionDenied",
10830
- `${operation} access is outside ${policy2.name}: ${absolute}`,
11251
+ `${operation2} access is outside ${policy2.name}: ${absolute}`,
10831
11252
  absolute
10832
11253
  );
10833
11254
  }
@@ -10838,7 +11259,7 @@ async function assertPathAccess(policy2, path, realPath, candidate, operation, r
10838
11259
  if (!insideAny(physical, physicalRoots, path)) {
10839
11260
  throw new HostError(
10840
11261
  "PermissionDenied",
10841
- `${operation} access escapes ${policy2.name}: ${absolute}`,
11262
+ `${operation2} access escapes ${policy2.name}: ${absolute}`,
10842
11263
  absolute
10843
11264
  );
10844
11265
  }
@@ -11034,8 +11455,8 @@ class NodeHost {
11034
11455
  throw translateNodeError(error, path);
11035
11456
  }
11036
11457
  }
11037
- async assertAccess(path, operation) {
11038
- await this.assertPath(path, operation);
11458
+ async assertAccess(path, operation2) {
11459
+ await this.assertPath(path, operation2);
11039
11460
  }
11040
11461
  createHash(_algorithm) {
11041
11462
  const hash = createHash("sha256");
@@ -11162,7 +11583,7 @@ class NodeHost {
11162
11583
  throw new HostError("PermissionDenied", `subprocess is not allowed: ${command}`);
11163
11584
  }
11164
11585
  }
11165
- async assertPath(candidate, operation, resolveLinks = true) {
11586
+ async assertPath(candidate, operation2, resolveLinks = true) {
11166
11587
  await assertPathAccess(
11167
11588
  this.policy,
11168
11589
  nodePath,
@@ -11174,7 +11595,7 @@ class NodeHost {
11174
11595
  }
11175
11596
  },
11176
11597
  candidate,
11177
- operation,
11598
+ operation2,
11178
11599
  resolveLinks
11179
11600
  );
11180
11601
  }