@get-bb/plugin-sdk 0.6.16 → 0.6.23

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
@@ -50,6 +50,9 @@ var UrlLink = runtimeComponent("UrlLink");
50
50
  var experimental_NewThreadComposer = runtimeComponent(
51
51
  "experimental_NewThreadComposer"
52
52
  );
53
+ var experimental_VoiceInputTextarea = runtimeComponent(
54
+ "experimental_VoiceInputTextarea"
55
+ );
53
56
  var experimental_ProviderModelPicker = runtimeComponent(
54
57
  "experimental_ProviderModelPicker"
55
58
  );
@@ -154,6 +157,7 @@ export {
154
157
  experimental_ProviderModelPicker,
155
158
  experimental_SidebarNavigationIcon,
156
159
  experimental_SourceCode,
160
+ experimental_VoiceInputTextarea,
157
161
  experimental_useAppPanel,
158
162
  experimental_useBranches,
159
163
  experimental_useCheckoutState,
package/dist/host.js CHANGED
@@ -952,6 +952,11 @@ function sanitizeInheritedChildProcessEnv(args) {
952
952
  import { execFile } from "node:child_process";
953
953
  import { promisify } from "node:util";
954
954
  var execFileAsync = promisify(execFile);
955
+
956
+ // ../process-utils/src/performance-diagnostics.ts
957
+ import { Session } from "node:inspector/promises";
958
+ var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
959
+ var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
955
960
  export {
956
961
  experimental_defineHostEntry,
957
962
  experimental_filterResolvedNativeRoots,
@@ -95,14 +95,26 @@ var mentionSchema = z.discriminatedUnion("kind", [
95
95
  icon: z.string().nullable().optional()
96
96
  })
97
97
  ]);
98
+ var attachmentFields = {
99
+ type: z.enum(["localImage", "localFile"]),
100
+ path: z.string().min(1),
101
+ name: z.string(),
102
+ mimeType: z.string().optional(),
103
+ sizeBytes: z.number().nonnegative().optional()
104
+ };
98
105
  var attachmentsSchema = z.array(
99
- z.object({
100
- type: z.enum(["localImage", "localFile"]),
101
- path: z.string().min(1),
102
- name: z.string(),
103
- mimeType: z.string().optional(),
104
- sizeBytes: z.number().nonnegative()
105
- })
106
+ z.union([
107
+ z.object({
108
+ ...attachmentFields,
109
+ hostId: z.string().min(1),
110
+ sourceProjectId: z.undefined().optional()
111
+ }),
112
+ z.object({
113
+ ...attachmentFields,
114
+ sourceProjectId: z.string().min(1).optional(),
115
+ hostId: z.undefined().optional()
116
+ })
117
+ ])
106
118
  );
107
119
  var replacementSchema = z.object({
108
120
  text: z.string(),
@@ -743,11 +743,15 @@ var promptInputSchema = z3.discriminatedUnion("type", [
743
743
  z3.object({
744
744
  type: z3.literal("localImage"),
745
745
  path: z3.string(),
746
+ sourceProjectId: z3.string().min(1).optional(),
747
+ hostId: z3.string().min(1).optional(),
746
748
  ...promptInputVisibilityFields
747
749
  }),
748
750
  z3.object({
749
751
  type: z3.literal("localFile"),
750
752
  path: z3.string(),
753
+ sourceProjectId: z3.string().min(1).optional(),
754
+ hostId: z3.string().min(1).optional(),
751
755
  name: z3.string().optional(),
752
756
  sizeBytes: z3.number().int().nonnegative().optional(),
753
757
  mimeType: z3.string().optional(),
@@ -11504,6 +11508,11 @@ import { execFile as execFile2 } from "node:child_process";
11504
11508
  import { promisify as promisify3 } from "node:util";
11505
11509
  var execFileAsync = promisify3(execFile2);
11506
11510
 
11511
+ // ../process-utils/src/performance-diagnostics.ts
11512
+ import { Session } from "node:inspector/promises";
11513
+ var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
11514
+ var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
11515
+
11507
11516
  // ../provider-bridge-protocol/src/bridge-kit/provider-maintenance-kit.ts
11508
11517
  var import_compare = __toESM(require_compare(), 1);
11509
11518
  var import_valid = __toESM(require_valid(), 1);
@@ -15967,7 +15976,7 @@ function resolveBridgeProcessEnvForMcpServer() {
15967
15976
  }
15968
15977
  async function forwardDynamicToolCall(args, signal) {
15969
15978
  const session = sessionsByBbThreadId.get(args.threadId);
15970
- if (!session || !session.providerThreadId || session.stopping) {
15979
+ if (!session || !session.providerThreadId || session.stopping || session.connection.exited) {
15971
15980
  return { ok: false, error: "No active ACP session for dynamic tool call." };
15972
15981
  }
15973
15982
  const controller = new AbortController();
@@ -16975,8 +16984,8 @@ async function startAgentSession(request) {
16975
16984
  onExit: (info) => {
16976
16985
  const wasCurrent = sessionsByBbThreadId.get(bbThreadId) === session;
16977
16986
  cancelPendingPermissions(session);
16978
- removeSession(session);
16979
16987
  if (!wasCurrent || session.stopping || session.providerThreadId === "") {
16988
+ removeSession(session);
16980
16989
  return;
16981
16990
  }
16982
16991
  void releaseCursorMcpApproval(session);
@@ -16984,6 +16993,7 @@ async function startAgentSession(request) {
16984
16993
  session,
16985
16994
  `ACP agent "${agentLabel}" exited unexpectedly${info.code !== null ? ` (code ${info.code})` : ""}${info.stderrTail ? `: ${info.stderrTail}` : ""}`
16986
16995
  );
16996
+ session.activePromptKind = null;
16987
16997
  }
16988
16998
  });
16989
16999
  session = {
@@ -17301,6 +17311,21 @@ function runTurn(session, firstInput) {
17301
17311
  let stopReason;
17302
17312
  session.cancelRequested = false;
17303
17313
  try {
17314
+ const previousSession = session;
17315
+ const reconciled = reconcileExecutionSettings(session, pending.options);
17316
+ session = reconciled instanceof Promise ? await reconciled : reconciled;
17317
+ if (session.stopping) {
17318
+ dropTurnInput(pending, "ACP session is stopping");
17319
+ finishTurn(session, "cancelled");
17320
+ return;
17321
+ }
17322
+ session.activePromptKind = "turn";
17323
+ session.turnSettled = previousSession.turnSettled;
17324
+ if (session !== previousSession) {
17325
+ emitForSession(session, ACP_TURN_STARTED_METHOD, {
17326
+ threadId: session.bbThreadId
17327
+ });
17328
+ }
17304
17329
  session.promptRequestPending = true;
17305
17330
  const promptResult = session.connection.request({
17306
17331
  method: "session/prompt",
@@ -17329,11 +17354,16 @@ function runTurn(session, firstInput) {
17329
17354
  "ACP turn failed before the steer was sent"
17330
17355
  );
17331
17356
  session.cancelRequested = false;
17332
- if (!session.stopping && !session.connection.exited) {
17333
- emitSessionError(
17334
- session,
17335
- error instanceof Error ? error.message : String(error)
17336
- );
17357
+ if (!session.stopping) {
17358
+ const message = error instanceof Error ? error.message : String(error);
17359
+ if (!session.connection.exited) {
17360
+ emitSessionError(session, message);
17361
+ } else if (session.activePromptKind === "turn") {
17362
+ emitForSession(session, "error", {
17363
+ threadId: session.bbThreadId,
17364
+ message
17365
+ });
17366
+ }
17337
17367
  }
17338
17368
  session.activePromptKind = null;
17339
17369
  return;
@@ -17351,6 +17381,77 @@ function runTurn(session, firstInput) {
17351
17381
  }
17352
17382
  })();
17353
17383
  }
17384
+ function reconcileExecutionSettings(session, options) {
17385
+ if (options.permissionMode === "auto") {
17386
+ throw new Error('ACP does not support permission mode "auto".');
17387
+ }
17388
+ const envVars = Object.keys(options.envVars ?? {}).length > 0 ? {
17389
+ ...decodeLaunchSpec(options.providerOptions)?.env ?? {},
17390
+ ...options.envVars
17391
+ } : session.construction.envVars;
17392
+ const workspaceWriteRoots = options.providerOptions?.additionalWorkspaceWriteRoots !== void 0 ? [
17393
+ session.cwd,
17394
+ ...decodeAdditionalWorkspaceWriteRoots(options.providerOptions)
17395
+ ] : session.policy.workspaceWriteRoots;
17396
+ const construction = {
17397
+ ...session.construction,
17398
+ envVars,
17399
+ permissionMode: options.permissionMode,
17400
+ workspaceWriteRoots
17401
+ };
17402
+ const launchArgsChanged = !isDeepStrictEqual(
17403
+ permissionCliArgsForMode(
17404
+ session.construction.permissionCli,
17405
+ session.construction.permissionMode
17406
+ ),
17407
+ permissionCliArgsForMode(
17408
+ construction.permissionCli,
17409
+ construction.permissionMode
17410
+ )
17411
+ );
17412
+ const restart = session.connection.exited || session.restartAfterCancelError || launchArgsChanged || !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {});
17413
+ cancelPendingPermissions(session);
17414
+ session.policy = {
17415
+ permissionMode: options.permissionMode,
17416
+ workspaceWriteRoots
17417
+ };
17418
+ if (!restart) {
17419
+ session.construction = construction;
17420
+ return session;
17421
+ }
17422
+ return rebuildAgentSession(session, construction);
17423
+ }
17424
+ async function rebuildAgentSession(session, construction) {
17425
+ const previousProviderThreadId = session.providerThreadId;
17426
+ const reason = session.connection.exited ? "The ACP agent exited unexpectedly; its session was rebuilt before continuing." : session.restartAfterCancelError ? "The ACP agent failed during cancellation; its session was rebuilt before continuing." : "Execution settings changed; the ACP session was rebuilt to apply them.";
17427
+ const queuedInputs = session.queuedInputs.splice(0);
17428
+ const continuingTurn = session.activePromptKind === "turn";
17429
+ finishTurn(session, "cancelled");
17430
+ let replacement;
17431
+ try {
17432
+ replacement = await startAgentSession({
17433
+ kind: "resume",
17434
+ params: construction,
17435
+ resumeProviderThreadId: previousProviderThreadId
17436
+ });
17437
+ } catch (error) {
17438
+ if (continuingTurn) {
17439
+ emitSessionError(
17440
+ session,
17441
+ error instanceof Error ? error.message : String(error)
17442
+ );
17443
+ }
17444
+ throw error;
17445
+ }
17446
+ replacement.queuedInputs.push(...queuedInputs);
17447
+ sendNotification(BRIDGE_NOTIFICATION_METHODS.sessionReplaced, {
17448
+ threadId: session.bbThreadId,
17449
+ providerThreadId: replacement.providerThreadId,
17450
+ reason,
17451
+ contextLost: replacement.providerThreadId !== previousProviderThreadId
17452
+ });
17453
+ return replacement;
17454
+ }
17354
17455
  function startCompaction(session, pending) {
17355
17456
  session.activePromptKind = "compaction";
17356
17457
  session.compactionAgentMessage = "";
@@ -17721,29 +17822,13 @@ async function handleRequest2(request) {
17721
17822
  sendError(request.id, -32e3, "A turn is already active");
17722
17823
  return;
17723
17824
  }
17724
- const envVars = Object.keys(params.options.envVars ?? {}).length > 0 ? {
17725
- ...decodeLaunchSpec(params.options.providerOptions)?.env ?? {},
17726
- ...params.options.envVars
17727
- } : session.construction.envVars;
17728
- if (session.restartAfterCancelError || !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {})) {
17729
- const previousProviderThreadId = session.providerThreadId;
17730
- const reason = session.restartAfterCancelError ? "The ACP agent failed during cancellation; its session was rebuilt before continuing." : "Execution settings changed; the ACP session was rebuilt to apply them.";
17731
- session = await startAgentSession({
17732
- kind: "resume",
17733
- params: { ...session.construction, envVars },
17734
- resumeProviderThreadId: previousProviderThreadId
17735
- });
17736
- sendNotification(BRIDGE_NOTIFICATION_METHODS.sessionReplaced, {
17737
- threadId: params.threadId,
17738
- providerThreadId: session.providerThreadId,
17739
- reason,
17740
- contextLost: session.providerThreadId !== previousProviderThreadId
17741
- });
17742
- }
17825
+ const reconciled = reconcileExecutionSettings(session, params.options);
17826
+ session = reconciled instanceof Promise ? await reconciled : reconciled;
17743
17827
  const pending = {
17744
17828
  clientRequestId: params.clientRequestId,
17745
17829
  input: params.input,
17746
- requestId: request.id
17830
+ requestId: request.id,
17831
+ options: params.options
17747
17832
  };
17748
17833
  if (isStandaloneBuiltinCompactCommand(params.input)) {
17749
17834
  startCompaction(session, pending);
@@ -17769,7 +17854,8 @@ async function handleRequest2(request) {
17769
17854
  session.queuedInputs.push({
17770
17855
  clientRequestId: params.clientRequestId,
17771
17856
  input: params.input,
17772
- requestId: null
17857
+ requestId: null,
17858
+ options: params.options
17773
17859
  });
17774
17860
  requestSteerCancel(session);
17775
17861
  sendResult(request.id, { threadId: params.threadId });