@moxt-ai/mobius 0.0.16 → 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.
package/dist/cli.js CHANGED
@@ -24015,7 +24015,7 @@ import { WebSocket as WebSocket2 } from "undici";
24015
24015
  // src/acp/session-manager.ts
24016
24016
  import { spawn as spawn3 } from "node:child_process";
24017
24017
  import {
24018
- methods as methods5,
24018
+ methods as methods6,
24019
24019
  ndJsonStream as ndJsonStream2,
24020
24020
  PROTOCOL_VERSION as PROTOCOL_VERSION2,
24021
24021
  RequestError as RequestError2
@@ -24529,6 +24529,491 @@ var nativeSessionPageSchema = external_exports.object({
24529
24529
  nextCursor: external_exports.string().min(1).max(4096).nullish()
24530
24530
  }).readonly();
24531
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
+
24532
25017
  // src/acp/session-history.ts
24533
25018
  var AcpHistoryReplay = class {
24534
25019
  #messages = [];
@@ -24633,7 +25118,7 @@ var FoundAcpStoredSession = class extends AcpStoredSessionLookup {
24633
25118
  var DeletedAcpStoredSession = class extends AcpStoredSessionLookup {
24634
25119
  found = false;
24635
25120
  };
24636
- function readString2(value, field) {
25121
+ function readString3(value, field) {
24637
25122
  if (typeof value !== "string" || value.length === 0) {
24638
25123
  throw new Error(`Stored ACP session has an invalid ${field}`);
24639
25124
  }
@@ -24663,10 +25148,10 @@ function decodeSessionRow(row) {
24663
25148
  throw new Error("Stored ACP session is not an object");
24664
25149
  }
24665
25150
  return new AcpStoredSession(
24666
- readString2(Reflect.get(row, "session_id"), "session ID"),
24667
- readString2(Reflect.get(row, "agent_id"), "agent ID"),
24668
- readString2(Reflect.get(row, "native_session_id"), "native session ID"),
24669
- 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"),
24670
25155
  readAdditionalDirectories(Reflect.get(row, "additional_directories_json")),
24671
25156
  readPrompted(Reflect.get(row, "prompted"))
24672
25157
  );
@@ -24928,149 +25413,18 @@ function createWritableAcpStream(output2) {
24928
25413
  }
24929
25414
  });
24930
25415
  }
24931
- function truncate2(value, maximumLength) {
25416
+ function truncate3(value, maximumLength) {
24932
25417
  return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
24933
25418
  }
24934
- function isRecord6(value) {
25419
+ function isRecord7(value) {
24935
25420
  return typeof value === "object" && value !== null && !Array.isArray(value);
24936
25421
  }
24937
- function readString3(value, fallback = "") {
25422
+ function readString4(value, fallback = "") {
24938
25423
  return typeof value === "string" ? value : fallback;
24939
25424
  }
24940
- function readBoolean(value, fallback = false) {
24941
- return typeof value === "boolean" ? value : fallback;
24942
- }
24943
25425
  function arraysEqual(left, right) {
24944
25426
  return left.length === right.length && left.every((value, index) => value === right[index]);
24945
25427
  }
24946
- function normalizeConfigValue(option, groupId = "", groupName = "") {
24947
- return {
24948
- description: truncate2(readString3(option["description"]), 500),
24949
- groupId: truncate2(groupId, 128),
24950
- groupName: truncate2(groupName, 255),
24951
- name: truncate2(
24952
- readString3(option["name"], readString3(option["value"])),
24953
- 255
24954
- ),
24955
- value: truncate2(readString3(option["value"]), 500)
24956
- };
24957
- }
24958
- function normalizeConfigValues(value) {
24959
- if (!Array.isArray(value)) {
24960
- return [];
24961
- }
24962
- const normalized = [];
24963
- for (const entry of value) {
24964
- if (!isRecord6(entry)) {
24965
- continue;
24966
- }
24967
- const groupedOptions = entry["options"];
24968
- if (Array.isArray(groupedOptions)) {
24969
- const groupId = readString3(entry["group"]);
24970
- const groupName = readString3(entry["name"]);
24971
- for (const groupedOption of groupedOptions) {
24972
- if (isRecord6(groupedOption)) {
24973
- normalized.push(
24974
- normalizeConfigValue(groupedOption, groupId, groupName)
24975
- );
24976
- }
24977
- }
24978
- continue;
24979
- }
24980
- normalized.push(normalizeConfigValue(entry));
24981
- }
24982
- return normalized.filter((entry) => entry.value.length > 0).slice(0, 500);
24983
- }
24984
- function normalizeConfigOptions(value, modes) {
24985
- const normalized = [];
24986
- if (Array.isArray(value)) {
24987
- for (const option of value) {
24988
- if (!isRecord6(option)) {
24989
- continue;
24990
- }
24991
- const id = truncate2(readString3(option["id"]), 128);
24992
- const name = truncate2(readString3(option["name"], id), 255);
24993
- if (id.length === 0 || name.length === 0) {
24994
- continue;
24995
- }
24996
- if (option["type"] === "boolean") {
24997
- normalized.push({
24998
- booleanValue: readBoolean(option["currentValue"]),
24999
- category: truncate2(readString3(option["category"]), 128),
25000
- currentValue: "",
25001
- description: truncate2(readString3(option["description"]), 500),
25002
- id,
25003
- name,
25004
- type: "boolean",
25005
- values: []
25006
- });
25007
- continue;
25008
- }
25009
- if (option["type"] === "select") {
25010
- const values = normalizeConfigValues(option["options"]);
25011
- const currentValue = truncate2(readString3(option["currentValue"]), 500);
25012
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue)) {
25013
- normalized.push({
25014
- booleanValue: false,
25015
- category: truncate2(readString3(option["category"]), 128),
25016
- currentValue,
25017
- description: truncate2(readString3(option["description"]), 500),
25018
- id,
25019
- name,
25020
- type: "select",
25021
- values
25022
- });
25023
- }
25024
- }
25025
- }
25026
- }
25027
- if (isRecord6(modes)) {
25028
- const values = [];
25029
- const availableModes = modes["availableModes"];
25030
- if (Array.isArray(availableModes)) {
25031
- for (const mode of availableModes) {
25032
- if (!isRecord6(mode)) {
25033
- continue;
25034
- }
25035
- const id = truncate2(readString3(mode["id"]), 500);
25036
- if (id.length === 0) {
25037
- continue;
25038
- }
25039
- values.push({
25040
- description: truncate2(readString3(mode["description"]), 500),
25041
- groupId: "",
25042
- groupName: "",
25043
- name: truncate2(readString3(mode["name"], id), 255),
25044
- value: id
25045
- });
25046
- }
25047
- }
25048
- const currentValue = truncate2(readString3(modes["currentModeId"]), 500);
25049
- if (currentValue.length > 0 && values.some((entry) => entry.value === currentValue) && !normalized.some((entry) => entry.category === "mode")) {
25050
- normalized.unshift({
25051
- booleanValue: false,
25052
- category: "mode",
25053
- currentValue,
25054
- description: "Agent session mode",
25055
- id: "mode",
25056
- name: "Mode",
25057
- type: "select",
25058
- values
25059
- });
25060
- }
25061
- }
25062
- return normalized.slice(0, 100);
25063
- }
25064
- function replaceConfigOptionsKeepingMode(current, value) {
25065
- const next = normalizeConfigOptions(value, void 0);
25066
- if (next.some((option) => option.category === "mode")) {
25067
- return next;
25068
- }
25069
- return [
25070
- ...current.filter((option) => option.category === "mode"),
25071
- ...next
25072
- ].slice(0, 100);
25073
- }
25074
25428
  function normalizeCapabilities(capabilities) {
25075
25429
  const session = capabilities.sessionCapabilities;
25076
25430
  const prompt = capabilities.promptCapabilities;
@@ -25107,11 +25461,11 @@ function normalizeElicitationOptions(schema) {
25107
25461
  const oneOf = schema["oneOf"];
25108
25462
  if (Array.isArray(oneOf)) {
25109
25463
  for (const option of oneOf) {
25110
- if (isRecord6(option) && typeof option["const"] === "string") {
25464
+ if (isRecord7(option) && typeof option["const"] === "string") {
25111
25465
  normalized.push({
25112
- description: truncate2(readString3(option["description"]), 500),
25113
- label: truncate2(readString3(option["title"], option["const"]), 255),
25114
- 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)
25115
25469
  });
25116
25470
  }
25117
25471
  }
@@ -25127,7 +25481,7 @@ function normalizeElicitationOptions(schema) {
25127
25481
  return normalized.slice(0, 200);
25128
25482
  }
25129
25483
  const items = schema["items"];
25130
- if (!isRecord6(items)) {
25484
+ if (!isRecord7(items)) {
25131
25485
  return normalized;
25132
25486
  }
25133
25487
  const anyOf = items["anyOf"];
@@ -25140,7 +25494,7 @@ function numericString(value) {
25140
25494
  return typeof value === "number" && Number.isFinite(value) ? value.toString() : "";
25141
25495
  }
25142
25496
  function normalizeElicitationFields(requestedSchema) {
25143
- if (!isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
25497
+ if (!isRecord7(requestedSchema) || !isRecord7(requestedSchema["properties"])) {
25144
25498
  return [];
25145
25499
  }
25146
25500
  const properties = requestedSchema["properties"];
@@ -25150,7 +25504,7 @@ function normalizeElicitationFields(requestedSchema) {
25150
25504
  );
25151
25505
  const normalized = [];
25152
25506
  for (const [name, property] of Object.entries(properties)) {
25153
- if (!isRecord6(property)) {
25507
+ if (!isRecord7(property)) {
25154
25508
  continue;
25155
25509
  }
25156
25510
  const type = elicitationFieldType(property["type"]);
@@ -25160,9 +25514,9 @@ function normalizeElicitationFields(requestedSchema) {
25160
25514
  normalized.push({
25161
25515
  defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
25162
25516
  defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
25163
- defaultStringValue: typeof defaultValue === "string" ? truncate2(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate2(JSON.stringify(defaultValue), 1e4) : "",
25164
- description: truncate2(readString3(property["description"]), 500),
25165
- 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),
25166
25520
  hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
25167
25521
  maximum: numericString(property["maximum"]),
25168
25522
  maximumLength: numericString(
@@ -25172,11 +25526,11 @@ function normalizeElicitationFields(requestedSchema) {
25172
25526
  minimumLength: numericString(
25173
25527
  property["minLength"] ?? property["minItems"]
25174
25528
  ),
25175
- name: truncate2(name, 128),
25529
+ name: truncate3(name, 128),
25176
25530
  options,
25177
- pattern: truncate2(readString3(property["pattern"]), 500),
25531
+ pattern: truncate3(readString4(property["pattern"]), 500),
25178
25532
  required: required2.has(name),
25179
- title: truncate2(readString3(property["title"], name), 255),
25533
+ title: truncate3(readString4(property["title"], name), 255),
25180
25534
  type: normalizedType
25181
25535
  });
25182
25536
  }
@@ -25245,7 +25599,7 @@ function validateElicitationContent(encoded, requestedSchema) {
25245
25599
  "invalid_elicitation_response"
25246
25600
  );
25247
25601
  }
25248
- if (!isRecord6(decoded) || !isRecord6(requestedSchema) || !isRecord6(requestedSchema["properties"])) {
25602
+ if (!isRecord7(decoded) || !isRecord7(requestedSchema) || !isRecord7(requestedSchema["properties"])) {
25249
25603
  throw new AcpExecutionError(
25250
25604
  "Elicitation response does not match the requested form",
25251
25605
  {},
@@ -25269,7 +25623,7 @@ function validateElicitationContent(encoded, requestedSchema) {
25269
25623
  const validated = {};
25270
25624
  for (const [name, value] of Object.entries(decoded)) {
25271
25625
  const property = properties[name];
25272
- if (!isRecord6(property)) {
25626
+ if (!isRecord7(property)) {
25273
25627
  throw new AcpExecutionError(
25274
25628
  `Elicitation field ${name} was not requested`,
25275
25629
  {},
@@ -25421,6 +25775,7 @@ var AcpProcessSession = class _AcpProcessSession {
25421
25775
  #pendingPermissions = /* @__PURE__ */ new Map();
25422
25776
  #preSessionUpdates = [];
25423
25777
  #processExit;
25778
+ #sessionConfigProtocol;
25424
25779
  #store;
25425
25780
  #verifiedAgentVersion;
25426
25781
  #preSessionUpdateBytes = 0;
@@ -25439,6 +25794,7 @@ var AcpProcessSession = class _AcpProcessSession {
25439
25794
  unstableForkSession: false
25440
25795
  };
25441
25796
  #commands = [];
25797
+ #configRevision = 0;
25442
25798
  #configOptions = [];
25443
25799
  #nativeSessionId = "";
25444
25800
  #prompted = false;
@@ -25456,6 +25812,7 @@ var AcpProcessSession = class _AcpProcessSession {
25456
25812
  this.#cwd = cwd;
25457
25813
  this.#getObserver = getObserver;
25458
25814
  this.#mobiusSessionId = mobiusSessionId;
25815
+ this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
25459
25816
  this.#store = store;
25460
25817
  this.#verifiedAgentVersion = agent.agentVersion;
25461
25818
  this.#child = spawn3(agent.adapterPath, [...agent.arguments], {
@@ -25560,7 +25917,7 @@ var AcpProcessSession = class _AcpProcessSession {
25560
25917
  try {
25561
25918
  await this.race(
25562
25919
  this.#connection.agent.request(
25563
- methods5.agent.session.load,
25920
+ methods6.agent.session.load,
25564
25921
  {
25565
25922
  additionalDirectories: [...this.#additionalDirectories],
25566
25923
  cwd: this.#cwd,
@@ -25582,7 +25939,7 @@ var AcpProcessSession = class _AcpProcessSession {
25582
25939
  async #initializeAgent(signal) {
25583
25940
  const initialized = await this.race(
25584
25941
  this.#connection.agent.request(
25585
- methods5.agent.initialize,
25942
+ methods6.agent.initialize,
25586
25943
  {
25587
25944
  clientCapabilities: {
25588
25945
  elicitation: { form: {}, url: {} },
@@ -25609,11 +25966,11 @@ var AcpProcessSession = class _AcpProcessSession {
25609
25966
  }
25610
25967
  const capabilities = initialized.agentCapabilities ?? {};
25611
25968
  this.#capabilities = normalizeCapabilities(capabilities);
25612
- this.#agentName = truncate2(
25969
+ this.#agentName = truncate3(
25613
25970
  initialized.agentInfo?.title ?? initialized.agentInfo?.name ?? this.#agentId,
25614
25971
  255
25615
25972
  );
25616
- this.#agentVersion = truncate2(
25973
+ this.#agentVersion = truncate3(
25617
25974
  this.#verifiedAgentVersion.length > 0 ? this.#verifiedAgentVersion : initialized.agentInfo?.version ?? "",
25618
25975
  128
25619
25976
  );
@@ -25650,7 +26007,7 @@ var AcpProcessSession = class _AcpProcessSession {
25650
26007
  );
25651
26008
  const forked = await this.race(
25652
26009
  this.#connection.agent.request(
25653
- methods5.agent.session.fork,
26010
+ methods6.agent.session.fork,
25654
26011
  {
25655
26012
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
25656
26013
  cwd: this.#cwd,
@@ -25683,7 +26040,7 @@ var AcpProcessSession = class _AcpProcessSession {
25683
26040
  if (this.#capabilities.resumeSession) {
25684
26041
  lifecycleResponse = await this.race(
25685
26042
  this.#connection.agent.request(
25686
- methods5.agent.session.resume,
26043
+ methods6.agent.session.resume,
25687
26044
  {
25688
26045
  additionalDirectories: [...this.#additionalDirectories],
25689
26046
  cwd: this.#cwd,
@@ -25700,7 +26057,7 @@ var AcpProcessSession = class _AcpProcessSession {
25700
26057
  try {
25701
26058
  lifecycleResponse = await this.race(
25702
26059
  this.#connection.agent.request(
25703
- methods5.agent.session.load,
26060
+ methods6.agent.session.load,
25704
26061
  {
25705
26062
  additionalDirectories: [...this.#additionalDirectories],
25706
26063
  cwd: this.#cwd,
@@ -25736,7 +26093,7 @@ var AcpProcessSession = class _AcpProcessSession {
25736
26093
  }
25737
26094
  const created = await this.race(
25738
26095
  this.#connection.agent.request(
25739
- methods5.agent.session.new,
26096
+ methods6.agent.session.new,
25740
26097
  {
25741
26098
  additionalDirectories: [...this.#additionalDirectories],
25742
26099
  cwd: this.#cwd,
@@ -25750,11 +26107,7 @@ var AcpProcessSession = class _AcpProcessSession {
25750
26107
  this.selectNativeSession(created.sessionId);
25751
26108
  lifecycleResponse = created;
25752
26109
  }
25753
- const lifecycleRecord = isRecord6(lifecycleResponse) ? lifecycleResponse : {};
25754
- this.#configOptions = normalizeConfigOptions(
25755
- lifecycleRecord["configOptions"],
25756
- lifecycleRecord["modes"]
25757
- );
26110
+ this.#configOptions = this.#sessionConfigProtocol.normalizeLifecycle(lifecycleResponse);
25758
26111
  await this.#updateTail;
25759
26112
  signal.throwIfAborted();
25760
26113
  if (this.#prompted) {
@@ -25779,7 +26132,7 @@ var AcpProcessSession = class _AcpProcessSession {
25779
26132
  );
25780
26133
  const response = await this.race(
25781
26134
  this.#connection.agent.request(
25782
- methods5.agent.session.list,
26135
+ methods6.agent.session.list,
25783
26136
  cursor === null ? {} : { cursor },
25784
26137
  { cancellationSignal: signal }
25785
26138
  ),
@@ -25804,7 +26157,7 @@ var AcpProcessSession = class _AcpProcessSession {
25804
26157
  );
25805
26158
  await this.race(
25806
26159
  this.#connection.agent.request(
25807
- methods5.agent.session.delete,
26160
+ methods6.agent.session.delete,
25808
26161
  { sessionId: nativeSessionIdSchema.parse(nativeSessionId) },
25809
26162
  { cancellationSignal: signal }
25810
26163
  ),
@@ -25825,64 +26178,50 @@ var AcpProcessSession = class _AcpProcessSession {
25825
26178
  );
25826
26179
  }
25827
26180
  if (existing.type === "select") {
25828
- if (!existing.values.some((entry) => entry.value === options.value)) {
26181
+ if (existing.values.length < 2) {
25829
26182
  throw new AcpExecutionError(
25830
- "The requested ACP configuration value is unavailable",
26183
+ "The requested ACP configuration option is unavailable",
25831
26184
  {},
25832
26185
  "invalid_session_configuration"
25833
26186
  );
25834
26187
  }
25835
- if (existing.category === "mode") {
25836
- await this.race(
25837
- this.#connection.agent.request(
25838
- methods5.agent.session.setMode,
25839
- { modeId: options.value, sessionId: this.#nativeSessionId },
25840
- { cancellationSignal: options.signal }
25841
- ),
25842
- "ACP agent exited while setting the session mode",
25843
- options.signal
25844
- );
25845
- this.#configOptions = this.#configOptions.map(
25846
- (option) => option.id === existing.id ? { ...option, currentValue: options.value } : option
25847
- );
25848
- } else {
25849
- const response = await this.race(
25850
- this.#connection.agent.request(
25851
- methods5.agent.session.setConfigOption,
25852
- {
25853
- configId: existing.id,
25854
- sessionId: this.#nativeSessionId,
25855
- value: options.value
25856
- },
25857
- { cancellationSignal: options.signal }
25858
- ),
25859
- "ACP agent exited while changing session configuration",
25860
- options.signal
25861
- );
25862
- this.#configOptions = replaceConfigOptionsKeepingMode(
25863
- this.#configOptions,
25864
- 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"
25865
26193
  );
25866
26194
  }
25867
- } else {
25868
- const response = await this.race(
25869
- this.#connection.agent.request(
25870
- methods5.agent.session.setConfigOption,
25871
- {
25872
- configId: existing.id,
25873
- sessionId: this.#nativeSessionId,
25874
- type: "boolean",
25875
- value: options.booleanValue
25876
- },
25877
- { cancellationSignal: options.signal }
25878
- ),
25879
- "ACP agent exited while changing session configuration",
25880
- options.signal
25881
- );
25882
- this.#configOptions = replaceConfigOptionsKeepingMode(
26195
+ }
26196
+ const configRevision = this.#configRevision;
26197
+ try {
26198
+ const configured = await this.#sessionConfigProtocol.configure(
25883
26199
  this.#configOptions,
25884
- 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
+ }
25885
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;
25886
26225
  }
25887
26226
  return this.#configOptions;
25888
26227
  };
@@ -25966,7 +26305,7 @@ var AcpProcessSession = class _AcpProcessSession {
25966
26305
  try {
25967
26306
  const response = await this.race(
25968
26307
  this.#connection.agent.request(
25969
- methods5.agent.session.prompt,
26308
+ methods6.agent.session.prompt,
25970
26309
  { prompt, sessionId: this.#nativeSessionId },
25971
26310
  { cancellationSignal: options.signal }
25972
26311
  ),
@@ -26013,7 +26352,7 @@ var AcpProcessSession = class _AcpProcessSession {
26013
26352
  try {
26014
26353
  await this.cancelPendingInteractions();
26015
26354
  if (this.#turn.running) {
26016
- await this.#connection.agent.notify(methods5.agent.session.cancel, {
26355
+ await this.#connection.agent.notify(methods6.agent.session.cancel, {
26017
26356
  sessionId: this.#nativeSessionId
26018
26357
  });
26019
26358
  }
@@ -26103,8 +26442,8 @@ var AcpProcessSession = class _AcpProcessSession {
26103
26442
  const interactionId = `permission-${crypto.randomUUID()}`;
26104
26443
  const options = request.options.slice(0, 20).map((option) => ({
26105
26444
  kind: option.kind,
26106
- name: truncate2(option.name, 255),
26107
- optionId: truncate2(option.optionId, 255)
26445
+ name: truncate3(option.name, 255),
26446
+ optionId: truncate3(option.optionId, 255)
26108
26447
  }));
26109
26448
  if (options.length === 0) {
26110
26449
  throw new AcpExecutionError(
@@ -26129,9 +26468,9 @@ var AcpProcessSession = class _AcpProcessSession {
26129
26468
  kind: SESSION_PERMISSION_REQUESTED_KIND,
26130
26469
  options,
26131
26470
  sessionId: this.#mobiusSessionId,
26132
- title: truncate2(request.toolCall.title ?? "Permission required", 500),
26133
- toolCallId: truncate2(request.toolCall.toolCallId, 255),
26134
- 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)
26135
26474
  });
26136
26475
  return await pending.completion.promise;
26137
26476
  } finally {
@@ -26160,7 +26499,7 @@ var AcpProcessSession = class _AcpProcessSession {
26160
26499
  const schemaValue = Reflect.get(request, "requestedSchema");
26161
26500
  const requestedSchema = request.mode === "form" ? schemaValue : {};
26162
26501
  const elicitationIdValue = Reflect.get(request, "elicitationId");
26163
- const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate2(elicitationIdValue, 255) : "";
26502
+ const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate3(elicitationIdValue, 255) : "";
26164
26503
  const pending = new PendingElicitation(
26165
26504
  interactionId,
26166
26505
  elicitationId,
@@ -26179,10 +26518,10 @@ var AcpProcessSession = class _AcpProcessSession {
26179
26518
  fields: normalizeElicitationFields(requestedSchema),
26180
26519
  interactionId,
26181
26520
  kind: SESSION_ELICITATION_REQUESTED_KIND,
26182
- message: truncate2(request.message, 2e3),
26521
+ message: truncate3(request.message, 2e3),
26183
26522
  mode: request.mode,
26184
26523
  sessionId: this.#mobiusSessionId,
26185
- 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) : ""
26186
26525
  });
26187
26526
  return await pending.completion.promise;
26188
26527
  } finally {
@@ -26271,7 +26610,7 @@ var AcpProcessSession = class _AcpProcessSession {
26271
26610
  content: normalizeContentBlock(update.content),
26272
26611
  contentId: `content-${crypto.randomUUID()}`,
26273
26612
  kind: AGENT_CONTENT_KIND,
26274
- messageId: truncate2(update.messageId ?? "", 255),
26613
+ messageId: truncate3(update.messageId ?? "", 255),
26275
26614
  sessionId: this.#mobiusSessionId
26276
26615
  });
26277
26616
  }
@@ -26309,9 +26648,9 @@ var AcpProcessSession = class _AcpProcessSession {
26309
26648
  }
26310
26649
  if (update.sessionUpdate === "available_commands_update") {
26311
26650
  const commands = update.availableCommands.slice(0, 500).map((command) => ({
26312
- description: truncate2(command.description, 500),
26313
- inputHint: truncate2(command.input?.hint ?? "", 255),
26314
- name: truncate2(command.name, 128)
26651
+ description: truncate3(command.description, 500),
26652
+ inputHint: truncate3(command.input?.hint ?? "", 255),
26653
+ name: truncate3(command.name, 128)
26315
26654
  })).filter((command) => command.name.length > 0);
26316
26655
  this.#commands = commands;
26317
26656
  await this.#getObserver().onCommands({
@@ -26322,10 +26661,11 @@ var AcpProcessSession = class _AcpProcessSession {
26322
26661
  return;
26323
26662
  }
26324
26663
  if (update.sessionUpdate === "config_option_update") {
26325
- this.#configOptions = replaceConfigOptionsKeepingMode(
26664
+ this.#configOptions = this.#sessionConfigProtocol.normalizeUpdate(
26326
26665
  this.#configOptions,
26327
26666
  update.configOptions
26328
26667
  );
26668
+ this.#configRevision += 1;
26329
26669
  await this.emitConfigUpdate();
26330
26670
  return;
26331
26671
  }
@@ -26333,15 +26673,16 @@ var AcpProcessSession = class _AcpProcessSession {
26333
26673
  this.#configOptions = this.#configOptions.map(
26334
26674
  (option) => option.category === "mode" ? { ...option, currentValue: update.currentModeId } : option
26335
26675
  );
26676
+ this.#configRevision += 1;
26336
26677
  await this.emitConfigUpdate();
26337
26678
  return;
26338
26679
  }
26339
26680
  if (update.sessionUpdate === "session_info_update") {
26340
26681
  if (Object.hasOwn(update, "title")) {
26341
- this.#sessionTitle = truncate2(update.title ?? "", 500);
26682
+ this.#sessionTitle = truncate3(update.title ?? "", 500);
26342
26683
  }
26343
26684
  if (Object.hasOwn(update, "updatedAt")) {
26344
- this.#sessionUpdatedAt = truncate2(update.updatedAt ?? "", 128);
26685
+ this.#sessionUpdatedAt = truncate3(update.updatedAt ?? "", 128);
26345
26686
  }
26346
26687
  await this.#getObserver().onInfo({
26347
26688
  kind: SESSION_INFO_UPDATED_KIND,
@@ -26354,7 +26695,7 @@ var AcpProcessSession = class _AcpProcessSession {
26354
26695
  if (update.sessionUpdate === "usage_update") {
26355
26696
  await this.#getObserver().onUsage({
26356
26697
  costAmount: update.cost?.amount ?? 0,
26357
- costCurrency: truncate2(update.cost?.currency ?? "", 16),
26698
+ costCurrency: truncate3(update.cost?.currency ?? "", 16),
26358
26699
  hasCost: update.cost !== void 0 && update.cost !== null,
26359
26700
  kind: SESSION_USAGE_UPDATED_KIND,
26360
26701
  sessionId: this.#mobiusSessionId,
@@ -26369,7 +26710,7 @@ var AcpProcessSession = class _AcpProcessSession {
26369
26710
  if (this.#capabilities.closeSession && this.#nativeSessionId.length > 0) {
26370
26711
  try {
26371
26712
  await this.#connection.agent.request(
26372
- methods5.agent.session.close,
26713
+ methods6.agent.session.close,
26373
26714
  { sessionId: this.#nativeSessionId },
26374
26715
  {
26375
26716
  cancellationSignal: AbortSignal.timeout(