@get-bb/plugin-sdk 0.6.26 → 0.6.33

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
@@ -107,15 +107,6 @@ var experimental_useSidebarThreadPullRequest = runtimeFunction(
107
107
  var experimental_useSidebarThreadSplit = runtimeFunction(
108
108
  "experimental_useSidebarThreadSplit"
109
109
  );
110
- var experimental_useSidebarNavigation = runtimeFunction(
111
- "experimental_useSidebarNavigation"
112
- );
113
- var experimental_useSidebarNavigationSplit = runtimeFunction(
114
- "experimental_useSidebarNavigationSplit"
115
- );
116
- var experimental_SidebarNavigationIcon = runtimeComponent(
117
- "experimental_SidebarNavigationIcon"
118
- );
119
110
  var useSidebarThreadDraft = runtimeFunction("useSidebarThreadDraft");
120
111
  var useSidebarThreadDraftIds = runtimeFunction(
121
112
  "useSidebarThreadDraftIds"
@@ -141,6 +132,9 @@ var experimental_useProviders = runtimeFunction(
141
132
  var experimental_useCodeTheme = runtimeFunction(
142
133
  "experimental_useCodeTheme"
143
134
  );
135
+ var experimental_copyToClipboard = runtimeFunction(
136
+ "experimental_copyToClipboard"
137
+ );
144
138
  export {
145
139
  Markdown,
146
140
  ThreadChat,
@@ -155,9 +149,9 @@ export {
155
149
  experimental_PermissionModePicker,
156
150
  experimental_ProviderIcon,
157
151
  experimental_ProviderModelPicker,
158
- experimental_SidebarNavigationIcon,
159
152
  experimental_SourceCode,
160
153
  experimental_VoiceInputTextarea,
154
+ experimental_copyToClipboard,
161
155
  experimental_useAppPanel,
162
156
  experimental_useBranches,
163
157
  experimental_useCheckoutState,
@@ -166,8 +160,6 @@ export {
166
160
  experimental_usePluginId,
167
161
  experimental_useProviders,
168
162
  experimental_useQuestionFormHost,
169
- experimental_useSidebarNavigation,
170
- experimental_useSidebarNavigationSplit,
171
163
  experimental_useSidebarThreadActions,
172
164
  experimental_useSidebarThreadPullRequest,
173
165
  experimental_useSidebarThreadSplit,
package/dist/host.js CHANGED
@@ -854,12 +854,22 @@ async function listLsofProcessCwds() {
854
854
  }
855
855
  async function resolveSweepDirectory(directory) {
856
856
  const resolved = resolve(directory);
857
- let parent = dirname(resolved);
858
- try {
859
- parent = await realpath(parent);
860
- } catch {
857
+ let ancestor = dirname(resolved);
858
+ const missing = [basename(resolved)];
859
+ for (; ; ) {
860
+ try {
861
+ ancestor = await realpath(ancestor);
862
+ break;
863
+ } catch {
864
+ }
865
+ const parent = dirname(ancestor);
866
+ if (parent === ancestor) {
867
+ break;
868
+ }
869
+ missing.unshift(basename(ancestor));
870
+ ancestor = parent;
861
871
  }
862
- const canonical = join(parent, basename(resolved));
872
+ const canonical = join(ancestor, ...missing);
863
873
  try {
864
874
  if ((await lstat(canonical)).isSymbolicLink()) {
865
875
  return null;
@@ -872,13 +882,15 @@ async function listProcessesWithCwdUnder(args) {
872
882
  if (process.platform === "win32") {
873
883
  return [];
874
884
  }
875
- const directory = await resolveSweepDirectory(args.directory);
876
- if (directory === null) {
885
+ const directories = (await Promise.all(args.directories.map(resolveSweepDirectory))).filter((directory) => directory !== null);
886
+ if (directories.length === 0) {
877
887
  return [];
878
888
  }
879
889
  const all = process.platform === "linux" ? await listLinuxProcessCwds() : await listLsofProcessCwds();
880
890
  return all.filter(
881
- (entry) => entry.pid !== process.pid && isPathUnderDirectory(entry.cwd, directory)
891
+ (entry) => entry.pid !== process.pid && directories.some(
892
+ (directory) => isPathUnderDirectory(entry.cwd, directory)
893
+ )
882
894
  );
883
895
  }
884
896
  function isProcessAlive(pid) {
@@ -907,7 +919,7 @@ async function killProcessesWithCwdUnder(args) {
907
919
  const signalled = /* @__PURE__ */ new Map();
908
920
  for (let round = 0; round < MAX_CWD_SWEEP_ROUNDS; round += 1) {
909
921
  const targets = await listProcessesWithCwdUnder({
910
- directory: args.directory
922
+ directories: args.directories
911
923
  });
912
924
  if (targets.length === 0) {
913
925
  break;
@@ -918,7 +930,7 @@ async function killProcessesWithCwdUnder(args) {
918
930
  await delay(50);
919
931
  }
920
932
  const survivors = await listProcessesWithCwdUnder({
921
- directory: args.directory
933
+ directories: args.directories
922
934
  });
923
935
  if (survivors.length === 0) {
924
936
  break;
@@ -950,20 +962,108 @@ function sanitizeInheritedChildProcessEnv(args) {
950
962
 
951
963
  // ../process-utils/src/process-info.ts
952
964
  import { execFile } from "node:child_process";
965
+ import path2 from "node:path";
953
966
  import { promisify } from "node:util";
954
967
  var execFileAsync = promisify(execFile);
968
+ async function readProcessIdentity(pid) {
969
+ if (!Number.isSafeInteger(pid) || pid <= 0) return null;
970
+ if (process.platform === "win32") return readWindowsProcess(pid);
971
+ try {
972
+ const { stdout } = await execFileAsync(
973
+ "ps",
974
+ ["-p", String(pid), "-o", "etime=", "-o", "command="],
975
+ {
976
+ timeout: 5e3,
977
+ maxBuffer: 1024 * 1024
978
+ }
979
+ );
980
+ const match = stdout.trim().match(/^(\S+)\s+([\s\S]+)$/u);
981
+ if (match === null) return null;
982
+ const elapsed = parseElapsedSeconds(match[1] ?? "");
983
+ return {
984
+ command: match[2] ?? null,
985
+ startedAt: elapsed === null ? null : Date.now() - elapsed * 1e3
986
+ };
987
+ } catch {
988
+ return null;
989
+ }
990
+ }
991
+ async function readWindowsProcess(pid) {
992
+ try {
993
+ const pending = execFileAsync(
994
+ path2.join(
995
+ process.env.SystemRoot ?? "C:\\Windows",
996
+ "System32",
997
+ "WindowsPowerShell",
998
+ "v1.0",
999
+ "powershell.exe"
1000
+ ),
1001
+ [
1002
+ "-NoProfile",
1003
+ "-NonInteractive",
1004
+ "-Command",
1005
+ [
1006
+ "$ErrorActionPreference = 'Stop'",
1007
+ "[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)",
1008
+ `Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' | ForEach-Object { @{ command = $_.CommandLine; startedAt = ([DateTimeOffset]$_.CreationDate).ToUnixTimeMilliseconds() } | ConvertTo-Json -Compress }`
1009
+ ].join("; ")
1010
+ ],
1011
+ {
1012
+ encoding: "utf8",
1013
+ windowsHide: true,
1014
+ timeout: 3e4,
1015
+ maxBuffer: 1024 * 1024
1016
+ }
1017
+ );
1018
+ pending.child.stdin?.end();
1019
+ const { stdout } = await pending;
1020
+ const value = JSON.parse(stdout);
1021
+ if (typeof value !== "object" || value === null || !("command" in value) || !("startedAt" in value) || typeof value.command !== "string" && value.command !== null || typeof value.startedAt !== "number" || !Number.isFinite(value.startedAt))
1022
+ return null;
1023
+ return { command: value.command, startedAt: value.startedAt };
1024
+ } catch {
1025
+ return null;
1026
+ }
1027
+ }
1028
+ function parseElapsedSeconds(rawElapsed) {
1029
+ const match = rawElapsed.trim().match(/^(?:(?:(\d+)-)?(\d+):)?(\d{1,2}):(\d{2})$/u);
1030
+ if (match === null) {
1031
+ return null;
1032
+ }
1033
+ const days = Number(match[1] ?? "0");
1034
+ const hours = Number(match[2] ?? "0");
1035
+ const minutes = Number(match[3]);
1036
+ const seconds = Number(match[4]);
1037
+ return ((days * 24 + hours) * 60 + minutes) * 60 + seconds;
1038
+ }
955
1039
 
956
1040
  // ../process-utils/src/performance-diagnostics.ts
957
1041
  import { Session } from "node:inspector/promises";
958
1042
  var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
959
1043
  var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
1044
+
1045
+ // src/kill-processes.ts
1046
+ function experimental_killProcessesWithCwdUnder(args) {
1047
+ if ("directory" in args && typeof args.directory === "string")
1048
+ return killProcessesWithCwdUnder({
1049
+ ...args,
1050
+ directories: [args.directory]
1051
+ });
1052
+ return killProcessesWithCwdUnder(args);
1053
+ }
1054
+
1055
+ // src/process-identity.ts
1056
+ function experimental_readProcessIdentity(pid) {
1057
+ return readProcessIdentity(pid);
1058
+ }
960
1059
  export {
961
1060
  experimental_defineHostEntry,
962
1061
  experimental_filterResolvedNativeRoots,
963
- killProcessesWithCwdUnder as experimental_killProcessesWithCwdUnder,
1062
+ experimental_killProcessesWithCwdUnder,
964
1063
  experimental_nativeRootsHostContract,
965
1064
  experimental_nativeRootsResolveInputSchema,
966
1065
  experimental_nativeRootsResolveOutputSchema,
1066
+ experimental_readProcessIdentity,
967
1067
  experimental_resolveClaudePluginRoots,
968
1068
  experimental_resolveVendorPluginRoots,
969
1069
  sanitizeInheritedChildProcessEnv as experimental_sanitizeInheritedChildProcessEnv,
@@ -50,6 +50,7 @@ var RESERVED_BB_CLI_COMMANDS = [
50
50
  // ../domain/src/plugin-interaction-limits.ts
51
51
  var PLUGIN_INTERACTION_MAX_TITLE_LENGTH = 160;
52
52
  var PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES = 64 * 1024;
53
+ var PLUGIN_INTERACTION_MAX_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1e3;
53
54
 
54
55
  // ../domain/src/provider-fork.ts
55
56
  import { z } from "zod";
@@ -2453,8 +2454,10 @@ function normalizeInteractionRequest(request) {
2453
2454
  throw new Error("ui.requestInput payload must be JSON-serializable");
2454
2455
  }
2455
2456
  const timeoutMs = request.timeoutMs ?? 10 * 60 * 1e3;
2456
- if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 60 * 60 * 1e3) {
2457
- throw new Error("ui.requestInput timeoutMs must be between 1 and 3600000");
2457
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > PLUGIN_INTERACTION_MAX_TIMEOUT_MS) {
2458
+ throw new Error(
2459
+ `ui.requestInput timeoutMs must be between 1 and ${PLUGIN_INTERACTION_MAX_TIMEOUT_MS}`
2460
+ );
2458
2461
  }
2459
2462
  if (request.describeSubmission !== void 0 && typeof request.describeSubmission !== "function") {
2460
2463
  throw new Error("ui.requestInput describeSubmission must be a function");
@@ -469,8 +469,6 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
469
469
  pendingInteractions: [],
470
470
  sidebarFooterActions: [],
471
471
  experimentalSidebarFooterItems: [],
472
- experimentalSidebarNavigations: [],
473
- experimentalSidebarHeaders: [],
474
472
  threadLists: [],
475
473
  threadHeaderActions: [],
476
474
  browserToolbarActions: [],
@@ -499,8 +497,6 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
499
497
  composerPopup: /* @__PURE__ */ new Set(),
500
498
  pendingInteraction: /* @__PURE__ */ new Set(),
501
499
  sidebarFooterItem: /* @__PURE__ */ new Set(),
502
- sidebarNavigation: /* @__PURE__ */ new Set(),
503
- sidebarHeader: /* @__PURE__ */ new Set(),
504
500
  threadList: /* @__PURE__ */ new Set(),
505
501
  threadHeaderAction: /* @__PURE__ */ new Set(),
506
502
  browserToolbarAction: /* @__PURE__ */ new Set(),
@@ -720,24 +716,6 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
720
716
  collected.sidebarFooterActions.push(legacyRegistration);
721
717
  sidebarFooterItems.push(adaptSidebarFooterAction(legacyRegistration));
722
718
  },
723
- experimental_sidebarNavigation(registration) {
724
- collected.experimentalSidebarNavigations.push(
725
- collectTitledComponent(
726
- "slots.experimental_sidebarNavigation",
727
- seenIds.sidebarNavigation,
728
- registration
729
- )
730
- );
731
- },
732
- experimental_sidebarHeader(registration) {
733
- collected.experimentalSidebarHeaders.push(
734
- collectTitledComponent(
735
- "slots.experimental_sidebarHeader",
736
- seenIds.sidebarHeader,
737
- registration
738
- )
739
- );
740
- },
741
719
  experimental_threadList(registration) {
742
720
  collected.threadLists.push(
743
721
  collectTitledComponent(
@@ -1245,6 +1245,7 @@ import { z as z10 } from "zod";
1245
1245
  // ../domain/src/plugin-interaction-limits.ts
1246
1246
  var PLUGIN_INTERACTION_MAX_TITLE_LENGTH = 160;
1247
1247
  var PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES = 64 * 1024;
1248
+ var PLUGIN_INTERACTION_MAX_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1e3;
1248
1249
  function jsonByteLength(value) {
1249
1250
  return new TextEncoder().encode(JSON.stringify(value)).length;
1250
1251
  }
@@ -3068,7 +3069,8 @@ var providerHealthSchema = z22.object({
3068
3069
  minimumSupportedVersion: z22.string().min(1).nullable(),
3069
3070
  canInstall: z22.boolean(),
3070
3071
  canUpdate: z22.boolean(),
3071
- loginCommand: z22.string().min(1).nullable()
3072
+ loginCommand: z22.string().min(1).nullable(),
3073
+ localLoginCommand: z22.string().min(1).nullable().optional()
3072
3074
  }).passthrough();
3073
3075
  var providerUsageWindowSchema = z22.object({
3074
3076
  label: z22.string().min(1),
@@ -15019,11 +15021,23 @@ function buildAcpModelListParams(launchSpec, options) {
15019
15021
  ...launchSpec.nativeReasoning !== void 0 ? { nativeReasoning: launchSpec.nativeReasoning } : {}
15020
15022
  };
15021
15023
  }
15022
- function buildAcpModelSelectionParam(launchSpec, options, parameterizedModelPicker, dialectId) {
15024
+ function buildAcpModelSelectionParams(launchSpec, options, parameterizedModelPicker, dialectId) {
15025
+ const modelSelection = buildAcpModelSelection(
15026
+ launchSpec,
15027
+ options,
15028
+ parameterizedModelPicker,
15029
+ dialectId
15030
+ );
15031
+ return {
15032
+ ...modelSelection !== void 0 ? { modelSelection } : {},
15033
+ ...launchSpec.reasoningCli !== void 0 && options.reasoningLevel !== void 0 ? { launchReasoningLevel: options.reasoningLevel } : {}
15034
+ };
15035
+ }
15036
+ function buildAcpModelSelection(launchSpec, options, parameterizedModelPicker, dialectId) {
15023
15037
  const model = options.model;
15024
15038
  const listCommand = buildAcpModelListCommand(launchSpec);
15025
15039
  if (!model || model === ACP_DEFAULT_MODEL_ID) {
15026
- return {};
15040
+ return void 0;
15027
15041
  }
15028
15042
  if (parameterizedModelPicker || !listCommand || !launchSpec.modelCli?.selectFlag) {
15029
15043
  const modelSelection = parameterizedModelPicker && dialectId === "cursor" ? cursorParameterizedSelection(model, options.reasoningLevel) : {
@@ -15031,20 +15045,16 @@ function buildAcpModelSelectionParam(launchSpec, options, parameterizedModelPick
15031
15045
  ...options.reasoningLevel !== void 0 ? { reasoningLevel: options.reasoningLevel } : {}
15032
15046
  };
15033
15047
  return {
15034
- modelSelection: {
15035
- ...modelSelection,
15036
- ...parameterizedModelPicker && options.serviceTier !== void 0 ? { serviceTier: options.serviceTier } : {}
15037
- }
15048
+ ...modelSelection,
15049
+ ...parameterizedModelPicker && options.serviceTier !== void 0 ? { serviceTier: options.serviceTier } : {}
15038
15050
  };
15039
15051
  }
15040
15052
  return {
15041
- modelSelection: {
15042
- listCommand,
15043
- selectFlag: launchSpec.modelCli.selectFlag,
15044
- model,
15045
- ...options.reasoningLevel !== void 0 ? { reasoningLevel: options.reasoningLevel } : {},
15046
- ...options.serviceTier === "fast" ? { serviceTier: options.serviceTier } : {}
15047
- }
15053
+ listCommand,
15054
+ selectFlag: launchSpec.modelCli.selectFlag,
15055
+ model,
15056
+ ...options.reasoningLevel !== void 0 ? { reasoningLevel: options.reasoningLevel } : {},
15057
+ ...options.serviceTier === "fast" ? { serviceTier: options.serviceTier } : {}
15048
15058
  };
15049
15059
  }
15050
15060
  function buildAcpSessionParams(args) {
@@ -15068,7 +15078,7 @@ function buildAcpSessionParams(args) {
15068
15078
  args: [...launchSpec.args]
15069
15079
  },
15070
15080
  ...args.dialectId === void 0 ? {} : { dialectId: args.dialectId },
15071
- ...buildAcpModelSelectionParam(
15081
+ ...buildAcpModelSelectionParams(
15072
15082
  launchSpec,
15073
15083
  options,
15074
15084
  args.parameterizedModelPicker,
@@ -15078,7 +15088,6 @@ function buildAcpSessionParams(args) {
15078
15088
  ...launchSpec.reasoningCli !== void 0 ? { reasoningCli: launchSpec.reasoningCli } : {},
15079
15089
  ...launchSpec.nativeReasoning !== void 0 ? { nativeReasoning: launchSpec.nativeReasoning } : {},
15080
15090
  ...launchSpec.permissionCli !== void 0 ? { permissionCli: launchSpec.permissionCli } : {},
15081
- ...launchSpec.reasoningCli !== void 0 && options.reasoningLevel !== void 0 ? { launchReasoningLevel: options.reasoningLevel } : {},
15082
15091
  permissionMode: options.permissionMode,
15083
15092
  workspaceWriteRoots: [cwd, ...args.additionalWorkspaceWriteRoots],
15084
15093
  ...Object.keys(envVars).length > 0 ? { envVars } : {},
@@ -16566,19 +16575,20 @@ async function selectAcpNativeModel(args) {
16566
16575
  if (!selection || !("modelId" in selection)) {
16567
16576
  return;
16568
16577
  }
16569
- let configOptions = args.configOptions;
16570
- const modelOption = findAcpModelConfigOption(args.configOptions);
16571
- const availableSessionModels = args.models?.availableModels ?? [];
16578
+ const { session } = args;
16579
+ const { configOptions, models } = session.nativeConfig;
16580
+ const modelOption = findAcpModelConfigOption(configOptions);
16581
+ const availableSessionModels = models?.availableModels ?? [];
16572
16582
  const sessionModelsIncludeSelection = availableSessionModels.some(
16573
16583
  (model) => model.modelId === selection.modelId
16574
16584
  );
16575
- const shouldSetModel = modelOption && modelOption.currentValue !== selection.modelId || !modelOption && sessionModelsIncludeSelection && args.models?.currentModelId !== selection.modelId;
16585
+ const shouldSetModel = modelOption && modelOption.currentValue !== selection.modelId || !modelOption && sessionModelsIncludeSelection && models?.currentModelId !== selection.modelId;
16576
16586
  if (shouldSetModel) {
16577
16587
  let configState = null;
16578
16588
  let setModel = true;
16579
16589
  if (modelOption) {
16580
16590
  try {
16581
- configState = await args.connection.request({
16591
+ configState = await session.connection.request({
16582
16592
  method: "session/set_config_option",
16583
16593
  params: {
16584
16594
  sessionId: args.sessionId,
@@ -16593,34 +16603,61 @@ async function selectAcpNativeModel(args) {
16593
16603
  }
16594
16604
  }
16595
16605
  if (setModel) {
16596
- configState = await args.connection.request({
16606
+ configState = await session.connection.request({
16597
16607
  method: "session/set_model",
16598
16608
  params: { sessionId: args.sessionId, modelId: selection.modelId },
16599
16609
  resultSchema: z43.union([acpConfigStateResultSchema, z43.null()])
16600
16610
  });
16601
16611
  }
16602
- configOptions = configState?.configOptions ?? configOptions;
16612
+ const current = session.nativeConfig;
16613
+ session.nativeConfig = {
16614
+ configOptions: configState?.configOptions ?? withAcpConfigValue(
16615
+ current.configOptions,
16616
+ modelOption?.id,
16617
+ selection.modelId
16618
+ ),
16619
+ models: configState?.models ?? (current.models && {
16620
+ ...current.models,
16621
+ currentModelId: selection.modelId
16622
+ })
16623
+ };
16603
16624
  }
16604
16625
  await selectAcpNativeReasoning({
16605
- connection: args.connection,
16626
+ session,
16606
16627
  sessionId: args.sessionId,
16607
- configOptions,
16608
16628
  modelSelection: selection,
16609
16629
  nativeReasoning: args.nativeReasoning
16610
16630
  });
16611
16631
  await selectAcpNativeServiceTier({
16612
- connection: args.connection,
16632
+ session,
16613
16633
  sessionId: args.sessionId,
16614
- configOptions,
16615
16634
  modelSelection: selection
16616
16635
  });
16617
16636
  }
16637
+ function withAcpConfigValue(configOptions, configId, value) {
16638
+ return configOptions?.map(
16639
+ (option) => option.id === configId ? { ...option, currentValue: value } : option
16640
+ );
16641
+ }
16642
+ function recordAcpConfigValue(session, configState, configId, value) {
16643
+ session.nativeConfig = {
16644
+ ...session.nativeConfig,
16645
+ configOptions: configState?.configOptions ?? withAcpConfigValue(session.nativeConfig.configOptions, configId, value)
16646
+ };
16647
+ }
16648
+ function acpNativeModelDrifted(nativeConfig, modelSelection) {
16649
+ if (!modelSelection || !("modelId" in modelSelection)) {
16650
+ return false;
16651
+ }
16652
+ const currentModelId = findAcpModelConfigOption(nativeConfig.configOptions)?.currentValue ?? nativeConfig.models?.currentModelId;
16653
+ return currentModelId !== void 0 && currentModelId !== modelSelection.modelId;
16654
+ }
16618
16655
  async function selectAcpNativeReasoning(args) {
16619
16656
  const reasoningLevel = args.modelSelection.reasoningLevel;
16620
16657
  if (reasoningLevel === void 0) {
16621
16658
  return;
16622
16659
  }
16623
- const thoughtLevelOption = findAcpThoughtLevelConfigOption(args.configOptions) ?? nativeReasoningToThoughtLevelOption(args.nativeReasoning);
16660
+ const thoughtLevelOption = findAcpThoughtLevelConfigOption(args.session.nativeConfig.configOptions) ?? nativeReasoningToThoughtLevelOption(args.nativeReasoning);
16624
16661
  if (!thoughtLevelOption) {
16625
16662
  return;
16626
16663
  }
@@ -16631,40 +16668,44 @@ async function selectAcpNativeReasoning(args) {
16631
16668
  if (value === void 0) {
16632
16669
  return;
16633
16670
  }
16671
+ let configState;
16634
16672
  try {
16635
- await args.connection.request({
16673
+ configState = await args.session.connection.request({
16636
16674
  method: "session/set_config_option",
16637
16675
  params: {
16638
16676
  sessionId: args.sessionId,
16639
16677
  configId: thoughtLevelOption.id,
16640
16678
  value
16641
16679
  },
16642
- resultSchema: acpConfigStateResultSchema
16680
+ resultSchema: z43.union([acpConfigStateResultSchema, z43.null()])
16643
16681
  });
16644
16682
  } catch {
16683
+ return;
16645
16684
  }
16685
+ recordAcpConfigValue(args.session, configState, thoughtLevelOption.id, value);
16646
16686
  }
16647
16687
  async function selectAcpNativeServiceTier(args) {
16648
16688
  const serviceTier = args.modelSelection.serviceTier;
16649
16689
  if (serviceTier === void 0) {
16650
16690
  return;
16651
16691
  }
16652
- const fastOption = (args.configOptions ?? []).find(
16692
+ const fastOption = (args.session.nativeConfig.configOptions ?? []).find(
16653
16693
  (option) => option.id === "fast" && option.type === "select"
16654
16694
  );
16655
16695
  const value = serviceTier === "fast" ? "true" : "false";
16656
16696
  if (!fastOption?.options?.some((option) => option.value === value)) {
16657
16697
  return;
16658
16698
  }
16659
- await args.connection.request({
16699
+ const configState = await args.session.connection.request({
16660
16700
  method: "session/set_config_option",
16661
16701
  params: {
16662
16702
  sessionId: args.sessionId,
16663
16703
  configId: fastOption.id,
16664
16704
  value
16665
16705
  },
16666
- resultSchema: acpConfigStateResultSchema
16706
+ resultSchema: z43.union([acpConfigStateResultSchema, z43.null()])
16667
16707
  });
16708
+ recordAcpConfigValue(args.session, configState, fastOption.id, value);
16668
16709
  }
16669
16710
  function buildPromptContentBlocks(session, input) {
16670
16711
  const blocks = [];
@@ -16999,6 +17040,7 @@ async function startAgentSession(request) {
16999
17040
  session = {
17000
17041
  bbThreadId,
17001
17042
  construction: params,
17043
+ nativeConfig: { configOptions: void 0, models: void 0 },
17002
17044
  providerThreadId: "",
17003
17045
  cwd: params.cwd,
17004
17046
  dialect,
@@ -17124,11 +17166,13 @@ async function startAgentSession(request) {
17124
17166
  sessionId = newSession.sessionId;
17125
17167
  createdFreshSession = true;
17126
17168
  rememberGrokContextWindow(session, newSession.models);
17169
+ session.nativeConfig = {
17170
+ configOptions: newSession.configOptions,
17171
+ models: newSession.models
17172
+ };
17127
17173
  await selectAcpNativeModel({
17128
- connection,
17174
+ session,
17129
17175
  sessionId,
17130
- configOptions: newSession.configOptions,
17131
- models: newSession.models,
17132
17176
  modelSelection: params.modelSelection,
17133
17177
  nativeReasoning: params.nativeReasoning
17134
17178
  });
@@ -17139,11 +17183,13 @@ async function startAgentSession(request) {
17139
17183
  });
17140
17184
  }
17141
17185
  } else {
17186
+ session.nativeConfig = {
17187
+ configOptions: loadedConfigOptions,
17188
+ models: loadedModels
17189
+ };
17142
17190
  await selectAcpNativeModel({
17143
- connection,
17191
+ session,
17144
17192
  sessionId,
17145
- configOptions: loadedConfigOptions,
17146
- models: loadedModels,
17147
17193
  modelSelection: params.modelSelection,
17148
17194
  nativeReasoning: params.nativeReasoning
17149
17195
  });
@@ -17385,16 +17431,25 @@ function reconcileExecutionSettings(session, options) {
17385
17431
  if (options.permissionMode === "auto") {
17386
17432
  throw new Error('ACP does not support permission mode "auto".');
17387
17433
  }
17434
+ const launchSpec = decodeLaunchSpec(options.providerOptions);
17388
17435
  const envVars = Object.keys(options.envVars ?? {}).length > 0 ? {
17389
- ...decodeLaunchSpec(options.providerOptions)?.env ?? {},
17436
+ ...launchSpec?.env ?? {},
17390
17437
  ...options.envVars
17391
17438
  } : session.construction.envVars;
17392
17439
  const workspaceWriteRoots = options.providerOptions?.additionalWorkspaceWriteRoots !== void 0 ? [
17393
17440
  session.cwd,
17394
17441
  ...decodeAdditionalWorkspaceWriteRoots(options.providerOptions)
17395
17442
  ] : session.policy.workspaceWriteRoots;
17443
+ const modelParams = launchSpec === null ? session.construction : buildAcpModelSelectionParams(
17444
+ launchSpec,
17445
+ options,
17446
+ decodeAcpModelPickerOptions(options.providerOptions).parameterizedModelPicker,
17447
+ decodeDialectId(options.providerOptions)
17448
+ );
17396
17449
  const construction = {
17397
17450
  ...session.construction,
17451
+ modelSelection: modelParams.modelSelection,
17452
+ launchReasoningLevel: modelParams.launchReasoningLevel,
17398
17453
  envVars,
17399
17454
  permissionMode: options.permissionMode,
17400
17455
  workspaceWriteRoots
@@ -17408,6 +17463,9 @@ function reconcileExecutionSettings(session, options) {
17408
17463
  construction.permissionCli,
17409
17464
  construction.permissionMode
17410
17465
  )
17466
+ ) || !isDeepStrictEqual(
17467
+ launchModelSelection(session.construction),
17468
+ launchModelSelection(construction)
17411
17469
  );
17412
17470
  const restart = session.connection.exited || session.restartAfterCancelError || launchArgsChanged || !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {});
17413
17471
  cancelPendingPermissions(session);
@@ -17415,11 +17473,33 @@ function reconcileExecutionSettings(session, options) {
17415
17473
  permissionMode: options.permissionMode,
17416
17474
  workspaceWriteRoots
17417
17475
  };
17418
- if (!restart) {
17476
+ if (restart) {
17477
+ return rebuildAgentSession(session, construction);
17478
+ }
17479
+ if (isDeepStrictEqual(
17480
+ construction.modelSelection,
17481
+ session.construction.modelSelection
17482
+ ) && !acpNativeModelDrifted(session.nativeConfig, construction.modelSelection)) {
17419
17483
  session.construction = construction;
17420
17484
  return session;
17421
17485
  }
17422
- return rebuildAgentSession(session, construction);
17486
+ return applyNativeModelSelection(session, construction);
17487
+ }
17488
+ function launchModelSelection(params) {
17489
+ return {
17490
+ modelSelection: params.modelSelection && "selectFlag" in params.modelSelection ? params.modelSelection : void 0,
17491
+ launchReasoningLevel: params.launchReasoningLevel
17492
+ };
17493
+ }
17494
+ async function applyNativeModelSelection(session, construction) {
17495
+ await selectAcpNativeModel({
17496
+ session,
17497
+ sessionId: session.providerThreadId,
17498
+ modelSelection: construction.modelSelection,
17499
+ nativeReasoning: construction.nativeReasoning
17500
+ });
17501
+ session.construction = construction;
17502
+ return session;
17423
17503
  }
17424
17504
  async function rebuildAgentSession(session, construction) {
17425
17505
  const previousProviderThreadId = session.providerThreadId;
@@ -17565,6 +17645,17 @@ function handleAgentNotification(session, method, params) {
17565
17645
  if (parsed.data.sessionId !== session.providerThreadId) {
17566
17646
  return;
17567
17647
  }
17648
+ if (parsed.data.update.sessionUpdate === "config_option_update") {
17649
+ const configState = acpConfigStateResultSchema.safeParse(
17650
+ parsed.data.update
17651
+ );
17652
+ if (configState.success && configState.data.configOptions) {
17653
+ session.nativeConfig = {
17654
+ ...session.nativeConfig,
17655
+ configOptions: configState.data.configOptions
17656
+ };
17657
+ }
17658
+ }
17568
17659
  if (session.activePromptKind === "compaction") {
17569
17660
  const chunk = acpAgentMessageChunkUpdateSchema.safeParse(
17570
17661
  parsed.data.update
@@ -340,6 +340,7 @@ import { z as z8 } from "zod";
340
340
  // ../domain/src/plugin-interaction-limits.ts
341
341
  var PLUGIN_INTERACTION_MAX_TITLE_LENGTH = 160;
342
342
  var PLUGIN_INTERACTION_MAX_PAYLOAD_BYTES = 64 * 1024;
343
+ var PLUGIN_INTERACTION_MAX_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1e3;
343
344
  function jsonByteLength(value) {
344
345
  return new TextEncoder().encode(JSON.stringify(value)).length;
345
346
  }
@@ -4189,7 +4190,11 @@ function createDeltaAssembler(options) {
4189
4190
 
4190
4191
  // ../provider-bridge-protocol/src/testing/bridge-delta-assembly.ts
4191
4192
  function createBridgeDeltaEventCollector(providerId = "pi") {
4192
- const assembler = createDeltaAssembler({ providerId, textDeltaFlushMs: 0 });
4193
+ const assembler = createDeltaAssembler({
4194
+ providerId,
4195
+ textDeltaFlushMs: 0,
4196
+ now: () => 0
4197
+ });
4193
4198
  return {
4194
4199
  assembler,
4195
4200
  assembleMessage(message) {
@@ -4415,7 +4420,8 @@ var providerHealthSchema = z23.object({
4415
4420
  minimumSupportedVersion: z23.string().min(1).nullable(),
4416
4421
  canInstall: z23.boolean(),
4417
4422
  canUpdate: z23.boolean(),
4418
- loginCommand: z23.string().min(1).nullable()
4423
+ loginCommand: z23.string().min(1).nullable(),
4424
+ localLoginCommand: z23.string().min(1).nullable().optional()
4419
4425
  }).passthrough();
4420
4426
  var providerUsageWindowSchema = z23.object({
4421
4427
  label: z23.string().min(1),