buckyos 0.7.148 → 0.7.150

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 (44) hide show
  1. package/cli/core/app.ts +2 -0
  2. package/cli/dist/cli.mjs +548 -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 +71 -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 +393 -0
  14. package/dist/bucket_client.d.ts.map +1 -0
  15. package/dist/{executor_client-4fbf0c3c.mjs → executor_client-84d7a70d.mjs} +494 -193
  16. package/dist/executor_client-84d7a70d.mjs.map +1 -0
  17. package/dist/executor_client-900330a4.js +13 -0
  18. package/dist/executor_client-900330a4.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 +32 -0
  26. package/dist/ndm_client.d.ts.map +1 -1
  27. package/dist/nfsp.cjs.map +1 -1
  28. package/dist/nfsp.d.ts +5 -3
  29. package/dist/nfsp.d.ts.map +1 -1
  30. package/dist/nfsp.mjs.map +1 -1
  31. package/dist/node.cjs +1 -1
  32. package/dist/node.cjs.map +1 -1
  33. package/dist/node.d.ts +2 -0
  34. package/dist/node.d.ts.map +1 -1
  35. package/dist/node.mjs +190 -189
  36. package/dist/node.mjs.map +1 -1
  37. package/dist/runtime.d.ts +2 -0
  38. package/dist/runtime.d.ts.map +1 -1
  39. package/dist/sdk_core.d.ts +4 -0
  40. package/dist/sdk_core.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/executor_client-4fbf0c3c.mjs.map +0 -1
  43. package/dist/executor_client-5fa2d501.js +0 -13
  44. 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,79 @@ 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
+ if (bucket.scope === "user")
4290
+ delete bucket.scope;
4291
+ optionalBoolean(bucket.versioning, `${at}.versioning`);
4292
+ const userOwned = policy2 === "documents" || policy2 === "collected";
4293
+ if (bucket.quota_mib !== void 0) {
4294
+ expectUint(bucket.quota_mib, `${at}.quota_mib`, Number.MAX_SAFE_INTEGER);
4295
+ if (userOwned)
4296
+ throw invalid("schema", `${at}: a ${policy2} bucket uses the user's quota`);
4297
+ }
4298
+ if (bucket.max_objects !== void 0)
4299
+ expectUint(bucket.max_objects, `${at}.max_objects`, Number.MAX_SAFE_INTEGER);
4300
+ if (bucket.versioning === true && !["documents", "app_data", "collected"].includes(policy2)) {
4301
+ throw invalid("schema", `${at}: a ${policy2} bucket cannot be versioned`);
4302
+ }
4303
+ if (bucket.default_ttl_days !== void 0) {
4304
+ expectUint(bucket.default_ttl_days, `${at}.default_ttl_days`, 4294967295);
4305
+ if (!["ambient", "temp", "cache"].includes(policy2)) {
4306
+ throw invalid("schema", `${at}: a ${policy2} bucket cannot declare default_ttl_days`);
4307
+ }
4308
+ }
4309
+ if (policy2 === "temp") {
4310
+ const days = bucket.default_ttl_days;
4311
+ if (typeof days !== "number" || days < 1 || days > 30) {
4312
+ throw invalid("schema", `${at}: a temp bucket declares default_ttl_days 1..30`);
4313
+ }
4314
+ }
4315
+ if (bucket.lifecycle !== void 0) {
4316
+ const lifecycle = bucket.lifecycle;
4317
+ if (!Array.isArray(lifecycle))
4318
+ throw invalid("schema", `${at}.lifecycle must be an array`);
4319
+ if (lifecycle.length === 0)
4320
+ delete bucket.lifecycle;
4321
+ for (const [index, rule] of lifecycle.entries()) {
4322
+ const kind = String(expectObject$3(rule, `${at}.lifecycle[${index}]`).rule);
4323
+ if (!["expire", "noncurrent_expire", "expired_delete_marker"].includes(kind)) {
4324
+ throw invalid("schema", `${at}.lifecycle[${index}].rule is invalid`);
4325
+ }
4326
+ if (policy2 === "temp" || userOwned && kind !== "noncurrent_expire") {
4327
+ throw invalid("schema", `${at}: a ${policy2} bucket does not accept the ${kind} rule`);
4328
+ }
4329
+ }
4330
+ }
4331
+ needsAppPool ||= policy2 === "app_data" || policy2 === "temp";
4332
+ }
4333
+ if (needsAppPool && config.storage_quota_mib === void 0) {
4334
+ throw invalid("schema", `${label}.storage_quota_mib is required when app_data or temp buckets are declared`);
4335
+ }
4336
+ }
4264
4337
  function validateServiceConfigTips(value, label) {
4265
4338
  const config = expectObject$3(value, label);
4266
4339
  for (const field of [
@@ -4375,6 +4448,7 @@ function validateServiceConfigTips(value, label) {
4375
4448
  }
4376
4449
  optionalString$3(database.connection, `${label}.rdb_instances.${name}.connection`);
4377
4450
  }
4451
+ validateBuckets(config, label);
4378
4452
  if (config.instance_volume !== void 0) {
4379
4453
  const volume = expectObject$3(config.instance_volume, `${label}.instance_volume`);
4380
4454
  assertKnownFields(
@@ -5105,7 +5179,7 @@ function validateContentHandlers(value, permissions) {
5105
5179
  }
5106
5180
  return value;
5107
5181
  }
5108
- const PACKAGE_VERSION = "0.7.148";
5182
+ const PACKAGE_VERSION = "0.7.150";
5109
5183
  const TOOL_VERSION = PACKAGE_VERSION;
5110
5184
  const SDK_VERSION = PACKAGE_VERSION;
5111
5185
  const PROTOCOL_VERSION = "1";
@@ -5122,7 +5196,7 @@ const VERSION$1 = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
5122
5196
  const SHA256_ID = /^sha256:[0-9a-f]{64}$/;
5123
5197
  const OBJECT_ID = /^(?:appdoc|pkg):[0-9a-f]{64}$/;
5124
5198
  const SAFE_GENERATED_FILE = /^[A-Za-z0-9._-]+$/;
5125
- const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
5199
+ const OBJECT_OUTPUT$b = { type: "object", additionalProperties: true };
5126
5200
  const APP_KINDS = ["static-web", "script", "docker", "agent-skills"];
5127
5201
  const PATH_KINDS = {
5128
5202
  "static-web": { key: "web", category: "web", selectorType: "static" },
@@ -5165,7 +5239,7 @@ function createPikgModule(dependencies = {}) {
5165
5239
  properties: { meta_dir: { type: "string", minLength: 1 } },
5166
5240
  additionalProperties: false
5167
5241
  },
5168
- outputSchema: OBJECT_OUTPUT$a,
5242
+ outputSchema: OBJECT_OUTPUT$b,
5169
5243
  resultSchemaVersion: 1,
5170
5244
  access: { mode: "fixed", level: "read" },
5171
5245
  asyncMode: "sync",
@@ -5212,7 +5286,7 @@ function createPikgModule(dependencies = {}) {
5212
5286
  },
5213
5287
  additionalProperties: false
5214
5288
  },
5215
- outputSchema: OBJECT_OUTPUT$a,
5289
+ outputSchema: OBJECT_OUTPUT$b,
5216
5290
  resultSchemaVersion: 1,
5217
5291
  access: { mode: "fixed", level: "write" },
5218
5292
  asyncMode: "sync",
@@ -5237,7 +5311,7 @@ function createPikgModule(dependencies = {}) {
5237
5311
  properties: { meta_dir: { type: "string", minLength: 1 } },
5238
5312
  additionalProperties: false
5239
5313
  },
5240
- outputSchema: OBJECT_OUTPUT$a,
5314
+ outputSchema: OBJECT_OUTPUT$b,
5241
5315
  resultSchemaVersion: 1,
5242
5316
  access: { mode: "fixed", level: "write" },
5243
5317
  asyncMode: "sync",
@@ -5258,7 +5332,7 @@ function createPikgModule(dependencies = {}) {
5258
5332
  properties: { dist_dir: { type: "string", minLength: 1 } },
5259
5333
  additionalProperties: false
5260
5334
  },
5261
- outputSchema: OBJECT_OUTPUT$a,
5335
+ outputSchema: OBJECT_OUTPUT$b,
5262
5336
  resultSchemaVersion: 1,
5263
5337
  access: { mode: "fixed", level: "write" },
5264
5338
  asyncMode: "sync",
@@ -5278,7 +5352,7 @@ function createPikgModule(dependencies = {}) {
5278
5352
  required: ["pikg_path"],
5279
5353
  additionalProperties: false
5280
5354
  },
5281
- outputSchema: OBJECT_OUTPUT$a,
5355
+ outputSchema: OBJECT_OUTPUT$b,
5282
5356
  resultSchemaVersion: 1,
5283
5357
  access: { mode: "fixed", level: "read" },
5284
5358
  asyncMode: "sync",
@@ -5299,7 +5373,7 @@ function createPikgModule(dependencies = {}) {
5299
5373
  properties: { meta_dir: { type: "string", minLength: 1 } },
5300
5374
  additionalProperties: false
5301
5375
  },
5302
- outputSchema: OBJECT_OUTPUT$a,
5376
+ outputSchema: OBJECT_OUTPUT$b,
5303
5377
  resultSchemaVersion: 1,
5304
5378
  access: { mode: "fixed", level: "destructive" },
5305
5379
  asyncMode: "sync",
@@ -6562,7 +6636,7 @@ const CONTROL_PANEL_SERVICE = "control-panel";
6562
6636
  const PLAN_SCHEMA_VERSION = 4;
6563
6637
  const STAGING_RELEASE_TIMEOUT_MS = 5e3;
6564
6638
  const ZIP_LOCAL_MAGIC = [80, 75, 3, 4];
6565
- const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
6639
+ const OBJECT_OUTPUT$a = { type: "object", additionalProperties: true };
6566
6640
  const INSTALL_POLICIES = [
6567
6641
  "strict-public",
6568
6642
  "normal",
@@ -6574,7 +6648,7 @@ function createAppModule(dependencies = {}) {
6574
6648
  const commands = [
6575
6649
  fetchCommand(dependencies),
6576
6650
  listCommand$2(),
6577
- getCommand$2(),
6651
+ getCommand$3(),
6578
6652
  installCommand(dependencies),
6579
6653
  upgradeCommand(dependencies),
6580
6654
  uninstallCommand(dependencies),
@@ -6613,7 +6687,7 @@ function cancelCommand$1() {
6613
6687
  required: ["task_id"],
6614
6688
  additionalProperties: false
6615
6689
  },
6616
- outputSchema: OBJECT_OUTPUT$9,
6690
+ outputSchema: OBJECT_OUTPUT$a,
6617
6691
  resultSchemaVersion: 1,
6618
6692
  access: { mode: "fixed", level: "write" },
6619
6693
  asyncMode: "sync",
@@ -6648,7 +6722,7 @@ function fetchCommand(dependencies) {
6648
6722
  target: { type: "object", additionalProperties: true },
6649
6723
  install_params: { type: "object", additionalProperties: true }
6650
6724
  }),
6651
- outputSchema: OBJECT_OUTPUT$9,
6725
+ outputSchema: OBJECT_OUTPUT$a,
6652
6726
  resultSchemaVersion: 1,
6653
6727
  access: { mode: "fixed", level: "read" },
6654
6728
  asyncMode: "sync",
@@ -6665,7 +6739,7 @@ function listCommand$2() {
6665
6739
  verb: "list",
6666
6740
  summary: "List visible installed Apps",
6667
6741
  inputSchema: emptyInputSchema(),
6668
- outputSchema: OBJECT_OUTPUT$9,
6742
+ outputSchema: OBJECT_OUTPUT$a,
6669
6743
  resultSchemaVersion: 1,
6670
6744
  access: { mode: "fixed", level: "read" },
6671
6745
  asyncMode: "sync",
@@ -6674,7 +6748,7 @@ function listCommand$2() {
6674
6748
  handler: async (ctx) => await callControl(ctx, "apps.list", {})
6675
6749
  };
6676
6750
  }
6677
- function getCommand$2() {
6751
+ function getCommand$3() {
6678
6752
  return selectorCommand({
6679
6753
  verb: "get",
6680
6754
  summary: "Get installation and runtime details for one App",
@@ -6723,7 +6797,7 @@ function installCommand(dependencies) {
6723
6797
  no_wait: { type: "boolean" },
6724
6798
  policy: { type: "string", enum: [...INSTALL_POLICIES] }
6725
6799
  }),
6726
- outputSchema: OBJECT_OUTPUT$9,
6800
+ outputSchema: OBJECT_OUTPUT$a,
6727
6801
  resultSchemaVersion: 1,
6728
6802
  access: { mode: "fixed", level: "write" },
6729
6803
  asyncMode: "either",
@@ -6767,7 +6841,7 @@ function upgradeCommand(dependencies) {
6767
6841
  },
6768
6842
  additionalProperties: false
6769
6843
  },
6770
- outputSchema: OBJECT_OUTPUT$9,
6844
+ outputSchema: OBJECT_OUTPUT$a,
6771
6845
  resultSchemaVersion: 1,
6772
6846
  access: { mode: "fixed", level: "write" },
6773
6847
  asyncMode: "either",
@@ -6896,7 +6970,7 @@ function statusCommand$1() {
6896
6970
  properties: { app_name: { type: "string", minLength: 1 } },
6897
6971
  additionalProperties: false
6898
6972
  },
6899
- outputSchema: OBJECT_OUTPUT$9,
6973
+ outputSchema: OBJECT_OUTPUT$a,
6900
6974
  resultSchemaVersion: 1,
6901
6975
  access: { mode: "fixed", level: "read" },
6902
6976
  asyncMode: "sync",
@@ -6967,7 +7041,7 @@ function publishCommand() {
6967
7041
  required: ["local_dir", "app_doc"],
6968
7042
  additionalProperties: false
6969
7043
  },
6970
- outputSchema: OBJECT_OUTPUT$9,
7044
+ outputSchema: OBJECT_OUTPUT$a,
6971
7045
  resultSchemaVersion: 1,
6972
7046
  access: { mode: "fixed", level: "write" },
6973
7047
  asyncMode: "sync",
@@ -7484,7 +7558,7 @@ async function stagePikg(ctx, snapshot, purpose) {
7484
7558
  throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
7485
7559
  const token = (await session.ensureValid()).token;
7486
7560
  const proxy = ndm_proxy.createNdmProxyClient({
7487
- endpoint: gatewayOrigin$1(ctx.connection.endpoint),
7561
+ endpoint: gatewayOrigin$2(ctx.connection.endpoint),
7488
7562
  sessionToken: token,
7489
7563
  fetcher: (request, init) => fetch(normalizeNdmRequestUrl(request), { ...init, signal: ctx.signal })
7490
7564
  });
@@ -8021,7 +8095,7 @@ function validatePikgSnapshot(bytes) {
8021
8095
  throw new UsageError("INVALID_PIKG", "PIKG magic mismatch: expected a ZIP container");
8022
8096
  }
8023
8097
  }
8024
- function gatewayOrigin$1(endpoint) {
8098
+ function gatewayOrigin$2(endpoint) {
8025
8099
  const url = new URL(endpoint);
8026
8100
  const marker = url.pathname.indexOf("/kapi");
8027
8101
  url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
@@ -8093,7 +8167,7 @@ function selectorCommand(options) {
8093
8167
  required: ["app_name"],
8094
8168
  additionalProperties: false
8095
8169
  },
8096
- outputSchema: OBJECT_OUTPUT$9,
8170
+ outputSchema: OBJECT_OUTPUT$a,
8097
8171
  resultSchemaVersion: 1,
8098
8172
  access: { mode: "fixed", level: options.access },
8099
8173
  asyncMode: options.asyncMode,
@@ -8257,7 +8331,7 @@ function toHex(bytes) {
8257
8331
  return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
8258
8332
  }
8259
8333
  const CONTROL_PANEL$3 = "control-panel";
8260
- const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
8334
+ const OBJECT_OUTPUT$9 = { type: "object", additionalProperties: true };
8261
8335
  function createDiagnosticModule(dependencies = {}) {
8262
8336
  return {
8263
8337
  name: "diagnostic",
@@ -8296,7 +8370,7 @@ function collectCommand() {
8296
8370
  required: ["services"],
8297
8371
  additionalProperties: false
8298
8372
  },
8299
- outputSchema: OBJECT_OUTPUT$8,
8373
+ outputSchema: OBJECT_OUTPUT$9,
8300
8374
  resultSchemaVersion: 1,
8301
8375
  access: { mode: "fixed", level: "privileged" },
8302
8376
  asyncMode: "task",
@@ -8350,7 +8424,7 @@ function exportCommand$1(dependencies) {
8350
8424
  required: ["bundle_id", "path"],
8351
8425
  additionalProperties: false
8352
8426
  },
8353
- outputSchema: OBJECT_OUTPUT$8,
8427
+ outputSchema: OBJECT_OUTPUT$9,
8354
8428
  resultSchemaVersion: 1,
8355
8429
  access: { mode: "fixed", level: "privileged" },
8356
8430
  asyncMode: "sync",
@@ -8392,7 +8466,7 @@ function compact$2(value) {
8392
8466
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
8393
8467
  }
8394
8468
  const CONTROL_PANEL$2 = "control-panel";
8395
- const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8469
+ const OBJECT_OUTPUT$8 = { type: "object", additionalProperties: true };
8396
8470
  const LOG_LEVELS = ["error", "warning", "info", "debug", "trace"];
8397
8471
  function createLogModule(dependencies = {}) {
8398
8472
  return {
@@ -8413,7 +8487,7 @@ function servicesCommand() {
8413
8487
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
8414
8488
  outputSchema: {
8415
8489
  type: "object",
8416
- properties: { services: { type: "array", items: OBJECT_OUTPUT$7 } },
8490
+ properties: { services: { type: "array", items: OBJECT_OUTPUT$8 } },
8417
8491
  required: ["services"],
8418
8492
  additionalProperties: false
8419
8493
  },
@@ -8486,7 +8560,7 @@ function tailCommand(dependencies) {
8486
8560
  }
8487
8561
  ],
8488
8562
  inputSchema: filterSchema({ from: { type: "string", enum: ["start", "end"] } }),
8489
- outputSchema: OBJECT_OUTPUT$7,
8563
+ outputSchema: OBJECT_OUTPUT$8,
8490
8564
  resultSchemaVersion: 1,
8491
8565
  access: { mode: "fixed", level: "read" },
8492
8566
  asyncMode: "stream",
@@ -8542,7 +8616,7 @@ function exportCommand(dependencies) {
8542
8616
  ...filterSchema({ path: { type: "string", minLength: 1 } }),
8543
8617
  required: ["path"]
8544
8618
  },
8545
- outputSchema: OBJECT_OUTPUT$7,
8619
+ outputSchema: OBJECT_OUTPUT$8,
8546
8620
  resultSchemaVersion: 1,
8547
8621
  access: { mode: "fixed", level: "read" },
8548
8622
  asyncMode: "sync",
@@ -8694,12 +8768,12 @@ function abortableSleep(milliseconds, signal) {
8694
8768
  }
8695
8769
  const TASK_MANAGER = "task-manager";
8696
8770
  const CONTROL_PANEL$1 = "control-panel";
8697
- const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
8771
+ const OBJECT_OUTPUT$7 = { type: "object", additionalProperties: true };
8698
8772
  function createTaskModule() {
8699
8773
  return {
8700
8774
  name: "task",
8701
8775
  summary: "Inspect, wait for, cancel, and retry durable Tasks",
8702
- commands: [listCommand$1(), getCommand$1(), waitCommand(), cancelCommand(), retryCommand()]
8776
+ commands: [listCommand$1(), getCommand$2(), waitCommand(), cancelCommand(), retryCommand()]
8703
8777
  };
8704
8778
  }
8705
8779
  function listCommand$1() {
@@ -8768,7 +8842,7 @@ function listCommand$1() {
8768
8842
  }
8769
8843
  };
8770
8844
  }
8771
- function getCommand$1() {
8845
+ function getCommand$2() {
8772
8846
  return {
8773
8847
  verb: "get",
8774
8848
  summary: "Get one Task snapshot and its direct children",
@@ -8797,7 +8871,7 @@ function getCommand$1() {
8797
8871
  required: ["task_id"],
8798
8872
  additionalProperties: false
8799
8873
  },
8800
- outputSchema: OBJECT_OUTPUT$6,
8874
+ outputSchema: OBJECT_OUTPUT$7,
8801
8875
  resultSchemaVersion: 1,
8802
8876
  access: { mode: "fixed", level: "read" },
8803
8877
  asyncMode: "sync",
@@ -8838,7 +8912,7 @@ function waitCommand() {
8838
8912
  summary: "Stream changes until a Task becomes terminal",
8839
8913
  positionals: [{ name: "task_id", description: "Opaque Task ID", required: true }],
8840
8914
  inputSchema: taskIdSchema(),
8841
- outputSchema: OBJECT_OUTPUT$6,
8915
+ outputSchema: OBJECT_OUTPUT$7,
8842
8916
  resultSchemaVersion: 1,
8843
8917
  access: { mode: "fixed", level: "read" },
8844
8918
  asyncMode: "stream",
@@ -8889,7 +8963,7 @@ function cancelCommand() {
8889
8963
  required: ["task_id"],
8890
8964
  additionalProperties: false
8891
8965
  },
8892
- outputSchema: OBJECT_OUTPUT$6,
8966
+ outputSchema: OBJECT_OUTPUT$7,
8893
8967
  resultSchemaVersion: 1,
8894
8968
  access: { mode: "fixed", level: "write" },
8895
8969
  asyncMode: "sync",
@@ -8932,7 +9006,7 @@ function retryCommand() {
8932
9006
  required: ["task_id"],
8933
9007
  additionalProperties: false
8934
9008
  },
8935
- outputSchema: OBJECT_OUTPUT$6,
9009
+ outputSchema: OBJECT_OUTPUT$7,
8936
9010
  resultSchemaVersion: 1,
8937
9011
  access: { mode: "fixed", level: "write" },
8938
9012
  asyncMode: "either",
@@ -9006,7 +9080,7 @@ function invalidResponse$1(label) {
9006
9080
  throw new ToolError("INVALID_SERVICE_RESPONSE", `${label} is invalid`, EXIT_INTERNAL);
9007
9081
  }
9008
9082
  const sdk = provisionSdk;
9009
- const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
9083
+ const OBJECT_OUTPUT$6 = { type: "object", additionalProperties: true };
9010
9084
  const ROOT_OPTION = {
9011
9085
  name: "root",
9012
9086
  description: "Installed BuckyOS root on this machine (BUCKYOS_ROOT); read by status/check, written by activate",
@@ -9090,7 +9164,7 @@ function statusCommand(deps) {
9090
9164
  additionalProperties: false
9091
9165
  },
9092
9166
  outputSchema: {
9093
- ...OBJECT_OUTPUT$5,
9167
+ ...OBJECT_OUTPUT$6,
9094
9168
  properties: {
9095
9169
  root: { type: "string" },
9096
9170
  state: {
@@ -9128,7 +9202,7 @@ function checkCommand(deps) {
9128
9202
  additionalProperties: false
9129
9203
  },
9130
9204
  outputSchema: {
9131
- ...OBJECT_OUTPUT$5,
9205
+ ...OBJECT_OUTPUT$6,
9132
9206
  properties: {
9133
9207
  ready: { type: "boolean" },
9134
9208
  root: { type: "string" },
@@ -9176,7 +9250,7 @@ function activateCommand(deps) {
9176
9250
  additionalProperties: false
9177
9251
  },
9178
9252
  outputSchema: {
9179
- ...OBJECT_OUTPUT$5,
9253
+ ...OBJECT_OUTPUT$6,
9180
9254
  properties: {
9181
9255
  root: { type: "string" },
9182
9256
  state: { type: "string", enum: ["configured"] },
@@ -9458,7 +9532,7 @@ function inputFingerprint(input) {
9458
9532
  hash.update(new TextEncoder().encode(JSON.stringify(material)));
9459
9533
  return hash.digestHex();
9460
9534
  }
9461
- const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9535
+ const OBJECT_OUTPUT$5 = { type: "object", additionalProperties: true };
9462
9536
  const SKILL_KINDS = ["cmd", "goal"];
9463
9537
  const SKILLS_SUB_PKG = "agent_skills";
9464
9538
  const SKILL_DIRS = ["cmd_skills", "goal_skills", "tools"];
@@ -9495,7 +9569,7 @@ function createSkillModule() {
9495
9569
  required: ["agent_id"],
9496
9570
  additionalProperties: false
9497
9571
  },
9498
- outputSchema: OBJECT_OUTPUT$4,
9572
+ outputSchema: OBJECT_OUTPUT$5,
9499
9573
  resultSchemaVersion: 1,
9500
9574
  access: { mode: "fixed", level: "read" },
9501
9575
  asyncMode: "sync",
@@ -9534,7 +9608,7 @@ function createSkillModule() {
9534
9608
  required: ["pikg_path", "agent_id"],
9535
9609
  additionalProperties: false
9536
9610
  },
9537
- outputSchema: OBJECT_OUTPUT$4,
9611
+ outputSchema: OBJECT_OUTPUT$5,
9538
9612
  resultSchemaVersion: 1,
9539
9613
  access: { mode: "fixed", level: "write" },
9540
9614
  asyncMode: "sync",
@@ -9561,7 +9635,7 @@ function createSkillModule() {
9561
9635
  required: ["name", "agent_id"],
9562
9636
  additionalProperties: false
9563
9637
  },
9564
- outputSchema: OBJECT_OUTPUT$4,
9638
+ outputSchema: OBJECT_OUTPUT$5,
9565
9639
  resultSchemaVersion: 1,
9566
9640
  access: { mode: "fixed", level: "destructive" },
9567
9641
  asyncMode: "sync",
@@ -9682,7 +9756,7 @@ function base64(bytes) {
9682
9756
  return btoa(binary);
9683
9757
  }
9684
9758
  const CONTROL_PANEL = "control-panel";
9685
- const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9759
+ const OBJECT_OUTPUT$4 = { type: "object", additionalProperties: true };
9686
9760
  const AGENT_POSITIONAL = {
9687
9761
  name: "agent_id",
9688
9762
  description: "Agent ID as `agent list` prints it (raw host name, e.g. jarvis.example.zone)"
@@ -9706,7 +9780,7 @@ function createAgentModule() {
9706
9780
  inputSchema: { type: "object", properties: {}, additionalProperties: false },
9707
9781
  outputSchema: {
9708
9782
  type: "object",
9709
- properties: { agents: { type: "array", items: OBJECT_OUTPUT$3 } },
9783
+ properties: { agents: { type: "array", items: OBJECT_OUTPUT$4 } },
9710
9784
  required: ["agents"],
9711
9785
  additionalProperties: false
9712
9786
  },
@@ -9732,7 +9806,7 @@ function createAgentModule() {
9732
9806
  summary: "Get one Agent: profile, settings, install state, template, and runtime",
9733
9807
  positionals: [AGENT_POSITIONAL],
9734
9808
  inputSchema: AGENT_INPUT,
9735
- outputSchema: OBJECT_OUTPUT$3,
9809
+ outputSchema: OBJECT_OUTPUT$4,
9736
9810
  resultSchemaVersion: 1,
9737
9811
  access: { mode: "fixed", level: "read" },
9738
9812
  asyncMode: "sync",
@@ -9745,7 +9819,7 @@ function createAgentModule() {
9745
9819
  summary: "Get the public profile (display name, bio, avatar) of an Agent",
9746
9820
  positionals: [AGENT_POSITIONAL],
9747
9821
  inputSchema: AGENT_INPUT,
9748
- outputSchema: OBJECT_OUTPUT$3,
9822
+ outputSchema: OBJECT_OUTPUT$4,
9749
9823
  resultSchemaVersion: 1,
9750
9824
  access: { mode: "fixed", level: "read" },
9751
9825
  asyncMode: "sync",
@@ -9786,8 +9860,8 @@ function createAgentModule() {
9786
9860
  type: "object",
9787
9861
  properties: {
9788
9862
  agent_id: { type: "string" },
9789
- before: OBJECT_OUTPUT$3,
9790
- profile: OBJECT_OUTPUT$3
9863
+ before: OBJECT_OUTPUT$4,
9864
+ profile: OBJECT_OUTPUT$4
9791
9865
  },
9792
9866
  required: ["agent_id", "before", "profile"],
9793
9867
  additionalProperties: false
@@ -9832,7 +9906,7 @@ async function callAgent(ctx, method, params) {
9832
9906
  }
9833
9907
  }
9834
9908
  const AICC = "aicc";
9835
- const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
9909
+ const OBJECT_OUTPUT$3 = { type: "object", additionalProperties: true };
9836
9910
  const EMPTY_INPUT = { type: "object", properties: {}, additionalProperties: false };
9837
9911
  const RANGES = ["last1d", "last7d", "last30d"];
9838
9912
  const GROUPS = [
@@ -9880,7 +9954,7 @@ function quotaCommand() {
9880
9954
  properties: { app: { type: "string", minLength: 1 } },
9881
9955
  additionalProperties: false
9882
9956
  },
9883
- outputSchema: OBJECT_OUTPUT$2,
9957
+ outputSchema: OBJECT_OUTPUT$3,
9884
9958
  resultSchemaVersion: 1,
9885
9959
  access: { mode: "fixed", level: "read" },
9886
9960
  asyncMode: "sync",
@@ -9898,7 +9972,7 @@ function readCommand$1(options) {
9898
9972
  summary: options.summary,
9899
9973
  description: options.description,
9900
9974
  inputSchema: EMPTY_INPUT,
9901
- outputSchema: OBJECT_OUTPUT$2,
9975
+ outputSchema: OBJECT_OUTPUT$3,
9902
9976
  resultSchemaVersion: 1,
9903
9977
  access: { mode: "fixed", level: "read" },
9904
9978
  asyncMode: "sync",
@@ -9950,7 +10024,7 @@ function usageCommand() {
9950
10024
  },
9951
10025
  additionalProperties: false
9952
10026
  },
9953
- outputSchema: OBJECT_OUTPUT$2,
10027
+ outputSchema: OBJECT_OUTPUT$3,
9954
10028
  resultSchemaVersion: 1,
9955
10029
  access: { mode: "fixed", level: "read" },
9956
10030
  asyncMode: "sync",
@@ -9995,8 +10069,8 @@ function timeRange(input) {
9995
10069
  }
9996
10070
  return { kind: "explicit", start_time_ms: since, end_time_ms: until ?? Date.now() };
9997
10071
  }
9998
- const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
9999
- const DAY_MS = 864e5;
10072
+ const OBJECT_OUTPUT$2 = { type: "object", additionalProperties: true };
10073
+ const DAY_MS$1 = 864e5;
10000
10074
  const EXPIRES_HELP = "1d, 7d (default), 30d, none, or an RFC 3339 time";
10001
10075
  function createShareModule() {
10002
10076
  return {
@@ -10005,7 +10079,7 @@ function createShareModule() {
10005
10079
  commands: [
10006
10080
  createCommand(),
10007
10081
  listCommand(),
10008
- getCommand(),
10082
+ getCommand$1(),
10009
10083
  updateCommand(),
10010
10084
  stopCommand(),
10011
10085
  statsCommand()
@@ -10017,7 +10091,7 @@ async function openNfsp(ctx) {
10017
10091
  if (!session)
10018
10092
  throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
10019
10093
  const token = (await session.ensureValid()).token;
10020
- const base = gatewayOrigin(ctx.connection.endpoint);
10094
+ const base = gatewayOrigin$1(ctx.connection.endpoint);
10021
10095
  let seq = 0;
10022
10096
  const post = async (method, body) => {
10023
10097
  const response = await fetch(`${base}/nfs/v1/${method}`, {
@@ -10048,7 +10122,7 @@ async function openNfsp(ctx) {
10048
10122
  call: (method, args, write = false) => post(method, { session: sessionId, args: { ...args, source_hint: "cli" }, ...write ? { seq: ++seq } : {} })
10049
10123
  };
10050
10124
  }
10051
- function gatewayOrigin(endpoint) {
10125
+ function gatewayOrigin$1(endpoint) {
10052
10126
  const url = new URL(endpoint);
10053
10127
  const marker = url.pathname.indexOf("/kapi");
10054
10128
  url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
@@ -10064,7 +10138,7 @@ function parseExpires(value) {
10064
10138
  return null;
10065
10139
  const days = text2.match(/^(\d+)d$/);
10066
10140
  if (days)
10067
- return Math.floor((Date.now() + Number(days[1]) * DAY_MS) / 1e3);
10141
+ return Math.floor((Date.now() + Number(days[1]) * DAY_MS$1) / 1e3);
10068
10142
  const at = parseTimestamp(value, "expires");
10069
10143
  if (at === void 0)
10070
10144
  return void 0;
@@ -10106,7 +10180,7 @@ function createCommand() {
10106
10180
  required: ["path"],
10107
10181
  additionalProperties: false
10108
10182
  },
10109
- outputSchema: OBJECT_OUTPUT$1,
10183
+ outputSchema: OBJECT_OUTPUT$2,
10110
10184
  resultSchemaVersion: 1,
10111
10185
  access: { mode: "fixed", level: "write" },
10112
10186
  asyncMode: "either",
@@ -10175,7 +10249,7 @@ function listCommand() {
10175
10249
  },
10176
10250
  additionalProperties: false
10177
10251
  },
10178
- outputSchema: OBJECT_OUTPUT$1,
10252
+ outputSchema: OBJECT_OUTPUT$2,
10179
10253
  resultSchemaVersion: 1,
10180
10254
  access: { mode: "fixed", level: "read" },
10181
10255
  asyncMode: "sync",
@@ -10196,7 +10270,7 @@ function listCommand() {
10196
10270
  }
10197
10271
  };
10198
10272
  }
10199
- function getCommand() {
10273
+ function getCommand$1() {
10200
10274
  return {
10201
10275
  verb: "get",
10202
10276
  summary: "Show one share: link, policy, snapshot, delivery, statistics and history",
@@ -10207,7 +10281,7 @@ function getCommand() {
10207
10281
  required: ["share_id"],
10208
10282
  additionalProperties: false
10209
10283
  },
10210
- outputSchema: OBJECT_OUTPUT$1,
10284
+ outputSchema: OBJECT_OUTPUT$2,
10211
10285
  resultSchemaVersion: 1,
10212
10286
  access: { mode: "fixed", level: "read" },
10213
10287
  asyncMode: "sync",
@@ -10244,7 +10318,7 @@ function updateCommand() {
10244
10318
  required: ["share_id"],
10245
10319
  additionalProperties: false
10246
10320
  },
10247
- outputSchema: OBJECT_OUTPUT$1,
10321
+ outputSchema: OBJECT_OUTPUT$2,
10248
10322
  resultSchemaVersion: 1,
10249
10323
  access: { mode: "fixed", level: "write" },
10250
10324
  asyncMode: "sync",
@@ -10288,7 +10362,7 @@ function stopCommand() {
10288
10362
  required: ["share_id"],
10289
10363
  additionalProperties: false
10290
10364
  },
10291
- outputSchema: OBJECT_OUTPUT$1,
10365
+ outputSchema: OBJECT_OUTPUT$2,
10292
10366
  resultSchemaVersion: 1,
10293
10367
  access: { mode: "fixed", level: "destructive" },
10294
10368
  asyncMode: "sync",
@@ -10320,7 +10394,7 @@ function statsCommand() {
10320
10394
  },
10321
10395
  additionalProperties: false
10322
10396
  },
10323
- outputSchema: OBJECT_OUTPUT$1,
10397
+ outputSchema: OBJECT_OUTPUT$2,
10324
10398
  resultSchemaVersion: 1,
10325
10399
  access: { mode: "fixed", level: "read" },
10326
10400
  asyncMode: "sync",
@@ -10339,6 +10413,396 @@ function statsCommand() {
10339
10413
  }
10340
10414
  };
10341
10415
  }
10416
+ const OBJECT_OUTPUT$1 = { type: "object", additionalProperties: true };
10417
+ const SERVICE$1 = "nfs-server";
10418
+ const MAX_PUT_BYTES = 32 * 1024 * 1024;
10419
+ const DAY_MS = 864e5;
10420
+ const BUCKET_ERROR_CODES = [
10421
+ "bucket_not_found",
10422
+ "no_such_key",
10423
+ "invalid_key",
10424
+ "invalid_argument",
10425
+ "precondition_failed",
10426
+ "permission_denied",
10427
+ "quota_exceeded",
10428
+ "object_too_large",
10429
+ "content_not_available",
10430
+ "content_evicted",
10431
+ "origin_unavailable",
10432
+ "kind_mismatch",
10433
+ "policy_violation",
10434
+ "origin_required",
10435
+ "not_held",
10436
+ "token_invalid",
10437
+ "conflict",
10438
+ "store_error",
10439
+ "db_error",
10440
+ "internal_error"
10441
+ ];
10442
+ function createBucketModule() {
10443
+ return {
10444
+ name: "bucket",
10445
+ summary: "Read and write application object buckets (key -> object, retained by the Zone)",
10446
+ commands: [lsCommand(), statCommand(), putCommand(), getCommand(), rmCommand(), linkCommand(), s3KeysCommand(), s3KeyCreateCommand(), s3KeyRevokeCommand()]
10447
+ };
10448
+ }
10449
+ function parseBucketTarget(value, keyRequired) {
10450
+ const path = value.startsWith("obj://bucket/") ? value.slice("obj://bucket/".length) : value;
10451
+ const parts = path.split("/");
10452
+ if (parts.length < 4 || !["user", "zone"].includes(parts[0]) || parts.slice(0, 4).some((p) => !p)) {
10453
+ throw new UsageError("INVALID_ARGUMENT", `'${value}' is not obj://bucket/<scope>/<appid>/<owner>/<name>[/<key>]`);
10454
+ }
10455
+ const key = parts.slice(4).join("/");
10456
+ if (keyRequired && !key)
10457
+ throw new UsageError("INVALID_ARGUMENT", `'${value}' names no key`);
10458
+ return { bucketId: parts.slice(0, 4).join("/"), key };
10459
+ }
10460
+ async function call$1(ctx, method, params) {
10461
+ try {
10462
+ return await callService(ctx, SERVICE$1, method, params);
10463
+ } catch (error) {
10464
+ const message = error instanceof Error ? error.message : String(error);
10465
+ const code = BUCKET_ERROR_CODES.find((c) => message.includes(`${c}: `));
10466
+ if (code)
10467
+ throw new ToolError(`BUCKET_${code.toUpperCase()}`, message);
10468
+ throw error;
10469
+ }
10470
+ }
10471
+ function gatewayOrigin(endpoint) {
10472
+ const url = new URL(endpoint);
10473
+ const marker = url.pathname.indexOf("/kapi");
10474
+ url.pathname = marker >= 0 ? url.pathname.slice(0, marker) || "/" : "/";
10475
+ url.search = "";
10476
+ url.hash = "";
10477
+ return url.toString().replace(/\/$/, "");
10478
+ }
10479
+ function objectUrl(ctx, target, query = {}) {
10480
+ const qs = new URLSearchParams(query).toString();
10481
+ const key = target.key.split("/").map(encodeURIComponent).join("/");
10482
+ return `${gatewayOrigin(ctx.connection.endpoint)}/bucket/v1/${target.bucketId}/${key}${qs ? `?${qs}` : ""}`;
10483
+ }
10484
+ async function bearer(ctx) {
10485
+ if (!ctx.session)
10486
+ throw new ToolError("AUTH_REQUIRED", "authenticated session is required", 3);
10487
+ return { Authorization: `Bearer ${(await ctx.session.ensureValid()).token}` };
10488
+ }
10489
+ async function failure(response) {
10490
+ let body = {};
10491
+ try {
10492
+ body = await response.json();
10493
+ } catch {
10494
+ throw new ToolError("INVALID_SERVICE_RESPONSE", `bucket data plane answered HTTP ${response.status}`, EXIT_INTERNAL);
10495
+ }
10496
+ throw new ToolError(`BUCKET_${String(body.error ?? response.status).toUpperCase()}`, String(body.message ?? `HTTP ${response.status}`));
10497
+ }
10498
+ const TARGET = { name: "target", description: "obj://bucket/<scope>/<appid>/<owner>/<name>[/<key>]", required: true };
10499
+ function lsCommand() {
10500
+ return {
10501
+ verb: "ls",
10502
+ summary: "List your buckets, or the keys of one bucket",
10503
+ positionals: [{ ...TARGET, required: false }],
10504
+ options: [
10505
+ { name: "delimiter", description: "Fold keys at this delimiter (e.g. /)", type: "string" },
10506
+ { name: "start-after", property: "start_after", description: "Continue after this key", type: "string" },
10507
+ { name: "limit", description: "Page size, at most 1000", type: "integer" },
10508
+ { name: "appid", description: "Only buckets of this app (no target)", type: "string" }
10509
+ ],
10510
+ inputSchema: {
10511
+ type: "object",
10512
+ properties: {
10513
+ target: { type: "string", minLength: 1 },
10514
+ delimiter: { type: "string", minLength: 1 },
10515
+ start_after: { type: "string", minLength: 1 },
10516
+ limit: { type: "integer", minimum: 1 },
10517
+ appid: { type: "string", minLength: 1 }
10518
+ },
10519
+ additionalProperties: false
10520
+ },
10521
+ outputSchema: OBJECT_OUTPUT$1,
10522
+ resultSchemaVersion: 1,
10523
+ access: { mode: "fixed", level: "read" },
10524
+ asyncMode: "sync",
10525
+ requiresSession: true,
10526
+ examples: ["buckyos bucket ls", "buckyos bucket ls obj://bucket/user/photos/alice/library/2026/ --delimiter /"],
10527
+ handler: async (ctx, input) => {
10528
+ const raw = inputString(input, "target");
10529
+ if (!raw)
10530
+ return { buckets: await call$1(ctx, "bucket.list", { appid: inputString(input, "appid") }) };
10531
+ const target = parseBucketTarget(raw, false);
10532
+ return await call$1(ctx, "bucket.list_objects", {
10533
+ bucket_id: target.bucketId,
10534
+ prefix: target.key,
10535
+ delimiter: inputString(input, "delimiter"),
10536
+ start_after: inputString(input, "start_after"),
10537
+ limit: input.limit
10538
+ });
10539
+ }
10540
+ };
10541
+ }
10542
+ function statCommand() {
10543
+ return {
10544
+ verb: "stat",
10545
+ summary: "Show a bucket (usage, quota) or a key (binding and where its content is)",
10546
+ positionals: [TARGET],
10547
+ options: [{ name: "version", description: "A specific version of the key", type: "integer" }],
10548
+ inputSchema: {
10549
+ type: "object",
10550
+ properties: { target: { type: "string", minLength: 1 }, version: { type: "integer", minimum: 1 } },
10551
+ required: ["target"],
10552
+ additionalProperties: false
10553
+ },
10554
+ outputSchema: OBJECT_OUTPUT$1,
10555
+ resultSchemaVersion: 1,
10556
+ access: { mode: "fixed", level: "read" },
10557
+ asyncMode: "sync",
10558
+ requiresSession: true,
10559
+ examples: ["buckyos bucket stat obj://bucket/user/photos/alice/library", "buckyos bucket stat obj://bucket/user/photos/alice/library/a.jpg"],
10560
+ handler: async (ctx, input) => {
10561
+ const target = parseBucketTarget(requiredInputString(input, "target"), false);
10562
+ if (!target.key) {
10563
+ const [bucket, quota] = await Promise.all([
10564
+ call$1(ctx, "bucket.stat", { bucket_id: target.bucketId }),
10565
+ call$1(ctx, "bucket.get_quota", { bucket_id: target.bucketId })
10566
+ ]);
10567
+ return { bucket, quota };
10568
+ }
10569
+ return await call$1(ctx, "bucket.head", { bucket_id: target.bucketId, key: target.key, version: input.version });
10570
+ }
10571
+ };
10572
+ }
10573
+ function putCommand() {
10574
+ return {
10575
+ verb: "put",
10576
+ summary: "Store a local file (up to 32 MiB) under a key; success means the Zone retains it",
10577
+ positionals: [TARGET, { name: "file", description: "Local file to upload", required: true }],
10578
+ options: [
10579
+ { name: "content-type", property: "content_type", description: "Content-Type of the object", type: "string" },
10580
+ { name: "if-absent", property: "if_absent", description: "Fail if the key already exists", type: "boolean" },
10581
+ { name: "expires", description: "Unbind after: 1d, 7d, or an RFC 3339 time (temp/cache/app_data buckets)", type: "string" }
10582
+ ],
10583
+ inputSchema: {
10584
+ type: "object",
10585
+ properties: {
10586
+ target: { type: "string", minLength: 1 },
10587
+ file: { type: "string", minLength: 1 },
10588
+ content_type: { type: "string", minLength: 1 },
10589
+ if_absent: { type: "boolean" },
10590
+ expires: { type: "string", minLength: 1 }
10591
+ },
10592
+ required: ["target", "file"],
10593
+ additionalProperties: false
10594
+ },
10595
+ outputSchema: OBJECT_OUTPUT$1,
10596
+ resultSchemaVersion: 1,
10597
+ access: { mode: "fixed", level: "write" },
10598
+ asyncMode: "sync",
10599
+ requiresSession: true,
10600
+ networkAccess: true,
10601
+ examples: ["buckyos bucket put obj://bucket/user/photos/alice/library/2026/a.jpg ./a.jpg --content-type image/jpeg"],
10602
+ handler: async (ctx, input) => {
10603
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10604
+ const bytes = await getHost().readFile(requiredInputString(input, "file"));
10605
+ if (bytes.byteLength > MAX_PUT_BYTES) {
10606
+ throw new UsageError("FILE_TOO_LARGE", "files over 32 MiB go through the SDK upload (ndm.startUpload with bind)");
10607
+ }
10608
+ const headers = { ...await bearer(ctx) };
10609
+ const contentType = inputString(input, "content_type");
10610
+ if (contentType)
10611
+ headers["Content-Type"] = contentType;
10612
+ if (input.if_absent === true)
10613
+ headers["If-None-Match"] = "*";
10614
+ const expires = inputString(input, "expires");
10615
+ if (expires) {
10616
+ const days = expires.match(/^(\d+)d$/);
10617
+ const at = days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(expires, "expires");
10618
+ if (at !== void 0)
10619
+ headers["x-bucky-expires-at"] = String(at);
10620
+ }
10621
+ const response = await fetch(objectUrl(ctx, target), { method: "PUT", headers, body: new Blob([bytes]), signal: ctx.signal });
10622
+ if (!response.ok)
10623
+ await failure(response);
10624
+ return await response.json();
10625
+ }
10626
+ };
10627
+ }
10628
+ function getCommand() {
10629
+ return {
10630
+ verb: "get",
10631
+ summary: "Download a key to a local file",
10632
+ positionals: [TARGET, { name: "output", description: "Local file to write", required: true }],
10633
+ options: [{ name: "version", description: "A specific version of the key", type: "integer" }],
10634
+ inputSchema: {
10635
+ type: "object",
10636
+ properties: {
10637
+ target: { type: "string", minLength: 1 },
10638
+ output: { type: "string", minLength: 1 },
10639
+ version: { type: "integer", minimum: 1 }
10640
+ },
10641
+ required: ["target", "output"],
10642
+ additionalProperties: false
10643
+ },
10644
+ outputSchema: OBJECT_OUTPUT$1,
10645
+ resultSchemaVersion: 1,
10646
+ access: { mode: "fixed", level: "read" },
10647
+ asyncMode: "sync",
10648
+ requiresSession: true,
10649
+ networkAccess: true,
10650
+ examples: ["buckyos bucket get obj://bucket/user/photos/alice/library/2026/a.jpg ./a.jpg"],
10651
+ handler: async (ctx, input) => {
10652
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10653
+ const query = input.version !== void 0 ? { version: String(input.version) } : {};
10654
+ const response = await fetch(objectUrl(ctx, target, query), { headers: await bearer(ctx), signal: ctx.signal });
10655
+ if (!response.ok)
10656
+ await failure(response);
10657
+ const bytes = new Uint8Array(await response.arrayBuffer());
10658
+ const output = requiredInputString(input, "output");
10659
+ await getHost().writeFile(output, bytes);
10660
+ return {
10661
+ output,
10662
+ size: bytes.byteLength,
10663
+ obj_id: response.headers.get("x-bucky-obj-id"),
10664
+ version: Number(response.headers.get("x-bucky-version")),
10665
+ content_type: response.headers.get("content-type")
10666
+ };
10667
+ }
10668
+ };
10669
+ }
10670
+ function rmCommand() {
10671
+ return {
10672
+ verb: "rm",
10673
+ summary: "Unbind a key (the bucket stops retaining its content)",
10674
+ positionals: [TARGET],
10675
+ options: [{ name: "version", description: "Remove only this version", type: "integer" }],
10676
+ inputSchema: {
10677
+ type: "object",
10678
+ properties: { target: { type: "string", minLength: 1 }, version: { type: "integer", minimum: 1 } },
10679
+ required: ["target"],
10680
+ additionalProperties: false
10681
+ },
10682
+ outputSchema: OBJECT_OUTPUT$1,
10683
+ resultSchemaVersion: 1,
10684
+ access: { mode: "fixed", level: "write" },
10685
+ asyncMode: "sync",
10686
+ requiresSession: true,
10687
+ examples: ["buckyos bucket rm obj://bucket/user/photos/alice/library/2026/a.jpg"],
10688
+ handler: async (ctx, input) => {
10689
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10690
+ return await call$1(ctx, "bucket.delete", { bucket_id: target.bucketId, key: target.key, version: input.version });
10691
+ }
10692
+ };
10693
+ }
10694
+ function linkCommand() {
10695
+ return {
10696
+ verb: "link",
10697
+ summary: "Create a revocable read link to one key (up to 7 days, no Zone account needed)",
10698
+ positionals: [TARGET],
10699
+ options: [
10700
+ { name: "expires", description: "1d (default) to 7d, or an RFC 3339 time", type: "string" },
10701
+ { name: "max-uses", property: "max_uses", description: "Stop after this many reads", type: "integer" }
10702
+ ],
10703
+ inputSchema: {
10704
+ type: "object",
10705
+ properties: {
10706
+ target: { type: "string", minLength: 1 },
10707
+ expires: { type: "string", minLength: 1 },
10708
+ max_uses: { type: "integer", minimum: 1 }
10709
+ },
10710
+ required: ["target"],
10711
+ additionalProperties: false
10712
+ },
10713
+ outputSchema: OBJECT_OUTPUT$1,
10714
+ resultSchemaVersion: 1,
10715
+ access: { mode: "fixed", level: "write" },
10716
+ asyncMode: "sync",
10717
+ requiresSession: true,
10718
+ examples: ["buckyos bucket link obj://bucket/user/photos/alice/library/2026/a.jpg --expires 3d"],
10719
+ handler: async (ctx, input) => {
10720
+ const target = parseBucketTarget(requiredInputString(input, "target"), true);
10721
+ const text2 = inputString(input, "expires") ?? "1d";
10722
+ const days = text2.match(/^(\d+)d$/);
10723
+ const expiresAt = days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
10724
+ if (expiresAt === void 0)
10725
+ throw new UsageError("INVALID_ARGUMENT", "expires is required");
10726
+ const issued = await call$1(ctx, "bucket.create_access_token", {
10727
+ bucket_id: target.bucketId,
10728
+ key: target.key,
10729
+ actions: ["read"],
10730
+ expires_at: expiresAt,
10731
+ max_uses: input.max_uses
10732
+ });
10733
+ return { ...issued, url: `${gatewayOrigin(ctx.connection.endpoint)}${String(issued.path)}` };
10734
+ }
10735
+ };
10736
+ }
10737
+ function s3KeysCommand() {
10738
+ return {
10739
+ verb: "s3-keys",
10740
+ summary: "List your S3 access keys (secrets are shown only when created)",
10741
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
10742
+ outputSchema: OBJECT_OUTPUT$1,
10743
+ resultSchemaVersion: 1,
10744
+ access: { mode: "fixed", level: "read" },
10745
+ asyncMode: "sync",
10746
+ requiresSession: true,
10747
+ examples: ["buckyos bucket s3-keys"],
10748
+ handler: async (ctx) => ({ keys: await call$1(ctx, "bucket.list_s3_keys", {}) })
10749
+ };
10750
+ }
10751
+ function s3KeyCreateCommand() {
10752
+ return {
10753
+ verb: "s3-key-create",
10754
+ summary: "Issue an S3 access key for one of your apps (endpoint https://<zone>/s3 or https://s3.<zone>)",
10755
+ options: [
10756
+ { name: "app", description: "App id whose buckets the key reaches", type: "string" },
10757
+ { name: "prefix", description: "Only keys under this prefix", type: "string" },
10758
+ { name: "expires", description: "Expiry: 30d, or an RFC 3339 time (default: none)", type: "string" }
10759
+ ],
10760
+ inputSchema: {
10761
+ type: "object",
10762
+ properties: { app: { type: "string", minLength: 1 }, prefix: { type: "string", minLength: 1 }, expires: { type: "string", minLength: 1 } },
10763
+ required: ["app"],
10764
+ additionalProperties: false
10765
+ },
10766
+ outputSchema: OBJECT_OUTPUT$1,
10767
+ resultSchemaVersion: 1,
10768
+ access: { mode: "fixed", level: "write" },
10769
+ asyncMode: "sync",
10770
+ requiresSession: true,
10771
+ examples: ["buckyos bucket s3-key-create --app photos.app.bns.did --expires 30d"],
10772
+ handler: async (ctx, input) => {
10773
+ const text2 = inputString(input, "expires");
10774
+ const days = text2?.match(/^(\d+)d$/);
10775
+ const expiresAt = !text2 ? void 0 : days ? Date.now() + Number(days[1]) * DAY_MS : parseTimestamp(text2, "expires");
10776
+ const prefix = inputString(input, "prefix");
10777
+ const key = await call$1(ctx, "bucket.create_s3_key", {
10778
+ appid: requiredInputString(input, "app"),
10779
+ scope: prefix ? { prefix } : void 0,
10780
+ expires_at: expiresAt
10781
+ });
10782
+ return { ...key, endpoint: `${gatewayOrigin(ctx.connection.endpoint)}/s3`, region: "us-east-1", path_style: true };
10783
+ }
10784
+ };
10785
+ }
10786
+ function s3KeyRevokeCommand() {
10787
+ return {
10788
+ verb: "s3-key-revoke",
10789
+ summary: "Revoke an S3 access key (its presigned URLs stop working too)",
10790
+ positionals: [{ name: "access_key_id", description: "Access key id (BK…)", required: true }],
10791
+ inputSchema: {
10792
+ type: "object",
10793
+ properties: { access_key_id: { type: "string", minLength: 1 } },
10794
+ required: ["access_key_id"],
10795
+ additionalProperties: false
10796
+ },
10797
+ outputSchema: OBJECT_OUTPUT$1,
10798
+ resultSchemaVersion: 1,
10799
+ access: { mode: "fixed", level: "write" },
10800
+ asyncMode: "sync",
10801
+ requiresSession: true,
10802
+ examples: ["buckyos bucket s3-key-revoke BKABCDEFGHIJKLMNOPQR"],
10803
+ handler: async (ctx, input) => await call$1(ctx, "bucket.revoke_s3_key", { access_key_id: requiredInputString(input, "access_key_id") })
10804
+ };
10805
+ }
10342
10806
  const text = { type: "string", minLength: 1 };
10343
10807
  const object = { type: "object", additionalProperties: true };
10344
10808
  const targetProperties = {
@@ -11125,6 +11589,7 @@ function createRegistry(pikgDependencies, appDependencies, logDependencies, diag
11125
11589
  registry.register(createAgentModule());
11126
11590
  registry.register(createAiModule());
11127
11591
  registry.register(createShareModule());
11592
+ registry.register(createBucketModule());
11128
11593
  registry.register(createExecutorModule());
11129
11594
  registry.register(createAiwsModule());
11130
11595
  return registry;