@get-bb/plugin-sdk 0.4.101 → 0.4.104

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.
@@ -25,6 +25,7 @@ function parseNamespacedGlyph(glyph) {
25
25
  // ../domain/src/plugin-cli.ts
26
26
  var RESERVED_BB_CLI_COMMANDS = [
27
27
  "browser",
28
+ "diagnostics",
28
29
  "environment",
29
30
  "file",
30
31
  "guide",
@@ -1705,12 +1706,12 @@ function rejectStaleAgentToolFields(toolName, tool) {
1705
1706
  );
1706
1707
  }
1707
1708
  }
1708
- function parsePluginAgentToolPresentation(toolName, value) {
1709
+ function parsePluginRowPresentation(subject, value) {
1709
1710
  if (value === void 0) {
1710
1711
  return null;
1711
1712
  }
1712
1713
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
1713
- throw new Error(`tool "${toolName}" presentation must be an object`);
1714
+ throw new Error(`${subject} presentation must be an object`);
1714
1715
  }
1715
1716
  const declared = value;
1716
1717
  const presentation = {};
@@ -1718,13 +1719,13 @@ function parsePluginAgentToolPresentation(toolName, value) {
1718
1719
  const label = declared.label;
1719
1720
  if (typeof label !== "object" || label === null || typeof label.pending !== "string" || typeof label.completed !== "string") {
1720
1721
  throw new Error(
1721
- `tool "${toolName}" presentation.label must provide pending and completed strings`
1722
+ `${subject} presentation.label must provide pending and completed strings`
1722
1723
  );
1723
1724
  }
1724
1725
  const { pending, completed } = label;
1725
1726
  if (pending.trim().length === 0 || completed.trim().length === 0 || pending.length > PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS || completed.length > PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS) {
1726
1727
  throw new Error(
1727
- `tool "${toolName}" presentation.label strings must be non-empty and at most ${PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS} characters`
1728
+ `${subject} presentation.label strings must be non-empty and at most ${PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS} characters`
1728
1729
  );
1729
1730
  }
1730
1731
  presentation.label = { pending, completed };
@@ -1732,17 +1733,13 @@ function parsePluginAgentToolPresentation(toolName, value) {
1732
1733
  if (declared.icon !== void 0) {
1733
1734
  const icon = declared.icon;
1734
1735
  if (typeof icon !== "object" || icon === null || typeof icon.glyph !== "string" || icon.glyph.trim().length === 0) {
1735
- throw new Error(
1736
- `tool "${toolName}" presentation.icon must be { glyph: string }`
1737
- );
1736
+ throw new Error(`${subject} presentation.icon must be { glyph: string }`);
1738
1737
  }
1739
1738
  presentation.icon = { glyph: icon.glyph };
1740
1739
  }
1741
1740
  if (declared.suppress !== void 0) {
1742
1741
  if (typeof declared.suppress !== "boolean") {
1743
- throw new Error(
1744
- `tool "${toolName}" presentation.suppress must be a boolean`
1745
- );
1742
+ throw new Error(`${subject} presentation.suppress must be a boolean`);
1746
1743
  }
1747
1744
  presentation.suppress = declared.suppress;
1748
1745
  }
@@ -1750,7 +1747,7 @@ function parsePluginAgentToolPresentation(toolName, value) {
1750
1747
  const tint = declared.tint;
1751
1748
  if (typeof tint !== "object" || tint === null || typeof tint.light !== "string" || typeof tint.dark !== "string") {
1752
1749
  throw new Error(
1753
- `tool "${toolName}" presentation.tint must provide light and dark strings`
1750
+ `${subject} presentation.tint must provide light and dark strings`
1754
1751
  );
1755
1752
  }
1756
1753
  presentation.tint = {
@@ -2333,6 +2330,7 @@ function normalizeCliRegistration(registration, alreadyRegistered) {
2333
2330
  name,
2334
2331
  summary: registration.summary,
2335
2332
  commands: validatedCommands,
2333
+ rendersHelp: registration.rendersHelp === true,
2336
2334
  run: registration.run.bind(registration)
2337
2335
  };
2338
2336
  }
@@ -2361,8 +2359,8 @@ function normalizeAgentToolRegistration(args) {
2361
2359
  `tool "${name}" instructions exceed the ${PLUGIN_AGENT_STATIC_INSTRUCTIONS_MAX_CHARS}-character limit`
2362
2360
  );
2363
2361
  }
2364
- const presentation = parsePluginAgentToolPresentation(
2365
- name,
2362
+ const presentation = parsePluginRowPresentation(
2363
+ `tool "${name}"`,
2366
2364
  tool.presentation
2367
2365
  );
2368
2366
  if (presentation?.icon !== void 0) {
@@ -2490,12 +2488,20 @@ function normalizeInteractionRequest(request) {
2490
2488
  if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 60 * 60 * 1e3) {
2491
2489
  throw new Error("ui.requestInput timeoutMs must be between 1 and 3600000");
2492
2490
  }
2491
+ if (request.describeSubmission !== void 0 && typeof request.describeSubmission !== "function") {
2492
+ throw new Error("ui.requestInput describeSubmission must be a function");
2493
+ }
2493
2494
  return {
2494
2495
  threadId: request.threadId,
2495
2496
  rendererId: request.rendererId,
2496
2497
  title: request.title.trim(),
2497
2498
  payload,
2498
- timeoutMs
2499
+ timeoutMs,
2500
+ presentation: parsePluginRowPresentation(
2501
+ `ui.requestInput form "${request.rendererId}"`,
2502
+ request.presentation
2503
+ ),
2504
+ describeSubmission: request.describeSubmission ?? null
2499
2505
  };
2500
2506
  }
2501
2507
  function validateProviderEnvContribution(label, providerId, resolve, registered) {
@@ -2807,7 +2813,7 @@ export {
2807
2813
  normalizeRpcJsonResult,
2808
2814
  normalizeRpcRegistration,
2809
2815
  normalizeWebSocketRouteRegistration,
2810
- parsePluginAgentToolPresentation,
2816
+ parsePluginRowPresentation,
2811
2817
  pluginCliCollisionWarning,
2812
2818
  pluginHookAlreadyRegisteredMessage,
2813
2819
  providerAlreadyRegisteredMessage,
@@ -1500,7 +1500,8 @@ var userQuestionPendingInteractionPayloadSchema = z10.object({
1500
1500
  var pluginPendingInteractionPayloadSchema = z10.object({
1501
1501
  kind: z10.literal("plugin"),
1502
1502
  title: z10.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH),
1503
- data: jsonValueSchema
1503
+ data: jsonValueSchema,
1504
+ presentation: threadEventItemPresentationSchema.optional()
1504
1505
  });
1505
1506
  var pluginExtensionInteractionRequestPayloadSchema = z10.object({
1506
1507
  kind: extensionKindSchema,
@@ -1551,8 +1552,17 @@ var userQuestionPendingInteractionResolutionSchema = z10.object({
1551
1552
  kind: z10.literal("user_answer"),
1552
1553
  answers: z10.record(z10.string().min(1), pendingInteractionUserAnswerSchema)
1553
1554
  });
1555
+ var pluginInteractionDescriptionSchema = z10.object({
1556
+ title: z10.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH).optional(),
1557
+ detail: z10.string().trim().min(1).max(THREAD_EVENT_ITEM_PRESENTATION_DETAIL_MAX_LENGTH).optional(),
1558
+ payload: jsonValueSchema.refine(
1559
+ (value) => jsonByteLength(value) <= PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES,
1560
+ { message: "Plugin interaction description payload exceeds 64 KiB" }
1561
+ ).optional()
1562
+ });
1554
1563
  var pluginPendingInteractionResolutionSchema = z10.object({
1555
- kind: z10.literal("plugin_submitted")
1564
+ kind: z10.literal("plugin_submitted"),
1565
+ description: pluginInteractionDescriptionSchema.optional()
1556
1566
  });
1557
1567
  var pluginExtensionInteractionResolutionSchema = z10.object({
1558
1568
  kind: z10.literal("request_answer"),
@@ -1703,6 +1713,7 @@ var systemMessageKindValues = [
1703
1713
  "child-failed",
1704
1714
  "child-interrupted",
1705
1715
  "child-outcome-batch",
1716
+ "tool-result-delivered",
1706
1717
  "unlabeled"
1707
1718
  ];
1708
1719
  var systemMessageKindSchema = z12.enum(systemMessageKindValues);
@@ -1715,6 +1726,11 @@ var systemMessageSubjectSchema = z12.discriminatedUnion("kind", [
1715
1726
  z12.object({
1716
1727
  kind: z12.literal("thread-batch"),
1717
1728
  count: z12.number()
1729
+ }),
1730
+ z12.object({
1731
+ kind: z12.literal("tool-call"),
1732
+ toolName: z12.string(),
1733
+ suppress: z12.boolean()
1718
1734
  })
1719
1735
  ]);
1720
1736
 
@@ -595,7 +595,8 @@ var userQuestionPendingInteractionPayloadSchema = z8.object({
595
595
  var pluginPendingInteractionPayloadSchema = z8.object({
596
596
  kind: z8.literal("plugin"),
597
597
  title: z8.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH),
598
- data: jsonValueSchema
598
+ data: jsonValueSchema,
599
+ presentation: threadEventItemPresentationSchema.optional()
599
600
  });
600
601
  var pluginExtensionInteractionRequestPayloadSchema = z8.object({
601
602
  kind: extensionKindSchema,
@@ -643,8 +644,17 @@ var userQuestionPendingInteractionResolutionSchema = z8.object({
643
644
  kind: z8.literal("user_answer"),
644
645
  answers: z8.record(z8.string().min(1), pendingInteractionUserAnswerSchema)
645
646
  });
647
+ var pluginInteractionDescriptionSchema = z8.object({
648
+ title: z8.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH).optional(),
649
+ detail: z8.string().trim().min(1).max(THREAD_EVENT_ITEM_PRESENTATION_DETAIL_MAX_LENGTH).optional(),
650
+ payload: jsonValueSchema.refine(
651
+ (value) => jsonByteLength(value) <= PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES,
652
+ { message: "Plugin interaction description payload exceeds 64 KiB" }
653
+ ).optional()
654
+ });
646
655
  var pluginPendingInteractionResolutionSchema = z8.object({
647
- kind: z8.literal("plugin_submitted")
656
+ kind: z8.literal("plugin_submitted"),
657
+ description: pluginInteractionDescriptionSchema.optional()
648
658
  });
649
659
  var pluginExtensionInteractionResolutionSchema = z8.object({
650
660
  kind: z8.literal("request_answer"),
@@ -792,6 +802,7 @@ var systemMessageKindValues = [
792
802
  "child-failed",
793
803
  "child-interrupted",
794
804
  "child-outcome-batch",
805
+ "tool-result-delivered",
795
806
  "unlabeled"
796
807
  ];
797
808
  var systemMessageKindSchema = z10.enum(systemMessageKindValues);
@@ -804,6 +815,11 @@ var systemMessageSubjectSchema = z10.discriminatedUnion("kind", [
804
815
  z10.object({
805
816
  kind: z10.literal("thread-batch"),
806
817
  count: z10.number()
818
+ }),
819
+ z10.object({
820
+ kind: z10.literal("tool-call"),
821
+ toolName: z10.string(),
822
+ suppress: z10.boolean()
807
823
  })
808
824
  ]);
809
825
 
@@ -2521,7 +2521,8 @@ var userQuestionPendingInteractionPayloadSchema = z12.object({
2521
2521
  var pluginPendingInteractionPayloadSchema = z12.object({
2522
2522
  kind: z12.literal("plugin"),
2523
2523
  title: z12.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH),
2524
- data: jsonValueSchema
2524
+ data: jsonValueSchema,
2525
+ presentation: threadEventItemPresentationSchema.optional()
2525
2526
  });
2526
2527
  var pluginExtensionInteractionRequestPayloadSchema = z12.object({
2527
2528
  kind: extensionKindSchema,
@@ -2575,8 +2576,17 @@ var userQuestionPendingInteractionResolutionSchema = z12.object({
2575
2576
  kind: z12.literal("user_answer"),
2576
2577
  answers: z12.record(z12.string().min(1), pendingInteractionUserAnswerSchema)
2577
2578
  });
2579
+ var pluginInteractionDescriptionSchema = z12.object({
2580
+ title: z12.string().trim().min(1).max(PLUGIN_INTERACTION_MAX_TITLE_LENGTH).optional(),
2581
+ detail: z12.string().trim().min(1).max(THREAD_EVENT_ITEM_PRESENTATION_DETAIL_MAX_LENGTH).optional(),
2582
+ payload: jsonValueSchema.refine(
2583
+ (value) => jsonByteLength(value) <= PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES,
2584
+ { message: "Plugin interaction description payload exceeds 64 KiB" }
2585
+ ).optional()
2586
+ });
2578
2587
  var pluginPendingInteractionResolutionSchema = z12.object({
2579
- kind: z12.literal("plugin_submitted")
2588
+ kind: z12.literal("plugin_submitted"),
2589
+ description: pluginInteractionDescriptionSchema.optional()
2580
2590
  });
2581
2591
  var pluginExtensionInteractionResolutionSchema = z12.object({
2582
2592
  kind: z12.literal("request_answer"),
@@ -2733,6 +2743,7 @@ var systemMessageKindValues = [
2733
2743
  "child-failed",
2734
2744
  "child-interrupted",
2735
2745
  "child-outcome-batch",
2746
+ "tool-result-delivered",
2736
2747
  "unlabeled"
2737
2748
  ];
2738
2749
  var systemMessageKindSchema = z14.enum(systemMessageKindValues);
@@ -2745,6 +2756,11 @@ var systemMessageSubjectSchema = z14.discriminatedUnion("kind", [
2745
2756
  z14.object({
2746
2757
  kind: z14.literal("thread-batch"),
2747
2758
  count: z14.number()
2759
+ }),
2760
+ z14.object({
2761
+ kind: z14.literal("tool-call"),
2762
+ toolName: z14.string(),
2763
+ suppress: z14.boolean()
2748
2764
  })
2749
2765
  ]);
2750
2766
 
@@ -15800,7 +15800,8 @@ function renderSlot(registration, props, options = {}) {
15800
15800
  quotes: [],
15801
15801
  mentions: [],
15802
15802
  focusCount: 0,
15803
- submits: []
15803
+ submits: [],
15804
+ selections: []
15804
15805
  };
15805
15806
  const composerOwnership = { active: true };
15806
15807
  const submissionListeners = /* @__PURE__ */ new Set();
@@ -15885,6 +15886,22 @@ ${block}
15885
15886
  composerLog.submits.push(options2);
15886
15887
  commitComposerText("");
15887
15888
  for (const listener of submissionListeners) listener();
15889
+ },
15890
+ async experimental_setSelection(selection) {
15891
+ if (!composerOwnership.active) {
15892
+ throw new Error("This composer is no longer active.");
15893
+ }
15894
+ if (composerScope.kind === "queued-message" || composerScope.kind === "side-chat") {
15895
+ throw new Error("This composer has no pickers to set.");
15896
+ }
15897
+ const {
15898
+ projectId: _projectId,
15899
+ environment: _environment,
15900
+ ...rest
15901
+ } = selection;
15902
+ const accepted = composerScope.kind === "thread" ? rest : { ...selection };
15903
+ composerLog.selections.push(accepted);
15904
+ return accepted;
15888
15905
  }
15889
15906
  }
15890
15907
  };
@@ -25,6 +25,7 @@ function parseNamespacedGlyph(glyph) {
25
25
  // ../domain/src/plugin-cli.ts
26
26
  var RESERVED_BB_CLI_COMMANDS = [
27
27
  "browser",
28
+ "diagnostics",
28
29
  "environment",
29
30
  "file",
30
31
  "guide",
@@ -1740,12 +1741,12 @@ function rejectStaleAgentToolFields(toolName, tool) {
1740
1741
  );
1741
1742
  }
1742
1743
  }
1743
- function parsePluginAgentToolPresentation(toolName, value) {
1744
+ function parsePluginRowPresentation(subject, value) {
1744
1745
  if (value === void 0) {
1745
1746
  return null;
1746
1747
  }
1747
1748
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
1748
- throw new Error(`tool "${toolName}" presentation must be an object`);
1749
+ throw new Error(`${subject} presentation must be an object`);
1749
1750
  }
1750
1751
  const declared = value;
1751
1752
  const presentation = {};
@@ -1753,13 +1754,13 @@ function parsePluginAgentToolPresentation(toolName, value) {
1753
1754
  const label = declared.label;
1754
1755
  if (typeof label !== "object" || label === null || typeof label.pending !== "string" || typeof label.completed !== "string") {
1755
1756
  throw new Error(
1756
- `tool "${toolName}" presentation.label must provide pending and completed strings`
1757
+ `${subject} presentation.label must provide pending and completed strings`
1757
1758
  );
1758
1759
  }
1759
1760
  const { pending, completed } = label;
1760
1761
  if (pending.trim().length === 0 || completed.trim().length === 0 || pending.length > PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS || completed.length > PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS) {
1761
1762
  throw new Error(
1762
- `tool "${toolName}" presentation.label strings must be non-empty and at most ${PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS} characters`
1763
+ `${subject} presentation.label strings must be non-empty and at most ${PLUGIN_AGENT_STATUS_LABEL_MAX_CHARS} characters`
1763
1764
  );
1764
1765
  }
1765
1766
  presentation.label = { pending, completed };
@@ -1767,17 +1768,13 @@ function parsePluginAgentToolPresentation(toolName, value) {
1767
1768
  if (declared.icon !== void 0) {
1768
1769
  const icon = declared.icon;
1769
1770
  if (typeof icon !== "object" || icon === null || typeof icon.glyph !== "string" || icon.glyph.trim().length === 0) {
1770
- throw new Error(
1771
- `tool "${toolName}" presentation.icon must be { glyph: string }`
1772
- );
1771
+ throw new Error(`${subject} presentation.icon must be { glyph: string }`);
1773
1772
  }
1774
1773
  presentation.icon = { glyph: icon.glyph };
1775
1774
  }
1776
1775
  if (declared.suppress !== void 0) {
1777
1776
  if (typeof declared.suppress !== "boolean") {
1778
- throw new Error(
1779
- `tool "${toolName}" presentation.suppress must be a boolean`
1780
- );
1777
+ throw new Error(`${subject} presentation.suppress must be a boolean`);
1781
1778
  }
1782
1779
  presentation.suppress = declared.suppress;
1783
1780
  }
@@ -1785,7 +1782,7 @@ function parsePluginAgentToolPresentation(toolName, value) {
1785
1782
  const tint = declared.tint;
1786
1783
  if (typeof tint !== "object" || tint === null || typeof tint.light !== "string" || typeof tint.dark !== "string") {
1787
1784
  throw new Error(
1788
- `tool "${toolName}" presentation.tint must provide light and dark strings`
1785
+ `${subject} presentation.tint must provide light and dark strings`
1789
1786
  );
1790
1787
  }
1791
1788
  presentation.tint = {
@@ -2358,6 +2355,7 @@ function normalizeCliRegistration(registration, alreadyRegistered) {
2358
2355
  name,
2359
2356
  summary: registration.summary,
2360
2357
  commands: validatedCommands,
2358
+ rendersHelp: registration.rendersHelp === true,
2361
2359
  run: registration.run.bind(registration)
2362
2360
  };
2363
2361
  }
@@ -2386,8 +2384,8 @@ function normalizeAgentToolRegistration(args) {
2386
2384
  `tool "${name}" instructions exceed the ${PLUGIN_AGENT_STATIC_INSTRUCTIONS_MAX_CHARS}-character limit`
2387
2385
  );
2388
2386
  }
2389
- const presentation = parsePluginAgentToolPresentation(
2390
- name,
2387
+ const presentation = parsePluginRowPresentation(
2388
+ `tool "${name}"`,
2391
2389
  tool.presentation
2392
2390
  );
2393
2391
  if (presentation?.icon !== void 0) {
@@ -2515,12 +2513,20 @@ function normalizeInteractionRequest(request) {
2515
2513
  if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 60 * 60 * 1e3) {
2516
2514
  throw new Error("ui.requestInput timeoutMs must be between 1 and 3600000");
2517
2515
  }
2516
+ if (request.describeSubmission !== void 0 && typeof request.describeSubmission !== "function") {
2517
+ throw new Error("ui.requestInput describeSubmission must be a function");
2518
+ }
2518
2519
  return {
2519
2520
  threadId: request.threadId,
2520
2521
  rendererId: request.rendererId,
2521
2522
  title: request.title.trim(),
2522
2523
  payload,
2523
- timeoutMs
2524
+ timeoutMs,
2525
+ presentation: parsePluginRowPresentation(
2526
+ `ui.requestInput form "${request.rendererId}"`,
2527
+ request.presentation
2528
+ ),
2529
+ describeSubmission: request.describeSubmission ?? null
2524
2530
  };
2525
2531
  }
2526
2532
  function validateProviderEnvContribution(label, providerId, resolve2, registered) {
@@ -3354,8 +3360,13 @@ function createFakePluginHostInternal(options, sharedState) {
3354
3360
  assertLive();
3355
3361
  const normalized = normalizeInteractionRequest(request);
3356
3362
  const normalizedRequest = {
3357
- ...request,
3358
- ...normalized
3363
+ threadId: normalized.threadId,
3364
+ rendererId: normalized.rendererId,
3365
+ title: normalized.title,
3366
+ payload: normalized.payload,
3367
+ timeoutMs: normalized.timeoutMs,
3368
+ ...normalized.presentation === null ? {} : { presentation: normalized.presentation },
3369
+ ...normalized.describeSubmission === null ? {} : { describeSubmission: normalized.describeSubmission }
3359
3370
  };
3360
3371
  const id = `fake-interaction-${nextInteractionId++}`;
3361
3372
  return new Promise((resolve2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.4.101",
3
+ "version": "0.4.104",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"