@get-bb/plugin-sdk 0.6.68 → 0.6.73

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.
@@ -1263,6 +1263,9 @@ import { QueryClient } from "@tanstack/react-query";
1263
1263
  import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
1264
1264
  import { useIsFetching } from "@tanstack/react-query";
1265
1265
 
1266
+ // ../domain/src/shared-types.ts
1267
+ import { z as z2 } from "zod";
1268
+
1266
1269
  // ../domain/src/json-value.ts
1267
1270
  import { z } from "zod";
1268
1271
  var jsonValueSchema = z.lazy(
@@ -1280,23 +1283,1149 @@ var jsonObjectSchema = z.record(
1280
1283
  jsonValueSchema
1281
1284
  );
1282
1285
 
1286
+ // ../domain/src/shared-types.ts
1287
+ var reasoningLevelSchema = z2.string().min(1);
1288
+ var serviceTierSchema = z2.string().min(1);
1289
+ var instructionModeValues = ["append", "replace"];
1290
+ var instructionModeSchema = z2.enum(instructionModeValues);
1291
+ var permissionModeValues = ["accept-edits", "auto", "full"];
1292
+ var permissionModeSchema = z2.enum(permissionModeValues);
1293
+ var permissionModeInputSchema = z2.union([permissionModeSchema, z2.literal("workspace-write")]).transform(
1294
+ (permissionMode) => permissionMode === "workspace-write" ? "accept-edits" : permissionMode
1295
+ );
1296
+ var legacyRecordedPermissionModeValues = [
1297
+ "workspace-write",
1298
+ "readonly"
1299
+ ];
1300
+ var recordedPermissionModeSchema = z2.enum([
1301
+ ...permissionModeValues,
1302
+ ...legacyRecordedPermissionModeValues
1303
+ ]);
1304
+ var permissionEscalationValues = ["ask", "deny"];
1305
+ var permissionEscalationSchema = z2.enum(permissionEscalationValues);
1306
+ var promptInputVisibilityValues = ["agent-only"];
1307
+ var promptInputVisibilitySchema = z2.enum(promptInputVisibilityValues);
1308
+ var promptInputVisibilityFields = {
1309
+ visibility: promptInputVisibilitySchema.optional()
1310
+ };
1311
+ var promptMentionPathSourceValues = ["workspace", "thread-storage"];
1312
+ var promptMentionPathSourceSchema = z2.enum(promptMentionPathSourceValues);
1313
+ var promptMentionPathEntryKindValues = ["file", "directory"];
1314
+ var promptMentionPathEntryKindSchema = z2.enum(
1315
+ promptMentionPathEntryKindValues
1316
+ );
1317
+ var promptMentionCommandTriggerValues = ["/", "$"];
1318
+ var promptMentionCommandTriggerSchema = z2.enum(
1319
+ promptMentionCommandTriggerValues
1320
+ );
1321
+ var promptMentionCommandSourceValues = ["skill", "command"];
1322
+ var promptMentionCommandSourceSchema = z2.enum(
1323
+ promptMentionCommandSourceValues
1324
+ );
1325
+ var promptMentionCommandOriginValues = [
1326
+ "builtin",
1327
+ "project",
1328
+ "user"
1329
+ ];
1330
+ var promptMentionCommandOriginSchema = z2.enum(
1331
+ promptMentionCommandOriginValues
1332
+ );
1333
+ var canonicalPromptMentionResourceSchema = z2.discriminatedUnion("kind", [
1334
+ z2.object({
1335
+ kind: z2.literal("thread"),
1336
+ threadId: z2.string(),
1337
+ projectId: z2.string().optional(),
1338
+ label: z2.string()
1339
+ }),
1340
+ z2.object({
1341
+ kind: z2.literal("project"),
1342
+ projectId: z2.string(),
1343
+ label: z2.string()
1344
+ }),
1345
+ z2.object({
1346
+ kind: z2.literal("section"),
1347
+ sectionId: z2.string(),
1348
+ label: z2.string()
1349
+ }),
1350
+ z2.object({
1351
+ kind: z2.literal("path"),
1352
+ source: promptMentionPathSourceSchema,
1353
+ entryKind: promptMentionPathEntryKindSchema,
1354
+ path: z2.string(),
1355
+ label: z2.string()
1356
+ }),
1357
+ z2.object({
1358
+ kind: z2.literal("command"),
1359
+ trigger: promptMentionCommandTriggerSchema,
1360
+ name: z2.string(),
1361
+ source: promptMentionCommandSourceSchema,
1362
+ origin: promptMentionCommandOriginSchema,
1363
+ label: z2.string(),
1364
+ argumentHint: z2.string().nullable()
1365
+ }),
1366
+ z2.object({
1367
+ kind: z2.literal("plugin"),
1368
+ pluginId: z2.string(),
1369
+ icon: z2.string().nullable().optional(),
1370
+ itemId: z2.string(),
1371
+ label: z2.string()
1372
+ }),
1373
+ z2.object({
1374
+ kind: z2.literal("attachment"),
1375
+ path: z2.string(),
1376
+ label: z2.string()
1377
+ })
1378
+ ]);
1379
+ function normalizeLegacyPromptMentionResource(value) {
1380
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1381
+ return value;
1382
+ }
1383
+ const record = value;
1384
+ if (record.kind !== "folder" || typeof record.folderId !== "string") {
1385
+ return value;
1386
+ }
1387
+ const { folderId, ...rest } = record;
1388
+ return { ...rest, kind: "section", sectionId: folderId };
1389
+ }
1390
+ var promptMentionResourceSchema = z2.preprocess(
1391
+ normalizeLegacyPromptMentionResource,
1392
+ canonicalPromptMentionResourceSchema
1393
+ );
1394
+ var promptTextMentionSchema = z2.object({
1395
+ start: z2.number().int().nonnegative(),
1396
+ end: z2.number().int().nonnegative(),
1397
+ resource: promptMentionResourceSchema
1398
+ });
1399
+ var promptInputSchema = z2.discriminatedUnion("type", [
1400
+ z2.object({
1401
+ type: z2.literal("text"),
1402
+ text: z2.string(),
1403
+ mentions: z2.array(promptTextMentionSchema).default([]),
1404
+ ...promptInputVisibilityFields
1405
+ }),
1406
+ z2.object({
1407
+ type: z2.literal("image"),
1408
+ url: z2.string().url(),
1409
+ ...promptInputVisibilityFields
1410
+ }),
1411
+ z2.object({
1412
+ type: z2.literal("localImage"),
1413
+ path: z2.string(),
1414
+ sourceProjectId: z2.string().min(1).optional(),
1415
+ hostId: z2.string().min(1).optional(),
1416
+ ...promptInputVisibilityFields
1417
+ }),
1418
+ z2.object({
1419
+ type: z2.literal("localFile"),
1420
+ path: z2.string(),
1421
+ sourceProjectId: z2.string().min(1).optional(),
1422
+ hostId: z2.string().min(1).optional(),
1423
+ name: z2.string().optional(),
1424
+ sizeBytes: z2.number().int().nonnegative().optional(),
1425
+ mimeType: z2.string().optional(),
1426
+ ...promptInputVisibilityFields
1427
+ })
1428
+ ]);
1429
+ var threadExecutionSourceSchema = z2.enum([
1430
+ "client/thread/start",
1431
+ "client/turn/requested",
1432
+ "client/turn/start"
1433
+ ]);
1434
+ var callerExecutionInputSourceValues = [
1435
+ "explicit",
1436
+ "client-preference"
1437
+ ];
1438
+ var callerExecutionInputSourceSchema = z2.enum(
1439
+ callerExecutionInputSourceValues
1440
+ );
1441
+ var threadExecutionOptionsSchema = z2.object({
1442
+ model: z2.string().optional(),
1443
+ serviceTier: serviceTierSchema.optional(),
1444
+ reasoningLevel: reasoningLevelSchema.optional(),
1445
+ permissionMode: permissionModeSchema.optional(),
1446
+ source: threadExecutionSourceSchema.optional(),
1447
+ seq: z2.number().int().optional()
1448
+ });
1449
+ var resolvedThreadExecutionOptionsSchema = threadExecutionOptionsSchema.extend({
1450
+ model: z2.string().min(1),
1451
+ serviceTier: serviceTierSchema,
1452
+ reasoningLevel: reasoningLevelSchema,
1453
+ permissionMode: permissionModeSchema,
1454
+ source: threadExecutionSourceSchema
1455
+ });
1456
+ var recordedThreadExecutionOptionsSchema = resolvedThreadExecutionOptionsSchema.extend({
1457
+ permissionMode: recordedPermissionModeSchema
1458
+ });
1459
+ var runtimePermissionScopeValues = ["workspace", "full"];
1460
+ var runtimePermissionScopeSchema = z2.enum(runtimePermissionScopeValues);
1461
+ var runtimePermissionPolicySchema = z2.discriminatedUnion(
1462
+ "permissionMode",
1463
+ [
1464
+ z2.object({
1465
+ permissionMode: z2.literal("accept-edits"),
1466
+ permissionScope: z2.literal("workspace"),
1467
+ approvalReviewer: z2.literal("user"),
1468
+ permissionEscalation: permissionEscalationSchema
1469
+ }),
1470
+ z2.object({
1471
+ permissionMode: z2.literal("auto"),
1472
+ permissionScope: z2.literal("workspace"),
1473
+ approvalReviewer: z2.literal("automatic"),
1474
+ permissionEscalation: permissionEscalationSchema
1475
+ }),
1476
+ z2.object({
1477
+ permissionMode: z2.literal("full"),
1478
+ permissionScope: z2.literal("full"),
1479
+ approvalReviewer: z2.null(),
1480
+ permissionEscalation: z2.null()
1481
+ })
1482
+ ]
1483
+ );
1484
+ var promptModeSchema = z2.literal("plan");
1485
+ var sessionOptionValueSchema = z2.union([z2.string(), z2.boolean()]);
1486
+ var sessionOptionSelectionsSchema = z2.record(
1487
+ z2.string().min(1),
1488
+ sessionOptionValueSchema
1489
+ );
1490
+ var runtimeThreadExecutionBaseOptionsSchema = z2.object({
1491
+ model: z2.string().min(1),
1492
+ serviceTier: serviceTierSchema,
1493
+ reasoningLevel: reasoningLevelSchema,
1494
+ promptMode: promptModeSchema.optional(),
1495
+ sessionOptions: sessionOptionSelectionsSchema.optional(),
1496
+ providerOptions: jsonObjectSchema
1497
+ });
1498
+ var runtimeThreadExecutionOptionsSchema = runtimeThreadExecutionBaseOptionsSchema.and(runtimePermissionPolicySchema);
1499
+ var projectExecutionDefaultsSchema = z2.object({
1500
+ providerId: z2.string().min(1),
1501
+ model: z2.string().min(1),
1502
+ serviceTier: serviceTierSchema,
1503
+ reasoningLevel: reasoningLevelSchema,
1504
+ permissionMode: permissionModeSchema
1505
+ });
1506
+
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
+ // ../domain/src/change-kinds.ts
1607
+ import { z as z18 } from "zod";
1608
+
1609
+ // ../domain/src/thread-event-types.ts
1610
+ import { z as z4 } from "zod";
1611
+ var systemEventTypeValues = [
1612
+ "client/thread/start",
1613
+ "client/turn/requested",
1614
+ "client/turn/rejected",
1615
+ "client/turn/start",
1616
+ "system/error",
1617
+ "system/manager/user_message",
1618
+ "system/thread/interrupted",
1619
+ "system/operation",
1620
+ "system/interaction/lifecycle",
1621
+ "system/permissionGrant/lifecycle",
1622
+ "system/userQuestion/lifecycle",
1623
+ "system/thread-provisioning",
1624
+ "system/provider-turn-watchdog"
1625
+ ];
1626
+ var providerEventTypeValues = [
1627
+ "thread/started",
1628
+ "thread/identity",
1629
+ "turn/started",
1630
+ "turn/completed",
1631
+ "turn/input/accepted",
1632
+ "thread/name/updated",
1633
+ "thread/compacted",
1634
+ "thread/context/cleared",
1635
+ "thread/goal/updated",
1636
+ "thread/goal/cleared",
1637
+ "item/started",
1638
+ "item/completed",
1639
+ "item/agentMessage/delta",
1640
+ "item/commandExecution/outputDelta",
1641
+ "item/fileChange/outputDelta",
1642
+ "item/reasoning/summaryTextDelta",
1643
+ "item/reasoning/textDelta",
1644
+ "item/plan/delta",
1645
+ "item/mcpToolCall/progress",
1646
+ "item/toolCall/progress",
1647
+ "item/backgroundTask/progress",
1648
+ "item/backgroundTask/completed",
1649
+ "item/delegation/progress",
1650
+ "item/delegation/completed",
1651
+ "thread/tokenUsage/updated",
1652
+ "thread/contextWindowUsage/updated",
1653
+ "turn/plan/updated",
1654
+ "turn/mainRun/updated",
1655
+ "turn/diff/updated",
1656
+ "provider/error",
1657
+ "provider/rateLimits/updated",
1658
+ "provider.env-resolved",
1659
+ "thread/extensionState/updated",
1660
+ "provider/warning",
1661
+ "provider/modelFallback",
1662
+ "provider/unhandled"
1663
+ ];
1664
+ var threadEventTypeValues = [
1665
+ ...providerEventTypeValues,
1666
+ ...systemEventTypeValues
1667
+ ];
1668
+ var threadEventTypeSet = new Set(threadEventTypeValues);
1669
+ var threadEventTypeSchema = z4.string().refine(
1670
+ (value) => threadEventTypeSet.has(value),
1671
+ "Invalid thread event type"
1672
+ );
1673
+
1674
+ // ../domain/src/thread.ts
1675
+ import { z as z17 } from "zod";
1676
+
1677
+ // ../domain/src/thread-create-origin.ts
1678
+ import { z as z5 } from "zod";
1679
+ var threadCreateOriginValues = ["app", "cli", "sdk", "plugin"];
1680
+ var threadCreateOriginSchema = z5.enum(threadCreateOriginValues);
1681
+
1682
+ // ../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),
1689
+ inputs: jsonValueSchema.nullable()
1690
+ })
1691
+ ]);
1692
+ var environmentProviderSelectionSchema = z6.object({
1693
+ machine: environmentMachineSelectionSchema,
1694
+ inputs: jsonValueSchema.nullable()
1695
+ });
1696
+ var environmentStatusValues = [
1697
+ "creating",
1698
+ "provisioning",
1699
+ "ready",
1700
+ "error",
1701
+ "destroyed"
1702
+ ];
1703
+ var environmentStatusSchema = z6.enum(environmentStatusValues);
1704
+ var environmentHostLifecycleValues = [
1705
+ "active",
1706
+ "removing",
1707
+ "cleanup-failed",
1708
+ "removed"
1709
+ ];
1710
+ var environmentHostLifecycleSchema = z6.enum(
1711
+ environmentHostLifecycleValues
1712
+ );
1713
+ var WORKSPACE_PROVISION_TYPES = [
1714
+ "unmanaged",
1715
+ "managed-worktree",
1716
+ "personal"
1717
+ ];
1718
+ var workspaceProvisionTypeSchema = z6.enum(WORKSPACE_PROVISION_TYPES);
1719
+ var environmentWorkspaceDisplayKindValues = [
1720
+ "managed-worktree",
1721
+ "unmanaged-worktree",
1722
+ "other"
1723
+ ];
1724
+ var environmentWorkspaceDisplayKindSchema = z6.enum(
1725
+ environmentWorkspaceDisplayKindValues
1726
+ );
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()
1733
+ });
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()
1741
+ }).nullable()
1742
+ });
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(),
1755
+ status: environmentStatusSchema,
1756
+ environmentProviderId: z6.string().nullable(),
1757
+ lifecycle: environmentLifecycleSchema,
1758
+ hostLifecycle: environmentHostLifecycleSchema,
1759
+ environmentProviderSelection: environmentProviderSelectionSchema.nullable(),
1760
+ environmentProviderInstanceKey: z6.string().nullable(),
1761
+ managed: z6.boolean(),
1762
+ workspaceProvisionType: workspaceProvisionTypeSchema.nullable(),
1763
+ createdAt: z6.number(),
1764
+ updatedAt: z6.number()
1765
+ });
1766
+
1767
+ // ../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);
1773
+
1774
+ // ../domain/src/protocol-ids.ts
1775
+ import { z as z8 } from "zod";
1776
+ var clientTurnRequestIdSchema = z8.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
1777
+
1778
+ // ../domain/src/system-message.ts
1779
+ import { z as z9 } from "zod";
1780
+ var systemMessageKindValues = [
1781
+ "ownership-assigned",
1782
+ "ownership-removed",
1783
+ "child-needs-attention",
1784
+ "child-completed",
1785
+ "child-failed",
1786
+ "child-interrupted",
1787
+ "child-outcome-batch",
1788
+ "tool-result-delivered",
1789
+ "environment-directory-updated",
1790
+ "unlabeled"
1791
+ ];
1792
+ var systemMessageKindSchema = z9.enum(systemMessageKindValues);
1793
+ var systemThreadInterruptedReasonSchema = z9.enum([
1794
+ "manual-stop",
1795
+ "host-daemon-restarted",
1796
+ "host-removed",
1797
+ "provider-turn-idle"
1798
+ ]);
1799
+ var childThreadOutcomeSchema = z9.object({
1800
+ threadId: z9.string(),
1801
+ status: z9.enum(["completed", "failed", "interrupted"]),
1802
+ interruption: z9.object({
1803
+ reason: systemThreadInterruptedReasonSchema,
1804
+ cause: z9.literal("host-connection-lost").optional()
1805
+ }).optional()
1806
+ });
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()
1813
+ }),
1814
+ z9.object({
1815
+ kind: z9.literal("thread-batch"),
1816
+ count: z9.number(),
1817
+ outcomes: z9.array(childThreadOutcomeSchema).optional()
1818
+ }),
1819
+ z9.object({
1820
+ kind: z9.literal("tool-call"),
1821
+ toolName: z9.string(),
1822
+ suppress: z9.boolean()
1823
+ }),
1824
+ z9.object({
1825
+ kind: z9.literal("directory"),
1826
+ path: z9.string()
1827
+ })
1828
+ ]);
1829
+
1830
+ // ../domain/src/queued-message.ts
1831
+ var queuedMessageWaitingOnKindValues = [
1832
+ "time",
1833
+ "thread-busy",
1834
+ "stopping",
1835
+ "turn-starting",
1836
+ "provisioning",
1837
+ "host-offline",
1838
+ "interaction",
1839
+ "plugin"
1840
+ ];
1841
+ var queuedMessageWaitingOnKindSchema = z10.enum(
1842
+ queuedMessageWaitingOnKindValues
1843
+ );
1844
+ var queuedMessageWaitHostNameSchema = z10.string().min(1).max(200);
1845
+ 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"),
1855
+ hostName: queuedMessageWaitHostNameSchema
1856
+ }),
1857
+ z10.object({ kind: z10.literal("interaction") }),
1858
+ z10.object({
1859
+ kind: z10.literal("plugin"),
1860
+ pluginId: pluginIdSchema,
1861
+ reason: queuedMessageWaitReasonSchema
1862
+ })
1863
+ ]);
1864
+ var QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH = 200;
1865
+ var queuedMessageFailureReasonSchema = z10.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
1866
+ var QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX = "plugin:";
1867
+ var queuedMessageWaitHolderSchema = z10.templateLiteral([
1868
+ QUEUED_MESSAGE_PLUGIN_WAIT_HOLDER_PREFIX,
1869
+ pluginIdSchema
1870
+ ]);
1871
+ var queuedMessagePayloadKindValues = ["inline", "retry"];
1872
+ var queuedMessagePayloadKindSchema = z10.enum(
1873
+ queuedMessagePayloadKindValues
1874
+ );
1875
+ var queuedMessagePayloadSchema = z10.discriminatedUnion("kind", [
1876
+ z10.object({ kind: z10.literal("inline") }),
1877
+ z10.object({
1878
+ kind: z10.literal("retry"),
1879
+ /**
1880
+ * The ORIGINAL request, not the attempt that just failed. Retrying a retry
1881
+ * re-submits the same original blocks, so this id is carried forward
1882
+ * unchanged across attempts and `attempt` is what distinguishes them.
1883
+ */
1884
+ retryOfTurnRequestId: clientTurnRequestIdSchema,
1885
+ /** Which attempt this row will dispatch: 2 is the first retry. */
1886
+ attempt: z10.number().int().min(2),
1887
+ /**
1888
+ * Why this turn is being retried, in the retrier's words ("Rate limited"),
1889
+ * as the row's card and `bb thread queue list` render it.
1890
+ *
1891
+ * It lives on the payload rather than on `waitingOn` because a retry can
1892
+ * wait on the clock, on a limiter, or on nothing at all, and the reason
1893
+ * outlives all three: it is a fact about the retry, not about what is
1894
+ * currently holding it. Filled at the boundary, so every row has one.
1895
+ */
1896
+ reason: queuedMessageWaitReasonSchema
1897
+ })
1898
+ ]);
1899
+ var queuedMessageSystemNoticeSchema = z10.object({
1900
+ kind: systemMessageKindSchema,
1901
+ subject: systemMessageSubjectSchema.nullable()
1902
+ });
1903
+
1904
+ // ../domain/src/queued-message-lifecycle.ts
1905
+ import { z as z11 } from "zod";
1906
+ var queuedMessageStateValues = [
1907
+ "queued",
1908
+ "scheduled",
1909
+ "waiting",
1910
+ "failed_retrying",
1911
+ "failed_exhausted",
1912
+ "claimed"
1913
+ ];
1914
+ var queuedMessageStateSchema = z11.enum(queuedMessageStateValues);
1915
+
1916
+ // ../domain/src/thread-status.ts
1917
+ import { z as z12 } from "zod";
1918
+ var threadStatusValues = [
1919
+ "pending",
1920
+ "idle",
1921
+ "starting",
1922
+ "active",
1923
+ "stopping",
1924
+ "error"
1925
+ ];
1926
+ var threadStatusSchema = z12.enum(threadStatusValues);
1927
+
1928
+ // ../domain/src/thread-origin-kind.ts
1929
+ import { z as z13 } from "zod";
1930
+ var threadOriginKindValues = ["fork"];
1931
+ var threadOriginKindSchema = z13.enum(threadOriginKindValues);
1932
+
1933
+ // ../domain/src/thread-parent-notifications.ts
1934
+ import { z as z14 } from "zod";
1935
+ var threadParentNotificationsValues = [
1936
+ "auto",
1937
+ "stuck",
1938
+ "off"
1939
+ ];
1940
+ var threadParentNotificationsSchema = z14.enum(
1941
+ threadParentNotificationsValues
1942
+ );
1943
+
1944
+ // ../domain/src/thread-visibility.ts
1945
+ import { z as z15 } from "zod";
1946
+ var threadVisibilityValues = ["visible", "hidden"];
1947
+ var threadVisibilitySchema = z15.enum(threadVisibilityValues);
1948
+
1949
+ // ../domain/src/thread-runtime-state.ts
1950
+ import { z as z16 } from "zod";
1951
+ var threadRuntimeDisplayStatusValues = [
1952
+ ...threadStatusValues,
1953
+ "provisioning",
1954
+ "waiting-for-host"
1955
+ ];
1956
+ var threadRuntimeDisplayStatusSchema = z16.enum(
1957
+ threadRuntimeDisplayStatusValues
1958
+ );
1959
+ var threadRuntimeStateSchema = z16.object({
1960
+ displayStatus: threadRuntimeDisplayStatusSchema
1961
+ });
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()
1968
+ });
1969
+
1970
+ // ../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(),
2034
+ origin: threadCreateOriginSchema.nullable(),
2035
+ originPluginId: z17.string().nullable(),
2036
+ initiator: z17.enum(["user", "agent", "system"]),
2037
+ senderThreadId: z17.string().nullable(),
2038
+ /**
2039
+ * The thread this row is waiting on. Redundant on the thread-scoped list
2040
+ * route that first served this DTO, and load-bearing everywhere else it is
2041
+ * now served: a `queue.*` plugin event and a cross-thread wait-holder query
2042
+ * both hand out rows with no surrounding thread to read it from.
2043
+ */
2044
+ threadId: z17.string(),
2045
+ content: z17.array(promptInputSchema).min(1),
2046
+ model: z17.string().min(1),
2047
+ reasoningLevel: reasoningLevelSchema,
2048
+ permissionMode: permissionModeSchema,
2049
+ serviceTier: serviceTierSchema,
2050
+ groupWithNext: z17.boolean(),
2051
+ /**
2052
+ * Epoch ms this row is scheduled to attempt dispatch, or null when it is
2053
+ * eligible as soon as its other waits clear.
2054
+ */
2055
+ sendAt: z17.number().int().nonnegative().nullable(),
2056
+ state: queuedMessageStateSchema,
2057
+ /**
2058
+ * Why this row is queued, or null for a `queued` row that is simply next in
2059
+ * line behind the running turn.
2060
+ */
2061
+ waitingOn: queuedMessageWaitingOnSchema.nullable(),
2062
+ /**
2063
+ * Why this row's last DRAIN attempt failed outright, or null when it has not
2064
+ * failed one — which is every row that has never been re-attempted, and
2065
+ * every row whose latest attempt merely queued again. An inline attempt
2066
+ * reports its failure to the sender that is still listening and never lands
2067
+ * here.
2068
+ *
2069
+ * Independent of `waitingOn`, not folded into it: the row is still waiting on
2070
+ * whatever it was waiting on, and writing a wait rewrites it wholesale, so a
2071
+ * failure stored there would not survive the next attempt.
2072
+ */
2073
+ failureReason: queuedMessageFailureReasonSchema.nullable(),
2074
+ payload: queuedMessagePayloadSchema,
2075
+ /**
2076
+ * Whether the sender may still rewrite this row's input. Not derivable from
2077
+ * `payload` alone: a `retry` row is never editable, and an `inline` row
2078
+ * stops being editable once the drain has claimed it — and the claim is
2079
+ * deliberately not part of this response, since it is drain bookkeeping and
2080
+ * not something a client should reason about. The server folds both into
2081
+ * this one answer.
2082
+ */
2083
+ editable: z17.boolean(),
2084
+ createdAt: z17.number(),
2085
+ updatedAt: z17.number()
2086
+ });
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(),
2095
+ status: threadStatusSchema,
2096
+ parentThreadId: z17.string().nullable(),
2097
+ lifecycleOwnerThreadId: z17.string().nullable(),
2098
+ sourceThreadId: z17.string().nullable(),
2099
+ originKind: threadOriginKindSchema.nullable(),
2100
+ originPluginId: z17.string().nullable(),
2101
+ visibility: threadVisibilitySchema,
2102
+ 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()
2110
+ });
2111
+ var threadWithRuntimeSchema = threadSchema.extend({
2112
+ runtime: threadRuntimeStateSchema
2113
+ });
2114
+ var threadQueuedWorkValues = ["none", "waiting", "failed"];
2115
+ var threadQueuedWorkSchema = z17.enum(threadQueuedWorkValues);
2116
+ var threadListEntrySchema = threadWithRuntimeSchema.extend({
2117
+ activity: threadActivityStateSchema,
2118
+ 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(),
2127
+ environmentWorkspaceDisplayKind: environmentWorkspaceDisplayKindSchema
2128
+ });
2129
+
2130
+ // ../domain/src/change-kinds.ts
2131
+ var THREAD_CHANGE_KINDS = [
2132
+ "thread-created",
2133
+ "thread-deleted",
2134
+ "events-appended",
2135
+ "history-rewritten",
2136
+ "history-compacted",
2137
+ "interactions-changed",
2138
+ "status-changed",
2139
+ "title-changed",
2140
+ "queue-changed",
2141
+ "archived-changed",
2142
+ "pin-state-changed",
2143
+ "parent-changed",
2144
+ "environment-changed",
2145
+ "read-state-changed",
2146
+ "tabs-changed",
2147
+ "terminals-changed"
2148
+ ];
2149
+ var PROJECT_CHANGE_KINDS = [
2150
+ "project-created",
2151
+ "project-updated",
2152
+ "project-deleted",
2153
+ "project-sources-changed",
2154
+ "threads-changed",
2155
+ "project-order-changed"
2156
+ ];
2157
+ var ENVIRONMENT_CHANGE_KINDS = [
2158
+ "environment-created",
2159
+ "environment-deleted",
2160
+ "metadata-changed",
2161
+ "status-changed",
2162
+ "work-status-changed",
2163
+ "git-refs-changed",
2164
+ "thread-storage-changed",
2165
+ "diff-viewed-changed"
2166
+ ];
2167
+ var HOST_CHANGE_KINDS = [
2168
+ "host-connected",
2169
+ "host-disconnected",
2170
+ "provider-model-catalog-changed"
2171
+ ];
2172
+ var SYSTEM_CHANGE_KINDS = [
2173
+ "config-changed",
2174
+ "plugins-changed",
2175
+ "plugin-install-jobs-changed",
2176
+ "plugin-update-jobs-changed",
2177
+ "provider-registrations-changed",
2178
+ "environment-availability-changed",
2179
+ "server-move-changed",
2180
+ "app-update-changed"
2181
+ ];
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()
2192
+ }).strict();
2193
+ function canonicalPluginReadInput(value) {
2194
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
2195
+ if (Array.isArray(value))
2196
+ return `[${value.map(canonicalPluginReadInput).join(",")}]`;
2197
+ return `{${Object.keys(value).sort().map(
2198
+ (key) => `${JSON.stringify(key)}:${canonicalPluginReadInput(value[key])}`
2199
+ ).join(",")}}`;
2200
+ }
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()
2208
+ ]).refine(
2209
+ (read) => new TextEncoder().encode(canonicalPluginReadInput(read)).byteLength <= 16384,
2210
+ "Plugin read input exceeds 16 KiB"
2211
+ )
2212
+ }).strict();
2213
+ var realtimeSubscriptionTargetSchema = z18.discriminatedUnion("kind", [
2214
+ 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)
2219
+ }).strict(),
2220
+ threadTimelineSubscriptionTargetSchema,
2221
+ z18.object({
2222
+ kind: z18.literal("thread-list")
2223
+ }).strict(),
2224
+ z18.object({
2225
+ kind: z18.literal("project-detail"),
2226
+ projectId: z18.string().min(1)
2227
+ }).strict(),
2228
+ z18.object({
2229
+ kind: z18.literal("project-list")
2230
+ }).strict(),
2231
+ z18.object({
2232
+ kind: z18.literal("environment-detail"),
2233
+ environmentId: z18.string().min(1)
2234
+ }).strict(),
2235
+ z18.object({
2236
+ kind: z18.literal("environment-list")
2237
+ }).strict(),
2238
+ z18.object({
2239
+ kind: z18.literal("host-detail"),
2240
+ hostId: z18.string().min(1)
2241
+ }).strict(),
2242
+ z18.object({
2243
+ kind: z18.literal("host-list")
2244
+ }).strict(),
2245
+ z18.object({
2246
+ kind: z18.literal("system")
2247
+ }).strict()
2248
+ ]);
2249
+ function isValidSubscriptionTarget(value) {
2250
+ return realtimeSubscriptionTargetSchema.safeParse(value).success;
2251
+ }
2252
+ var validSubscriptionTargetsSchema = z18.preprocess(
2253
+ (value) => Array.isArray(value) ? value.filter(isValidSubscriptionTarget) : value,
2254
+ z18.array(realtimeSubscriptionTargetSchema)
2255
+ );
2256
+ var validSubscriptionTargetSchema = z18.preprocess(
2257
+ (value) => value === void 0 || isValidSubscriptionTarget(value) ? value : null,
2258
+ realtimeSubscriptionTargetSchema.nullable().optional()
2259
+ );
2260
+ var subscriptionFields = {
2261
+ target: validSubscriptionTargetSchema,
2262
+ targets: validSubscriptionTargetsSchema.optional()
2263
+ };
2264
+ 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")
2269
+ });
2270
+ var visibilityMessageSchema = z18.object({
2271
+ type: z18.literal("visibility"),
2272
+ visible: z18.boolean()
2273
+ });
2274
+ var clientMessageSchema = z18.discriminatedUnion("type", [
2275
+ subscribeMessageSchema,
2276
+ unsubscribeMessageSchema,
2277
+ pingMessageSchema,
2278
+ visibilityMessageSchema
2279
+ ]);
2280
+ var pongMessageSchema = z18.object({
2281
+ type: z18.literal("pong")
2282
+ }).strict();
2283
+ var pongMessageLenientSchema = z18.object({
2284
+ type: z18.literal("pong")
2285
+ });
2286
+ var threadStatusChangeMetadataSchema = z18.object({
2287
+ status: threadStatusSchema,
2288
+ runtime: threadRuntimeStateSchema,
2289
+ activity: threadActivityStateSchema,
2290
+ latestAttentionAt: z18.number(),
2291
+ updatedAt: z18.number()
2292
+ }).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(),
2299
+ statusChange: threadStatusChangeMetadataSchema.optional()
2300
+ }).strict();
2301
+ var threadChangedMessageSchema = z18.object({
2302
+ type: z18.literal("changed"),
2303
+ entity: z18.literal("thread"),
2304
+ id: z18.string().optional(),
2305
+ metadata: threadChangeMetadataSchema.optional(),
2306
+ changes: z18.array(threadChangeKindSchema).readonly()
2307
+ }).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()
2313
+ }).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()
2319
+ }).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()
2325
+ }).strict();
2326
+ var systemChangedMessageSchema = z18.object({
2327
+ type: z18.literal("changed"),
2328
+ entity: z18.literal("system"),
2329
+ changes: z18.array(systemChangeKindSchema).readonly()
2330
+ }).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)
2335
+ }).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()
2341
+ }).strict();
2342
+ var changedMessageSchema = z18.discriminatedUnion("entity", [
2343
+ threadChangedMessageSchema,
2344
+ projectChangedMessageSchema,
2345
+ environmentChangedMessageSchema,
2346
+ hostChangedMessageSchema,
2347
+ systemChangedMessageSchema,
2348
+ tagsChangedMessageSchema,
2349
+ pluginChangedMessageSchema
2350
+ ]);
2351
+ function lenientKinds(kinds) {
2352
+ const known = new Set(kinds);
2353
+ return z18.array(z18.string()).transform(
2354
+ (values) => values.filter((value) => known.has(value))
2355
+ );
2356
+ }
2357
+ var knownThreadEventTypes = new Set(
2358
+ threadEventTypeValues
2359
+ );
2360
+ var threadChangeMetadataLenientSchema = z18.object({
2361
+ timelineSequence: z18.number().int().nonnegative().optional(),
2362
+ backgroundActivityChanged: z18.boolean().optional(),
2363
+ eventTypes: z18.array(z18.string()).transform(
2364
+ (values) => values.filter(
2365
+ (value) => knownThreadEventTypes.has(value)
2366
+ )
2367
+ ).optional(),
2368
+ hasPendingInteraction: z18.boolean().optional(),
2369
+ projectId: z18.string().optional(),
2370
+ statusChange: threadStatusChangeMetadataSchema.optional().catch(void 0)
2371
+ });
2372
+ var threadChangedMessageLenientSchema = z18.object({
2373
+ type: z18.literal("changed"),
2374
+ entity: z18.literal("thread"),
2375
+ id: z18.string().optional(),
2376
+ metadata: threadChangeMetadataLenientSchema.optional(),
2377
+ changes: lenientKinds(THREAD_CHANGE_KINDS)
2378
+ });
2379
+ var projectChangedMessageLenientSchema = z18.object({
2380
+ type: z18.literal("changed"),
2381
+ entity: z18.literal("project"),
2382
+ id: z18.string().optional(),
2383
+ changes: lenientKinds(PROJECT_CHANGE_KINDS)
2384
+ });
2385
+ var environmentChangedMessageLenientSchema = z18.object({
2386
+ type: z18.literal("changed"),
2387
+ entity: z18.literal("environment"),
2388
+ id: z18.string().optional(),
2389
+ changes: lenientKinds(ENVIRONMENT_CHANGE_KINDS)
2390
+ });
2391
+ var hostChangedMessageLenientSchema = z18.object({
2392
+ type: z18.literal("changed"),
2393
+ entity: z18.literal("host"),
2394
+ id: z18.string().optional(),
2395
+ changes: lenientKinds(HOST_CHANGE_KINDS)
2396
+ });
2397
+ var systemChangedMessageLenientSchema = z18.object({
2398
+ type: z18.literal("changed"),
2399
+ entity: z18.literal("system"),
2400
+ changes: lenientKinds(SYSTEM_CHANGE_KINDS)
2401
+ });
2402
+ var changedMessageLenientSchema = z18.discriminatedUnion("entity", [
2403
+ threadChangedMessageLenientSchema,
2404
+ projectChangedMessageLenientSchema,
2405
+ environmentChangedMessageLenientSchema,
2406
+ hostChangedMessageLenientSchema,
2407
+ systemChangedMessageLenientSchema,
2408
+ tagsChangedMessageSchema.strip(),
2409
+ pluginChangedMessageSchema.strip()
2410
+ ]);
2411
+
1283
2412
  // src/internal/rpc-tags.ts
1284
- import { z as z2 } from "zod";
1285
- var rpcInvalidationTags = z2.array(z2.string().min(1)).min(1);
2413
+ import { z as z19 } from "zod";
2414
+ var rpcInvalidationTags = z19.array(z19.string().min(1)).min(1);
1286
2415
  function rpcResponseTags(declarations, input, output) {
1287
- const tags = z2.array(z2.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
2416
+ const tags = z19.array(z19.string().min(1)).parse(declarations.tags?.(input, output) ?? []);
1288
2417
  const keyTags = {};
1289
2418
  if (declarations.keyTags && typeof output === "object" && output !== null && !Array.isArray(output)) {
1290
2419
  for (const [key, value] of Object.entries(output)) {
1291
- keyTags[key] = z2.array(z2.string().min(1)).parse(declarations.keyTags(key, value));
2420
+ keyTags[key] = z19.array(z19.string().min(1)).parse(declarations.keyTags(key, value));
1292
2421
  }
1293
2422
  }
1294
- const invalidated = z2.array(z2.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
2423
+ const invalidated = z19.array(z19.string().min(1)).parse(declarations.invalidates?.(input, output) ?? []);
1295
2424
  return { tags, keyTags, invalidated };
1296
2425
  }
1297
2426
 
1298
2427
  // src/internal/rpc-query-host.ts
1299
- import { z as z3 } from "zod";
2428
+ import { z as z20 } from "zod";
1300
2429
  var rpcQueryKey = (pluginId, method, input) => [
1301
2430
  "plugin-rpc",
1302
2431
  pluginId,
@@ -1369,6 +2498,15 @@ async function callRpc(host, pluginId, contract, method, input) {
1369
2498
  ...rpcResponseTags(methodContract, parsedInput.value, result.data)
1370
2499
  };
1371
2500
  }
2501
+ function resolvePluginId(host, pluginId) {
2502
+ const resolved = pluginId ?? host.pluginId;
2503
+ if (resolved === null) {
2504
+ throw new Error(
2505
+ "plugin RPC hooks outside a plugin slot component need an explicit pluginId"
2506
+ );
2507
+ }
2508
+ return resolved;
2509
+ }
1372
2510
  var tagsOf = (data) => [
1373
2511
  ...data.tags,
1374
2512
  ...Object.values(data.keyTags).flat()
@@ -1383,10 +2521,17 @@ function createRpcQueryHooks(useHost) {
1383
2521
  }
1384
2522
  const experimental_useRpcQuery = (options) => {
1385
2523
  const host = useHost();
1386
- const pluginId = options.pluginId ?? host.pluginId;
2524
+ const pluginId = resolvePluginId(host, options.pluginId);
1387
2525
  const input = jsonValueSchema.parse(options.input ?? null);
1388
2526
  const queryKey = rpcQueryKey(pluginId, options.method, input);
1389
2527
  useSubscription(host, pluginId, options.enabled ?? true);
2528
+ const watchIdentity = canonicalPluginReadInput(input);
2529
+ useEffect2(() => {
2530
+ if (options.enabled === false) return;
2531
+ return host.watch?.(pluginId, options.method, {
2532
+ input: jsonValueSchema.parse(JSON.parse(watchIdentity))
2533
+ });
2534
+ }, [host, pluginId, options.method, watchIdentity, options.enabled]);
1390
2535
  const query = useTaggedQuery(
1391
2536
  {
1392
2537
  queryKey,
@@ -1398,13 +2543,7 @@ function createRpcQueryHooks(useHost) {
1398
2543
  queryFn: () => runTaggedRead(
1399
2544
  host.queryClient,
1400
2545
  queryKey,
1401
- async () => callRpc(
1402
- host,
1403
- pluginId,
1404
- options.contract,
1405
- options.method,
1406
- input
1407
- )
2546
+ async () => callRpc(host, pluginId, options.contract, options.method, input)
1408
2547
  )
1409
2548
  },
1410
2549
  host.queryClient
@@ -1424,11 +2563,11 @@ function createRpcQueryHooks(useHost) {
1424
2563
  };
1425
2564
  function experimental_useRpcKeyedQuery(options) {
1426
2565
  const host = useHost();
1427
- const pluginId = options.pluginId ?? host.pluginId;
2566
+ const pluginId = resolvePluginId(host, options.pluginId);
1428
2567
  const enabled = options.enabled ?? true;
1429
2568
  const identity = JSON.stringify([...new Set(options.keys)].sort());
1430
2569
  const keys = useMemo2(
1431
- () => z3.array(z3.string()).parse(JSON.parse(identity)),
2570
+ () => z20.array(z20.string()).parse(JSON.parse(identity)),
1432
2571
  [identity]
1433
2572
  );
1434
2573
  let cache = owners.get(host.queryClient);
@@ -1454,7 +2593,7 @@ function createRpcQueryHooks(useHost) {
1454
2593
  );
1455
2594
  return {
1456
2595
  ...response,
1457
- result: z3.record(z3.string(), jsonValueSchema).parse(response.result)
2596
+ result: z20.record(z20.string(), jsonValueSchema).parse(response.result)
1458
2597
  };
1459
2598
  }
1460
2599
  });
@@ -1491,6 +2630,15 @@ function createRpcQueryHooks(useHost) {
1491
2630
  [keys, enabled, selectRows]
1492
2631
  );
1493
2632
  const query = useQuerySelection(subscribe, getSnapshot, select);
2633
+ useEffect2(() => {
2634
+ if (!enabled) return;
2635
+ const releases = keys.map(
2636
+ (key) => host.watch?.(pluginId, options.method, { key })
2637
+ );
2638
+ return () => {
2639
+ releases.forEach((release) => release?.());
2640
+ };
2641
+ }, [host, pluginId, options.method, keys, enabled]);
1494
2642
  const refetch = useCallback2(async () => {
1495
2643
  await current.observer.refetch();
1496
2644
  }, [current]);
@@ -1501,7 +2649,7 @@ function createRpcQueryHooks(useHost) {
1501
2649
  }
1502
2650
  function experimental_useRpcMutation(options) {
1503
2651
  const host = useHost();
1504
- const pluginId = options.pluginId ?? host.pluginId;
2652
+ const pluginId = resolvePluginId(host, options.pluginId);
1505
2653
  const mutation = useTaggedMutation({
1506
2654
  client: host.queryClient,
1507
2655
  invalidate: (tags) => invalidateTags(host.queryClient, pluginTagScope(pluginId), tags),
@@ -1550,18 +2698,12 @@ function createRpcQueryHooks(useHost) {
1550
2698
  }
1551
2699
  function experimental_useRpcRefresh() {
1552
2700
  const host = useHost();
1553
- const isRefreshing = useIsFetching(
1554
- { queryKey: ["plugin-rpc", host.pluginId] },
1555
- host.queryClient
1556
- ) > 0;
2701
+ const pluginId = resolvePluginId(host, void 0);
2702
+ const isRefreshing = useIsFetching({ queryKey: ["plugin-rpc", pluginId] }, host.queryClient) > 0;
1557
2703
  return {
1558
2704
  isRefreshing,
1559
2705
  refresh: () => {
1560
- void invalidateTags(
1561
- host.queryClient,
1562
- pluginTagScope(host.pluginId),
1563
- null
1564
- );
2706
+ void invalidateTags(host.queryClient, pluginTagScope(pluginId), null);
1565
2707
  }
1566
2708
  };
1567
2709
  }
@@ -1577,6 +2719,7 @@ function createRpcQueryHooks(useHost) {
1577
2719
  import * as React from "react";
1578
2720
  import {
1579
2721
  createContext,
2722
+ Fragment,
1580
2723
  useCallback as useCallback3,
1581
2724
  useContext,
1582
2725
  useLayoutEffect,
@@ -1650,71 +2793,71 @@ function reconcileComposerMentions(currentText, nextText, mentions) {
1650
2793
  }
1651
2794
 
1652
2795
  // src/internal/composer-draft-actions.ts
1653
- import { z as z4 } from "zod";
2796
+ import { z as z21 } from "zod";
1654
2797
  var range = {
1655
- from: z4.number().int().nonnegative(),
1656
- to: z4.number().int().nonnegative(),
1657
- label: z4.string()
2798
+ from: z21.number().int().nonnegative(),
2799
+ to: z21.number().int().nonnegative(),
2800
+ label: z21.string()
1658
2801
  };
1659
- var mentionSchema = z4.discriminatedUnion("kind", [
1660
- z4.object({
2802
+ var mentionSchema = z21.discriminatedUnion("kind", [
2803
+ z21.object({
1661
2804
  ...range,
1662
- kind: z4.literal("thread"),
1663
- threadId: z4.string(),
1664
- projectId: z4.string().optional()
2805
+ kind: z21.literal("thread"),
2806
+ threadId: z21.string(),
2807
+ projectId: z21.string().optional()
1665
2808
  }),
1666
- z4.object({ ...range, kind: z4.literal("project"), projectId: z4.string() }),
1667
- z4.object({ ...range, kind: z4.literal("section"), sectionId: z4.string() }),
1668
- z4.object({
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({
1669
2812
  ...range,
1670
- kind: z4.literal("path"),
1671
- path: z4.string(),
1672
- source: z4.enum(["workspace", "thread-storage"]),
1673
- entryKind: z4.enum(["file", "directory"])
2813
+ kind: z21.literal("path"),
2814
+ path: z21.string(),
2815
+ source: z21.enum(["workspace", "thread-storage"]),
2816
+ entryKind: z21.enum(["file", "directory"])
1674
2817
  }),
1675
- z4.object({
2818
+ z21.object({
1676
2819
  ...range,
1677
- kind: z4.literal("command"),
1678
- trigger: z4.enum(["/", "$"]),
1679
- name: z4.string(),
1680
- source: z4.enum(["skill", "command"]),
1681
- origin: z4.enum(["builtin", "project", "user"]),
1682
- argumentHint: z4.string().nullable()
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()
1683
2826
  }),
1684
- z4.object({ ...range, kind: z4.literal("attachment"), path: z4.string() }),
1685
- z4.object({
2827
+ z21.object({ ...range, kind: z21.literal("attachment"), path: z21.string() }),
2828
+ z21.object({
1686
2829
  ...range,
1687
- kind: z4.literal("plugin"),
1688
- pluginId: z4.string(),
1689
- provider: z4.string().min(1).refine((value) => !value.includes(":")),
1690
- id: z4.string(),
1691
- icon: z4.string().nullable().optional()
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()
1692
2835
  })
1693
2836
  ]);
1694
2837
  var attachmentFields = {
1695
- type: z4.enum(["localImage", "localFile"]),
1696
- path: z4.string().min(1),
1697
- name: z4.string(),
1698
- mimeType: z4.string().optional(),
1699
- sizeBytes: z4.number().nonnegative().optional()
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()
1700
2843
  };
1701
- var attachmentsSchema = z4.array(
1702
- z4.union([
1703
- z4.object({
2844
+ var attachmentsSchema = z21.array(
2845
+ z21.union([
2846
+ z21.object({
1704
2847
  ...attachmentFields,
1705
- hostId: z4.string().min(1),
1706
- sourceProjectId: z4.undefined().optional()
2848
+ hostId: z21.string().min(1),
2849
+ sourceProjectId: z21.undefined().optional()
1707
2850
  }),
1708
- z4.object({
2851
+ z21.object({
1709
2852
  ...attachmentFields,
1710
- sourceProjectId: z4.string().min(1).optional(),
1711
- hostId: z4.undefined().optional()
2853
+ sourceProjectId: z21.string().min(1).optional(),
2854
+ hostId: z21.undefined().optional()
1712
2855
  })
1713
2856
  ])
1714
2857
  );
1715
- var replacementSchema = z4.object({
1716
- text: z4.string(),
1717
- mentions: z4.array(mentionSchema),
2858
+ var replacementSchema = z21.object({
2859
+ text: z21.string(),
2860
+ mentions: z21.array(mentionSchema),
1718
2861
  attachments: attachmentsSchema.optional()
1719
2862
  }).superRefine((draft, context) => {
1720
2863
  let end = 0;
@@ -1957,7 +3100,7 @@ function createComposerHandleBinding(key, initial) {
1957
3100
  throw new Error("Pick a time in the future.");
1958
3101
  }
1959
3102
  const errorBefore = editorState().attachmentError;
1960
- await waitForUploads(target());
3103
+ if (editorState().isAttaching) await waitForUploads(target());
1961
3104
  const state = editorState();
1962
3105
  if (state.attachmentError !== null && state.attachmentError !== errorBefore) {
1963
3106
  throw new Error(state.attachmentError);
@@ -2540,6 +3683,20 @@ var experimental_THREAD_ACTION_GROUPS = {
2540
3683
  lifecycle: "4_lifecycle"
2541
3684
  };
2542
3685
 
3686
+ // src/thread-info-groups.ts
3687
+ var experimental_THREAD_INFO_ROW_GROUPS = {
3688
+ thread: "1_thread",
3689
+ environment: "2_environment",
3690
+ git: "3_git",
3691
+ pullRequest: "4_pullRequest",
3692
+ lifecycle: "5_lifecycle"
3693
+ };
3694
+ var experimental_THREAD_INFO_SECTION_GROUPS = {
3695
+ related: "1_related",
3696
+ changes: "2_changes",
3697
+ storage: "3_storage"
3698
+ };
3699
+
2543
3700
  // src/internal/sidebar-footer-runtime.ts
2544
3701
  var sidebarFooterCommandSequence = 0;
2545
3702
  var SidebarFooterItemRuntime = class {
@@ -2590,7 +3747,7 @@ function adaptSidebarFooterAction(registration) {
2590
3747
  var sidebarFooterItemsByRegistrationSet = /* @__PURE__ */ new WeakMap();
2591
3748
 
2592
3749
  // src/internal/plugin-app-registration-collector.ts
2593
- import { z as z5 } from "zod";
3750
+ import { z as z22 } from "zod";
2594
3751
  var CODE_FENCE_LANGUAGE_PATTERN = /^[a-z0-9][a-z0-9+#._-]*$/;
2595
3752
  var SIDEBAR_FOOTER_ACTION_KEYS = /* @__PURE__ */ new Set([
2596
3753
  "id",
@@ -2706,8 +3863,8 @@ function checkStaleNavPanelKeys(kind, registration, onWarning) {
2706
3863
  }
2707
3864
  }
2708
3865
  function createCommandShortcutSchema() {
2709
- return z5.object({
2710
- key: z5.string().min(1).max(32).refine(
3866
+ return z22.object({
3867
+ key: z22.string().min(1).max(32).refine(
2711
3868
  (key) => ![
2712
3869
  "Alt",
2713
3870
  "Control",
@@ -2718,16 +3875,23 @@ function createCommandShortcutSchema() {
2718
3875
  "Unidentified"
2719
3876
  ].includes(key)
2720
3877
  ),
2721
- mod: z5.boolean().default(false),
2722
- meta: z5.boolean().default(false),
2723
- control: z5.boolean().default(false),
2724
- alt: z5.boolean().default(false),
2725
- shift: z5.boolean().default(false)
3878
+ mod: z22.boolean().default(false),
3879
+ meta: z22.boolean().default(false),
3880
+ control: z22.boolean().default(false),
3881
+ alt: z22.boolean().default(false),
3882
+ shift: z22.boolean().default(false)
2726
3883
  }).strict().refine(
2727
3884
  (shortcut) => shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key),
2728
3885
  "Use Command, Control, or Alt with a key, or a function key"
2729
3886
  );
2730
3887
  }
3888
+ function requireOptionalOrder(kind, order2) {
3889
+ if (order2 === void 0) return {};
3890
+ if (!Number.isFinite(order2)) {
3891
+ throw new Error(`${kind}: "order" must be a finite number`);
3892
+ }
3893
+ return { order: order2 };
3894
+ }
2731
3895
  function collectTitledComponent(kind, seen, registration) {
2732
3896
  const id = requireSlotId(kind, registration?.id);
2733
3897
  requireUniqueId(kind, seen, id);
@@ -2769,7 +3933,12 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2769
3933
  settingsSections: [],
2770
3934
  appOverlays: [],
2771
3935
  navPanels: [],
2772
- threadPanelActions: [],
3936
+ tabs: [],
3937
+ get threadPanelActions() {
3938
+ return this.tabs.filter(
3939
+ (tab) => tab.context.kind === "thread" && tab.availability === "action"
3940
+ );
3941
+ },
2773
3942
  newThreadPanelActions: [],
2774
3943
  composerCustomizations: [],
2775
3944
  pendingInteractions: [],
@@ -2778,11 +3947,14 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2778
3947
  threadLists: [],
2779
3948
  experimentalSidebarNavigations: [],
2780
3949
  threadHeaderActions: [],
3950
+ threadInfoRows: [],
3951
+ threadInfoSections: [],
2781
3952
  threadActions: [],
2782
3953
  browserToolbarActions: [],
2783
3954
  fileOpeners: [],
2784
3955
  sourceCodeRenderers: [],
2785
3956
  diffRenderers: [],
3957
+ composers: [],
2786
3958
  messageDirectives: [],
2787
3959
  codeFenceRenderers: [],
2788
3960
  messageActions: [],
@@ -2800,7 +3972,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2800
3972
  settingsSection: /* @__PURE__ */ new Set(),
2801
3973
  appOverlay: /* @__PURE__ */ new Set(),
2802
3974
  navPanel: /* @__PURE__ */ new Set(),
2803
- threadPanelAction: /* @__PURE__ */ new Set(),
3975
+ tab: /* @__PURE__ */ new Set(),
2804
3976
  newThreadPanelAction: /* @__PURE__ */ new Set(),
2805
3977
  composerCustomization: /* @__PURE__ */ new Set(),
2806
3978
  composerPopup: /* @__PURE__ */ new Set(),
@@ -2810,11 +3982,14 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2810
3982
  sidebarNavigation: /* @__PURE__ */ new Set(),
2811
3983
  sidebarHeader: /* @__PURE__ */ new Set(),
2812
3984
  threadHeaderAction: /* @__PURE__ */ new Set(),
3985
+ threadInfoRow: /* @__PURE__ */ new Set(),
3986
+ threadInfoSection: /* @__PURE__ */ new Set(),
2813
3987
  threadAction: /* @__PURE__ */ new Set(),
2814
3988
  browserToolbarAction: /* @__PURE__ */ new Set(),
2815
3989
  fileOpener: /* @__PURE__ */ new Set(),
2816
3990
  sourceCodeRenderer: /* @__PURE__ */ new Set(),
2817
3991
  diffRenderer: /* @__PURE__ */ new Set(),
3992
+ composer: /* @__PURE__ */ new Set(),
2818
3993
  messageDirective: /* @__PURE__ */ new Set(),
2819
3994
  codeFenceRenderer: /* @__PURE__ */ new Set(),
2820
3995
  codeFenceLanguage: /* @__PURE__ */ new Set(),
@@ -2826,6 +4001,54 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2826
4001
  machineProviderInputs: /* @__PURE__ */ new Set(),
2827
4002
  contentScript: /* @__PURE__ */ new Set()
2828
4003
  };
4004
+ function collectTab(value, legacy = false) {
4005
+ const registration = value;
4006
+ const kind = "slots.experimental_tab";
4007
+ const id = requireSlotId(kind, registration?.id);
4008
+ const context = registration.context;
4009
+ if (context?.kind !== "thread" && context?.kind !== "nav-panel") {
4010
+ throw new Error(`${kind}: context must be thread or nav-panel`);
4011
+ }
4012
+ if (context.kind === "nav-panel") requireSlotId(kind, context.panelId);
4013
+ const availability = registration.availability;
4014
+ if (availability !== "fixed" && availability !== "action") {
4015
+ throw new Error(`${kind}: availability must be fixed or action`);
4016
+ }
4017
+ requireUniqueId(
4018
+ kind,
4019
+ seenIds.tab,
4020
+ `${context.kind}/${context.kind === "nav-panel" ? context.panelId : ""}/${id}`
4021
+ );
4022
+ if (registration.useVisible !== void 0 && typeof registration.useVisible !== "function") {
4023
+ throw new Error(`${kind}: useVisible must be a function`);
4024
+ }
4025
+ if (availability === "fixed" && (registration.run !== void 0 || registration.params !== void 0)) {
4026
+ throw new Error(`${kind}: run and params require action availability`);
4027
+ }
4028
+ const target = registration.experimental_target;
4029
+ if (target !== void 0 && (context.kind !== "nav-panel" || availability !== "fixed" || typeof target?.validate !== "function")) {
4030
+ throw new Error(
4031
+ `${kind}: experimental_target requires a nav-panel fixed tab and a validate function`
4032
+ );
4033
+ }
4034
+ const validated = {
4035
+ ...registration,
4036
+ ...collectPanelAction(kind, /* @__PURE__ */ new Set(), {
4037
+ ...registration,
4038
+ icon: legacy && registration.icon === "" ? void 0 : registration.icon
4039
+ }),
4040
+ icon: legacy && registration.icon === "" ? "" : requireNonEmptyString(kind, "icon", registration.icon),
4041
+ ...registration.tooltip === void 0 ? {} : {
4042
+ tooltip: requireNonEmptyString(
4043
+ kind,
4044
+ "tooltip",
4045
+ registration.tooltip
4046
+ )
4047
+ },
4048
+ ...availability === "action" && registration.params !== void 0 ? { params: z22.json().parse(registration.params) } : {}
4049
+ };
4050
+ collected.tabs.push(validated);
4051
+ }
2829
4052
  function collectCommand(kind, registration) {
2830
4053
  const id = requireSlotId(kind, registration?.id);
2831
4054
  requireUniqueId(kind, seenIds.command, id);
@@ -2860,6 +4083,26 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2860
4083
  }
2861
4084
  const legacySidebarHeaders = [];
2862
4085
  const legacySlotAliases = {
4086
+ threadPanelAction(registration) {
4087
+ try {
4088
+ const action = collectPanelAction(
4089
+ "slots.threadPanelAction",
4090
+ /* @__PURE__ */ new Set(),
4091
+ registration
4092
+ );
4093
+ collectTab(
4094
+ {
4095
+ ...action,
4096
+ icon: action.icon ?? "",
4097
+ context: { kind: "thread" },
4098
+ availability: "action"
4099
+ },
4100
+ true
4101
+ );
4102
+ } catch (error) {
4103
+ onWarning(`Legacy threadPanelAction ignored: ${String(error)}`);
4104
+ }
4105
+ },
2863
4106
  experimental_sidebarHeader(registration) {
2864
4107
  legacySidebarHeaders.push(
2865
4108
  collectTitledComponent(
@@ -2947,63 +4190,45 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
2947
4190
  `${kind}: "experimental_usePageTitle" must be a React hook function when set`
2948
4191
  );
2949
4192
  }
2950
- const fixedTabs = (() => {
2951
- if (registration.fixedTabs === void 0) return [];
2952
- if (!Array.isArray(registration.fixedTabs)) {
2953
- throw new Error(`${kind}: "fixedTabs" must be an array when set`);
2954
- }
2955
- const seenFixedTabIds = /* @__PURE__ */ new Set();
2956
- return registration.fixedTabs.map((value, index) => {
2957
- const fixedTabKind = `${kind}.fixedTabs[${index}]`;
2958
- const fixedTab = value;
2959
- const id2 = requireSlotId(fixedTabKind, fixedTab?.id);
2960
- requireUniqueId(fixedTabKind, seenFixedTabIds, id2);
2961
- const layout = fixedTab?.layout;
2962
- if (layout !== void 0 && layout !== "padded" && layout !== "flush") {
2963
- throw new Error(
2964
- `${fixedTabKind}: "layout" must be "padded" or "flush" when set`
2965
- );
2966
- }
2967
- const fixedTabPanelId = requireNonEmptyString(
2968
- fixedTabKind,
2969
- "panelId",
2970
- fixedTab?.panelId
2971
- );
2972
- if (fixedTabPanelId !== panelId) {
2973
- throw new Error(
2974
- `${fixedTabKind}: "panelId" must match its containing navPanel id ${JSON.stringify(panelId)}`
2975
- );
2976
- }
2977
- const experimentalTarget = fixedTab?.experimental_target;
2978
- if (experimentalTarget !== void 0 && (typeof experimentalTarget !== "object" || experimentalTarget === null || typeof Reflect.get(experimentalTarget, "validate") !== "function")) {
2979
- throw new Error(
2980
- `${fixedTabKind}: "experimental_target.validate" must be a function when set`
2981
- );
2982
- }
2983
- return {
4193
+ const legacy = registration;
4194
+ const fixedTabs = [];
4195
+ if (legacy.fixedTabs !== void 0 && !Array.isArray(legacy.fixedTabs)) {
4196
+ onWarning("Legacy navPanel.fixedTabs ignored: expected an array");
4197
+ }
4198
+ for (const value of Array.isArray(legacy.fixedTabs) ? legacy.fixedTabs : []) {
4199
+ try {
4200
+ const id2 = requireSlotId(kind, value?.id);
4201
+ const tab = {
2984
4202
  id: id2,
2985
- panelId: fixedTabPanelId,
2986
- title: requireNonEmptyString(
2987
- fixedTabKind,
2988
- "title",
2989
- fixedTab?.title
2990
- ),
2991
- icon: requireNonEmptyString(fixedTabKind, "icon", fixedTab?.icon),
2992
- component: requireComponent(fixedTabKind, fixedTab?.component),
2993
- ...layout === void 0 ? {} : { layout },
2994
- ...experimentalTarget === void 0 ? {} : {
2995
- experimental_target: experimentalTarget
2996
- }
4203
+ panelId,
4204
+ title: requireNonEmptyString(kind, "title", value.title ?? id2),
4205
+ icon: typeof value.icon === "string" ? value.icon : "",
4206
+ component: requireComponent(kind, value.component),
4207
+ ...value.layout === "flush" ? { layout: "flush" } : {},
4208
+ ...typeof value.experimental_target?.validate === "function" ? { experimental_target: value.experimental_target } : {}
2997
4209
  };
2998
- });
2999
- })();
4210
+ collectTab(
4211
+ {
4212
+ ...tab,
4213
+ context: { kind: "nav-panel", panelId },
4214
+ availability: "fixed"
4215
+ },
4216
+ true
4217
+ );
4218
+ fixedTabs.push(tab);
4219
+ } catch (error) {
4220
+ onWarning(
4221
+ `Legacy navPanel.fixedTabs entry ignored: ${String(error)}`
4222
+ );
4223
+ }
4224
+ }
3000
4225
  collected.navPanels.push({
3001
4226
  id,
3002
4227
  title: requireNonEmptyString(kind, "title", registration.title),
3003
4228
  icon: requireNonEmptyString(kind, "icon", registration.icon),
3004
4229
  path,
4230
+ ...fixedTabs.length === 0 ? {} : { fixedTabs },
3005
4231
  component: requireComponent(kind, registration.component),
3006
- ...fixedTabs.length > 0 ? { fixedTabs } : {},
3007
4232
  ...registration.experimental_useBadge !== void 0 ? {
3008
4233
  experimental_useBadge: registration.experimental_useBadge
3009
4234
  } : {},
@@ -3014,14 +4239,8 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3014
4239
  ...registration.headerContent !== void 0 ? { headerContent: registration.headerContent } : {}
3015
4240
  });
3016
4241
  },
3017
- threadPanelAction(registration) {
3018
- collected.threadPanelActions.push(
3019
- collectPanelAction(
3020
- "slots.threadPanelAction",
3021
- seenIds.threadPanelAction,
3022
- registration
3023
- )
3024
- );
4242
+ experimental_tab(registration) {
4243
+ collectTab(registration);
3025
4244
  },
3026
4245
  experimental_newThreadPanelAction(registration) {
3027
4246
  collected.newThreadPanelActions.push(
@@ -3099,6 +4318,28 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3099
4318
  component: requireComponent(kind, registration.component)
3100
4319
  });
3101
4320
  },
4321
+ experimental_threadInfoRow(registration) {
4322
+ const kind = "slots.experimental_threadInfoRow";
4323
+ const id = requireSlotId(kind, registration?.id);
4324
+ requireUniqueId(kind, seenIds.threadInfoRow, id);
4325
+ collected.threadInfoRows.push({
4326
+ id,
4327
+ group: requireNonEmptyString(kind, "group", registration.group),
4328
+ ...requireOptionalOrder(kind, registration.order),
4329
+ component: requireComponent(kind, registration.component)
4330
+ });
4331
+ },
4332
+ experimental_threadInfoSection(registration) {
4333
+ const kind = "slots.experimental_threadInfoSection";
4334
+ const id = requireSlotId(kind, registration?.id);
4335
+ requireUniqueId(kind, seenIds.threadInfoSection, id);
4336
+ collected.threadInfoSections.push({
4337
+ id,
4338
+ group: requireNonEmptyString(kind, "group", registration.group),
4339
+ ...requireOptionalOrder(kind, registration.order),
4340
+ component: requireComponent(kind, registration.component)
4341
+ });
4342
+ },
3102
4343
  experimental_threadAction(registration) {
3103
4344
  const kind = "slots.experimental_threadAction";
3104
4345
  const id = requireSlotId(kind, registration?.id);
@@ -3109,15 +4350,12 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3109
4350
  if (registration.useData !== void 0 && typeof registration.useData !== "function") {
3110
4351
  throw new Error(`${kind}: "useData" must be a function`);
3111
4352
  }
3112
- if (registration.order !== void 0 && !Number.isFinite(registration.order)) {
3113
- throw new Error(`${kind}: "order" must be a finite number`);
3114
- }
3115
4353
  collected.threadActions.push({
3116
4354
  id,
3117
4355
  title: requireNonEmptyString(kind, "title", registration.title),
3118
4356
  icon: requireNonEmptyString(kind, "icon", registration.icon),
3119
4357
  group: requireNonEmptyString(kind, "group", registration.group),
3120
- ...registration.order !== void 0 ? { order: registration.order } : {},
4358
+ ...requireOptionalOrder(kind, registration.order),
3121
4359
  ...registration.useData !== void 0 ? { useData: registration.useData } : {},
3122
4360
  item: registration.item
3123
4361
  });
@@ -3175,6 +4413,15 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
3175
4413
  )
3176
4414
  );
3177
4415
  },
4416
+ experimental_composer(registration) {
4417
+ collected.composers.push(
4418
+ collectTitledComponent(
4419
+ "slots.experimental_composer",
4420
+ seenIds.composer,
4421
+ registration
4422
+ )
4423
+ );
4424
+ },
3178
4425
  messageDirective(registration) {
3179
4426
  const kind = "slots.messageDirective";
3180
4427
  const id = requireMessageDirectiveId(kind, registration?.id);
@@ -3368,7 +4615,7 @@ function attachLegacySidebarHeaders(navigations, headers, onWarning) {
3368
4615
  }
3369
4616
 
3370
4617
  // src/testing/app.tsx
3371
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4618
+ import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
3372
4619
  function TestSidebarNavigationIcon({
3373
4620
  icon,
3374
4621
  className
@@ -3996,6 +5243,106 @@ function TestPermissionModePicker({
3996
5243
  }
3997
5244
  );
3998
5245
  }
5246
+ function TestComposerRoot(_props) {
5247
+ return null;
5248
+ }
5249
+ function TestComposerPluginActions() {
5250
+ return null;
5251
+ }
5252
+ function TestComposerPluginPopup({
5253
+ contribution
5254
+ }) {
5255
+ return /* @__PURE__ */ jsx(contribution.popup.component, {});
5256
+ }
5257
+ function TestComposerMenuEntry({
5258
+ contribution
5259
+ }) {
5260
+ return /* @__PURE__ */ jsx("div", { role: "menuitem", children: contribution.item.label });
5261
+ }
5262
+ var IDLE_COMPOSER_MENTION_SEARCH = {
5263
+ status: "idle",
5264
+ refreshing: false,
5265
+ groups: [],
5266
+ search: () => {
5267
+ }
5268
+ };
5269
+ var IDLE_COMPOSER_COMMAND_SEARCH = {
5270
+ status: "idle",
5271
+ refreshing: false,
5272
+ groups: [],
5273
+ search: () => {
5274
+ }
5275
+ };
5276
+ var TEST_COMPOSER_CONTRIBUTIONS = {
5277
+ popups: [],
5278
+ plusMenuItems: [],
5279
+ sendMenuItems: [],
5280
+ Actions: TestComposerPluginActions,
5281
+ Popup: TestComposerPluginPopup,
5282
+ MenuEntry: TestComposerMenuEntry
5283
+ };
5284
+ function TestVoiceInputButton({
5285
+ warning: _warning,
5286
+ variant: _variant,
5287
+ size: _size,
5288
+ ...props
5289
+ }) {
5290
+ return /* @__PURE__ */ jsx("button", { ...props });
5291
+ }
5292
+ function TestVoiceRecordingBar({
5293
+ state,
5294
+ onConfirm,
5295
+ onCancel
5296
+ }) {
5297
+ return /* @__PURE__ */ jsxs("div", { "data-voice-recording-state": state, children: [
5298
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onConfirm, children: "Finish voice input" }),
5299
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onCancel, children: "Cancel voice input" })
5300
+ ] });
5301
+ }
5302
+ function TestFailedVoiceRecordings({
5303
+ recordings,
5304
+ className
5305
+ }) {
5306
+ return /* @__PURE__ */ jsx("ul", { className, children: recordings.map((recording) => /* @__PURE__ */ jsx("li", { children: recording.errorMessage }, recording.id)) });
5307
+ }
5308
+ function TestShortcutHint({
5309
+ shortcut,
5310
+ className
5311
+ }) {
5312
+ return shortcut === null ? null : /* @__PURE__ */ jsx("kbd", { className, children: shortcut.label });
5313
+ }
5314
+ function TestImageLightbox({
5315
+ imageSrc,
5316
+ imageAlt,
5317
+ isOpen
5318
+ }) {
5319
+ const visible = isOpen ?? imageSrc !== null;
5320
+ return visible && imageSrc !== null ? /* @__PURE__ */ jsx("img", { alt: imageAlt, src: imageSrc }) : null;
5321
+ }
5322
+ function TestPromptMentionIcon({
5323
+ className
5324
+ }) {
5325
+ return /* @__PURE__ */ jsx("span", { className, "aria-hidden": true });
5326
+ }
5327
+ var TEST_PROMPT_MENTION_ATTRIBUTE = "data-test-prompt-mention";
5328
+ function testPromptMentionClipboardAttributes(mention, text) {
5329
+ return { [TEST_PROMPT_MENTION_ATTRIBUTE]: JSON.stringify({ mention, text }) };
5330
+ }
5331
+ function readTestPromptMentionClipboard(element) {
5332
+ const value = element.getAttribute(TEST_PROMPT_MENTION_ATTRIBUTE);
5333
+ if (value === null) return null;
5334
+ const pill = JSON.parse(value);
5335
+ return pill;
5336
+ }
5337
+ function TestPluginIcon({ className }) {
5338
+ return /* @__PURE__ */ jsx("span", { className, "aria-hidden": true });
5339
+ }
5340
+ function TestThreadTitleText({
5341
+ title,
5342
+ className
5343
+ }) {
5344
+ return /* @__PURE__ */ jsx("span", { className, children: title });
5345
+ }
3999
5346
  function TestVoiceInputTextarea({
4000
5347
  onValueChange,
4001
5348
  onVoiceInputActiveChange: _onVoiceInputActiveChange,
@@ -4051,6 +5398,52 @@ function TestDiff({
4051
5398
  }
4052
5399
  );
4053
5400
  }
5401
+ function TestInfoSection({
5402
+ label,
5403
+ count,
5404
+ accessory,
5405
+ trailing,
5406
+ children
5407
+ }) {
5408
+ return /* @__PURE__ */ jsxs("section", { "aria-label": label, "data-testid": "bb-info-section", children: [
5409
+ /* @__PURE__ */ jsxs("h3", { children: [
5410
+ label,
5411
+ count === void 0 ? null : /* @__PURE__ */ jsx("span", { children: count })
5412
+ ] }),
5413
+ accessory,
5414
+ trailing,
5415
+ children
5416
+ ] });
5417
+ }
5418
+ function TestDetailRow({ label, icon, children }) {
5419
+ return /* @__PURE__ */ jsxs("div", { "data-testid": "bb-detail-row", "data-icon": icon, children: [
5420
+ /* @__PURE__ */ jsx("dt", { children: label }),
5421
+ /* @__PURE__ */ jsx("dd", { children })
5422
+ ] });
5423
+ }
5424
+ function TestInfoList({
5425
+ items,
5426
+ getKey,
5427
+ renderItem,
5428
+ limit
5429
+ }) {
5430
+ return /* @__PURE__ */ jsx("ul", { "data-limit": limit, children: items.map((item) => /* @__PURE__ */ jsx(Fragment, { children: renderItem(item) }, getKey(item))) });
5431
+ }
5432
+ function TestInfoListRow({
5433
+ leading,
5434
+ name,
5435
+ title,
5436
+ context,
5437
+ trailing,
5438
+ onSelect
5439
+ }) {
5440
+ return /* @__PURE__ */ jsxs("li", { children: [
5441
+ leading,
5442
+ onSelect === void 0 ? /* @__PURE__ */ jsx("span", { title, children: name }) : /* @__PURE__ */ jsx("button", { type: "button", title, onClick: onSelect, children: name }),
5443
+ context === void 0 ? null : /* @__PURE__ */ jsx("span", { children: context }),
5444
+ trailing
5445
+ ] });
5446
+ }
4054
5447
  var activeClipboard = null;
4055
5448
  function captureClipboardWrites(result) {
4056
5449
  const writes = [];
@@ -4120,7 +5513,7 @@ var testPluginSdkApp = {
4120
5513
  store.getSnapshot,
4121
5514
  store.getSnapshot
4122
5515
  );
4123
- if (state === null || state.panelId !== tab.panelId || state.tabId !== tab.id || tab.experimental_target === void 0) {
5516
+ if (state === null || state.panelId !== ("context" in tab ? tab.context.panelId : tab.panelId) || state.tabId !== tab.id || tab.experimental_target === void 0) {
4124
5517
  return null;
4125
5518
  }
4126
5519
  try {
@@ -4176,6 +5569,27 @@ var testPluginSdkApp = {
4176
5569
  UrlLink: TestUrlLink,
4177
5570
  experimental_NewThreadComposer: TestNewThreadComposer,
4178
5571
  experimental_VoiceInputTextarea: TestVoiceInputTextarea,
5572
+ experimental_ComposerRoot: TestComposerRoot,
5573
+ experimental_VoiceInputButton: TestVoiceInputButton,
5574
+ experimental_VoiceRecordingBar: TestVoiceRecordingBar,
5575
+ experimental_FailedVoiceRecordings: TestFailedVoiceRecordings,
5576
+ experimental_ShortcutHint: TestShortcutHint,
5577
+ experimental_ImageLightbox: TestImageLightbox,
5578
+ experimental_PromptMentionIcon: TestPromptMentionIcon,
5579
+ experimental_describePromptMention(mention) {
5580
+ return {
5581
+ className: "prompt-mention-pill",
5582
+ title: mention.label,
5583
+ text: `${mention.kind}: ${mention.label}`
5584
+ };
5585
+ },
5586
+ experimental_promptMentionClipboardAttributes: testPromptMentionClipboardAttributes,
5587
+ experimental_readPromptMentionClipboard: readTestPromptMentionClipboard,
5588
+ experimental_PluginIcon: TestPluginIcon,
5589
+ experimental_ThreadTitleText: TestThreadTitleText,
5590
+ experimental_useThreadTitleDisplayText(title) {
5591
+ return title;
5592
+ },
4179
5593
  experimental_ProviderModelPicker: TestProviderModelPicker,
4180
5594
  experimental_PermissionModePicker: TestPermissionModePicker,
4181
5595
  experimental_BranchPicker: TestBranchPicker,
@@ -4187,6 +5601,10 @@ var testPluginSdkApp = {
4187
5601
  },
4188
5602
  experimental_SourceCode: TestSourceCode,
4189
5603
  experimental_Diff: TestDiff,
5604
+ experimental_InfoSection: TestInfoSection,
5605
+ experimental_DetailRow: TestDetailRow,
5606
+ experimental_InfoList: TestInfoList,
5607
+ experimental_InfoListRow: TestInfoListRow,
4190
5608
  experimental_useSidebarThreads() {
4191
5609
  return useSlotEnv("experimental_useSidebarThreads").sidebarThreads;
4192
5610
  },
@@ -4230,6 +5648,8 @@ var testPluginSdkApp = {
4230
5648
  experimental_ThreadActionsContextMenu: TestThreadActionsContextMenu,
4231
5649
  experimental_PluginRpcCallError,
4232
5650
  experimental_THREAD_ACTION_GROUPS,
5651
+ experimental_THREAD_INFO_ROW_GROUPS,
5652
+ experimental_THREAD_INFO_SECTION_GROUPS,
4233
5653
  experimental_useSidebarNavigation() {
4234
5654
  return useSlotEnv("experimental_useSidebarNavigation").sidebarNavigation;
4235
5655
  },
@@ -4301,15 +5721,30 @@ var testPluginSdkApp = {
4301
5721
  useSdk() {
4302
5722
  return useSlotEnv("useSdk").sdk;
4303
5723
  },
4304
- experimental_useSidebarThreadPullRequest(threadId) {
4305
- const env = useSlotEnv("experimental_useSidebarThreadPullRequest");
4306
- return useMemo3(
4307
- () => ({
4308
- isLoading: false,
4309
- pullRequest: env.sidebarPullRequests.get(threadId) ?? null
4310
- }),
4311
- [env, threadId]
4312
- );
5724
+ experimental_useComposerRenderer() {
5725
+ const renderer = useSlotEnv(
5726
+ "experimental_useComposerRenderer"
5727
+ ).composerRenderer;
5728
+ if (renderer === null) {
5729
+ throw new Error(
5730
+ "experimental_useComposerRenderer() is only available inside an experimental_composer component; pass composerRenderer to mount it as one."
5731
+ );
5732
+ }
5733
+ return renderer;
5734
+ },
5735
+ experimental_useComposerContributions() {
5736
+ if (useSlotEnv("experimental_useComposerContributions").composerRenderer === null) {
5737
+ throw new Error(
5738
+ "experimental_useComposerContributions() is only available inside an experimental_composer component; pass composerRenderer to mount it as one."
5739
+ );
5740
+ }
5741
+ return TEST_COMPOSER_CONTRIBUTIONS;
5742
+ },
5743
+ experimental_useComposerMentionSearch() {
5744
+ return IDLE_COMPOSER_MENTION_SEARCH;
5745
+ },
5746
+ experimental_useComposerCommandSearch() {
5747
+ return IDLE_COMPOSER_COMMAND_SEARCH;
4313
5748
  },
4314
5749
  useComposerView() {
4315
5750
  const composer = useSlotEnv("useComposerView").composer;
@@ -4501,7 +5936,9 @@ function renderSlot(registration, props, options = {}) {
4501
5936
  });
4502
5937
  return parsed.value;
4503
5938
  };
4504
- const queryClient = new QueryClient();
5939
+ const queryClient = new QueryClient({
5940
+ defaultOptions: { queries: { retry: false } }
5941
+ });
4505
5942
  const callRpc2 = async (method, input) => {
4506
5943
  const normalizedInput = input === void 0 ? null : strictJsonRoundTrip(input, `rpc "${method}" input`);
4507
5944
  rpcCalls.push({ method, input: normalizedInput });
@@ -4543,6 +5980,7 @@ function renderSlot(registration, props, options = {}) {
4543
5980
  };
4544
5981
  const navigateCalls = [];
4545
5982
  const experimental_fixedTabOpenCalls = [];
5983
+ const experimental_tabOpenCalls = [];
4546
5984
  let fixedTabTargetSnapshot = options.experimental_fixedTabTarget === void 0 ? null : {
4547
5985
  panelId: options.experimental_fixedTabTarget.panelId,
4548
5986
  sequence: 1,
@@ -4565,7 +6003,55 @@ function renderSlot(registration, props, options = {}) {
4565
6003
  for (const listener of fixedTabTargetListeners) listener();
4566
6004
  }
4567
6005
  };
6006
+ function captureFixedTabOpen(surface, panelId, tabId, target) {
6007
+ const call = {
6008
+ surface,
6009
+ ...panelId === void 0 ? {} : { panelId },
6010
+ tabId,
6011
+ ...target === void 0 ? {} : { target }
6012
+ };
6013
+ experimental_fixedTabOpenCalls.push(call);
6014
+ const accepted = options.experimental_openFixedTab?.(call) ?? false;
6015
+ if (accepted && target !== void 0 && panelId !== void 0) {
6016
+ fixedTabTargetSnapshot = {
6017
+ panelId,
6018
+ sequence: (fixedTabTargetSnapshot?.sequence ?? 0) + 1,
6019
+ tabId,
6020
+ target
6021
+ };
6022
+ for (const listener of fixedTabTargetListeners) listener();
6023
+ }
6024
+ return accepted;
6025
+ }
4568
6026
  const appPanel = {
6027
+ experimental_openTab(tabOptions) {
6028
+ experimental_tabOpenCalls.push(tabOptions);
6029
+ if (options.experimental_openTab !== void 0)
6030
+ return options.experimental_openTab(tabOptions);
6031
+ if (tabOptions.tab.availability === "action") {
6032
+ try {
6033
+ const params = tabOptions.params === void 0 ? void 0 : strictJsonRoundTrip(tabOptions.params, "tab params");
6034
+ return navigate.openThreadPanel({
6035
+ actionId: tabOptions.tab.id,
6036
+ ...tabOptions.title === void 0 ? {} : { title: tabOptions.title },
6037
+ ...params === void 0 ? {} : { params }
6038
+ });
6039
+ } catch {
6040
+ return false;
6041
+ }
6042
+ }
6043
+ try {
6044
+ const target = tabOptions.target === void 0 ? void 0 : strictJsonRoundTrip(tabOptions.target, "tab target");
6045
+ return captureFixedTabOpen(
6046
+ tabOptions.surface,
6047
+ tabOptions.tab.context.kind === "nav-panel" ? tabOptions.tab.context.panelId : void 0,
6048
+ tabOptions.tab.id,
6049
+ target
6050
+ );
6051
+ } catch {
6052
+ return false;
6053
+ }
6054
+ },
4569
6055
  openFixedTab(panelOptions) {
4570
6056
  let target;
4571
6057
  if (panelOptions.target !== void 0) {
@@ -4586,24 +6072,26 @@ function renderSlot(registration, props, options = {}) {
4586
6072
  return false;
4587
6073
  }
4588
6074
  }
4589
- const call = {
6075
+ if (panelOptions.tab.panelId === void 0) {
6076
+ if (target !== void 0) return false;
6077
+ return appPanel.experimental_openTab({
6078
+ surface: panelOptions.surface,
6079
+ tab: {
6080
+ id: panelOptions.tab.id,
6081
+ context: { kind: "thread" },
6082
+ availability: "fixed"
6083
+ }
6084
+ });
6085
+ }
6086
+ return appPanel.experimental_openTab({
4590
6087
  surface: panelOptions.surface,
4591
- panelId: panelOptions.tab.panelId,
4592
- tabId: panelOptions.tab.id,
6088
+ tab: {
6089
+ id: panelOptions.tab.id,
6090
+ context: { kind: "nav-panel", panelId: panelOptions.tab.panelId },
6091
+ availability: "fixed"
6092
+ },
4593
6093
  ...target === void 0 ? {} : { target }
4594
- };
4595
- experimental_fixedTabOpenCalls.push(call);
4596
- const accepted = options.experimental_openFixedTab?.(call) ?? false;
4597
- if (accepted && target !== void 0) {
4598
- fixedTabTargetSnapshot = {
4599
- panelId: panelOptions.tab.panelId,
4600
- sequence: (fixedTabTargetSnapshot?.sequence ?? 0) + 1,
4601
- tabId: panelOptions.tab.id,
4602
- target
4603
- };
4604
- for (const listener of fixedTabTargetListeners) listener();
4605
- }
4606
- return accepted;
6094
+ });
4607
6095
  }
4608
6096
  };
4609
6097
  const sidebarActionCalls = [];
@@ -4652,9 +6140,6 @@ function renderSlot(registration, props, options = {}) {
4652
6140
  }
4653
6141
  };
4654
6142
  const environmentArchiveCalls = [];
4655
- const sidebarPullRequests = new Map(
4656
- Object.entries(options.sidebarPullRequests ?? {})
4657
- );
4658
6143
  const sidebarDraftThreadIds = new Set(
4659
6144
  options.sidebarDraftThreadIds ?? []
4660
6145
  );
@@ -5044,6 +6529,7 @@ ${block}
5044
6529
  navigateCalls,
5045
6530
  appPanel,
5046
6531
  experimental_fixedTabOpenCalls,
6532
+ experimental_tabOpenCalls,
5047
6533
  fixedTabTarget,
5048
6534
  composer,
5049
6535
  composerLog,
@@ -5055,11 +6541,11 @@ ${block}
5055
6541
  environmentArchiveCalls,
5056
6542
  threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
5057
6543
  threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
5058
- sidebarPullRequests,
5059
6544
  sidebarDraftThreadIds,
5060
6545
  sidebarRowStatuses,
5061
6546
  sidebarShortcuts,
5062
6547
  sidebarSplitLayout: options.sidebarSplitLayout ?? null,
6548
+ composerRenderer: options.composerRenderer ?? null,
5063
6549
  environmentProviders,
5064
6550
  sdk,
5065
6551
  sdkCalls,
@@ -5097,7 +6583,7 @@ ${block}
5097
6583
  pageTitle = null;
5098
6584
  };
5099
6585
  }, [value]);
5100
- return /* @__PURE__ */ jsx(Fragment, { children });
6586
+ return /* @__PURE__ */ jsx(Fragment2, { children });
5101
6587
  }
5102
6588
  const renderSlotTree = (ui) => /* @__PURE__ */ jsx(SlotEnvContext.Provider, { value: env, children: /* @__PURE__ */ jsx(SlotLifecycleGuard, { onUnmount: releaseComposerOwnership, children: /* @__PURE__ */ jsx(SlotPageTitle, { children: ui }) }) });
5103
6589
  const Component = registration.component;
@@ -5116,7 +6602,15 @@ ${block}
5116
6602
  });
5117
6603
  };
5118
6604
  const setRealtimeConnectionState = async (state) => {
5119
- await act(async () => realtimeConnection.setState(state));
6605
+ await act(async () => {
6606
+ realtimeConnection.setState(state);
6607
+ if (state === "connected")
6608
+ await invalidateTags(
6609
+ queryClient,
6610
+ pluginTagScope(options.pluginId ?? "test-plugin"),
6611
+ null
6612
+ );
6613
+ });
5120
6614
  };
5121
6615
  const setComposerText2 = async (text) => {
5122
6616
  await act(async () => commitComposerText(text));
@@ -5127,13 +6621,9 @@ ${block}
5127
6621
  notifyComposerListeners();
5128
6622
  });
5129
6623
  };
5130
- const experimental_invalidateRpc = async (tags) => {
6624
+ const experimental_invalidateRpc = async (tags, pluginId = options.pluginId ?? "test-plugin") => {
5131
6625
  await act(async () => {
5132
- await invalidateTags(
5133
- queryClient,
5134
- pluginTagScope(rpcQueryHost.pluginId),
5135
- tags
5136
- );
6626
+ await invalidateTags(queryClient, pluginTagScope(pluginId), tags);
5137
6627
  });
5138
6628
  };
5139
6629
  const unmountSlot = () => {
@@ -5152,6 +6642,7 @@ ${block}
5152
6642
  setComposerScope,
5153
6643
  navigateCalls,
5154
6644
  experimental_fixedTabOpenCalls,
6645
+ experimental_tabOpenCalls,
5155
6646
  sidebarActionCalls,
5156
6647
  sidebarNavigationCalls,
5157
6648
  experimental_environmentArchiveCalls: environmentArchiveCalls,
@@ -5172,6 +6663,7 @@ ${block}
5172
6663
  rpcCalls,
5173
6664
  navigateCalls,
5174
6665
  experimental_fixedTabOpenCalls,
6666
+ experimental_tabOpenCalls,
5175
6667
  sidebarActionCalls,
5176
6668
  sidebarNavigationCalls,
5177
6669
  experimental_environmentArchiveCalls: environmentArchiveCalls,