@get-bb/plugin-sdk 0.6.80 → 0.6.90

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([
@@ -1189,6 +1188,15 @@ function createTaggedKeyedQueryOwner(options) {
1189
1188
  let stop;
1190
1189
  return {
1191
1190
  observer,
1191
+ async refetchKeys(requested) {
1192
+ const subscribed = requested.filter((key) => keys.has(key));
1193
+ if (subscribed.length === 0) return;
1194
+ for (const key of subscribed) dirtyKeys.add(key);
1195
+ if (observer.getCurrentResult().isFetching) {
1196
+ restartTaggedRead(observer.getCurrentQuery());
1197
+ }
1198
+ await observer.refetch({ cancelRefetch: false });
1199
+ },
1192
1200
  subscribe(requested, listener) {
1193
1201
  let added = false;
1194
1202
  for (const key of requested) {
@@ -1196,8 +1204,8 @@ function createTaggedKeyedQueryOwner(options) {
1196
1204
  keys.set(key, (keys.get(key) ?? 0) + 1);
1197
1205
  }
1198
1206
  const cached = getTaggedReadData(client, queryKey);
1199
- const missing = requested.filter(
1200
- (key) => !Object.hasOwn(cached?.result ?? {}, key)
1207
+ const pending = requested.filter(
1208
+ (key) => dirtyKeys.has(key) || !Object.hasOwn(cached?.result ?? {}, key)
1201
1209
  );
1202
1210
  if (!stop) missingOnly = cached === void 0;
1203
1211
  listeners.add(listener);
@@ -1206,9 +1214,9 @@ function createTaggedKeyedQueryOwner(options) {
1206
1214
  for (const notify of listeners) notify();
1207
1215
  });
1208
1216
  }
1209
- if (added && missing.length > 0) {
1217
+ if (added && pending.length > 0) {
1210
1218
  if (observer.getCurrentResult().isFetching) {
1211
- if (readingKeys.size > 0 && missing.some((key) => !readingKeys.has(key)))
1219
+ if (readingKeys.size > 0 && pending.some((key) => !readingKeys.has(key)))
1212
1220
  restartTaggedRead(observer.getCurrentQuery());
1213
1221
  } else {
1214
1222
  missingOnly = true;
@@ -1504,107 +1512,12 @@ var projectExecutionDefaultsSchema = z2.object({
1504
1512
  permissionMode: permissionModeSchema
1505
1513
  });
1506
1514
 
1507
- // ../domain/src/git-checkout.ts
1515
+ // ../domain/src/plugin-id.ts
1508
1516
  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
- );
1517
+ var pluginIdSchema = z3.string().regex(/^[a-z0-9][a-z0-9-]*$/u);
1605
1518
 
1606
1519
  // ../domain/src/change-kinds.ts
1607
- import { z as z18 } from "zod";
1520
+ import { z as z17 } from "zod";
1608
1521
 
1609
1522
  // ../domain/src/thread-event-types.ts
1610
1523
  import { z as z4 } from "zod";
@@ -1672,7 +1585,7 @@ var threadEventTypeSchema = z4.string().refine(
1672
1585
  );
1673
1586
 
1674
1587
  // ../domain/src/thread.ts
1675
- import { z as z17 } from "zod";
1588
+ import { z as z16 } from "zod";
1676
1589
 
1677
1590
  // ../domain/src/thread-create-origin.ts
1678
1591
  import { z as z5 } from "zod";
@@ -1765,18 +1678,14 @@ var environmentSchema = z6.object({
1765
1678
  });
1766
1679
 
1767
1680
  // ../domain/src/queued-message.ts
1768
- import { z as z10 } from "zod";
1769
-
1770
- // ../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);
1681
+ import { z as z9 } from "zod";
1773
1682
 
1774
1683
  // ../domain/src/protocol-ids.ts
1775
- import { z as z8 } from "zod";
1776
- var clientTurnRequestIdSchema = z8.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
1684
+ import { z as z7 } from "zod";
1685
+ var clientTurnRequestIdSchema = z7.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
1777
1686
 
1778
1687
  // ../domain/src/system-message.ts
1779
- import { z as z9 } from "zod";
1688
+ import { z as z8 } from "zod";
1780
1689
  var systemMessageKindValues = [
1781
1690
  "ownership-assigned",
1782
1691
  "ownership-removed",
@@ -1789,41 +1698,41 @@ var systemMessageKindValues = [
1789
1698
  "environment-directory-updated",
1790
1699
  "unlabeled"
1791
1700
  ];
1792
- var systemMessageKindSchema = z9.enum(systemMessageKindValues);
1793
- var systemThreadInterruptedReasonSchema = z9.enum([
1701
+ var systemMessageKindSchema = z8.enum(systemMessageKindValues);
1702
+ var systemThreadInterruptedReasonSchema = z8.enum([
1794
1703
  "manual-stop",
1795
1704
  "host-daemon-restarted",
1796
1705
  "host-removed",
1797
1706
  "provider-turn-idle"
1798
1707
  ]);
1799
- var childThreadOutcomeSchema = z9.object({
1800
- threadId: z9.string(),
1801
- status: z9.enum(["completed", "failed", "interrupted"]),
1802
- interruption: z9.object({
1708
+ var childThreadOutcomeSchema = z8.object({
1709
+ threadId: z8.string(),
1710
+ status: z8.enum(["completed", "failed", "interrupted"]),
1711
+ interruption: z8.object({
1803
1712
  reason: systemThreadInterruptedReasonSchema,
1804
- cause: z9.literal("host-connection-lost").optional()
1713
+ cause: z8.literal("host-connection-lost").optional()
1805
1714
  }).optional()
1806
1715
  });
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()
1716
+ var systemMessageSubjectSchema = z8.discriminatedUnion("kind", [
1717
+ z8.object({
1718
+ kind: z8.literal("thread"),
1719
+ threadId: z8.string(),
1720
+ threadName: z8.string(),
1721
+ outcomes: z8.array(childThreadOutcomeSchema).optional()
1813
1722
  }),
1814
- z9.object({
1815
- kind: z9.literal("thread-batch"),
1816
- count: z9.number(),
1817
- outcomes: z9.array(childThreadOutcomeSchema).optional()
1723
+ z8.object({
1724
+ kind: z8.literal("thread-batch"),
1725
+ count: z8.number(),
1726
+ outcomes: z8.array(childThreadOutcomeSchema).optional()
1818
1727
  }),
1819
- z9.object({
1820
- kind: z9.literal("tool-call"),
1821
- toolName: z9.string(),
1822
- suppress: z9.boolean()
1728
+ z8.object({
1729
+ kind: z8.literal("tool-call"),
1730
+ toolName: z8.string(),
1731
+ suppress: z8.boolean()
1823
1732
  }),
1824
- z9.object({
1825
- kind: z9.literal("directory"),
1826
- path: z9.string()
1733
+ z8.object({
1734
+ kind: z8.literal("directory"),
1735
+ path: z8.string()
1827
1736
  })
1828
1737
  ]);
1829
1738
 
@@ -1838,44 +1747,44 @@ var queuedMessageWaitingOnKindValues = [
1838
1747
  "interaction",
1839
1748
  "plugin"
1840
1749
  ];
1841
- var queuedMessageWaitingOnKindSchema = z10.enum(
1750
+ var queuedMessageWaitingOnKindSchema = z9.enum(
1842
1751
  queuedMessageWaitingOnKindValues
1843
1752
  );
1844
- var queuedMessageWaitHostNameSchema = z10.string().min(1).max(200);
1753
+ var queuedMessageWaitHostNameSchema = z9.string().min(1).max(200);
1845
1754
  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"),
1755
+ var queuedMessageWaitReasonSchema = z9.string().min(1).max(QUEUED_MESSAGE_WAIT_REASON_MAX_LENGTH);
1756
+ var queuedMessageWaitingOnSchema = z9.discriminatedUnion("kind", [
1757
+ z9.object({ kind: z9.literal("time") }),
1758
+ z9.object({ kind: z9.literal("thread-busy") }),
1759
+ z9.object({ kind: z9.literal("stopping") }),
1760
+ z9.object({ kind: z9.literal("turn-starting") }),
1761
+ z9.object({ kind: z9.literal("provisioning") }),
1762
+ z9.object({
1763
+ kind: z9.literal("host-offline"),
1855
1764
  hostName: queuedMessageWaitHostNameSchema
1856
1765
  }),
1857
- z10.object({ kind: z10.literal("interaction") }),
1858
- z10.object({
1859
- kind: z10.literal("plugin"),
1766
+ z9.object({ kind: z9.literal("interaction") }),
1767
+ z9.object({
1768
+ kind: z9.literal("plugin"),
1860
1769
  pluginId: pluginIdSchema,
1861
1770
  reason: queuedMessageWaitReasonSchema
1862
1771
  })
1863
1772
  ]);
1864
1773
  var QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH = 200;
1865
- var queuedMessageFailureReasonSchema = z10.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
1774
+ var queuedMessageFailureReasonSchema = z9.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
1866
1775
  var QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX = "plugin:";
1867
- var queuedMessageWaitHolderSchema = z10.templateLiteral([
1776
+ var queuedMessageWaitHolderSchema = z9.templateLiteral([
1868
1777
  QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX,
1869
1778
  pluginIdSchema
1870
1779
  ]);
1871
1780
  var queuedMessagePayloadKindValues = ["inline", "retry"];
1872
- var queuedMessagePayloadKindSchema = z10.enum(
1781
+ var queuedMessagePayloadKindSchema = z9.enum(
1873
1782
  queuedMessagePayloadKindValues
1874
1783
  );
1875
- var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1876
- z10.object({ kind: z10.literal("inline") }),
1877
- z10.object({
1878
- kind: z10.literal("retry"),
1784
+ var queuedMessagePayloadSchema = z9.discriminatedUnion("kind", [
1785
+ z9.object({ kind: z9.literal("inline") }),
1786
+ z9.object({
1787
+ kind: z9.literal("retry"),
1879
1788
  /**
1880
1789
  * The ORIGINAL request, not the attempt that just failed. Retrying a retry
1881
1790
  * re-submits the same original blocks, so this id is carried forward
@@ -1883,7 +1792,7 @@ var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1883
1792
  */
1884
1793
  retryOfTurnRequestId: clientTurnRequestIdSchema,
1885
1794
  /** Which attempt this row will dispatch: 2 is the first retry. */
1886
- attempt: z10.number().int().min(2),
1795
+ attempt: z9.number().int().min(2),
1887
1796
  /**
1888
1797
  * Why this turn is being retried, in the retrier's words ("Rate limited"),
1889
1798
  * as the row's card and `bb thread queue list` render it.
@@ -1896,13 +1805,13 @@ var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1896
1805
  reason: queuedMessageWaitReasonSchema
1897
1806
  })
1898
1807
  ]);
1899
- var queuedMessageSystemNoticeSchema = z10.object({
1808
+ var queuedMessageSystemNoticeSchema = z9.object({
1900
1809
  kind: systemMessageKindSchema,
1901
1810
  subject: systemMessageSubjectSchema.nullable()
1902
1811
  });
1903
1812
 
1904
1813
  // ../domain/src/queued-message-lifecycle.ts
1905
- import { z as z11 } from "zod";
1814
+ import { z as z10 } from "zod";
1906
1815
  var queuedMessageStateValues = [
1907
1816
  "queued",
1908
1817
  "scheduled",
@@ -1911,10 +1820,10 @@ var queuedMessageStateValues = [
1911
1820
  "failed_exhausted",
1912
1821
  "claimed"
1913
1822
  ];
1914
- var queuedMessageStateSchema = z11.enum(queuedMessageStateValues);
1823
+ var queuedMessageStateSchema = z10.enum(queuedMessageStateValues);
1915
1824
 
1916
1825
  // ../domain/src/thread-status.ts
1917
- import { z as z12 } from "zod";
1826
+ import { z as z11 } from "zod";
1918
1827
  var threadStatusValues = [
1919
1828
  "pending",
1920
1829
  "idle",
@@ -1923,136 +1832,75 @@ var threadStatusValues = [
1923
1832
  "stopping",
1924
1833
  "error"
1925
1834
  ];
1926
- var threadStatusSchema = z12.enum(threadStatusValues);
1835
+ var threadStatusSchema = z11.enum(threadStatusValues);
1927
1836
 
1928
1837
  // ../domain/src/thread-origin-kind.ts
1929
- import { z as z13 } from "zod";
1838
+ import { z as z12 } from "zod";
1930
1839
  var threadOriginKindValues = ["fork"];
1931
- var threadOriginKindSchema = z13.enum(threadOriginKindValues);
1840
+ var threadOriginKindSchema = z12.enum(threadOriginKindValues);
1932
1841
 
1933
1842
  // ../domain/src/thread-parent-notifications.ts
1934
- import { z as z14 } from "zod";
1843
+ import { z as z13 } from "zod";
1935
1844
  var threadParentNotificationsValues = [
1936
1845
  "auto",
1937
1846
  "stuck",
1938
1847
  "off"
1939
1848
  ];
1940
- var threadParentNotificationsSchema = z14.enum(
1849
+ var threadParentNotificationsSchema = z13.enum(
1941
1850
  threadParentNotificationsValues
1942
1851
  );
1943
1852
 
1944
1853
  // ../domain/src/thread-visibility.ts
1945
- import { z as z15 } from "zod";
1854
+ import { z as z14 } from "zod";
1946
1855
  var threadVisibilityValues = ["visible", "hidden"];
1947
- var threadVisibilitySchema = z15.enum(threadVisibilityValues);
1856
+ var threadVisibilitySchema = z14.enum(threadVisibilityValues);
1948
1857
 
1949
1858
  // ../domain/src/thread-runtime-state.ts
1950
- import { z as z16 } from "zod";
1859
+ import { z as z15 } from "zod";
1951
1860
  var threadRuntimeDisplayStatusValues = [
1952
1861
  ...threadStatusValues,
1953
1862
  "provisioning",
1954
1863
  "waiting-for-host"
1955
1864
  ];
1956
- var threadRuntimeDisplayStatusSchema = z16.enum(
1865
+ var threadRuntimeDisplayStatusSchema = z15.enum(
1957
1866
  threadRuntimeDisplayStatusValues
1958
1867
  );
1959
- var threadRuntimeStateSchema = z16.object({
1868
+ var threadRuntimeStateSchema = z15.object({
1960
1869
  displayStatus: threadRuntimeDisplayStatusSchema
1961
1870
  });
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()
1871
+ var threadActivityStateSchema = z15.object({
1872
+ activeWorkflowCount: z15.number().int().nonnegative(),
1873
+ activeBackgroundAgentCount: z15.number().int().nonnegative(),
1874
+ activeBackgroundCommandCount: z15.number().int().nonnegative(),
1875
+ activePlanModeCount: z15.number().int().nonnegative(),
1876
+ activeGoalCount: z15.number().int().nonnegative()
1968
1877
  });
1969
1878
 
1970
1879
  // ../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(),
1880
+ var threadQueuedMessageSchema = z16.object({
1881
+ id: z16.string(),
2034
1882
  origin: threadCreateOriginSchema.nullable(),
2035
- originPluginId: z17.string().nullable(),
2036
- initiator: z17.enum(["user", "agent", "system"]),
2037
- senderThreadId: z17.string().nullable(),
1883
+ originPluginId: z16.string().nullable(),
1884
+ initiator: z16.enum(["user", "agent", "system"]),
1885
+ senderThreadId: z16.string().nullable(),
2038
1886
  /**
2039
1887
  * The thread this row is waiting on. Redundant on the thread-scoped list
2040
1888
  * route that first served this DTO, and load-bearing everywhere else it is
2041
1889
  * now served: a `queue.*` plugin event and a cross-thread wait-holder query
2042
1890
  * both hand out rows with no surrounding thread to read it from.
2043
1891
  */
2044
- threadId: z17.string(),
2045
- content: z17.array(promptInputSchema).min(1),
2046
- model: z17.string().min(1),
1892
+ threadId: z16.string(),
1893
+ content: z16.array(promptInputSchema).min(1),
1894
+ model: z16.string().min(1),
2047
1895
  reasoningLevel: reasoningLevelSchema,
2048
1896
  permissionMode: permissionModeSchema,
2049
1897
  serviceTier: serviceTierSchema,
2050
- groupWithNext: z17.boolean(),
1898
+ groupWithNext: z16.boolean(),
2051
1899
  /**
2052
1900
  * Epoch ms this row is scheduled to attempt dispatch, or null when it is
2053
1901
  * eligible as soon as its other waits clear.
2054
1902
  */
2055
- sendAt: z17.number().int().nonnegative().nullable(),
1903
+ sendAt: z16.number().int().nonnegative().nullable(),
2056
1904
  state: queuedMessageStateSchema,
2057
1905
  /**
2058
1906
  * Why this row is queued, or null for a `queued` row that is simply next in
@@ -2080,50 +1928,50 @@ var threadQueuedMessageSchema = z17.object({
2080
1928
  * not something a client should reason about. The server folds both into
2081
1929
  * this one answer.
2082
1930
  */
2083
- editable: z17.boolean(),
2084
- createdAt: z17.number(),
2085
- updatedAt: z17.number()
1931
+ editable: z16.boolean(),
1932
+ createdAt: z16.number(),
1933
+ updatedAt: z16.number()
2086
1934
  });
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(),
1935
+ var threadSchema = z16.object({
1936
+ id: z16.string(),
1937
+ projectId: z16.string(),
1938
+ environmentId: z16.string().nullable(),
1939
+ providerId: z16.string(),
1940
+ title: z16.string().nullable(),
1941
+ titleFallback: z16.string().nullable(),
1942
+ sectionId: z16.string().nullable(),
2095
1943
  status: threadStatusSchema,
2096
- parentThreadId: z17.string().nullable(),
2097
- lifecycleOwnerThreadId: z17.string().nullable(),
2098
- sourceThreadId: z17.string().nullable(),
1944
+ parentThreadId: z16.string().nullable(),
1945
+ lifecycleOwnerThreadId: z16.string().nullable(),
1946
+ sourceThreadId: z16.string().nullable(),
2099
1947
  originKind: threadOriginKindSchema.nullable(),
2100
- originPluginId: z17.string().nullable(),
1948
+ originPluginId: z16.string().nullable(),
2101
1949
  visibility: threadVisibilitySchema,
2102
1950
  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()
1951
+ archivedAt: z16.number().nullable(),
1952
+ pinnedAt: z16.number().nullable(),
1953
+ deletedAt: z16.number().nullable(),
1954
+ lastReadAt: z16.number().nullable(),
1955
+ latestAttentionAt: z16.number(),
1956
+ createdAt: z16.number(),
1957
+ updatedAt: z16.number()
2110
1958
  });
2111
1959
  var threadWithRuntimeSchema = threadSchema.extend({
2112
1960
  runtime: threadRuntimeStateSchema
2113
1961
  });
2114
1962
  var threadQueuedWorkValues = ["none", "waiting", "failed"];
2115
- var threadQueuedWorkSchema = z17.enum(threadQueuedWorkValues);
1963
+ var threadQueuedWorkSchema = z16.enum(threadQueuedWorkValues);
2116
1964
  var threadListEntrySchema = threadWithRuntimeSchema.extend({
2117
1965
  activity: threadActivityStateSchema,
2118
1966
  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(),
1967
+ pinSortKey: z16.string().nullable(),
1968
+ hasPendingInteraction: z16.boolean(),
1969
+ environmentHostId: z16.string().nullable(),
1970
+ environmentName: z16.string().nullable(),
1971
+ environmentBranchName: z16.string().nullable(),
1972
+ environmentPath: z16.string().nullable(),
1973
+ environmentProviderId: z16.string().nullable(),
1974
+ environmentIsWorktree: z16.boolean().nullable(),
2127
1975
  environmentWorkspaceDisplayKind: environmentWorkspaceDisplayKindSchema
2128
1976
  });
2129
1977
 
@@ -2167,7 +2015,8 @@ var ENVIRONMENT_CHANGE_KINDS = [
2167
2015
  var HOST_CHANGE_KINDS = [
2168
2016
  "host-connected",
2169
2017
  "host-disconnected",
2170
- "provider-model-catalog-changed"
2018
+ "provider-model-catalog-changed",
2019
+ "provider-commands-changed"
2171
2020
  ];
2172
2021
  var SYSTEM_CHANGE_KINDS = [
2173
2022
  "config-changed",
@@ -2179,16 +2028,16 @@ var SYSTEM_CHANGE_KINDS = [
2179
2028
  "server-move-changed",
2180
2029
  "app-update-changed"
2181
2030
  ];
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()
2031
+ var threadChangeKindSchema = z17.enum(THREAD_CHANGE_KINDS);
2032
+ var projectChangeKindSchema = z17.enum(PROJECT_CHANGE_KINDS);
2033
+ var environmentChangeKindSchema = z17.enum(ENVIRONMENT_CHANGE_KINDS);
2034
+ var hostChangeKindSchema = z17.enum(HOST_CHANGE_KINDS);
2035
+ var systemChangeKindSchema = z17.enum(SYSTEM_CHANGE_KINDS);
2036
+ var threadTimelineSubscriptionTargetSchema = z17.object({
2037
+ kind: z17.literal("thread-timeline"),
2038
+ threadId: z17.string().min(1),
2039
+ segmentLimit: z17.number().int().positive().nullable(),
2040
+ deferContent: z17.boolean()
2192
2041
  }).strict();
2193
2042
  function canonicalPluginReadInput(value) {
2194
2043
  if (value === null || typeof value !== "object") return JSON.stringify(value);
@@ -2198,62 +2047,62 @@ function canonicalPluginReadInput(value) {
2198
2047
  (key) => `${JSON.stringify(key)}:${canonicalPluginReadInput(value[key])}`
2199
2048
  ).join(",")}}`;
2200
2049
  }
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()
2050
+ var pluginReadSubscriptionTargetSchema = z17.object({
2051
+ kind: z17.literal("plugin-read"),
2052
+ pluginId: z17.string().min(1),
2053
+ method: z17.string().min(1),
2054
+ read: z17.union([
2055
+ z17.object({ input: jsonValueSchema }).strict(),
2056
+ z17.object({ key: z17.string() }).strict()
2208
2057
  ]).refine(
2209
2058
  (read) => new TextEncoder().encode(canonicalPluginReadInput(read)).byteLength <= 16384,
2210
2059
  "Plugin read input exceeds 16 KiB"
2211
2060
  )
2212
2061
  }).strict();
2213
- var realtimeSubscriptionTargetSchema = z18.discriminatedUnion("kind", [
2062
+ var realtimeSubscriptionTargetSchema = z17.discriminatedUnion("kind", [
2214
2063
  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)
2064
+ z17.object({ kind: z17.literal("plugin"), pluginId: z17.string().min(1) }).strict(),
2065
+ z17.object({
2066
+ kind: z17.literal("thread-detail"),
2067
+ threadId: z17.string().min(1)
2219
2068
  }).strict(),
2220
2069
  threadTimelineSubscriptionTargetSchema,
2221
- z18.object({
2222
- kind: z18.literal("thread-list")
2070
+ z17.object({
2071
+ kind: z17.literal("thread-list")
2223
2072
  }).strict(),
2224
- z18.object({
2225
- kind: z18.literal("project-detail"),
2226
- projectId: z18.string().min(1)
2073
+ z17.object({
2074
+ kind: z17.literal("project-detail"),
2075
+ projectId: z17.string().min(1)
2227
2076
  }).strict(),
2228
- z18.object({
2229
- kind: z18.literal("project-list")
2077
+ z17.object({
2078
+ kind: z17.literal("project-list")
2230
2079
  }).strict(),
2231
- z18.object({
2232
- kind: z18.literal("environment-detail"),
2233
- environmentId: z18.string().min(1)
2080
+ z17.object({
2081
+ kind: z17.literal("environment-detail"),
2082
+ environmentId: z17.string().min(1)
2234
2083
  }).strict(),
2235
- z18.object({
2236
- kind: z18.literal("environment-list")
2084
+ z17.object({
2085
+ kind: z17.literal("environment-list")
2237
2086
  }).strict(),
2238
- z18.object({
2239
- kind: z18.literal("host-detail"),
2240
- hostId: z18.string().min(1)
2087
+ z17.object({
2088
+ kind: z17.literal("host-detail"),
2089
+ hostId: z17.string().min(1)
2241
2090
  }).strict(),
2242
- z18.object({
2243
- kind: z18.literal("host-list")
2091
+ z17.object({
2092
+ kind: z17.literal("host-list")
2244
2093
  }).strict(),
2245
- z18.object({
2246
- kind: z18.literal("system")
2094
+ z17.object({
2095
+ kind: z17.literal("system")
2247
2096
  }).strict()
2248
2097
  ]);
2249
2098
  function isValidSubscriptionTarget(value) {
2250
2099
  return realtimeSubscriptionTargetSchema.safeParse(value).success;
2251
2100
  }
2252
- var validSubscriptionTargetsSchema = z18.preprocess(
2101
+ var validSubscriptionTargetsSchema = z17.preprocess(
2253
2102
  (value) => Array.isArray(value) ? value.filter(isValidSubscriptionTarget) : value,
2254
- z18.array(realtimeSubscriptionTargetSchema)
2103
+ z17.array(realtimeSubscriptionTargetSchema)
2255
2104
  );
2256
- var validSubscriptionTargetSchema = z18.preprocess(
2105
+ var validSubscriptionTargetSchema = z17.preprocess(
2257
2106
  (value) => value === void 0 || isValidSubscriptionTarget(value) ? value : null,
2258
2107
  realtimeSubscriptionTargetSchema.nullable().optional()
2259
2108
  );
@@ -2262,84 +2111,88 @@ var subscriptionFields = {
2262
2111
  targets: validSubscriptionTargetsSchema.optional()
2263
2112
  };
2264
2113
  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")
2114
+ var subscribeMessageSchema = z17.object({
2115
+ type: z17.literal("subscribe"),
2116
+ ...subscriptionFields,
2117
+ timelineTags: z17.record(z17.string(), z17.string().min(1).nullable()).optional()
2118
+ }).refine(hasSubscriptionTargets);
2119
+ var unsubscribeMessageSchema = z17.object({ type: z17.literal("unsubscribe"), ...subscriptionFields }).refine(hasSubscriptionTargets);
2120
+ var pingMessageSchema = z17.object({
2121
+ type: z17.literal("ping")
2269
2122
  });
2270
- var visibilityMessageSchema = z18.object({
2271
- type: z18.literal("visibility"),
2272
- visible: z18.boolean()
2123
+ var visibilityMessageSchema = z17.object({
2124
+ type: z17.literal("visibility"),
2125
+ visible: z17.boolean()
2273
2126
  });
2274
- var clientMessageSchema = z18.discriminatedUnion("type", [
2127
+ var clientMessageSchema = z17.discriminatedUnion("type", [
2275
2128
  subscribeMessageSchema,
2276
2129
  unsubscribeMessageSchema,
2277
2130
  pingMessageSchema,
2278
2131
  visibilityMessageSchema
2279
2132
  ]);
2280
- var pongMessageSchema = z18.object({
2281
- type: z18.literal("pong")
2133
+ var pongMessageSchema = z17.object({
2134
+ type: z17.literal("pong")
2282
2135
  }).strict();
2283
- var pongMessageLenientSchema = z18.object({
2284
- type: z18.literal("pong")
2136
+ var pongMessageLenientSchema = z17.object({
2137
+ type: z17.literal("pong")
2285
2138
  });
2286
- var threadStatusChangeMetadataSchema = z18.object({
2139
+ var threadStatusChangeMetadataSchema = z17.object({
2287
2140
  status: threadStatusSchema,
2288
2141
  runtime: threadRuntimeStateSchema,
2289
2142
  activity: threadActivityStateSchema,
2290
- latestAttentionAt: z18.number(),
2291
- updatedAt: z18.number()
2143
+ latestAttentionAt: z17.number(),
2144
+ updatedAt: z17.number()
2292
2145
  }).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(),
2146
+ var threadChangeMetadataSchema = z17.object({
2147
+ backgroundActivityChanged: z17.boolean().optional(),
2148
+ eventTypes: z17.array(threadEventTypeSchema).readonly().optional(),
2149
+ timelineSequence: z17.number().int().nonnegative().optional(),
2150
+ hasPendingInteraction: z17.boolean().optional(),
2151
+ projectId: z17.string().optional(),
2299
2152
  statusChange: threadStatusChangeMetadataSchema.optional()
2300
2153
  }).strict();
2301
- var threadChangedMessageSchema = z18.object({
2302
- type: z18.literal("changed"),
2303
- entity: z18.literal("thread"),
2304
- id: z18.string().optional(),
2154
+ var threadChangedMessageSchema = z17.object({
2155
+ type: z17.literal("changed"),
2156
+ entity: z17.literal("thread"),
2157
+ id: z17.string().optional(),
2305
2158
  metadata: threadChangeMetadataSchema.optional(),
2306
- changes: z18.array(threadChangeKindSchema).readonly()
2159
+ changes: z17.array(threadChangeKindSchema).readonly()
2307
2160
  }).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()
2161
+ var projectChangedMessageSchema = z17.object({
2162
+ type: z17.literal("changed"),
2163
+ entity: z17.literal("project"),
2164
+ id: z17.string().optional(),
2165
+ changes: z17.array(projectChangeKindSchema).readonly()
2313
2166
  }).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()
2167
+ var environmentChangedMessageSchema = z17.object({
2168
+ type: z17.literal("changed"),
2169
+ entity: z17.literal("environment"),
2170
+ id: z17.string().optional(),
2171
+ changes: z17.array(environmentChangeKindSchema).readonly()
2319
2172
  }).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()
2173
+ var hostChangedMessageSchema = z17.object({
2174
+ type: z17.literal("changed"),
2175
+ entity: z17.literal("host"),
2176
+ id: z17.string().optional(),
2177
+ changes: z17.array(hostChangeKindSchema).readonly()
2325
2178
  }).strict();
2326
- var systemChangedMessageSchema = z18.object({
2327
- type: z18.literal("changed"),
2328
- entity: z18.literal("system"),
2329
- changes: z18.array(systemChangeKindSchema).readonly()
2179
+ var systemChangedMessageSchema = z17.object({
2180
+ type: z17.literal("changed"),
2181
+ entity: z17.literal("system"),
2182
+ changes: z17.array(systemChangeKindSchema).readonly()
2330
2183
  }).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)
2184
+ var tagsChangedMessageSchema = z17.object({
2185
+ type: z17.literal("changed"),
2186
+ entity: z17.literal("tags"),
2187
+ tags: z17.array(z17.string().min(1)).min(1)
2335
2188
  }).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()
2189
+ var pluginChangedMessageSchema = z17.object({
2190
+ type: z17.literal("changed"),
2191
+ entity: z17.literal("plugin"),
2192
+ pluginId: z17.string().min(1),
2193
+ tags: z17.array(z17.string().min(1)).min(1).nullable()
2341
2194
  }).strict();
2342
- var changedMessageSchema = z18.discriminatedUnion("entity", [
2195
+ var changedMessageSchema = z17.discriminatedUnion("entity", [
2343
2196
  threadChangedMessageSchema,
2344
2197
  projectChangedMessageSchema,
2345
2198
  environmentChangedMessageSchema,
@@ -2350,56 +2203,56 @@ var changedMessageSchema = z18.discriminatedUnion("entity", [
2350
2203
  ]);
2351
2204
  function lenientKinds(kinds) {
2352
2205
  const known = new Set(kinds);
2353
- return z18.array(z18.string()).transform(
2206
+ return z17.array(z17.string()).transform(
2354
2207
  (values) => values.filter((value) => known.has(value))
2355
2208
  );
2356
2209
  }
2357
2210
  var knownThreadEventTypes = new Set(
2358
2211
  threadEventTypeValues
2359
2212
  );
2360
- var threadChangeMetadataLenientSchema = z18.object({
2361
- timelineSequence: z18.number().int().nonnegative().optional(),
2362
- backgroundActivityChanged: z18.boolean().optional(),
2363
- eventTypes: z18.array(z18.string()).transform(
2213
+ var threadChangeMetadataLenientSchema = z17.object({
2214
+ timelineSequence: z17.number().int().nonnegative().optional(),
2215
+ backgroundActivityChanged: z17.boolean().optional(),
2216
+ eventTypes: z17.array(z17.string()).transform(
2364
2217
  (values) => values.filter(
2365
2218
  (value) => knownThreadEventTypes.has(value)
2366
2219
  )
2367
2220
  ).optional(),
2368
- hasPendingInteraction: z18.boolean().optional(),
2369
- projectId: z18.string().optional(),
2221
+ hasPendingInteraction: z17.boolean().optional(),
2222
+ projectId: z17.string().optional(),
2370
2223
  statusChange: threadStatusChangeMetadataSchema.optional().catch(void 0)
2371
2224
  });
2372
- var threadChangedMessageLenientSchema = z18.object({
2373
- type: z18.literal("changed"),
2374
- entity: z18.literal("thread"),
2375
- id: z18.string().optional(),
2225
+ var threadChangedMessageLenientSchema = z17.object({
2226
+ type: z17.literal("changed"),
2227
+ entity: z17.literal("thread"),
2228
+ id: z17.string().optional(),
2376
2229
  metadata: threadChangeMetadataLenientSchema.optional(),
2377
2230
  changes: lenientKinds(THREAD_CHANGE_KINDS)
2378
2231
  });
2379
- var projectChangedMessageLenientSchema = z18.object({
2380
- type: z18.literal("changed"),
2381
- entity: z18.literal("project"),
2382
- id: z18.string().optional(),
2232
+ var projectChangedMessageLenientSchema = z17.object({
2233
+ type: z17.literal("changed"),
2234
+ entity: z17.literal("project"),
2235
+ id: z17.string().optional(),
2383
2236
  changes: lenientKinds(PROJECT_CHANGE_KINDS)
2384
2237
  });
2385
- var environmentChangedMessageLenientSchema = z18.object({
2386
- type: z18.literal("changed"),
2387
- entity: z18.literal("environment"),
2388
- id: z18.string().optional(),
2238
+ var environmentChangedMessageLenientSchema = z17.object({
2239
+ type: z17.literal("changed"),
2240
+ entity: z17.literal("environment"),
2241
+ id: z17.string().optional(),
2389
2242
  changes: lenientKinds(ENVIRONMENT_CHANGE_KINDS)
2390
2243
  });
2391
- var hostChangedMessageLenientSchema = z18.object({
2392
- type: z18.literal("changed"),
2393
- entity: z18.literal("host"),
2394
- id: z18.string().optional(),
2244
+ var hostChangedMessageLenientSchema = z17.object({
2245
+ type: z17.literal("changed"),
2246
+ entity: z17.literal("host"),
2247
+ id: z17.string().optional(),
2395
2248
  changes: lenientKinds(HOST_CHANGE_KINDS)
2396
2249
  });
2397
- var systemChangedMessageLenientSchema = z18.object({
2398
- type: z18.literal("changed"),
2399
- entity: z18.literal("system"),
2250
+ var systemChangedMessageLenientSchema = z17.object({
2251
+ type: z17.literal("changed"),
2252
+ entity: z17.literal("system"),
2400
2253
  changes: lenientKinds(SYSTEM_CHANGE_KINDS)
2401
2254
  });
2402
- var changedMessageLenientSchema = z18.discriminatedUnion("entity", [
2255
+ var changedMessageLenientSchema = z17.discriminatedUnion("entity", [
2403
2256
  threadChangedMessageLenientSchema,
2404
2257
  projectChangedMessageLenientSchema,
2405
2258
  environmentChangedMessageLenientSchema,
@@ -2410,22 +2263,22 @@ var changedMessageLenientSchema = z18.discriminatedUnion("entity", [
2410
2263
  ]);
2411
2264
 
2412
2265
  // src/internal/rpc-tags.ts
2413
- import { z as z19 } from "zod";
2414
- var rpcInvalidationTags = z19.array(z19.string().min(1)).min(1);
2266
+ import { z as z18 } from "zod";
2267
+ var rpcInvalidationTags = z18.array(z18.string().min(1)).min(1);
2415
2268
  function rpcResponseTags(declarations, input, output) {
2416
- const tags = z19.array(z19.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
2269
+ const tags = z18.array(z18.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
2417
2270
  const keyTags = {};
2418
2271
  if (declarations.keyTags && typeof output === "object" && output !== null && !Array.isArray(output)) {
2419
2272
  for (const [key, value] of Object.entries(output)) {
2420
- keyTags[key] = z19.array(z19.string().min(1)).parse(declarations.keyTags(key, value));
2273
+ keyTags[key] = z18.array(z18.string().min(1)).parse(declarations.keyTags(key, value));
2421
2274
  }
2422
2275
  }
2423
- const invalidated = z19.array(z19.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
2276
+ const invalidated = z18.array(z18.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
2424
2277
  return { tags, keyTags, invalidated };
2425
2278
  }
2426
2279
 
2427
2280
  // src/internal/rpc-query-host.ts
2428
- import { z as z20 } from "zod";
2281
+ import { z as z19 } from "zod";
2429
2282
  var rpcQueryKey = (pluginId, method, input) => [
2430
2283
  "plugin-rpc",
2431
2284
  pluginId,
@@ -2567,7 +2420,7 @@ function createRpcQueryHooks(useHost) {
2567
2420
  const enabled = options.enabled ?? true;
2568
2421
  const identity = JSON.stringify([...new Set(options.keys)].sort());
2569
2422
  const keys = useMemo2(
2570
- () => z20.array(z20.string()).parse(JSON.parse(identity)),
2423
+ () => z19.array(z19.string()).parse(JSON.parse(identity)),
2571
2424
  [identity]
2572
2425
  );
2573
2426
  let cache = owners.get(host.queryClient);
@@ -2593,7 +2446,7 @@ function createRpcQueryHooks(useHost) {
2593
2446
  );
2594
2447
  return {
2595
2448
  ...response,
2596
- result: z20.record(z20.string(), jsonValueSchema).parse(response.result)
2449
+ result: z19.record(z19.string(), jsonValueSchema).parse(response.result)
2597
2450
  };
2598
2451
  }
2599
2452
  });
@@ -2642,9 +2495,18 @@ function createRpcQueryHooks(useHost) {
2642
2495
  const refetch = useCallback2(async () => {
2643
2496
  await current.observer.refetch();
2644
2497
  }, [current]);
2498
+ const refetchKeys = useCallback2(
2499
+ async (requested) => {
2500
+ await current.refetchKeys(
2501
+ requested.filter((key) => keys.includes(key))
2502
+ );
2503
+ },
2504
+ [current, keys]
2505
+ );
2645
2506
  return {
2646
2507
  ...query,
2647
- refetch
2508
+ refetch,
2509
+ refetchKeys
2648
2510
  };
2649
2511
  }
2650
2512
  function experimental_useRpcMutation(options) {
@@ -2793,71 +2655,71 @@ function reconcileComposerMentions(currentText, nextText, mentions) {
2793
2655
  }
2794
2656
 
2795
2657
  // src/internal/composer-draft-actions.ts
2796
- import { z as z21 } from "zod";
2658
+ import { z as z20 } from "zod";
2797
2659
  var range = {
2798
- from: z21.number().int().nonnegative(),
2799
- to: z21.number().int().nonnegative(),
2800
- label: z21.string()
2660
+ from: z20.number().int().nonnegative(),
2661
+ to: z20.number().int().nonnegative(),
2662
+ label: z20.string()
2801
2663
  };
2802
- var mentionSchema = z21.discriminatedUnion("kind", [
2803
- z21.object({
2664
+ var mentionSchema = z20.discriminatedUnion("kind", [
2665
+ z20.object({
2804
2666
  ...range,
2805
- kind: z21.literal("thread"),
2806
- threadId: z21.string(),
2807
- projectId: z21.string().optional()
2667
+ kind: z20.literal("thread"),
2668
+ threadId: z20.string(),
2669
+ projectId: z20.string().optional()
2808
2670
  }),
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({
2671
+ z20.object({ ...range, kind: z20.literal("project"), projectId: z20.string() }),
2672
+ z20.object({ ...range, kind: z20.literal("section"), sectionId: z20.string() }),
2673
+ z20.object({
2812
2674
  ...range,
2813
- kind: z21.literal("path"),
2814
- path: z21.string(),
2815
- source: z21.enum(["workspace", "thread-storage"]),
2816
- entryKind: z21.enum(["file", "directory"])
2675
+ kind: z20.literal("path"),
2676
+ path: z20.string(),
2677
+ source: z20.enum(["workspace", "thread-storage"]),
2678
+ entryKind: z20.enum(["file", "directory"])
2817
2679
  }),
2818
- z21.object({
2680
+ z20.object({
2819
2681
  ...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()
2682
+ kind: z20.literal("command"),
2683
+ trigger: z20.enum(["/", "$"]),
2684
+ name: z20.string(),
2685
+ source: z20.enum(["skill", "command"]),
2686
+ origin: z20.enum(["builtin", "project", "user"]),
2687
+ argumentHint: z20.string().nullable()
2826
2688
  }),
2827
- z21.object({ ...range, kind: z21.literal("attachment"), path: z21.string() }),
2828
- z21.object({
2689
+ z20.object({ ...range, kind: z20.literal("attachment"), path: z20.string() }),
2690
+ z20.object({
2829
2691
  ...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()
2692
+ kind: z20.literal("plugin"),
2693
+ pluginId: z20.string(),
2694
+ provider: z20.string().min(1).refine((value) => !value.includes(":")),
2695
+ id: z20.string(),
2696
+ icon: z20.string().nullable().optional()
2835
2697
  })
2836
2698
  ]);
2837
2699
  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()
2700
+ type: z20.enum(["localImage", "localFile"]),
2701
+ path: z20.string().min(1),
2702
+ name: z20.string(),
2703
+ mimeType: z20.string().optional(),
2704
+ sizeBytes: z20.number().nonnegative().optional()
2843
2705
  };
2844
- var attachmentsSchema = z21.array(
2845
- z21.union([
2846
- z21.object({
2706
+ var attachmentsSchema = z20.array(
2707
+ z20.union([
2708
+ z20.object({
2847
2709
  ...attachmentFields,
2848
- hostId: z21.string().min(1),
2849
- sourceProjectId: z21.undefined().optional()
2710
+ hostId: z20.string().min(1),
2711
+ sourceProjectId: z20.undefined().optional()
2850
2712
  }),
2851
- z21.object({
2713
+ z20.object({
2852
2714
  ...attachmentFields,
2853
- sourceProjectId: z21.string().min(1).optional(),
2854
- hostId: z21.undefined().optional()
2715
+ sourceProjectId: z20.string().min(1).optional(),
2716
+ hostId: z20.undefined().optional()
2855
2717
  })
2856
2718
  ])
2857
2719
  );
2858
- var replacementSchema = z21.object({
2859
- text: z21.string(),
2860
- mentions: z21.array(mentionSchema),
2720
+ var replacementSchema = z20.object({
2721
+ text: z20.string(),
2722
+ mentions: z20.array(mentionSchema),
2861
2723
  attachments: attachmentsSchema.optional()
2862
2724
  }).superRefine((draft, context) => {
2863
2725
  let end = 0;
@@ -3547,6 +3409,7 @@ function collectComposerCustomization(registration, seenIds, onRejected, seenPop
3547
3409
  var FILE_PATH_MAX_LENGTH = 32768;
3548
3410
  var WINDOWS_DRIVE_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/u;
3549
3411
  var WINDOWS_UNC_ABSOLUTE_PATH = /^\\\\/u;
3412
+ var REVISION_REF = /^(?:HEAD|[0-9a-f]{4,40})$/iu;
3550
3413
  function isJsonObject(value) {
3551
3414
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
3552
3415
  return false;
@@ -3585,6 +3448,9 @@ function hasUnpairedSurrogate(value) {
3585
3448
  function isValidPathSegment(segment) {
3586
3449
  return segment.length > 0 && segment !== "." && segment !== "..";
3587
3450
  }
3451
+ function isValidRevisionRef(value) {
3452
+ return typeof value === "string" && REVISION_REF.test(value);
3453
+ }
3588
3454
  function isPositiveSafeInteger(value) {
3589
3455
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
3590
3456
  }
@@ -3615,15 +3481,22 @@ function isValidAbsoluteHostFilePath(value) {
3615
3481
  function normalizeExperimentalLiveFileTarget(value) {
3616
3482
  if (!isJsonObject(value) || typeof value.kind !== "string") return null;
3617
3483
  switch (value.kind) {
3618
- case "workspace":
3619
- if (!hasExactKeys(value, ["kind", "environmentId", "path"]) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
3484
+ case "workspace": {
3485
+ const ref = value.experimental_ref;
3486
+ if (!hasExactKeys(
3487
+ value,
3488
+ ref === void 0 ? ["kind", "environmentId", "path"] : ["kind", "environmentId", "path", "experimental_ref"]
3489
+ ) || !isNonEmptyIdentity(value.environmentId) || !isValidRelativeFilePath(value.path)) {
3620
3490
  return null;
3621
3491
  }
3622
- return {
3492
+ const target = {
3623
3493
  kind: value.kind,
3624
3494
  environmentId: value.environmentId,
3625
3495
  path: value.path
3626
3496
  };
3497
+ if (ref === void 0) return target;
3498
+ return isValidRevisionRef(ref) ? { ...target, experimental_ref: ref } : null;
3499
+ }
3627
3500
  case "host":
3628
3501
  if (!hasExactKeys(value, ["kind", "hostId", "path"]) || !isNonEmptyIdentity(value.hostId) || !isValidAbsoluteHostFilePath(value.path)) {
3629
3502
  return null;
@@ -3751,7 +3624,7 @@ function adaptSidebarFooterAction(registration) {
3751
3624
  var sidebarFooterItemsByRegistrationSet = /* @__PURE__ */ new WeakMap();
3752
3625
 
3753
3626
  // src/internal/plugin-app-registration-collector.ts
3754
- import { z as z22 } from "zod";
3627
+ import { z as z21 } from "zod";
3755
3628
  var CODE_FENCE_LANGUAGE_PATTERN = /^[a-z0-9][a-z0-9+#._-]*$/;
3756
3629
  var SIDEBAR_FOOTER_ACTION_KEYS = /* @__PURE__ */ new Set([
3757
3630
  "id",
@@ -3867,8 +3740,8 @@ function checkStaleNavPanelKeys(kind, registration, onWarning) {
3867
3740
  }
3868
3741
  }
3869
3742
  function createCommandShortcutSchema() {
3870
- return z22.object({
3871
- key: z22.string().min(1).max(32).refine(
3743
+ return z21.object({
3744
+ key: z21.string().min(1).max(32).refine(
3872
3745
  (key) => ![
3873
3746
  "Alt",
3874
3747
  "Control",
@@ -3879,11 +3752,11 @@ function createCommandShortcutSchema() {
3879
3752
  "Unidentified"
3880
3753
  ].includes(key)
3881
3754
  ),
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)
3755
+ mod: z21.boolean().default(false),
3756
+ meta: z21.boolean().default(false),
3757
+ control: z21.boolean().default(false),
3758
+ alt: z21.boolean().default(false),
3759
+ shift: z21.boolean().default(false)
3887
3760
  }).strict().refine(
3888
3761
  (shortcut) => shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key),
3889
3762
  "Use Command, Control, or Alt with a key, or a function key"
@@ -4032,9 +3905,9 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4032
3905
  throw new Error(`${kind}: run and params require action availability`);
4033
3906
  }
4034
3907
  const target = registration.experimental_target;
4035
- if (target !== void 0 && (context.kind !== "nav-panel" || availability !== "fixed" || typeof target?.validate !== "function")) {
3908
+ if (target !== void 0 && (availability !== "fixed" || typeof target?.validate !== "function")) {
4036
3909
  throw new Error(
4037
- `${kind}: experimental_target requires a nav-panel fixed tab and a validate function`
3910
+ `${kind}: experimental_target requires a fixed tab and a validate function`
4038
3911
  );
4039
3912
  }
4040
3913
  const validated = {
@@ -4051,7 +3924,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4051
3924
  registration.tooltip
4052
3925
  )
4053
3926
  },
4054
- ...availability === "action" && registration.params !== void 0 ? { params: z22.json().parse(registration.params) } : {}
3927
+ ...availability === "action" && registration.params !== void 0 ? { params: z21.json().parse(registration.params) } : {}
4055
3928
  };
4056
3929
  collected.tabs.push(validated);
4057
3930
  }
@@ -4389,6 +4262,11 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4389
4262
  if (registration.useData !== void 0 && typeof registration.useData !== "function") {
4390
4263
  throw new Error(`${kind}: "useData" must be a function`);
4391
4264
  }
4265
+ if (registration.experimental_bulkItem !== void 0 && typeof registration.experimental_bulkItem !== "function") {
4266
+ throw new Error(
4267
+ `${kind}: "experimental_bulkItem" must be a function`
4268
+ );
4269
+ }
4392
4270
  collected.threadActions.push({
4393
4271
  id,
4394
4272
  title: requireNonEmptyString(kind, "title", registration.title),
@@ -4396,7 +4274,10 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
4396
4274
  group: requireNonEmptyString(kind, "group", registration.group),
4397
4275
  ...requireOptionalOrder(kind, registration.order),
4398
4276
  ...registration.useData !== void 0 ? { useData: registration.useData } : {},
4399
- item: registration.item
4277
+ item: registration.item,
4278
+ ...registration.experimental_bulkItem !== void 0 ? {
4279
+ experimental_bulkItem: registration.experimental_bulkItem
4280
+ } : {}
4400
4281
  });
4401
4282
  },
4402
4283
  experimental_browserToolbarAction(registration) {
@@ -4758,6 +4639,7 @@ function SlotLifecycleGuard({
4758
4639
  }
4759
4640
  var SlotEnvContext = createContext(null);
4760
4641
  var NO_THREAD_ACTIONS = () => [];
4642
+ var NO_THREAD_BULK_ACTIONS = () => [];
4761
4643
  var NO_THREAD_ACTION_REGISTRATIONS = [];
4762
4644
  function noRenameEditor() {
4763
4645
  }
@@ -4781,6 +4663,25 @@ function TestThreadActionsMenuItems({
4781
4663
  }) {
4782
4664
  const rename = requestRename ?? noRenameEditor;
4783
4665
  const entries = useTestThreadActions(hook, thread, { requestRename: rename });
4666
+ return /* @__PURE__ */ jsx(
4667
+ TestThreadActionRows,
4668
+ {
4669
+ label: "Thread actions",
4670
+ entries,
4671
+ inline,
4672
+ rename,
4673
+ onClose
4674
+ }
4675
+ );
4676
+ }
4677
+ function TestThreadActionRows({
4678
+ label,
4679
+ entries,
4680
+ inline,
4681
+ rename,
4682
+ onClose,
4683
+ onKeyDown
4684
+ }) {
4784
4685
  const rows = [
4785
4686
  ...entries.map((entry) => ({
4786
4687
  key: entry.key,
@@ -4793,7 +4694,7 @@ function TestThreadActionsMenuItems({
4793
4694
  run: () => item.action.run({ requestRename: rename })
4794
4695
  }))
4795
4696
  ];
4796
- return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": "Thread actions", children: rows.map((row) => /* @__PURE__ */ jsx(
4697
+ return /* @__PURE__ */ jsx("div", { role: "menu", "aria-label": label, onKeyDown, children: rows.map((row) => /* @__PURE__ */ jsx(
4797
4698
  "button",
4798
4699
  {
4799
4700
  type: "button",
@@ -4875,19 +4776,31 @@ function TestThreadActionsMenu({
4875
4776
  function TestThreadActionsContextMenu({
4876
4777
  thread,
4877
4778
  children,
4878
- inline,
4779
+ inline = [],
4879
4780
  requestRename,
4880
4781
  onOpenChange,
4881
4782
  onCloseAutoFocus,
4783
+ onEscapeKeyDown,
4882
4784
  disabled,
4883
- dragging
4785
+ dragging,
4786
+ experimental_bulkThreads
4884
4787
  }) {
4885
4788
  const menu = useTestMenuOpenState({ onOpenChange, onCloseAutoFocus });
4789
+ const resolveSelection = useSlotEnv(
4790
+ "experimental_ThreadActionsContextMenu"
4791
+ ).threadBulkActions;
4792
+ const selection = experimental_bulkThreads !== void 0 && experimental_bulkThreads.length > 1 ? experimental_bulkThreads : null;
4793
+ const onKeyDown = (event) => {
4794
+ if (event.key !== "Escape") return;
4795
+ onEscapeKeyDown?.(event.nativeEvent);
4796
+ menu.close();
4797
+ };
4886
4798
  return /* @__PURE__ */ jsxs(
4887
4799
  "div",
4888
4800
  {
4889
4801
  "data-testid": "bb-thread-actions-context-menu",
4890
4802
  "data-thread-id": thread.id,
4803
+ "data-selection-thread-ids": selection === null ? void 0 : selection.map((target) => target.id).join(" "),
4891
4804
  "data-disabled": disabled === true ? "true" : "false",
4892
4805
  "data-dragging": dragging === true ? "true" : "false",
4893
4806
  className: "contents",
@@ -4898,7 +4811,18 @@ function TestThreadActionsContextMenu({
4898
4811
  },
4899
4812
  children: [
4900
4813
  children,
4901
- menu.open ? /* @__PURE__ */ jsx(
4814
+ menu.open && selection !== null ? /* @__PURE__ */ jsx(
4815
+ TestThreadActionRows,
4816
+ {
4817
+ label: `Actions for ${selection.length} threads`,
4818
+ entries: resolveSelection(selection),
4819
+ inline,
4820
+ rename: requestRename ?? noRenameEditor,
4821
+ onClose: menu.close,
4822
+ onKeyDown
4823
+ }
4824
+ ) : null,
4825
+ menu.open && selection === null ? /* @__PURE__ */ jsx(
4902
4826
  TestThreadActionsMenuItems,
4903
4827
  {
4904
4828
  hook: "experimental_ThreadActionsContextMenu",
@@ -5493,6 +5417,8 @@ function captureClipboardWrites(result) {
5493
5417
  return writes;
5494
5418
  }
5495
5419
  var testPluginSdkApp = {
5420
+ experimental_getApplicationLinkApprovals: async () => [],
5421
+ experimental_revokeApplicationLinkApproval: async (_scheme) => [],
5496
5422
  definePluginApp,
5497
5423
  ...createRpcQueryHooks(() => useSlotEnv("rpc query").rpcQueryHost),
5498
5424
  useRpc() {
@@ -5555,7 +5481,7 @@ var testPluginSdkApp = {
5555
5481
  store.getSnapshot,
5556
5482
  store.getSnapshot
5557
5483
  );
5558
- if (state === null || state.panelId !== ("context" in tab ? tab.context.panelId : tab.panelId) || state.tabId !== tab.id || tab.experimental_target === void 0) {
5484
+ 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
5485
  return null;
5560
5486
  }
5561
5487
  try {
@@ -5656,6 +5582,14 @@ var testPluginSdkApp = {
5656
5582
  experimental_useCodeTheme() {
5657
5583
  return useSlotEnv("experimental_useCodeTheme").codeTheme;
5658
5584
  },
5585
+ experimental_useCanOpenFileExternally(target) {
5586
+ return useSlotEnv(
5587
+ "experimental_useCanOpenFileExternally"
5588
+ ).canOpenFileExternally(target);
5589
+ },
5590
+ experimental_useTabVisible() {
5591
+ return useSlotEnv("experimental_useTabVisible").tabVisible;
5592
+ },
5659
5593
  experimental_copyToClipboard(content) {
5660
5594
  return activeClipboard?.(content) ?? Promise.resolve(true);
5661
5595
  },
@@ -6022,10 +5956,12 @@ function renderSlot(registration, props, options = {}) {
6022
5956
  }
6023
5957
  };
6024
5958
  const navigateCalls = [];
5959
+ const retired = options;
5960
+ const experimental_panelCalls = [];
6025
5961
  const experimental_fixedTabOpenCalls = [];
6026
5962
  const experimental_tabOpenCalls = [];
6027
5963
  let fixedTabTargetSnapshot = options.experimental_fixedTabTarget === void 0 ? null : {
6028
- panelId: options.experimental_fixedTabTarget.panelId,
5964
+ panelId: options.experimental_fixedTabTarget.panelId ?? null,
6029
5965
  sequence: 1,
6030
5966
  tabId: options.experimental_fixedTabTarget.tabId,
6031
5967
  target: strictJsonRoundTrip(
@@ -6046,54 +5982,88 @@ function renderSlot(registration, props, options = {}) {
6046
5982
  for (const listener of fixedTabTargetListeners) listener();
6047
5983
  }
6048
5984
  };
6049
- function captureFixedTabOpen(surface, panelId, tabId, target) {
5985
+ function openTabWithRetiredHosts(tabOptions) {
5986
+ if (retired.experimental_openTab !== void 0)
5987
+ return retired.experimental_openTab({
5988
+ surface: { kind: "current" },
5989
+ ...tabOptions
5990
+ });
5991
+ if (tabOptions.tab.availability === "action") {
5992
+ navigateCalls.push({
5993
+ method: "openThreadPanel",
5994
+ options: {
5995
+ actionId: tabOptions.tab.id,
5996
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
5997
+ ...tabOptions.params === void 0 ? {} : { params: tabOptions.params }
5998
+ }
5999
+ });
6000
+ return retired.openThreadPanel?.({
6001
+ actionId: tabOptions.tab.id,
6002
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
6003
+ ...tabOptions.params === void 0 ? {} : { params: tabOptions.params }
6004
+ }) ?? false;
6005
+ }
6050
6006
  const call = {
6051
- surface,
6052
- ...panelId === void 0 ? {} : { panelId },
6053
- tabId,
6054
- ...target === void 0 ? {} : { target }
6007
+ surface: { kind: "current" },
6008
+ ...tabOptions.tab.context.kind === "nav-panel" ? { panelId: tabOptions.tab.context.panelId } : {},
6009
+ tabId: tabOptions.tab.id,
6010
+ ...tabOptions.target === void 0 ? {} : { target: tabOptions.target }
6055
6011
  };
6056
6012
  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
6013
+ return retired.experimental_openFixedTab?.(call) ?? false;
6014
+ }
6015
+ function jsonTabOptions(tabOptions) {
6016
+ try {
6017
+ if (tabOptions.tab.availability === "fixed")
6018
+ return tabOptions.target === void 0 ? { tab: tabOptions.tab } : {
6019
+ tab: tabOptions.tab,
6020
+ target: strictJsonRoundTrip(tabOptions.target, "tab target")
6021
+ };
6022
+ return {
6023
+ tab: tabOptions.tab,
6024
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
6025
+ ...tabOptions.params === void 0 ? {} : { params: strictJsonRoundTrip(tabOptions.params, "tab params") }
6064
6026
  };
6065
- for (const listener of fixedTabTargetListeners) listener();
6027
+ } catch {
6028
+ return null;
6066
6029
  }
6067
- return accepted;
6068
6030
  }
6031
+ const panelController = {
6032
+ openTab(tabOptions) {
6033
+ experimental_panelCalls.push({ method: "openTab", options: tabOptions });
6034
+ const json = jsonTabOptions(tabOptions);
6035
+ if (json === null) return false;
6036
+ const accepted = options.experimental_panel?.openTab?.(json) ?? openTabWithRetiredHosts(json);
6037
+ if (accepted && json.tab.availability === "fixed" && json.target !== void 0) {
6038
+ fixedTabTargetSnapshot = {
6039
+ panelId: json.tab.context.kind === "nav-panel" ? json.tab.context.panelId : null,
6040
+ sequence: (fixedTabTargetSnapshot?.sequence ?? 0) + 1,
6041
+ tabId: json.tab.id,
6042
+ target: json.target
6043
+ };
6044
+ for (const listener of fixedTabTargetListeners) listener();
6045
+ }
6046
+ return accepted;
6047
+ },
6048
+ toggleTab(tabOptions) {
6049
+ experimental_panelCalls.push({
6050
+ method: "toggleTab",
6051
+ options: tabOptions
6052
+ });
6053
+ const json = jsonTabOptions(tabOptions);
6054
+ if (json === null) return false;
6055
+ return options.experimental_panel?.toggleTab?.(json) ?? false;
6056
+ },
6057
+ close() {
6058
+ experimental_panelCalls.push({ method: "close" });
6059
+ return options.experimental_panel?.close?.() ?? false;
6060
+ }
6061
+ };
6069
6062
  const appPanel = {
6063
+ ...panelController,
6070
6064
  experimental_openTab(tabOptions) {
6071
6065
  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
- }
6066
+ return panelController.openTab(tabOptions);
6097
6067
  },
6098
6068
  openFixedTab(panelOptions) {
6099
6069
  let target;
@@ -6115,22 +6085,13 @@ function renderSlot(registration, props, options = {}) {
6115
6085
  return false;
6116
6086
  }
6117
6087
  }
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
- }
6088
+ if (panelOptions.tab.panelId === void 0 && target !== void 0)
6089
+ return false;
6129
6090
  return appPanel.experimental_openTab({
6130
6091
  surface: panelOptions.surface,
6131
6092
  tab: {
6132
6093
  id: panelOptions.tab.id,
6133
- context: { kind: "nav-panel", panelId: panelOptions.tab.panelId },
6094
+ context: panelOptions.tab.panelId === void 0 ? { kind: "thread" } : { kind: "nav-panel", panelId: panelOptions.tab.panelId },
6134
6095
  availability: "fixed"
6135
6096
  },
6136
6097
  ...target === void 0 ? {} : { target }
@@ -6279,11 +6240,15 @@ function renderSlot(registration, props, options = {}) {
6279
6240
  });
6280
6241
  },
6281
6242
  openThreadPanel(panelOptions) {
6282
- navigateCalls.push({
6283
- method: "openThreadPanel",
6284
- options: panelOptions
6243
+ return panelController.openTab({
6244
+ tab: {
6245
+ id: panelOptions.actionId,
6246
+ context: { kind: "thread" },
6247
+ availability: "action"
6248
+ },
6249
+ ...panelOptions.title === void 0 ? {} : { title: panelOptions.title },
6250
+ ...panelOptions.params === void 0 ? {} : { params: panelOptions.params }
6285
6251
  });
6286
- return options.openThreadPanel?.(panelOptions) ?? false;
6287
6252
  },
6288
6253
  openUrl(url) {
6289
6254
  navigateCalls.push({ method: "openUrl", url });
@@ -6571,8 +6536,6 @@ ${block}
6571
6536
  navigate,
6572
6537
  navigateCalls,
6573
6538
  appPanel,
6574
- experimental_fixedTabOpenCalls,
6575
- experimental_tabOpenCalls,
6576
6539
  fixedTabTarget,
6577
6540
  composer,
6578
6541
  composerLog,
@@ -6583,6 +6546,7 @@ ${block}
6583
6546
  sidebarNavigationCalls,
6584
6547
  environmentArchiveCalls,
6585
6548
  threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
6549
+ threadBulkActions: options.threadBulkActions ?? NO_THREAD_BULK_ACTIONS,
6586
6550
  threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
6587
6551
  sidebarDraftThreadIds,
6588
6552
  experiments: new Set(options.experiments ?? []),
@@ -6595,6 +6559,8 @@ ${block}
6595
6559
  sdkCalls,
6596
6560
  providers,
6597
6561
  codeTheme,
6562
+ canOpenFileExternally: options.canOpenFileExternally ?? (() => false),
6563
+ tabVisible: options.tabVisible ?? true,
6598
6564
  branchesState: {
6599
6565
  branches: options.branchesState?.branches ?? [],
6600
6566
  remoteBranches: options.branchesState?.remoteBranches ?? [],
@@ -6674,6 +6640,10 @@ ${block}
6674
6640
  if (!composerOwnership.active) return;
6675
6641
  result.unmount();
6676
6642
  };
6643
+ const retiredLogs = {
6644
+ experimental_fixedTabOpenCalls,
6645
+ experimental_tabOpenCalls
6646
+ };
6677
6647
  return {
6678
6648
  ...result,
6679
6649
  rerender: rerenderSlot,
@@ -6685,8 +6655,8 @@ ${block}
6685
6655
  setComposerText: setComposerText2,
6686
6656
  setComposerScope,
6687
6657
  navigateCalls,
6688
- experimental_fixedTabOpenCalls,
6689
- experimental_tabOpenCalls,
6658
+ experimental_panelCalls,
6659
+ ...retiredLogs,
6690
6660
  sidebarActionCalls,
6691
6661
  sidebarNavigationCalls,
6692
6662
  experimental_environmentArchiveCalls: environmentArchiveCalls,
@@ -6706,8 +6676,8 @@ ${block}
6706
6676
  },
6707
6677
  rpcCalls,
6708
6678
  navigateCalls,
6709
- experimental_fixedTabOpenCalls,
6710
- experimental_tabOpenCalls,
6679
+ experimental_panelCalls,
6680
+ ...retiredLogs,
6711
6681
  sidebarActionCalls,
6712
6682
  sidebarNavigationCalls,
6713
6683
  experimental_environmentArchiveCalls: environmentArchiveCalls,