@moxt-ai/mobius 0.0.15 → 0.0.17

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.
Files changed (31) hide show
  1. package/dist/acp/session-config/grok-build-session-config.d.ts +10 -0
  2. package/dist/acp/session-config/grok-build-session-config.d.ts.map +1 -0
  3. package/dist/acp/session-config/grok-build-session-config.js +202 -0
  4. package/dist/acp/session-config/grok-build-session-config.js.map +1 -0
  5. package/dist/acp/session-config/session-config-protocol.d.ts +32 -0
  6. package/dist/acp/session-config/session-config-protocol.d.ts.map +1 -0
  7. package/dist/acp/session-config/session-config-protocol.js +237 -0
  8. package/dist/acp/session-config/session-config-protocol.js.map +1 -0
  9. package/dist/acp/session-config/session-config-registry.d.ts +3 -0
  10. package/dist/acp/session-config/session-config-registry.d.ts.map +1 -0
  11. package/dist/acp/session-config/session-config-registry.js +8 -0
  12. package/dist/acp/session-config/session-config-registry.js.map +1 -0
  13. package/dist/acp/session-manager.d.ts.map +1 -1
  14. package/dist/acp/session-manager.js +29 -155
  15. package/dist/acp/session-manager.js.map +1 -1
  16. package/dist/agent-catalog/agent-specification.d.ts +1 -0
  17. package/dist/agent-catalog/agent-specification.d.ts.map +1 -1
  18. package/dist/agent-catalog/agent-specification.js +1 -0
  19. package/dist/agent-catalog/agent-specification.js.map +1 -1
  20. package/dist/agent-catalog/agents/workbuddy-agent.d.ts +3 -1
  21. package/dist/agent-catalog/agents/workbuddy-agent.d.ts.map +1 -1
  22. package/dist/agent-catalog/agents/workbuddy-agent.js +33 -1
  23. package/dist/agent-catalog/agents/workbuddy-agent.js.map +1 -1
  24. package/dist/agent-catalog/executable-discovery.d.ts.map +1 -1
  25. package/dist/agent-catalog/executable-discovery.js +18 -8
  26. package/dist/agent-catalog/executable-discovery.js.map +1 -1
  27. package/dist/cli.js +641 -254
  28. package/dist/cli.js.map +4 -4
  29. package/dist/index.js +662 -275
  30. package/dist/index.js.map +4 -4
  31. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1131,6 +1131,7 @@ var LocalAgentSpecification = class {
1131
1131
  };
1132
1132
  createLaunchEnvironment = async (_agent, _context) => Object.freeze({});
1133
1133
  recoveryCommand = () => "";
1134
+ resolveInstalledAgentExecutables = (_context) => Promise.resolve([]);
1134
1135
  supportsInstallation = (platform, architecture) => (platform === "darwin" || platform === "linux") && (architecture === "arm64" || architecture === "x64");
1135
1136
  verifyAcp = (_connection, _initialized, _defaultWorkspace, _signal) => Promise.resolve();
1136
1137
  };
@@ -2303,7 +2304,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
2303
2304
  };
2304
2305
 
2305
2306
  // src/agent-catalog/agents/workbuddy-agent.ts
2306
- import { join as join10 } from "node:path";
2307
+ import { isAbsolute as isAbsolute5, join as join10 } from "node:path";
2307
2308
 
2308
2309
  // src/agent-installation/workbuddy-managed-package.ts
2309
2310
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -2323,6 +2324,15 @@ var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
2323
2324
  );
2324
2325
 
2325
2326
  // src/agent-catalog/agents/workbuddy-agent.ts
2327
+ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
2328
+ "WorkBuddy.app",
2329
+ "Contents",
2330
+ "Resources",
2331
+ "app.asar.unpacked",
2332
+ "cli",
2333
+ "bin",
2334
+ "codebuddy"
2335
+ ]);
2326
2336
  var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
2327
2337
  adapterVersion = WORKBUDDY_MANAGED_VERSION;
2328
2338
  authenticationCommand = () => "codebuddy";
@@ -2355,6 +2365,30 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
2355
2365
  signal.throwIfAborted();
2356
2366
  return executable;
2357
2367
  };
2368
+ resolveInstalledAgentExecutables = async (context) => {
2369
+ context.signal.throwIfAborted();
2370
+ if ((context.platform ?? process.platform) !== "darwin") {
2371
+ return [];
2372
+ }
2373
+ const requestedPaths = [
2374
+ join10("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)
2375
+ ];
2376
+ const homeDirectory = context.environment["HOME"];
2377
+ if (homeDirectory !== void 0 && isAbsolute5(homeDirectory)) {
2378
+ requestedPaths.unshift(
2379
+ join10(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)
2380
+ );
2381
+ }
2382
+ const executables = [];
2383
+ for (const requestedPath of requestedPaths) {
2384
+ const executable = await resolveExecutablePath(requestedPath, "darwin");
2385
+ context.signal.throwIfAborted();
2386
+ if (executable !== null) {
2387
+ executables.push(executable);
2388
+ }
2389
+ }
2390
+ return executables;
2391
+ };
2358
2392
  verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
2359
2393
  const capabilities = initialized.agentCapabilities ?? {};
2360
2394
  if (capabilities.loadSession !== true || (initialized.authMethods ?? []).length === 0) {
@@ -2436,7 +2470,7 @@ var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
2436
2470
  );
2437
2471
 
2438
2472
  // src/agent-catalog/executable-discovery.ts
2439
- import { isAbsolute as isAbsolute5, join as join12 } from "node:path";
2473
+ import { isAbsolute as isAbsolute6, join as join12 } from "node:path";
2440
2474
 
2441
2475
  // src/agent-installation/managed-adapter-installer.ts
2442
2476
  import { join as join11 } from "node:path";
@@ -2553,10 +2587,10 @@ async function resolveManagedAdapterExecutable(specification, context) {
2553
2587
  }
2554
2588
  return managed;
2555
2589
  }
2556
- async function resolveSpecificationExecutables(executableName, overrideVariable, resolveManaged, context) {
2590
+ async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
2557
2591
  const override = context.environment[overrideVariable];
2558
2592
  if (override !== void 0) {
2559
- if (override.length === 0 || !isAbsolute5(override)) {
2593
+ if (override.length === 0 || !isAbsolute6(override)) {
2560
2594
  return [];
2561
2595
  }
2562
2596
  const executable = await resolveExecutablePath(override, context.platform);
@@ -2567,19 +2601,30 @@ async function resolveSpecificationExecutables(executableName, overrideVariable,
2567
2601
  context.environment,
2568
2602
  context.platform
2569
2603
  );
2604
+ const installed = await resolveInstalled();
2570
2605
  const managed = await resolveManaged();
2571
- if (external === null) {
2572
- return managed === null ? [] : [managed];
2606
+ const executables = [];
2607
+ const paths = /* @__PURE__ */ new Set();
2608
+ if (external !== null) {
2609
+ executables.push(external);
2610
+ paths.add(external.path);
2611
+ }
2612
+ for (const executable of installed) {
2613
+ if (!paths.has(executable.path)) {
2614
+ executables.push(executable);
2615
+ paths.add(executable.path);
2616
+ }
2573
2617
  }
2574
- if (managed === null || managed.path === external.path) {
2575
- return [external];
2618
+ if (managed !== null && !paths.has(managed.path)) {
2619
+ executables.push(managed);
2576
2620
  }
2577
- return [external, managed];
2621
+ return executables;
2578
2622
  }
2579
2623
  async function resolveAgentExecutables(specification, context) {
2580
2624
  return await resolveSpecificationExecutables(
2581
2625
  specification.agentExecutable,
2582
2626
  specification.agentOverrideVariable,
2627
+ async () => await specification.resolveInstalledAgentExecutables(context),
2583
2628
  async () => await resolveManagedExecutable(specification, context),
2584
2629
  context
2585
2630
  );
@@ -2594,6 +2639,7 @@ async function resolveAdapterExecutables(specification, context) {
2594
2639
  return await resolveSpecificationExecutables(
2595
2640
  specification.adapterExecutable,
2596
2641
  specification.adapterOverrideVariable,
2642
+ () => Promise.resolve([]),
2597
2643
  async () => await resolveManagedAdapterExecutable(specification, context),
2598
2644
  context
2599
2645
  );
@@ -23969,7 +24015,7 @@ import { WebSocket as WebSocket2 } from "undici";
23969
24015
  // src/acp/session-manager.ts
23970
24016
  import { spawn as spawn3 } from "node:child_process";
23971
24017
  import {
23972
- methods as methods5,
24018
+ methods as methods6,
23973
24019
  ndJsonStream as ndJsonStream2,
23974
24020
  PROTOCOL_VERSION as PROTOCOL_VERSION2,
23975
24021
  RequestError as RequestError2
@@ -24483,6 +24529,491 @@ var nativeSessionPageSchema = external_exports.object({
24483
24529
  nextCursor: external_exports.string().min(1).max(4096).nullish()
24484
24530
  }).readonly();
24485
24531
 
24532
+ // src/acp/session-config/session-config-protocol.ts
24533
+ import { methods as methods5 } from "@agentclientprotocol/sdk";
24534
+ var AGENT_DEFAULT_REASONING_EFFORT = "agent_default";
24535
+ var MAXIMUM_CONFIG_OPTIONS = 100;
24536
+ var SessionConfigProtocolError = class extends Error {
24537
+ code = "invalid_session_configuration_response";
24538
+ constructor(message, options = {}) {
24539
+ super(message, options);
24540
+ this.name = "SessionConfigProtocolError";
24541
+ }
24542
+ };
24543
+ function isRecord6(value) {
24544
+ return typeof value === "object" && value !== null && !Array.isArray(value);
24545
+ }
24546
+ function readString2(value, fallback = "") {
24547
+ return typeof value === "string" ? value : fallback;
24548
+ }
24549
+ function truncate2(value, maximum) {
24550
+ return value.length <= maximum ? value : value.slice(0, maximum);
24551
+ }
24552
+ function readBoolean(value, fallback = false) {
24553
+ return typeof value === "boolean" ? value : fallback;
24554
+ }
24555
+ function normalizeConfigValue(option, groupId = "", groupName = "") {
24556
+ return {
24557
+ description: truncate2(readString2(option["description"]), 500),
24558
+ groupId: truncate2(groupId, 128),
24559
+ groupName: truncate2(groupName, 255),
24560
+ name: truncate2(
24561
+ readString2(option["name"], readString2(option["value"])),
24562
+ 255
24563
+ ),
24564
+ value: truncate2(readString2(option["value"]), 500)
24565
+ };
24566
+ }
24567
+ function normalizeConfigValues(value) {
24568
+ if (!Array.isArray(value)) {
24569
+ return [];
24570
+ }
24571
+ const normalized = [];
24572
+ for (const entry of value) {
24573
+ if (!isRecord6(entry)) {
24574
+ continue;
24575
+ }
24576
+ const groupedOptions = entry["options"];
24577
+ if (Array.isArray(groupedOptions)) {
24578
+ const groupId = readString2(entry["group"]);
24579
+ const groupName = readString2(entry["name"]);
24580
+ for (const groupedOption of groupedOptions) {
24581
+ if (isRecord6(groupedOption)) {
24582
+ normalized.push(
24583
+ normalizeConfigValue(groupedOption, groupId, groupName)
24584
+ );
24585
+ }
24586
+ }
24587
+ continue;
24588
+ }
24589
+ normalized.push(normalizeConfigValue(entry));
24590
+ }
24591
+ return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
24592
+ }
24593
+ function normalizeConfigOptions(value, modes) {
24594
+ const normalized = [];
24595
+ if (Array.isArray(value)) {
24596
+ for (const option of value) {
24597
+ if (!isRecord6(option)) {
24598
+ continue;
24599
+ }
24600
+ const id = truncate2(readString2(option["id"]), 128);
24601
+ const name = truncate2(readString2(option["name"], id), 255);
24602
+ if (id.length === 0 || name.length === 0) {
24603
+ continue;
24604
+ }
24605
+ if (option["type"] === "boolean") {
24606
+ normalized.push({
24607
+ booleanValue: readBoolean(option["currentValue"]),
24608
+ category: truncate2(readString2(option["category"]), 128),
24609
+ currentValue: "",
24610
+ description: truncate2(readString2(option["description"]), 500),
24611
+ id,
24612
+ name,
24613
+ type: "boolean",
24614
+ values: []
24615
+ });
24616
+ continue;
24617
+ }
24618
+ if (option["type"] === "select") {
24619
+ const values = normalizeConfigValues(option["options"]);
24620
+ const currentValue = truncate2(readString2(option["currentValue"]), 500);
24621
+ if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
24622
+ normalized.push({
24623
+ booleanValue: false,
24624
+ category: truncate2(readString2(option["category"]), 128),
24625
+ currentValue,
24626
+ description: truncate2(readString2(option["description"]), 500),
24627
+ id,
24628
+ name,
24629
+ type: "select",
24630
+ values
24631
+ });
24632
+ }
24633
+ }
24634
+ }
24635
+ }
24636
+ if (isRecord6(modes)) {
24637
+ const values = [];
24638
+ const availableModes = modes["availableModes"];
24639
+ if (Array.isArray(availableModes)) {
24640
+ for (const mode of availableModes) {
24641
+ if (!isRecord6(mode)) {
24642
+ continue;
24643
+ }
24644
+ const id = truncate2(readString2(mode["id"]), 500);
24645
+ if (id.length === 0) {
24646
+ continue;
24647
+ }
24648
+ values.push({
24649
+ description: truncate2(readString2(mode["description"]), 500),
24650
+ groupId: "",
24651
+ groupName: "",
24652
+ name: truncate2(readString2(mode["name"], id), 255),
24653
+ value: id
24654
+ });
24655
+ }
24656
+ }
24657
+ const currentValue = truncate2(readString2(modes["currentModeId"]), 500);
24658
+ if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue) && !normalized.some((entry) => entry.category === "mode")) {
24659
+ normalized.unshift({
24660
+ booleanValue: false,
24661
+ category: "mode",
24662
+ currentValue,
24663
+ description: "Agent session mode",
24664
+ id: "mode",
24665
+ name: "Mode",
24666
+ type: "select",
24667
+ values
24668
+ });
24669
+ }
24670
+ }
24671
+ return normalized.slice(0, 100);
24672
+ }
24673
+ function ensureReasoningEffortOption(current) {
24674
+ if (current.some((option) => option.category === "thought_level")) {
24675
+ return current;
24676
+ }
24677
+ const unavailable = {
24678
+ booleanValue: false,
24679
+ category: "thought_level",
24680
+ currentValue: AGENT_DEFAULT_REASONING_EFFORT,
24681
+ description: "This Agent does not expose adjustable reasoning effort for the selected model.",
24682
+ id: "reasoning_effort",
24683
+ name: "Reasoning effort",
24684
+ type: "select",
24685
+ values: [
24686
+ {
24687
+ description: "Selected by the Agent",
24688
+ groupId: "",
24689
+ groupName: "",
24690
+ name: "Agent default",
24691
+ value: AGENT_DEFAULT_REASONING_EFFORT
24692
+ }
24693
+ ]
24694
+ };
24695
+ const modelIndex = current.findIndex((option) => option.category === "model");
24696
+ if (current.length < MAXIMUM_CONFIG_OPTIONS) {
24697
+ if (modelIndex < 0) {
24698
+ return [...current, unavailable];
24699
+ }
24700
+ return [
24701
+ ...current.slice(0, modelIndex + 1),
24702
+ unavailable,
24703
+ ...current.slice(modelIndex + 1)
24704
+ ];
24705
+ }
24706
+ if (modelIndex < 0) {
24707
+ return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), unavailable];
24708
+ }
24709
+ if (modelIndex < MAXIMUM_CONFIG_OPTIONS - 1) {
24710
+ return [
24711
+ ...current.slice(0, modelIndex + 1),
24712
+ unavailable,
24713
+ ...current.slice(modelIndex + 1, MAXIMUM_CONFIG_OPTIONS - 1)
24714
+ ];
24715
+ }
24716
+ const model = current[modelIndex];
24717
+ if (model === void 0) {
24718
+ return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 1), unavailable];
24719
+ }
24720
+ return [...current.slice(0, MAXIMUM_CONFIG_OPTIONS - 2), model, unavailable];
24721
+ }
24722
+ function normalizeStandardLifecycle(response) {
24723
+ const lifecycle = isRecord6(response) ? response : {};
24724
+ return ensureReasoningEffortOption(
24725
+ normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"])
24726
+ );
24727
+ }
24728
+ function replaceStandardConfigOptions(current, value) {
24729
+ const next = normalizeConfigOptions(value, void 0);
24730
+ const withMode = next.some((option) => option.category === "mode") ? next : [
24731
+ ...current.filter((option) => option.category === "mode"),
24732
+ ...next
24733
+ ].slice(0, 100);
24734
+ return ensureReasoningEffortOption(withMode);
24735
+ }
24736
+ function updateCurrentValue(current, configId, value) {
24737
+ return current.map(
24738
+ (option) => option.id === configId ? { ...option, currentValue: value } : option
24739
+ );
24740
+ }
24741
+ var StandardSessionConfigProtocol = class {
24742
+ configure = async (current, change, nativeSessionId, transport) => {
24743
+ const existing = current.find((option) => option.id === change.configId);
24744
+ if (existing === void 0) {
24745
+ return current;
24746
+ }
24747
+ if (existing.type === "select" && existing.category === "mode") {
24748
+ await transport.request(
24749
+ methods5.agent.session.setMode,
24750
+ { modeId: change.value, sessionId: nativeSessionId },
24751
+ "ACP agent exited while setting the session mode",
24752
+ change.signal
24753
+ );
24754
+ return updateCurrentValue(current, existing.id, change.value);
24755
+ }
24756
+ const params = existing.type === "boolean" ? {
24757
+ configId: existing.id,
24758
+ sessionId: nativeSessionId,
24759
+ type: "boolean",
24760
+ value: change.booleanValue
24761
+ } : {
24762
+ configId: existing.id,
24763
+ sessionId: nativeSessionId,
24764
+ value: change.value
24765
+ };
24766
+ const response = await transport.request(
24767
+ methods5.agent.session.setConfigOption,
24768
+ params,
24769
+ "ACP agent exited while changing session configuration",
24770
+ change.signal
24771
+ );
24772
+ if (!isRecord6(response) || !Array.isArray(response["configOptions"])) {
24773
+ throw new SessionConfigProtocolError(
24774
+ "The Agent returned an invalid session configuration response"
24775
+ );
24776
+ }
24777
+ return replaceStandardConfigOptions(current, response["configOptions"]);
24778
+ };
24779
+ normalizeLifecycle = (response) => normalizeStandardLifecycle(response);
24780
+ normalizeUpdate = (current, value) => replaceStandardConfigOptions(current, value);
24781
+ };
24782
+ var standardSessionConfigProtocol = new StandardSessionConfigProtocol();
24783
+
24784
+ // src/acp/session-config/grok-build-session-config.ts
24785
+ var LEGACY_MODEL_CONFIG_ID = "grok_build_legacy_model";
24786
+ var LEGACY_REASONING_EFFORT_CONFIG_ID = "grok_build_legacy_reasoning_effort";
24787
+ function legacyOptions(response) {
24788
+ if (!isRecord6(response)) {
24789
+ return [];
24790
+ }
24791
+ const metadata = response["_meta"];
24792
+ if (!isRecord6(metadata)) {
24793
+ return [];
24794
+ }
24795
+ const sessionConfig = metadata["x.ai/sessionConfig"];
24796
+ if (!isRecord6(sessionConfig) || !Array.isArray(sessionConfig["options"])) {
24797
+ return [];
24798
+ }
24799
+ return sessionConfig["options"].slice(0, 500).filter(isRecord6);
24800
+ }
24801
+ function legacyValue(option) {
24802
+ const value = readString2(option["id"]);
24803
+ return {
24804
+ description: readString2(option["description"]).slice(0, 500),
24805
+ groupId: "",
24806
+ groupName: "",
24807
+ name: readString2(option["label"], value).slice(0, 255),
24808
+ value: value.slice(0, 500)
24809
+ };
24810
+ }
24811
+ function modelsRecord(response) {
24812
+ if (!isRecord6(response) || !isRecord6(response["models"])) {
24813
+ return {};
24814
+ }
24815
+ return response["models"];
24816
+ }
24817
+ function legacyModelOptions(response) {
24818
+ const options = legacyOptions(response);
24819
+ const models = modelsRecord(response);
24820
+ const values = [];
24821
+ for (const option of options) {
24822
+ if (option["category"] === "model") {
24823
+ const value = legacyValue(option);
24824
+ if (value.value.length > 0 && !values.some((existing) => existing.value === value.value)) {
24825
+ values.push(value);
24826
+ }
24827
+ }
24828
+ }
24829
+ if (values.length === 0 && Array.isArray(models["availableModels"])) {
24830
+ for (const model of models["availableModels"]) {
24831
+ if (!isRecord6(model)) {
24832
+ continue;
24833
+ }
24834
+ const value = readString2(model["modelId"]).slice(0, 500);
24835
+ if (value.length === 0) {
24836
+ continue;
24837
+ }
24838
+ if (!values.some((existing) => existing.value === value)) {
24839
+ values.push({
24840
+ description: "",
24841
+ groupId: "",
24842
+ groupName: "",
24843
+ name: readString2(model["name"], value).slice(0, 255),
24844
+ value
24845
+ });
24846
+ }
24847
+ }
24848
+ }
24849
+ const selected = options.find(
24850
+ (option) => option["category"] === "model" && option["selected"] === true
24851
+ );
24852
+ const currentValue = readString2(
24853
+ models["currentModelId"],
24854
+ selected === void 0 ? "" : readString2(selected["id"])
24855
+ ).slice(0, 500);
24856
+ if (values.length === 0 || !values.some((value) => value.value === currentValue)) {
24857
+ return [];
24858
+ }
24859
+ const result = {
24860
+ booleanValue: false,
24861
+ category: "model",
24862
+ currentValue,
24863
+ description: "Model used by Grok Build",
24864
+ id: LEGACY_MODEL_CONFIG_ID,
24865
+ name: "Model",
24866
+ type: "select",
24867
+ values: values.slice(0, 500)
24868
+ };
24869
+ return [result];
24870
+ }
24871
+ function legacyReasoningEffortOptions(response) {
24872
+ const options = legacyOptions(response);
24873
+ const values = [];
24874
+ for (const option of options) {
24875
+ if (option["category"] !== "mode") {
24876
+ continue;
24877
+ }
24878
+ const value = legacyValue(option);
24879
+ if (value.value.length > 0 && !values.some((existing) => existing.value === value.value)) {
24880
+ values.push(value);
24881
+ }
24882
+ }
24883
+ if (values.length === 0) {
24884
+ return [];
24885
+ }
24886
+ const selected = options.find(
24887
+ (option) => option["category"] === "mode" && option["selected"] === true
24888
+ );
24889
+ if (selected === void 0) {
24890
+ values.unshift({
24891
+ description: "Use the selected model's default reasoning effort",
24892
+ groupId: "",
24893
+ groupName: "",
24894
+ name: "Agent default",
24895
+ value: AGENT_DEFAULT_REASONING_EFFORT
24896
+ });
24897
+ }
24898
+ const currentValue = selected === void 0 ? AGENT_DEFAULT_REASONING_EFFORT : readString2(selected["id"], AGENT_DEFAULT_REASONING_EFFORT);
24899
+ if (!values.some((value) => value.value === currentValue)) {
24900
+ return [];
24901
+ }
24902
+ const result = {
24903
+ booleanValue: false,
24904
+ category: "thought_level",
24905
+ currentValue,
24906
+ description: "Reasoning effort used by Grok Build",
24907
+ id: LEGACY_REASONING_EFFORT_CONFIG_ID,
24908
+ name: "Reasoning effort",
24909
+ type: "select",
24910
+ values: values.slice(0, 500)
24911
+ };
24912
+ return [result];
24913
+ }
24914
+ function normalizeGrokLifecycle(response) {
24915
+ const lifecycle = isRecord6(response) ? response : {};
24916
+ const standard = normalizeConfigOptions(
24917
+ lifecycle["configOptions"],
24918
+ lifecycle["modes"]
24919
+ );
24920
+ const normalized = [...standard];
24921
+ if (!normalized.some((option) => option.category === "model")) {
24922
+ normalized.push(...legacyModelOptions(response));
24923
+ }
24924
+ if (!normalized.some((option) => option.category === "thought_level")) {
24925
+ const efforts = legacyReasoningEffortOptions(response);
24926
+ if (efforts.length > 0) {
24927
+ const modelIndex = normalized.findIndex(
24928
+ (option) => option.category === "model"
24929
+ );
24930
+ normalized.splice(
24931
+ modelIndex < 0 ? normalized.length : modelIndex + 1,
24932
+ 0,
24933
+ ...efforts
24934
+ );
24935
+ }
24936
+ }
24937
+ return ensureReasoningEffortOption(normalized.slice(0, 100));
24938
+ }
24939
+ function updateCurrentValue2(current, category, value) {
24940
+ return current.map(
24941
+ (option) => option.category === category ? { ...option, currentValue: value } : option
24942
+ );
24943
+ }
24944
+ function validateGrokResponse(response, modelId) {
24945
+ if (!isRecord6(response) || !isRecord6(response["_meta"])) {
24946
+ throw new SessionConfigProtocolError(
24947
+ "Grok Build returned an invalid session configuration response"
24948
+ );
24949
+ }
24950
+ const model = response["_meta"]["model"];
24951
+ const appliedModel = isRecord6(model) ? model["Ok"] : model;
24952
+ if (appliedModel !== modelId) {
24953
+ throw new SessionConfigProtocolError(
24954
+ "Grok Build returned an invalid session configuration response"
24955
+ );
24956
+ }
24957
+ }
24958
+ var GrokBuildSessionConfigProtocol = class {
24959
+ configure = async (current, change, nativeSessionId, transport) => {
24960
+ const existing = current.find((option) => option.id === change.configId);
24961
+ if (existing === void 0 || existing.id !== LEGACY_MODEL_CONFIG_ID && existing.id !== LEGACY_REASONING_EFFORT_CONFIG_ID) {
24962
+ return await standardSessionConfigProtocol.configure(
24963
+ current,
24964
+ change,
24965
+ nativeSessionId,
24966
+ transport
24967
+ );
24968
+ }
24969
+ const model = current.find((option) => option.category === "model");
24970
+ if (model === void 0) {
24971
+ return current;
24972
+ }
24973
+ if (existing.category === "thought_level" && change.value === AGENT_DEFAULT_REASONING_EFFORT) {
24974
+ return current;
24975
+ }
24976
+ const modelId = existing.category === "model" ? change.value : model.currentValue;
24977
+ const params = {
24978
+ modelId,
24979
+ sessionId: nativeSessionId
24980
+ };
24981
+ if (existing.category === "thought_level") {
24982
+ params["_meta"] = {
24983
+ reasoningEffort: change.value
24984
+ };
24985
+ }
24986
+ const response = await transport.request(
24987
+ "session/set_model",
24988
+ params,
24989
+ existing.category === "model" ? "Grok Build exited while setting the session model" : "Grok Build exited while setting reasoning effort",
24990
+ change.signal
24991
+ );
24992
+ validateGrokResponse(response, modelId);
24993
+ const updated = updateCurrentValue2(
24994
+ current,
24995
+ existing.category,
24996
+ change.value
24997
+ );
24998
+ return existing.category === "thought_level" ? updated.map(
24999
+ (option) => option.category === "thought_level" ? {
25000
+ ...option,
25001
+ values: option.values.filter(
25002
+ (value) => value.value !== AGENT_DEFAULT_REASONING_EFFORT
25003
+ )
25004
+ } : option
25005
+ ) : updated;
25006
+ };
25007
+ normalizeLifecycle = (response) => normalizeGrokLifecycle(response);
25008
+ normalizeUpdate = (current, value) => standardSessionConfigProtocol.normalizeUpdate(current, value);
25009
+ };
25010
+ var grokBuildSessionConfigProtocol = new GrokBuildSessionConfigProtocol();
25011
+
25012
+ // src/acp/session-config/session-config-registry.ts
25013
+ function sessionConfigProtocolForAgent(agentId) {
25014
+ return agentId === "grok-build" ? grokBuildSessionConfigProtocol : standardSessionConfigProtocol;
25015
+ }
25016
+
24486
25017
  // src/acp/session-history.ts
24487
25018
  var AcpHistoryReplay = class {
24488
25019
  #messages = [];
@@ -24587,7 +25118,7 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
24587
25118
  var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
24588
25119
  found = false;
24589
25120
  };
24590
- function readString2(value, field) {
25121
+ function readString3(value, field) {
24591
25122
  if (typeof value !== "string" || value.length === 0) {
24592
25123
  throw new Error(`Stored ACP session has an invalid ${field}`);
24593
25124
  }
@@ -24617,10 +25148,10 @@ function decodeSessionRow(row) {
24617
25148
  throw new Error("Stored ACP session is not an object");
24618
25149
  }
24619
25150
  return new AcpStoredSession(
24620
- readString2(Reflect.get(row, "session_id"), "session ID"),
24621
- readString2(Reflect.get(row, "agent_id"), "agent ID"),
24622
- readString2(Reflect.get(row, "native_session_id"), "native session ID"),
24623
- readString2(Reflect.get(row, "cwd"), "working directory"),
25151
+ readString3(Reflect.get(row, "session_id"), "session ID"),
25152
+ readString3(Reflect.get(row, "agent_id"), "agent ID"),
25153
+ readString3(Reflect.get(row, "native_session_id"), "native session ID"),
25154
+ readString3(Reflect.get(row, "cwd"), "working directory"),
24624
25155
  readAdditionalDirectories(Reflect.get(row, "additional_directories_json")),
24625
25156
  readPrompted(Reflect.get(row, "prompted"))
24626
25157
  );
@@ -24882,149 +25413,18 @@ function createWritableAcpStream(output2) {
24882
25413
  }
24883
25414
  });
24884
25415
  }
24885
- function truncate2(value, maximumLength) {
25416
+ function truncate3(value, maximumLength) {
24886
25417
  return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
24887
25418
  }
24888
- function isRecord6(value) {
25419
+ function isRecord7(value) {
24889
25420
  return typeof value === "object" && value !== null && !Array.isArray(value);
24890
25421
  }
24891
- function readString3(value, fallback = "") {
25422
+ function readString4(value, fallback = "") {
24892
25423
  return typeof value === "string" ? value : fallback;
24893
25424
  }
24894
- function readBoolean(value, fallback = false) {
24895
- return typeof value === "boolean" ? value : fallback;
24896
- }
24897
25425
  function arraysEqual(left, right) {
24898
25426
  return left.length === right.length && left.every((value, index) => value === right[index]);
24899
25427
  }
24900
- function normalizeConfigValue(option, groupId = "", groupName = "") {
24901
- return {
24902
- description: truncate2(readString3(option["description"]), 500),
24903
- groupId: truncate2(groupId, 128),
24904
- groupName: truncate2(groupName, 255),
24905
- name: truncate2(
24906
- readString3(option["name"], readString3(option["value"])),
24907
- 255
24908
- ),
24909
- value: truncate2(readString3(option["value"]), 500)
24910
- };
24911
- }
24912
- function normalizeConfigValues(value) {
24913
- if (!Array.isArray(value)) {
24914
- return [];
24915
- }
24916
- const normalized = [];
24917
- for (const entry of value) {
24918
- if (!isRecord6(entry)) {
24919
- continue;
24920
- }
24921
- const groupedOptions = entry["options"];
24922
- if (Array.isArray(groupedOptions)) {
24923
- const groupId = readString3(entry["group"]);
24924
- const groupName = readString3(entry["name"]);
24925
- for (const groupedOption of groupedOptions) {
24926
- if (isRecord6(groupedOption)) {
24927
- normalized.push(
24928
- normalizeConfigValue(groupedOption, groupId, groupName)
24929
- );
24930
- }
24931
- }
24932
- continue;
24933
- }
24934
- normalized.push(normalizeConfigValue(entry));
24935
- }
24936
- return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
24937
- }
24938
- function normalizeConfigOptions(value, modes) {
24939
- const normalized = [];
24940
- if (Array.isArray(value)) {
24941
- for (const option of value) {
24942
- if (!isRecord6(option)) {
24943
- continue;
24944
- }
24945
- const id = truncate2(readString3(option["id"]), 128);
24946
- const name = truncate2(readString3(option["name"], id), 255);
24947
- if (id.length === 0 || name.length === 0) {
24948
- continue;
24949
- }
24950
- if (option["type"] === "boolean") {
24951
- normalized.push({
24952
- booleanValue: readBoolean(option["currentValue"]),
24953
- category: truncate2(readString3(option["category"]), 128),
24954
- currentValue: "",
24955
- description: truncate2(readString3(option["description"]), 500),
24956
- id,
24957
- name,
24958
- type: "boolean",
24959
- values: []
24960
- });
24961
- continue;
24962
- }
24963
- if (option["type"] === "select") {
24964
- const values = normalizeConfigValues(option["options"]);
24965
- const currentValue = truncate2(readString3(option["currentValue"]), 500);
24966
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
24967
- normalized.push({
24968
- booleanValue: false,
24969
- category: truncate2(readString3(option["category"]), 128),
24970
- currentValue,
24971
- description: truncate2(readString3(option["description"]), 500),
24972
- id,
24973
- name,
24974
- type: "select",
24975
- values
24976
- });
24977
- }
24978
- }
24979
- }
24980
- }
24981
- if (isRecord6(modes)) {
24982
- const values = [];
24983
- const availableModes = modes["availableModes"];
24984
- if (Array.isArray(availableModes)) {
24985
- for (const mode of availableModes) {
24986
- if (!isRecord6(mode)) {
24987
- continue;
24988
- }
24989
- const id = truncate2(readString3(mode["id"]), 500);
24990
- if (id.length === 0) {
24991
- continue;
24992
- }
24993
- values.push({
24994
- description: truncate2(readString3(mode["description"]), 500),
24995
- groupId: "",
24996
- groupName: "",
24997
- name: truncate2(readString3(mode["name"], id), 255),
24998
- value: id
24999
- });
25000
- }
25001
- }
25002
- const currentValue = truncate2(readString3(modes["currentModeId"]), 500);
25003
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue) && !normalized.some((entry) => entry.category === "mode")) {
25004
- normalized.unshift({
25005
- booleanValue: false,
25006
- category: "mode",
25007
- currentValue,
25008
- description: "Agent session mode",
25009
- id: "mode",
25010
- name: "Mode",
25011
- type: "select",
25012
- values
25013
- });
25014
- }
25015
- }
25016
- return normalized.slice(0, 100);
25017
- }
25018
- function replaceConfigOptionsKeepingMode(current, value) {
25019
- const next = normalizeConfigOptions(value, void 0);
25020
- if (next.some((option) => option.category === "mode")) {
25021
- return next;
25022
- }
25023
- return [
25024
- ...current.filter((option) => option.category === "mode"),
25025
- ...next
25026
- ].slice(0, 100);
25027
- }
25028
25428
  function normalizeCapabilities(capabilities) {
25029
25429
  const session = capabilities.sessionCapabilities;
25030
25430
  const prompt = capabilities.promptCapabilities;
@@ -25061,11 +25461,11 @@ function normalizeElicitationOptions(schema) {
25061
25461
  const oneOf = schema["oneOf"];
25062
25462
  if (Array.isArray(oneOf)) {
25063
25463
  for (const option of oneOf) {
25064
- if (isRecord6(option) && typeof option["const"] === "string") {
25464
+ if (isRecord7(option) && typeof option["const"] === "string") {
25065
25465
  normalized.push({
25066
- description: truncate2(readString3(option["description"]), 500),
25067
- label: truncate2(readString3(option["title"], option["const"]), 255),
25068
- value: truncate2(option["const"], 500)
25466
+ description: truncate3(readString4(option["description"]), 500),
25467
+ label: truncate3(readString4(option["title"], option["const"]), 255),
25468
+ value: truncate3(option["const"], 500)
25069
25469
  });
25070
25470
  }
25071
25471
  }
@@ -25081,7 +25481,7 @@ function normalizeElicitationOptions(schema) {
25081
25481
  return normalized.slice(0, 200);
25082
25482
  }
25083
25483
  const items = schema["items"];
25084
- if (!isRecord6(items)) {
25484
+ if (!isRecord7(items)) {
25085
25485
  return normalized;
25086
25486
  }
25087
25487
  const anyOf = items["anyOf"];
@@ -25094,7 +25494,7 @@ function numericString(value) {
25094
25494
  return typeof value === "number" && Number.isFinite(value) ? value.toString() : "";
25095
25495
  }
25096
25496
  function normalizeElicitationFields(requestedSchema) {
25097
- if (!isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
25497
+ if (!isRecord7(requestedSchema) || !isRecord7(requestedSchema["properties"])) {
25098
25498
  return [];
25099
25499
  }
25100
25500
  const properties = requestedSchema["properties"];
@@ -25104,7 +25504,7 @@ function normalizeElicitationFields(requestedSchema) {
25104
25504
  );
25105
25505
  const normalized = [];
25106
25506
  for (const [name, property] of Object.entries(properties)) {
25107
- if (!isRecord6(property)) {
25507
+ if (!isRecord7(property)) {
25108
25508
  continue;
25109
25509
  }
25110
25510
  const type = elicitationFieldType(property["type"]);
@@ -25114,9 +25514,9 @@ function normalizeElicitationFields(requestedSchema) {
25114
25514
  normalized.push({
25115
25515
  defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
25116
25516
  defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
25117
- defaultStringValue: typeof defaultValue === "string" ? truncate2(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate2(JSON.stringify(defaultValue), 1e4) : "",
25118
- description: truncate2(readString3(property["description"]), 500),
25119
- format: truncate2(readString3(property["format"]), 64),
25517
+ defaultStringValue: typeof defaultValue === "string" ? truncate3(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate3(JSON.stringify(defaultValue), 1e4) : "",
25518
+ description: truncate3(readString4(property["description"]), 500),
25519
+ format: truncate3(readString4(property["format"]), 64),
25120
25520
  hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
25121
25521
  maximum: numericString(property["maximum"]),
25122
25522
  maximumLength: numericString(
@@ -25126,11 +25526,11 @@ function normalizeElicitationFields(requestedSchema) {
25126
25526
  minimumLength: numericString(
25127
25527
  property["minLength"] ?? property["minItems"]
25128
25528
  ),
25129
- name: truncate2(name, 128),
25529
+ name: truncate3(name, 128),
25130
25530
  options,
25131
- pattern: truncate2(readString3(property["pattern"]), 500),
25531
+ pattern: truncate3(readString4(property["pattern"]), 500),
25132
25532
  required: required2.has(name),
25133
- title: truncate2(readString3(property["title"], name), 255),
25533
+ title: truncate3(readString4(property["title"], name), 255),
25134
25534
  type: normalizedType
25135
25535
  });
25136
25536
  }
@@ -25199,7 +25599,7 @@ function validateElicitationContent(encoded, requestedSchema) {
25199
25599
  "invalid_elicitation_response"
25200
25600
  );
25201
25601
  }
25202
- if (!isRecord6(decoded) || !isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
25602
+ if (!isRecord7(decoded) || !isRecord7(requestedSchema) || !isRecord7(requestedSchema["properties"])) {
25203
25603
  throw new AcpExecutionError(
25204
25604
  "Elicitation response does not match the requested form",
25205
25605
  {},
@@ -25223,7 +25623,7 @@ function validateElicitationContent(encoded, requestedSchema) {
25223
25623
  const validated = {};
25224
25624
  for (const [name, value] of Object.entries(decoded)) {
25225
25625
  const property = properties[name];
25226
- if (!isRecord6(property)) {
25626
+ if (!isRecord7(property)) {
25227
25627
  throw new AcpExecutionError(
25228
25628
  `Elicitation field ${name} was not requested`,
25229
25629
  {},
@@ -25375,6 +25775,7 @@ var AcpProcessSession = class _AcpProcessSession {
25375
25775
  #pendingPermissions = /* @__PURE__ */ new Map();
25376
25776
  #preSessionUpdates = [];
25377
25777
  #processExit;
25778
+ #sessionConfigProtocol;
25378
25779
  #store;
25379
25780
  #verifiedAgentVersion;
25380
25781
  #preSessionUpdateBytes = 0;
@@ -25393,6 +25794,7 @@ var AcpProcessSession = class _AcpProcessSession {
25393
25794
  unstableForkSession: false
25394
25795
  };
25395
25796
  #commands = [];
25797
+ #configRevision = 0;
25396
25798
  #configOptions = [];
25397
25799
  #nativeSessionId = "";
25398
25800
  #prompted = false;
@@ -25410,6 +25812,7 @@ var AcpProcessSession = class _AcpProcessSession {
25410
25812
  this.#cwd = cwd;
25411
25813
  this.#getObserver = getObserver;
25412
25814
  this.#mobiusSessionId = mobiusSessionId;
25815
+ this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
25413
25816
  this.#store = store;
25414
25817
  this.#verifiedAgentVersion = agent.agentVersion;
25415
25818
  this.#child = spawn3(agent.adapterPath, [...agent.arguments], {
@@ -25514,7 +25917,7 @@ var AcpProcessSession = class _AcpProcessSession {
25514
25917
  try {
25515
25918
  await this.race(
25516
25919
  this.#connection.agent.request(
25517
- methods5.agent.session.load,
25920
+ methods6.agent.session.load,
25518
25921
  {
25519
25922
  additionalDirectories: [...this.#additionalDirectories],
25520
25923
  cwd: this.#cwd,
@@ -25536,7 +25939,7 @@ var AcpProcessSession = class _AcpProcessSession {
25536
25939
  async #initializeAgent(signal) {
25537
25940
  const initialized = await this.race(
25538
25941
  this.#connection.agent.request(
25539
- methods5.agent.initialize,
25942
+ methods6.agent.initialize,
25540
25943
  {
25541
25944
  clientCapabilities: {
25542
25945
  elicitation: { form: {}, url: {} },
@@ -25563,11 +25966,11 @@ var AcpProcessSession = class _AcpProcessSession {
25563
25966
  }
25564
25967
  const capabilities = initialized.agentCapabilities ?? {};
25565
25968
  this.#capabilities = normalizeCapabilities(capabilities);
25566
- this.#agentName = truncate2(
25969
+ this.#agentName = truncate3(
25567
25970
  initialized.agentInfo?.title ?? initialized.agentInfo?.name ?? this.#agentId,
25568
25971
  255
25569
25972
  );
25570
- this.#agentVersion = truncate2(
25973
+ this.#agentVersion = truncate3(
25571
25974
  this.#verifiedAgentVersion.length > 0 ? this.#verifiedAgentVersion : initialized.agentInfo?.version ?? "",
25572
25975
  128
25573
25976
  );
@@ -25604,7 +26007,7 @@ var AcpProcessSession = class _AcpProcessSession {
25604
26007
  );
25605
26008
  const forked = await this.race(
25606
26009
  this.#connection.agent.request(
25607
- methods5.agent.session.fork,
26010
+ methods6.agent.session.fork,
25608
26011
  {
25609
26012
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
25610
26013
  cwd: this.#cwd,
@@ -25637,7 +26040,7 @@ var AcpProcessSession = class _AcpProcessSession {
25637
26040
  if (this.#capabilities.resumeSession) {
25638
26041
  lifecycleResponse = await this.race(
25639
26042
  this.#connection.agent.request(
25640
- methods5.agent.session.resume,
26043
+ methods6.agent.session.resume,
25641
26044
  {
25642
26045
  additionalDirectories: [...this.#additionalDirectories],
25643
26046
  cwd: this.#cwd,
@@ -25654,7 +26057,7 @@ var AcpProcessSession = class _AcpProcessSession {
25654
26057
  try {
25655
26058
  lifecycleResponse = await this.race(
25656
26059
  this.#connection.agent.request(
25657
- methods5.agent.session.load,
26060
+ methods6.agent.session.load,
25658
26061
  {
25659
26062
  additionalDirectories: [...this.#additionalDirectories],
25660
26063
  cwd: this.#cwd,
@@ -25690,7 +26093,7 @@ var AcpProcessSession = class _AcpProcessSession {
25690
26093
  }
25691
26094
  const created = await this.race(
25692
26095
  this.#connection.agent.request(
25693
- methods5.agent.session.new,
26096
+ methods6.agent.session.new,
25694
26097
  {
25695
26098
  additionalDirectories: [...this.#additionalDirectories],
25696
26099
  cwd: this.#cwd,
@@ -25704,11 +26107,7 @@ var AcpProcessSession = class _AcpProcessSession {
25704
26107
  this.selectNativeSession(created.sessionId);
25705
26108
  lifecycleResponse = created;
25706
26109
  }
25707
- const lifecycleRecord = isRecord6(lifecycleResponse) ? lifecycleResponse : {};
25708
- this.#configOptions = normalizeConfigOptions(
25709
- lifecycleRecord["configOptions"],
25710
- lifecycleRecord["modes"]
25711
- );
26110
+ this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
25712
26111
  await this.#updateTail;
25713
26112
  signal.throwIfAborted();
25714
26113
  if (this.#prompted) {
@@ -25733,7 +26132,7 @@ var AcpProcessSession = class _AcpProcessSession {
25733
26132
  );
25734
26133
  const response = await this.race(
25735
26134
  this.#connection.agent.request(
25736
- methods5.agent.session.list,
26135
+ methods6.agent.session.list,
25737
26136
  cursor === null ? {} : { cursor },
25738
26137
  { cancellationSignal: signal }
25739
26138
  ),
@@ -25758,7 +26157,7 @@ var AcpProcessSession = class _AcpProcessSession {
25758
26157
  );
25759
26158
  await this.race(
25760
26159
  this.#connection.agent.request(
25761
- methods5.agent.session.delete,
26160
+ methods6.agent.session.delete,
25762
26161
  { sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
25763
26162
  { cancellationSignal: signal }
25764
26163
  ),
@@ -25779,64 +26178,50 @@ var AcpProcessSession = class _AcpProcessSession {
25779
26178
  );
25780
26179
  }
25781
26180
  if (existing.type === "select") {
25782
- if (!existing.values.some((entry) => entry.value === options.value)) {
26181
+ if (existing.values.length < 2) {
25783
26182
  throw new AcpExecutionError(
25784
- "The requested ACP configuration value is unavailable",
26183
+ "The requested ACP configuration option is unavailable",
25785
26184
  {},
25786
26185
  "invalid_session_configuration"
25787
26186
  );
25788
26187
  }
25789
- if (existing.category === "mode") {
25790
- await this.race(
25791
- this.#connection.agent.request(
25792
- methods5.agent.session.setMode,
25793
- { modeId: options.value, sessionId: this.#nativeSessionId },
25794
- { cancellationSignal: options.signal }
25795
- ),
25796
- "ACP agent exited while setting the session mode",
25797
- options.signal
25798
- );
25799
- this.#configOptions = this.#configOptions.map(
25800
- (option) => option.id === existing.id ? { ...option, currentValue: options.value } : option
25801
- );
25802
- } else {
25803
- const response = await this.race(
25804
- this.#connection.agent.request(
25805
- methods5.agent.session.setConfigOption,
25806
- {
25807
- configId: existing.id,
25808
- sessionId: this.#nativeSessionId,
25809
- value: options.value
25810
- },
25811
- { cancellationSignal: options.signal }
25812
- ),
25813
- "ACP agent exited while changing session configuration",
25814
- options.signal
25815
- );
25816
- this.#configOptions = replaceConfigOptionsKeepingMode(
25817
- this.#configOptions,
25818
- response.configOptions
26188
+ if (!existing.values.some((entry) => entry.value === options.value)) {
26189
+ throw new AcpExecutionError(
26190
+ "The requested ACP configuration value is unavailable",
26191
+ {},
26192
+ "invalid_session_configuration"
25819
26193
  );
25820
26194
  }
25821
- } else {
25822
- const response = await this.race(
25823
- this.#connection.agent.request(
25824
- methods5.agent.session.setConfigOption,
25825
- {
25826
- configId: existing.id,
25827
- sessionId: this.#nativeSessionId,
25828
- type: "boolean",
25829
- value: options.booleanValue
25830
- },
25831
- { cancellationSignal: options.signal }
25832
- ),
25833
- "ACP agent exited while changing session configuration",
25834
- options.signal
25835
- );
25836
- this.#configOptions = replaceConfigOptionsKeepingMode(
26195
+ }
26196
+ const configRevision = this.#configRevision;
26197
+ try {
26198
+ const configured = await this.#sessionConfigProtocol.configure(
25837
26199
  this.#configOptions,
25838
- response.configOptions
26200
+ options,
26201
+ this.#nativeSessionId,
26202
+ {
26203
+ request: async (method, params, failureMessage, signal) => await this.race(
26204
+ this.#connection.agent.request(method, params, {
26205
+ cancellationSignal: signal
26206
+ }),
26207
+ failureMessage,
26208
+ signal
26209
+ )
26210
+ }
25839
26211
  );
26212
+ await this.#updateTail;
26213
+ if (this.#configRevision === configRevision) {
26214
+ this.#configOptions = configured;
26215
+ }
26216
+ } catch (error61) {
26217
+ if (error61 instanceof SessionConfigProtocolError) {
26218
+ throw new AcpExecutionError(
26219
+ error61.message,
26220
+ { cause: error61 },
26221
+ error61.code
26222
+ );
26223
+ }
26224
+ throw error61;
25840
26225
  }
25841
26226
  return this.#configOptions;
25842
26227
  };
@@ -25920,7 +26305,7 @@ var AcpProcessSession = class _AcpProcessSession {
25920
26305
  try {
25921
26306
  const response = await this.race(
25922
26307
  this.#connection.agent.request(
25923
- methods5.agent.session.prompt,
26308
+ methods6.agent.session.prompt,
25924
26309
  { prompt, sessionId: this.#nativeSessionId },
25925
26310
  { cancellationSignal: options.signal }
25926
26311
  ),
@@ -25967,7 +26352,7 @@ var AcpProcessSession = class _AcpProcessSession {
25967
26352
  try {
25968
26353
  await this.cancelPendingInteractions();
25969
26354
  if (this.#turn.running) {
25970
- await this.#connection.agent.notify(methods5.agent.session.cancel, {
26355
+ await this.#connection.agent.notify(methods6.agent.session.cancel, {
25971
26356
  sessionId: this.#nativeSessionId
25972
26357
  });
25973
26358
  }
@@ -26057,8 +26442,8 @@ var AcpProcessSession = class _AcpProcessSession {
26057
26442
  const interactionId = `permission-${crypto.randomUUID()}`;
26058
26443
  const options = request.options.slice(0, 20).map((option) => ({
26059
26444
  kind: option.kind,
26060
- name: truncate2(option.name, 255),
26061
- optionId: truncate2(option.optionId, 255)
26445
+ name: truncate3(option.name, 255),
26446
+ optionId: truncate3(option.optionId, 255)
26062
26447
  }));
26063
26448
  if (options.length === 0) {
26064
26449
  throw new AcpExecutionError(
@@ -26083,9 +26468,9 @@ var AcpProcessSession = class _AcpProcessSession {
26083
26468
  kind: SESSION_PERMISSION_REQUESTED_KIND,
26084
26469
  options,
26085
26470
  sessionId: this.#mobiusSessionId,
26086
- title: truncate2(request.toolCall.title ?? "Permission required", 500),
26087
- toolCallId: truncate2(request.toolCall.toolCallId, 255),
26088
- toolKind: truncate2(request.toolCall.kind ?? "other", 64)
26471
+ title: truncate3(request.toolCall.title ?? "Permission required", 500),
26472
+ toolCallId: truncate3(request.toolCall.toolCallId, 255),
26473
+ toolKind: truncate3(request.toolCall.kind ?? "other", 64)
26089
26474
  });
26090
26475
  return await pending.completion.promise;
26091
26476
  } finally {
@@ -26114,7 +26499,7 @@ var AcpProcessSession = class _AcpProcessSession {
26114
26499
  const schemaValue = Reflect.get(request, "requestedSchema");
26115
26500
  const requestedSchema = request.mode === "form" ? schemaValue : {};
26116
26501
  const elicitationIdValue = Reflect.get(request, "elicitationId");
26117
- const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate2(elicitationIdValue, 255) : "";
26502
+ const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate3(elicitationIdValue, 255) : "";
26118
26503
  const pending = new PendingElicitation(
26119
26504
  interactionId,
26120
26505
  elicitationId,
@@ -26133,10 +26518,10 @@ var AcpProcessSession = class _AcpProcessSession {
26133
26518
  fields: normalizeElicitationFields(requestedSchema),
26134
26519
  interactionId,
26135
26520
  kind: SESSION_ELICITATION_REQUESTED_KIND,
26136
- message: truncate2(request.message, 2e3),
26521
+ message: truncate3(request.message, 2e3),
26137
26522
  mode: request.mode,
26138
26523
  sessionId: this.#mobiusSessionId,
26139
- url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate2(readString3(Reflect.get(request, "url")), 4096) : ""
26524
+ url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate3(readString4(Reflect.get(request, "url")), 4096) : ""
26140
26525
  });
26141
26526
  return await pending.completion.promise;
26142
26527
  } finally {
@@ -26225,7 +26610,7 @@ var AcpProcessSession = class _AcpProcessSession {
26225
26610
  content: normalizeContentBlock(update.content),
26226
26611
  contentId: `content-${crypto.randomUUID()}`,
26227
26612
  kind: AGENT_CONTENT_KIND,
26228
- messageId: truncate2(update.messageId ?? "", 255),
26613
+ messageId: truncate3(update.messageId ?? "", 255),
26229
26614
  sessionId: this.#mobiusSessionId
26230
26615
  });
26231
26616
  }
@@ -26263,9 +26648,9 @@ var AcpProcessSession = class _AcpProcessSession {
26263
26648
  }
26264
26649
  if (update.sessionUpdate === "available_commands_update") {
26265
26650
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
26266
- description: truncate2(command.description, 500),
26267
- inputHint: truncate2(command.input?.hint ?? "", 255),
26268
- name: truncate2(command.name, 128)
26651
+ description: truncate3(command.description, 500),
26652
+ inputHint: truncate3(command.input?.hint ?? "", 255),
26653
+ name: truncate3(command.name, 128)
26269
26654
  })).filter((command) => command.name.length > 0);
26270
26655
  this.#commands = commands;
26271
26656
  await this.#getObserver().onCommands({
@@ -26276,10 +26661,11 @@ var AcpProcessSession = class _AcpProcessSession {
26276
26661
  return;
26277
26662
  }
26278
26663
  if (update.sessionUpdate === "config_option_update") {
26279
- this.#configOptions = replaceConfigOptionsKeepingMode(
26664
+ this.#configOptions = this.#sessionConfigProtocol.normalizeUpdate(
26280
26665
  this.#configOptions,
26281
26666
  update.configOptions
26282
26667
  );
26668
+ this.#configRevision += 1;
26283
26669
  await this.emitConfigUpdate();
26284
26670
  return;
26285
26671
  }
@@ -26287,15 +26673,16 @@ var AcpProcessSession = class _AcpProcessSession {
26287
26673
  this.#configOptions = this.#configOptions.map(
26288
26674
  (option) => option.category === "mode" ? { ...option, currentValue: update.currentModeId } : option
26289
26675
  );
26676
+ this.#configRevision += 1;
26290
26677
  await this.emitConfigUpdate();
26291
26678
  return;
26292
26679
  }
26293
26680
  if (update.sessionUpdate === "session_info_update") {
26294
26681
  if (Object.hasOwn(update, "title")) {
26295
- this.#sessionTitle = truncate2(update.title ?? "", 500);
26682
+ this.#sessionTitle = truncate3(update.title ?? "", 500);
26296
26683
  }
26297
26684
  if (Object.hasOwn(update, "updatedAt")) {
26298
- this.#sessionUpdatedAt = truncate2(update.updatedAt ?? "", 128);
26685
+ this.#sessionUpdatedAt = truncate3(update.updatedAt ?? "", 128);
26299
26686
  }
26300
26687
  await this.#getObserver().onInfo({
26301
26688
  kind: SESSION_INFO_UPDATED_KIND,
@@ -26308,7 +26695,7 @@ var AcpProcessSession = class _AcpProcessSession {
26308
26695
  if (update.sessionUpdate === "usage_update") {
26309
26696
  await this.#getObserver().onUsage({
26310
26697
  costAmount: update.cost?.amount ?? 0,
26311
- costCurrency: truncate2(update.cost?.currency ?? "", 16),
26698
+ costCurrency: truncate3(update.cost?.currency ?? "", 16),
26312
26699
  hasCost: update.cost !== void 0 && update.cost !== null,
26313
26700
  kind: SESSION_USAGE_UPDATED_KIND,
26314
26701
  sessionId: this.#mobiusSessionId,
@@ -26323,7 +26710,7 @@ var AcpProcessSession = class _AcpProcessSession {
26323
26710
  if (this.#capabilities.closeSession && this.#nativeSessionId.length > 0) {
26324
26711
  try {
26325
26712
  await this.#connection.agent.request(
26326
- methods5.agent.session.close,
26713
+ methods6.agent.session.close,
26327
26714
  { sessionId: this.#nativeSessionId },
26328
26715
  {
26329
26716
  cancellationSignal: AbortSignal.timeout(
@@ -27519,11 +27906,11 @@ var FixedAgentInstallRecipe = class {
27519
27906
 
27520
27907
  // src/agent-installation/grok-build-install-recipe.ts
27521
27908
  import { mkdir as mkdir4, realpath as realpath7, stat as stat6 } from "node:fs/promises";
27522
- import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute6, join as join15, relative as relative4, sep as sep4 } from "node:path";
27909
+ import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute7, join as join15, relative as relative4, sep as sep4 } from "node:path";
27523
27910
  var INSTALL_TIMEOUT_MILLISECONDS2 = 5 * 60 * 1e3;
27524
27911
  function isContainedPath4(root, candidate) {
27525
27912
  const difference = relative4(root, candidate);
27526
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep4}`) && !isAbsolute6(difference);
27913
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep4}`) && !isAbsolute7(difference);
27527
27914
  }
27528
27915
  async function resolveLifecycleScript(packageRoot) {
27529
27916
  try {
@@ -28364,7 +28751,7 @@ import { homedir as homedir2 } from "node:os";
28364
28751
  import {
28365
28752
  basename as basename2,
28366
28753
  dirname as dirname6,
28367
- isAbsolute as isAbsolute7,
28754
+ isAbsolute as isAbsolute8,
28368
28755
  join as join18,
28369
28756
  normalize as normalize2,
28370
28757
  relative as relative5
@@ -28417,20 +28804,20 @@ var WorkspaceDirectoryService = class {
28417
28804
  if (id === "home") return homedir2();
28418
28805
  if (id.startsWith("path-")) {
28419
28806
  const path2 = decodePath(id, "path-");
28420
- if (isAbsolute7(path2)) return path2;
28807
+ if (isAbsolute8(path2)) return path2;
28421
28808
  }
28422
28809
  throw new LocalAuthorizationError("The directory identifier is invalid");
28423
28810
  };
28424
28811
  resolvePath = async (requested, signal) => {
28425
28812
  signal.throwIfAborted();
28426
- if (!isAbsolute7(requested) || requested.includes("\0") || normalize2(requested) !== requested)
28813
+ if (!isAbsolute8(requested) || requested.includes("\0") || normalize2(requested) !== requested)
28427
28814
  throw new LocalAuthorizationError("The local directory path is invalid");
28428
28815
  try {
28429
28816
  const target = await realpath8(requested);
28430
28817
  signal.throwIfAborted();
28431
28818
  const metadata = await stat7(target);
28432
28819
  signal.throwIfAborted();
28433
- if (!isAbsolute7(target) || normalize2(target) !== target || !metadata.isDirectory())
28820
+ if (!isAbsolute8(target) || normalize2(target) !== target || !metadata.isDirectory())
28434
28821
  throw new LocalAuthorizationError(
28435
28822
  "The selected location is not a directory"
28436
28823
  );
@@ -28446,7 +28833,7 @@ var WorkspaceDirectoryService = class {
28446
28833
  };
28447
28834
  label = (path2) => {
28448
28835
  const suffix = relative5(homedir2(), path2);
28449
- return suffix === "" ? "~" : !isAbsolute7(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
28836
+ return suffix === "" ? "~" : !isAbsolute8(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
28450
28837
  };
28451
28838
  identify = async (bindingId, requestedPath, signal) => {
28452
28839
  this.authorizeMachine(bindingId);