buckyos 0.7.148 → 0.7.149

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 (40) hide show
  1. package/cli/core/app.ts +2 -0
  2. package/cli/dist/cli.mjs +543 -83
  3. package/cli/dist/cli.mjs.map +1 -1
  4. package/cli/modules/bucket.ts +396 -0
  5. package/cli/modules/pikg_protocol.ts +67 -0
  6. package/cli/version.ts +1 -1
  7. package/dist/browser.cjs +1 -1
  8. package/dist/browser.cjs.map +1 -1
  9. package/dist/browser.d.ts +2 -0
  10. package/dist/browser.d.ts.map +1 -1
  11. package/dist/browser.mjs +190 -189
  12. package/dist/browser.mjs.map +1 -1
  13. package/dist/bucket_client.d.ts +344 -0
  14. package/dist/bucket_client.d.ts.map +1 -0
  15. package/dist/{executor_client-4fbf0c3c.mjs → executor_client-06dad8a8.mjs} +434 -192
  16. package/dist/executor_client-06dad8a8.mjs.map +1 -0
  17. package/dist/executor_client-d7fc4a8b.js +13 -0
  18. package/dist/executor_client-d7fc4a8b.js.map +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.mjs +195 -192
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/ndm_client.d.ts +30 -0
  26. package/dist/ndm_client.d.ts.map +1 -1
  27. package/dist/node.cjs +1 -1
  28. package/dist/node.cjs.map +1 -1
  29. package/dist/node.d.ts +2 -0
  30. package/dist/node.d.ts.map +1 -1
  31. package/dist/node.mjs +190 -189
  32. package/dist/node.mjs.map +1 -1
  33. package/dist/runtime.d.ts +2 -0
  34. package/dist/runtime.d.ts.map +1 -1
  35. package/dist/sdk_core.d.ts +4 -0
  36. package/dist/sdk_core.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/executor_client-4fbf0c3c.mjs.map +0 -1
  39. package/dist/executor_client-5fa2d501.js +0 -13
  40. package/dist/executor_client-5fa2d501.js.map +0 -1
package/cli/dist/cli.mjs CHANGED
@@ -2498,7 +2498,7 @@ function replPrompt(config) {
2498
2498
  return `buckyos[${profile}|${zone}|${identity}]> `;
2499
2499
  }
2500
2500
  const EMPTY_INPUT$3 = { type: "object", properties: {}, additionalProperties: false };
2501
- const OBJECT_OUTPUT$d = { type: "object", additionalProperties: true };
2501
+ const OBJECT_OUTPUT$e = { type: "object", additionalProperties: true };
2502
2502
  function createAuthModule() {
2503
2503
  return {
2504
2504
  name: "auth",
@@ -2508,7 +2508,7 @@ function createAuthModule() {
2508
2508
  verb: "whoami",
2509
2509
  summary: "Show the effective principal and application identity",
2510
2510
  inputSchema: EMPTY_INPUT$3,
2511
- outputSchema: OBJECT_OUTPUT$d,
2511
+ outputSchema: OBJECT_OUTPUT$e,
2512
2512
  resultSchemaVersion: 1,
2513
2513
  access: { mode: "fixed", level: "read" },
2514
2514
  asyncMode: "sync",
@@ -2526,7 +2526,7 @@ function createAuthModule() {
2526
2526
  verb: "session-status",
2527
2527
  summary: "Show the in-memory session state without exposing credentials",
2528
2528
  inputSchema: EMPTY_INPUT$3,
2529
- outputSchema: OBJECT_OUTPUT$d,
2529
+ outputSchema: OBJECT_OUTPUT$e,
2530
2530
  resultSchemaVersion: 1,
2531
2531
  access: { mode: "fixed", level: "read" },
2532
2532
  asyncMode: "sync",
@@ -2547,7 +2547,7 @@ const EMPTY_INPUT$2 = {
2547
2547
  properties: {},
2548
2548
  additionalProperties: false
2549
2549
  };
2550
- const OBJECT_OUTPUT$c = { type: "object", additionalProperties: true };
2550
+ const OBJECT_OUTPUT$d = { type: "object", additionalProperties: true };
2551
2551
  function createCoreModules(registry) {
2552
2552
  return [createCommandModule(registry), createConfigModule(), createCompletionModule(registry)];
2553
2553
  }
@@ -2560,7 +2560,7 @@ function createCommandModule(registry) {
2560
2560
  verb: "list",
2561
2561
  summary: "List registered modules and commands",
2562
2562
  inputSchema: EMPTY_INPUT$2,
2563
- outputSchema: OBJECT_OUTPUT$c,
2563
+ outputSchema: OBJECT_OUTPUT$d,
2564
2564
  resultSchemaVersion: 1,
2565
2565
  access: { mode: "fixed", level: "read" },
2566
2566
  asyncMode: "sync",
@@ -2593,7 +2593,7 @@ function createCommandModule(registry) {
2593
2593
  required: ["target_module", "target_verb"],
2594
2594
  additionalProperties: false
2595
2595
  },
2596
- outputSchema: OBJECT_OUTPUT$c,
2596
+ outputSchema: OBJECT_OUTPUT$d,
2597
2597
  resultSchemaVersion: 1,
2598
2598
  access: { mode: "fixed", level: "read" },
2599
2599
  asyncMode: "sync",
@@ -2615,7 +2615,7 @@ function createConfigModule() {
2615
2615
  verb: "list",
2616
2616
  summary: "List the global configuration and available profiles",
2617
2617
  inputSchema: EMPTY_INPUT$2,
2618
- outputSchema: OBJECT_OUTPUT$c,
2618
+ outputSchema: OBJECT_OUTPUT$d,
2619
2619
  resultSchemaVersion: 1,
2620
2620
  access: { mode: "fixed", level: "read" },
2621
2621
  asyncMode: "sync",
@@ -2646,7 +2646,7 @@ function createConfigModule() {
2646
2646
  },
2647
2647
  additionalProperties: false
2648
2648
  },
2649
- outputSchema: OBJECT_OUTPUT$c,
2649
+ outputSchema: OBJECT_OUTPUT$d,
2650
2650
  resultSchemaVersion: 1,
2651
2651
  access: { mode: "fixed", level: "read" },
2652
2652
  asyncMode: "sync",
@@ -2692,7 +2692,7 @@ function createConfigModule() {
2692
2692
  required: ["key", "value"],
2693
2693
  additionalProperties: false
2694
2694
  },
2695
- outputSchema: OBJECT_OUTPUT$c,
2695
+ outputSchema: OBJECT_OUTPUT$d,
2696
2696
  resultSchemaVersion: 1,
2697
2697
  access: { mode: "fixed", level: "write" },
2698
2698
  asyncMode: "sync",
@@ -2732,7 +2732,7 @@ function createConfigModule() {
2732
2732
  required: ["profile_name"],
2733
2733
  additionalProperties: false
2734
2734
  },
2735
- outputSchema: OBJECT_OUTPUT$c,
2735
+ outputSchema: OBJECT_OUTPUT$d,
2736
2736
  resultSchemaVersion: 1,
2737
2737
  access: { mode: "fixed", level: "write" },
2738
2738
  asyncMode: "sync",
@@ -2764,7 +2764,7 @@ function createConfigModule() {
2764
2764
  properties: { effective: { type: "boolean" } },
2765
2765
  additionalProperties: false
2766
2766
  },
2767
- outputSchema: OBJECT_OUTPUT$c,
2767
+ outputSchema: OBJECT_OUTPUT$d,
2768
2768
  resultSchemaVersion: 1,
2769
2769
  access: { mode: "fixed", level: "read" },
2770
2770
  asyncMode: "sync",
@@ -3006,7 +3006,7 @@ async function buckyosInfo(ctx) {
3006
3006
  );
3007
3007
  }
3008
3008
  const SERVICE_NAME = "system_config";
3009
- const OBJECT_OUTPUT$b = { type: "object", additionalProperties: false };
3009
+ const OBJECT_OUTPUT$c = { type: "object", additionalProperties: false };
3010
3010
  const KEY_INPUT = {
3011
3011
  type: "object",
3012
3012
  properties: { key: { type: "string", minLength: 1 } },
@@ -3024,7 +3024,7 @@ function createSystemConfigModule() {
3024
3024
  positionals: [{ name: "key", description: "System-config key" }],
3025
3025
  inputSchema: KEY_INPUT,
3026
3026
  outputSchema: {
3027
- ...OBJECT_OUTPUT$b,
3027
+ ...OBJECT_OUTPUT$c,
3028
3028
  properties: {
3029
3029
  key: { type: "string" },
3030
3030
  value: { type: "string" },
@@ -3067,7 +3067,7 @@ function createSystemConfigModule() {
3067
3067
  additionalProperties: false
3068
3068
  },
3069
3069
  outputSchema: {
3070
- ...OBJECT_OUTPUT$b,
3070
+ ...OBJECT_OUTPUT$c,
3071
3071
  properties: {
3072
3072
  key: { type: "string" },
3073
3073
  items: { type: "array", items: { type: "string" } }
@@ -3121,7 +3121,7 @@ function setCommand() {
3121
3121
  additionalProperties: false
3122
3122
  },
3123
3123
  outputSchema: {
3124
- ...OBJECT_OUTPUT$b,
3124
+ ...OBJECT_OUTPUT$c,
3125
3125
  properties: { key: { type: "string" }, updated: { type: "boolean" } },
3126
3126
  required: ["key", "updated"]
3127
3127
  },
@@ -3160,7 +3160,7 @@ function setFileCommand() {
3160
3160
  additionalProperties: false
3161
3161
  },
3162
3162
  outputSchema: {
3163
- ...OBJECT_OUTPUT$b,
3163
+ ...OBJECT_OUTPUT$c,
3164
3164
  properties: { key: { type: "string" }, updated: { type: "boolean" } },
3165
3165
  required: ["key", "updated"]
3166
3166
  },
@@ -3197,7 +3197,7 @@ function mutationCommand(options) {
3197
3197
  additionalProperties: false
3198
3198
  },
3199
3199
  outputSchema: {
3200
- ...OBJECT_OUTPUT$b,
3200
+ ...OBJECT_OUTPUT$c,
3201
3201
  properties: {
3202
3202
  key: { type: "string" },
3203
3203
  [options.resultProperty]: { type: "boolean" }
@@ -4261,6 +4261,74 @@ function validatePermissions(value, label) {
4261
4261
  return raw;
4262
4262
  });
4263
4263
  }
4264
+ const BUCKET_POLICIES = ["documents", "app_data", "collected", "ambient", "temp", "cache"];
4265
+ function validateBuckets(config, label) {
4266
+ if (config.storage_quota_mib !== void 0) {
4267
+ expectUint(config.storage_quota_mib, `${label}.storage_quota_mib`, Number.MAX_SAFE_INTEGER);
4268
+ }
4269
+ let needsAppPool = false;
4270
+ for (const [name, raw] of Object.entries(expectObject$3(config.buckets ?? {}, `${label}.buckets`))) {
4271
+ const at = `${label}.buckets.${name}`;
4272
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(name) || name === "." || name === "..") {
4273
+ throw invalid("schema", `${at} is not a valid bucket name`);
4274
+ }
4275
+ const bucket = expectObject$3(raw, at);
4276
+ assertKnownFields(
4277
+ bucket,
4278
+ ["kind", "data_policy", "scope", "versioning", "quota_mib", "max_objects", "default_ttl_days", "lifecycle"],
4279
+ at
4280
+ );
4281
+ if (!["data", "object"].includes(String(bucket.kind)))
4282
+ throw invalid("schema", `${at}.kind is data or object`);
4283
+ const policy2 = String(bucket.data_policy);
4284
+ if (!BUCKET_POLICIES.includes(policy2))
4285
+ throw invalid("schema", `${at}.data_policy is invalid`);
4286
+ if (bucket.scope !== void 0 && !["user", "zone"].includes(String(bucket.scope))) {
4287
+ throw invalid("schema", `${at}.scope is user or zone`);
4288
+ }
4289
+ optionalBoolean(bucket.versioning, `${at}.versioning`);
4290
+ const userOwned = policy2 === "documents" || policy2 === "collected";
4291
+ if (bucket.quota_mib !== void 0) {
4292
+ expectUint(bucket.quota_mib, `${at}.quota_mib`, Number.MAX_SAFE_INTEGER);
4293
+ if (userOwned)
4294
+ throw invalid("schema", `${at}: a ${policy2} bucket uses the user's quota`);
4295
+ }
4296
+ if (bucket.max_objects !== void 0)
4297
+ expectUint(bucket.max_objects, `${at}.max_objects`, Number.MAX_SAFE_INTEGER);
4298
+ if (bucket.versioning === true && !["documents", "app_data", "collected"].includes(policy2)) {
4299
+ throw invalid("schema", `${at}: a ${policy2} bucket cannot be versioned`);
4300
+ }
4301
+ if (bucket.default_ttl_days !== void 0) {
4302
+ expectUint(bucket.default_ttl_days, `${at}.default_ttl_days`, 4294967295);
4303
+ if (!["ambient", "temp", "cache"].includes(policy2)) {
4304
+ throw invalid("schema", `${at}: a ${policy2} bucket cannot declare default_ttl_days`);
4305
+ }
4306
+ }
4307
+ if (policy2 === "temp") {
4308
+ const days = bucket.default_ttl_days;
4309
+ if (typeof days !== "number" || days < 1 || days > 30) {
4310
+ throw invalid("schema", `${at}: a temp bucket declares default_ttl_days 1..30`);
4311
+ }
4312
+ }
4313
+ if (bucket.lifecycle !== void 0) {
4314
+ if (!Array.isArray(bucket.lifecycle))
4315
+ throw invalid("schema", `${at}.lifecycle must be an array`);
4316
+ for (const [index, rule] of bucket.lifecycle.entries()) {
4317
+ const kind = String(expectObject$3(rule, `${at}.lifecycle[${index}]`).rule);
4318
+ if (!["expire", "noncurrent_expire", "expired_delete_marker"].includes(kind)) {
4319
+ throw invalid("schema", `${at}.lifecycle[${index}].rule is invalid`);
4320
+ }
4321
+ if (policy2 === "temp" || userOwned && kind !== "noncurrent_expire") {
4322
+ throw invalid("schema", `${at}: a ${policy2} bucket does not accept the ${kind} rule`);
4323
+ }
4324
+ }
4325
+ }
4326
+ needsAppPool ||= policy2 === "app_data" || policy2 === "temp";
4327
+ }
4328
+ if (needsAppPool && config.storage_quota_mib === void 0) {
4329
+ throw invalid("schema", `${label}.storage_quota_mib is required when app_data or temp buckets are declared`);
4330
+ }
4331
+ }
4264
4332
  function validateServiceConfigTips(value, label) {
4265
4333
  const config = expectObject$3(value, label);
4266
4334
  for (const field of [
@@ -4375,6 +4443,7 @@ function validateServiceConfigTips(value, label) {
4375
4443
  }
4376
4444
  optionalString$3(database.connection, `${label}.rdb_instances.${name}.connection`);
4377
4445
  }
4446
+ validateBuckets(config, label);
4378
4447
  if (config.instance_volume !== void 0) {
4379
4448
  const volume = expectObject$3(config.instance_volume, `${label}.instance_volume`);
4380
4449
  assertKnownFields(
@@ -5105,7 +5174,7 @@ function validateContentHandlers(value, permissions) {
5105
5174
  }
5106
5175
  return value;
5107
5176
  }
5108
- const PACKAGE_VERSION = "0.7.148";
5177
+ const PACKAGE_VERSION = "0.7.149";
5109
5178
  const TOOL_VERSION = PACKAGE_VERSION;
5110
5179
  const SDK_VERSION = PACKAGE_VERSION;
5111
5180
  const PROTOCOL_VERSION = "1";
@@ -5122,7 +5191,7 @@ const VERSION$1 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
5122
5191
  const SHA256_ID = /^sha256:[0-9a-f]{64}$/;
5123
5192
  const OBJECT_ID = /^(?:appdoc|pkg):[0-9a-f]{64}$/;
5124
5193
  const SAFE_GENERATED_FILE = /^[A-Za-z0-9._-]+$/;
5125
- const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
5194
+ const OBJECT_OUTPUT$b = { type: "object", additionalProperties: true };
5126
5195
  const APP_KINDS = ["static-web", "script", "docker", "agent-skills"];
5127
5196
  const PATH_KINDS = {
5128
5197
  "static-web": { key: "web", category: "web", selectorType: "static" },
@@ -5165,7 +5234,7 @@ function createPikgModule(dependencies = {}) {
5165
5234
  properties: { meta_dir: { type: "string", minLength: 1 } },
5166
5235
  additionalProperties: false
5167
5236
  },
5168
- outputSchema: OBJECT_OUTPUT$a,
5237
+ outputSchema: OBJECT_OUTPUT$b,
5169
5238
  resultSchemaVersion: 1,
5170
5239
  access: { mode: "fixed", level: "read" },
5171
5240
  asyncMode: "sync",
@@ -5212,7 +5281,7 @@ function createPikgModule(dependencies = {}) {
5212
5281
  },
5213
5282
  additionalProperties: false
5214
5283
  },
5215
- outputSchema: OBJECT_OUTPUT$a,
5284
+ outputSchema: OBJECT_OUTPUT$b,
5216
5285
  resultSchemaVersion: 1,
5217
5286
  access: { mode: "fixed", level: "write" },
5218
5287
  asyncMode: "sync",
@@ -5237,7 +5306,7 @@ function createPikgModule(dependencies = {}) {
5237
5306
  properties: { meta_dir: { type: "string", minLength: 1 } },
5238
5307
  additionalProperties: false
5239
5308
  },
5240
- outputSchema: OBJECT_OUTPUT$a,
5309
+ outputSchema: OBJECT_OUTPUT$b,
5241
5310
  resultSchemaVersion: 1,
5242
5311
  access: { mode: "fixed", level: "write" },
5243
5312
  asyncMode: "sync",
@@ -5258,7 +5327,7 @@ function createPikgModule(dependencies = {}) {
5258
5327
  properties: { dist_dir: { type: "string", minLength: 1 } },
5259
5328
  additionalProperties: false
5260
5329
  },
5261
- outputSchema: OBJECT_OUTPUT$a,
5330
+ outputSchema: OBJECT_OUTPUT$b,
5262
5331
  resultSchemaVersion: 1,
5263
5332
  access: { mode: "fixed", level: "write" },
5264
5333
  asyncMode: "sync",
@@ -5278,7 +5347,7 @@ function createPikgModule(dependencies = {}) {
5278
5347
  required: ["pikg_path"],
5279
5348
  additionalProperties: false
5280
5349
  },
5281
- outputSchema: OBJECT_OUTPUT$a,
5350
+ outputSchema: OBJECT_OUTPUT$b,
5282
5351
  resultSchemaVersion: 1,
5283
5352
  access: { mode: "fixed", level: "read" },
5284
5353
  asyncMode: "sync",
@@ -5299,7 +5368,7 @@ function createPikgModule(dependencies = {}) {
5299
5368
  properties: { meta_dir: { type: "string", minLength: 1 } },
5300
5369
  additionalProperties: false
5301
5370
  },
5302
- outputSchema: OBJECT_OUTPUT$a,
5371
+ outputSchema: OBJECT_OUTPUT$b,
5303
5372
  resultSchemaVersion: 1,
5304
5373
  access: { mode: "fixed", level: "destructive" },
5305
5374
  asyncMode: "sync",
@@ -6562,7 +6631,7 @@ const CONTROL_PANEL_SERVICE = "control-panel";
6562
6631
  const PLAN_SCHEMA_VERSION = 4;
6563
6632
  const STAGING_RELEASE_TIMEOUT_MS = 5e3;
6564
6633
  const ZIP_LOCAL_MAGIC = [80, 75, 3, 4];
6565
- const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
6634
+ const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
6566
6635
  const INSTALL_POLICIES = [
6567
6636
  "strict-public",
6568
6637
  "normal",
@@ -6574,7 +6643,7 @@ function createAppModule(dependencies = {}) {
6574
6643
  const commands = [
6575
6644
  fetchCommand(dependencies),
6576
6645
  listCommand$2(),
6577
- getCommand$2(),
6646
+ getCommand$3(),
6578
6647
  installCommand(dependencies),
6579
6648
  upgradeCommand(dependencies),
6580
6649
  uninstallCommand(dependencies),
@@ -6613,7 +6682,7 @@ function cancelCommand$1() {
6613
6682
  required: ["task_id"],
6614
6683
  additionalProperties: false
6615
6684
  },
6616
- outputSchema: OBJECT_OUTPUT$9,
6685
+ outputSchema: OBJECT_OUTPUT$a,
6617
6686
  resultSchemaVersion: 1,
6618
6687
  access: { mode: "fixed", level: "write" },
6619
6688
  asyncMode: "sync",
@@ -6648,7 +6717,7 @@ function fetchCommand(dependencies) {
6648
6717
  target: { type: "object", additionalProperties: true },
6649
6718
  install_params: { type: "object", additionalProperties: true }
6650
6719
  }),
6651
- outputSchema: OBJECT_OUTPUT$9,
6720
+ outputSchema: OBJECT_OUTPUT$a,
6652
6721
  resultSchemaVersion: 1,
6653
6722
  access: { mode: "fixed", level: "read" },
6654
6723
  asyncMode: "sync",
@@ -6665,7 +6734,7 @@ function listCommand$2() {
6665
6734
  verb: "list",
6666
6735
  summary: "List visible installed Apps",
6667
6736
  inputSchema: emptyInputSchema(),
6668
- outputSchema: OBJECT_OUTPUT$9,
6737
+ outputSchema: OBJECT_OUTPUT$a,
6669
6738
  resultSchemaVersion: 1,
6670
6739
  access: { mode: "fixed", level: "read" },
6671
6740
  asyncMode: "sync",
@@ -6674,7 +6743,7 @@ function listCommand$2() {
6674
6743
  handler: async (ctx) => await callControl(ctx, "apps.list", {})
6675
6744
  };
6676
6745
  }
6677
- function getCommand$2() {
6746
+ function getCommand$3() {
6678
6747
  return selectorCommand({
6679
6748
  verb: "get",
6680
6749
  summary: "Get installation and runtime details for one App",
@@ -6723,7 +6792,7 @@ function installCommand(dependencies) {
6723
6792
  no_wait: { type: "boolean" },
6724
6793
  policy: { type: "string", enum: [...INSTALL_POLICIES] }
6725
6794
  }),
6726
- outputSchema: OBJECT_OUTPUT$9,
6795
+ outputSchema: OBJECT_OUTPUT$a,
6727
6796
  resultSchemaVersion: 1,
6728
6797
  access: { mode: "fixed", level: "write" },
6729
6798
  asyncMode: "either",
@@ -6767,7 +6836,7 @@ function upgradeCommand(dependencies) {
6767
6836
  },
6768
6837
  additionalProperties: false
6769
6838
  },
6770
- outputSchema: OBJECT_OUTPUT$9,
6839
+ outputSchema: OBJECT_OUTPUT$a,
6771
6840
  resultSchemaVersion: 1,
6772
6841
  access: { mode: "fixed", level: "write" },
6773
6842
  asyncMode: "either",
@@ -6896,7 +6965,7 @@ function statusCommand$1() {
6896
6965
  properties: { app_name: { type: "string", minLength: 1 } },
6897
6966
  additionalProperties: false
6898
6967
  },
6899
- outputSchema: OBJECT_OUTPUT$9,
6968
+ outputSchema: OBJECT_OUTPUT$a,
6900
6969
  resultSchemaVersion: 1,
6901
6970
  access: { mode: "fixed", level: "read" },
6902
6971
  asyncMode: "sync",
@@ -6967,7 +7036,7 @@ function publishCommand() {
6967
7036
  required: ["local_dir", "app_doc"],
6968
7037
  additionalProperties: false
6969
7038
  },
6970
- outputSchema: OBJECT_OUTPUT$9,
7039
+ outputSchema: OBJECT_OUTPUT$a,
6971
7040
  resultSchemaVersion: 1,
6972
7041
  access: { mode: "fixed", level: "write" },
6973
7042
  asyncMode: "sync",
@@ -7484,7 +7553,7 @@ async function stagePikg(ctx, snapshot, purpose) {
7484
7553
  throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
7485
7554
  const token = (await session.ensureValid()).token;
7486
7555
  const proxy = ndm_proxy.createNdmProxyClient({
7487
- endpoint: gatewayOrigin$1(ctx.connection.endpoint),
7556
+ endpoint: gatewayOrigin$2(ctx.connection.endpoint),
7488
7557
  sessionToken: token,
7489
7558
  fetcher: (request, init) => fetch(normalizeNdmRequestUrl(request), { ...init, signal: ctx.signal })
7490
7559
  });
@@ -8021,7 +8090,7 @@ function validatePikgSnapshot(bytes) {
8021
8090
  throw new UsageError("INVALID_PIKG", "PIKG magic mismatch: expected a ZIP container");
8022
8091
  }
8023
8092
  }
8024
- function gatewayOrigin$1(endpoint) {
8093
+ function gatewayOrigin$2(endpoint) {
8025
8094
  const url = new URL(endpoint);
8026
8095
  const marker = url.pathname.indexOf("/kapi");
8027
8096
  url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
@@ -8093,7 +8162,7 @@ function selectorCommand(options) {
8093
8162
  required: ["app_name"],
8094
8163
  additionalProperties: false
8095
8164
  },
8096
- outputSchema: OBJECT_OUTPUT$9,
8165
+ outputSchema: OBJECT_OUTPUT$a,
8097
8166
  resultSchemaVersion: 1,
8098
8167
  access: { mode: "fixed", level: options.access },
8099
8168
  asyncMode: options.asyncMode,
@@ -8257,7 +8326,7 @@ function toHex(bytes) {
8257
8326
  return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
8258
8327
  }
8259
8328
  const CONTROL_PANEL$3 = "control-panel";
8260
- const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
8329
+ const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
8261
8330
  function createDiagnosticModule(dependencies = {}) {
8262
8331
  return {
8263
8332
  name: "diagnostic",
@@ -8296,7 +8365,7 @@ function collectCommand() {
8296
8365
  required: ["services"],
8297
8366
  additionalProperties: false
8298
8367
  },
8299
- outputSchema: OBJECT_OUTPUT$8,
8368
+ outputSchema: OBJECT_OUTPUT$9,
8300
8369
  resultSchemaVersion: 1,
8301
8370
  access: { mode: "fixed", level: "privileged" },
8302
8371
  asyncMode: "task",
@@ -8350,7 +8419,7 @@ function exportCommand$1(dependencies) {
8350
8419
  required: ["bundle_id", "path"],
8351
8420
  additionalProperties: false
8352
8421
  },
8353
- outputSchema: OBJECT_OUTPUT$8,
8422
+ outputSchema: OBJECT_OUTPUT$9,
8354
8423
  resultSchemaVersion: 1,
8355
8424
  access: { mode: "fixed", level: "privileged" },
8356
8425
  asyncMode: "sync",
@@ -8392,7 +8461,7 @@ function compact$2(value) {
8392
8461
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
8393
8462
  }
8394
8463
  const CONTROL_PANEL$2 = "control-panel";
8395
- const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8464
+ const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
8396
8465
  const LOG_LEVELS = ["error", "warning", "info", "debug", "trace"];
8397
8466
  function createLogModule(dependencies = {}) {
8398
8467
  return {
@@ -8413,7 +8482,7 @@ function servicesCommand() {
8413
8482
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
8414
8483
  outputSchema: {
8415
8484
  type: "object",
8416
- properties: { services: { type: "array", items: OBJECT_OUTPUT$7 } },
8485
+ properties: { services: { type: "array", items: OBJECT_OUTPUT$8 } },
8417
8486
  required: ["services"],
8418
8487
  additionalProperties: false
8419
8488
  },
@@ -8486,7 +8555,7 @@ function tailCommand(dependencies) {
8486
8555
  }
8487
8556
  ],
8488
8557
  inputSchema: filterSchema({ from: { type: "string", enum: ["start", "end"] } }),
8489
- outputSchema: OBJECT_OUTPUT$7,
8558
+ outputSchema: OBJECT_OUTPUT$8,
8490
8559
  resultSchemaVersion: 1,
8491
8560
  access: { mode: "fixed", level: "read" },
8492
8561
  asyncMode: "stream",
@@ -8542,7 +8611,7 @@ function exportCommand(dependencies) {
8542
8611
  ...filterSchema({ path: { type: "string", minLength: 1 } }),
8543
8612
  required: ["path"]
8544
8613
  },
8545
- outputSchema: OBJECT_OUTPUT$7,
8614
+ outputSchema: OBJECT_OUTPUT$8,
8546
8615
  resultSchemaVersion: 1,
8547
8616
  access: { mode: "fixed", level: "read" },
8548
8617
  asyncMode: "sync",
@@ -8694,12 +8763,12 @@ function abortableSleep(milliseconds, signal) {
8694
8763
  }
8695
8764
  const TASK_MANAGER = "task-manager";
8696
8765
  const CONTROL_PANEL$1 = "control-panel";
8697
- const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
8766
+ const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8698
8767
  function createTaskModule() {
8699
8768
  return {
8700
8769
  name: "task",
8701
8770
  summary: "Inspect, wait for, cancel, and retry durable Tasks",
8702
- commands: [listCommand$1(), getCommand$1(), waitCommand(), cancelCommand(), retryCommand()]
8771
+ commands: [listCommand$1(), getCommand$2(), waitCommand(), cancelCommand(), retryCommand()]
8703
8772
  };
8704
8773
  }
8705
8774
  function listCommand$1() {
@@ -8768,7 +8837,7 @@ function listCommand$1() {
8768
8837
  }
8769
8838
  };
8770
8839
  }
8771
- function getCommand$1() {
8840
+ function getCommand$2() {
8772
8841
  return {
8773
8842
  verb: "get",
8774
8843
  summary: "Get one Task snapshot and its direct children",
@@ -8797,7 +8866,7 @@ function getCommand$1() {
8797
8866
  required: ["task_id"],
8798
8867
  additionalProperties: false
8799
8868
  },
8800
- outputSchema: OBJECT_OUTPUT$6,
8869
+ outputSchema: OBJECT_OUTPUT$7,
8801
8870
  resultSchemaVersion: 1,
8802
8871
  access: { mode: "fixed", level: "read" },
8803
8872
  asyncMode: "sync",
@@ -8838,7 +8907,7 @@ function waitCommand() {
8838
8907
  summary: "Stream changes until a Task becomes terminal",
8839
8908
  positionals: [{ name: "task_id", description: "Opaque Task ID", required: true }],
8840
8909
  inputSchema: taskIdSchema(),
8841
- outputSchema: OBJECT_OUTPUT$6,
8910
+ outputSchema: OBJECT_OUTPUT$7,
8842
8911
  resultSchemaVersion: 1,
8843
8912
  access: { mode: "fixed", level: "read" },
8844
8913
  asyncMode: "stream",
@@ -8889,7 +8958,7 @@ function cancelCommand() {
8889
8958
  required: ["task_id"],
8890
8959
  additionalProperties: false
8891
8960
  },
8892
- outputSchema: OBJECT_OUTPUT$6,
8961
+ outputSchema: OBJECT_OUTPUT$7,
8893
8962
  resultSchemaVersion: 1,
8894
8963
  access: { mode: "fixed", level: "write" },
8895
8964
  asyncMode: "sync",
@@ -8932,7 +9001,7 @@ function retryCommand() {
8932
9001
  required: ["task_id"],
8933
9002
  additionalProperties: false
8934
9003
  },
8935
- outputSchema: OBJECT_OUTPUT$6,
9004
+ outputSchema: OBJECT_OUTPUT$7,
8936
9005
  resultSchemaVersion: 1,
8937
9006
  access: { mode: "fixed", level: "write" },
8938
9007
  asyncMode: "either",
@@ -9006,7 +9075,7 @@ function invalidResponse$1(label) {
9006
9075
  throw new ToolError("INVALID_SERVICE_RESPONSE", `${label} is invalid`, EXIT_INTERNAL);
9007
9076
  }
9008
9077
  const sdk = provisionSdk;
9009
- const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
9078
+ const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
9010
9079
  const ROOT_OPTION = {
9011
9080
  name: "root",
9012
9081
  description: "Installed BuckyOS root on this machine (BUCKYOS_ROOT); read by status/check, written by activate",
@@ -9090,7 +9159,7 @@ function statusCommand(deps) {
9090
9159
  additionalProperties: false
9091
9160
  },
9092
9161
  outputSchema: {
9093
- ...OBJECT_OUTPUT$5,
9162
+ ...OBJECT_OUTPUT$6,
9094
9163
  properties: {
9095
9164
  root: { type: "string" },
9096
9165
  state: {
@@ -9128,7 +9197,7 @@ function checkCommand(deps) {
9128
9197
  additionalProperties: false
9129
9198
  },
9130
9199
  outputSchema: {
9131
- ...OBJECT_OUTPUT$5,
9200
+ ...OBJECT_OUTPUT$6,
9132
9201
  properties: {
9133
9202
  ready: { type: "boolean" },
9134
9203
  root: { type: "string" },
@@ -9176,7 +9245,7 @@ function activateCommand(deps) {
9176
9245
  additionalProperties: false
9177
9246
  },
9178
9247
  outputSchema: {
9179
- ...OBJECT_OUTPUT$5,
9248
+ ...OBJECT_OUTPUT$6,
9180
9249
  properties: {
9181
9250
  root: { type: "string" },
9182
9251
  state: { type: "string", enum: ["configured"] },
@@ -9458,7 +9527,7 @@ function inputFingerprint(input) {
9458
9527
  hash.update(new TextEncoder().encode(JSON.stringify(material)));
9459
9528
  return hash.digestHex();
9460
9529
  }
9461
- const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9530
+ const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
9462
9531
  const SKILL_KINDS = ["cmd", "goal"];
9463
9532
  const SKILLS_SUB_PKG = "agent_skills";
9464
9533
  const SKILL_DIRS = ["cmd_skills", "goal_skills", "tools"];
@@ -9495,7 +9564,7 @@ function createSkillModule() {
9495
9564
  required: ["agent_id"],
9496
9565
  additionalProperties: false
9497
9566
  },
9498
- outputSchema: OBJECT_OUTPUT$4,
9567
+ outputSchema: OBJECT_OUTPUT$5,
9499
9568
  resultSchemaVersion: 1,
9500
9569
  access: { mode: "fixed", level: "read" },
9501
9570
  asyncMode: "sync",
@@ -9534,7 +9603,7 @@ function createSkillModule() {
9534
9603
  required: ["pikg_path", "agent_id"],
9535
9604
  additionalProperties: false
9536
9605
  },
9537
- outputSchema: OBJECT_OUTPUT$4,
9606
+ outputSchema: OBJECT_OUTPUT$5,
9538
9607
  resultSchemaVersion: 1,
9539
9608
  access: { mode: "fixed", level: "write" },
9540
9609
  asyncMode: "sync",
@@ -9561,7 +9630,7 @@ function createSkillModule() {
9561
9630
  required: ["name", "agent_id"],
9562
9631
  additionalProperties: false
9563
9632
  },
9564
- outputSchema: OBJECT_OUTPUT$4,
9633
+ outputSchema: OBJECT_OUTPUT$5,
9565
9634
  resultSchemaVersion: 1,
9566
9635
  access: { mode: "fixed", level: "destructive" },
9567
9636
  asyncMode: "sync",
@@ -9682,7 +9751,7 @@ function base64(bytes) {
9682
9751
  return btoa(binary);
9683
9752
  }
9684
9753
  const CONTROL_PANEL = "control-panel";
9685
- const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9754
+ const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9686
9755
  const AGENT_POSITIONAL = {
9687
9756
  name: "agent_id",
9688
9757
  description: "Agent ID as `agent list` prints it (raw host name, e.g. jarvis.example.zone)"
@@ -9706,7 +9775,7 @@ function createAgentModule() {
9706
9775
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
9707
9776
  outputSchema: {
9708
9777
  type: "object",
9709
- properties: { agents: { type: "array", items: OBJECT_OUTPUT$3 } },
9778
+ properties: { agents: { type: "array", items: OBJECT_OUTPUT$4 } },
9710
9779
  required: ["agents"],
9711
9780
  additionalProperties: false
9712
9781
  },
@@ -9732,7 +9801,7 @@ function createAgentModule() {
9732
9801
  summary: "Get one Agent: profile, settings, install state, template, and runtime",
9733
9802
  positionals: [AGENT_POSITIONAL],
9734
9803
  inputSchema: AGENT_INPUT,
9735
- outputSchema: OBJECT_OUTPUT$3,
9804
+ outputSchema: OBJECT_OUTPUT$4,
9736
9805
  resultSchemaVersion: 1,
9737
9806
  access: { mode: "fixed", level: "read" },
9738
9807
  asyncMode: "sync",
@@ -9745,7 +9814,7 @@ function createAgentModule() {
9745
9814
  summary: "Get the public profile (display name, bio, avatar) of an Agent",
9746
9815
  positionals: [AGENT_POSITIONAL],
9747
9816
  inputSchema: AGENT_INPUT,
9748
- outputSchema: OBJECT_OUTPUT$3,
9817
+ outputSchema: OBJECT_OUTPUT$4,
9749
9818
  resultSchemaVersion: 1,
9750
9819
  access: { mode: "fixed", level: "read" },
9751
9820
  asyncMode: "sync",
@@ -9786,8 +9855,8 @@ function createAgentModule() {
9786
9855
  type: "object",
9787
9856
  properties: {
9788
9857
  agent_id: { type: "string" },
9789
- before: OBJECT_OUTPUT$3,
9790
- profile: OBJECT_OUTPUT$3
9858
+ before: OBJECT_OUTPUT$4,
9859
+ profile: OBJECT_OUTPUT$4
9791
9860
  },
9792
9861
  required: ["agent_id", "before", "profile"],
9793
9862
  additionalProperties: false
@@ -9832,7 +9901,7 @@ async function callAgent(ctx, method, params) {
9832
9901
  }
9833
9902
  }
9834
9903
  const AICC = "aicc";
9835
- const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
9904
+ const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9836
9905
  const EMPTY_INPUT = { type: "object", properties: {}, additionalProperties: false };
9837
9906
  const RANGES = ["last1d", "last7d", "last30d"];
9838
9907
  const GROUPS = [
@@ -9880,7 +9949,7 @@ function quotaCommand() {
9880
9949
  properties: { app: { type: "string", minLength: 1 } },
9881
9950
  additionalProperties: false
9882
9951
  },
9883
- outputSchema: OBJECT_OUTPUT$2,
9952
+ outputSchema: OBJECT_OUTPUT$3,
9884
9953
  resultSchemaVersion: 1,
9885
9954
  access: { mode: "fixed", level: "read" },
9886
9955
  asyncMode: "sync",
@@ -9898,7 +9967,7 @@ function readCommand$1(options) {
9898
9967
  summary: options.summary,
9899
9968
  description: options.description,
9900
9969
  inputSchema: EMPTY_INPUT,
9901
- outputSchema: OBJECT_OUTPUT$2,
9970
+ outputSchema: OBJECT_OUTPUT$3,
9902
9971
  resultSchemaVersion: 1,
9903
9972
  access: { mode: "fixed", level: "read" },
9904
9973
  asyncMode: "sync",
@@ -9950,7 +10019,7 @@ function usageCommand() {
9950
10019
  },
9951
10020
  additionalProperties: false
9952
10021
  },
9953
- outputSchema: OBJECT_OUTPUT$2,
10022
+ outputSchema: OBJECT_OUTPUT$3,
9954
10023
  resultSchemaVersion: 1,
9955
10024
  access: { mode: "fixed", level: "read" },
9956
10025
  asyncMode: "sync",
@@ -9995,8 +10064,8 @@ function timeRange(input) {
9995
10064
  }
9996
10065
  return { kind: "explicit", start_time_ms: since, end_time_ms: until ?? Date.now() };
9997
10066
  }
9998
- const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
9999
- const DAY_MS = 864e5;
10067
+ const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
10068
+ const DAY_MS$1 = 864e5;
10000
10069
  const EXPIRES_HELP = "1d, 7d (default), 30d, none, or an RFC 3339 time";
10001
10070
  function createShareModule() {
10002
10071
  return {
@@ -10005,7 +10074,7 @@ function createShareModule() {
10005
10074
  commands: [
10006
10075
  createCommand(),
10007
10076
  listCommand(),
10008
- getCommand(),
10077
+ getCommand$1(),
10009
10078
  updateCommand(),
10010
10079
  stopCommand(),
10011
10080
  statsCommand()
@@ -10017,7 +10086,7 @@ async function openNfsp(ctx) {
10017
10086
  if (!session)
10018
10087
  throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
10019
10088
  const token = (await session.ensureValid()).token;
10020
- const base = gatewayOrigin(ctx.connection.endpoint);
10089
+ const base = gatewayOrigin$1(ctx.connection.endpoint);
10021
10090
  let seq = 0;
10022
10091
  const post = async (method, body) => {
10023
10092
  const response = await fetch(`${base}/nfs/v1/${method}`, {
@@ -10048,7 +10117,7 @@ async function openNfsp(ctx) {
10048
10117
  call: (method, args, write = false) => post(method, { session: sessionId, args: { ...args, source_hint: "cli" }, ...write ? { seq: ++seq } : {} })
10049
10118
  };
10050
10119
  }
10051
- function gatewayOrigin(endpoint) {
10120
+ function gatewayOrigin$1(endpoint) {
10052
10121
  const url = new URL(endpoint);
10053
10122
  const marker = url.pathname.indexOf("/kapi");
10054
10123
  url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
@@ -10064,7 +10133,7 @@ function parseExpires(value) {
10064
10133
  return null;
10065
10134
  const days = text2.match(/^(\d+)d$/);
10066
10135
  if (days)
10067
- return Math.floor((Date.now() + Number(days[1]) * DAY_MS) / 1e3);
10136
+ return Math.floor((Date.now() + Number(days[1]) * DAY_MS$1) / 1e3);
10068
10137
  const at = parseTimestamp(value, "expires");
10069
10138
  if (at === void 0)
10070
10139
  return void 0;
@@ -10106,7 +10175,7 @@ function createCommand() {
10106
10175
  required: ["path"],
10107
10176
  additionalProperties: false
10108
10177
  },
10109
- outputSchema: OBJECT_OUTPUT$1,
10178
+ outputSchema: OBJECT_OUTPUT$2,
10110
10179
  resultSchemaVersion: 1,
10111
10180
  access: { mode: "fixed", level: "write" },
10112
10181
  asyncMode: "either",
@@ -10175,7 +10244,7 @@ function listCommand() {
10175
10244
  },
10176
10245
  additionalProperties: false
10177
10246
  },
10178
- outputSchema: OBJECT_OUTPUT$1,
10247
+ outputSchema: OBJECT_OUTPUT$2,
10179
10248
  resultSchemaVersion: 1,
10180
10249
  access: { mode: "fixed", level: "read" },
10181
10250
  asyncMode: "sync",
@@ -10196,7 +10265,7 @@ function listCommand() {
10196
10265
  }
10197
10266
  };
10198
10267
  }
10199
- function getCommand() {
10268
+ function getCommand$1() {
10200
10269
  return {
10201
10270
  verb: "get",
10202
10271
  summary: "Show one share: link, policy, snapshot, delivery, statistics and history",
@@ -10207,7 +10276,7 @@ function getCommand() {
10207
10276
  required: ["share_id"],
10208
10277
  additionalProperties: false
10209
10278
  },
10210
- outputSchema: OBJECT_OUTPUT$1,
10279
+ outputSchema: OBJECT_OUTPUT$2,
10211
10280
  resultSchemaVersion: 1,
10212
10281
  access: { mode: "fixed", level: "read" },
10213
10282
  asyncMode: "sync",
@@ -10244,7 +10313,7 @@ function updateCommand() {
10244
10313
  required: ["share_id"],
10245
10314
  additionalProperties: false
10246
10315
  },
10247
- outputSchema: OBJECT_OUTPUT$1,
10316
+ outputSchema: OBJECT_OUTPUT$2,
10248
10317
  resultSchemaVersion: 1,
10249
10318
  access: { mode: "fixed", level: "write" },
10250
10319
  asyncMode: "sync",
@@ -10288,7 +10357,7 @@ function stopCommand() {
10288
10357
  required: ["share_id"],
10289
10358
  additionalProperties: false
10290
10359
  },
10291
- outputSchema: OBJECT_OUTPUT$1,
10360
+ outputSchema: OBJECT_OUTPUT$2,
10292
10361
  resultSchemaVersion: 1,
10293
10362
  access: { mode: "fixed", level: "destructive" },
10294
10363
  asyncMode: "sync",
@@ -10320,7 +10389,7 @@ function statsCommand() {
10320
10389
  },
10321
10390
  additionalProperties: false
10322
10391
  },
10323
- outputSchema: OBJECT_OUTPUT$1,
10392
+ outputSchema: OBJECT_OUTPUT$2,
10324
10393
  resultSchemaVersion: 1,
10325
10394
  access: { mode: "fixed", level: "read" },
10326
10395
  asyncMode: "sync",
@@ -10339,6 +10408,396 @@ function statsCommand() {
10339
10408
  }
10340
10409
  };
10341
10410
  }
10411
+ const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
10412
+ const SERVICE$1 = "nfs-server";
10413
+ const MAX_PUT_BYTES = 32 * 1024 * 1024;
10414
+ const DAY_MS = 864e5;
10415
+ const BUCKET_ERROR_CODES = [
10416
+ "bucket_not_found",
10417
+ "no_such_key",
10418
+ "invalid_key",
10419
+ "invalid_argument",
10420
+ "precondition_failed",
10421
+ "permission_denied",
10422
+ "quota_exceeded",
10423
+ "object_too_large",
10424
+ "content_not_available",
10425
+ "content_evicted",
10426
+ "origin_unavailable",
10427
+ "kind_mismatch",
10428
+ "policy_violation",
10429
+ "origin_required",
10430
+ "not_held",
10431
+ "token_invalid",
10432
+ "conflict",
10433
+ "store_error",
10434
+ "db_error",
10435
+ "internal_error"
10436
+ ];
10437
+ function createBucketModule() {
10438
+ return {
10439
+ name: "bucket",
10440
+ summary: "Read and write application object buckets (key -> object, retained by the Zone)",
10441
+ commands: [lsCommand(), statCommand(), putCommand(), getCommand(), rmCommand(), linkCommand(), s3KeysCommand(), s3KeyCreateCommand(), s3KeyRevokeCommand()]
10442
+ };
10443
+ }
10444
+ function parseBucketTarget(value, keyRequired) {
10445
+ const path = value.startsWith("obj://bucket/") ? value.slice("obj://bucket/".length) : value;
10446
+ const parts = path.split("/");
10447
+ if (parts.length < 4 || !["user", "zone"].includes(parts[0]) || parts.slice(0, 4).some((p) => !p)) {
10448
+ throw new UsageError("INVALID_ARGUMENT", `'${value}' is not obj://bucket/<scope>/<appid>/<owner>/<name>[/<key>]`);
10449
+ }
10450
+ const key = parts.slice(4).join("/");
10451
+ if (keyRequired && !key)
10452
+ throw new UsageError("INVALID_ARGUMENT", `'${value}' names no key`);
10453
+ return { bucketId: parts.slice(0, 4).join("/"), key };
10454
+ }
10455
+ async function call$1(ctx, method, params) {
10456
+ try {
10457
+ return await callService(ctx, SERVICE$1, method, params);
10458
+ } catch (error) {
10459
+ const message = error instanceof Error ? error.message : String(error);
10460
+ const code = BUCKET_ERROR_CODES.find((c) => message.includes(`${c}: `));
10461
+ if (code)
10462
+ throw new ToolError(`BUCKET_${code.toUpperCase()}`, message);
10463
+ throw error;
10464
+ }
10465
+ }
10466
+ function gatewayOrigin(endpoint) {
10467
+ const url = new URL(endpoint);
10468
+ const marker = url.pathname.indexOf("/kapi");
10469
+ url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
10470
+ url.search = "";
10471
+ url.hash = "";
10472
+ return url.toString().replace(/\/$/, "");
10473
+ }
10474
+ function objectUrl(ctx, target, query = {}) {
10475
+ const qs = new URLSearchParams(query).toString();
10476
+ const key = target.key.split("/").map(encodeURIComponent).join("/");
10477
+ return `${gatewayOrigin(ctx.connection.endpoint)}/bucket/v1/${target.bucketId}/${key}${qs ? `?${qs}` : ""}`;
10478
+ }
10479
+ async function bearer(ctx) {
10480
+ if (!ctx.session)
10481
+ throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
10482
+ return { Authorization: `Bearer ${(await ctx.session.ensureValid()).token}` };
10483
+ }
10484
+ async function failure(response) {
10485
+ let body = {};
10486
+ try {
10487
+ body = await response.json();
10488
+ } catch {
10489
+ throw new ToolError("INVALID_SERVICE_RESPONSE", `bucket data plane answered HTTP ${response.status}`, EXIT_INTERNAL);
10490
+ }
10491
+ throw new ToolError(`BUCKET_${String(body.error ?? response.status).toUpperCase()}`, String(body.message ?? `HTTP ${response.status}`));
10492
+ }
10493
+ const TARGET = { name: "target", description: "obj://bucket/<scope>/<appid>/<owner>/<name>[/<key>]", required: true };
10494
+ function lsCommand() {
10495
+ return {
10496
+ verb: "ls",
10497
+ summary: "List your buckets, or the keys of one bucket",
10498
+ positionals: [{ ...TARGET, required: false }],
10499
+ options: [
10500
+ { name: "delimiter", description: "Fold keys at this delimiter (e.g. /)", type: "string" },
10501
+ { name: "start-after", property: "start_after", description: "Continue after this key", type: "string" },
10502
+ { name: "limit", description: "Page size, at most 1000", type: "integer" },
10503
+ { name: "appid", description: "Only buckets of this app (no target)", type: "string" }
10504
+ ],
10505
+ inputSchema: {
10506
+ type: "object",
10507
+ properties: {
10508
+ target: { type: "string", minLength: 1 },
10509
+ delimiter: { type: "string", minLength: 1 },
10510
+ start_after: { type: "string", minLength: 1 },
10511
+ limit: { type: "integer", minimum: 1 },
10512
+ appid: { type: "string", minLength: 1 }
10513
+ },
10514
+ additionalProperties: false
10515
+ },
10516
+ outputSchema: OBJECT_OUTPUT$1,
10517
+ resultSchemaVersion: 1,
10518
+ access: { mode: "fixed", level: "read" },
10519
+ asyncMode: "sync",
10520
+ requiresSession: true,
10521
+ examples: ["buckyos bucket ls", "buckyos bucket ls obj://bucket/user/photos/alice/library/2026/ --delimiter /"],
10522
+ handler: async (ctx, input) => {
10523
+ const raw = inputString(input, "target");
10524
+ if (!raw)
10525
+ return { buckets: await call$1(ctx, "bucket.list", { appid: inputString(input, "appid") }) };
10526
+ const target = parseBucketTarget(raw, false);
10527
+ return await call$1(ctx, "bucket.list_objects", {
10528
+ bucket_id: target.bucketId,
10529
+ prefix: target.key,
10530
+ delimiter: inputString(input, "delimiter"),
10531
+ start_after: inputString(input, "start_after"),
10532
+ limit: input.limit
10533
+ });
10534
+ }
10535
+ };
10536
+ }
10537
+ function statCommand() {
10538
+ return {
10539
+ verb: "stat",
10540
+ summary: "Show a bucket (usage, quota) or a key (binding and where its content is)",
10541
+ positionals: [TARGET],
10542
+ options: [{ name: "version", description: "A specific version of the key", type: "integer" }],
10543
+ inputSchema: {
10544
+ type: "object",
10545
+ properties: { target: { type: "string", minLength: 1 }, version: { type: "integer", minimum: 1 } },
10546
+ required: ["target"],
10547
+ additionalProperties: false
10548
+ },
10549
+ outputSchema: OBJECT_OUTPUT$1,
10550
+ resultSchemaVersion: 1,
10551
+ access: { mode: "fixed", level: "read" },
10552
+ asyncMode: "sync",
10553
+ requiresSession: true,
10554
+ examples: ["buckyos bucket stat obj://bucket/user/photos/alice/library", "buckyos bucket stat obj://bucket/user/photos/alice/library/a.jpg"],
10555
+ handler: async (ctx, input) => {
10556
+ const target = parseBucketTarget(requiredInputString(input, "target"), false);
10557
+ if (!target.key) {
10558
+ const [bucket, quota] = await Promise.all([
10559
+ call$1(ctx, "bucket.stat", { bucket_id: target.bucketId }),
10560
+ call$1(ctx, "bucket.get_quota", { bucket_id: target.bucketId })
10561
+ ]);
10562
+ return { bucket, quota };
10563
+ }
10564
+ return await call$1(ctx, "bucket.head", { bucket_id: target.bucketId, key: target.key, version: input.version });
10565
+ }
10566
+ };
10567
+ }
10568
+ function putCommand() {
10569
+ return {
10570
+ verb: "put",
10571
+ summary: "Store a local file (up to 32 MiB) under a key; success means the Zone retains it",
10572
+ positionals: [TARGET, { name: "file", description: "Local file to upload", required: true }],
10573
+ options: [
10574
+ { name: "content-type", property: "content_type", description: "Content-Type of the object", type: "string" },
10575
+ { name: "if-absent", property: "if_absent", description: "Fail if the key already exists", type: "boolean" },
10576
+ { name: "expires", description: "Unbind after: 1d, 7d, or an RFC 3339 time (temp/cache/app_data buckets)", type: "string" }
10577
+ ],
10578
+ inputSchema: {
10579
+ type: "object",
10580
+ properties: {
10581
+ target: { type: "string", minLength: 1 },
10582
+ file: { type: "string", minLength: 1 },
10583
+ content_type: { type: "string", minLength: 1 },
10584
+ if_absent: { type: "boolean" },
10585
+ expires: { type: "string", minLength: 1 }
10586
+ },
10587
+ required: ["target", "file"],
10588
+ additionalProperties: false
10589
+ },
10590
+ outputSchema: OBJECT_OUTPUT$1,
10591
+ resultSchemaVersion: 1,
10592
+ access: { mode: "fixed", level: "write" },
10593
+ asyncMode: "sync",
10594
+ requiresSession: true,
10595
+ networkAccess: true,
10596
+ examples: ["buckyos bucket put obj://bucket/user/photos/alice/library/2026/a.jpg ./a.jpg --content-type image/jpeg"],
10597
+ handler: async (ctx, input) => {
10598
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10599
+ const bytes = await getHost().readFile(requiredInputString(input, "file"));
10600
+ if (bytes.byteLength > MAX_PUT_BYTES) {
10601
+ throw new UsageError("FILE_TOO_LARGE", "files over 32 MiB go through the SDK upload (ndm.startUpload with bind)");
10602
+ }
10603
+ const headers = { ...await bearer(ctx) };
10604
+ const contentType = inputString(input, "content_type");
10605
+ if (contentType)
10606
+ headers["Content-Type"] = contentType;
10607
+ if (input.if_absent === true)
10608
+ headers["If-None-Match"] = "*";
10609
+ const expires = inputString(input, "expires");
10610
+ if (expires) {
10611
+ const days = expires.match(/^(\d+)d$/);
10612
+ const at = days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(expires, "expires");
10613
+ if (at !== void 0)
10614
+ headers["x-bucky-expires-at"] = String(at);
10615
+ }
10616
+ const response = await fetch(objectUrl(ctx, target), { method: "PUT", headers, body: new Blob([bytes]), signal: ctx.signal });
10617
+ if (!response.ok)
10618
+ await failure(response);
10619
+ return await response.json();
10620
+ }
10621
+ };
10622
+ }
10623
+ function getCommand() {
10624
+ return {
10625
+ verb: "get",
10626
+ summary: "Download a key to a local file",
10627
+ positionals: [TARGET, { name: "output", description: "Local file to write", required: true }],
10628
+ options: [{ name: "version", description: "A specific version of the key", type: "integer" }],
10629
+ inputSchema: {
10630
+ type: "object",
10631
+ properties: {
10632
+ target: { type: "string", minLength: 1 },
10633
+ output: { type: "string", minLength: 1 },
10634
+ version: { type: "integer", minimum: 1 }
10635
+ },
10636
+ required: ["target", "output"],
10637
+ additionalProperties: false
10638
+ },
10639
+ outputSchema: OBJECT_OUTPUT$1,
10640
+ resultSchemaVersion: 1,
10641
+ access: { mode: "fixed", level: "read" },
10642
+ asyncMode: "sync",
10643
+ requiresSession: true,
10644
+ networkAccess: true,
10645
+ examples: ["buckyos bucket get obj://bucket/user/photos/alice/library/2026/a.jpg ./a.jpg"],
10646
+ handler: async (ctx, input) => {
10647
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10648
+ const query = input.version !== void 0 ? { version: String(input.version) } : {};
10649
+ const response = await fetch(objectUrl(ctx, target, query), { headers: await bearer(ctx), signal: ctx.signal });
10650
+ if (!response.ok)
10651
+ await failure(response);
10652
+ const bytes = new Uint8Array(await response.arrayBuffer());
10653
+ const output = requiredInputString(input, "output");
10654
+ await getHost().writeFile(output, bytes);
10655
+ return {
10656
+ output,
10657
+ size: bytes.byteLength,
10658
+ obj_id: response.headers.get("x-bucky-obj-id"),
10659
+ version: Number(response.headers.get("x-bucky-version")),
10660
+ content_type: response.headers.get("content-type")
10661
+ };
10662
+ }
10663
+ };
10664
+ }
10665
+ function rmCommand() {
10666
+ return {
10667
+ verb: "rm",
10668
+ summary: "Unbind a key (the bucket stops retaining its content)",
10669
+ positionals: [TARGET],
10670
+ options: [{ name: "version", description: "Remove only this version", type: "integer" }],
10671
+ inputSchema: {
10672
+ type: "object",
10673
+ properties: { target: { type: "string", minLength: 1 }, version: { type: "integer", minimum: 1 } },
10674
+ required: ["target"],
10675
+ additionalProperties: false
10676
+ },
10677
+ outputSchema: OBJECT_OUTPUT$1,
10678
+ resultSchemaVersion: 1,
10679
+ access: { mode: "fixed", level: "write" },
10680
+ asyncMode: "sync",
10681
+ requiresSession: true,
10682
+ examples: ["buckyos bucket rm obj://bucket/user/photos/alice/library/2026/a.jpg"],
10683
+ handler: async (ctx, input) => {
10684
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10685
+ return await call$1(ctx, "bucket.delete", { bucket_id: target.bucketId, key: target.key, version: input.version });
10686
+ }
10687
+ };
10688
+ }
10689
+ function linkCommand() {
10690
+ return {
10691
+ verb: "link",
10692
+ summary: "Create a revocable read link to one key (up to 7 days, no Zone account needed)",
10693
+ positionals: [TARGET],
10694
+ options: [
10695
+ { name: "expires", description: "1d (default) to 7d, or an RFC 3339 time", type: "string" },
10696
+ { name: "max-uses", property: "max_uses", description: "Stop after this many reads", type: "integer" }
10697
+ ],
10698
+ inputSchema: {
10699
+ type: "object",
10700
+ properties: {
10701
+ target: { type: "string", minLength: 1 },
10702
+ expires: { type: "string", minLength: 1 },
10703
+ max_uses: { type: "integer", minimum: 1 }
10704
+ },
10705
+ required: ["target"],
10706
+ additionalProperties: false
10707
+ },
10708
+ outputSchema: OBJECT_OUTPUT$1,
10709
+ resultSchemaVersion: 1,
10710
+ access: { mode: "fixed", level: "write" },
10711
+ asyncMode: "sync",
10712
+ requiresSession: true,
10713
+ examples: ["buckyos bucket link obj://bucket/user/photos/alice/library/2026/a.jpg --expires 3d"],
10714
+ handler: async (ctx, input) => {
10715
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10716
+ const text2 = inputString(input, "expires") ?? "1d";
10717
+ const days = text2.match(/^(\d+)d$/);
10718
+ const expiresAt = days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
10719
+ if (expiresAt === void 0)
10720
+ throw new UsageError("INVALID_ARGUMENT", "expires is required");
10721
+ const issued = await call$1(ctx, "bucket.create_access_token", {
10722
+ bucket_id: target.bucketId,
10723
+ key: target.key,
10724
+ actions: ["read"],
10725
+ expires_at: expiresAt,
10726
+ max_uses: input.max_uses
10727
+ });
10728
+ return { ...issued, url: `${gatewayOrigin(ctx.connection.endpoint)}${String(issued.path)}` };
10729
+ }
10730
+ };
10731
+ }
10732
+ function s3KeysCommand() {
10733
+ return {
10734
+ verb: "s3-keys",
10735
+ summary: "List your S3 access keys (secrets are shown only when created)",
10736
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
10737
+ outputSchema: OBJECT_OUTPUT$1,
10738
+ resultSchemaVersion: 1,
10739
+ access: { mode: "fixed", level: "read" },
10740
+ asyncMode: "sync",
10741
+ requiresSession: true,
10742
+ examples: ["buckyos bucket s3-keys"],
10743
+ handler: async (ctx) => ({ keys: await call$1(ctx, "bucket.list_s3_keys", {}) })
10744
+ };
10745
+ }
10746
+ function s3KeyCreateCommand() {
10747
+ return {
10748
+ verb: "s3-key-create",
10749
+ summary: "Issue an S3 access key for one of your apps (endpoint https://<zone>/s3 or https://s3.<zone>)",
10750
+ options: [
10751
+ { name: "app", description: "App id whose buckets the key reaches", type: "string" },
10752
+ { name: "prefix", description: "Only keys under this prefix", type: "string" },
10753
+ { name: "expires", description: "Expiry: 30d, or an RFC 3339 time (default: none)", type: "string" }
10754
+ ],
10755
+ inputSchema: {
10756
+ type: "object",
10757
+ properties: { app: { type: "string", minLength: 1 }, prefix: { type: "string", minLength: 1 }, expires: { type: "string", minLength: 1 } },
10758
+ required: ["app"],
10759
+ additionalProperties: false
10760
+ },
10761
+ outputSchema: OBJECT_OUTPUT$1,
10762
+ resultSchemaVersion: 1,
10763
+ access: { mode: "fixed", level: "write" },
10764
+ asyncMode: "sync",
10765
+ requiresSession: true,
10766
+ examples: ["buckyos bucket s3-key-create --app photos.app.bns.did --expires 30d"],
10767
+ handler: async (ctx, input) => {
10768
+ const text2 = inputString(input, "expires");
10769
+ const days = text2?.match(/^(\d+)d$/);
10770
+ const expiresAt = !text2 ? void 0 : days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
10771
+ const prefix = inputString(input, "prefix");
10772
+ const key = await call$1(ctx, "bucket.create_s3_key", {
10773
+ appid: requiredInputString(input, "app"),
10774
+ scope: prefix ? { prefix } : void 0,
10775
+ expires_at: expiresAt
10776
+ });
10777
+ return { ...key, endpoint: `${gatewayOrigin(ctx.connection.endpoint)}/s3`, region: "us-east-1", path_style: true };
10778
+ }
10779
+ };
10780
+ }
10781
+ function s3KeyRevokeCommand() {
10782
+ return {
10783
+ verb: "s3-key-revoke",
10784
+ summary: "Revoke an S3 access key (its presigned URLs stop working too)",
10785
+ positionals: [{ name: "access_key_id", description: "Access key id (BK…)", required: true }],
10786
+ inputSchema: {
10787
+ type: "object",
10788
+ properties: { access_key_id: { type: "string", minLength: 1 } },
10789
+ required: ["access_key_id"],
10790
+ additionalProperties: false
10791
+ },
10792
+ outputSchema: OBJECT_OUTPUT$1,
10793
+ resultSchemaVersion: 1,
10794
+ access: { mode: "fixed", level: "write" },
10795
+ asyncMode: "sync",
10796
+ requiresSession: true,
10797
+ examples: ["buckyos bucket s3-key-revoke BKABCDEFGHIJKLMNOPQR"],
10798
+ handler: async (ctx, input) => await call$1(ctx, "bucket.revoke_s3_key", { access_key_id: requiredInputString(input, "access_key_id") })
10799
+ };
10800
+ }
10342
10801
  const text = { type: "string", minLength: 1 };
10343
10802
  const object = { type: "object", additionalProperties: true };
10344
10803
  const targetProperties = {
@@ -11125,6 +11584,7 @@ function createRegistry(pikgDependencies, appDependencies, logDependencies, diag
11125
11584
  registry.register(createAgentModule());
11126
11585
  registry.register(createAiModule());
11127
11586
  registry.register(createShareModule());
11587
+ registry.register(createBucketModule());
11128
11588
  registry.register(createExecutorModule());
11129
11589
  registry.register(createAiwsModule());
11130
11590
  return registry;