busa-cli 0.11.2 → 0.11.4

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.
@@ -126,6 +126,11 @@ import { basename as basename2, extname as extname2 } from "path";
126
126
 
127
127
  // ../../packages/busabase-contract/src/tasks/base-field.ts
128
128
  var OPERATIONS = ["add", "update", "delete", "convert", "reorder", "restore"];
129
+ var mergeIntent = (input) => {
130
+ if (input.requireReview) return { autoMerge: false };
131
+ if (input.autoMerge) return { autoMerge: true };
132
+ return {};
133
+ };
129
134
  var REQUIRED_BY_OPERATION = {
130
135
  add: ["slug", "name"],
131
136
  update: ["fieldId", "patch"],
@@ -147,7 +152,7 @@ var baseFieldChangeTask = {
147
152
  name: "base_field_change_request",
148
153
  cliPath: ["bases", "field-change-request"],
149
154
  summary: "Propose a Base schema change (add / update / delete / convert / reorder / restore)",
150
- guidance: "Approval-first: proposes a ChangeRequest, it does not alter the schema directly. Pick `operation` first, then supply only that operation's arguments \u2014 add needs slug+name; update needs fieldId+patch; delete/restore need fieldId; convert needs fieldId+newType; reorder needs the complete fieldIds order. Before a convert, `bases_preview_field_conversion` shows what the data would become.",
155
+ guidance: "Review is permission-aware for add / update / reorder / restore, decided server-side: the change merges immediately when your key has write access on the Base's node and lands as a pending ChangeRequest otherwise \u2014 check the response's `status`. Pass requireReview to always propose instead. `delete` and `convert` are ALWAYS review-first regardless of permission, by design: delete soft-deletes the field's stored values with it, and convert can drop values. Pick `operation` first, then supply only that operation's arguments \u2014 add needs slug+name; update needs fieldId+patch; delete/restore need fieldId; convert needs fieldId+newType; reorder needs the complete fieldIds order. Before a convert, `bases_preview_field_conversion` shows what the data would become.",
151
156
  annotations: { readOnly: false, destructive: false },
152
157
  params: [
153
158
  { name: "baseId", kind: "string", required: true, description: "Base to change." },
@@ -220,7 +225,19 @@ var baseFieldChangeTask = {
220
225
  description: "Complete field order (reorder only). Repeat the flag per field."
221
226
  },
222
227
  { name: "message", kind: "string", description: "Explanation for the reviewer." },
223
- { name: "submittedBy", kind: "string", description: "Producer label recorded on the change." }
228
+ { name: "submittedBy", kind: "string", description: "Producer label recorded on the change." },
229
+ {
230
+ name: "autoMerge",
231
+ kind: "boolean",
232
+ appliesWhen: { param: "operation", values: ["add", "update", "reorder", "restore"] },
233
+ description: "Skip review and apply the schema change immediately if you have write access. Not a permission override \u2014 a changeRequest-level key still gets a pending CR. Default is permission-aware: merge when you can, otherwise propose."
234
+ },
235
+ {
236
+ name: "requireReview",
237
+ kind: "boolean",
238
+ appliesWhen: { param: "operation", values: ["add", "update", "reorder", "restore"] },
239
+ description: "Always propose a pending ChangeRequest, even with write access. delete and convert are review-first regardless."
240
+ }
224
241
  ],
225
242
  examples: [
226
243
  "busabase-cli bases field-change-request --base-id bas_1 --operation add --slug status --name Status --field-type select",
@@ -232,7 +249,8 @@ var baseFieldChangeTask = {
232
249
  const common = {
233
250
  baseId: input.baseId,
234
251
  ...input.message ? { message: input.message } : {},
235
- ...input.submittedBy ? { submittedBy: input.submittedBy } : {}
252
+ ...input.submittedBy ? { submittedBy: input.submittedBy } : {},
253
+ ...mergeIntent(input)
236
254
  };
237
255
  switch (input.operation) {
238
256
  case "add":
@@ -557,6 +575,11 @@ var nodeReadFileTask = {
557
575
  type: resolveKind(input.kind)
558
576
  })
559
577
  };
578
+ var mergeIntent2 = (input) => {
579
+ if (input.requireReview) return { autoMerge: false };
580
+ if (input.autoMerge) return { autoMerge: true };
581
+ return {};
582
+ };
560
583
  var nodeFilesChangeRequestTask = {
561
584
  name: "node_files_change_request",
562
585
  cliPath: ["nodes", "files-change-request"],
@@ -578,7 +601,7 @@ var nodeFilesChangeRequestTask = {
578
601
  }
579
602
  ],
580
603
  summary: "Propose file changes inside a Skill, Drive, or AirApp node",
581
- guidance: 'Approval-first: this proposes a ChangeRequest for a human to review, it does not write directly. Each operation is one of create / update / delete / metadata_update. Include `baseContentHash` (from `node_file_read`) on an update so a concurrent edit is caught. For kind "airapp", keep the project runnable by `npm run dev` \u2014 editing package.json must leave a "dev" script starting a plain Node server, not a bundler dev server.',
604
+ guidance: 'Review is permission-aware, decided server-side: the change merges immediately when your key has write access on the node and lands as a pending ChangeRequest otherwise \u2014 check the response\'s `status`. Pass requireReview to always propose instead. A batch containing a `delete` is ALWAYS review-first regardless of permission, by design \u2014 deleting a mounted file destroys content, and a batch is never partially merged. Each operation is one of create / update / delete / metadata_update. Include `baseContentHash` (from `node_file_read`) on an update so a concurrent edit is caught. For kind "airapp", keep the project runnable by `npm run dev` \u2014 editing package.json must leave a "dev" script starting a plain Node server, not a bundler dev server.',
582
605
  annotations: { readOnly: false, destructive: false },
583
606
  params: [
584
607
  kindParam,
@@ -594,10 +617,21 @@ var nodeFilesChangeRequestTask = {
594
617
  kind: "string",
595
618
  description: 'Explanation for the reviewer. Conventional-commit style, e.g. "Rewrite README quickstart for the new auth flow".'
596
619
  },
597
- { name: "submittedBy", kind: "string", description: "Producer label recorded on the change." }
620
+ { name: "submittedBy", kind: "string", description: "Producer label recorded on the change." },
621
+ {
622
+ name: "autoMerge",
623
+ kind: "boolean",
624
+ description: "Skip review and apply the file changes immediately if you have write access. Not a permission override, and ignored for a batch containing a delete. Default is permission-aware: merge when you can, otherwise propose."
625
+ },
626
+ {
627
+ name: "requireReview",
628
+ kind: "boolean",
629
+ description: "Always propose a pending ChangeRequest, even with write access."
630
+ }
598
631
  ],
599
632
  examples: [
600
- `busabase-cli nodes files-change-request --kind skill --node-id nod_123 --operations-json '[{"kind":"update","path":"SKILL.md","content":"# Hi"}]'`
633
+ `busabase-cli nodes files-change-request --kind skill --node-id nod_123 --operations-json '[{"kind":"update","path":"SKILL.md","content":"# Hi"}]'`,
634
+ "busabase-cli nodes files-change-request --kind skill --node-id nod_123 --operations-json @ops.json --require-review"
601
635
  ],
602
636
  execute: async (client, input) => {
603
637
  if (!Array.isArray(input.operations) || input.operations.length === 0) {
@@ -608,7 +642,8 @@ var nodeFilesChangeRequestTask = {
608
642
  type: resolveKind(input.kind),
609
643
  operations: input.operations,
610
644
  ...input.message ? { message: input.message } : {},
611
- ...input.submittedBy ? { submittedBy: input.submittedBy } : {}
645
+ ...input.submittedBy ? { submittedBy: input.submittedBy } : {},
646
+ ...mergeIntent2(input)
612
647
  };
613
648
  return client.fileTrees.createChangeRequest(payload);
614
649
  }
@@ -1119,7 +1154,7 @@ var rejectMismatchedPayload = (input) => {
1119
1154
  );
1120
1155
  }
1121
1156
  };
1122
- var mergeIntent = (input) => {
1157
+ var mergeIntent3 = (input) => {
1123
1158
  if (input.requireReview) return { autoMerge: false };
1124
1159
  if (input.autoMerge) return { autoMerge: true };
1125
1160
  return {};
@@ -1248,7 +1283,7 @@ var nodeCreateTask = {
1248
1283
  name: input.name,
1249
1284
  description: input.description,
1250
1285
  parentNodeId: input.parentNodeId,
1251
- ...mergeIntent(input)
1286
+ ...mergeIntent3(input)
1252
1287
  };
1253
1288
  if (FILE_TREE_TYPES.has(type)) {
1254
1289
  const payload = {
@@ -1279,7 +1314,7 @@ var nodeCreateTask = {
1279
1314
  return client.nodes.createChangeRequest({
1280
1315
  message: input.message ?? `Create ${type} ${input.name}`,
1281
1316
  submittedBy: input.submittedBy,
1282
- ...mergeIntent(input),
1317
+ ...mergeIntent3(input),
1283
1318
  operations: [
1284
1319
  {
1285
1320
  kind: "create",
@@ -1296,7 +1331,7 @@ var nodeCreateTask = {
1296
1331
 
1297
1332
  // ../../packages/busabase-contract/src/tasks/record-change.ts
1298
1333
  var OPERATIONS2 = ["update", "delete", "restore"];
1299
- var mergeIntent2 = (input) => {
1334
+ var mergeIntent4 = (input) => {
1300
1335
  if (input.requireReview) return { autoMerge: false };
1301
1336
  if (input.autoMerge) return { autoMerge: true };
1302
1337
  return {};
@@ -1362,7 +1397,7 @@ var recordChangeTask = {
1362
1397
  fields: input.fields,
1363
1398
  // Only `update` carries the merge intent — the endpoint's delete/restore
1364
1399
  // branches have no `autoMerge` in their schema at all, by design.
1365
- ...mergeIntent2(input)
1400
+ ...mergeIntent4(input)
1366
1401
  });
1367
1402
  }
1368
1403
  if (input.operation === "delete") {
@@ -1423,7 +1458,7 @@ var recordQueryTask = {
1423
1458
  { path: ["records", "count"], preset: { countOnly: true }, summary: "Count records" }
1424
1459
  ],
1425
1460
  summary: "List records with pagination, or count them",
1426
- guidance: "Always keyset-paginated: when `nextCursor` comes back non-null there ARE more records \u2014 page with it instead of raising `limit` (capped at 100). Pass countOnly to get the total without fetching rows. To find records by a field value use `record_find_by_field`; to search content use `search` or `grep`.",
1461
+ guidance: 'Always keyset-paginated: when `nextCursor` comes back non-null there ARE more records \u2014 page with it instead of raising `limit` (capped at 100). Pass countOnly to get the total without fetching rows \u2014 it is a real, exact SQL count (never an estimate), so it is the right tool for a dashboard total instead of paging through everything and counting client-side. countOnly accepts viewId and/or filters to count a scoped subset (e.g. "PRs on the main branch"); both require baseId. To find records by a field value use `record_find_by_field`; to search content use `search` or `grep`.',
1427
1462
  annotations: { readOnly: true, destructive: false },
1428
1463
  params: [
1429
1464
  { name: "baseId", kind: "string", description: "Restrict to one Base. Omit for the space." },
@@ -1438,20 +1473,29 @@ var recordQueryTask = {
1438
1473
  {
1439
1474
  name: "filters",
1440
1475
  kind: "json",
1441
- description: "View filters pushed down to the server."
1476
+ description: "View filters pushed down to the server. With countOnly, requires baseId; not every filter is a cheap SQL count (see the records.count API description) but the result is always exact."
1442
1477
  },
1443
1478
  { name: "sort", kind: "json", description: "View sort (number/date fields only)." },
1444
- { name: "countOnly", kind: "boolean", description: "Return the total instead of rows." }
1479
+ { name: "countOnly", kind: "boolean", description: "Return the total instead of rows." },
1480
+ {
1481
+ name: "viewId",
1482
+ kind: "string",
1483
+ description: "countOnly only: count the rows this saved View displays. Requires baseId."
1484
+ }
1445
1485
  ],
1446
1486
  examples: [
1447
1487
  "busabase-cli records query --base-id bas_123 --limit 100",
1448
- "busabase-cli records count --base-id bas_123"
1488
+ "busabase-cli records count --base-id bas_123",
1489
+ `busabase-cli records count --base-id bas_123 --filters '[{"fieldSlug":"branch","fieldType":"text","operator":"equals","value":"main"}]'`,
1490
+ "busabase-cli records count --base-id bas_123 --view-id viw_456"
1449
1491
  ],
1450
1492
  execute: async (client, input) => {
1451
1493
  if (input.countOnly) {
1452
- return client.records.count(
1453
- input.baseId ? { baseId: input.baseId } : {}
1454
- );
1494
+ return client.records.count({
1495
+ ...input.baseId ? { baseId: input.baseId } : {},
1496
+ ...input.viewId ? { viewId: input.viewId } : {},
1497
+ ...Array.isArray(input.filters) ? { filters: input.filters } : {}
1498
+ });
1455
1499
  }
1456
1500
  return client.records.list({
1457
1501
  ...input.limit !== void 0 ? { limit: input.limit } : {},
@@ -1465,7 +1509,7 @@ var recordQueryTask = {
1465
1509
 
1466
1510
  // ../../packages/busabase-contract/src/tasks/view-change.ts
1467
1511
  var ACTIONS = ["create", "update", "delete", "restore"];
1468
- var mergeIntent3 = (input) => {
1512
+ var mergeIntent5 = (input) => {
1469
1513
  if (input.requireReview) return { autoMerge: false };
1470
1514
  if (input.autoMerge) return { autoMerge: true };
1471
1515
  return {};
@@ -1544,7 +1588,7 @@ var viewChangeTask = {
1544
1588
  ...input.submittedBy ? { submittedBy: input.submittedBy } : {},
1545
1589
  // Tri-state, like node_create's: omitted keeps the endpoint's
1546
1590
  // permission-aware default, explicit true/false forces the branch.
1547
- ...mergeIntent3(input)
1591
+ ...mergeIntent5(input)
1548
1592
  };
1549
1593
  if (input.action === "create") {
1550
1594
  if (!input.baseId || !input.name) {
@@ -3230,7 +3274,7 @@ import { readFile } from "fs/promises";
3230
3274
  import { join as join3 } from "path";
3231
3275
 
3232
3276
  // ../../packages/busabase-contract/src/domains/package/types.ts
3233
- import { z as z9 } from "zod";
3277
+ import { z as z10 } from "zod";
3234
3278
 
3235
3279
  // ../../packages/openlib/i18n/i-string.ts
3236
3280
  import { z as z5 } from "zod";
@@ -3249,15 +3293,21 @@ var iStringRecordSchema = z5.partialRecord(LocaleSchema, z5.string());
3249
3293
  var iStringSchema = z5.union([z5.string(), iStringRecordSchema]).describe("i18n string");
3250
3294
 
3251
3295
  // ../../packages/busabase-contract/src/domains/base/contract/base-schemas.ts
3296
+ import { z as z7 } from "zod";
3297
+
3298
+ // ../../packages/busabase-contract/src/contract/auto-merge.ts
3252
3299
  import { z as z6 } from "zod";
3253
- var fieldNameSchema = z6.union([
3254
- z6.string().min(1),
3300
+ var autoMergeNotAccepted = (reason) => z6.literal(false, { error: `\`autoMerge: true\` is not accepted here: ${reason}` }).optional().describe(`Only \`false\` (or omitted) is accepted. ${reason}`);
3301
+
3302
+ // ../../packages/busabase-contract/src/domains/base/contract/base-schemas.ts
3303
+ var fieldNameSchema = z7.union([
3304
+ z7.string().min(1),
3255
3305
  iStringRecordSchema.refine(
3256
3306
  (record) => Object.values(record).some((value) => value && value.trim().length > 0),
3257
3307
  "field name must have at least one non-empty locale value"
3258
3308
  )
3259
3309
  ]);
3260
- var fieldTypeSchema = z6.enum([
3310
+ var fieldTypeSchema = z7.enum([
3261
3311
  "text",
3262
3312
  "longtext",
3263
3313
  "markdown",
@@ -3287,105 +3337,105 @@ var fieldTypeSchema = z6.enum([
3287
3337
  "lookup",
3288
3338
  "whiteboard"
3289
3339
  ]);
3290
- var lookupRollupSchema = z6.enum(["values", "count", "sum", "average", "min", "max", "concatenate"]).default("values");
3291
- var fieldOptionsSchema = z6.object({
3292
- ai: z6.object({
3293
- model: z6.string().optional(),
3294
- prompt: z6.string().optional(),
3295
- reviewRequired: z6.boolean().optional(),
3296
- sourceFieldIds: z6.array(z6.string()).optional()
3340
+ var lookupRollupSchema = z7.enum(["values", "count", "sum", "average", "min", "max", "concatenate"]).default("values");
3341
+ var fieldOptionsSchema = z7.object({
3342
+ ai: z7.object({
3343
+ model: z7.string().optional(),
3344
+ prompt: z7.string().optional(),
3345
+ reviewRequired: z7.boolean().optional(),
3346
+ sourceFieldIds: z7.array(z7.string()).optional()
3297
3347
  }).optional(),
3298
3348
  // Per-field config for `attachment` columns (all optional; logic enforces a
3299
3349
  // 25MB ceiling regardless).
3300
- attachment: z6.object({
3301
- maxFiles: z6.number().int().positive().optional(),
3302
- allowedMimeTypes: z6.array(z6.string()).optional(),
3303
- maxFileSize: z6.number().int().positive().optional()
3350
+ attachment: z7.object({
3351
+ maxFiles: z7.number().int().positive().optional(),
3352
+ allowedMimeTypes: z7.array(z7.string()).optional(),
3353
+ maxFileSize: z7.number().int().positive().optional()
3304
3354
  }).optional(),
3305
- choices: z6.array(
3306
- z6.object({
3307
- color: z6.string().optional(),
3308
- id: z6.string(),
3309
- name: z6.string()
3355
+ choices: z7.array(
3356
+ z7.object({
3357
+ color: z7.string().optional(),
3358
+ id: z7.string(),
3359
+ name: z7.string()
3310
3360
  })
3311
3361
  ).optional(),
3312
- code: z6.object({
3313
- language: z6.string().optional()
3362
+ code: z7.object({
3363
+ language: z7.string().optional()
3314
3364
  }).optional(),
3315
- embed: z6.object({
3316
- aspectRatio: z6.enum(["16:9", "4:3", "1:1"]).optional(),
3317
- height: z6.number().int().positive().max(1200).optional(),
3318
- providers: z6.array(z6.string()).optional()
3365
+ embed: z7.object({
3366
+ aspectRatio: z7.enum(["16:9", "4:3", "1:1"]).optional(),
3367
+ height: z7.number().int().positive().max(1200).optional(),
3368
+ providers: z7.array(z7.string()).optional()
3319
3369
  }).optional(),
3320
3370
  // `formula` fields are server-computed (like the other computed types) from
3321
3371
  // `expression` at record write time — see packages/busabase-core's
3322
3372
  // domains/base/formula/ engine. `{slug}` references a sibling field, including
3323
3373
  // another `formula` field (chained formulas) — a dependency graph orders
3324
3374
  // computation and rejects cycles at field create/edit time.
3325
- formula: z6.object({
3326
- expression: z6.string().min(1)
3375
+ formula: z7.object({
3376
+ expression: z7.string().min(1)
3327
3377
  }).optional(),
3328
- inverseFieldId: z6.string().optional(),
3378
+ inverseFieldId: z7.string().optional(),
3329
3379
  // `lookup` fields pull a field's values across a `relation` field on the same
3330
3380
  // Base, optionally rolling them up into one scalar. Unlike every other computed
3331
3381
  // type they are NOT stored on the commit: a lookup's value depends on OTHER
3332
3382
  // records, which can change without this record ever being written, so it is
3333
3383
  // resolved at read time (see busabase-core's domains/base/logic/lookup-values.ts).
3334
- lookup: z6.object({
3335
- relationFieldSlug: z6.string().min(1).describe("Slug of a `relation` field on THIS Base \u2014 the hop to follow."),
3336
- targetFieldSlug: z6.string().min(1).describe("Slug of the field on the related Base whose values are pulled over."),
3384
+ lookup: z7.object({
3385
+ relationFieldSlug: z7.string().min(1).describe("Slug of a `relation` field on THIS Base \u2014 the hop to follow."),
3386
+ targetFieldSlug: z7.string().min(1).describe("Slug of the field on the related Base whose values are pulled over."),
3337
3387
  rollup: lookupRollupSchema.optional(),
3338
- limit: z6.enum(["all", "first"]).optional().describe("`first` looks at only the first linked record; default `all`.")
3388
+ limit: z7.enum(["all", "first"]).optional().describe("`first` looks at only the first linked record; default `all`.")
3339
3389
  }).optional(),
3340
- multiple: z6.boolean().optional(),
3390
+ multiple: z7.boolean().optional(),
3341
3391
  // Display formatting for `number` columns (Notion-style: one number type,
3342
3392
  // a format option). `currency` renders via Intl.NumberFormat.
3343
- number: z6.object({
3344
- format: z6.enum(["plain", "currency"]).optional(),
3345
- currency: z6.string().optional(),
3346
- locale: z6.string().optional()
3393
+ number: z7.object({
3394
+ format: z7.enum(["plain", "currency"]).optional(),
3395
+ currency: z7.string().optional(),
3396
+ locale: z7.string().optional()
3347
3397
  }).optional(),
3348
- targetBaseId: z6.string().optional().describe("Relation target Base id (bse_\u2026). Or pass targetBaseSlug to name it by slug."),
3349
- targetBaseSlug: z6.string().optional().describe(
3398
+ targetBaseId: z7.string().optional().describe("Relation target Base id (bse_\u2026). Or pass targetBaseSlug to name it by slug."),
3399
+ targetBaseSlug: z7.string().optional().describe(
3350
3400
  "Relation target Base by slug \u2014 a convenience alias for targetBaseId, resolved server-side (active bases in the current space). If both are given, targetBaseId wins."
3351
3401
  )
3352
3402
  }).default({});
3353
- var baseFieldSchema = z6.object({
3354
- id: z6.string(),
3355
- baseId: z6.string(),
3356
- slug: z6.string(),
3403
+ var baseFieldSchema = z7.object({
3404
+ id: z7.string(),
3405
+ baseId: z7.string(),
3406
+ slug: z7.string(),
3357
3407
  name: fieldNameSchema,
3358
3408
  type: fieldTypeSchema,
3359
- required: z6.boolean(),
3360
- position: z6.number(),
3409
+ required: z7.boolean(),
3410
+ position: z7.number(),
3361
3411
  options: fieldOptionsSchema
3362
3412
  });
3363
- var baseSchema = z6.object({
3364
- id: z6.string(),
3365
- nodeId: z6.string(),
3366
- slug: z6.string(),
3367
- name: z6.string(),
3368
- description: z6.string(),
3369
- reviewPolicy: z6.object({
3370
- kind: z6.literal("single"),
3371
- requiredApprovals: z6.number()
3413
+ var baseSchema = z7.object({
3414
+ id: z7.string(),
3415
+ nodeId: z7.string(),
3416
+ slug: z7.string(),
3417
+ name: z7.string(),
3418
+ description: z7.string(),
3419
+ reviewPolicy: z7.object({
3420
+ kind: z7.literal("single"),
3421
+ requiredApprovals: z7.number()
3372
3422
  }),
3373
- createdAt: z6.string(),
3374
- fields: z6.array(baseFieldSchema)
3423
+ createdAt: z7.string(),
3424
+ fields: z7.array(baseFieldSchema)
3375
3425
  });
3376
- var createBaseInputSchema = z6.object({
3377
- parentNodeId: z6.string().optional().describe(
3426
+ var createBaseInputSchema = z7.object({
3427
+ parentNodeId: z7.string().optional().describe(
3378
3428
  "Parent node id. Must be a folder or the space root; container-incapable node types (Base, Doc, AirApp, etc.) cannot hold children."
3379
3429
  ),
3380
- slug: z6.string().min(1).regex(/^[a-z0-9-]+$/),
3381
- name: z6.string().min(1),
3382
- description: z6.string().optional().default(""),
3383
- fields: z6.array(
3384
- z6.object({
3385
- slug: z6.string().min(1),
3430
+ slug: z7.string().min(1).regex(/^[a-z0-9-]+$/),
3431
+ name: z7.string().min(1),
3432
+ description: z7.string().optional().default(""),
3433
+ fields: z7.array(
3434
+ z7.object({
3435
+ slug: z7.string().min(1),
3386
3436
  name: fieldNameSchema,
3387
3437
  type: fieldTypeSchema.default("text"),
3388
- required: z6.boolean().default(false),
3438
+ required: z7.boolean().default(false),
3389
3439
  options: fieldOptionsSchema.optional().default({})
3390
3440
  })
3391
3441
  ).default([]),
@@ -3393,135 +3443,157 @@ var createBaseInputSchema = z6.object({
3393
3443
  // write access on the parent node, otherwise falls back to a pending
3394
3444
  // ChangeRequest (status "in_review"). Pass explicit `autoMerge: false` to
3395
3445
  // force review even with write access.
3396
- autoMerge: z6.boolean().optional()
3446
+ autoMerge: z7.boolean().optional()
3397
3447
  });
3398
- var createBaseFieldInputSchema = z6.object({
3448
+ var createBaseFieldInputSchema = z7.object({
3399
3449
  name: fieldNameSchema,
3400
3450
  // Field slugs are snake_case identifiers (e.g. `cover_image`, `publish_date`) — the
3401
3451
  // seed and the inline-fields path on `POST /bases` already allow underscores, so the
3402
3452
  // add-field endpoint must too. (Base/folder/view slugs stay kebab-case: they go in URLs.)
3403
- slug: z6.string().min(1).regex(/^[a-z0-9_-]+$/),
3453
+ slug: z7.string().min(1).regex(/^[a-z0-9_-]+$/),
3404
3454
  type: fieldTypeSchema.default("text"),
3405
- required: z6.boolean().optional().default(false),
3455
+ required: z7.boolean().optional().default(false),
3406
3456
  options: fieldOptionsSchema.optional().default({})
3407
3457
  });
3458
+ var fieldAutoMergeSchema = z7.boolean().optional().describe(
3459
+ "Whether to approve and merge this field change immediately. Omitted defaults to merging immediately if the actor has write access on the Base's node, otherwise falling back to a pending Change Request; pass explicit false to force review even with write access. Not accepted by the delete and convert operations, which always require review."
3460
+ );
3408
3461
  var createFieldChangeRequestInputSchema = createBaseFieldInputSchema.extend({
3409
- message: z6.string().optional().default("Add field"),
3410
- submittedBy: z6.string().optional().default("local-editor")
3462
+ message: z7.string().optional().default("Add field"),
3463
+ submittedBy: z7.string().optional().default("local-editor"),
3464
+ autoMerge: fieldAutoMergeSchema
3411
3465
  });
3412
- var deleteFieldChangeRequestInputSchema = z6.object({
3413
- fieldId: z6.string().min(1),
3414
- message: z6.string().optional(),
3415
- submittedBy: z6.string().optional().default("local-editor")
3466
+ var deleteFieldChangeRequestInputSchema = z7.object({
3467
+ fieldId: z7.string().min(1),
3468
+ message: z7.string().optional(),
3469
+ submittedBy: z7.string().optional().default("local-editor"),
3470
+ autoMerge: autoMergeNotAccepted(
3471
+ "deleting a field soft-deletes its stored values with it, so it always requires review. Omit the flag."
3472
+ )
3416
3473
  });
3417
- var updateFieldChangeRequestInputSchema = z6.object({
3418
- fieldId: z6.string().min(1),
3419
- patch: z6.object({
3474
+ var updateFieldChangeRequestInputSchema = z7.object({
3475
+ fieldId: z7.string().min(1),
3476
+ patch: z7.object({
3420
3477
  name: fieldNameSchema.optional(),
3421
- required: z6.boolean().optional(),
3478
+ required: z7.boolean().optional(),
3422
3479
  options: fieldOptionsSchema.optional()
3423
3480
  }),
3424
- message: z6.string().optional(),
3425
- submittedBy: z6.string().optional().default("local-editor")
3481
+ message: z7.string().optional(),
3482
+ submittedBy: z7.string().optional().default("local-editor"),
3483
+ autoMerge: fieldAutoMergeSchema
3426
3484
  });
3427
- var previewFieldConversionInputSchema = z6.object({
3428
- fieldId: z6.string().min(1),
3485
+ var previewFieldConversionInputSchema = z7.object({
3486
+ fieldId: z7.string().min(1),
3429
3487
  newType: fieldTypeSchema
3430
3488
  });
3431
- var previewFieldConversionOutputSchema = z6.object({
3432
- totalCount: z6.number(),
3433
- convertibleCount: z6.number(),
3434
- nullCount: z6.number(),
3435
- conflicts: z6.array(z6.object({ recordId: z6.string(), currentValue: z6.unknown() }))
3489
+ var previewFieldConversionOutputSchema = z7.object({
3490
+ totalCount: z7.number(),
3491
+ convertibleCount: z7.number(),
3492
+ nullCount: z7.number(),
3493
+ conflicts: z7.array(z7.object({ recordId: z7.string(), currentValue: z7.unknown() }))
3436
3494
  });
3437
- var convertFieldChangeRequestInputSchema = z6.object({
3438
- fieldId: z6.string().min(1),
3495
+ var convertFieldChangeRequestInputSchema = z7.object({
3496
+ fieldId: z7.string().min(1),
3439
3497
  newType: fieldTypeSchema,
3440
- selectChoiceMode: z6.enum(["auto_create", "null_on_missing"]).default("null_on_missing"),
3441
- message: z6.string().optional(),
3442
- submittedBy: z6.string().optional().default("local-editor")
3498
+ selectChoiceMode: z7.enum(["auto_create", "null_on_missing"]).default("null_on_missing"),
3499
+ message: z7.string().optional(),
3500
+ submittedBy: z7.string().optional().default("local-editor"),
3501
+ autoMerge: autoMergeNotAccepted(
3502
+ "converting a field's type can drop values, so it always requires review. Run previewFieldConversion first to see what would change, then omit the flag."
3503
+ )
3443
3504
  });
3444
- var reorderFieldsChangeRequestInputSchema = z6.object({
3445
- fieldIds: z6.array(z6.string()).min(1),
3446
- message: z6.string().optional(),
3447
- submittedBy: z6.string().optional().default("local-editor")
3505
+ var reorderFieldsChangeRequestInputSchema = z7.object({
3506
+ fieldIds: z7.array(z7.string()).min(1),
3507
+ message: z7.string().optional(),
3508
+ submittedBy: z7.string().optional().default("local-editor"),
3509
+ autoMerge: fieldAutoMergeSchema
3448
3510
  });
3449
- var archiveBaseInputSchema = z6.object({
3450
- message: z6.string().optional(),
3451
- submittedBy: z6.string().optional().default("local-editor")
3511
+ var archiveBaseInputSchema = z7.object({
3512
+ message: z7.string().optional(),
3513
+ submittedBy: z7.string().optional().default("local-editor"),
3514
+ autoMerge: autoMergeNotAccepted(
3515
+ "archiving a Base removes it and every record in it from every listing at once, so it always requires review. Omit the flag."
3516
+ )
3452
3517
  });
3453
- var restoreBaseInputSchema = z6.object({
3454
- message: z6.string().optional(),
3455
- submittedBy: z6.string().optional().default("local-editor")
3518
+ var restoreBaseInputSchema = z7.object({
3519
+ message: z7.string().optional(),
3520
+ submittedBy: z7.string().optional().default("local-editor"),
3521
+ // Restoring an archived Base is the undo of a destructive act — nothing is at
3522
+ // risk, so it takes the same permission-aware default as everything else.
3523
+ // `archiveBaseInputSchema` above deliberately has no `autoMerge`: archiving
3524
+ // takes a whole Base and every record in it out of every listing at once,
3525
+ // which is strictly larger than the record `delete` that is already review-only.
3526
+ autoMerge: z7.boolean().optional()
3456
3527
  });
3457
- var restoreFieldChangeRequestInputSchema = z6.object({
3458
- fieldId: z6.string().min(1),
3459
- message: z6.string().optional(),
3460
- submittedBy: z6.string().optional().default("local-editor")
3528
+ var restoreFieldChangeRequestInputSchema = z7.object({
3529
+ fieldId: z7.string().min(1),
3530
+ message: z7.string().optional(),
3531
+ submittedBy: z7.string().optional().default("local-editor"),
3532
+ autoMerge: fieldAutoMergeSchema
3461
3533
  });
3462
- var withBaseId = { baseId: z6.string().min(1) };
3463
- var fieldChangeRequestInputSchema = z6.discriminatedUnion("operation", [
3464
- createFieldChangeRequestInputSchema.extend({ operation: z6.literal("create"), ...withBaseId }),
3465
- updateFieldChangeRequestInputSchema.extend({ operation: z6.literal("update"), ...withBaseId }),
3466
- deleteFieldChangeRequestInputSchema.extend({ operation: z6.literal("delete"), ...withBaseId }),
3467
- convertFieldChangeRequestInputSchema.extend({ operation: z6.literal("convert"), ...withBaseId }),
3468
- reorderFieldsChangeRequestInputSchema.extend({ operation: z6.literal("reorder"), ...withBaseId }),
3469
- restoreFieldChangeRequestInputSchema.extend({ operation: z6.literal("restore"), ...withBaseId })
3534
+ var withBaseId = { baseId: z7.string().min(1) };
3535
+ var fieldChangeRequestInputSchema = z7.discriminatedUnion("operation", [
3536
+ createFieldChangeRequestInputSchema.extend({ operation: z7.literal("create"), ...withBaseId }),
3537
+ updateFieldChangeRequestInputSchema.extend({ operation: z7.literal("update"), ...withBaseId }),
3538
+ deleteFieldChangeRequestInputSchema.extend({ operation: z7.literal("delete"), ...withBaseId }),
3539
+ convertFieldChangeRequestInputSchema.extend({ operation: z7.literal("convert"), ...withBaseId }),
3540
+ reorderFieldsChangeRequestInputSchema.extend({ operation: z7.literal("reorder"), ...withBaseId }),
3541
+ restoreFieldChangeRequestInputSchema.extend({ operation: z7.literal("restore"), ...withBaseId })
3470
3542
  ]);
3471
- var baseLifecycleChangeRequestInputSchema = z6.discriminatedUnion("operation", [
3472
- archiveBaseInputSchema.extend({ operation: z6.literal("archive"), ...withBaseId }),
3473
- restoreBaseInputSchema.extend({ operation: z6.literal("restore"), ...withBaseId })
3543
+ var baseLifecycleChangeRequestInputSchema = z7.discriminatedUnion("operation", [
3544
+ archiveBaseInputSchema.extend({ operation: z7.literal("archive"), ...withBaseId }),
3545
+ restoreBaseInputSchema.extend({ operation: z7.literal("restore"), ...withBaseId })
3474
3546
  ]);
3475
3547
 
3476
3548
  // ../../packages/busabase-contract/src/domains/base/contract/view-schemas.ts
3477
- import { z as z8 } from "zod";
3549
+ import { z as z9 } from "zod";
3478
3550
 
3479
3551
  // ../../packages/busabase-contract/src/contract/schemas.ts
3480
- import { z as z7 } from "zod";
3481
- var nodeSchema = z7.lazy(
3482
- () => z7.object({
3483
- id: z7.string(),
3484
- parentId: z7.string().nullable(),
3485
- type: z7.enum(NODE_TYPES),
3486
- slug: z7.string(),
3487
- name: z7.string(),
3488
- description: z7.string(),
3489
- metadata: z7.object({
3490
- entryFile: z7.string().optional(),
3491
- visibility: z7.enum(["private", "workspace", "public"]).optional(),
3492
- version: z7.string().optional(),
3493
- assetId: z7.string().optional()
3494
- }).catchall(z7.unknown()).default({}),
3495
- position: z7.number(),
3496
- createdAt: z7.string(),
3497
- updatedAt: z7.string(),
3498
- baseId: z7.string().nullable(),
3499
- children: z7.array(nodeSchema),
3500
- hasChildren: z7.boolean().optional()
3552
+ import { z as z8 } from "zod";
3553
+ var nodeSchema = z8.lazy(
3554
+ () => z8.object({
3555
+ id: z8.string(),
3556
+ parentId: z8.string().nullable(),
3557
+ type: z8.enum(NODE_TYPES),
3558
+ slug: z8.string(),
3559
+ name: z8.string(),
3560
+ description: z8.string(),
3561
+ metadata: z8.object({
3562
+ entryFile: z8.string().optional(),
3563
+ visibility: z8.enum(["private", "workspace", "public"]).optional(),
3564
+ version: z8.string().optional(),
3565
+ assetId: z8.string().optional()
3566
+ }).catchall(z8.unknown()).default({}),
3567
+ position: z8.number(),
3568
+ createdAt: z8.string(),
3569
+ updatedAt: z8.string(),
3570
+ baseId: z8.string().nullable(),
3571
+ children: z8.array(nodeSchema),
3572
+ hasChildren: z8.boolean().optional()
3501
3573
  })
3502
3574
  );
3503
- var nodePrincipalSchema = z7.object({
3504
- id: z7.string(),
3505
- nodeId: z7.string(),
3506
- principalType: z7.enum(["user", "team", "space"]),
3507
- principalId: z7.string(),
3508
- role: z7.enum(["read", "changeRequest", "write", "manage"]),
3509
- grantedBy: z7.string(),
3510
- createdAt: z7.string(),
3511
- updatedAt: z7.string()
3575
+ var nodePrincipalSchema = z8.object({
3576
+ id: z8.string(),
3577
+ nodeId: z8.string(),
3578
+ principalType: z8.enum(["user", "team", "space"]),
3579
+ principalId: z8.string(),
3580
+ role: z8.enum(["read", "changeRequest", "write", "manage"]),
3581
+ grantedBy: z8.string(),
3582
+ createdAt: z8.string(),
3583
+ updatedAt: z8.string()
3512
3584
  });
3513
- var nodeShareSchema = z7.object({
3514
- nodeId: z7.string(),
3515
- scope: z7.enum(["none", "public"]),
3516
- capability: z7.enum(["read", "submit"]),
3585
+ var nodeShareSchema = z8.object({
3586
+ nodeId: z8.string(),
3587
+ scope: z8.enum(["none", "public"]),
3588
+ capability: z8.enum(["read", "submit"]),
3517
3589
  // Derived from `passwordHash != null` — the hash itself is never serialized.
3518
- hasPassword: z7.boolean(),
3519
- expiresAt: z7.string().nullable(),
3520
- updatedAt: z7.string()
3590
+ hasPassword: z8.boolean(),
3591
+ expiresAt: z8.string().nullable(),
3592
+ updatedAt: z8.string()
3521
3593
  });
3522
- var listNodesInputSchema = z7.object({
3523
- parentId: z7.string().nullable().optional().describe("Node to start from. Omit or null to start from the space root."),
3524
- depth: z7.coerce.number().int().min(1).max(5).optional().describe(
3594
+ var listNodesInputSchema = z8.object({
3595
+ parentId: z8.string().nullable().optional().describe("Node to start from. Omit or null to start from the space root."),
3596
+ depth: z8.coerce.number().int().min(1).max(5).optional().describe(
3525
3597
  "How many levels beneath the start point to eagerly include (default 2 once either field is set). Capped at 5."
3526
3598
  ),
3527
3599
  /**
@@ -3529,7 +3601,7 @@ var listNodesInputSchema = z7.object({
3529
3601
  * soft-archived nodes for the Trash view — no `parentId`/`depth` walk, since
3530
3602
  * archived nodes are shown as a list, not a tree.
3531
3603
  */
3532
- status: z7.enum(["active", "archived"]).optional().default("active"),
3604
+ status: z8.enum(["active", "archived"]).optional().default("active"),
3533
3605
  /**
3534
3606
  * Narrow to specific node types and return a FLAT list of lightweight node
3535
3607
  * summaries (`children: []`) instead of walking the tree. This is what
@@ -3553,110 +3625,110 @@ var listNodesInputSchema = z7.object({
3553
3625
  * bare string, not a 1-element array — only a REPEATED occurrence
3554
3626
  * (`?types=doc&types=file`) becomes an array. Accept both and normalize.
3555
3627
  */
3556
- types: z7.union([z7.array(z7.enum(NODE_TYPES)), z7.enum(NODE_TYPES)]).transform((value) => Array.isArray(value) ? value : [value]).optional().describe(
3628
+ types: z8.union([z8.array(z8.enum(NODE_TYPES)), z8.enum(NODE_TYPES)]).transform((value) => Array.isArray(value) ? value : [value]).optional().describe(
3557
3629
  "Return a flat list of lightweight summaries for these node types instead of the tree. Read one node's full detail with GET /nodes/{nodeId}."
3558
3630
  )
3559
3631
  }).optional();
3560
- var isDescendantInputSchema = z7.object({
3561
- nodeId: z7.string(),
3562
- potentialAncestorId: z7.string()
3632
+ var isDescendantInputSchema = z8.object({
3633
+ nodeId: z8.string(),
3634
+ potentialAncestorId: z8.string()
3563
3635
  });
3564
- var isDescendantOutputSchema = z7.object({
3565
- isDescendant: z7.boolean()
3636
+ var isDescendantOutputSchema = z8.object({
3637
+ isDescendant: z8.boolean()
3566
3638
  });
3567
- var updateNodeMetadataInputSchema = z7.object({
3568
- nodeId: z7.string(),
3569
- metadata: z7.record(z7.string(), z7.unknown())
3639
+ var updateNodeMetadataInputSchema = z8.object({
3640
+ nodeId: z8.string(),
3641
+ metadata: z8.record(z8.string(), z8.unknown())
3570
3642
  });
3571
- var searchNodesByNameInputSchema = z7.object({
3572
- query: z7.string().min(1),
3573
- limit: z7.number().int().min(1).max(50).optional().default(20)
3643
+ var searchNodesByNameInputSchema = z8.object({
3644
+ query: z8.string().min(1),
3645
+ limit: z8.number().int().min(1).max(50).optional().default(20)
3574
3646
  });
3575
- var nodeSearchResultSchema = z7.object({
3576
- id: z7.string(),
3577
- type: z7.enum(NODE_TYPES),
3578
- name: z7.string(),
3579
- slug: z7.string(),
3580
- path: z7.string(),
3581
- updatedAt: z7.string()
3647
+ var nodeSearchResultSchema = z8.object({
3648
+ id: z8.string(),
3649
+ type: z8.enum(NODE_TYPES),
3650
+ name: z8.string(),
3651
+ slug: z8.string(),
3652
+ path: z8.string(),
3653
+ updatedAt: z8.string()
3582
3654
  });
3583
- var userRefSchema = z7.object({
3584
- id: z7.string(),
3585
- name: z7.string().nullable(),
3586
- email: z7.string().nullable(),
3587
- image: z7.string().nullable(),
3588
- role: z7.string().nullable().optional()
3655
+ var userRefSchema = z8.object({
3656
+ id: z8.string(),
3657
+ name: z8.string().nullable(),
3658
+ email: z8.string().nullable(),
3659
+ image: z8.string().nullable(),
3660
+ role: z8.string().nullable().optional()
3589
3661
  });
3590
- var commitSchema = z7.object({
3591
- id: z7.string(),
3592
- baseId: z7.string().nullable(),
3593
- targetType: z7.enum(["base", "node"]),
3594
- nodeId: z7.string().nullable(),
3595
- operationId: z7.string().nullable(),
3596
- parentCommitId: z7.string().nullable(),
3597
- fields: z7.record(z7.string(), z7.unknown()),
3598
- operation: z7.enum(OPERATION_KINDS),
3599
- message: z7.string(),
3600
- author: z7.string(),
3662
+ var commitSchema = z8.object({
3663
+ id: z8.string(),
3664
+ baseId: z8.string().nullable(),
3665
+ targetType: z8.enum(["base", "node"]),
3666
+ nodeId: z8.string().nullable(),
3667
+ operationId: z8.string().nullable(),
3668
+ parentCommitId: z8.string().nullable(),
3669
+ fields: z8.record(z8.string(), z8.unknown()),
3670
+ operation: z8.enum(OPERATION_KINDS),
3671
+ message: z8.string(),
3672
+ author: z8.string(),
3601
3673
  authorUser: userRefSchema.nullable().optional().default(null),
3602
- createdAt: z7.string()
3674
+ createdAt: z8.string()
3603
3675
  });
3604
- var operationSchema = z7.object({
3605
- id: z7.string(),
3606
- changeRequestId: z7.string(),
3607
- baseId: z7.string().nullable(),
3608
- targetType: z7.enum(["base", "node"]),
3609
- nodeId: z7.string().nullable(),
3610
- operation: z7.enum(OPERATION_KINDS),
3611
- status: z7.enum(["pending", "merged", "archived", "failed"]),
3612
- targetRecordId: z7.string().nullable(),
3613
- targetViewId: z7.string().nullable(),
3614
- filePath: z7.string().nullable(),
3615
- sourceRecordId: z7.string().nullable(),
3616
- sourceCommitId: z7.string().nullable(),
3617
- baseCommitId: z7.string().nullable(),
3618
- headCommitId: z7.string(),
3619
- deleteMode: z7.enum(["archive"]),
3620
- mergedRecordId: z7.string().nullable(),
3621
- mergedViewId: z7.string().nullable(),
3622
- position: z7.number(),
3623
- createdAt: z7.string(),
3624
- updatedAt: z7.string(),
3676
+ var operationSchema = z8.object({
3677
+ id: z8.string(),
3678
+ changeRequestId: z8.string(),
3679
+ baseId: z8.string().nullable(),
3680
+ targetType: z8.enum(["base", "node"]),
3681
+ nodeId: z8.string().nullable(),
3682
+ operation: z8.enum(OPERATION_KINDS),
3683
+ status: z8.enum(["pending", "merged", "archived", "failed"]),
3684
+ targetRecordId: z8.string().nullable(),
3685
+ targetViewId: z8.string().nullable(),
3686
+ filePath: z8.string().nullable(),
3687
+ sourceRecordId: z8.string().nullable(),
3688
+ sourceCommitId: z8.string().nullable(),
3689
+ baseCommitId: z8.string().nullable(),
3690
+ headCommitId: z8.string(),
3691
+ deleteMode: z8.enum(["archive"]),
3692
+ mergedRecordId: z8.string().nullable(),
3693
+ mergedViewId: z8.string().nullable(),
3694
+ position: z8.number(),
3695
+ createdAt: z8.string(),
3696
+ updatedAt: z8.string(),
3625
3697
  headCommit: commitSchema,
3626
3698
  // Resolved canonical "before" values for the operation's target, so the UI can
3627
3699
  // render a true before → after field diff. Null for creations (no prior state)
3628
3700
  // and for kinds whose prior state isn't a field map (e.g. skill files, whose
3629
3701
  // previous content lives in storage). Records resolve from the base commit;
3630
3702
  // views resolve from the current view row ({ name, description, config }).
3631
- baseFields: z7.record(z7.string(), z7.unknown()).nullable()
3703
+ baseFields: z8.record(z8.string(), z8.unknown()).nullable()
3632
3704
  });
3633
- var reviewSchema = z7.object({
3634
- id: z7.string(),
3635
- changeRequestId: z7.string(),
3636
- reviewerId: z7.string(),
3705
+ var reviewSchema = z8.object({
3706
+ id: z8.string(),
3707
+ changeRequestId: z8.string(),
3708
+ reviewerId: z8.string(),
3637
3709
  reviewer: userRefSchema.nullable().optional().default(null),
3638
- verdict: z7.enum(["approved", "rejected"]),
3639
- reason: z7.string().nullable(),
3640
- visibleOperationHeads: z7.record(z7.string(), z7.string()),
3641
- createdAt: z7.string()
3710
+ verdict: z8.enum(["approved", "rejected"]),
3711
+ reason: z8.string().nullable(),
3712
+ visibleOperationHeads: z8.record(z8.string(), z8.string()),
3713
+ createdAt: z8.string()
3642
3714
  });
3643
- var commentSubjectTypeSchema = z7.enum(["record", "change_request", "operation", "commit"]);
3644
- var commentSchema = z7.object({
3645
- id: z7.string(),
3715
+ var commentSubjectTypeSchema = z8.enum(["record", "change_request", "operation", "commit"]);
3716
+ var commentSchema = z8.object({
3717
+ id: z8.string(),
3646
3718
  subjectType: commentSubjectTypeSchema,
3647
- subjectId: z7.string(),
3648
- recordId: z7.string().nullable(),
3649
- changeRequestId: z7.string().nullable(),
3650
- operationId: z7.string().nullable(),
3651
- commitId: z7.string().nullable(),
3652
- authorId: z7.string(),
3719
+ subjectId: z8.string(),
3720
+ recordId: z8.string().nullable(),
3721
+ changeRequestId: z8.string().nullable(),
3722
+ operationId: z8.string().nullable(),
3723
+ commitId: z8.string().nullable(),
3724
+ authorId: z8.string(),
3653
3725
  author: userRefSchema.nullable().optional().default(null),
3654
- body: z7.string(),
3655
- mentionsAi: z7.boolean(),
3656
- createdAt: z7.string(),
3657
- updatedAt: z7.string()
3726
+ body: z8.string(),
3727
+ mentionsAi: z8.boolean(),
3728
+ createdAt: z8.string(),
3729
+ updatedAt: z8.string()
3658
3730
  });
3659
- var changeRequestStatusSchema = z7.enum([
3731
+ var changeRequestStatusSchema = z8.enum([
3660
3732
  "in_review",
3661
3733
  "changes_requested",
3662
3734
  "approved",
@@ -3665,53 +3737,53 @@ var changeRequestStatusSchema = z7.enum([
3665
3737
  "abandoned",
3666
3738
  "conflict"
3667
3739
  ]);
3668
- var changeRequestSchema = z7.object({
3669
- id: z7.string(),
3670
- baseId: z7.string().nullable(),
3671
- targetType: z7.enum(["base", "node"]),
3672
- nodeId: z7.string().nullable(),
3740
+ var changeRequestSchema = z8.object({
3741
+ id: z8.string(),
3742
+ baseId: z8.string().nullable(),
3743
+ targetType: z8.enum(["base", "node"]),
3744
+ nodeId: z8.string().nullable(),
3673
3745
  status: changeRequestStatusSchema,
3674
- submittedBy: z7.string(),
3746
+ submittedBy: z8.string(),
3675
3747
  submittedByUser: userRefSchema.nullable().optional().default(null),
3676
- sourceMeta: z7.record(z7.string(), z7.unknown()),
3677
- reviewPolicySnapshot: z7.record(z7.string(), z7.unknown()),
3678
- mergeSummary: z7.record(z7.string(), z7.unknown()),
3679
- rejectedReason: z7.string().nullable(),
3680
- reviewedAt: z7.string().nullable(),
3681
- mergedAt: z7.string().nullable(),
3682
- createdAt: z7.string(),
3683
- updatedAt: z7.string(),
3748
+ sourceMeta: z8.record(z8.string(), z8.unknown()),
3749
+ reviewPolicySnapshot: z8.record(z8.string(), z8.unknown()),
3750
+ mergeSummary: z8.record(z8.string(), z8.unknown()),
3751
+ rejectedReason: z8.string().nullable(),
3752
+ reviewedAt: z8.string().nullable(),
3753
+ mergedAt: z8.string().nullable(),
3754
+ createdAt: z8.string(),
3755
+ updatedAt: z8.string(),
3684
3756
  base: baseSchema.nullable(),
3685
3757
  node: nodeSchema.nullable(),
3686
- operations: z7.array(operationSchema),
3758
+ operations: z8.array(operationSchema),
3687
3759
  primaryOperation: operationSchema.nullable(),
3688
- operationCount: z7.number(),
3689
- reviews: z7.array(reviewSchema)
3760
+ operationCount: z8.number(),
3761
+ reviews: z8.array(reviewSchema)
3690
3762
  });
3691
- var agentTaskSchema = z7.object({
3763
+ var agentTaskSchema = z8.object({
3692
3764
  changeRequest: changeRequestSchema,
3693
- trigger: z7.enum(["changes_requested", "ai_mention"]),
3694
- reviewReason: z7.string().nullable(),
3695
- aiComments: z7.array(commentSchema)
3765
+ trigger: z8.enum(["changes_requested", "ai_mention"]),
3766
+ reviewReason: z8.string().nullable(),
3767
+ aiComments: z8.array(commentSchema)
3696
3768
  });
3697
- var searchResultSchema = z7.object({
3698
- id: z7.string(),
3699
- kind: z7.enum(["record", "change_request", "base", "file"]),
3700
- title: z7.string(),
3701
- body: z7.string(),
3702
- eyebrow: z7.string(),
3703
- href: z7.string(),
3704
- updatedAt: z7.string().nullable()
3769
+ var searchResultSchema = z8.object({
3770
+ id: z8.string(),
3771
+ kind: z8.enum(["record", "change_request", "base", "file"]),
3772
+ title: z8.string(),
3773
+ body: z8.string(),
3774
+ eyebrow: z8.string(),
3775
+ href: z8.string(),
3776
+ updatedAt: z8.string().nullable()
3705
3777
  });
3706
- var searchResponseSchema = z7.object({
3707
- query: z7.string(),
3708
- limit: z7.number(),
3709
- offset: z7.number(),
3710
- hasMore: z7.boolean(),
3711
- results: z7.array(searchResultSchema)
3778
+ var searchResponseSchema = z8.object({
3779
+ query: z8.string(),
3780
+ limit: z8.number(),
3781
+ offset: z8.number(),
3782
+ hasMore: z8.boolean(),
3783
+ results: z8.array(searchResultSchema)
3712
3784
  });
3713
- var liveEventSchema = z7.object({
3714
- kind: z7.enum([
3785
+ var liveEventSchema = z8.object({
3786
+ kind: z8.enum([
3715
3787
  "change_request.created",
3716
3788
  "change_request.updated",
3717
3789
  "change_request.deleted",
@@ -3731,18 +3803,18 @@ var liveEventSchema = z7.object({
3731
3803
  // stale whiteboard/workflow/HTML document until the next reload.
3732
3804
  "node.metadata_updated"
3733
3805
  ]),
3734
- spaceId: z7.string(),
3735
- actorId: z7.string(),
3806
+ spaceId: z8.string(),
3807
+ actorId: z8.string(),
3736
3808
  // Null for events that aren't about a change request at all
3737
3809
  // (`node.metadata_updated`), which is every direct, auto-audited write.
3738
- changeRequestId: z7.string().nullable(),
3739
- baseId: z7.string().nullable(),
3740
- nodeIds: z7.array(z7.string()),
3741
- recordIds: z7.array(z7.string()),
3742
- viewIds: z7.array(z7.string()),
3743
- operationCount: z7.number()
3810
+ changeRequestId: z8.string().nullable(),
3811
+ baseId: z8.string().nullable(),
3812
+ nodeIds: z8.array(z8.string()),
3813
+ recordIds: z8.array(z8.string()),
3814
+ viewIds: z8.array(z8.string()),
3815
+ operationCount: z8.number()
3744
3816
  });
3745
- var auditActionSchema = z7.enum([
3817
+ var auditActionSchema = z8.enum([
3746
3818
  "record.viewed",
3747
3819
  "change_request.created",
3748
3820
  "change_request.updated",
@@ -3767,171 +3839,174 @@ var auditActionSchema = z7.enum([
3767
3839
  "node.metadata_updated",
3768
3840
  "node.purged"
3769
3841
  ]);
3770
- var auditEventSchema = z7.object({
3771
- id: z7.string(),
3842
+ var auditEventSchema = z8.object({
3843
+ id: z8.string(),
3772
3844
  action: auditActionSchema,
3773
- actorId: z7.string(),
3845
+ actorId: z8.string(),
3774
3846
  actor: userRefSchema.nullable().optional().default(null),
3775
- baseId: z7.string().nullable(),
3776
- recordId: z7.string().nullable(),
3777
- changeRequestId: z7.string().nullable(),
3778
- operationId: z7.string().nullable(),
3779
- commitId: z7.string().nullable(),
3780
- metadata: z7.record(z7.string(), z7.unknown()),
3781
- createdAt: z7.string()
3847
+ baseId: z8.string().nullable(),
3848
+ recordId: z8.string().nullable(),
3849
+ changeRequestId: z8.string().nullable(),
3850
+ operationId: z8.string().nullable(),
3851
+ commitId: z8.string().nullable(),
3852
+ metadata: z8.record(z8.string(), z8.unknown()),
3853
+ createdAt: z8.string()
3782
3854
  });
3783
- var createAuditEventInputSchema = z7.object({
3855
+ var createAuditEventInputSchema = z8.object({
3784
3856
  action: auditActionSchema,
3785
- actorId: z7.string().optional().default("local-viewer"),
3786
- baseId: z7.string().optional().nullable(),
3787
- recordId: z7.string().optional().nullable(),
3788
- changeRequestId: z7.string().optional().nullable(),
3789
- operationId: z7.string().optional().nullable(),
3790
- commitId: z7.string().optional().nullable(),
3791
- metadata: z7.record(z7.string(), z7.unknown()).optional().default({})
3857
+ actorId: z8.string().optional().default("local-viewer"),
3858
+ baseId: z8.string().optional().nullable(),
3859
+ recordId: z8.string().optional().nullable(),
3860
+ changeRequestId: z8.string().optional().nullable(),
3861
+ operationId: z8.string().optional().nullable(),
3862
+ commitId: z8.string().optional().nullable(),
3863
+ metadata: z8.record(z8.string(), z8.unknown()).optional().default({})
3792
3864
  });
3793
- var nodeOperationInputSchema = z7.discriminatedUnion("kind", [
3794
- z7.object({
3795
- kind: z7.literal("create"),
3796
- ref: z7.string().min(1).optional().describe(
3865
+ var nodeOperationInputSchema = z8.discriminatedUnion("kind", [
3866
+ z8.object({
3867
+ kind: z8.literal("create"),
3868
+ ref: z8.string().min(1).optional().describe(
3797
3869
  'Optional in-change-request temp id for this node. A later operation can set parentNodeRef to this value to nest under it \u2014 e.g. create a folder with ref "growth", then create Bases with parentNodeRef "growth", all in one change request.'
3798
3870
  ),
3799
- parentNodeId: z7.string().optional(),
3800
- parentNodeRef: z7.string().min(1).optional().describe(
3871
+ parentNodeId: z8.string().optional(),
3872
+ parentNodeRef: z8.string().min(1).optional().describe(
3801
3873
  "Parent this node under a node an EARLIER operation in the same change request created (matched by its ref). Mutually exclusive with parentNodeId."
3802
3874
  ),
3803
- nodeType: z7.enum(CREATABLE_NODE_TYPES),
3804
- slug: z7.string().min(1).regex(/^[a-z0-9-]+$/),
3805
- name: z7.string().min(1),
3806
- description: z7.string().optional().default(""),
3807
- metadata: z7.record(z7.string(), z7.unknown()).optional().default({}),
3875
+ nodeType: z8.enum(CREATABLE_NODE_TYPES),
3876
+ slug: z8.string().min(1).regex(/^[a-z0-9-]+$/),
3877
+ name: z8.string().min(1),
3878
+ description: z8.string().optional().default(""),
3879
+ metadata: z8.record(z8.string(), z8.unknown()).optional().default({}),
3808
3880
  // Base fields (nodeType "base" only); a base needs at least one field.
3809
- fields: z7.array(
3810
- z7.object({
3811
- slug: z7.string().min(1).regex(/^[a-z0-9-]+$/),
3881
+ fields: z8.array(
3882
+ z8.object({
3883
+ slug: z8.string().min(1).regex(/^[a-z0-9-]+$/),
3812
3884
  name: fieldNameSchema,
3813
3885
  type: fieldTypeSchema.default("text"),
3814
- required: z7.boolean().optional().default(false),
3886
+ required: z8.boolean().optional().default(false),
3815
3887
  options: fieldOptionsSchema.optional().default({})
3816
3888
  })
3817
3889
  ).optional()
3818
3890
  }),
3819
- z7.object({
3820
- kind: z7.literal("rename"),
3821
- nodeId: z7.string(),
3822
- slug: z7.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
3823
- name: z7.string().min(1).optional(),
3824
- description: z7.string().optional()
3891
+ z8.object({
3892
+ kind: z8.literal("rename"),
3893
+ nodeId: z8.string(),
3894
+ slug: z8.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
3895
+ name: z8.string().min(1).optional(),
3896
+ description: z8.string().optional()
3825
3897
  }),
3826
- z7.object({
3827
- kind: z7.literal("delete"),
3828
- nodeId: z7.string()
3898
+ z8.object({
3899
+ kind: z8.literal("delete"),
3900
+ nodeId: z8.string()
3829
3901
  }),
3830
- z7.object({
3831
- kind: z7.literal("restore"),
3832
- nodeId: z7.string()
3902
+ z8.object({
3903
+ kind: z8.literal("restore"),
3904
+ nodeId: z8.string()
3833
3905
  }),
3834
- z7.object({
3835
- kind: z7.literal("move"),
3836
- nodeId: z7.string(),
3906
+ z8.object({
3907
+ kind: z8.literal("move"),
3908
+ nodeId: z8.string(),
3837
3909
  // Exactly one of parentNodeId / parentNodeRef (a ref created earlier in this CR).
3838
- parentNodeId: z7.string().optional(),
3839
- parentNodeRef: z7.string().min(1).optional(),
3840
- position: z7.number().int().optional()
3910
+ parentNodeId: z8.string().optional(),
3911
+ parentNodeRef: z8.string().min(1).optional(),
3912
+ position: z8.number().int().optional()
3841
3913
  })
3842
3914
  ]);
3843
- var createNodeChangeRequestInputSchema = z7.object({
3844
- message: z7.string().optional().default("Update node tree").describe(
3915
+ var createNodeChangeRequestInputSchema = z8.object({
3916
+ message: z8.string().optional().default("Update node tree").describe(
3845
3917
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Reorganize marketing docs under a Campaigns folder".'
3846
3918
  ),
3847
- submittedBy: z7.string().optional().default("local-producer"),
3848
- autoMerge: z7.boolean().optional().describe(
3919
+ submittedBy: z8.string().optional().default("local-producer"),
3920
+ autoMerge: z8.boolean().optional().describe(
3849
3921
  "Whether to approve and merge this structural node change immediately. Omitted defaults to merging immediately if the actor has write access on every target node, otherwise falling back to a pending Change Request; pass explicit false to force review even with write access."
3850
3922
  ),
3851
- operations: z7.array(nodeOperationInputSchema).min(1)
3923
+ operations: z8.array(nodeOperationInputSchema).min(1)
3852
3924
  });
3853
- var moveNodeInputSchema = z7.object({
3854
- nodeId: z7.string(),
3855
- parentNodeId: z7.string().optional().describe("New parent folder node id. Omit to keep the current parent and only reorder."),
3856
- position: z7.number().int().optional().describe("New position among the target parent's children."),
3857
- message: z7.string().optional().describe("Reviewer-facing Change Request message."),
3858
- submittedBy: z7.string().optional()
3925
+ var moveNodeInputSchema = z8.object({
3926
+ nodeId: z8.string(),
3927
+ parentNodeId: z8.string().optional().describe("New parent folder node id. Omit to keep the current parent and only reorder."),
3928
+ position: z8.number().int().optional().describe("New position among the target parent's children."),
3929
+ message: z8.string().optional().describe("Reviewer-facing Change Request message."),
3930
+ submittedBy: z8.string().optional()
3859
3931
  });
3860
- var createDeleteChangeRequestInputSchema = z7.object({
3861
- message: z7.string().optional().default("Delete record").describe(
3932
+ var createDeleteChangeRequestInputSchema = z8.object({
3933
+ message: z8.string().optional().default("Delete record").describe(
3862
3934
  'Explanation shown to the human reviewer. Say what is being removed and why, e.g. "Archive duplicate contact \u2014 merged into Acme Corp".'
3863
3935
  ),
3864
- submittedBy: z7.string().optional().default("local-producer"),
3936
+ submittedBy: z8.string().optional().default("local-producer"),
3865
3937
  // Only "archive" is supported — hard delete after retention was never
3866
3938
  // implemented, so the API no longer accepts it (breaking change).
3867
- deleteMode: z7.enum(["archive"]).optional().default("archive")
3939
+ deleteMode: z8.enum(["archive"]).optional().default("archive"),
3940
+ autoMerge: autoMergeNotAccepted(
3941
+ "archiving a record removes user content from every listing, so it always requires review. Omit the flag."
3942
+ )
3868
3943
  });
3869
- var reviseOperationInputSchema = z7.object({
3870
- fields: z7.record(z7.string(), z7.unknown()).describe(
3944
+ var reviseOperationInputSchema = z8.object({
3945
+ fields: z8.record(z8.string(), z8.unknown()).describe(
3871
3946
  "Updated field values keyed by field slug. If you set the base's PRIMARY field (its first field), keep it a short human-readable name \u2014 it is the record's display title everywhere."
3872
3947
  ),
3873
- message: z7.string().optional().default("Revise operation").describe(
3948
+ message: z8.string().optional().default("Revise operation").describe(
3874
3949
  'Explanation shown to the human reviewer. Write a conventional-commit style subject \u2014 imperative verb + what + why, e.g. "Update deal stage to qualified \u2014 demo booked for July 8".'
3875
3950
  ),
3876
- author: z7.string().optional().default("local-producer"),
3877
- baseCommitId: z7.string().optional()
3951
+ author: z8.string().optional().default("local-producer"),
3952
+ baseCommitId: z8.string().optional()
3878
3953
  });
3879
- var reviewChangeRequestInputSchema = z7.object({
3880
- verdict: z7.enum(["approved", "rejected"]),
3881
- reason: z7.string().optional()
3954
+ var reviewChangeRequestInputSchema = z8.object({
3955
+ verdict: z8.enum(["approved", "rejected"]),
3956
+ reason: z8.string().optional()
3882
3957
  });
3883
- var commentSubjectInputSchema = z7.object({
3958
+ var commentSubjectInputSchema = z8.object({
3884
3959
  subjectType: commentSubjectTypeSchema,
3885
- subjectId: z7.string().min(1)
3960
+ subjectId: z8.string().min(1)
3886
3961
  });
3887
3962
  var createCommentInputSchema = commentSubjectInputSchema.extend({
3888
- authorId: z7.string().optional().default("local-admin"),
3889
- body: z7.string().trim().min(1),
3890
- mentionsAi: z7.boolean().optional().default(false)
3963
+ authorId: z8.string().optional().default("local-admin"),
3964
+ body: z8.string().trim().min(1),
3965
+ mentionsAi: z8.boolean().optional().default(false)
3891
3966
  });
3892
- var listInputSchema = z7.object({
3893
- limit: z7.coerce.number().int().min(1).max(100).optional().default(50)
3967
+ var listInputSchema = z8.object({
3968
+ limit: z8.coerce.number().int().min(1).max(100).optional().default(50)
3894
3969
  }).optional().default({ limit: 50 });
3895
- var listByStatusInputSchema = z7.object({
3896
- status: z7.enum(["active", "archived"]).optional().default("active")
3970
+ var listByStatusInputSchema = z8.object({
3971
+ status: z8.enum(["active", "archived"]).optional().default("active")
3897
3972
  });
3898
- var listChangeRequestsPagedInputSchema = z7.object({
3899
- limit: z7.coerce.number().int().min(1).max(100).optional().default(50),
3973
+ var listChangeRequestsPagedInputSchema = z8.object({
3974
+ limit: z8.coerce.number().int().min(1).max(100).optional().default(50),
3900
3975
  /** Opaque base64 cursor (`createdAt|id`) for keyset pagination. */
3901
- cursor: z7.string().optional(),
3902
- status: z7.array(changeRequestStatusSchema).optional(),
3903
- mine: z7.boolean().optional()
3976
+ cursor: z8.string().optional(),
3977
+ status: z8.array(changeRequestStatusSchema).optional(),
3978
+ mine: z8.boolean().optional()
3904
3979
  }).optional().default({ limit: 50 });
3905
- var listChangeRequestsResponseSchema = z7.object({
3906
- changeRequests: z7.array(changeRequestSchema),
3907
- nextCursor: z7.string().nullable()
3980
+ var listChangeRequestsResponseSchema = z8.object({
3981
+ changeRequests: z8.array(changeRequestSchema),
3982
+ nextCursor: z8.string().nullable()
3908
3983
  });
3909
- var listChangeRequestsPageInputSchema = z7.object({
3910
- page: z7.coerce.number().int().min(1).optional().default(1),
3911
- pageSize: z7.coerce.number().int().min(1).max(100).optional().default(50),
3912
- status: z7.array(changeRequestStatusSchema).optional(),
3913
- mine: z7.boolean().optional()
3984
+ var listChangeRequestsPageInputSchema = z8.object({
3985
+ page: z8.coerce.number().int().min(1).optional().default(1),
3986
+ pageSize: z8.coerce.number().int().min(1).max(100).optional().default(50),
3987
+ status: z8.array(changeRequestStatusSchema).optional(),
3988
+ mine: z8.boolean().optional()
3914
3989
  }).optional().default({ page: 1, pageSize: 50 });
3915
- var listChangeRequestsPageResponseSchema = z7.object({
3916
- changeRequests: z7.array(changeRequestSchema),
3917
- total: z7.number().int().nonnegative(),
3918
- totalPages: z7.number().int().nonnegative(),
3919
- page: z7.number().int().min(1),
3920
- pageSize: z7.number().int().min(1).max(100)
3990
+ var listChangeRequestsPageResponseSchema = z8.object({
3991
+ changeRequests: z8.array(changeRequestSchema),
3992
+ total: z8.number().int().nonnegative(),
3993
+ totalPages: z8.number().int().nonnegative(),
3994
+ page: z8.number().int().min(1),
3995
+ pageSize: z8.number().int().min(1).max(100)
3921
3996
  });
3922
- var changeRequestCountsSchema = z7.object({
3923
- review: z7.number().int().nonnegative(),
3924
- changes: z7.number().int().nonnegative(),
3925
- created: z7.number().int().nonnegative(),
3926
- approved: z7.number().int().nonnegative(),
3927
- merged: z7.number().int().nonnegative(),
3928
- rejected: z7.number().int().nonnegative()
3997
+ var changeRequestCountsSchema = z8.object({
3998
+ review: z8.number().int().nonnegative(),
3999
+ changes: z8.number().int().nonnegative(),
4000
+ created: z8.number().int().nonnegative(),
4001
+ approved: z8.number().int().nonnegative(),
4002
+ merged: z8.number().int().nonnegative(),
4003
+ rejected: z8.number().int().nonnegative()
3929
4004
  });
3930
4005
  var SEARCH_SOURCES = ["records", "files", "names"];
3931
- var searchInputSchema = z7.object({
3932
- query: z7.string().default(""),
3933
- limit: z7.coerce.number().int().min(1).max(100).optional().default(20),
3934
- offset: z7.coerce.number().int().min(0).optional().default(0),
4006
+ var searchInputSchema = z8.object({
4007
+ query: z8.string().default(""),
4008
+ limit: z8.coerce.number().int().min(1).max(100).optional().default(20),
4009
+ offset: z8.coerce.number().int().min(0).optional().default(0),
3935
4010
  /**
3936
4011
  * Restrict which content this call searches. Omitted means all three
3937
4012
  * (unchanged behavior for every caller before this parameter existed).
@@ -3941,13 +4016,13 @@ var searchInputSchema = z7.object({
3941
4016
  * (`?sources=records&sources=files`) becomes an array. Accept both shapes
3942
4017
  * and normalize to an array.
3943
4018
  */
3944
- sources: z7.union([z7.array(z7.enum(SEARCH_SOURCES)), z7.enum(SEARCH_SOURCES)]).transform((value) => Array.isArray(value) ? value : [value]).optional()
4019
+ sources: z8.union([z8.array(z8.enum(SEARCH_SOURCES)), z8.enum(SEARCH_SOURCES)]).transform((value) => Array.isArray(value) ? value : [value]).optional()
3945
4020
  });
3946
- var authSpaceSchema = z7.object({
3947
- id: z7.string(),
3948
- name: z7.string(),
3949
- slug: z7.string().nullable(),
3950
- plan: z7.string().nullable(),
4021
+ var authSpaceSchema = z8.object({
4022
+ id: z8.string(),
4023
+ name: z8.string(),
4024
+ slug: z8.string().nullable(),
4025
+ plan: z8.string().nullable(),
3951
4026
  /**
3952
4027
  * The space's DEFAULT content visibility for its members — the same
3953
4028
  * `spaces.nodeVisibilityMode` the cloud dashboard reads. `"open"` = a node
@@ -3963,20 +4038,20 @@ var authSpaceSchema = z7.object({
3963
4038
  * (or a host that doesn't model a space default at all) simply omits it.
3964
4039
  * Treat an absent value as `"open"` — the historical behaviour.
3965
4040
  */
3966
- nodeVisibilityMode: z7.enum(["open", "restricted"]).optional()
4041
+ nodeVisibilityMode: z8.enum(["open", "restricted"]).optional()
3967
4042
  });
3968
- var authUserSchema = z7.object({
3969
- id: z7.string(),
3970
- name: z7.string(),
3971
- email: z7.string().nullable(),
3972
- image: z7.string().nullable()
4043
+ var authUserSchema = z8.object({
4044
+ id: z8.string(),
4045
+ name: z8.string(),
4046
+ email: z8.string().nullable(),
4047
+ image: z8.string().nullable()
3973
4048
  });
3974
- var authMemberSchema = z7.object({
3975
- userId: z7.string(),
3976
- spaceId: z7.string(),
3977
- role: z7.string()
4049
+ var authMemberSchema = z8.object({
4050
+ userId: z8.string(),
4051
+ spaceId: z8.string(),
4052
+ role: z8.string()
3978
4053
  });
3979
- var authInfoSchema = z7.object({
4054
+ var authInfoSchema = z8.object({
3980
4055
  /** The space this request is scoped to (explicit `x-busabase-space` header, else the default). */
3981
4056
  space: authSpaceSchema,
3982
4057
  user: authUserSchema,
@@ -3986,11 +4061,11 @@ var authInfoSchema = z7.object({
3986
4061
  * space-scoped — when this has more than one entry, callers should confirm the
3987
4062
  * intended space and target it explicitly via the `x-busabase-space` header.
3988
4063
  */
3989
- spaces: z7.array(authSpaceSchema),
4064
+ spaces: z8.array(authSpaceSchema),
3990
4065
  /** Cloud only: the server created this user's first Space during this exact request. */
3991
- createdSpace: z7.boolean().optional(),
4066
+ createdSpace: z8.boolean().optional(),
3992
4067
  /** Cloud only: this auto-created Space still needs its idempotent starter initialization. */
3993
- bootstrapRequired: z7.boolean().optional()
4068
+ bootstrapRequired: z8.boolean().optional()
3994
4069
  });
3995
4070
 
3996
4071
  // ../../packages/busabase-contract/src/domains/base/types.ts
@@ -3998,7 +4073,7 @@ var VIEW_FIELD_MIN_WIDTH = 92;
3998
4073
  var VIEW_FIELD_MAX_WIDTH = 640;
3999
4074
 
4000
4075
  // ../../packages/busabase-contract/src/domains/base/contract/view-schemas.ts
4001
- var viewFilterOperatorSchema = z8.enum([
4076
+ var viewFilterOperatorSchema = z9.enum([
4002
4077
  "contains",
4003
4078
  "equals",
4004
4079
  "not_empty",
@@ -4006,107 +4081,107 @@ var viewFilterOperatorSchema = z8.enum([
4006
4081
  "is_true",
4007
4082
  "is_false"
4008
4083
  ]);
4009
- var viewFilterSchema = z8.object({
4010
- fieldSlug: z8.string(),
4084
+ var viewFilterSchema = z9.object({
4085
+ fieldSlug: z9.string(),
4011
4086
  // Stable field identity — survives slug reuse; populated on merge.
4012
- fieldId: z8.string().optional(),
4087
+ fieldId: z9.string().optional(),
4013
4088
  operator: viewFilterOperatorSchema,
4014
- value: z8.unknown().optional()
4089
+ value: z9.unknown().optional()
4015
4090
  });
4016
- var viewSortSchema = z8.object({
4017
- direction: z8.enum(["asc", "desc"]),
4018
- fieldSlug: z8.string(),
4019
- fieldId: z8.string().optional()
4091
+ var viewSortSchema = z9.object({
4092
+ direction: z9.enum(["asc", "desc"]),
4093
+ fieldSlug: z9.string(),
4094
+ fieldId: z9.string().optional()
4020
4095
  });
4021
- var viewTypeSchema = z8.enum(["table", "gallery", "kanban", "calendar", "gantt"]);
4022
- var ganttScaleSchema = z8.enum(["week", "month"]);
4023
- var galleryCoverFitSchema = z8.enum(["cover", "fit"]);
4024
- var galleryCardSizeSchema = z8.enum(["small", "medium", "large"]);
4025
- var viewConfigSchema = z8.object({
4026
- filters: z8.array(viewFilterSchema).default([]),
4027
- sorts: z8.array(viewSortSchema).default([]),
4028
- visibleFieldSlugs: z8.array(z8.string()).nullable().optional(),
4029
- fieldWidths: z8.record(z8.string().min(1), z8.number().int().min(VIEW_FIELD_MIN_WIDTH).max(VIEW_FIELD_MAX_WIDTH)).optional(),
4096
+ var viewTypeSchema = z9.enum(["table", "gallery", "kanban", "calendar", "gantt"]);
4097
+ var ganttScaleSchema = z9.enum(["week", "month"]);
4098
+ var galleryCoverFitSchema = z9.enum(["cover", "fit"]);
4099
+ var galleryCardSizeSchema = z9.enum(["small", "medium", "large"]);
4100
+ var viewConfigSchema = z9.object({
4101
+ filters: z9.array(viewFilterSchema).default([]),
4102
+ sorts: z9.array(viewSortSchema).default([]),
4103
+ visibleFieldSlugs: z9.array(z9.string()).nullable().optional(),
4104
+ fieldWidths: z9.record(z9.string().min(1), z9.number().int().min(VIEW_FIELD_MIN_WIDTH).max(VIEW_FIELD_MAX_WIDTH)).optional(),
4030
4105
  // ── Gallery-only presentation config (ignored by table views) ──
4031
4106
  // Which attachment field supplies the cover image (null = no cover).
4032
- coverFieldSlug: z8.string().nullable().optional(),
4107
+ coverFieldSlug: z9.string().nullable().optional(),
4033
4108
  coverFit: galleryCoverFitSchema.optional(),
4034
4109
  cardSize: galleryCardSizeSchema.optional(),
4035
4110
  // Whether to render the field label above each value on a card.
4036
- showFieldLabels: z8.boolean().optional(),
4111
+ showFieldLabels: z9.boolean().optional(),
4037
4112
  // ── Kanban-only: which single-select field stacks records into columns.
4038
- stackByFieldSlug: z8.string().nullable().optional(),
4113
+ stackByFieldSlug: z9.string().nullable().optional(),
4039
4114
  // ── Calendar-only: which date field positions records on the month grid.
4040
- dateFieldSlug: z8.string().nullable().optional(),
4115
+ dateFieldSlug: z9.string().nullable().optional(),
4041
4116
  // ── Gantt-only: the start/end date fields bounding each record's bar, plus
4042
4117
  // the time-axis granularity.
4043
- startFieldSlug: z8.string().nullable().optional(),
4044
- endFieldSlug: z8.string().nullable().optional(),
4118
+ startFieldSlug: z9.string().nullable().optional(),
4119
+ endFieldSlug: z9.string().nullable().optional(),
4045
4120
  ganttScale: ganttScaleSchema.optional()
4046
4121
  });
4047
- var viewSchema = z8.object({
4048
- id: z8.string(),
4049
- baseId: z8.string(),
4050
- slug: z8.string(),
4051
- name: z8.string(),
4052
- description: z8.string(),
4122
+ var viewSchema = z9.object({
4123
+ id: z9.string(),
4124
+ baseId: z9.string(),
4125
+ slug: z9.string(),
4126
+ name: z9.string(),
4127
+ description: z9.string(),
4053
4128
  type: viewTypeSchema,
4054
4129
  config: viewConfigSchema,
4055
- status: z8.enum(["active", "archived"]),
4056
- createdBy: z8.string(),
4130
+ status: z9.enum(["active", "archived"]),
4131
+ createdBy: z9.string(),
4057
4132
  createdByUser: userRefSchema.nullable().optional().default(null),
4058
- archivedAt: z8.string().nullable(),
4059
- createdAt: z8.string(),
4060
- updatedAt: z8.string()
4133
+ archivedAt: z9.string().nullable(),
4134
+ createdAt: z9.string(),
4135
+ updatedAt: z9.string()
4061
4136
  });
4062
- var autoMergeSchema = z8.boolean().optional().describe(
4137
+ var autoMergeSchema = z9.boolean().optional().describe(
4063
4138
  "Whether to approve and merge this view change immediately. Omitted defaults to merging immediately if the actor has write access on the Base's node, otherwise falling back to a pending Change Request; pass explicit false to force review even with write access."
4064
4139
  );
4065
- var createViewInputSchema = z8.object({
4140
+ var createViewInputSchema = z9.object({
4066
4141
  config: viewConfigSchema.optional().default({ filters: [], sorts: [] }),
4067
- description: z8.string().optional().default(""),
4068
- message: z8.string().optional().default("Create view"),
4069
- name: z8.string().min(1),
4142
+ description: z9.string().optional().default(""),
4143
+ message: z9.string().optional().default("Create view"),
4144
+ name: z9.string().min(1),
4070
4145
  type: viewTypeSchema.optional().default("table"),
4071
- slug: z8.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
4072
- submittedBy: z8.string().optional().default("local-producer"),
4146
+ slug: z9.string().min(1).regex(/^[a-z0-9-]+$/).optional(),
4147
+ submittedBy: z9.string().optional().default("local-producer"),
4073
4148
  autoMerge: autoMergeSchema
4074
4149
  });
4075
- var updateViewInputSchema = z8.object({
4150
+ var updateViewInputSchema = z9.object({
4076
4151
  config: viewConfigSchema.optional(),
4077
- description: z8.string().optional(),
4078
- message: z8.string().optional().default("Update view"),
4079
- name: z8.string().min(1).optional(),
4152
+ description: z9.string().optional(),
4153
+ message: z9.string().optional().default("Update view"),
4154
+ name: z9.string().min(1).optional(),
4080
4155
  type: viewTypeSchema.optional(),
4081
- submittedBy: z8.string().optional().default("local-producer"),
4156
+ submittedBy: z9.string().optional().default("local-producer"),
4082
4157
  autoMerge: autoMergeSchema
4083
4158
  });
4084
- var deleteViewInputSchema = z8.object({
4085
- message: z8.string().optional().default("Delete view"),
4086
- submittedBy: z8.string().optional().default("local-producer"),
4159
+ var deleteViewInputSchema = z9.object({
4160
+ message: z9.string().optional().default("Delete view"),
4161
+ submittedBy: z9.string().optional().default("local-producer"),
4087
4162
  autoMerge: autoMergeSchema
4088
4163
  });
4089
- var restoreViewInputSchema = z8.object({
4090
- message: z8.string().optional().default("Restore view"),
4091
- submittedBy: z8.string().optional().default("local-producer"),
4164
+ var restoreViewInputSchema = z9.object({
4165
+ message: z9.string().optional().default("Restore view"),
4166
+ submittedBy: z9.string().optional().default("local-producer"),
4092
4167
  autoMerge: autoMergeSchema
4093
4168
  });
4094
- var viewChangeRequestInputSchema = z8.discriminatedUnion("operation", [
4169
+ var viewChangeRequestInputSchema = z9.discriminatedUnion("operation", [
4095
4170
  createViewInputSchema.extend({
4096
- operation: z8.literal("create"),
4097
- baseId: z8.string().min(1).describe("Base the new view belongs to.")
4171
+ operation: z9.literal("create"),
4172
+ baseId: z9.string().min(1).describe("Base the new view belongs to.")
4098
4173
  }),
4099
4174
  updateViewInputSchema.extend({
4100
- operation: z8.literal("update"),
4101
- viewId: z8.string().min(1)
4175
+ operation: z9.literal("update"),
4176
+ viewId: z9.string().min(1)
4102
4177
  }),
4103
4178
  deleteViewInputSchema.extend({
4104
- operation: z8.literal("delete"),
4105
- viewId: z8.string().min(1)
4179
+ operation: z9.literal("delete"),
4180
+ viewId: z9.string().min(1)
4106
4181
  }),
4107
4182
  restoreViewInputSchema.extend({
4108
- operation: z8.literal("restore"),
4109
- viewId: z8.string().min(1)
4183
+ operation: z9.literal("restore"),
4184
+ viewId: z9.string().min(1)
4110
4185
  })
4111
4186
  ]);
4112
4187
 
@@ -4148,141 +4223,141 @@ var PACKAGE_MAX_FILE_BYTES = 25 * 1024 * 1024;
4148
4223
  var PACKAGE_MAX_TOTAL_BYTES = 250 * 1024 * 1024;
4149
4224
  var PACKAGE_MAX_FILE_COUNT = 5e3;
4150
4225
  var PACKAGE_MAX_RECORDS_PER_BASE = 5e4;
4151
- var PackageManifestSchema = z9.object({
4152
- format: z9.literal(PACKAGE_FORMAT),
4226
+ var PackageManifestSchema = z10.object({
4227
+ format: z10.literal(PACKAGE_FORMAT),
4153
4228
  /** Default `--into-folder` name. Not the repo name — a repo can host many packages. */
4154
- name: z9.string().min(1),
4155
- description: z9.string().default(""),
4229
+ name: z10.string().min(1),
4230
+ description: z10.string().default(""),
4156
4231
  /**
4157
4232
  * Informational / reserved for a future marketplace index. The real version pin
4158
4233
  * is always the git ref in the install URL.
4159
4234
  */
4160
- version: z9.string().optional(),
4161
- author: z9.string().optional(),
4162
- license: z9.string().optional(),
4163
- homepage: z9.string().url().optional(),
4164
- tags: z9.array(z9.string()).default([])
4235
+ version: z10.string().optional(),
4236
+ author: z10.string().optional(),
4237
+ license: z10.string().optional(),
4238
+ homepage: z10.string().url().optional(),
4239
+ tags: z10.array(z10.string()).default([])
4165
4240
  });
4166
- var PackageFileTreeNodeMetaSchema = z9.object({
4167
- type: z9.enum(PACKAGE_FILE_TREE_NODE_TYPES),
4168
- name: z9.string().min(1),
4169
- description: z9.string().default(""),
4170
- position: z9.number().int().optional()
4241
+ var PackageFileTreeNodeMetaSchema = z10.object({
4242
+ type: z10.enum(PACKAGE_FILE_TREE_NODE_TYPES),
4243
+ name: z10.string().min(1),
4244
+ description: z10.string().default(""),
4245
+ position: z10.number().int().optional()
4171
4246
  });
4172
- var PackageFolderMetaSchema = z9.object({
4247
+ var PackageFolderMetaSchema = z10.object({
4173
4248
  /** Defaults to the humanized slug when absent. */
4174
- name: z9.string().optional(),
4175
- description: z9.string().default(""),
4176
- position: z9.number().int().optional()
4249
+ name: z10.string().optional(),
4250
+ description: z10.string().default(""),
4251
+ position: z10.number().int().optional()
4177
4252
  });
4178
4253
  var PackageFileNodeMetaSchema = PackageFolderMetaSchema;
4179
- var PackageDocFrontmatterSchema = z9.object({
4180
- name: z9.string().min(1),
4181
- description: z9.string().default(""),
4182
- position: z9.number().int().optional()
4254
+ var PackageDocFrontmatterSchema = z10.object({
4255
+ name: z10.string().min(1),
4256
+ description: z10.string().default(""),
4257
+ position: z10.number().int().optional()
4183
4258
  });
4184
- var PackageFieldOptionsSchema = z9.object({
4185
- ai: z9.object({
4186
- model: z9.string().optional(),
4187
- prompt: z9.string().optional(),
4188
- reviewRequired: z9.boolean().optional(),
4259
+ var PackageFieldOptionsSchema = z10.object({
4260
+ ai: z10.object({
4261
+ model: z10.string().optional(),
4262
+ prompt: z10.string().optional(),
4263
+ reviewRequired: z10.boolean().optional(),
4189
4264
  /** Package-only — replaces `ai.sourceFieldIds`. */
4190
- sourceFieldSlugs: z9.array(z9.string()).optional()
4265
+ sourceFieldSlugs: z10.array(z10.string()).optional()
4191
4266
  }).optional(),
4192
- attachment: z9.object({
4193
- maxFiles: z9.number().int().positive().optional(),
4194
- allowedMimeTypes: z9.array(z9.string()).optional(),
4195
- maxFileSize: z9.number().int().positive().optional()
4267
+ attachment: z10.object({
4268
+ maxFiles: z10.number().int().positive().optional(),
4269
+ allowedMimeTypes: z10.array(z10.string()).optional(),
4270
+ maxFileSize: z10.number().int().positive().optional()
4196
4271
  }).optional(),
4197
- choices: z9.array(
4198
- z9.object({
4199
- color: z9.string().optional(),
4200
- id: z9.string(),
4201
- name: z9.string()
4272
+ choices: z10.array(
4273
+ z10.object({
4274
+ color: z10.string().optional(),
4275
+ id: z10.string(),
4276
+ name: z10.string()
4202
4277
  })
4203
4278
  ).optional(),
4204
- code: z9.object({
4205
- language: z9.string().optional()
4279
+ code: z10.object({
4280
+ language: z10.string().optional()
4206
4281
  }).optional(),
4207
- embed: z9.object({
4208
- aspectRatio: z9.enum(["16:9", "4:3", "1:1"]).optional(),
4209
- height: z9.number().int().positive().max(1200).optional(),
4210
- providers: z9.array(z9.string()).optional()
4282
+ embed: z10.object({
4283
+ aspectRatio: z10.enum(["16:9", "4:3", "1:1"]).optional(),
4284
+ height: z10.number().int().positive().max(1200).optional(),
4285
+ providers: z10.array(z10.string()).optional()
4211
4286
  }).optional(),
4212
4287
  /** Mirrors the API's `formula.expression` verbatim — `{slug}` references carry
4213
4288
  * over unchanged since the package format keys everything by slug already. */
4214
- formula: z9.object({
4215
- expression: z9.string().min(1)
4289
+ formula: z10.object({
4290
+ expression: z10.string().min(1)
4216
4291
  }).optional(),
4217
4292
  /** Package-only — replaces `inverseFieldId`. */
4218
- inverseFieldSlug: z9.string().optional(),
4293
+ inverseFieldSlug: z10.string().optional(),
4219
4294
  /** Carried verbatim: the API's own `lookup` config is already keyed entirely
4220
4295
  * by slug (`relationFieldSlug` / `targetFieldSlug`), so it survives a
4221
4296
  * re-id'ing install with no package-only alias. The companion `number`
4222
4297
  * snapshot rides along in the `number` key above. */
4223
- lookup: z9.object({
4224
- relationFieldSlug: z9.string().min(1),
4225
- targetFieldSlug: z9.string().min(1),
4298
+ lookup: z10.object({
4299
+ relationFieldSlug: z10.string().min(1),
4300
+ targetFieldSlug: z10.string().min(1),
4226
4301
  rollup: lookupRollupSchema.optional(),
4227
- limit: z9.enum(["all", "first"]).optional()
4302
+ limit: z10.enum(["all", "first"]).optional()
4228
4303
  }).optional(),
4229
- multiple: z9.boolean().optional(),
4230
- number: z9.object({
4231
- format: z9.enum(["plain", "currency"]).optional(),
4232
- currency: z9.string().optional(),
4233
- locale: z9.string().optional()
4304
+ multiple: z10.boolean().optional(),
4305
+ number: z10.object({
4306
+ format: z10.enum(["plain", "currency"]).optional(),
4307
+ currency: z10.string().optional(),
4308
+ locale: z10.string().optional()
4234
4309
  }).optional(),
4235
4310
  /** Native API alias — the server resolves it to `targetBaseId`. */
4236
- targetBaseSlug: z9.string().optional()
4311
+ targetBaseSlug: z10.string().optional()
4237
4312
  }).default({});
4238
- var PackageBaseFieldSchema = z9.object({
4239
- slug: z9.string().min(1),
4313
+ var PackageBaseFieldSchema = z10.object({
4314
+ slug: z10.string().min(1),
4240
4315
  name: fieldNameSchema,
4241
4316
  type: fieldTypeSchema,
4242
- required: z9.boolean().default(false),
4243
- position: z9.number().int(),
4317
+ required: z10.boolean().default(false),
4318
+ position: z10.number().int(),
4244
4319
  options: PackageFieldOptionsSchema
4245
4320
  });
4246
- var PackageViewFilterSchema = z9.object({
4247
- fieldSlug: z9.string().min(1),
4321
+ var PackageViewFilterSchema = z10.object({
4322
+ fieldSlug: z10.string().min(1),
4248
4323
  operator: viewFilterOperatorSchema,
4249
- value: z9.unknown().optional()
4324
+ value: z10.unknown().optional()
4250
4325
  });
4251
- var PackageViewSortSchema = z9.object({
4252
- direction: z9.enum(["asc", "desc"]),
4253
- fieldSlug: z9.string().min(1)
4326
+ var PackageViewSortSchema = z10.object({
4327
+ direction: z10.enum(["asc", "desc"]),
4328
+ fieldSlug: z10.string().min(1)
4254
4329
  });
4255
- var PackageViewConfigSchema = z9.object({
4256
- filters: z9.array(PackageViewFilterSchema).default([]),
4257
- sorts: z9.array(PackageViewSortSchema).default([]),
4258
- visibleFieldSlugs: z9.array(z9.string()).nullable().optional(),
4259
- fieldWidths: z9.record(z9.string().min(1), z9.number().int().min(VIEW_FIELD_MIN_WIDTH).max(VIEW_FIELD_MAX_WIDTH)).optional()
4330
+ var PackageViewConfigSchema = z10.object({
4331
+ filters: z10.array(PackageViewFilterSchema).default([]),
4332
+ sorts: z10.array(PackageViewSortSchema).default([]),
4333
+ visibleFieldSlugs: z10.array(z10.string()).nullable().optional(),
4334
+ fieldWidths: z10.record(z10.string().min(1), z10.number().int().min(VIEW_FIELD_MIN_WIDTH).max(VIEW_FIELD_MAX_WIDTH)).optional()
4260
4335
  });
4261
- var PackageViewSchema = z9.object({
4262
- slug: z9.string().min(1),
4263
- name: z9.string().min(1),
4264
- description: z9.string().default(""),
4265
- type: z9.literal("table").default("table"),
4336
+ var PackageViewSchema = z10.object({
4337
+ slug: z10.string().min(1),
4338
+ name: z10.string().min(1),
4339
+ description: z10.string().default(""),
4340
+ type: z10.literal("table").default("table"),
4266
4341
  config: PackageViewConfigSchema.default({ filters: [], sorts: [] })
4267
4342
  });
4268
- var PackageBaseSchema = z9.object({
4269
- name: z9.string().min(1),
4270
- description: z9.string().default(""),
4271
- position: z9.number().int().optional(),
4343
+ var PackageBaseSchema = z10.object({
4344
+ name: z10.string().min(1),
4345
+ description: z10.string().default(""),
4346
+ position: z10.number().int().optional(),
4272
4347
  /**
4273
4348
  * Informational only — `reviewPolicy` is NOT settable via `bases.create`, so
4274
4349
  * install cannot apply it and warns when it differs from the target's default.
4275
4350
  */
4276
- reviewPolicy: z9.object({
4277
- kind: z9.literal("single"),
4278
- requiredApprovals: z9.number()
4351
+ reviewPolicy: z10.object({
4352
+ kind: z10.literal("single"),
4353
+ requiredApprovals: z10.number()
4279
4354
  }).optional(),
4280
- fields: z9.array(PackageBaseFieldSchema).default([]),
4281
- views: z9.array(PackageViewSchema).default([])
4355
+ fields: z10.array(PackageBaseFieldSchema).default([]),
4356
+ views: z10.array(PackageViewSchema).default([])
4282
4357
  });
4283
- var PackageRecordLineSchema = z9.object({
4284
- key: z9.string().min(1),
4285
- fields: z9.record(z9.string(), z9.unknown()).default({})
4358
+ var PackageRecordLineSchema = z10.object({
4359
+ key: z10.string().min(1),
4360
+ fields: z10.record(z10.string(), z10.unknown()).default({})
4286
4361
  });
4287
4362
 
4288
4363
  // ../../packages/busabase-package/src/apply.ts
@@ -4458,9 +4533,18 @@ var applyInstall = async (client, plan, options) => {
4458
4533
  fieldId,
4459
4534
  patch: { options: patched },
4460
4535
  message: `Wire up ${base.node.slug}.${field.slug} references`,
4461
- submittedBy: options.submittedBy
4536
+ submittedBy: options.submittedBy,
4537
+ // Field wiring is STRUCTURE, like the Base and its views above — ask for it
4538
+ // outright rather than proposing it and immediately approving our own
4539
+ // proposal, which is what this used to do only because the endpoint had no
4540
+ // `autoMerge`.
4541
+ autoMerge: true
4462
4542
  });
4463
- await approveAndMerge(client, changeRequest.id);
4543
+ if (changeRequest.status !== "merged") {
4544
+ throw new Error(
4545
+ `Field reference wiring for ${base.node.slug}.${field.slug} was requested immediately but came back "${changeRequest.status}"; install cannot leave a Base's relation fields unwired.`
4546
+ );
4547
+ }
4464
4548
  }
4465
4549
  }
4466
4550
  const recordIdsByKey = /* @__PURE__ */ new Map();
@@ -4785,7 +4869,13 @@ var createRecords = async (client, base, plan, options, state, recordIdsByKey) =
4785
4869
  records: batch.map((record) => toCreatableFields(base.node, record.fields)),
4786
4870
  message: `Install ${batch.length} record(s) into ${base.node.slug}`,
4787
4871
  submittedBy: options.submittedBy,
4788
- idempotencyKey: batchIdempotencyKey(plan.tree.manifest.name, batch[0].key)
4872
+ idempotencyKey: batchIdempotencyKey(plan.tree.manifest.name, batch[0].key),
4873
+ // Forwarded explicitly, load-bearing: `--auto-merge` is the ONLY thing that
4874
+ // decides whether an install's records go live, and that promise is what the
4875
+ // review-first install is. Leaving this to the endpoint's permission-aware
4876
+ // default would silently merge a review-first install's records for any
4877
+ // write-capable installer.
4878
+ autoMerge: options.autoMerge
4789
4879
  });
4790
4880
  if (!options.autoMerge) {
4791
4881
  state.pendingChangeRequests++;
@@ -6388,21 +6478,21 @@ function parseJsonValue(raw, flagName) {
6388
6478
  JSON parse error: ${reason}`);
6389
6479
  }
6390
6480
  }
6481
+ function formatIssues(issues) {
6482
+ if (!Array.isArray(issues) || issues.length === 0) return void 0;
6483
+ return issues.map((issue) => {
6484
+ if (!issue || typeof issue !== "object") return String(issue);
6485
+ const { path, message } = issue;
6486
+ const pathLabel = Array.isArray(path) && path.length > 0 ? path.join(".") : void 0;
6487
+ return pathLabel ? `${pathLabel}: ${message}` : String(message ?? issue);
6488
+ }).join("; ");
6489
+ }
6391
6490
  function formatRawErrorBody(status, statusText, text) {
6392
6491
  try {
6393
6492
  const parsed = JSON.parse(text);
6394
6493
  if (typeof parsed.error === "string") {
6395
- const issues = parsed.data?.issues;
6396
- let message = parsed.error;
6397
- if (Array.isArray(issues) && issues.length > 0) {
6398
- const details = issues.map((issue) => {
6399
- if (!issue || typeof issue !== "object") return String(issue);
6400
- const { path, message: issueMessage } = issue;
6401
- const pathLabel = Array.isArray(path) ? path.join(".") : void 0;
6402
- return pathLabel ? `${pathLabel}: ${issueMessage}` : String(issueMessage ?? issue);
6403
- }).join("; ");
6404
- message = `${message} \u2014 ${details}`;
6405
- }
6494
+ const details = formatIssues(parsed.data?.issues);
6495
+ const message = details ? `${parsed.error} \u2014 ${details}` : parsed.error;
6406
6496
  return `HTTP ${status} ${statusText}: ${message}`;
6407
6497
  }
6408
6498
  } catch {
@@ -7404,7 +7494,9 @@ function renderedHelp() {
7404
7494
  var HELP = renderedHelp();
7405
7495
  function explainError(error, config) {
7406
7496
  const base = config.baseUrl;
7407
- const msg = error instanceof Error ? error.message : String(error);
7497
+ const rawMessage = error instanceof Error ? error.message : String(error);
7498
+ const issueDetail = formatIssues(error.data?.issues);
7499
+ const msg = issueDetail ? `${rawMessage} \u2014 ${issueDetail}` : rawMessage;
7408
7500
  const status = error.status;
7409
7501
  const lower = msg.toLowerCase();
7410
7502
  let body;