@get-bb/plugin-sdk 0.6.157 → 0.6.164

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.
package/dist/app.js CHANGED
@@ -384,6 +384,12 @@ var experimental_ImageLightbox = runtimeComponent(
384
384
  var experimental_PromptMentionIcon = runtimeComponent(
385
385
  "experimental_PromptMentionIcon"
386
386
  );
387
+ var experimental_matchesShortcutKey = runtimeFunction(
388
+ "experimental_matchesShortcutKey"
389
+ );
390
+ var experimental_sliceUtf16Head = runtimeFunction(
391
+ "experimental_sliceUtf16Head"
392
+ );
387
393
  var experimental_describePromptMention = runtimeFunction(
388
394
  "experimental_describePromptMention"
389
395
  );
@@ -532,11 +538,13 @@ export {
532
538
  experimental_copyToClipboard,
533
539
  experimental_describePromptMention,
534
540
  experimental_getApplicationLinkApprovals,
541
+ experimental_matchesShortcutKey,
535
542
  experimental_promptMentionClipboardAttributes,
536
543
  experimental_readPromptMentionClipboard,
537
544
  experimental_resolveThreadStatus,
538
545
  experimental_revokeApplicationLinkApproval,
539
546
  experimental_saveFile,
547
+ experimental_sliceUtf16Head,
540
548
  experimental_useAppPanel,
541
549
  experimental_useArchiveEnvironmentThreads,
542
550
  experimental_useBranches,
package/dist/host.js CHANGED
@@ -213,6 +213,30 @@ var providerNativeRootSetSchema = z.object({
213
213
  resolved: providerResolvedNativeRootsSchema
214
214
  }).strict();
215
215
 
216
+ // ../text-utils/src/utf16.ts
217
+ function isHighSurrogateAt(value, index) {
218
+ const code = value.charCodeAt(index);
219
+ return code >= 55296 && code <= 56319;
220
+ }
221
+ function isLowSurrogateAt(value, index) {
222
+ const code = value.charCodeAt(index);
223
+ return code >= 56320 && code <= 57343;
224
+ }
225
+ function sliceUtf16Head(value, maxChars) {
226
+ let end = Math.min(value.length, Math.max(0, maxChars));
227
+ if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
228
+ end -= 1;
229
+ }
230
+ return value.slice(0, end);
231
+ }
232
+ function sliceUtf16Tail(value, maxChars) {
233
+ let start = Math.max(0, value.length - Math.max(0, maxChars));
234
+ if (isHighSurrogateAt(value, start - 1) && isLowSurrogateAt(value, start)) {
235
+ start += 1;
236
+ }
237
+ return value.slice(start);
238
+ }
239
+
216
240
  // src/rpc-contract.ts
217
241
  var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
218
242
  var experimental_PluginRpcRefusal = class extends Error {
@@ -1442,8 +1466,7 @@ function spawnPortableProcess(request) {
1442
1466
  cwd: request.cwd,
1443
1467
  detached: request.detached,
1444
1468
  env: request.env,
1445
- stdio: request.stdio,
1446
- windowsHide: true
1469
+ stdio: request.stdio
1447
1470
  });
1448
1471
  }
1449
1472
  function assertPortableOutputProcess(child) {
@@ -1834,7 +1857,6 @@ async function readWindowsProcess(pid) {
1834
1857
  ],
1835
1858
  {
1836
1859
  encoding: "utf8",
1837
- windowsHide: true,
1838
1860
  timeout: 3e4,
1839
1861
  maxBuffer: 1024 * 1024
1840
1862
  }
@@ -1887,5 +1909,7 @@ export {
1887
1909
  experimental_resolveVendorPluginRoots,
1888
1910
  runVcsProcess as experimental_runVcsProcess,
1889
1911
  sanitizeInheritedChildProcessEnv as experimental_sanitizeInheritedChildProcessEnv,
1912
+ sliceUtf16Head as experimental_sliceUtf16Head,
1913
+ sliceUtf16Tail as experimental_sliceUtf16Tail,
1890
1914
  spawnPortableOutputProcess as experimental_spawnPortableOutputProcess
1891
1915
  };
package/dist/index.js CHANGED
@@ -919,6 +919,23 @@ var experimental_THREAD_INFO_SECTION_GROUPS = {
919
919
  storage: "3_storage"
920
920
  };
921
921
 
922
+ // ../text-utils/src/utf16.ts
923
+ function isHighSurrogateAt(value, index) {
924
+ const code = value.charCodeAt(index);
925
+ return code >= 55296 && code <= 56319;
926
+ }
927
+ function isLowSurrogateAt(value, index) {
928
+ const code = value.charCodeAt(index);
929
+ return code >= 56320 && code <= 57343;
930
+ }
931
+ function sliceUtf16Head(value, maxChars) {
932
+ let end = Math.min(value.length, Math.max(0, maxChars));
933
+ if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
934
+ end -= 1;
935
+ }
936
+ return value.slice(0, end);
937
+ }
938
+
922
939
  // ../domain/src/host-path.ts
923
940
  var WINDOWS_DRIVE_PATH_PATTERN = /^([A-Za-z]):(?:[\\/]+|$)/u;
924
941
  var WINDOWS_UNC_PATH_PATTERN = /^[\\/]{2}([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]+|$)/u;
@@ -1090,5 +1107,6 @@ export {
1090
1107
  isHostPathWithin as experimental_isHostPathWithin,
1091
1108
  joinHostPath as experimental_joinHostPath,
1092
1109
  normalizeHostPath as experimental_normalizeHostPath,
1093
- resolveHostPath as experimental_resolveHostPath
1110
+ resolveHostPath as experimental_resolveHostPath,
1111
+ sliceUtf16Head as experimental_sliceUtf16Head
1094
1112
  };
@@ -287,6 +287,23 @@ var providerNativeRootSetSchema = z4.object({
287
287
  resolved: providerResolvedNativeRootsSchema
288
288
  }).strict();
289
289
 
290
+ // ../text-utils/src/utf16.ts
291
+ function isHighSurrogateAt(value, index) {
292
+ const code = value.charCodeAt(index);
293
+ return code >= 55296 && code <= 56319;
294
+ }
295
+ function isLowSurrogateAt(value, index) {
296
+ const code = value.charCodeAt(index);
297
+ return code >= 56320 && code <= 57343;
298
+ }
299
+ function sliceUtf16Head(value, maxChars) {
300
+ let end = Math.min(value.length, Math.max(0, maxChars));
301
+ if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
302
+ end -= 1;
303
+ }
304
+ return value.slice(0, end);
305
+ }
306
+
290
307
  // src/backend-contract.ts
291
308
  var PLUGIN_CLI_OUTPUT_MAX_BYTES = 32 * 1024 * 1024;
292
309
 
@@ -2147,7 +2164,9 @@ function runPluginStorageMigrations(database, statements) {
2147
2164
  if (!migrationColumns.some((column) => column.name === "statement_hash")) {
2148
2165
  database.exec("ALTER TABLE _bb_migrations ADD COLUMN statement_hash TEXT");
2149
2166
  }
2150
- const rows = database.prepare("SELECT id, statement_hash FROM _bb_migrations ORDER BY id").all();
2167
+ const rows = database.prepare(
2168
+ "SELECT id, statement_hash FROM _bb_migrations ORDER BY id"
2169
+ ).all();
2151
2170
  const applied = /* @__PURE__ */ new Map();
2152
2171
  for (const row of rows) applied.set(row.id, row.statement_hash);
2153
2172
  const statementHashes = statements.map(migrationStatementHash);
@@ -2700,7 +2719,10 @@ function normalizePluginAgentConfiguration(args) {
2700
2719
  if (output.instructions !== void 0 && typeof output.instructions !== "string") {
2701
2720
  throw new Error("configure() output.instructions must be a string");
2702
2721
  }
2703
- const instructions = typeof output.instructions === "string" && output.instructions.trim().length > 0 ? output.instructions.slice(0, PLUGIN_DYNAMIC_INSTRUCTIONS_MAX_CHARS) : null;
2722
+ const instructions = typeof output.instructions === "string" && output.instructions.trim().length > 0 ? sliceUtf16Head(
2723
+ output.instructions,
2724
+ PLUGIN_DYNAMIC_INSTRUCTIONS_MAX_CHARS
2725
+ ) : null;
2704
2726
  const toolSelections = normalizePluginAgentToolSelections({
2705
2727
  knownIds: args.knownToolIds,
2706
2728
  pluginId: args.pluginId,
@@ -439,6 +439,22 @@ function createCommandShortcutSchema() {
439
439
  "Use Command, Control, or Alt with a key, or a function key"
440
440
  );
441
441
  }
442
+ var MESSAGE_ACTION_SURFACES = [
443
+ "thread-view",
444
+ "embedded-chat"
445
+ ];
446
+ function isMessageActionSurface(value) {
447
+ return value === "thread-view" || value === "embedded-chat";
448
+ }
449
+ function collectMessageActionSurfaces(kind, value) {
450
+ if (value === void 0) return MESSAGE_ACTION_SURFACES;
451
+ if (!Array.isArray(value) || value.length === 0 || !value.every(isMessageActionSurface)) {
452
+ throw new Error(
453
+ `${kind}: "experimental_surfaces" must be a non-empty array of "thread-view" or "embedded-chat", got ${JSON.stringify(value)}`
454
+ );
455
+ }
456
+ return MESSAGE_ACTION_SURFACES.filter((surface) => value.includes(surface));
457
+ }
442
458
  function requireOptionalOrder(kind, order) {
443
459
  if (order === void 0) return {};
444
460
  if (!Number.isFinite(order)) {
@@ -1165,6 +1181,10 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
1165
1181
  ...registration.icon !== void 0 ? {
1166
1182
  icon: requireNonEmptyString(kind, "icon", registration.icon)
1167
1183
  } : {},
1184
+ experimental_surfaces: collectMessageActionSurfaces(
1185
+ kind,
1186
+ registration.experimental_surfaces
1187
+ ),
1168
1188
  run: registration.run
1169
1189
  });
1170
1190
  },
@@ -1666,6 +1666,7 @@ var environmentLifecycleSchema = z6.object({
1666
1666
  teardown: z6.object({
1667
1667
  status: z6.enum(["running", "failed", "removed"]),
1668
1668
  attempt: z6.number().int().nonnegative(),
1669
+ needsRecovery: z6.boolean(),
1669
1670
  message: z6.string().optional()
1670
1671
  }).nullable()
1671
1672
  });
@@ -0,0 +1,95 @@
1
+ // src/internal/thread-event-gate.ts
2
+ function fromThread(thread) {
3
+ return { threadId: thread.id, createdAt: thread.createdAt };
4
+ }
5
+ function fromThreadId(threadId) {
6
+ return { threadId, createdAt: null };
7
+ }
8
+ var THREAD_OF_EVENT = {
9
+ "experimental_environment.removed": () => null,
10
+ "experimental_thread.events": ({ thread }) => fromThread(thread),
11
+ "experimental_thread.parentChanged": ({ thread }) => fromThread(thread),
12
+ "experimental_thread.read": ({ thread }) => fromThread(thread),
13
+ "experimental_terminal.input": () => null,
14
+ "experimental_host.deleted": () => null,
15
+ "thread.created": ({ thread }) => fromThread(thread),
16
+ "thread.active": ({ thread }) => fromThread(thread),
17
+ "thread.idle": ({ thread }) => fromThread(thread),
18
+ "thread.failed": ({ thread }) => fromThread(thread),
19
+ "thread.archived": ({ thread }) => fromThread(thread),
20
+ "thread.unarchived": ({ thread }) => fromThread(thread),
21
+ "thread.deleted": ({ thread }) => fromThread(thread),
22
+ "interaction.pending": ({ thread }) => fromThread(thread),
23
+ "message.queued": ({ entry }) => fromThreadId(entry.threadId),
24
+ "message.dispatched": ({ entry }) => fromThreadId(entry.threadId),
25
+ "message.cancelled": ({ entry }) => fromThreadId(entry.threadId),
26
+ "turn.failed": ({ threadId }) => fromThreadId(threadId),
27
+ "experimental_thread.settled": ({ thread }) => fromThread(thread)
28
+ };
29
+ function threadOfEvent(event, payload) {
30
+ const extract = THREAD_OF_EVENT[event];
31
+ return extract(payload);
32
+ }
33
+ function createThreadEventGate(options = {}) {
34
+ const now = options.now ?? Date.now;
35
+ const schedule = options.schedule ?? ((run) => void setImmediate(run));
36
+ const callsStartedAt = /* @__PURE__ */ new Map();
37
+ let held = [];
38
+ function createdDuringCall(createdAt) {
39
+ if (createdAt === null) return false;
40
+ for (const startedAt of callsStartedAt.values()) {
41
+ if (startedAt <= createdAt) return true;
42
+ }
43
+ return false;
44
+ }
45
+ function release() {
46
+ const pending = held;
47
+ held = [];
48
+ const stillHeld = /* @__PURE__ */ new Set();
49
+ for (const entry of pending) {
50
+ if (stillHeld.has(entry.threadId) || createdDuringCall(entry.createdAt)) {
51
+ stillHeld.add(entry.threadId);
52
+ held.push(entry);
53
+ continue;
54
+ }
55
+ entry.deliver();
56
+ }
57
+ }
58
+ return {
59
+ async track(call) {
60
+ const token = /* @__PURE__ */ Symbol("thread-creating-call");
61
+ callsStartedAt.set(token, now());
62
+ try {
63
+ return await call();
64
+ } finally {
65
+ callsStartedAt.delete(token);
66
+ schedule(release);
67
+ }
68
+ },
69
+ deliver(subject, deliver) {
70
+ if (subject === null) {
71
+ deliver();
72
+ return;
73
+ }
74
+ const threadId = subject.threadId;
75
+ if (held.some((entry) => entry.threadId === threadId)) {
76
+ held.push({ threadId, createdAt: null, deliver });
77
+ return;
78
+ }
79
+ if (callsStartedAt.size === 0) {
80
+ deliver();
81
+ return;
82
+ }
83
+ const createdAt = subject.createdAt();
84
+ if (!createdDuringCall(createdAt)) {
85
+ deliver();
86
+ return;
87
+ }
88
+ held.push({ threadId, createdAt, deliver });
89
+ }
90
+ };
91
+ }
92
+ export {
93
+ createThreadEventGate,
94
+ threadOfEvent
95
+ };
package/dist/process.js CHANGED
@@ -600,7 +600,13 @@ function forkHostProcess(modulePath, args = [], options = {}) {
600
600
  );
601
601
  const execPath = options.execPath === void 0 || options.execPath === process.execPath ? hostToolchain.node({ env, cwd: options.cwd }) : options.execPath;
602
602
  return observe(
603
- nodeFork(modulePath, args, { ...options, env, execArgv, execPath })
603
+ nodeFork(modulePath, args, {
604
+ ...options,
605
+ env,
606
+ execArgv,
607
+ execPath,
608
+ windowsHide: options.windowsHide ?? true
609
+ })
604
610
  );
605
611
  }
606
612
  function prepareExecFile(command, args, options) {