@get-bb/plugin-sdk 0.6.80 → 0.6.89

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.
@@ -169,14 +169,27 @@ function writeBase(store, collection, id, update) {
169
169
  collection.base.set(id, next);
170
170
  changed(store, collection, [id]);
171
171
  }
172
+ function dropAccepted(collection, id, acceptedBefore) {
173
+ let dropped = false;
174
+ collection.layers = collection.layers.filter((layer) => {
175
+ if (layer.acceptedAt === null || layer.acceptedAt >= acceptedBefore || !layer.ids.has(id))
176
+ return true;
177
+ dropped = true;
178
+ layer.ids.delete(id);
179
+ return layer.ids.size > 0;
180
+ });
181
+ return dropped;
182
+ }
172
183
  function ingest(store, skeleton, id, item, readStart) {
173
- const fresh = readStart > (skeleton.collection.acknowledgedAt.get(id) ?? -1);
184
+ const { collection } = skeleton;
185
+ const fresh = readStart > (collection.acknowledgedAt.get(id) ?? -1);
174
186
  writeBase(
175
187
  store,
176
- skeleton.collection,
188
+ collection,
177
189
  id,
178
190
  (current) => skeleton.view.read(item, current, fresh)
179
191
  );
192
+ if (dropAccepted(collection, id, readStart)) changed(store, collection, [id]);
180
193
  }
181
194
  function materializeItem(store, view, item, entity) {
182
195
  if (!isObject(item) || !isObject(entity)) return view.render(item, entity);
@@ -281,6 +294,7 @@ function setSkeleton(store, query, skeleton) {
281
294
  collection.views.delete(id);
282
295
  collection.base.delete(id);
283
296
  collection.visible.delete(id);
297
+ dropAccepted(collection, id, Number.POSITIVE_INFINITY);
284
298
  }
285
299
  }
286
300
  }
@@ -476,44 +490,24 @@ function recordKeyedRead(client, queryKey, startedAt) {
476
490
  const query = client.getQueryCache().get(client.defaultQueryOptions({ queryKey }).queryHash);
477
491
  if (query !== void 0) storeOf(client).receipts.set(query, startedAt);
478
492
  }
479
- function bakeSettledLayers(collection) {
480
- const baked = /* @__PURE__ */ new Set();
481
- const pending = /* @__PURE__ */ new Set();
482
- collection.layers = collection.layers.filter((layer) => {
483
- const blocked = [...layer.ids].some((id) => pending.has(id));
484
- if (!layer.settled || blocked) {
485
- for (const id of layer.ids) pending.add(id);
486
- return true;
487
- }
488
- for (const id of layer.ids) {
489
- const current = collection.base.get(id);
490
- if (current !== void 0)
491
- collection.base.set(id, layer.apply(current, id));
492
- baked.add(id);
493
- }
494
- return false;
495
- });
496
- return baked;
497
- }
498
493
  function predictKeyed(client, token, ids, apply) {
499
494
  const store = storeOf(client);
500
495
  const collection = collectionOf(store, token);
501
- const layer = { ids, apply, settled: false };
496
+ const layer = { ids: new Set(ids), apply, acceptedAt: null };
502
497
  collection.layers.push(layer);
503
498
  changed(store, collection, ids);
504
- const live = () => !layer.settled && collection.layers.includes(layer);
499
+ const live = () => layer.acceptedAt === null && collection.layers.includes(layer);
505
500
  return {
506
501
  accept() {
507
502
  if (!live()) return;
508
503
  const at = tick();
509
504
  for (const id of ids) collection.acknowledgedAt.set(id, at);
510
- layer.settled = true;
511
- changed(store, collection, [...ids, ...bakeSettledLayers(collection)]);
505
+ layer.acceptedAt = at;
512
506
  },
513
507
  remove() {
514
508
  if (!live()) return;
515
509
  collection.layers = collection.layers.filter((other) => other !== layer);
516
- changed(store, collection, [...ids, ...bakeSettledLayers(collection)]);
510
+ changed(store, collection, ids);
517
511
  }
518
512
  };
519
513
  }
@@ -1117,7 +1111,7 @@ function createTaggedKeyedQueryOwner(options) {
1117
1111
  queryFn: () => {
1118
1112
  let previous = getTaggedReadData(client, queryKey);
1119
1113
  const startedAt = /* @__PURE__ */ new Map();
1120
- let refresh = !missingOnly && dirtyKeys.size === 0;
1114
+ let refresh = !missingOnly && ![...keys.keys()].some((key) => dirtyKeys.has(key));
1121
1115
  missingOnly = false;
1122
1116
  const refreshedKeys = /* @__PURE__ */ new Set();
1123
1117
  let refreshedAll = false;
@@ -1126,13 +1120,18 @@ function createTaggedKeyedQueryOwner(options) {
1126
1120
  const all = refreshAll || refresh;
1127
1121
  refresh = false;
1128
1122
  const dirty = new Set(dirtyKeys);
1129
- for (const key of dirty) refreshedKeys.add(key);
1130
1123
  refreshedAll ||= all;
1131
- dirtyKeys.clear();
1124
+ if (all)
1125
+ for (const key of Object.keys(previous?.result ?? {}))
1126
+ dirtyKeys.add(key);
1132
1127
  refreshAll = false;
1133
1128
  const requested = subscribed.filter(
1134
1129
  (key) => all || dirty.has(key) || !Object.hasOwn(previous?.result ?? {}, key)
1135
1130
  );
1131
+ for (const key of requested) {
1132
+ refreshedKeys.add(key);
1133
+ dirtyKeys.delete(key);
1134
+ }
1136
1135
  readingKeys = new Set(requested);
1137
1136
  const started = tick();
1138
1137
  try {
@@ -1149,7 +1148,7 @@ function createTaggedKeyedQueryOwner(options) {
1149
1148
  }
1150
1149
  )
1151
1150
  );
1152
- const retained = (key) => !all && !dirty.has(key) && !readingKeys.has(key);
1151
+ const retained = (key) => !readingKeys.has(key);
1153
1152
  for (const key of requested) startedAt.set(key, started);
1154
1153
  previous = {
1155
1154
  result: Object.fromEntries([
@@ -1196,8 +1195,8 @@ function createTaggedKeyedQueryOwner(options) {
1196
1195
  keys.set(key, (keys.get(key) ?? 0) + 1);
1197
1196
  }
1198
1197
  const cached = getTaggedReadData(client, queryKey);
1199
- const missing = requested.filter(
1200
- (key) => !Object.hasOwn(cached?.result ?? {}, key)
1198
+ const pending = requested.filter(
1199
+ (key) => dirtyKeys.has(key) || !Object.hasOwn(cached?.result ?? {}, key)
1201
1200
  );
1202
1201
  if (!stop) missingOnly = cached === void 0;
1203
1202
  listeners.add(listener);
@@ -1206,9 +1205,9 @@ function createTaggedKeyedQueryOwner(options) {
1206
1205
  for (const notify of listeners) notify();
1207
1206
  });
1208
1207
  }
1209
- if (added && missing.length > 0) {
1208
+ if (added && pending.length > 0) {
1210
1209
  if (observer.getCurrentResult().isFetching) {
1211
- if (readingKeys.size > 0 && missing.some((key) => !readingKeys.has(key)))
1210
+ if (readingKeys.size > 0 && pending.some((key) => !readingKeys.has(key)))
1212
1211
  restartTaggedRead(observer.getCurrentQuery());
1213
1212
  } else {
1214
1213
  missingOnly = true;
@@ -1504,110 +1503,11 @@ var projectExecutionDefaultsSchema = z2.object({
1504
1503
  permissionMode: permissionModeSchema
1505
1504
  });
1506
1505
 
1507
- // ../domain/src/git-checkout.ts
1508
- import { z as z3 } from "zod";
1509
- var gitBranchForbiddenCharacterPattern = /[\u0000-\u001f\u007f\\:~^?*\[]/u;
1510
- var gitBranchWhitespacePattern = /[ \t]/u;
1511
- var gitReservedBranchNames = /* @__PURE__ */ new Set([
1512
- "AUTO_MERGE",
1513
- "BISECT_HEAD",
1514
- "CHERRY_PICK_HEAD",
1515
- "FETCH_HEAD",
1516
- "HEAD",
1517
- "MERGE_HEAD",
1518
- "ORIG_HEAD",
1519
- "REVERT_HEAD"
1520
- ]);
1521
- function isValidGitBranchName(name) {
1522
- const components = name.split("/");
1523
- return name.length > 0 && name.trim().length > 0 && !name.startsWith("-") && !name.startsWith("/") && name !== "@" && !gitReservedBranchNames.has(name) && !gitBranchForbiddenCharacterPattern.test(name) && !gitBranchWhitespacePattern.test(name) && !name.includes("..") && !name.includes("@{") && !name.includes("//") && !name.endsWith("/") && !name.endsWith(".") && components.every(
1524
- (component) => component.length > 0 && !component.startsWith(".") && !component.endsWith(".lock")
1525
- );
1526
- }
1527
- var gitBranchNameSchema = z3.string().refine(isValidGitBranchName, { message: "Invalid git branch name" });
1528
- var gitBranchSelectionSchema = z3.discriminatedUnion("kind", [
1529
- z3.object({ kind: z3.literal("named"), name: gitBranchNameSchema }),
1530
- z3.object({ kind: z3.literal("default") })
1531
- ]);
1532
- var gitCheckoutRefSchema = z3.discriminatedUnion("kind", [
1533
- z3.object({
1534
- kind: z3.literal("branch"),
1535
- branchName: z3.string().min(1),
1536
- headSha: z3.string().min(1).nullable()
1537
- }),
1538
- z3.object({
1539
- kind: z3.literal("detached"),
1540
- headSha: z3.string().min(1).nullable()
1541
- }),
1542
- z3.object({
1543
- kind: z3.literal("unborn"),
1544
- branchName: z3.string().min(1).nullable()
1545
- }),
1546
- z3.object({
1547
- kind: z3.literal("unknown"),
1548
- reason: z3.string().min(1)
1549
- })
1550
- ]);
1551
- var workspaceGitOperationSchema = z3.discriminatedUnion("kind", [
1552
- z3.object({ kind: z3.literal("none") }),
1553
- z3.object({
1554
- kind: z3.literal("merge"),
1555
- hasConflicts: z3.boolean()
1556
- }),
1557
- z3.object({
1558
- kind: z3.literal("rebase"),
1559
- hasConflicts: z3.boolean()
1560
- }),
1561
- z3.object({
1562
- kind: z3.literal("cherry-pick"),
1563
- hasConflicts: z3.boolean()
1564
- }),
1565
- z3.object({
1566
- kind: z3.literal("revert"),
1567
- hasConflicts: z3.boolean()
1568
- }),
1569
- z3.object({
1570
- kind: z3.literal("unknown"),
1571
- reason: z3.string().min(1),
1572
- hasConflicts: z3.boolean()
1573
- })
1574
- ]);
1575
- var gitBranchRefClassificationSchema = z3.object({
1576
- name: z3.string().min(1),
1577
- kind: z3.enum(["local", "remote", "missing"])
1578
- });
1579
- var defaultBranchRelationSchema = z3.enum([
1580
- "equal",
1581
- "local-behind",
1582
- "local-ahead",
1583
- "diverged",
1584
- "unknown"
1585
- ]);
1586
- var gitSourceInspectionSchema = z3.object({
1587
- checkout: gitCheckoutRefSchema,
1588
- defaultBranch: z3.string().min(1).nullable(),
1589
- isWorktree: z3.boolean(),
1590
- defaultBranchRelation: defaultBranchRelationSchema.nullable(),
1591
- hasUncommittedChanges: z3.boolean(),
1592
- operation: workspaceGitOperationSchema,
1593
- originDefaultBranch: z3.string().min(1).nullable()
1594
- });
1595
- var gitBranchOptionsSchema = z3.object({
1596
- branches: z3.array(z3.string()),
1597
- branchesTruncated: z3.boolean(),
1598
- remoteBranches: z3.array(z3.string()),
1599
- remoteBranchesTruncated: z3.boolean(),
1600
- selectedBranch: gitBranchRefClassificationSchema.nullable()
1601
- });
1602
- var projectSourceCheckoutSchema = gitSourceInspectionSchema.extend(
1603
- gitBranchOptionsSchema.shape
1604
- );
1605
-
1606
1506
  // ../domain/src/change-kinds.ts
1607
- import { z as z18 } from "zod";
1507
+ import { z as z17 } from "zod";
1608
1508
 
1609
1509
  // ../domain/src/thread-event-types.ts
1610
- import { z as z4 } from "zod";
1510
+ import { z as z3 } from "zod";
1611
1511
  var systemEventTypeValues = [
1612
1512
  "client/thread/start",
1613
1513
  "client/turn/requested",
@@ -1666,30 +1566,30 @@ var threadEventTypeValues = [
1666
1566
  ...systemEventTypeValues
1667
1567
  ];
1668
1568
  var threadEventTypeSet = new Set(threadEventTypeValues);
1669
- var threadEventTypeSchema = z4.string().refine(
1569
+ var threadEventTypeSchema = z3.string().refine(
1670
1570
  (value) => threadEventTypeSet.has(value),
1671
1571
  "Invalid thread event type"
1672
1572
  );
1673
1573
 
1674
1574
  // ../domain/src/thread.ts
1675
- import { z as z17 } from "zod";
1575
+ import { z as z16 } from "zod";
1676
1576
 
1677
1577
  // ../domain/src/thread-create-origin.ts
1678
- import { z as z5 } from "zod";
1578
+ import { z as z4 } from "zod";
1679
1579
  var threadCreateOriginValues = ["app", "cli", "sdk", "plugin"];
1680
- var threadCreateOriginSchema = z5.enum(threadCreateOriginValues);
1580
+ var threadCreateOriginSchema = z4.enum(threadCreateOriginValues);
1681
1581
 
1682
1582
  // ../domain/src/environment.ts
1683
- import { z as z6 } from "zod";
1684
- var environmentMachineSelectionSchema = z6.discriminatedUnion("type", [
1685
- z6.object({ type: z6.literal("existing"), hostId: z6.string().min(1) }),
1686
- z6.object({
1687
- type: z6.literal("new"),
1688
- machineProviderId: z6.string().min(1),
1583
+ import { z as z5 } from "zod";
1584
+ var environmentMachineSelectionSchema = z5.discriminatedUnion("type", [
1585
+ z5.object({ type: z5.literal("existing"), hostId: z5.string().min(1) }),
1586
+ z5.object({
1587
+ type: z5.literal("new"),
1588
+ machineProviderId: z5.string().min(1),
1689
1589
  inputs: jsonValueSchema.nullable()
1690
1590
  })
1691
1591
  ]);
1692
- var environmentProviderSelectionSchema = z6.object({
1592
+ var environmentProviderSelectionSchema = z5.object({
1693
1593
  machine: environmentMachineSelectionSchema,
1694
1594
  inputs: jsonValueSchema.nullable()
1695
1595
  });
@@ -1700,14 +1600,14 @@ var environmentStatusValues = [
1700
1600
  "error",
1701
1601
  "destroyed"
1702
1602
  ];
1703
- var environmentStatusSchema = z6.enum(environmentStatusValues);
1603
+ var environmentStatusSchema = z5.enum(environmentStatusValues);
1704
1604
  var environmentHostLifecycleValues = [
1705
1605
  "active",
1706
1606
  "removing",
1707
1607
  "cleanup-failed",
1708
1608
  "removed"
1709
1609
  ];
1710
- var environmentHostLifecycleSchema = z6.enum(
1610
+ var environmentHostLifecycleSchema = z5.enum(
1711
1611
  environmentHostLifecycleValues
1712
1612
  );
1713
1613
  var WORKSPACE_PROVISION_TYPES = [
@@ -1715,68 +1615,68 @@ var WORKSPACE_PROVISION_TYPES = [
1715
1615
  "managed-worktree",
1716
1616
  "personal"
1717
1617
  ];
1718
- var workspaceProvisionTypeSchema = z6.enum(WORKSPACE_PROVISION_TYPES);
1618
+ var workspaceProvisionTypeSchema = z5.enum(WORKSPACE_PROVISION_TYPES);
1719
1619
  var environmentWorkspaceDisplayKindValues = [
1720
1620
  "managed-worktree",
1721
1621
  "unmanaged-worktree",
1722
1622
  "other"
1723
1623
  ];
1724
- var environmentWorkspaceDisplayKindSchema = z6.enum(
1624
+ var environmentWorkspaceDisplayKindSchema = z5.enum(
1725
1625
  environmentWorkspaceDisplayKindValues
1726
1626
  );
1727
- var discoveredWorkspacePropertiesSchema = z6.object({
1728
- path: z6.string().min(1),
1729
- isGitRepo: z6.boolean(),
1730
- isWorktree: z6.boolean(),
1731
- branchName: z6.string().nullable(),
1732
- defaultBranch: z6.string().nullable()
1627
+ var discoveredWorkspacePropertiesSchema = z5.object({
1628
+ path: z5.string().min(1),
1629
+ isGitRepo: z5.boolean(),
1630
+ isWorktree: z5.boolean(),
1631
+ branchName: z5.string().nullable(),
1632
+ defaultBranch: z5.string().nullable()
1733
1633
  });
1734
- var environmentLifecycleSchema = z6.object({
1735
- phase: z6.enum(["active", "retiring", "teardown", "destroyed"]),
1736
- retireAt: z6.number().nullable(),
1737
- teardown: z6.object({
1738
- status: z6.enum(["running", "failed", "removed"]),
1739
- attempt: z6.number().int().nonnegative(),
1740
- message: z6.string().optional()
1634
+ var environmentLifecycleSchema = z5.object({
1635
+ phase: z5.enum(["active", "retiring", "teardown", "destroyed"]),
1636
+ retireAt: z5.number().nullable(),
1637
+ teardown: z5.object({
1638
+ status: z5.enum(["running", "failed", "removed"]),
1639
+ attempt: z5.number().int().nonnegative(),
1640
+ message: z5.string().optional()
1741
1641
  }).nullable()
1742
1642
  });
1743
- var environmentSchema = z6.object({
1744
- id: z6.string(),
1745
- name: z6.string().nullable(),
1746
- projectId: z6.string(),
1747
- hostId: z6.string(),
1748
- path: z6.string().nullable(),
1749
- isGitRepo: z6.boolean(),
1750
- isWorktree: z6.boolean(),
1751
- branchName: z6.string().nullable(),
1752
- baseBranch: z6.string().nullable(),
1753
- defaultBranch: z6.string().nullable(),
1754
- mergeBaseBranch: z6.string().nullable(),
1643
+ var environmentSchema = z5.object({
1644
+ id: z5.string(),
1645
+ name: z5.string().nullable(),
1646
+ projectId: z5.string(),
1647
+ hostId: z5.string(),
1648
+ path: z5.string().nullable(),
1649
+ isGitRepo: z5.boolean(),
1650
+ isWorktree: z5.boolean(),
1651
+ branchName: z5.string().nullable(),
1652
+ baseBranch: z5.string().nullable(),
1653
+ defaultBranch: z5.string().nullable(),
1654
+ mergeBaseBranch: z5.string().nullable(),
1755
1655
  status: environmentStatusSchema,
1756
- environmentProviderId: z6.string().nullable(),
1656
+ environmentProviderId: z5.string().nullable(),
1757
1657
  lifecycle: environmentLifecycleSchema,
1758
1658
  hostLifecycle: environmentHostLifecycleSchema,
1759
1659
  environmentProviderSelection: environmentProviderSelectionSchema.nullable(),
1760
- environmentProviderInstanceKey: z6.string().nullable(),
1761
- managed: z6.boolean(),
1660
+ environmentProviderInstanceKey: z5.string().nullable(),
1661
+ managed: z5.boolean(),
1762
1662
  workspaceProvisionType: workspaceProvisionTypeSchema.nullable(),
1763
- createdAt: z6.number(),
1764
- updatedAt: z6.number()
1663
+ createdAt: z5.number(),
1664
+ updatedAt: z5.number()
1765
1665
  });
1766
1666
 
1767
1667
  // ../domain/src/queued-message.ts
1768
- import { z as z10 } from "zod";
1668
+ import { z as z9 } from "zod";
1769
1669
 
1770
1670
  // ../domain/src/plugin-id.ts
1771
- import { z as z7 } from "zod";
1772
- var pluginIdSchema = z7.string().regex(/^[a-z0-9][a-z0-9-]*$/u);
1671
+ import { z as z6 } from "zod";
1672
+ var pluginIdSchema = z6.string().regex(/^[a-z0-9][a-z0-9-]*$/u);
1773
1673
 
1774
1674
  // ../domain/src/protocol-ids.ts
1775
- import { z as z8 } from "zod";
1776
- var clientTurnRequestIdSchema = z8.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
1675
+ import { z as z7 } from "zod";
1676
+ var clientTurnRequestIdSchema = z7.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
1777
1677
 
1778
1678
  // ../domain/src/system-message.ts
1779
- import { z as z9 } from "zod";
1679
+ import { z as z8 } from "zod";
1780
1680
  var systemMessageKindValues = [
1781
1681
  "ownership-assigned",
1782
1682
  "ownership-removed",
@@ -1789,41 +1689,41 @@ var systemMessageKindValues = [
1789
1689
  "environment-directory-updated",
1790
1690
  "unlabeled"
1791
1691
  ];
1792
- var systemMessageKindSchema = z9.enum(systemMessageKindValues);
1793
- var systemThreadInterruptedReasonSchema = z9.enum([
1692
+ var systemMessageKindSchema = z8.enum(systemMessageKindValues);
1693
+ var systemThreadInterruptedReasonSchema = z8.enum([
1794
1694
  "manual-stop",
1795
1695
  "host-daemon-restarted",
1796
1696
  "host-removed",
1797
1697
  "provider-turn-idle"
1798
1698
  ]);
1799
- var childThreadOutcomeSchema = z9.object({
1800
- threadId: z9.string(),
1801
- status: z9.enum(["completed", "failed", "interrupted"]),
1802
- interruption: z9.object({
1699
+ var childThreadOutcomeSchema = z8.object({
1700
+ threadId: z8.string(),
1701
+ status: z8.enum(["completed", "failed", "interrupted"]),
1702
+ interruption: z8.object({
1803
1703
  reason: systemThreadInterruptedReasonSchema,
1804
- cause: z9.literal("host-connection-lost").optional()
1704
+ cause: z8.literal("host-connection-lost").optional()
1805
1705
  }).optional()
1806
1706
  });
1807
- var systemMessageSubjectSchema = z9.discriminatedUnion("kind", [
1808
- z9.object({
1809
- kind: z9.literal("thread"),
1810
- threadId: z9.string(),
1811
- threadName: z9.string(),
1812
- outcomes: z9.array(childThreadOutcomeSchema).optional()
1707
+ var systemMessageSubjectSchema = z8.discriminatedUnion("kind", [
1708
+ z8.object({
1709
+ kind: z8.literal("thread"),
1710
+ threadId: z8.string(),
1711
+ threadName: z8.string(),
1712
+ outcomes: z8.array(childThreadOutcomeSchema).optional()
1813
1713
  }),
1814
- z9.object({
1815
- kind: z9.literal("thread-batch"),
1816
- count: z9.number(),
1817
- outcomes: z9.array(childThreadOutcomeSchema).optional()
1714
+ z8.object({
1715
+ kind: z8.literal("thread-batch"),
1716
+ count: z8.number(),
1717
+ outcomes: z8.array(childThreadOutcomeSchema).optional()
1818
1718
  }),
1819
- z9.object({
1820
- kind: z9.literal("tool-call"),
1821
- toolName: z9.string(),
1822
- suppress: z9.boolean()
1719
+ z8.object({
1720
+ kind: z8.literal("tool-call"),
1721
+ toolName: z8.string(),
1722
+ suppress: z8.boolean()
1823
1723
  }),
1824
- z9.object({
1825
- kind: z9.literal("directory"),
1826
- path: z9.string()
1724
+ z8.object({
1725
+ kind: z8.literal("directory"),
1726
+ path: z8.string()
1827
1727
  })
1828
1728
  ]);
1829
1729
 
@@ -1838,44 +1738,44 @@ var queuedMessageWaitingOnKindValues = [
1838
1738
  "interaction",
1839
1739
  "plugin"
1840
1740
  ];
1841
- var queuedMessageWaitingOnKindSchema = z10.enum(
1741
+ var queuedMessageWaitingOnKindSchema = z9.enum(
1842
1742
  queuedMessageWaitingOnKindValues
1843
1743
  );
1844
- var queuedMessageWaitHostNameSchema = z10.string().min(1).max(200);
1744
+ var queuedMessageWaitHostNameSchema = z9.string().min(1).max(200);
1845
1745
  var QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH = 200;
1846
- var queuedMessageWaitReasonSchema = z10.string().min(1).max(QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH);
1847
- var queuedMessageWaitingOnSchema = z10.discriminatedUnion("kind", [
1848
- z10.object({ kind: z10.literal("time") }),
1849
- z10.object({ kind: z10.literal("thread-busy") }),
1850
- z10.object({ kind: z10.literal("stopping") }),
1851
- z10.object({ kind: z10.literal("turn-starting") }),
1852
- z10.object({ kind: z10.literal("provisioning") }),
1853
- z10.object({
1854
- kind: z10.literal("host-offline"),
1746
+ var queuedMessageWaitReasonSchema = z9.string().min(1).max(QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH);
1747
+ var queuedMessageWaitingOnSchema = z9.discriminatedUnion("kind", [
1748
+ z9.object({ kind: z9.literal("time") }),
1749
+ z9.object({ kind: z9.literal("thread-busy") }),
1750
+ z9.object({ kind: z9.literal("stopping") }),
1751
+ z9.object({ kind: z9.literal("turn-starting") }),
1752
+ z9.object({ kind: z9.literal("provisioning") }),
1753
+ z9.object({
1754
+ kind: z9.literal("host-offline"),
1855
1755
  hostName: queuedMessageWaitHostNameSchema
1856
1756
  }),
1857
- z10.object({ kind: z10.literal("interaction") }),
1858
- z10.object({
1859
- kind: z10.literal("plugin"),
1757
+ z9.object({ kind: z9.literal("interaction") }),
1758
+ z9.object({
1759
+ kind: z9.literal("plugin"),
1860
1760
  pluginId: pluginIdSchema,
1861
1761
  reason: queuedMessageWaitReasonSchema
1862
1762
  })
1863
1763
  ]);
1864
1764
  var QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH = 200;
1865
- var queuedMessageFailureReasonSchema = z10.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
1765
+ var queuedMessageFailureReasonSchema = z9.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
1866
1766
  var QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX = "plugin:";
1867
- var queuedMessageWaitHolderSchema = z10.templateLiteral([
1767
+ var queuedMessageWaitHolderSchema = z9.templateLiteral([
1868
1768
  QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX,
1869
1769
  pluginIdSchema
1870
1770
  ]);
1871
1771
  var queuedMessagePayloadKindValues = ["inline", "retry"];
1872
- var queuedMessagePayloadKindSchema = z10.enum(
1772
+ var queuedMessagePayloadKindSchema = z9.enum(
1873
1773
  queuedMessagePayloadKindValues
1874
1774
  );
1875
- var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1876
- z10.object({ kind: z10.literal("inline") }),
1877
- z10.object({
1878
- kind: z10.literal("retry"),
1775
+ var queuedMessagePayloadSchema = z9.discriminatedUnion("kind", [
1776
+ z9.object({ kind: z9.literal("inline") }),
1777
+ z9.object({
1778
+ kind: z9.literal("retry"),
1879
1779
  /**
1880
1780
  * The ORIGINAL request, not the attempt that just failed. Retrying a retry
1881
1781
  * re-submits the same original blocks, so this id is carried forward
@@ -1883,7 +1783,7 @@ var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1883
1783
  */
1884
1784
  retryOfTurnRequestId: clientTurnRequestIdSchema,
1885
1785
  /** Which attempt this row will dispatch: 2 is the first retry. */
1886
- attempt: z10.number().int().min(2),
1786
+ attempt: z9.number().int().min(2),
1887
1787
  /**
1888
1788
  * Why this turn is being retried, in the retrier's words ("Rate limited"),
1889
1789
  * as the row's card and `bb thread queue list` render it.
@@ -1896,13 +1796,13 @@ var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1896
1796
  reason: queuedMessageWaitReasonSchema
1897
1797
  })
1898
1798
  ]);
1899
- var queuedMessageSystemNoticeSchema = z10.object({
1799
+ var queuedMessageSystemNoticeSchema = z9.object({
1900
1800
  kind: systemMessageKindSchema,
1901
1801
  subject: systemMessageSubjectSchema.nullable()
1902
1802
  });
1903
1803
 
1904
1804
  // ../domain/src/queued-message-lifecycle.ts
1905
- import { z as z11 } from "zod";
1805
+ import { z as z10 } from "zod";
1906
1806
  var queuedMessageStateValues = [
1907
1807
  "queued",
1908
1808
  "scheduled",
@@ -1911,10 +1811,10 @@ var queuedMessageStateValues = [
1911
1811
  "failed_exhausted",
1912
1812
  "claimed"
1913
1813
  ];
1914
- var queuedMessageStateSchema = z11.enum(queuedMessageStateValues);
1814
+ var queuedMessageStateSchema = z10.enum(queuedMessageStateValues);
1915
1815
 
1916
1816
  // ../domain/src/thread-status.ts
1917
- import { z as z12 } from "zod";
1817
+ import { z as z11 } from "zod";
1918
1818
  var threadStatusValues = [
1919
1819
  "pending",
1920
1820
  "idle",
@@ -1923,136 +1823,75 @@ var threadStatusValues = [
1923
1823
  "stopping",
1924
1824
  "error"
1925
1825
  ];
1926
- var threadStatusSchema = z12.enum(threadStatusValues);
1826
+ var threadStatusSchema = z11.enum(threadStatusValues);
1927
1827
 
1928
1828
  // ../domain/src/thread-origin-kind.ts
1929
- import { z as z13 } from "zod";
1829
+ import { z as z12 } from "zod";
1930
1830
  var threadOriginKindValues = ["fork"];
1931
- var threadOriginKindSchema = z13.enum(threadOriginKindValues);
1831
+ var threadOriginKindSchema = z12.enum(threadOriginKindValues);
1932
1832
 
1933
1833
  // ../domain/src/thread-parent-notifications.ts
1934
- import { z as z14 } from "zod";
1834
+ import { z as z13 } from "zod";
1935
1835
  var threadParentNotificationsValues = [
1936
1836
  "auto",
1937
1837
  "stuck",
1938
1838
  "off"
1939
1839
  ];
1940
- var threadParentNotificationsSchema = z14.enum(
1840
+ var threadParentNotificationsSchema = z13.enum(
1941
1841
  threadParentNotificationsValues
1942
1842
  );
1943
1843
 
1944
1844
  // ../domain/src/thread-visibility.ts
1945
- import { z as z15 } from "zod";
1845
+ import { z as z14 } from "zod";
1946
1846
  var threadVisibilityValues = ["visible", "hidden"];
1947
- var threadVisibilitySchema = z15.enum(threadVisibilityValues);
1847
+ var threadVisibilitySchema = z14.enum(threadVisibilityValues);
1948
1848
 
1949
1849
  // ../domain/src/thread-runtime-state.ts
1950
- import { z as z16 } from "zod";
1850
+ import { z as z15 } from "zod";
1951
1851
  var threadRuntimeDisplayStatusValues = [
1952
1852
  ...threadStatusValues,
1953
1853
  "provisioning",
1954
1854
  "waiting-for-host"
1955
1855
  ];
1956
- var threadRuntimeDisplayStatusSchema = z16.enum(
1856
+ var threadRuntimeDisplayStatusSchema = z15.enum(
1957
1857
  threadRuntimeDisplayStatusValues
1958
1858
  );
1959
- var threadRuntimeStateSchema = z16.object({
1859
+ var threadRuntimeStateSchema = z15.object({
1960
1860
  displayStatus: threadRuntimeDisplayStatusSchema
1961
1861
  });
1962
- var threadActivityStateSchema = z16.object({
1963
- activeWorkflowCount: z16.number().int().nonnegative(),
1964
- activeBackgroundAgentCount: z16.number().int().nonnegative(),
1965
- activeBackgroundCommandCount: z16.number().int().nonnegative(),
1966
- activePlanModeCount: z16.number().int().nonnegative(),
1967
- activeGoalCount: z16.number().int().nonnegative()
1862
+ var threadActivityStateSchema = z15.object({
1863
+ activeWorkflowCount: z15.number().int().nonnegative(),
1864
+ activeBackgroundAgentCount: z15.number().int().nonnegative(),
1865
+ activeBackgroundCommandCount: z15.number().int().nonnegative(),
1866
+ activePlanModeCount: z15.number().int().nonnegative(),
1867
+ activeGoalCount: z15.number().int().nonnegative()
1968
1868
  });
1969
1869
 
1970
1870
  // ../domain/src/thread.ts
1971
- var workspaceStateValues = [
1972
- "clean",
1973
- "untracked",
1974
- "dirty_uncommitted",
1975
- "committed_unmerged",
1976
- "dirty_and_committed_unmerged"
1977
- ];
1978
- var workspaceStateSchema = z17.enum(workspaceStateValues);
1979
- var workspaceFileStatusKindSchema = z17.enum([
1980
- "M",
1981
- "A",
1982
- "D",
1983
- "R",
1984
- "C",
1985
- "U",
1986
- "??",
1987
- "?"
1988
- ]);
1989
- var workspaceFileStatusSchema = z17.object({
1990
- path: z17.string(),
1991
- status: workspaceFileStatusKindSchema,
1992
- insertions: z17.number().nullable(),
1993
- deletions: z17.number().nullable()
1994
- });
1995
- var workspaceCommitSummarySchema = z17.object({
1996
- sha: z17.string(),
1997
- shortSha: z17.string(),
1998
- subject: z17.string(),
1999
- authorName: z17.string(),
2000
- authoredAt: z17.number()
2001
- });
2002
- var workspaceChangeStatsSchema = z17.object({
2003
- insertions: z17.number(),
2004
- deletions: z17.number(),
2005
- lineStatsComplete: z17.boolean(),
2006
- fileCount: z17.number().int().nonnegative(),
2007
- files: z17.array(workspaceFileStatusSchema)
2008
- });
2009
- var workspaceWorkingTreeSchema = workspaceChangeStatsSchema.extend({
2010
- hasUncommittedChanges: z17.boolean(),
2011
- state: workspaceStateSchema
2012
- });
2013
- var workspaceBranchSchema = z17.object({
2014
- currentBranch: z17.string().nullable(),
2015
- defaultBranch: z17.string()
2016
- });
2017
- var workspaceMergeBaseSchema = workspaceChangeStatsSchema.extend({
2018
- mergeBaseBranch: z17.string(),
2019
- baseRef: z17.string().nullable(),
2020
- aheadCount: z17.number(),
2021
- behindCount: z17.number(),
2022
- squashMergeCheckComplete: z17.boolean(),
2023
- hasCommittedUnmergedChanges: z17.boolean(),
2024
- commits: z17.array(workspaceCommitSummarySchema)
2025
- });
2026
- var workspaceStatusSchema = z17.object({
2027
- workingTree: workspaceWorkingTreeSchema,
2028
- checkout: gitCheckoutRefSchema,
2029
- branch: workspaceBranchSchema,
2030
- mergeBase: workspaceMergeBaseSchema.nullable()
2031
- });
2032
- var threadQueuedMessageSchema = z17.object({
2033
- id: z17.string(),
1871
+ var threadQueuedMessageSchema = z16.object({
1872
+ id: z16.string(),
2034
1873
  origin: threadCreateOriginSchema.nullable(),
2035
- originPluginId: z17.string().nullable(),
2036
- initiator: z17.enum(["user", "agent", "system"]),
2037
- senderThreadId: z17.string().nullable(),
1874
+ originPluginId: z16.string().nullable(),
1875
+ initiator: z16.enum(["user", "agent", "system"]),
1876
+ senderThreadId: z16.string().nullable(),
2038
1877
  /**
2039
1878
  * The thread this row is waiting on. Redundant on the thread-scoped list
2040
1879
  * route that first served this DTO, and load-bearing everywhere else it is
2041
1880
  * now served: a `queue.*` plugin event and a cross-thread wait-holder query
2042
1881
  * both hand out rows with no surrounding thread to read it from.
2043
1882
  */
2044
- threadId: z17.string(),
2045
- content: z17.array(promptInputSchema).min(1),
2046
- model: z17.string().min(1),
1883
+ threadId: z16.string(),
1884
+ content: z16.array(promptInputSchema).min(1),
1885
+ model: z16.string().min(1),
2047
1886
  reasoningLevel: reasoningLevelSchema,
2048
1887
  permissionMode: permissionModeSchema,
2049
1888
  serviceTier: serviceTierSchema,
2050
- groupWithNext: z17.boolean(),
1889
+ groupWithNext: z16.boolean(),
2051
1890
  /**
2052
1891
  * Epoch ms this row is scheduled to attempt dispatch, or null when it is
2053
1892
  * eligible as soon as its other waits clear.
2054
1893
  */
2055
- sendAt: z17.number().int().nonnegative().nullable(),
1894
+ sendAt: z16.number().int().nonnegative().nullable(),
2056
1895
  state: queuedMessageStateSchema,
2057
1896
  /**
2058
1897
  * Why this row is queued, or null for a `queued` row that is simply next in
@@ -2080,50 +1919,50 @@ var threadQueuedMessageSchema = z17.object({
2080
1919
  * not something a client should reason about. The server folds both into
2081
1920
  * this one answer.
2082
1921
  */
2083
- editable: z17.boolean(),
2084
- createdAt: z17.number(),
2085
- updatedAt: z17.number()
1922
+ editable: z16.boolean(),
1923
+ createdAt: z16.number(),
1924
+ updatedAt: z16.number()
2086
1925
  });
2087
- var threadSchema = z17.object({
2088
- id: z17.string(),
2089
- projectId: z17.string(),
2090
- environmentId: z17.string().nullable(),
2091
- providerId: z17.string(),
2092
- title: z17.string().nullable(),
2093
- titleFallback: z17.string().nullable(),
2094
- sectionId: z17.string().nullable(),
1926
+ var threadSchema = z16.object({
1927
+ id: z16.string(),
1928
+ projectId: z16.string(),
1929
+ environmentId: z16.string().nullable(),
1930
+ providerId: z16.string(),
1931
+ title: z16.string().nullable(),
1932
+ titleFallback: z16.string().nullable(),
1933
+ sectionId: z16.string().nullable(),
2095
1934
  status: threadStatusSchema,
2096
- parentThreadId: z17.string().nullable(),
2097
- lifecycleOwnerThreadId: z17.string().nullable(),
2098
- sourceThreadId: z17.string().nullable(),
1935
+ parentThreadId: z16.string().nullable(),
1936
+ lifecycleOwnerThreadId: z16.string().nullable(),
1937
+ sourceThreadId: z16.string().nullable(),
2099
1938
  originKind: threadOriginKindSchema.nullable(),
2100
- originPluginId: z17.string().nullable(),
1939
+ originPluginId: z16.string().nullable(),
2101
1940
  visibility: threadVisibilitySchema,
2102
1941
  parentNotifications: threadParentNotificationsSchema,
2103
- archivedAt: z17.number().nullable(),
2104
- pinnedAt: z17.number().nullable(),
2105
- deletedAt: z17.number().nullable(),
2106
- lastReadAt: z17.number().nullable(),
2107
- latestAttentionAt: z17.number(),
2108
- createdAt: z17.number(),
2109
- updatedAt: z17.number()
1942
+ archivedAt: z16.number().nullable(),
1943
+ pinnedAt: z16.number().nullable(),
1944
+ deletedAt: z16.number().nullable(),
1945
+ lastReadAt: z16.number().nullable(),
1946
+ latestAttentionAt: z16.number(),
1947
+ createdAt: z16.number(),
1948
+ updatedAt: z16.number()
2110
1949
  });
2111
1950
  var threadWithRuntimeSchema = threadSchema.extend({
2112
1951
  runtime: threadRuntimeStateSchema
2113
1952
  });
2114
1953
  var threadQueuedWorkValues = ["none", "waiting", "failed"];
2115
- var threadQueuedWorkSchema = z17.enum(threadQueuedWorkValues);
1954
+ var threadQueuedWorkSchema = z16.enum(threadQueuedWorkValues);
2116
1955
  var threadListEntrySchema = threadWithRuntimeSchema.extend({
2117
1956
  activity: threadActivityStateSchema,
2118
1957
  queuedWork: threadQueuedWorkSchema,
2119
- pinSortKey: z17.string().nullable(),
2120
- hasPendingInteraction: z17.boolean(),
2121
- environmentHostId: z17.string().nullable(),
2122
- environmentName: z17.string().nullable(),
2123
- environmentBranchName: z17.string().nullable(),
2124
- environmentPath: z17.string().nullable(),
2125
- environmentProviderId: z17.string().nullable(),
2126
- environmentIsWorktree: z17.boolean().nullable(),
1958
+ pinSortKey: z16.string().nullable(),
1959
+ hasPendingInteraction: z16.boolean(),
1960
+ environmentHostId: z16.string().nullable(),
1961
+ environmentName: z16.string().nullable(),
1962
+ environmentBranchName: z16.string().nullable(),
1963
+ environmentPath: z16.string().nullable(),
1964
+ environmentProviderId: z16.string().nullable(),
1965
+ environmentIsWorktree: z16.boolean().nullable(),
2127
1966
  environmentWorkspaceDisplayKind: environmentWorkspaceDisplayKindSchema
2128
1967
  });
2129
1968
 
@@ -2167,7 +2006,8 @@ var ENVIRONMENT_CHANGE_KINDS = [
2167
2006
  var HOST_CHANGE_KINDS = [
2168
2007
  "host-connected",
2169
2008
  "host-disconnected",
2170
- "provider-model-catalog-changed"
2009
+ "provider-model-catalog-changed",
2010
+ "provider-commands-changed"
2171
2011
  ];
2172
2012
  var SYSTEM_CHANGE_KINDS = [
2173
2013
  "config-changed",
@@ -2179,16 +2019,16 @@ var SYSTEM_CHANGE_KINDS = [
2179
2019
  "server-move-changed",
2180
2020
  "app-update-changed"
2181
2021
  ];
2182
- var threadChangeKindSchema = z18.enum(THREAD_CHANGE_KINDS);
2183
- var projectChangeKindSchema = z18.enum(PROJECT_CHANGE_KINDS);
2184
- var environmentChangeKindSchema = z18.enum(ENVIRONMENT_CHANGE_KINDS);
2185
- var hostChangeKindSchema = z18.enum(HOST_CHANGE_KINDS);
2186
- var systemChangeKindSchema = z18.enum(SYSTEM_CHANGE_KINDS);
2187
- var threadTimelineSubscriptionTargetSchema = z18.object({
2188
- kind: z18.literal("thread-timeline"),
2189
- threadId: z18.string().min(1),
2190
- segmentLimit: z18.number().int().positive().nullable(),
2191
- deferContent: z18.boolean()
2022
+ var threadChangeKindSchema = z17.enum(THREAD_CHANGE_KINDS);
2023
+ var projectChangeKindSchema = z17.enum(PROJECT_CHANGE_KINDS);
2024
+ var environmentChangeKindSchema = z17.enum(ENVIRONMENT_CHANGE_KINDS);
2025
+ var hostChangeKindSchema = z17.enum(HOST_CHANGE_KINDS);
2026
+ var systemChangeKindSchema = z17.enum(SYSTEM_CHANGE_KINDS);
2027
+ var threadTimelineSubscriptionTargetSchema = z17.object({
2028
+ kind: z17.literal("thread-timeline"),
2029
+ threadId: z17.string().min(1),
2030
+ segmentLimit: z17.number().int().positive().nullable(),
2031
+ deferContent: z17.boolean()
2192
2032
  }).strict();
2193
2033
  function canonicalPluginReadInput(value) {
2194
2034
  if (value === null || typeof value !== "object") return JSON.stringify(value);
@@ -2198,62 +2038,62 @@ function canonicalPluginReadInput(value) {
2198
2038
  (key) => `${JSON.stringify(key)}:${canonicalPluginReadInput(value[key])}`
2199
2039
  ).join(",")}}`;
2200
2040
  }
2201
- var pluginReadSubscriptionTargetSchema = z18.object({
2202
- kind: z18.literal("plugin-read"),
2203
- pluginId: z18.string().min(1),
2204
- method: z18.string().min(1),
2205
- read: z18.union([
2206
- z18.object({ input: jsonValueSchema }).strict(),
2207
- z18.object({ key: z18.string() }).strict()
2041
+ var pluginReadSubscriptionTargetSchema = z17.object({
2042
+ kind: z17.literal("plugin-read"),
2043
+ pluginId: z17.string().min(1),
2044
+ method: z17.string().min(1),
2045
+ read: z17.union([
2046
+ z17.object({ input: jsonValueSchema }).strict(),
2047
+ z17.object({ key: z17.string() }).strict()
2208
2048
  ]).refine(
2209
2049
  (read) => new TextEncoder().encode(canonicalPluginReadInput(read)).byteLength <= 16384,
2210
2050
  "Plugin read input exceeds 16 KiB"
2211
2051
  )
2212
2052
  }).strict();
2213
- var realtimeSubscriptionTargetSchema = z18.discriminatedUnion("kind", [
2053
+ var realtimeSubscriptionTargetSchema = z17.discriminatedUnion("kind", [
2214
2054
  pluginReadSubscriptionTargetSchema,
2215
- z18.object({ kind: z18.literal("plugin"), pluginId: z18.string().min(1) }).strict(),
2216
- z18.object({
2217
- kind: z18.literal("thread-detail"),
2218
- threadId: z18.string().min(1)
2055
+ z17.object({ kind: z17.literal("plugin"), pluginId: z17.string().min(1) }).strict(),
2056
+ z17.object({
2057
+ kind: z17.literal("thread-detail"),
2058
+ threadId: z17.string().min(1)
2219
2059
  }).strict(),
2220
2060
  threadTimelineSubscriptionTargetSchema,
2221
- z18.object({
2222
- kind: z18.literal("thread-list")
2061
+ z17.object({
2062
+ kind: z17.literal("thread-list")
2223
2063
  }).strict(),
2224
- z18.object({
2225
- kind: z18.literal("project-detail"),
2226
- projectId: z18.string().min(1)
2064
+ z17.object({
2065
+ kind: z17.literal("project-detail"),
2066
+ projectId: z17.string().min(1)
2227
2067
  }).strict(),
2228
- z18.object({
2229
- kind: z18.literal("project-list")
2068
+ z17.object({
2069
+ kind: z17.literal("project-list")
2230
2070
  }).strict(),
2231
- z18.object({
2232
- kind: z18.literal("environment-detail"),
2233
- environmentId: z18.string().min(1)
2071
+ z17.object({
2072
+ kind: z17.literal("environment-detail"),
2073
+ environmentId: z17.string().min(1)
2234
2074
  }).strict(),
2235
- z18.object({
2236
- kind: z18.literal("environment-list")
2075
+ z17.object({
2076
+ kind: z17.literal("environment-list")
2237
2077
  }).strict(),
2238
- z18.object({
2239
- kind: z18.literal("host-detail"),
2240
- hostId: z18.string().min(1)
2078
+ z17.object({
2079
+ kind: z17.literal("host-detail"),
2080
+ hostId: z17.string().min(1)
2241
2081
  }).strict(),
2242
- z18.object({
2243
- kind: z18.literal("host-list")
2082
+ z17.object({
2083
+ kind: z17.literal("host-list")
2244
2084
  }).strict(),
2245
- z18.object({
2246
- kind: z18.literal("system")
2085
+ z17.object({
2086
+ kind: z17.literal("system")
2247
2087
  }).strict()
2248
2088
  ]);
2249
2089
  function isValidSubscriptionTarget(value) {
2250
2090
  return realtimeSubscriptionTargetSchema.safeParse(value).success;
2251
2091
  }
2252
- var validSubscriptionTargetsSchema = z18.preprocess(
2092
+ var validSubscriptionTargetsSchema = z17.preprocess(
2253
2093
  (value) => Array.isArray(value) ? value.filter(isValidSubscriptionTarget) : value,
2254
- z18.array(realtimeSubscriptionTargetSchema)
2094
+ z17.array(realtimeSubscriptionTargetSchema)
2255
2095
  );
2256
- var validSubscriptionTargetSchema = z18.preprocess(
2096
+ var validSubscriptionTargetSchema = z17.preprocess(
2257
2097
  (value) => value === void 0 || isValidSubscriptionTarget(value) ? value : null,
2258
2098
  realtimeSubscriptionTargetSchema.nullable().optional()
2259
2099
  );
@@ -2262,84 +2102,88 @@ var subscriptionFields = {
2262
2102
  targets: validSubscriptionTargetsSchema.optional()
2263
2103
  };
2264
2104
  var hasSubscriptionTargets = (value) => value.target !== void 0 !== (value.targets !== void 0);
2265
- var subscribeMessageSchema = z18.object({ type: z18.literal("subscribe"), ...subscriptionFields }).refine(hasSubscriptionTargets);
2266
- var unsubscribeMessageSchema = z18.object({ type: z18.literal("unsubscribe"), ...subscriptionFields }).refine(hasSubscriptionTargets);
2267
- var pingMessageSchema = z18.object({
2268
- type: z18.literal("ping")
2105
+ var subscribeMessageSchema = z17.object({
2106
+ type: z17.literal("subscribe"),
2107
+ ...subscriptionFields,
2108
+ timelineTags: z17.record(z17.string(), z17.string().min(1).nullable()).optional()
2109
+ }).refine(hasSubscriptionTargets);
2110
+ var unsubscribeMessageSchema = z17.object({ type: z17.literal("unsubscribe"), ...subscriptionFields }).refine(hasSubscriptionTargets);
2111
+ var pingMessageSchema = z17.object({
2112
+ type: z17.literal("ping")
2269
2113
  });
2270
- var visibilityMessageSchema = z18.object({
2271
- type: z18.literal("visibility"),
2272
- visible: z18.boolean()
2114
+ var visibilityMessageSchema = z17.object({
2115
+ type: z17.literal("visibility"),
2116
+ visible: z17.boolean()
2273
2117
  });
2274
- var clientMessageSchema = z18.discriminatedUnion("type", [
2118
+ var clientMessageSchema = z17.discriminatedUnion("type", [
2275
2119
  subscribeMessageSchema,
2276
2120
  unsubscribeMessageSchema,
2277
2121
  pingMessageSchema,
2278
2122
  visibilityMessageSchema
2279
2123
  ]);
2280
- var pongMessageSchema = z18.object({
2281
- type: z18.literal("pong")
2124
+ var pongMessageSchema = z17.object({
2125
+ type: z17.literal("pong")
2282
2126
  }).strict();
2283
- var pongMessageLenientSchema = z18.object({
2284
- type: z18.literal("pong")
2127
+ var pongMessageLenientSchema = z17.object({
2128
+ type: z17.literal("pong")
2285
2129
  });
2286
- var threadStatusChangeMetadataSchema = z18.object({
2130
+ var threadStatusChangeMetadataSchema = z17.object({
2287
2131
  status: threadStatusSchema,
2288
2132
  runtime: threadRuntimeStateSchema,
2289
2133
  activity: threadActivityStateSchema,
2290
- latestAttentionAt: z18.number(),
2291
- updatedAt: z18.number()
2134
+ latestAttentionAt: z17.number(),
2135
+ updatedAt: z17.number()
2292
2136
  }).strict();
2293
- var threadChangeMetadataSchema = z18.object({
2294
- backgroundActivityChanged: z18.boolean().optional(),
2295
- eventTypes: z18.array(threadEventTypeSchema).readonly().optional(),
2296
- timelineSequence: z18.number().int().nonnegative().optional(),
2297
- hasPendingInteraction: z18.boolean().optional(),
2298
- projectId: z18.string().optional(),
2137
+ var threadChangeMetadataSchema = z17.object({
2138
+ backgroundActivityChanged: z17.boolean().optional(),
2139
+ eventTypes: z17.array(threadEventTypeSchema).readonly().optional(),
2140
+ timelineSequence: z17.number().int().nonnegative().optional(),
2141
+ hasPendingInteraction: z17.boolean().optional(),
2142
+ projectId: z17.string().optional(),
2299
2143
  statusChange: threadStatusChangeMetadataSchema.optional()
2300
2144
  }).strict();
2301
- var threadChangedMessageSchema = z18.object({
2302
- type: z18.literal("changed"),
2303
- entity: z18.literal("thread"),
2304
- id: z18.string().optional(),
2145
+ var threadChangedMessageSchema = z17.object({
2146
+ type: z17.literal("changed"),
2147
+ entity: z17.literal("thread"),
2148
+ id: z17.string().optional(),
2305
2149
  metadata: threadChangeMetadataSchema.optional(),
2306
- changes: z18.array(threadChangeKindSchema).readonly()
2150
+ changes: z17.array(threadChangeKindSchema).readonly()
2307
2151
  }).strict();
2308
- var projectChangedMessageSchema = z18.object({
2309
- type: z18.literal("changed"),
2310
- entity: z18.literal("project"),
2311
- id: z18.string().optional(),
2312
- changes: z18.array(projectChangeKindSchema).readonly()
2152
+ var projectChangedMessageSchema = z17.object({
2153
+ type: z17.literal("changed"),
2154
+ entity: z17.literal("project"),
2155
+ id: z17.string().optional(),
2156
+ changes: z17.array(projectChangeKindSchema).readonly()
2313
2157
  }).strict();
2314
- var environmentChangedMessageSchema = z18.object({
2315
- type: z18.literal("changed"),
2316
- entity: z18.literal("environment"),
2317
- id: z18.string().optional(),
2318
- changes: z18.array(environmentChangeKindSchema).readonly()
2158
+ var environmentChangedMessageSchema = z17.object({
2159
+ type: z17.literal("changed"),
2160
+ entity: z17.literal("environment"),
2161
+ id: z17.string().optional(),
2162
+ changes: z17.array(environmentChangeKindSchema).readonly()
2319
2163
  }).strict();
2320
- var hostChangedMessageSchema = z18.object({
2321
- type: z18.literal("changed"),
2322
- entity: z18.literal("host"),
2323
- id: z18.string().optional(),
2324
- changes: z18.array(hostChangeKindSchema).readonly()
2164
+ var hostChangedMessageSchema = z17.object({
2165
+ type: z17.literal("changed"),
2166
+ entity: z17.literal("host"),
2167
+ id: z17.string().optional(),
2168
+ changes: z17.array(hostChangeKindSchema).readonly()
2325
2169
  }).strict();
2326
- var systemChangedMessageSchema = z18.object({
2327
- type: z18.literal("changed"),
2328
- entity: z18.literal("system"),
2329
- changes: z18.array(systemChangeKindSchema).readonly()
2170
+ var systemChangedMessageSchema = z17.object({
2171
+ type: z17.literal("changed"),
2172
+ entity: z17.literal("system"),
2173
+ changes: z17.array(systemChangeKindSchema).readonly()
2330
2174
  }).strict();
2331
- var tagsChangedMessageSchema = z18.object({
2332
- type: z18.literal("changed"),
2333
- entity: z18.literal("tags"),
2334
- tags: z18.array(z18.string().min(1)).min(1)
2175
+ var tagsChangedMessageSchema = z17.object({
2176
+ type: z17.literal("changed"),
2177
+ entity: z17.literal("tags"),
2178
+ tags: z17.array(z17.string().min(1)).min(1)
2335
2179
  }).strict();
2336
- var pluginChangedMessageSchema = z18.object({
2337
- type: z18.literal("changed"),
2338
- entity: z18.literal("plugin"),
2339
- pluginId: z18.string().min(1),
2340
- tags: z18.array(z18.string().min(1)).min(1).nullable()
2180
+ var pluginChangedMessageSchema = z17.object({
2181
+ type: z17.literal("changed"),
2182
+ entity: z17.literal("plugin"),
2183
+ pluginId: z17.string().min(1),
2184
+ tags: z17.array(z17.string().min(1)).min(1).nullable()
2341
2185
  }).strict();
2342
- var changedMessageSchema = z18.discriminatedUnion("entity", [
2186
+ var changedMessageSchema = z17.discriminatedUnion("entity", [
2343
2187
  threadChangedMessageSchema,
2344
2188
  projectChangedMessageSchema,
2345
2189
  environmentChangedMessageSchema,
@@ -2350,56 +2194,56 @@ var changedMessageSchema = z18.discriminatedUnion("entity", [
2350
2194
  ]);
2351
2195
  function lenientKinds(kinds) {
2352
2196
  const known = new Set(kinds);
2353
- return z18.array(z18.string()).transform(
2197
+ return z17.array(z17.string()).transform(
2354
2198
  (values) => values.filter((value) => known.has(value))
2355
2199
  );
2356
2200
  }
2357
2201
  var knownThreadEventTypes = new Set(
2358
2202
  threadEventTypeValues
2359
2203
  );
2360
- var threadChangeMetadataLenientSchema = z18.object({
2361
- timelineSequence: z18.number().int().nonnegative().optional(),
2362
- backgroundActivityChanged: z18.boolean().optional(),
2363
- eventTypes: z18.array(z18.string()).transform(
2204
+ var threadChangeMetadataLenientSchema = z17.object({
2205
+ timelineSequence: z17.number().int().nonnegative().optional(),
2206
+ backgroundActivityChanged: z17.boolean().optional(),
2207
+ eventTypes: z17.array(z17.string()).transform(
2364
2208
  (values) => values.filter(
2365
2209
  (value) => knownThreadEventTypes.has(value)
2366
2210
  )
2367
2211
  ).optional(),
2368
- hasPendingInteraction: z18.boolean().optional(),
2369
- projectId: z18.string().optional(),
2212
+ hasPendingInteraction: z17.boolean().optional(),
2213
+ projectId: z17.string().optional(),
2370
2214
  statusChange: threadStatusChangeMetadataSchema.optional().catch(void 0)
2371
2215
  });
2372
- var threadChangedMessageLenientSchema = z18.object({
2373
- type: z18.literal("changed"),
2374
- entity: z18.literal("thread"),
2375
- id: z18.string().optional(),
2216
+ var threadChangedMessageLenientSchema = z17.object({
2217
+ type: z17.literal("changed"),
2218
+ entity: z17.literal("thread"),
2219
+ id: z17.string().optional(),
2376
2220
  metadata: threadChangeMetadataLenientSchema.optional(),
2377
2221
  changes: lenientKinds(THREAD_CHANGE_KINDS)
2378
2222
  });
2379
- var projectChangedMessageLenientSchema = z18.object({
2380
- type: z18.literal("changed"),
2381
- entity: z18.literal("project"),
2382
- id: z18.string().optional(),
2223
+ var projectChangedMessageLenientSchema = z17.object({
2224
+ type: z17.literal("changed"),
2225
+ entity: z17.literal("project"),
2226
+ id: z17.string().optional(),
2383
2227
  changes: lenientKinds(PROJECT_CHANGE_KINDS)
2384
2228
  });
2385
- var environmentChangedMessageLenientSchema = z18.object({
2386
- type: z18.literal("changed"),
2387
- entity: z18.literal("environment"),
2388
- id: z18.string().optional(),
2229
+ var environmentChangedMessageLenientSchema = z17.object({
2230
+ type: z17.literal("changed"),
2231
+ entity: z17.literal("environment"),
2232
+ id: z17.string().optional(),
2389
2233
  changes: lenientKinds(ENVIRONMENT_CHANGE_KINDS)
2390
2234
  });
2391
- var hostChangedMessageLenientSchema = z18.object({
2392
- type: z18.literal("changed"),
2393
- entity: z18.literal("host"),
2394
- id: z18.string().optional(),
2235
+ var hostChangedMessageLenientSchema = z17.object({
2236
+ type: z17.literal("changed"),
2237
+ entity: z17.literal("host"),
2238
+ id: z17.string().optional(),
2395
2239
  changes: lenientKinds(HOST_CHANGE_KINDS)
2396
2240
  });
2397
- var systemChangedMessageLenientSchema = z18.object({
2398
- type: z18.literal("changed"),
2399
- entity: z18.literal("system"),
2241
+ var systemChangedMessageLenientSchema = z17.object({
2242
+ type: z17.literal("changed"),
2243
+ entity: z17.literal("system"),
2400
2244
  changes: lenientKinds(SYSTEM_CHANGE_KINDS)
2401
2245
  });
2402
- var changedMessageLenientSchema = z18.discriminatedUnion("entity", [
2246
+ var changedMessageLenientSchema = z17.discriminatedUnion("entity", [
2403
2247
  threadChangedMessageLenientSchema,
2404
2248
  projectChangedMessageLenientSchema,
2405
2249
  environmentChangedMessageLenientSchema,
@@ -2410,22 +2254,22 @@ var changedMessageLenientSchema = z18.discriminatedUnion("entity", [
2410
2254
  ]);
2411
2255
 
2412
2256
  // src/internal/rpc-tags.ts
2413
- import { z as z19 } from "zod";
2414
- var rpcInvalidationTags = z19.array(z19.string().min(1)).min(1);
2257
+ import { z as z18 } from "zod";
2258
+ var rpcInvalidationTags = z18.array(z18.string().min(1)).min(1);
2415
2259
  function rpcResponseTags(declarations, input, output) {
2416
- const tags = z19.array(z19.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
2260
+ const tags = z18.array(z18.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
2417
2261
  const keyTags = {};
2418
2262
  if (declarations.keyTags && typeof output === "object" && output !== null && !Array.isArray(output)) {
2419
2263
  for (const [key, value] of Object.entries(output)) {
2420
- keyTags[key] = z19.array(z19.string().min(1)).parse(declarations.keyTags(key, value));
2264
+ keyTags[key] = z18.array(z18.string().min(1)).parse(declarations.keyTags(key, value));
2421
2265
  }
2422
2266
  }
2423
- const invalidated = z19.array(z19.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
2267
+ const invalidated = z18.array(z18.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
2424
2268
  return { tags, keyTags, invalidated };
2425
2269
  }
2426
2270
 
2427
2271
  // src/internal/rpc-query-host.ts
2428
- import { z as z20 } from "zod";
2272
+ import { z as z19 } from "zod";
2429
2273
  var rpcQueryKey = (pluginId, method, input) => [
2430
2274
  "plugin-rpc",
2431
2275
  pluginId,
@@ -2567,7 +2411,7 @@ function createRpcQueryHooks(useHost) {
2567
2411
  const enabled = options.enabled ?? true;
2568
2412
  const identity = JSON.stringify([...new Set(options.keys)].sort());
2569
2413
  const keys = useMemo2(
2570
- () => z20.array(z20.string()).parse(JSON.parse(identity)),
2414
+ () => z19.array(z19.string()).parse(JSON.parse(identity)),
2571
2415
  [identity]
2572
2416
  );
2573
2417
  let cache = owners.get(host.queryClient);
@@ -2593,7 +2437,7 @@ function createRpcQueryHooks(useHost) {
2593
2437
  );
2594
2438
  return {
2595
2439
  ...response,
2596
- result: z20.record(z20.string(), jsonValueSchema).parse(response.result)
2440
+ result: z19.record(z19.string(), jsonValueSchema).parse(response.result)
2597
2441
  };
2598
2442
  }
2599
2443
  });
@@ -2793,71 +2637,71 @@ function reconcileComposerMentions(currentText, nextText, mentions) {
2793
2637
  }
2794
2638
 
2795
2639
  // src/internal/composer-draft-actions.ts
2796
- import { z as z21 } from "zod";
2640
+ import { z as z20 } from "zod";
2797
2641
  var range = {
2798
- from: z21.number().int().nonnegative(),
2799
- to: z21.number().int().nonnegative(),
2800
- label: z21.string()
2642
+ from: z20.number().int().nonnegative(),
2643
+ to: z20.number().int().nonnegative(),
2644
+ label: z20.string()
2801
2645
  };
2802
- var mentionSchema = z21.discriminatedUnion("kind", [
2803
- z21.object({
2646
+ var mentionSchema = z20.discriminatedUnion("kind", [
2647
+ z20.object({
2804
2648
  ...range,
2805
- kind: z21.literal("thread"),
2806
- threadId: z21.string(),
2807
- projectId: z21.string().optional()
2649
+ kind: z20.literal("thread"),
2650
+ threadId: z20.string(),
2651
+ projectId: z20.string().optional()
2808
2652
  }),
2809
- z21.object({ ...range, kind: z21.literal("project"), projectId: z21.string() }),
2810
- z21.object({ ...range, kind: z21.literal("section"), sectionId: z21.string() }),
2811
- z21.object({
2653
+ z20.object({ ...range, kind: z20.literal("project"), projectId: z20.string() }),
2654
+ z20.object({ ...range, kind: z20.literal("section"), sectionId: z20.string() }),
2655
+ z20.object({
2812
2656
  ...range,
2813
- kind: z21.literal("path"),
2814
- path: z21.string(),
2815
- source: z21.enum(["workspace", "thread-storage"]),
2816
- entryKind: z21.enum(["file", "directory"])
2657
+ kind: z20.literal("path"),
2658
+ path: z20.string(),
2659
+ source: z20.enum(["workspace", "thread-storage"]),
2660
+ entryKind: z20.enum(["file", "directory"])
2817
2661
  }),
2818
- z21.object({
2662
+ z20.object({
2819
2663
  ...range,
2820
- kind: z21.literal("command"),
2821
- trigger: z21.enum(["/", "$"]),
2822
- name: z21.string(),
2823
- source: z21.enum(["skill", "command"]),
2824
- origin: z21.enum(["builtin", "project", "user"]),
2825
- argumentHint: z21.string().nullable()
2664
+ kind: z20.literal("command"),
2665
+ trigger: z20.enum(["/", "$"]),
2666
+ name: z20.string(),
2667
+ source: z20.enum(["skill", "command"]),
2668
+ origin: z20.enum(["builtin", "project", "user"]),
2669
+ argumentHint: z20.string().nullable()
2826
2670
  }),
2827
- z21.object({ ...range, kind: z21.literal("attachment"), path: z21.string() }),
2828
- z21.object({
2671
+ z20.object({ ...range, kind: z20.literal("attachment"), path: z20.string() }),
2672
+ z20.object({
2829
2673
  ...range,
2830
- kind: z21.literal("plugin"),
2831
- pluginId: z21.string(),
2832
- provider: z21.string().min(1).refine((value) => !value.includes(":")),
2833
- id: z21.string(),
2834
- icon: z21.string().nullable().optional()
2674
+ kind: z20.literal("plugin"),
2675
+ pluginId: z20.string(),
2676
+ provider: z20.string().min(1).refine((value) => !value.includes(":")),
2677
+ id: z20.string(),
2678
+ icon: z20.string().nullable().optional()
2835
2679
  })
2836
2680
  ]);
2837
2681
  var attachmentFields = {
2838
- type: z21.enum(["localImage", "localFile"]),
2839
- path: z21.string().min(1),
2840
- name: z21.string(),
2841
- mimeType: z21.string().optional(),
2842
- sizeBytes: z21.number().nonnegative().optional()
2682
+ type: z20.enum(["localImage", "localFile"]),
2683
+ path: z20.string().min(1),
2684
+ name: z20.string(),
2685
+ mimeType: z20.string().optional(),
2686
+ sizeBytes: z20.number().nonnegative().optional()
2843
2687
  };
2844
- var attachmentsSchema = z21.array(
2845
- z21.union([
2846
- z21.object({
2688
+ var attachmentsSchema = z20.array(
2689
+ z20.union([
2690
+ z20.object({
2847
2691
  ...attachmentFields,
2848
- hostId: z21.string().min(1),
2849
- sourceProjectId: z21.undefined().optional()
2692
+ hostId: z20.string().min(1),
2693
+ sourceProjectId: z20.undefined().optional()
2850
2694
  }),
2851
- z21.object({
2695
+ z20.object({
2852
2696
  ...attachmentFields,
2853
- sourceProjectId: z21.string().min(1).optional(),
2854
- hostId: z21.undefined().optional()
2697
+ sourceProjectId: z20.string().min(1).optional(),
2698
+ hostId: z20.undefined().optional()
2855
2699
  })
2856
2700
  ])
2857
2701
  );
2858
- var replacementSchema = z21.object({
2859
- text: z21.string(),
2860
- mentions: z21.array(mentionSchema),
2702
+ var replacementSchema = z20.object({
2703
+ text: z20.string(),
2704
+ mentions: z20.array(mentionSchema),
2861
2705
  attachments: attachmentsSchema.optional()
2862
2706
  }).superRefine((draft, context) => {
2863
2707
  let end = 0;
@@ -3547,6 +3391,7 @@ function collectComposerCustomization(registration, seenIds, onRejected, seenPop
3547
3391
  var FILE_PATH_MAX_LENGTH = 32768;
3548
3392
  var WINDOWS_DRIVE_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/u;
3549
3393
  var WINDOWS_UNC_ABSOLUTE_PATH = /^\\\\/u;
3394
+ var REVISION_REF = /^(?:HEAD|[0-9a-f]{4,40})$/iu;
3550
3395
  function isJsonObject(value) {
3551
3396
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
3552
3397
  return false;
@@ -3585,6 +3430,9 @@ function hasUnpairedSurrogate(value) {
3585
3430
  function isValidPathSegment(segment) {
3586
3431
  return segment.length > 0 && segment !== "." && segment !== "..";
3587
3432
  }
3433
+ function isValidRevisionRef(value) {
3434
+ return typeof value === "string" && REVISION_REF.test(value);
3435
+ }
3588
3436
  function isPositiveSafeInteger(value) {
3589
3437
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
3590
3438
  }
@@ -3615,15 +3463,22 @@ function isValidAbsoluteHostFilePath(value) {
3615
3463
  function normalizeExperimentalLiveFileTarget(value) {
3616
3464
  if (!isJsonObject(value) || typeof value.kind !== "string") return null;
3617
3465
  switch (value.kind) {
3618
- case "workspace":
3619
- if (!hasExactKeys(value, ["kind", "environmentId", "path"]) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
3466
+ case "workspace": {
3467
+ const ref = value.experimental_ref;
3468
+ if (!hasExactKeys(
3469
+ value,
3470
+ ref === void 0 ? ["kind", "environmentId", "path"] : ["kind", "environmentId", "path", "experimental_ref"]
3471
+ ) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
3620
3472
  return null;
3621
3473
  }
3622
- return {
3474
+ const target = {
3623
3475
  kind: value.kind,
3624
3476
  environmentId: value.environmentId,
3625
3477
  path: value.path
3626
3478
  };
3479
+ if (ref === void 0) return target;
3480
+ return isValidRevisionRef(ref) ? { ...target, experimental_ref: ref } : null;
3481
+ }
3627
3482
  case "host":
3628
3483
  if (!hasExactKeys(value, ["kind", "hostId", "path"]) || !isNonEmptyIdentity(value.hostId) || !isValidAbsoluteHostFilePath(value.path)) {
3629
3484
  return null;
@@ -3751,7 +3606,7 @@ function adaptSidebarFooterAction(registration) {
3751
3606
  var sidebarFooterItemsByRegistrationSet = /* @__PURE__ */ new WeakMap();
3752
3607
 
3753
3608
  // src/internal/plugin-app-registration-collector.ts
3754
- import { z as z22 } from "zod";
3609
+ import { z as z21 } from "zod";
3755
3610
  var CODE_FENCE_LANGUAGE_PATTERN = /^[a-z0-9][a-z0-9+#._-]*$/;
3756
3611
  var SIDEBAR_FOOTER_ACTION_KEYS = /* @__PURE__ */ new Set([
3757
3612
  "id",
@@ -3867,8 +3722,8 @@ function checkStaleNavPanelKeys(kind, registration, onWarning) {
3867
3722
  }
3868
3723
  }
3869
3724
  function createCommandShortcutSchema() {
3870
- return z22.object({
3871
- key: z22.string().min(1).max(32).refine(
3725
+ return z21.object({
3726
+ key: z21.string().min(1).max(32).refine(
3872
3727
  (key) => ![
3873
3728
  "Alt",
3874
3729
  "Control",
@@ -3879,11 +3734,11 @@ function createCommandShortcutSchema() {
3879
3734
  "Unidentified"
3880
3735
  ].includes(key)
3881
3736
  ),
3882
- mod: z22.boolean().default(false),
3883
- meta: z22.boolean().default(false),
3884
- control: z22.boolean().default(false),
3885
- alt: z22.boolean().default(false),
3886
- shift: z22.boolean().default(false)
3737
+ mod: z21.boolean().default(false),
3738
+ meta: z21.boolean().default(false),
3739
+ control: z21.boolean().default(false),
3740
+ alt: z21.boolean().default(false),
3741
+ shift: z21.boolean().default(false)
3887
3742
  }).strict().refine(
3888
3743
  (shortcut) => shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key),
3889
3744
  "Use Command, Control, or Alt with a key, or a function key"
@@ -4032,9 +3887,9 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4032
3887
  throw new Error(`${kind}: run and params require action availability`);
4033
3888
  }
4034
3889
  const target = registration.experimental_target;
4035
- if (target !== void 0 && (context.kind !== "nav-panel" || availability !== "fixed" || typeof target?.validate !== "function")) {
3890
+ if (target !== void 0 && (availability !== "fixed" || typeof target?.validate !== "function")) {
4036
3891
  throw new Error(
4037
- `${kind}: experimental_target requires a nav-panel fixed tab and a validate function`
3892
+ `${kind}: experimental_target requires a fixed tab and a validate function`
4038
3893
  );
4039
3894
  }
4040
3895
  const validated = {
@@ -4051,7 +3906,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4051
3906
  registration.tooltip
4052
3907
  )
4053
3908
  },
4054
- ...availability === "action" && registration.params !== void 0 ? { params: z22.json().parse(registration.params) } : {}
3909
+ ...availability === "action" && registration.params !== void 0 ? { params: z21.json().parse(registration.params) } : {}
4055
3910
  };
4056
3911
  collected.tabs.push(validated);
4057
3912
  }
@@ -4389,6 +4244,11 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4389
4244
  if (registration.useData !== void 0 && typeof registration.useData !== "function") {
4390
4245
  throw new Error(`${kind}: "useData" must be a function`);
4391
4246
  }
4247
+ if (registration.experimental_bulkItem !== void 0 && typeof registration.experimental_bulkItem !== "function") {
4248
+ throw new Error(
4249
+ `${kind}: "experimental_bulkItem" must be a function`
4250
+ );
4251
+ }
4392
4252
  collected.threadActions.push({
4393
4253
  id,
4394
4254
  title: requireNonEmptyString(kind, "title", registration.title),
@@ -4396,7 +4256,10 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4396
4256
  group: requireNonEmptyString(kind, "group", registration.group),
4397
4257
  ...requireOptionalOrder(kind, registration.order),
4398
4258
  ...registration.useData !== void 0 ? { useData: registration.useData } : {},
4399
- item: registration.item
4259
+ item: registration.item,
4260
+ ...registration.experimental_bulkItem !== void 0 ? {
4261
+ experimental_bulkItem: registration.experimental_bulkItem
4262
+ } : {}
4400
4263
  });
4401
4264
  },
4402
4265
  experimental_browserToolbarAction(registration) {
@@ -4758,6 +4621,7 @@ function SlotLifecycleGuard({
4758
4621
  }
4759
4622
  var SlotEnvContext = createContext(null);
4760
4623
  var NO_THREAD_ACTIONS = () => [];
4624
+ var NO_THREAD_BULK_ACTIONS = () => [];
4761
4625
  var NO_THREAD_ACTION_REGISTRATIONS = [];
4762
4626
  function noRenameEditor() {
4763
4627
  }
@@ -4781,6 +4645,25 @@ function TestThreadActionsMenuItems({
4781
4645
  }) {
4782
4646
  const rename = requestRename ?? noRenameEditor;
4783
4647
  const entries = useTestThreadActions(hook, thread, { requestRename: rename });
4648
+ return /* @__PURE__ */ jsx(
4649
+ TestThreadActionRows,
4650
+ {
4651
+ label: "Thread actions",
4652
+ entries,
4653
+ inline,
4654
+ rename,
4655
+ onClose
4656
+ }
4657
+ );
4658
+ }
4659
+ function TestThreadActionRows({
4660
+ label,
4661
+ entries,
4662
+ inline,
4663
+ rename,
4664
+ onClose,
4665
+ onKeyDown
4666
+ }) {
4784
4667
  const rows = [
4785
4668
  ...entries.map((entry) => ({
4786
4669
  key: entry.key,
@@ -4793,7 +4676,7 @@ function TestThreadActionsMenuItems({
4793
4676
  run: () => item.action.run({ requestRename: rename })
4794
4677
  }))
4795
4678
  ];
4796
- return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": "Thread actions", children: rows.map((row) => /* @__PURE__ */ jsx(
4679
+ return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": label, onKeyDown, children: rows.map((row) => /* @__PURE__ */ jsx(
4797
4680
  "button",
4798
4681
  {
4799
4682
  type: "button",
@@ -4875,19 +4758,31 @@ function TestThreadActionsMenu({
4875
4758
  function TestThreadActionsContextMenu({
4876
4759
  thread,
4877
4760
  children,
4878
- inline,
4761
+ inline = [],
4879
4762
  requestRename,
4880
4763
  onOpenChange,
4881
4764
  onCloseAutoFocus,
4765
+ onEscapeKeyDown,
4882
4766
  disabled,
4883
- dragging
4767
+ dragging,
4768
+ experimental_bulkThreads
4884
4769
  }) {
4885
4770
  const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
4771
+ const resolveSelection = useSlotEnv(
4772
+ "experimental_ThreadActionsContextMenu"
4773
+ ).threadBulkActions;
4774
+ const selection = experimental_bulkThreads !== void 0 && experimental_bulkThreads.length > 1 ? experimental_bulkThreads : null;
4775
+ const onKeyDown = (event) => {
4776
+ if (event.key !== "Escape") return;
4777
+ onEscapeKeyDown?.(event.nativeEvent);
4778
+ menu.close();
4779
+ };
4886
4780
  return /* @__PURE__ */ jsxs(
4887
4781
  "div",
4888
4782
  {
4889
4783
  "data-testid": "bb-thread-actions-context-menu",
4890
4784
  "data-thread-id": thread.id,
4785
+ "data-selection-thread-ids": selection === null ? void 0 : selection.map((target) => target.id).join(" "),
4891
4786
  "data-disabled": disabled === true ? "true" : "false",
4892
4787
  "data-dragging": dragging === true ? "true" : "false",
4893
4788
  className: "contents",
@@ -4898,7 +4793,18 @@ function TestThreadActionsContextMenu({
4898
4793
  },
4899
4794
  children: [
4900
4795
  children,
4901
- menu.open ? /* @__PURE__ */ jsx(
4796
+ menu.open && selection !== null ? /* @__PURE__ */ jsx(
4797
+ TestThreadActionRows,
4798
+ {
4799
+ label: `Actions for ${selection.length} threads`,
4800
+ entries: resolveSelection(selection),
4801
+ inline,
4802
+ rename: requestRename ?? noRenameEditor,
4803
+ onClose: menu.close,
4804
+ onKeyDown
4805
+ }
4806
+ ) : null,
4807
+ menu.open && selection === null ? /* @__PURE__ */ jsx(
4902
4808
  TestThreadActionsMenuItems,
4903
4809
  {
4904
4810
  hook: "experimental_ThreadActionsContextMenu",
@@ -5555,7 +5461,7 @@ var testPluginSdkApp = {
5555
5461
  store.getSnapshot,
5556
5462
  store.getSnapshot
5557
5463
  );
5558
- if (state === null || state.panelId !== ("context" in tab ? tab.context.panelId : tab.panelId) || state.tabId !== tab.id || tab.experimental_target === void 0) {
5464
+ if (state === null || state.panelId !== ("context" in tab ? tab.context.kind === "nav-panel" ? tab.context.panelId : null : tab.panelId) || state.tabId !== tab.id || tab.experimental_target === void 0) {
5559
5465
  return null;
5560
5466
  }
5561
5467
  try {
@@ -5656,6 +5562,11 @@ var testPluginSdkApp = {
5656
5562
  experimental_useCodeTheme() {
5657
5563
  return useSlotEnv("experimental_useCodeTheme").codeTheme;
5658
5564
  },
5565
+ experimental_useCanOpenFileExternally(target) {
5566
+ return useSlotEnv(
5567
+ "experimental_useCanOpenFileExternally"
5568
+ ).canOpenFileExternally(target);
5569
+ },
5659
5570
  experimental_copyToClipboard(content) {
5660
5571
  return activeClipboard?.(content) ?? Promise.resolve(true);
5661
5572
  },
@@ -6022,10 +5933,12 @@ function renderSlot(registration, props, options = {}) {
6022
5933
  }
6023
5934
  };
6024
5935
  const navigateCalls = [];
5936
+ const retired = options;
5937
+ const experimental_panelCalls = [];
6025
5938
  const experimental_fixedTabOpenCalls = [];
6026
5939
  const experimental_tabOpenCalls = [];
6027
5940
  let fixedTabTargetSnapshot = options.experimental_fixedTabTarget === void 0 ? null : {
6028
- panelId: options.experimental_fixedTabTarget.panelId,
5941
+ panelId: options.experimental_fixedTabTarget.panelId ?? null,
6029
5942
  sequence: 1,
6030
5943
  tabId: options.experimental_fixedTabTarget.tabId,
6031
5944
  target: strictJsonRoundTrip(
@@ -6046,54 +5959,88 @@ function renderSlot(registration, props, options = {}) {
6046
5959
  for (const listener of fixedTabTargetListeners) listener();
6047
5960
  }
6048
5961
  };
6049
- function captureFixedTabOpen(surface, panelId, tabId, target) {
5962
+ function openTabWithRetiredHosts(tabOptions) {
5963
+ if (retired.experimental_openTab !== void 0)
5964
+ return retired.experimental_openTab({
5965
+ surface: { kind: "current" },
5966
+ ...tabOptions
5967
+ });
5968
+ if (tabOptions.tab.availability === "action") {
5969
+ navigateCalls.push({
5970
+ method: "openThreadPanel",
5971
+ options: {
5972
+ actionId: tabOptions.tab.id,
5973
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
5974
+ ...tabOptions.params === void 0 ? {} : { params: tabOptions.params }
5975
+ }
5976
+ });
5977
+ return retired.openThreadPanel?.({
5978
+ actionId: tabOptions.tab.id,
5979
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
5980
+ ...tabOptions.params === void 0 ? {} : { params: tabOptions.params }
5981
+ }) ?? false;
5982
+ }
6050
5983
  const call = {
6051
- surface,
6052
- ...panelId === void 0 ? {} : { panelId },
6053
- tabId,
6054
- ...target === void 0 ? {} : { target }
5984
+ surface: { kind: "current" },
5985
+ ...tabOptions.tab.context.kind === "nav-panel" ? { panelId: tabOptions.tab.context.panelId } : {},
5986
+ tabId: tabOptions.tab.id,
5987
+ ...tabOptions.target === void 0 ? {} : { target: tabOptions.target }
6055
5988
  };
6056
5989
  experimental_fixedTabOpenCalls.push(call);
6057
- const accepted = options.experimental_openFixedTab?.(call) ?? false;
6058
- if (accepted && target !== void 0 && panelId !== void 0) {
6059
- fixedTabTargetSnapshot = {
6060
- panelId,
6061
- sequence: (fixedTabTargetSnapshot?.sequence ?? 0) + 1,
6062
- tabId,
6063
- target
5990
+ return retired.experimental_openFixedTab?.(call) ?? false;
5991
+ }
5992
+ function jsonTabOptions(tabOptions) {
5993
+ try {
5994
+ if (tabOptions.tab.availability === "fixed")
5995
+ return tabOptions.target === void 0 ? { tab: tabOptions.tab } : {
5996
+ tab: tabOptions.tab,
5997
+ target: strictJsonRoundTrip(tabOptions.target, "tab target")
5998
+ };
5999
+ return {
6000
+ tab: tabOptions.tab,
6001
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
6002
+ ...tabOptions.params === void 0 ? {} : { params: strictJsonRoundTrip(tabOptions.params, "tab params") }
6064
6003
  };
6065
- for (const listener of fixedTabTargetListeners) listener();
6004
+ } catch {
6005
+ return null;
6066
6006
  }
6067
- return accepted;
6068
6007
  }
6008
+ const panelController = {
6009
+ openTab(tabOptions) {
6010
+ experimental_panelCalls.push({ method: "openTab", options: tabOptions });
6011
+ const json = jsonTabOptions(tabOptions);
6012
+ if (json === null) return false;
6013
+ const accepted = options.experimental_panel?.openTab?.(json) ?? openTabWithRetiredHosts(json);
6014
+ if (accepted && json.tab.availability === "fixed" && json.target !== void 0) {
6015
+ fixedTabTargetSnapshot = {
6016
+ panelId: json.tab.context.kind === "nav-panel" ? json.tab.context.panelId : null,
6017
+ sequence: (fixedTabTargetSnapshot?.sequence ?? 0) + 1,
6018
+ tabId: json.tab.id,
6019
+ target: json.target
6020
+ };
6021
+ for (const listener of fixedTabTargetListeners) listener();
6022
+ }
6023
+ return accepted;
6024
+ },
6025
+ toggleTab(tabOptions) {
6026
+ experimental_panelCalls.push({
6027
+ method: "toggleTab",
6028
+ options: tabOptions
6029
+ });
6030
+ const json = jsonTabOptions(tabOptions);
6031
+ if (json === null) return false;
6032
+ return options.experimental_panel?.toggleTab?.(json) ?? false;
6033
+ },
6034
+ close() {
6035
+ experimental_panelCalls.push({ method: "close" });
6036
+ return options.experimental_panel?.close?.() ?? false;
6037
+ }
6038
+ };
6069
6039
  const appPanel = {
6040
+ ...panelController,
6070
6041
  experimental_openTab(tabOptions) {
6071
6042
  experimental_tabOpenCalls.push(tabOptions);
6072
- if (options.experimental_openTab !== void 0)
6073
- return options.experimental_openTab(tabOptions);
6074
- if (tabOptions.tab.availability === "action") {
6075
- try {
6076
- const params = tabOptions.params === void 0 ? void 0 : strictJsonRoundTrip(tabOptions.params, "tab params");
6077
- return navigate.openThreadPanel({
6078
- actionId: tabOptions.tab.id,
6079
- ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
6080
- ...params === void 0 ? {} : { params }
6081
- });
6082
- } catch {
6083
- return false;
6084
- }
6085
- }
6086
- try {
6087
- const target = tabOptions.target === void 0 ? void 0 : strictJsonRoundTrip(tabOptions.target, "tab target");
6088
- return captureFixedTabOpen(
6089
- tabOptions.surface,
6090
- tabOptions.tab.context.kind === "nav-panel" ? tabOptions.tab.context.panelId : void 0,
6091
- tabOptions.tab.id,
6092
- target
6093
- );
6094
- } catch {
6095
- return false;
6096
- }
6043
+ return panelController.openTab(tabOptions);
6097
6044
  },
6098
6045
  openFixedTab(panelOptions) {
6099
6046
  let target;
@@ -6115,22 +6062,13 @@ function renderSlot(registration, props, options = {}) {
6115
6062
  return false;
6116
6063
  }
6117
6064
  }
6118
- if (panelOptions.tab.panelId === void 0) {
6119
- if (target !== void 0) return false;
6120
- return appPanel.experimental_openTab({
6121
- surface: panelOptions.surface,
6122
- tab: {
6123
- id: panelOptions.tab.id,
6124
- context: { kind: "thread" },
6125
- availability: "fixed"
6126
- }
6127
- });
6128
- }
6065
+ if (panelOptions.tab.panelId === void 0 && target !== void 0)
6066
+ return false;
6129
6067
  return appPanel.experimental_openTab({
6130
6068
  surface: panelOptions.surface,
6131
6069
  tab: {
6132
6070
  id: panelOptions.tab.id,
6133
- context: { kind: "nav-panel", panelId: panelOptions.tab.panelId },
6071
+ context: panelOptions.tab.panelId === void 0 ? { kind: "thread" } : { kind: "nav-panel", panelId: panelOptions.tab.panelId },
6134
6072
  availability: "fixed"
6135
6073
  },
6136
6074
  ...target === void 0 ? {} : { target }
@@ -6279,11 +6217,15 @@ function renderSlot(registration, props, options = {}) {
6279
6217
  });
6280
6218
  },
6281
6219
  openThreadPanel(panelOptions) {
6282
- navigateCalls.push({
6283
- method: "openThreadPanel",
6284
- options: panelOptions
6220
+ return panelController.openTab({
6221
+ tab: {
6222
+ id: panelOptions.actionId,
6223
+ context: { kind: "thread" },
6224
+ availability: "action"
6225
+ },
6226
+ ...panelOptions.title === void 0 ? {} : { title: panelOptions.title },
6227
+ ...panelOptions.params === void 0 ? {} : { params: panelOptions.params }
6285
6228
  });
6286
- return options.openThreadPanel?.(panelOptions) ?? false;
6287
6229
  },
6288
6230
  openUrl(url) {
6289
6231
  navigateCalls.push({ method: "openUrl", url });
@@ -6571,8 +6513,6 @@ ${block}
6571
6513
  navigate,
6572
6514
  navigateCalls,
6573
6515
  appPanel,
6574
- experimental_fixedTabOpenCalls,
6575
- experimental_tabOpenCalls,
6576
6516
  fixedTabTarget,
6577
6517
  composer,
6578
6518
  composerLog,
@@ -6583,6 +6523,7 @@ ${block}
6583
6523
  sidebarNavigationCalls,
6584
6524
  environmentArchiveCalls,
6585
6525
  threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
6526
+ threadBulkActions: options.threadBulkActions ?? NO_THREAD_BULK_ACTIONS,
6586
6527
  threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
6587
6528
  sidebarDraftThreadIds,
6588
6529
  experiments: new Set(options.experiments ?? []),
@@ -6595,6 +6536,7 @@ ${block}
6595
6536
  sdkCalls,
6596
6537
  providers,
6597
6538
  codeTheme,
6539
+ canOpenFileExternally: options.canOpenFileExternally ?? (() => false),
6598
6540
  branchesState: {
6599
6541
  branches: options.branchesState?.branches ?? [],
6600
6542
  remoteBranches: options.branchesState?.remoteBranches ?? [],
@@ -6674,6 +6616,10 @@ ${block}
6674
6616
  if (!composerOwnership.active) return;
6675
6617
  result.unmount();
6676
6618
  };
6619
+ const retiredLogs = {
6620
+ experimental_fixedTabOpenCalls,
6621
+ experimental_tabOpenCalls
6622
+ };
6677
6623
  return {
6678
6624
  ...result,
6679
6625
  rerender: rerenderSlot,
@@ -6685,8 +6631,8 @@ ${block}
6685
6631
  setComposerText: setComposerText2,
6686
6632
  setComposerScope,
6687
6633
  navigateCalls,
6688
- experimental_fixedTabOpenCalls,
6689
- experimental_tabOpenCalls,
6634
+ experimental_panelCalls,
6635
+ ...retiredLogs,
6690
6636
  sidebarActionCalls,
6691
6637
  sidebarNavigationCalls,
6692
6638
  experimental_environmentArchiveCalls: environmentArchiveCalls,
@@ -6706,8 +6652,8 @@ ${block}
6706
6652
  },
6707
6653
  rpcCalls,
6708
6654
  navigateCalls,
6709
- experimental_fixedTabOpenCalls,
6710
- experimental_tabOpenCalls,
6655
+ experimental_panelCalls,
6656
+ ...retiredLogs,
6711
6657
  sidebarActionCalls,
6712
6658
  sidebarNavigationCalls,
6713
6659
  experimental_environmentArchiveCalls: environmentArchiveCalls,