@moxt-ai/mobius 0.0.317 → 0.0.319
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/acp/adapter/agent-initialization.d.ts.map +1 -1
- package/dist/acp/adapter/agent-initialization.js +7 -12
- package/dist/acp/adapter/agent-initialization.js.map +1 -1
- package/dist/acp/adapter/claude/agent-connection.d.ts +6 -0
- package/dist/acp/adapter/claude/agent-connection.d.ts.map +1 -0
- package/dist/acp/adapter/claude/agent-connection.js +15 -0
- package/dist/acp/adapter/claude/agent-connection.js.map +1 -0
- package/dist/acp/adapter/codex/agent-connection.d.ts +6 -0
- package/dist/acp/adapter/codex/agent-connection.d.ts.map +1 -0
- package/dist/acp/adapter/codex/agent-connection.js +15 -0
- package/dist/acp/adapter/codex/agent-connection.js.map +1 -0
- package/dist/acp/adapter/pi/agent-connection.d.ts +6 -0
- package/dist/acp/adapter/pi/agent-connection.d.ts.map +1 -0
- package/dist/acp/adapter/pi/agent-connection.js +15 -0
- package/dist/acp/adapter/pi/agent-connection.js.map +1 -0
- package/dist/acp/adapter/session-events.d.ts +1 -1
- package/dist/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/acp/adapter/session-events.js +12 -11
- package/dist/acp/adapter/session-events.js.map +1 -1
- package/dist/acp/agent/agent-definition.d.ts +9 -21
- package/dist/acp/agent/agent-definition.d.ts.map +1 -1
- package/dist/acp/agent/agent-definition.js +11 -31
- package/dist/acp/agent/agent-definition.js.map +1 -1
- package/dist/acp/connection/agent-connection.d.ts +18 -10
- package/dist/acp/connection/agent-connection.d.ts.map +1 -1
- package/dist/acp/connection/agent-connection.js +1 -231
- package/dist/acp/connection/agent-connection.js.map +1 -1
- package/dist/acp/connection/agent-operation.d.ts +4 -0
- package/dist/acp/connection/agent-operation.d.ts.map +1 -0
- package/dist/acp/connection/agent-operation.js +57 -0
- package/dist/acp/connection/agent-operation.js.map +1 -0
- package/dist/acp/connection/endpoint-agent-connection.d.ts +28 -0
- package/dist/acp/connection/endpoint-agent-connection.d.ts.map +1 -0
- package/dist/acp/connection/endpoint-agent-connection.js +31 -0
- package/dist/acp/connection/endpoint-agent-connection.js.map +1 -0
- package/dist/agent/discovery/acp-readiness-probe.d.ts +1 -0
- package/dist/agent/discovery/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent/discovery/acp-readiness-probe.js +29 -188
- package/dist/agent/discovery/acp-readiness-probe.js.map +1 -1
- package/dist/agent/discovery/discover-agent.d.ts.map +1 -1
- package/dist/agent/discovery/discover-agent.js +4 -6
- package/dist/agent/discovery/discover-agent.js.map +1 -1
- package/dist/agent/discovery/executable-discovery.d.ts +1 -1
- package/dist/agent/discovery/executable-discovery.d.ts.map +1 -1
- package/dist/agent/discovery/executable-discovery.js +1 -6
- package/dist/agent/discovery/executable-discovery.js.map +1 -1
- package/dist/agent/specification/agent-specification.d.ts +3 -9
- package/dist/agent/specification/agent-specification.d.ts.map +1 -1
- package/dist/agent/specification/agent-specification.js +1 -12
- package/dist/agent/specification/agent-specification.js.map +1 -1
- package/dist/agent/specification/vendors/claude-code-agent.d.ts +2 -2
- package/dist/agent/specification/vendors/claude-code-agent.d.ts.map +1 -1
- package/dist/agent/specification/vendors/claude-code-agent.js +2 -2
- package/dist/agent/specification/vendors/claude-code-agent.js.map +1 -1
- package/dist/agent/specification/vendors/codex-agent.d.ts +2 -2
- package/dist/agent/specification/vendors/codex-agent.d.ts.map +1 -1
- package/dist/agent/specification/vendors/codex-agent.js +2 -2
- package/dist/agent/specification/vendors/codex-agent.js.map +1 -1
- package/dist/agent/specification/vendors/pi-agent.d.ts +2 -2
- package/dist/agent/specification/vendors/pi-agent.d.ts.map +1 -1
- package/dist/agent/specification/vendors/pi-agent.js +2 -2
- package/dist/agent/specification/vendors/pi-agent.js.map +1 -1
- package/dist/cli/handler/agents/logic/agent-diagnostics.d.ts.map +1 -1
- package/dist/cli/handler/agents/logic/agent-diagnostics.js +1 -4
- package/dist/cli/handler/agents/logic/agent-diagnostics.js.map +1 -1
- package/dist/cli.js +584 -862
- package/dist/cli.js.map +4 -4
- package/dist/runtime/catalog/resolve-catalog-agent.js +6 -3
- package/dist/runtime/catalog/resolve-catalog-agent.js.map +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +308 -611
- package/dist/runtime.js.map +4 -4
- package/dist/session/settings/discover-agent-settings.js +1 -1
- package/dist/session/settings/discover-agent-settings.js.map +1 -1
- package/dist/session/turn/session-turns.d.ts +7 -0
- package/dist/session/turn/session-turns.d.ts.map +1 -1
- package/dist/session/turn/session-turns.js +1 -0
- package/dist/session/turn/session-turns.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.319",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -5781,6 +5781,224 @@ var init_state_root = __esm({
|
|
|
5781
5781
|
}
|
|
5782
5782
|
});
|
|
5783
5783
|
|
|
5784
|
+
// src/util/value-utils.ts
|
|
5785
|
+
function truncate(value, maximumLength) {
|
|
5786
|
+
return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
|
|
5787
|
+
}
|
|
5788
|
+
function isRecord(value) {
|
|
5789
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5790
|
+
}
|
|
5791
|
+
function readString(value, fallback = "") {
|
|
5792
|
+
return typeof value === "string" ? value : fallback;
|
|
5793
|
+
}
|
|
5794
|
+
function arraysEqual(left, right) {
|
|
5795
|
+
return left.length === right.length && left.every((value, index2) => value === right[index2]);
|
|
5796
|
+
}
|
|
5797
|
+
function recordsEqual(left, right) {
|
|
5798
|
+
const leftEntries = Object.entries(left);
|
|
5799
|
+
const rightEntries = Object.entries(right);
|
|
5800
|
+
return leftEntries.length === rightEntries.length && leftEntries.every(([name2, value]) => right[name2] === value);
|
|
5801
|
+
}
|
|
5802
|
+
var init_value_utils = __esm({
|
|
5803
|
+
"src/util/value-utils.ts"() {
|
|
5804
|
+
"use strict";
|
|
5805
|
+
}
|
|
5806
|
+
});
|
|
5807
|
+
|
|
5808
|
+
// src/infra/operation-error.ts
|
|
5809
|
+
function operationErrorCode(error62) {
|
|
5810
|
+
return error62 instanceof OperationError ? error62.code : "session_operation_failed";
|
|
5811
|
+
}
|
|
5812
|
+
function operationErrorMessage(error62) {
|
|
5813
|
+
return error62 instanceof OperationError ? error62.message : "The local agent operation could not be completed";
|
|
5814
|
+
}
|
|
5815
|
+
var OperationError;
|
|
5816
|
+
var init_operation_error = __esm({
|
|
5817
|
+
"src/infra/operation-error.ts"() {
|
|
5818
|
+
"use strict";
|
|
5819
|
+
OperationError = class extends Error {
|
|
5820
|
+
code;
|
|
5821
|
+
constructor(code, message, options = {}) {
|
|
5822
|
+
super(message, options);
|
|
5823
|
+
this.code = code;
|
|
5824
|
+
}
|
|
5825
|
+
};
|
|
5826
|
+
}
|
|
5827
|
+
});
|
|
5828
|
+
|
|
5829
|
+
// src/acp/acp-error.ts
|
|
5830
|
+
var AcpExecutionError, AcpConfigurationValueUnavailableError;
|
|
5831
|
+
var init_acp_error = __esm({
|
|
5832
|
+
"src/acp/acp-error.ts"() {
|
|
5833
|
+
"use strict";
|
|
5834
|
+
init_operation_error();
|
|
5835
|
+
AcpExecutionError = class extends OperationError {
|
|
5836
|
+
constructor(message, options = {}, code = "acp_execution_failed") {
|
|
5837
|
+
super(code, message, options);
|
|
5838
|
+
this.name = "AcpExecutionError";
|
|
5839
|
+
}
|
|
5840
|
+
};
|
|
5841
|
+
AcpConfigurationValueUnavailableError = class extends AcpExecutionError {
|
|
5842
|
+
configId;
|
|
5843
|
+
offeredValueCount;
|
|
5844
|
+
offeredValues;
|
|
5845
|
+
requestedValue;
|
|
5846
|
+
constructor(configId, requestedValue, offeredValues) {
|
|
5847
|
+
super("The requested ACP configuration value is unavailable", {}, "invalid_session_configuration");
|
|
5848
|
+
this.name = "AcpConfigurationValueUnavailableError";
|
|
5849
|
+
this.configId = configId.slice(0, 128);
|
|
5850
|
+
this.requestedValue = requestedValue.slice(0, 128);
|
|
5851
|
+
this.offeredValueCount = offeredValues.length;
|
|
5852
|
+
this.offeredValues = Object.freeze(offeredValues.slice(0, 32).map((value) => value.slice(0, 128)));
|
|
5853
|
+
}
|
|
5854
|
+
};
|
|
5855
|
+
}
|
|
5856
|
+
});
|
|
5857
|
+
|
|
5858
|
+
// src/acp/agent/in-process-endpoint.ts
|
|
5859
|
+
function acpEndpointTerminationError(termination) {
|
|
5860
|
+
switch (termination.kind) {
|
|
5861
|
+
case "failed":
|
|
5862
|
+
return termination.error;
|
|
5863
|
+
case "closed":
|
|
5864
|
+
return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
|
|
5865
|
+
default: {
|
|
5866
|
+
const unreachable3 = termination;
|
|
5867
|
+
return unreachable3;
|
|
5868
|
+
}
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
var init_in_process_endpoint = __esm({
|
|
5872
|
+
"src/acp/agent/in-process-endpoint.ts"() {
|
|
5873
|
+
"use strict";
|
|
5874
|
+
init_acp_error();
|
|
5875
|
+
}
|
|
5876
|
+
});
|
|
5877
|
+
|
|
5878
|
+
// src/acp/connection/agent-operation.ts
|
|
5879
|
+
import { RequestError } from "@agentclientprotocol/sdk";
|
|
5880
|
+
function requestErrorMessage(error62) {
|
|
5881
|
+
const fallback = truncate(error62.message, 500);
|
|
5882
|
+
if (error62.message !== "Internal error" || !isRecord(error62.data)) {
|
|
5883
|
+
return fallback;
|
|
5884
|
+
}
|
|
5885
|
+
const agentError = error62.data["error"];
|
|
5886
|
+
if (isRecord(agentError)) {
|
|
5887
|
+
const message = agentError["message"];
|
|
5888
|
+
if (typeof message === "string" && message.length > 0) {
|
|
5889
|
+
return truncate(message, 500);
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
const details = error62.data["details"];
|
|
5893
|
+
return typeof details === "string" && details.length > 0 ? truncate(details, 500) : fallback;
|
|
5894
|
+
}
|
|
5895
|
+
async function raceAgentOperation(operation, termination, exitMessage, signal) {
|
|
5896
|
+
let removeAbortListener = () => {
|
|
5897
|
+
};
|
|
5898
|
+
const aborted2 = new Promise((_resolve, reject2) => {
|
|
5899
|
+
const rejectAbort = () => {
|
|
5900
|
+
reject2(signal.reason ?? new Error("ACP request was cancelled"));
|
|
5901
|
+
};
|
|
5902
|
+
signal.addEventListener("abort", rejectAbort, { once: true });
|
|
5903
|
+
removeAbortListener = () => signal.removeEventListener("abort", rejectAbort);
|
|
5904
|
+
if (signal.aborted) {
|
|
5905
|
+
rejectAbort();
|
|
5906
|
+
}
|
|
5907
|
+
});
|
|
5908
|
+
try {
|
|
5909
|
+
return await Promise.race([
|
|
5910
|
+
aborted2,
|
|
5911
|
+
operation,
|
|
5912
|
+
termination.then((result) => {
|
|
5913
|
+
const cause = acpEndpointTerminationError(result);
|
|
5914
|
+
throw new AcpExecutionError(exitMessage, { cause }, cause.code);
|
|
5915
|
+
})
|
|
5916
|
+
]);
|
|
5917
|
+
} catch (error62) {
|
|
5918
|
+
signal.throwIfAborted();
|
|
5919
|
+
if (error62 instanceof RequestError && error62.code === -32e3) {
|
|
5920
|
+
throw new AcpExecutionError(
|
|
5921
|
+
"Agent authentication is required",
|
|
5922
|
+
{ cause: error62 },
|
|
5923
|
+
"authentication_required"
|
|
5924
|
+
);
|
|
5925
|
+
}
|
|
5926
|
+
if (error62 instanceof RequestError) {
|
|
5927
|
+
throw new AcpExecutionError(requestErrorMessage(error62), { cause: error62 }, "acp_agent_error");
|
|
5928
|
+
}
|
|
5929
|
+
throw error62;
|
|
5930
|
+
} finally {
|
|
5931
|
+
removeAbortListener();
|
|
5932
|
+
}
|
|
5933
|
+
}
|
|
5934
|
+
var init_agent_operation = __esm({
|
|
5935
|
+
"src/acp/connection/agent-operation.ts"() {
|
|
5936
|
+
"use strict";
|
|
5937
|
+
init_value_utils();
|
|
5938
|
+
init_acp_error();
|
|
5939
|
+
init_in_process_endpoint();
|
|
5940
|
+
}
|
|
5941
|
+
});
|
|
5942
|
+
|
|
5943
|
+
// src/acp/connection/create-client.ts
|
|
5944
|
+
import {
|
|
5945
|
+
client,
|
|
5946
|
+
methods
|
|
5947
|
+
} from "@agentclientprotocol/sdk";
|
|
5948
|
+
var createAcpClient;
|
|
5949
|
+
var init_create_client = __esm({
|
|
5950
|
+
"src/acp/connection/create-client.ts"() {
|
|
5951
|
+
"use strict";
|
|
5952
|
+
createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
5953
|
+
methods.client.session.requestPermission,
|
|
5954
|
+
async (context) => await handler.onPermission(context.params, context.signal)
|
|
5955
|
+
).onRequest(
|
|
5956
|
+
methods.client.elicitation.create,
|
|
5957
|
+
async (context) => await handler.onElicitation(context.params, context.signal)
|
|
5958
|
+
).onNotification(methods.client.session.update, async (context) => {
|
|
5959
|
+
await handler.onUpdate(context.params);
|
|
5960
|
+
}).onNotification(methods.client.elicitation.complete, async (context) => {
|
|
5961
|
+
await handler.onElicitationComplete(context.params);
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5964
|
+
});
|
|
5965
|
+
|
|
5966
|
+
// src/acp/connection/endpoint-agent-connection.ts
|
|
5967
|
+
var EndpointAgentConnection;
|
|
5968
|
+
var init_endpoint_agent_connection = __esm({
|
|
5969
|
+
"src/acp/connection/endpoint-agent-connection.ts"() {
|
|
5970
|
+
"use strict";
|
|
5971
|
+
init_agent_operation();
|
|
5972
|
+
init_create_client();
|
|
5973
|
+
EndpointAgentConnection = class {
|
|
5974
|
+
#endpoint;
|
|
5975
|
+
connection;
|
|
5976
|
+
termination;
|
|
5977
|
+
#closePromise = null;
|
|
5978
|
+
constructor(endpoint, client2) {
|
|
5979
|
+
this.#endpoint = endpoint;
|
|
5980
|
+
this.termination = endpoint.terminated;
|
|
5981
|
+
this.connection = createAcpClient(client2).connect(endpoint.app());
|
|
5982
|
+
}
|
|
5983
|
+
initialize = async (signal) => {
|
|
5984
|
+
await this.#endpoint.initialize(signal);
|
|
5985
|
+
};
|
|
5986
|
+
agentSettingsModelEffort = () => this.#endpoint.agentSettingsModelEffort?.() ?? null;
|
|
5987
|
+
closeProcess = () => {
|
|
5988
|
+
this.#closePromise ??= (async () => {
|
|
5989
|
+
try {
|
|
5990
|
+
await this.#endpoint.close();
|
|
5991
|
+
} finally {
|
|
5992
|
+
this.connection.close();
|
|
5993
|
+
}
|
|
5994
|
+
})();
|
|
5995
|
+
return this.#closePromise;
|
|
5996
|
+
};
|
|
5997
|
+
race = (operation, exitMessage, signal) => raceAgentOperation(operation, this.termination, exitMessage, signal);
|
|
5998
|
+
};
|
|
5999
|
+
}
|
|
6000
|
+
});
|
|
6001
|
+
|
|
5784
6002
|
// src/acp/harness/claude/parent-lifeline.ts
|
|
5785
6003
|
import { spawn } from "node:child_process";
|
|
5786
6004
|
import { Duplex } from "node:stream";
|
|
@@ -42527,7 +42745,7 @@ ${plan}` }]
|
|
|
42527
42745
|
});
|
|
42528
42746
|
|
|
42529
42747
|
// src/acp/harness/claude/upstream/dist/goal-extension.js
|
|
42530
|
-
import { RequestError } from "@agentclientprotocol/sdk";
|
|
42748
|
+
import { RequestError as RequestError2 } from "@agentclientprotocol/sdk";
|
|
42531
42749
|
function goalUpdateFromPrompt(prompt) {
|
|
42532
42750
|
const match = /^\/goal(?:\s+([\s\S]*))?$/.exec(prompt);
|
|
42533
42751
|
const argument = match?.[1]?.trim();
|
|
@@ -42545,17 +42763,17 @@ function goalUpdateFromPrompt(prompt) {
|
|
|
42545
42763
|
}
|
|
42546
42764
|
function parseGoalRequest(params) {
|
|
42547
42765
|
if (!params || typeof params !== "object") {
|
|
42548
|
-
throw
|
|
42766
|
+
throw RequestError2.invalidParams(void 0, "goal params must be an object");
|
|
42549
42767
|
}
|
|
42550
42768
|
const { sessionId, action, objective } = params;
|
|
42551
42769
|
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
42552
|
-
throw
|
|
42770
|
+
throw RequestError2.invalidParams(void 0, "goal params require a non-empty sessionId");
|
|
42553
42771
|
}
|
|
42554
42772
|
if (!GOAL_ACTIONS.includes(action)) {
|
|
42555
|
-
throw
|
|
42773
|
+
throw RequestError2.invalidParams(void 0, 'goal action must be "set" or "clear"');
|
|
42556
42774
|
}
|
|
42557
42775
|
if (action === "set" && (typeof objective !== "string" || objective.trim().length === 0)) {
|
|
42558
|
-
throw
|
|
42776
|
+
throw RequestError2.invalidParams(void 0, 'goal action "set" requires a non-empty objective');
|
|
42559
42777
|
}
|
|
42560
42778
|
return action === "set" ? { sessionId, action, objective: objective.trim() } : { sessionId, action: "clear" };
|
|
42561
42779
|
}
|
|
@@ -42631,7 +42849,7 @@ var init_modes = __esm({
|
|
|
42631
42849
|
});
|
|
42632
42850
|
|
|
42633
42851
|
// src/acp/harness/claude/upstream/dist/permissions/normalization.js
|
|
42634
|
-
function
|
|
42852
|
+
function isRecord2(value) {
|
|
42635
42853
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
42636
42854
|
}
|
|
42637
42855
|
function isDestination(value) {
|
|
@@ -42648,13 +42866,13 @@ function safePlainString(value, maxLength) {
|
|
|
42648
42866
|
});
|
|
42649
42867
|
}
|
|
42650
42868
|
function isRule(value) {
|
|
42651
|
-
if (!
|
|
42869
|
+
if (!isRecord2(value) || !safePlainString(value.toolName, MAX_TOOL_NAME_LENGTH)) {
|
|
42652
42870
|
return false;
|
|
42653
42871
|
}
|
|
42654
42872
|
return value.ruleContent === void 0 || safePlainString(value.ruleContent, MAX_RULE_CONTENT_LENGTH);
|
|
42655
42873
|
}
|
|
42656
42874
|
function isKnownUpdate(value) {
|
|
42657
|
-
if (!
|
|
42875
|
+
if (!isRecord2(value) || !isDestination(value.destination) || typeof value.type !== "string") {
|
|
42658
42876
|
return false;
|
|
42659
42877
|
}
|
|
42660
42878
|
switch (value.type) {
|
|
@@ -65115,7 +65333,7 @@ var init_settings = __esm({
|
|
|
65115
65333
|
});
|
|
65116
65334
|
|
|
65117
65335
|
// src/acp/harness/claude/upstream/dist/session-mode.js
|
|
65118
|
-
import { RequestError as
|
|
65336
|
+
import { RequestError as RequestError3 } from "@agentclientprotocol/sdk";
|
|
65119
65337
|
var MODE_CONFIG_ID, AUTO_MODE_FALLBACK, AUTO_MODE_FALLBACK_NOTICE, SessionModeManager;
|
|
65120
65338
|
var init_session_mode = __esm({
|
|
65121
65339
|
"src/acp/harness/claude/upstream/dist/session-mode.js"() {
|
|
@@ -65265,7 +65483,7 @@ var init_session_mode = __esm({
|
|
|
65265
65483
|
throw new Error("Session not found");
|
|
65266
65484
|
}
|
|
65267
65485
|
if (session.queryClosed) {
|
|
65268
|
-
throw
|
|
65486
|
+
throw RequestError3.internalError(void 0, this.options.sessionEndedMessage);
|
|
65269
65487
|
}
|
|
65270
65488
|
return session;
|
|
65271
65489
|
}
|
|
@@ -65345,7 +65563,7 @@ import * as fs4 from "node:fs/promises";
|
|
|
65345
65563
|
import * as os3 from "node:os";
|
|
65346
65564
|
import * as path6 from "node:path";
|
|
65347
65565
|
import { promisify } from "node:util";
|
|
65348
|
-
import { agent as acpAgent, CreateElicitationResponse as CreateElicitationResponse2, methods, ndJsonStream, RequestError as
|
|
65566
|
+
import { agent as acpAgent, CreateElicitationResponse as CreateElicitationResponse2, methods as methods2, ndJsonStream, RequestError as RequestError4 } from "@agentclientprotocol/sdk";
|
|
65349
65567
|
function supportsMcpOAuth(query) {
|
|
65350
65568
|
return typeof query.mcpAuthenticate === "function";
|
|
65351
65569
|
}
|
|
@@ -65367,19 +65585,19 @@ function waitUnlessAborted(milliseconds, signal) {
|
|
|
65367
65585
|
}
|
|
65368
65586
|
function parseSteerRequest(params) {
|
|
65369
65587
|
if (!params || typeof params !== "object") {
|
|
65370
|
-
throw
|
|
65588
|
+
throw RequestError4.invalidParams(void 0, "steer params must be an object");
|
|
65371
65589
|
}
|
|
65372
65590
|
const { sessionId, prompt, _meta } = params;
|
|
65373
65591
|
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
65374
|
-
throw
|
|
65592
|
+
throw RequestError4.invalidParams(void 0, "steer params require a non-empty sessionId");
|
|
65375
65593
|
}
|
|
65376
65594
|
if (!Array.isArray(prompt) || prompt.length === 0) {
|
|
65377
|
-
throw
|
|
65595
|
+
throw RequestError4.invalidParams(void 0, "steer params require a non-empty prompt array");
|
|
65378
65596
|
}
|
|
65379
65597
|
const steering = _meta && typeof _meta === "object" ? _meta.steering : void 0;
|
|
65380
65598
|
const idleBehavior = steering && typeof steering === "object" ? steering.idleBehavior : void 0;
|
|
65381
65599
|
if (idleBehavior !== void 0 && idleBehavior !== "promptRequired") {
|
|
65382
|
-
throw
|
|
65600
|
+
throw RequestError4.invalidParams(void 0, "unsupported steering idleBehavior");
|
|
65383
65601
|
}
|
|
65384
65602
|
return {
|
|
65385
65603
|
sessionId,
|
|
@@ -65389,14 +65607,14 @@ function parseSteerRequest(params) {
|
|
|
65389
65607
|
}
|
|
65390
65608
|
function parseRenameRequest(params) {
|
|
65391
65609
|
if (!params || typeof params !== "object") {
|
|
65392
|
-
throw
|
|
65610
|
+
throw RequestError4.invalidParams(void 0, "rename params must be an object");
|
|
65393
65611
|
}
|
|
65394
65612
|
const { sessionId, title: title2 } = params;
|
|
65395
65613
|
if (typeof sessionId !== "string" || sessionId.length === 0) {
|
|
65396
|
-
throw
|
|
65614
|
+
throw RequestError4.invalidParams(void 0, "rename params require a non-empty sessionId");
|
|
65397
65615
|
}
|
|
65398
65616
|
if (typeof title2 !== "string" || title2.trim().length === 0) {
|
|
65399
|
-
throw
|
|
65617
|
+
throw RequestError4.invalidParams(void 0, "rename params require a non-empty title");
|
|
65400
65618
|
}
|
|
65401
65619
|
return { sessionId, title: title2 };
|
|
65402
65620
|
}
|
|
@@ -66860,7 +67078,7 @@ function createClaudeAcpApp(options = {}) {
|
|
|
66860
67078
|
const app = acpAgent({ name: "claude-code-acp" }).onConnect((connection) => {
|
|
66861
67079
|
agent = new ClaudeAcpAgent(new ClientConnection(connection.client, options.onSessionUpdate), options.logger, options.environment, options.spawnClaudeCodeProcess, options.onBackgroundActivity);
|
|
66862
67080
|
options.onConnect?.(connection);
|
|
66863
|
-
}).onRequest(
|
|
67081
|
+
}).onRequest(methods2.agent.initialize, (ctx) => requiredAgent(agent).initialize(ctx.params)).onRequest(methods2.agent.session.new, (ctx) => requiredAgent(agent).newSession(ctx.params)).onRequest(methods2.agent.session.load, (ctx) => requiredAgent(agent).loadSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.fork, (ctx) => requiredAgent(agent).unstable_forkSession(ctx.params, ctx.signal)).onRequest(methods2.agent.session.list, (ctx) => requiredAgent(agent).listSessions(ctx.params, ctx.signal)).onRequest(methods2.agent.session.delete, (ctx) => requiredAgent(agent).deleteSession(ctx.params)).onRequest(methods2.agent.session.resume, (ctx) => requiredAgent(agent).resumeSession(ctx.params)).onRequest(methods2.agent.session.close, (ctx) => requiredAgent(agent).closeSession(ctx.params)).onRequest(methods2.agent.session.setMode, (ctx) => requiredAgent(agent).setSessionMode(ctx.params)).onRequest(methods2.agent.session.setConfigOption, (ctx) => requiredAgent(agent).setSessionConfigOption(ctx.params)).onRequest(methods2.agent.authenticate, (ctx) => requiredAgent(agent).authenticate(ctx.params)).onRequest(methods2.agent.providers.list, (ctx) => requiredAgent(agent).unstable_listProviders(ctx.params)).onRequest(methods2.agent.providers.set, (ctx) => requiredAgent(agent).unstable_setProvider(ctx.params)).onRequest(methods2.agent.providers.disable, (ctx) => requiredAgent(agent).unstable_disableProvider(ctx.params)).onRequest(methods2.agent.logout, (ctx) => requiredAgent(agent).logout(ctx.params)).onRequest(methods2.agent.session.prompt, (ctx) => runPromptWithCancellation(requiredAgent(agent), ctx.params, ctx.signal)).onNotification(methods2.agent.session.cancel, (ctx) => requiredAgent(agent).cancel(ctx.params)).onRequest(STEER_METHOD, { parse: parseSteerRequest }, (ctx) => requiredAgent(agent).steer(ctx.params)).onRequest(RENAME_METHOD, { parse: parseRenameRequest }, (ctx) => requiredAgent(agent).renameSession(ctx.params)).onRequest(GOAL_CONTROL_METHOD, { parse: parseGoalRequest }, (ctx) => requiredAgent(agent).goal(ctx.params));
|
|
66864
67082
|
return { agent: () => agent, app };
|
|
66865
67083
|
}
|
|
66866
67084
|
function requiredAgent(agent) {
|
|
@@ -67028,26 +67246,26 @@ var init_acp_agent = __esm({
|
|
|
67028
67246
|
if (this.onSessionUpdate !== void 0) {
|
|
67029
67247
|
return this.onSessionUpdate(params);
|
|
67030
67248
|
}
|
|
67031
|
-
return this.ctx.notify(
|
|
67249
|
+
return this.ctx.notify(methods2.client.session.update, params);
|
|
67032
67250
|
}
|
|
67033
67251
|
requestPermission(params, signal) {
|
|
67034
|
-
return this.ctx.request(
|
|
67252
|
+
return this.ctx.request(methods2.client.session.requestPermission, params, {
|
|
67035
67253
|
cancellationSignal: signal
|
|
67036
67254
|
});
|
|
67037
67255
|
}
|
|
67038
67256
|
readTextFile(params) {
|
|
67039
|
-
return this.ctx.request(
|
|
67257
|
+
return this.ctx.request(methods2.client.fs.readTextFile, params);
|
|
67040
67258
|
}
|
|
67041
67259
|
writeTextFile(params) {
|
|
67042
|
-
return this.ctx.request(
|
|
67260
|
+
return this.ctx.request(methods2.client.fs.writeTextFile, params);
|
|
67043
67261
|
}
|
|
67044
67262
|
createElicitation(params, signal) {
|
|
67045
|
-
return this.ctx.request(
|
|
67263
|
+
return this.ctx.request(methods2.client.elicitation.create, params, {
|
|
67046
67264
|
cancellationSignal: signal
|
|
67047
67265
|
});
|
|
67048
67266
|
}
|
|
67049
67267
|
completeElicitation(params) {
|
|
67050
|
-
return this.ctx.notify(
|
|
67268
|
+
return this.ctx.notify(methods2.client.elicitation.complete, params);
|
|
67051
67269
|
}
|
|
67052
67270
|
extNotification(method, params) {
|
|
67053
67271
|
return this.ctx.notify(method, params);
|
|
@@ -67377,13 +67595,13 @@ var init_acp_agent = __esm({
|
|
|
67377
67595
|
*/
|
|
67378
67596
|
async unstable_setProvider(params) {
|
|
67379
67597
|
if (params.providerId !== PROVIDER_ID) {
|
|
67380
|
-
throw
|
|
67598
|
+
throw RequestError4.invalidParams({ providerId: params.providerId }, `Unknown provider ID "${params.providerId}"; expected "${PROVIDER_ID}".`);
|
|
67381
67599
|
}
|
|
67382
67600
|
if (!SUPPORTED_PROTOCOLS.includes(params.apiType)) {
|
|
67383
|
-
throw
|
|
67601
|
+
throw RequestError4.invalidParams({ apiType: params.apiType, supported: SUPPORTED_PROTOCOLS }, `Unsupported apiType "${params.apiType}" for provider "${PROVIDER_ID}".`);
|
|
67384
67602
|
}
|
|
67385
67603
|
if (!isValidBaseUrl(params.baseUrl)) {
|
|
67386
|
-
throw
|
|
67604
|
+
throw RequestError4.invalidParams({ baseUrl: params.baseUrl }, "baseUrl must be a non-empty absolute http(s) URL.");
|
|
67387
67605
|
}
|
|
67388
67606
|
const config2 = {
|
|
67389
67607
|
apiType: params.apiType,
|
|
@@ -67393,7 +67611,7 @@ var init_acp_agent = __esm({
|
|
|
67393
67611
|
if (params.apiType === "vertex") {
|
|
67394
67612
|
const vertex = params._meta?.claudeCode?.vertex;
|
|
67395
67613
|
if (!vertex || typeof vertex.projectId !== "string" || vertex.projectId.trim() === "" || typeof vertex.region !== "string" || vertex.region.trim() === "") {
|
|
67396
|
-
throw
|
|
67614
|
+
throw RequestError4.invalidParams(void 0, "vertex apiType requires non-empty `_meta.claudeCode.vertex.projectId` and `_meta.claudeCode.vertex.region`.");
|
|
67397
67615
|
}
|
|
67398
67616
|
config2.vertex = { projectId: vertex.projectId, region: vertex.region };
|
|
67399
67617
|
}
|
|
@@ -67449,7 +67667,7 @@ var init_acp_agent = __esm({
|
|
|
67449
67667
|
await execFileAsync(cliPath, ["auth", "logout"]);
|
|
67450
67668
|
} catch (error62) {
|
|
67451
67669
|
const stderr = typeof error62 === "object" && error62 && "stderr" in error62 ? String(error62.stderr).trim() : void 0;
|
|
67452
|
-
throw
|
|
67670
|
+
throw RequestError4.internalError({ stderr: stderr || void 0 }, `claude auth logout failed: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
67453
67671
|
}
|
|
67454
67672
|
}
|
|
67455
67673
|
async prompt(params) {
|
|
@@ -67461,7 +67679,7 @@ var init_acp_agent = __esm({
|
|
|
67461
67679
|
throw new Error("Session not found");
|
|
67462
67680
|
}
|
|
67463
67681
|
if (session.queryClosed) {
|
|
67464
|
-
throw
|
|
67682
|
+
throw RequestError4.internalError(void 0, SESSION_ENDED_MESSAGE);
|
|
67465
67683
|
}
|
|
67466
67684
|
if (session.autoModeFallbackWarningPending) {
|
|
67467
67685
|
await this.sessionModes.publishFallbackWarning(params.sessionId, session);
|
|
@@ -67601,7 +67819,7 @@ var init_acp_agent = __esm({
|
|
|
67601
67819
|
throw new Error("Session not found");
|
|
67602
67820
|
}
|
|
67603
67821
|
if (session.queryClosed) {
|
|
67604
|
-
throw
|
|
67822
|
+
throw RequestError4.internalError(void 0, SESSION_ENDED_MESSAGE);
|
|
67605
67823
|
}
|
|
67606
67824
|
const turnInFlight = (session.turnQueue ?? []).find((turn) => !turn.settled);
|
|
67607
67825
|
if (!turnInFlight) {
|
|
@@ -67932,7 +68150,7 @@ var init_acp_agent = __esm({
|
|
|
67932
68150
|
for (const queued of [...session.turnQueue ?? []]) {
|
|
67933
68151
|
if (!queued.settled) {
|
|
67934
68152
|
queued.settled = true;
|
|
67935
|
-
queued.reject(
|
|
68153
|
+
queued.reject(RequestError4.internalError(void 0, SESSION_ENDED_MESSAGE));
|
|
67936
68154
|
}
|
|
67937
68155
|
}
|
|
67938
68156
|
session.turnQueue = [];
|
|
@@ -68081,16 +68299,15 @@ var init_acp_agent = __esm({
|
|
|
68081
68299
|
session.lastSessionState = message.state;
|
|
68082
68300
|
if (message.state === "idle") {
|
|
68083
68301
|
disarmResultWatchdog();
|
|
68302
|
+
const boundary = session.idleBoundary;
|
|
68303
|
+
const hadEarlierResult = boundary.kind === "accounted" && boundary.turn !== session.activeTurn;
|
|
68304
|
+
session.idleBoundary = { kind: "unaccounted" };
|
|
68084
68305
|
if (session.cancelled && session.activeTurn && !session.activeTurn.settled) {
|
|
68085
68306
|
settleActive(turnOutcome(session, "cancelled"));
|
|
68086
68307
|
session.emittedAssistantText = false;
|
|
68087
68308
|
} else if (isHeldOpen(session.activeTurn)) {
|
|
68088
|
-
if (session.owedTrailingIdles > 0) {
|
|
68089
|
-
session.owedTrailingIdles--;
|
|
68090
|
-
}
|
|
68091
68309
|
settleDeferredIfDrained();
|
|
68092
|
-
} else if (
|
|
68093
|
-
session.owedTrailingIdles--;
|
|
68310
|
+
} else if (hadEarlierResult) {
|
|
68094
68311
|
} else if (isSteering(session.activeTurn)) {
|
|
68095
68312
|
const steered = session.activeTurn;
|
|
68096
68313
|
if (steered.steeredEchoes?.size === 0 && steered.steeredSettle !== void 0) {
|
|
@@ -68099,9 +68316,9 @@ var init_acp_agent = __esm({
|
|
|
68099
68316
|
steered.steeredSettle = void 0;
|
|
68100
68317
|
settleDeferredIfDrained();
|
|
68101
68318
|
}
|
|
68102
|
-
} else if (!session.cancelled && session.activeTurn && !session.activeTurn.settled) {
|
|
68319
|
+
} else if (boundary.kind === "unaccounted" && !session.cancelled && session.activeTurn && !session.activeTurn.settled) {
|
|
68103
68320
|
this.logger.error(`Session ${params.sessionId}: SDK went idle without emitting a result for the active turn; failing the in-flight prompt (issue #825)`);
|
|
68104
|
-
failActive(
|
|
68321
|
+
failActive(RequestError4.internalError(errorKindData("no_result"), TURN_NO_RESULT_MESSAGE));
|
|
68105
68322
|
}
|
|
68106
68323
|
await session.titles.onTurnEnd(session);
|
|
68107
68324
|
}
|
|
@@ -68360,9 +68577,8 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68360
68577
|
}
|
|
68361
68578
|
}
|
|
68362
68579
|
const deliveredAssistantText = session.emittedAssistantText;
|
|
68363
|
-
|
|
68364
|
-
|
|
68365
|
-
session.owedTrailingIdles++;
|
|
68580
|
+
if (isAutonomousResult || !session.cancelled || !session.activeTurn) {
|
|
68581
|
+
session.idleBoundary = { kind: "accounted", turn: session.activeTurn ?? null };
|
|
68366
68582
|
}
|
|
68367
68583
|
if (!isAutonomousResult) {
|
|
68368
68584
|
session.accumulatedUsage.inputTokens += message.usage.input_tokens;
|
|
@@ -68457,7 +68673,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68457
68673
|
break;
|
|
68458
68674
|
}
|
|
68459
68675
|
if (message.is_error) {
|
|
68460
|
-
failActive(
|
|
68676
|
+
failActive(RequestError4.internalError(errorKindData(lastAssistantError), message.result));
|
|
68461
68677
|
break;
|
|
68462
68678
|
}
|
|
68463
68679
|
if (session.activeTurn?.isLocalOnlyCommand || !deliveredAssistantText && (message.usage.output_tokens ?? 0) === 0) {
|
|
@@ -68473,7 +68689,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68473
68689
|
break;
|
|
68474
68690
|
}
|
|
68475
68691
|
if (message.is_error) {
|
|
68476
|
-
failActive(
|
|
68692
|
+
failActive(RequestError4.internalError(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype));
|
|
68477
68693
|
break;
|
|
68478
68694
|
}
|
|
68479
68695
|
stopReason = "end_turn";
|
|
@@ -68483,7 +68699,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68483
68699
|
case "error_max_turns":
|
|
68484
68700
|
case "error_max_structured_output_retries":
|
|
68485
68701
|
if (message.is_error) {
|
|
68486
|
-
failActive(
|
|
68702
|
+
failActive(RequestError4.internalError(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype));
|
|
68487
68703
|
break;
|
|
68488
68704
|
}
|
|
68489
68705
|
stopReason = "max_turn_requests";
|
|
@@ -68624,12 +68840,18 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68624
68840
|
if (session.activeTurn !== queued) {
|
|
68625
68841
|
if (session.activeTurn) {
|
|
68626
68842
|
if (session.cancelled) {
|
|
68627
|
-
session.
|
|
68843
|
+
session.idleBoundary = {
|
|
68844
|
+
kind: "accounted",
|
|
68845
|
+
turn: session.activeTurn ?? null
|
|
68846
|
+
};
|
|
68628
68847
|
settleActive(turnOutcome(session, "cancelled"));
|
|
68629
68848
|
} else if (isHeldOpen(session.activeTurn)) {
|
|
68630
68849
|
settleActive(session.activeTurn.deferredSettle);
|
|
68631
68850
|
} else if (isSteering(session.activeTurn) && session.activeTurn.steeredSettle !== void 0) {
|
|
68632
|
-
session.
|
|
68851
|
+
session.idleBoundary = {
|
|
68852
|
+
kind: "accounted",
|
|
68853
|
+
turn: session.activeTurn ?? null
|
|
68854
|
+
};
|
|
68633
68855
|
settleActive(session.activeTurn.steeredSettle);
|
|
68634
68856
|
} else {
|
|
68635
68857
|
settleActive(turnOutcome(session, "end_turn"));
|
|
@@ -68640,8 +68862,8 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68640
68862
|
break;
|
|
68641
68863
|
}
|
|
68642
68864
|
if ("isReplay" in message && message.isReplay) {
|
|
68643
|
-
if (isSteering(session.activeTurn)) {
|
|
68644
|
-
session.activeTurn.
|
|
68865
|
+
if (isSteering(session.activeTurn) && session.activeTurn.steeredEchoes.delete(message.uuid)) {
|
|
68866
|
+
session.activeTurn.steeredSettle = void 0;
|
|
68645
68867
|
}
|
|
68646
68868
|
break;
|
|
68647
68869
|
}
|
|
@@ -68695,7 +68917,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68695
68917
|
break;
|
|
68696
68918
|
}
|
|
68697
68919
|
if (message.type === "assistant" && message.error === "authentication_failed") {
|
|
68698
|
-
failActive(
|
|
68920
|
+
failActive(RequestError4.authRequired(errorKindData(message.error)));
|
|
68699
68921
|
break;
|
|
68700
68922
|
}
|
|
68701
68923
|
let content;
|
|
@@ -68820,7 +69042,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68820
69042
|
const processDied = error62 instanceof Error && (message.includes("ProcessTransport") || message.includes("terminated process") || message.includes("process exited with") || message.includes("process terminated by signal") || message.includes("Failed to write to process stdin"));
|
|
68821
69043
|
if (processDied) {
|
|
68822
69044
|
this.logger.error(`Session ${params.sessionId}: Claude Agent process died: ${message}`);
|
|
68823
|
-
failAllTurns(
|
|
69045
|
+
failAllTurns(RequestError4.internalError(void 0, "The Claude Agent process exited unexpectedly. Please start a new session."));
|
|
68824
69046
|
this.closeQueryStream(session);
|
|
68825
69047
|
delete this.sessions[params.sessionId];
|
|
68826
69048
|
} else {
|
|
@@ -68906,7 +69128,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68906
69128
|
session.activeTurn = null;
|
|
68907
69129
|
session.emittedAssistantText = false;
|
|
68908
69130
|
if (session.lastSessionState !== "idle") {
|
|
68909
|
-
session.
|
|
69131
|
+
session.idleBoundary = { kind: "accounted", turn: active };
|
|
68910
69132
|
}
|
|
68911
69133
|
active.resolve({
|
|
68912
69134
|
stopReason: "cancelled",
|
|
@@ -68916,7 +69138,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
68916
69138
|
}
|
|
68917
69139
|
}
|
|
68918
69140
|
if (isSteering(session.activeTurn) && session.activeTurn.steeredSettle !== void 0) {
|
|
68919
|
-
session.
|
|
69141
|
+
session.idleBoundary = { kind: "accounted", turn: session.activeTurn ?? null };
|
|
68920
69142
|
}
|
|
68921
69143
|
if (session.activeTurn && session.cancelController && !session.cancelController.signal.aborted && !session.forceCancelTimer) {
|
|
68922
69144
|
const cancelController = session.cancelController;
|
|
@@ -69025,7 +69247,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69025
69247
|
throw new Error("Session not found");
|
|
69026
69248
|
}
|
|
69027
69249
|
if (session.queryClosed) {
|
|
69028
|
-
throw
|
|
69250
|
+
throw RequestError4.internalError(void 0, SESSION_ENDED_MESSAGE);
|
|
69029
69251
|
}
|
|
69030
69252
|
const option = session.configOptions.find((o) => o.id === params.configId);
|
|
69031
69253
|
if (!option) {
|
|
@@ -69621,16 +69843,16 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69621
69843
|
*/
|
|
69622
69844
|
async validateCwd(cwd) {
|
|
69623
69845
|
if (!path6.isAbsolute(cwd)) {
|
|
69624
|
-
throw
|
|
69846
|
+
throw RequestError4.invalidParams({ cwd }, `\`cwd\` must be an absolute path, but received: ${cwd}`);
|
|
69625
69847
|
}
|
|
69626
69848
|
let stats;
|
|
69627
69849
|
try {
|
|
69628
69850
|
stats = await fs4.stat(cwd);
|
|
69629
69851
|
} catch {
|
|
69630
|
-
throw
|
|
69852
|
+
throw RequestError4.invalidParams({ cwd }, `\`cwd\` does not exist on the machine running the agent: ${cwd}`);
|
|
69631
69853
|
}
|
|
69632
69854
|
if (!stats.isDirectory()) {
|
|
69633
|
-
throw
|
|
69855
|
+
throw RequestError4.invalidParams({ cwd }, `\`cwd\` is not a directory: ${cwd}`);
|
|
69634
69856
|
}
|
|
69635
69857
|
}
|
|
69636
69858
|
async createSession(params, creationOpts = {}) {
|
|
@@ -69853,12 +70075,12 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69853
70075
|
initializationResult = await q2.initializationResult();
|
|
69854
70076
|
} catch (error62) {
|
|
69855
70077
|
if (creationOpts.resume && error62 instanceof Error && (error62.message === "Query closed before response received" || error62.message.includes("No conversation found with session ID"))) {
|
|
69856
|
-
throw
|
|
70078
|
+
throw RequestError4.resourceNotFound(sessionId);
|
|
69857
70079
|
}
|
|
69858
70080
|
throw error62;
|
|
69859
70081
|
}
|
|
69860
70082
|
if (shouldHideClaudeAuth() && initializationResult.account.subscriptionType && !this.gatewayAuthRequest) {
|
|
69861
|
-
throw
|
|
70083
|
+
throw RequestError4.authRequired(void 0, "This integration does not support using claude.ai subscriptions.");
|
|
69862
70084
|
}
|
|
69863
70085
|
const settingsAvailableModels = settingsManager.getSettings().availableModels;
|
|
69864
70086
|
const settingsModelOverrides = settingsManager.getSettings().modelOverrides;
|
|
@@ -69934,7 +70156,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69934
70156
|
emittedToolCalls: /* @__PURE__ */ new Set(),
|
|
69935
70157
|
liveBackgroundTasks: /* @__PURE__ */ new Map(),
|
|
69936
70158
|
emittedAssistantText: false,
|
|
69937
|
-
|
|
70159
|
+
idleBoundary: { kind: "unaccounted" },
|
|
69938
70160
|
messageIdToUuid: /* @__PURE__ */ new Map()
|
|
69939
70161
|
};
|
|
69940
70162
|
return {
|
|
@@ -70081,6 +70303,28 @@ var init_endpoint = __esm({
|
|
|
70081
70303
|
}
|
|
70082
70304
|
});
|
|
70083
70305
|
|
|
70306
|
+
// src/acp/adapter/claude/agent-connection.ts
|
|
70307
|
+
var ClaudeAgentConnection;
|
|
70308
|
+
var init_agent_connection = __esm({
|
|
70309
|
+
"src/acp/adapter/claude/agent-connection.ts"() {
|
|
70310
|
+
"use strict";
|
|
70311
|
+
init_endpoint_agent_connection();
|
|
70312
|
+
init_endpoint();
|
|
70313
|
+
ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
70314
|
+
constructor(options) {
|
|
70315
|
+
const endpoint = new ClaudeAcpEndpoint({
|
|
70316
|
+
command: options.command,
|
|
70317
|
+
cwd: options.cwd,
|
|
70318
|
+
environment: options.environment,
|
|
70319
|
+
onSessionUpdate: options.client.onUpdate,
|
|
70320
|
+
onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
|
|
70321
|
+
});
|
|
70322
|
+
super(endpoint, options.client);
|
|
70323
|
+
}
|
|
70324
|
+
};
|
|
70325
|
+
}
|
|
70326
|
+
});
|
|
70327
|
+
|
|
70084
70328
|
// src/util/filesystem/path-error.ts
|
|
70085
70329
|
var LocalPathError;
|
|
70086
70330
|
var init_path_error = __esm({
|
|
@@ -71025,7 +71269,7 @@ var init_version_output = __esm({
|
|
|
71025
71269
|
});
|
|
71026
71270
|
|
|
71027
71271
|
// src/agent/specification/agent-specification.ts
|
|
71028
|
-
var VERSION_PROBE_TIMEOUT_MILLISECONDS, ACP_PROBE_TIMEOUT_MILLISECONDS, LocalAgentSpecification,
|
|
71272
|
+
var VERSION_PROBE_TIMEOUT_MILLISECONDS, ACP_PROBE_TIMEOUT_MILLISECONDS, LocalAgentSpecification, InProcessAcpAgentSpecification;
|
|
71029
71273
|
var init_agent_specification = __esm({
|
|
71030
71274
|
"src/agent/specification/agent-specification.ts"() {
|
|
71031
71275
|
"use strict";
|
|
@@ -71047,17 +71291,6 @@ var init_agent_specification = __esm({
|
|
|
71047
71291
|
resolveInstalledAgentExecutables = (_context) => Promise.resolve([]);
|
|
71048
71292
|
verifyAcp = (_connection, _initialized, _defaultWorkspace, _signal) => Promise.resolve();
|
|
71049
71293
|
};
|
|
71050
|
-
DirectAcpAgentSpecification = class extends LocalAgentSpecification {
|
|
71051
|
-
adapterOverrideVariable;
|
|
71052
|
-
agentOverrideVariable;
|
|
71053
|
-
launchArguments;
|
|
71054
|
-
constructor(executableOverrideVariable, launchArguments) {
|
|
71055
|
-
super();
|
|
71056
|
-
this.adapterOverrideVariable = executableOverrideVariable;
|
|
71057
|
-
this.agentOverrideVariable = executableOverrideVariable;
|
|
71058
|
-
this.launchArguments = Object.freeze([...launchArguments]);
|
|
71059
|
-
}
|
|
71060
|
-
};
|
|
71061
71294
|
InProcessAcpAgentSpecification = class extends LocalAgentSpecification {
|
|
71062
71295
|
launchArguments = Object.freeze([]);
|
|
71063
71296
|
adapterOverrideVariable;
|
|
@@ -71077,13 +71310,13 @@ var ClaudeCodeAgentSpecification;
|
|
|
71077
71310
|
var init_claude_code_agent = __esm({
|
|
71078
71311
|
"src/agent/specification/vendors/claude-code-agent.ts"() {
|
|
71079
71312
|
"use strict";
|
|
71080
|
-
|
|
71313
|
+
init_agent_connection();
|
|
71081
71314
|
init_platform();
|
|
71082
71315
|
init_executable();
|
|
71083
71316
|
init_agent_specification();
|
|
71084
71317
|
ClaudeCodeAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
71085
71318
|
agentExecutable = "claude";
|
|
71086
|
-
|
|
71319
|
+
createConnection = (options) => new ClaudeAgentConnection(options);
|
|
71087
71320
|
id = "claude";
|
|
71088
71321
|
label = "Claude Code";
|
|
71089
71322
|
minimumSupportedAgentVersion = "2.1.273";
|
|
@@ -71109,76 +71342,6 @@ var init_claude_code_agent = __esm({
|
|
|
71109
71342
|
}
|
|
71110
71343
|
});
|
|
71111
71344
|
|
|
71112
|
-
// src/infra/operation-error.ts
|
|
71113
|
-
function operationErrorCode(error62) {
|
|
71114
|
-
return error62 instanceof OperationError ? error62.code : "session_operation_failed";
|
|
71115
|
-
}
|
|
71116
|
-
function operationErrorMessage(error62) {
|
|
71117
|
-
return error62 instanceof OperationError ? error62.message : "The local agent operation could not be completed";
|
|
71118
|
-
}
|
|
71119
|
-
var OperationError;
|
|
71120
|
-
var init_operation_error = __esm({
|
|
71121
|
-
"src/infra/operation-error.ts"() {
|
|
71122
|
-
"use strict";
|
|
71123
|
-
OperationError = class extends Error {
|
|
71124
|
-
code;
|
|
71125
|
-
constructor(code, message, options = {}) {
|
|
71126
|
-
super(message, options);
|
|
71127
|
-
this.code = code;
|
|
71128
|
-
}
|
|
71129
|
-
};
|
|
71130
|
-
}
|
|
71131
|
-
});
|
|
71132
|
-
|
|
71133
|
-
// src/acp/acp-error.ts
|
|
71134
|
-
var AcpExecutionError, AcpConfigurationValueUnavailableError;
|
|
71135
|
-
var init_acp_error = __esm({
|
|
71136
|
-
"src/acp/acp-error.ts"() {
|
|
71137
|
-
"use strict";
|
|
71138
|
-
init_operation_error();
|
|
71139
|
-
AcpExecutionError = class extends OperationError {
|
|
71140
|
-
constructor(message, options = {}, code = "acp_execution_failed") {
|
|
71141
|
-
super(code, message, options);
|
|
71142
|
-
this.name = "AcpExecutionError";
|
|
71143
|
-
}
|
|
71144
|
-
};
|
|
71145
|
-
AcpConfigurationValueUnavailableError = class extends AcpExecutionError {
|
|
71146
|
-
configId;
|
|
71147
|
-
offeredValueCount;
|
|
71148
|
-
offeredValues;
|
|
71149
|
-
requestedValue;
|
|
71150
|
-
constructor(configId, requestedValue, offeredValues) {
|
|
71151
|
-
super("The requested ACP configuration value is unavailable", {}, "invalid_session_configuration");
|
|
71152
|
-
this.name = "AcpConfigurationValueUnavailableError";
|
|
71153
|
-
this.configId = configId.slice(0, 128);
|
|
71154
|
-
this.requestedValue = requestedValue.slice(0, 128);
|
|
71155
|
-
this.offeredValueCount = offeredValues.length;
|
|
71156
|
-
this.offeredValues = Object.freeze(offeredValues.slice(0, 32).map((value) => value.slice(0, 128)));
|
|
71157
|
-
}
|
|
71158
|
-
};
|
|
71159
|
-
}
|
|
71160
|
-
});
|
|
71161
|
-
|
|
71162
|
-
// src/acp/agent/in-process-endpoint.ts
|
|
71163
|
-
function acpEndpointTerminationError(termination) {
|
|
71164
|
-
switch (termination.kind) {
|
|
71165
|
-
case "failed":
|
|
71166
|
-
return termination.error;
|
|
71167
|
-
case "closed":
|
|
71168
|
-
return new AcpExecutionError("The ACP endpoint is closed", {}, "acp_endpoint_closed");
|
|
71169
|
-
default: {
|
|
71170
|
-
const unreachable3 = termination;
|
|
71171
|
-
return unreachable3;
|
|
71172
|
-
}
|
|
71173
|
-
}
|
|
71174
|
-
}
|
|
71175
|
-
var init_in_process_endpoint = __esm({
|
|
71176
|
-
"src/acp/agent/in-process-endpoint.ts"() {
|
|
71177
|
-
"use strict";
|
|
71178
|
-
init_acp_error();
|
|
71179
|
-
}
|
|
71180
|
-
});
|
|
71181
|
-
|
|
71182
71345
|
// src/acp/harness/codex/app-server-protocol.ts
|
|
71183
71346
|
import { isAbsolute as isAbsolute8 } from "node:path";
|
|
71184
71347
|
function decodeAppServerMessage(value) {
|
|
@@ -71741,7 +71904,7 @@ var init_app_server_client = __esm({
|
|
|
71741
71904
|
|
|
71742
71905
|
// src/acp/harness/codex/items.ts
|
|
71743
71906
|
import { pathToFileURL } from "node:url";
|
|
71744
|
-
function
|
|
71907
|
+
function truncate2(value, limit) {
|
|
71745
71908
|
return value.length <= limit ? value : value.slice(0, limit);
|
|
71746
71909
|
}
|
|
71747
71910
|
function boundedParagraphs(values, limit) {
|
|
@@ -71757,7 +71920,7 @@ function boundedParagraphs(values, limit) {
|
|
|
71757
71920
|
return text2;
|
|
71758
71921
|
}
|
|
71759
71922
|
function textContent(text2) {
|
|
71760
|
-
const block = { text:
|
|
71923
|
+
const block = { text: truncate2(text2, TOOL_OUTPUT_CHARACTER_LIMIT), type: "text" };
|
|
71761
71924
|
return { content: block, type: "content" };
|
|
71762
71925
|
}
|
|
71763
71926
|
function structuredToolText(value) {
|
|
@@ -71846,16 +72009,16 @@ function presentToolItem(item) {
|
|
|
71846
72009
|
rawInput: { command: item.command, cwd: item.cwd },
|
|
71847
72010
|
rawOutput: {
|
|
71848
72011
|
...item.exitCode == null ? {} : { exitCode: item.exitCode },
|
|
71849
|
-
output:
|
|
72012
|
+
output: truncate2(output2, TOOL_OUTPUT_CHARACTER_LIMIT)
|
|
71850
72013
|
},
|
|
71851
72014
|
status: commandStatus(item.status),
|
|
71852
|
-
title:
|
|
72015
|
+
title: truncate2(firstLine(item.command), TITLE_CHARACTER_LIMIT)
|
|
71853
72016
|
};
|
|
71854
72017
|
}
|
|
71855
72018
|
if (item.type === "fileChange") {
|
|
71856
72019
|
const paths = item.changes.map((change) => change.path);
|
|
71857
72020
|
const content = item.changes.map((change) => ({
|
|
71858
|
-
newText:
|
|
72021
|
+
newText: truncate2(change.diff, TOOL_OUTPUT_CHARACTER_LIMIT),
|
|
71859
72022
|
path: change.path,
|
|
71860
72023
|
type: "diff"
|
|
71861
72024
|
}));
|
|
@@ -71866,7 +72029,7 @@ function presentToolItem(item) {
|
|
|
71866
72029
|
rawInput: { changes: item.changes.map((change) => change.path) },
|
|
71867
72030
|
rawOutput: null,
|
|
71868
72031
|
status: patchStatus(item.status),
|
|
71869
|
-
title:
|
|
72032
|
+
title: truncate2(paths.join(", "), TITLE_CHARACTER_LIMIT)
|
|
71870
72033
|
};
|
|
71871
72034
|
}
|
|
71872
72035
|
if (item.type === "mcpToolCall") {
|
|
@@ -71879,7 +72042,7 @@ function presentToolItem(item) {
|
|
|
71879
72042
|
rawInput: item.arguments ?? null,
|
|
71880
72043
|
rawOutput: item.error ?? item.result ?? null,
|
|
71881
72044
|
status: mcpStatus(item.status),
|
|
71882
|
-
title:
|
|
72045
|
+
title: truncate2(label, TITLE_CHARACTER_LIMIT)
|
|
71883
72046
|
};
|
|
71884
72047
|
}
|
|
71885
72048
|
if (item.type === "dynamicToolCall") {
|
|
@@ -71892,16 +72055,16 @@ function presentToolItem(item) {
|
|
|
71892
72055
|
rawInput: item.arguments ?? null,
|
|
71893
72056
|
rawOutput: item.contentItems ?? null,
|
|
71894
72057
|
status: mcpStatus(item.status),
|
|
71895
|
-
title:
|
|
72058
|
+
title: truncate2(label, TITLE_CHARACTER_LIMIT)
|
|
71896
72059
|
};
|
|
71897
72060
|
}
|
|
71898
72061
|
if (item.type === "collabAgentToolCall") {
|
|
71899
|
-
const
|
|
72062
|
+
const spawn8 = item.tool === "spawnAgent";
|
|
71900
72063
|
return {
|
|
71901
72064
|
content: [],
|
|
71902
72065
|
kind: "other",
|
|
71903
72066
|
locations: [],
|
|
71904
|
-
rawInput:
|
|
72067
|
+
rawInput: spawn8 ? {
|
|
71905
72068
|
model: item.model,
|
|
71906
72069
|
prompt: item.prompt,
|
|
71907
72070
|
reasoningEffort: item.reasoningEffort,
|
|
@@ -71909,10 +72072,10 @@ function presentToolItem(item) {
|
|
|
71909
72072
|
} : { receiverThreadIds: item.receiverThreadIds, senderThreadId: item.senderThreadId },
|
|
71910
72073
|
rawOutput: {
|
|
71911
72074
|
agentsStates: item.agentsStates,
|
|
71912
|
-
...
|
|
72075
|
+
...spawn8 ? { receiverThreadIds: item.receiverThreadIds } : {}
|
|
71913
72076
|
},
|
|
71914
72077
|
status: collaborationStatus(item.status),
|
|
71915
|
-
title:
|
|
72078
|
+
title: spawn8 ? "Dispatch subagent" : "Wait for subagent"
|
|
71916
72079
|
};
|
|
71917
72080
|
}
|
|
71918
72081
|
if (item.type === "subAgentActivity" && item.kind === "started") {
|
|
@@ -71923,7 +72086,7 @@ function presentToolItem(item) {
|
|
|
71923
72086
|
rawInput: { agentPath: item.agentPath },
|
|
71924
72087
|
rawOutput: { agentThreadId: item.agentThreadId },
|
|
71925
72088
|
status: "in_progress",
|
|
71926
|
-
title:
|
|
72089
|
+
title: truncate2(`Dispatch subagent ${item.agentPath}`, TITLE_CHARACTER_LIMIT)
|
|
71927
72090
|
};
|
|
71928
72091
|
}
|
|
71929
72092
|
return null;
|
|
@@ -72533,7 +72696,7 @@ var init_history_images = __esm({
|
|
|
72533
72696
|
// src/acp/harness/codex/owned-agent.ts
|
|
72534
72697
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
72535
72698
|
import { setTimeout as delay } from "node:timers/promises";
|
|
72536
|
-
import { methods as
|
|
72699
|
+
import { methods as methods3 } from "@agentclientprotocol/sdk";
|
|
72537
72700
|
function permissionDecision(optionId) {
|
|
72538
72701
|
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
72539
72702
|
return optionId;
|
|
@@ -72787,7 +72950,7 @@ var init_owned_agent = __esm({
|
|
|
72787
72950
|
if (connection === null || this.#context.threadId().length === 0) {
|
|
72788
72951
|
return;
|
|
72789
72952
|
}
|
|
72790
|
-
await connection.client.notify(
|
|
72953
|
+
await connection.client.notify(methods3.client.session.update, {
|
|
72791
72954
|
sessionId: this.#context.threadId(),
|
|
72792
72955
|
update: { configOptions: this.#settings.configOptions(), sessionUpdate: "config_option_update" }
|
|
72793
72956
|
});
|
|
@@ -73012,7 +73175,7 @@ var init_owned_agent = __esm({
|
|
|
73012
73175
|
return "cancel";
|
|
73013
73176
|
}
|
|
73014
73177
|
const response = await connection.client.request(
|
|
73015
|
-
|
|
73178
|
+
methods3.client.session.requestPermission,
|
|
73016
73179
|
{
|
|
73017
73180
|
options: [...APPROVAL_OPTIONS],
|
|
73018
73181
|
sessionId: this.#context.threadId(),
|
|
@@ -73049,7 +73212,7 @@ var init_owned_agent = __esm({
|
|
|
73049
73212
|
}
|
|
73050
73213
|
const questions = decoded.data.questions;
|
|
73051
73214
|
const response = await connection.client.request(
|
|
73052
|
-
|
|
73215
|
+
methods3.client.elicitation.create,
|
|
73053
73216
|
{
|
|
73054
73217
|
message: questions.map((question) => question.question).join("\n\n").slice(0, 2e3),
|
|
73055
73218
|
mode: "form",
|
|
@@ -73078,7 +73241,7 @@ var init_owned_agent = __esm({
|
|
|
73078
73241
|
const signal = AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS);
|
|
73079
73242
|
if (params.mode === "url" && params.url !== void 0) {
|
|
73080
73243
|
const response2 = await connection.client.request(
|
|
73081
|
-
|
|
73244
|
+
methods3.client.elicitation.create,
|
|
73082
73245
|
{
|
|
73083
73246
|
elicitationId: `${this.#context.threadId()}-${String(request.id)}`,
|
|
73084
73247
|
message: params.message,
|
|
@@ -73092,7 +73255,7 @@ var init_owned_agent = __esm({
|
|
|
73092
73255
|
return;
|
|
73093
73256
|
}
|
|
73094
73257
|
const response = await connection.client.request(
|
|
73095
|
-
|
|
73258
|
+
methods3.client.elicitation.create,
|
|
73096
73259
|
{
|
|
73097
73260
|
message: params.message,
|
|
73098
73261
|
mode: "form",
|
|
@@ -73447,7 +73610,7 @@ var init_directory = __esm({
|
|
|
73447
73610
|
});
|
|
73448
73611
|
|
|
73449
73612
|
// ../mobius-sdk/src/protocol/shared/message-codec.ts
|
|
73450
|
-
function
|
|
73613
|
+
function isRecord3(value) {
|
|
73451
73614
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73452
73615
|
}
|
|
73453
73616
|
function parseJson(encoded) {
|
|
@@ -73459,12 +73622,12 @@ function parseJson(encoded) {
|
|
|
73459
73622
|
cause: error62
|
|
73460
73623
|
});
|
|
73461
73624
|
}
|
|
73462
|
-
if (!
|
|
73625
|
+
if (!isRecord3(value)) {
|
|
73463
73626
|
throw new ProtocolMessageError("Message must be a JSON object");
|
|
73464
73627
|
}
|
|
73465
73628
|
return value;
|
|
73466
73629
|
}
|
|
73467
|
-
function
|
|
73630
|
+
function readString2(value, key, maximumLength) {
|
|
73468
73631
|
const field = value[key];
|
|
73469
73632
|
if (typeof field !== "string" || field.length === 0 || field.length > maximumLength) {
|
|
73470
73633
|
throw new ProtocolMessageError(`Invalid string field: ${key}`);
|
|
@@ -73502,7 +73665,7 @@ function readIdentifier(value, key) {
|
|
|
73502
73665
|
}
|
|
73503
73666
|
}
|
|
73504
73667
|
function readDirectoryIdentifier(value, key) {
|
|
73505
|
-
const field =
|
|
73668
|
+
const field = readString2(value, key, MAX_DIRECTORY_IDENTIFIER_LENGTH);
|
|
73506
73669
|
if (!isDirectoryIdentifier(field)) {
|
|
73507
73670
|
throw new ProtocolMessageError(`Invalid directory identifier field: ${key}`);
|
|
73508
73671
|
}
|
|
@@ -73514,7 +73677,7 @@ function assertKind(value, expectedKind) {
|
|
|
73514
73677
|
}
|
|
73515
73678
|
}
|
|
73516
73679
|
function decodeMessageKind(encoded) {
|
|
73517
|
-
return
|
|
73680
|
+
return readString2(parseJson(encoded), "kind", 64);
|
|
73518
73681
|
}
|
|
73519
73682
|
function decodeZodMessage(encoded, schema) {
|
|
73520
73683
|
const result = schema.safeParse(parseJson(encoded));
|
|
@@ -74715,7 +74878,9 @@ var init_native = __esm({
|
|
|
74715
74878
|
external_exports.object({
|
|
74716
74879
|
commandId: identifierStringSchema,
|
|
74717
74880
|
prompt: external_exports.string().max(1e5),
|
|
74718
|
-
images: external_exports.array(promptImageSchema).max(8).readonly()
|
|
74881
|
+
images: external_exports.array(promptImageSchema).max(8).readonly(),
|
|
74882
|
+
// Absent from daemons that predate it; a client then cannot restore the prompt's files.
|
|
74883
|
+
resources: external_exports.array(promptResourceSchema).max(16).readonly().optional()
|
|
74719
74884
|
}).readonly()
|
|
74720
74885
|
).readonly(),
|
|
74721
74886
|
turn: activeTurnSnapshotSchema.nullable()
|
|
@@ -76391,7 +76556,7 @@ var init_settings3 = __esm({
|
|
|
76391
76556
|
// src/acp/harness/codex/agent.ts
|
|
76392
76557
|
import {
|
|
76393
76558
|
agent as createAgentApp,
|
|
76394
|
-
methods as
|
|
76559
|
+
methods as methods4,
|
|
76395
76560
|
PROTOCOL_VERSION
|
|
76396
76561
|
} from "@agentclientprotocol/sdk";
|
|
76397
76562
|
function promptInput(prompt) {
|
|
@@ -76490,7 +76655,7 @@ var init_agent = __esm({
|
|
|
76490
76655
|
});
|
|
76491
76656
|
this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
|
|
76492
76657
|
this.#connection = connection;
|
|
76493
|
-
}).onRequest(
|
|
76658
|
+
}).onRequest(methods4.agent.initialize, async () => ({
|
|
76494
76659
|
_meta: { steering: { supported: true } },
|
|
76495
76660
|
agentCapabilities: {
|
|
76496
76661
|
loadSession: true,
|
|
@@ -76500,7 +76665,7 @@ var init_agent = __esm({
|
|
|
76500
76665
|
agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
|
|
76501
76666
|
authMethods: [],
|
|
76502
76667
|
protocolVersion: PROTOCOL_VERSION
|
|
76503
|
-
})).onRequest(
|
|
76668
|
+
})).onRequest(methods4.agent.session.new, async (context) => {
|
|
76504
76669
|
const created = threadStartResponseSchema.parse(
|
|
76505
76670
|
await this.#appServer.request(
|
|
76506
76671
|
"thread/start",
|
|
@@ -76513,13 +76678,13 @@ var init_agent = __esm({
|
|
|
76513
76678
|
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
76514
76679
|
this.#advertiseCompactCommand();
|
|
76515
76680
|
return { configOptions: this.#settings.configOptions(), sessionId: created.thread.id };
|
|
76516
|
-
}).onRequest(
|
|
76681
|
+
}).onRequest(methods4.agent.session.setConfigOption, async (context) => {
|
|
76517
76682
|
this.#settings.applySelection(context.params.configId, context.params.value);
|
|
76518
76683
|
return { configOptions: this.#settings.configOptions() };
|
|
76519
|
-
}).onRequest(
|
|
76684
|
+
}).onRequest(methods4.agent.session.setMode, async (context) => {
|
|
76520
76685
|
this.#settings.applySelection("mode", context.params.modeId);
|
|
76521
76686
|
return {};
|
|
76522
|
-
}).onRequest(
|
|
76687
|
+
}).onRequest(methods4.agent.session.load, async (context) => {
|
|
76523
76688
|
await this.#resume(context.params.sessionId, context.params.cwd, context.signal);
|
|
76524
76689
|
await this.#replaySavedHistory(context.signal);
|
|
76525
76690
|
this.#advertiseCompactCommand();
|
|
@@ -76527,7 +76692,7 @@ var init_agent = __esm({
|
|
|
76527
76692
|
_meta: { steering: { supported: this.#sessionAgent.steeringSupported } },
|
|
76528
76693
|
configOptions: this.#settings.configOptions()
|
|
76529
76694
|
};
|
|
76530
|
-
}).onRequest(
|
|
76695
|
+
}).onRequest(methods4.agent.session.fork, async (context) => {
|
|
76531
76696
|
const forked = threadForkResponseSchema.parse(
|
|
76532
76697
|
await this.#appServer.request(
|
|
76533
76698
|
"thread/fork",
|
|
@@ -76546,14 +76711,14 @@ var init_agent = __esm({
|
|
|
76546
76711
|
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
76547
76712
|
this.#advertiseCompactCommand();
|
|
76548
76713
|
return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
|
|
76549
|
-
}).onRequest(
|
|
76714
|
+
}).onRequest(methods4.agent.session.resume, async (context) => {
|
|
76550
76715
|
await this.#resume(context.params.sessionId, context.params.cwd, context.signal);
|
|
76551
76716
|
this.#advertiseCompactCommand();
|
|
76552
76717
|
return {
|
|
76553
76718
|
_meta: { steering: { supported: this.#sessionAgent.steeringSupported } },
|
|
76554
76719
|
configOptions: this.#settings.configOptions()
|
|
76555
76720
|
};
|
|
76556
|
-
}).onRequest(
|
|
76721
|
+
}).onRequest(methods4.agent.session.prompt, async (context) => {
|
|
76557
76722
|
if (isCompactCommand(context.params.prompt)) {
|
|
76558
76723
|
return await this.#sessionAgent.compact(context.signal);
|
|
76559
76724
|
}
|
|
@@ -76562,7 +76727,7 @@ var init_agent = __esm({
|
|
|
76562
76727
|
"_session/steering",
|
|
76563
76728
|
(params) => params,
|
|
76564
76729
|
async (context) => await this.#sessionAgent.steer(context.params, context.signal)
|
|
76565
|
-
).onRequest(
|
|
76730
|
+
).onRequest(methods4.agent.session.list, async (context) => {
|
|
76566
76731
|
const decoded = threadListResponseSchema.parse(
|
|
76567
76732
|
await this.#appServer.request(
|
|
76568
76733
|
"thread/list",
|
|
@@ -76584,9 +76749,9 @@ var init_agent = __esm({
|
|
|
76584
76749
|
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
76585
76750
|
}))
|
|
76586
76751
|
};
|
|
76587
|
-
}).onRequest(
|
|
76752
|
+
}).onRequest(methods4.agent.session.close, async () => {
|
|
76588
76753
|
await this.#sessionAgent.cancel();
|
|
76589
|
-
}).onNotification(
|
|
76754
|
+
}).onNotification(methods4.agent.session.cancel, async () => {
|
|
76590
76755
|
await this.#sessionAgent.cancel();
|
|
76591
76756
|
});
|
|
76592
76757
|
}
|
|
@@ -76705,17 +76870,39 @@ var init_agent = __esm({
|
|
|
76705
76870
|
}
|
|
76706
76871
|
});
|
|
76707
76872
|
|
|
76873
|
+
// src/acp/adapter/codex/agent-connection.ts
|
|
76874
|
+
var CodexAgentConnection;
|
|
76875
|
+
var init_agent_connection2 = __esm({
|
|
76876
|
+
"src/acp/adapter/codex/agent-connection.ts"() {
|
|
76877
|
+
"use strict";
|
|
76878
|
+
init_endpoint_agent_connection();
|
|
76879
|
+
init_agent();
|
|
76880
|
+
CodexAgentConnection = class extends EndpointAgentConnection {
|
|
76881
|
+
constructor(options) {
|
|
76882
|
+
const endpoint = new CodexAcpAgent({
|
|
76883
|
+
command: options.command,
|
|
76884
|
+
cwd: options.cwd,
|
|
76885
|
+
environment: options.environment,
|
|
76886
|
+
onSessionUpdate: options.client.onUpdate,
|
|
76887
|
+
onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
|
|
76888
|
+
});
|
|
76889
|
+
super(endpoint, options.client);
|
|
76890
|
+
}
|
|
76891
|
+
};
|
|
76892
|
+
}
|
|
76893
|
+
});
|
|
76894
|
+
|
|
76708
76895
|
// src/agent/specification/vendors/codex-agent.ts
|
|
76709
76896
|
var CodexAgentSpecification;
|
|
76710
76897
|
var init_codex_agent = __esm({
|
|
76711
76898
|
"src/agent/specification/vendors/codex-agent.ts"() {
|
|
76712
76899
|
"use strict";
|
|
76713
|
-
|
|
76900
|
+
init_agent_connection2();
|
|
76714
76901
|
init_agent_specification();
|
|
76715
76902
|
CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
76716
76903
|
versionProbeTimeoutMilliseconds = 1e4;
|
|
76717
76904
|
agentExecutable = "codex";
|
|
76718
|
-
|
|
76905
|
+
createConnection = (options) => new CodexAgentConnection(options);
|
|
76719
76906
|
id = "codex";
|
|
76720
76907
|
label = "Codex";
|
|
76721
76908
|
minimumSupportedAgentVersion = "0.153.0";
|
|
@@ -77171,7 +77358,7 @@ var init_auth = __esm({
|
|
|
77171
77358
|
});
|
|
77172
77359
|
|
|
77173
77360
|
// src/acp/harness/pi/upstream/dist/acp/auth-required.js
|
|
77174
|
-
import { RequestError as
|
|
77361
|
+
import { RequestError as RequestError5 } from "@agentclientprotocol/sdk";
|
|
77175
77362
|
function maybeAuthRequiredError(err) {
|
|
77176
77363
|
const msg = String(err?.message ?? err ?? "");
|
|
77177
77364
|
const s = msg.toLowerCase();
|
|
@@ -77192,7 +77379,7 @@ function maybeAuthRequiredError(err) {
|
|
|
77192
77379
|
if (!hit) {
|
|
77193
77380
|
return null;
|
|
77194
77381
|
}
|
|
77195
|
-
return
|
|
77382
|
+
return RequestError5.authRequired({
|
|
77196
77383
|
authMethods: getAuthMethods()
|
|
77197
77384
|
}, "Configure an API key or log in with an OAuth provider.");
|
|
77198
77385
|
}
|
|
@@ -77680,7 +77867,7 @@ var init_pi_settings = __esm({
|
|
|
77680
77867
|
});
|
|
77681
77868
|
|
|
77682
77869
|
// src/acp/harness/pi/upstream/dist/acp/extension-questions.js
|
|
77683
|
-
import { RequestError as
|
|
77870
|
+
import { RequestError as RequestError6 } from "@agentclientprotocol/sdk";
|
|
77684
77871
|
function questionField(question) {
|
|
77685
77872
|
const title2 = question.title || "Answer";
|
|
77686
77873
|
switch (question.method) {
|
|
@@ -77728,7 +77915,7 @@ var init_extension_questions = __esm({
|
|
|
77728
77915
|
external_exports.object({ ...questionBase, method: external_exports.literal("editor"), prefill: external_exports.string().max(1e4).optional() })
|
|
77729
77916
|
]).readonly();
|
|
77730
77917
|
QUESTION_TIMEOUT_MS = 36e5;
|
|
77731
|
-
PiQuestionError = class extends
|
|
77918
|
+
PiQuestionError = class extends RequestError6 {
|
|
77732
77919
|
constructor(kind, cause) {
|
|
77733
77920
|
const messages = {
|
|
77734
77921
|
request_failed: "Pi could not request an answer.",
|
|
@@ -77840,7 +78027,7 @@ var init_extension_questions = __esm({
|
|
|
77840
78027
|
throw new PiQuestionError("invalid_response");
|
|
77841
78028
|
}
|
|
77842
78029
|
} catch (cause) {
|
|
77843
|
-
if (!signal.aborted && !(cause instanceof
|
|
78030
|
+
if (!signal.aborted && !(cause instanceof RequestError6 && cause.code === -32800)) {
|
|
77844
78031
|
turn.controller.abort(cause instanceof PiQuestionError ? cause : new PiQuestionError("request_failed", cause));
|
|
77845
78032
|
}
|
|
77846
78033
|
} finally {
|
|
@@ -78148,7 +78335,7 @@ var init_pi_tools = __esm({
|
|
|
78148
78335
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
78149
78336
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
78150
78337
|
import { isAbsolute as isAbsolute11, resolve as resolvePath } from "node:path";
|
|
78151
|
-
import { RequestError as
|
|
78338
|
+
import { RequestError as RequestError7 } from "@agentclientprotocol/sdk";
|
|
78152
78339
|
function toUsageUpdate(stats) {
|
|
78153
78340
|
const used = stats?.contextUsage?.tokens;
|
|
78154
78341
|
const size = stats?.contextUsage?.contextWindow;
|
|
@@ -78322,7 +78509,7 @@ var init_session = __esm({
|
|
|
78322
78509
|
});
|
|
78323
78510
|
} catch (e) {
|
|
78324
78511
|
if (e instanceof PiRpcSpawnError) {
|
|
78325
|
-
throw
|
|
78512
|
+
throw RequestError7.internalError({ code: e.code }, e.message);
|
|
78326
78513
|
}
|
|
78327
78514
|
throw e;
|
|
78328
78515
|
}
|
|
@@ -78351,7 +78538,7 @@ var init_session = __esm({
|
|
|
78351
78538
|
get(sessionId) {
|
|
78352
78539
|
const s = this.sessions.get(sessionId);
|
|
78353
78540
|
if (!s) {
|
|
78354
|
-
throw
|
|
78541
|
+
throw RequestError7.invalidParams(`Unknown sessionId: ${sessionId}`);
|
|
78355
78542
|
}
|
|
78356
78543
|
return s;
|
|
78357
78544
|
}
|
|
@@ -78448,8 +78635,8 @@ var init_session = __esm({
|
|
|
78448
78635
|
if (cause instanceof PiRpcProcessError) {
|
|
78449
78636
|
const pending = this.pendingTurn;
|
|
78450
78637
|
const reason = pending?.questionSignal.reason;
|
|
78451
|
-
const error62 = reason instanceof
|
|
78452
|
-
if (!(reason instanceof
|
|
78638
|
+
const error62 = reason instanceof RequestError7 ? reason : RequestError7.internalError({ code: cause.code, details: cause.message });
|
|
78639
|
+
if (!(reason instanceof RequestError7)) {
|
|
78453
78640
|
error62.cause = cause;
|
|
78454
78641
|
}
|
|
78455
78642
|
this.extensionQuestions.endTurn(error62);
|
|
@@ -78517,12 +78704,12 @@ var init_session = __esm({
|
|
|
78517
78704
|
const signal = this.extensionQuestions.startTurn();
|
|
78518
78705
|
try {
|
|
78519
78706
|
const result = await this.proc.compact(customInstructions, { signal, timeoutMs });
|
|
78520
|
-
if (signal.aborted && signal.reason instanceof
|
|
78707
|
+
if (signal.aborted && signal.reason instanceof RequestError7) {
|
|
78521
78708
|
throw signal.reason;
|
|
78522
78709
|
}
|
|
78523
78710
|
return result;
|
|
78524
78711
|
} catch (cause) {
|
|
78525
|
-
if (signal.aborted && signal.reason instanceof
|
|
78712
|
+
if (signal.aborted && signal.reason instanceof RequestError7) {
|
|
78526
78713
|
try {
|
|
78527
78714
|
await this.proc.abort({ signal: this.proc.signal, timeoutMs });
|
|
78528
78715
|
} catch (abortCause) {
|
|
@@ -78615,14 +78802,14 @@ var init_session = __esm({
|
|
|
78615
78802
|
await this.publishContextUsage();
|
|
78616
78803
|
const retryFailure = this.turnRetryFailure;
|
|
78617
78804
|
this.turnRetryFailure = null;
|
|
78618
|
-
if (questionSignal?.aborted && questionSignal.reason instanceof
|
|
78805
|
+
if (questionSignal?.aborted && questionSignal.reason instanceof RequestError7 && !this.cancelRequested) {
|
|
78619
78806
|
this.pendingTurn?.reject(questionSignal.reason);
|
|
78620
78807
|
} else if (retryFailure !== null && !this.cancelRequested) {
|
|
78621
78808
|
this.pendingTurn?.reject(
|
|
78622
78809
|
// The message rides in `data.details` so clients that unwrap the
|
|
78623
78810
|
// JSON-RPC internal-error envelope (like Mobius) surface the real
|
|
78624
78811
|
// model error; `code` keeps the failure machine-readable.
|
|
78625
|
-
|
|
78812
|
+
RequestError7.internalError({
|
|
78626
78813
|
code: "pi_retries_exhausted",
|
|
78627
78814
|
details: `Pi retries exhausted: ${retryFailure}`
|
|
78628
78815
|
})
|
|
@@ -79074,7 +79261,7 @@ import { spawnSync } from "node:child_process";
|
|
|
79074
79261
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
79075
79262
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
79076
79263
|
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute12, join as join20 } from "node:path";
|
|
79077
|
-
import { RequestError as
|
|
79264
|
+
import { RequestError as RequestError8 } from "@agentclientprotocol/sdk";
|
|
79078
79265
|
function thinkingLevelName(id) {
|
|
79079
79266
|
return id.split(/[_-]/u).map((part) => part.length === 0 ? part : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
79080
79267
|
}
|
|
@@ -79278,7 +79465,7 @@ async function setSessionModel(proc, requestedModelId) {
|
|
|
79278
79465
|
}
|
|
79279
79466
|
}
|
|
79280
79467
|
if (!provider || !modelId) {
|
|
79281
|
-
throw
|
|
79468
|
+
throw RequestError8.invalidParams(`Unknown modelId: ${requestedModelId}`);
|
|
79282
79469
|
}
|
|
79283
79470
|
await proc.setModel(provider, modelId);
|
|
79284
79471
|
}
|
|
@@ -79559,7 +79746,7 @@ var init_agent2 = __esm({
|
|
|
79559
79746
|
const restorePromise = (async () => {
|
|
79560
79747
|
const stored = this.findStoredSession(sessionId);
|
|
79561
79748
|
if (!stored) {
|
|
79562
|
-
throw
|
|
79749
|
+
throw RequestError8.invalidParams(`Unknown sessionId: ${sessionId}`);
|
|
79563
79750
|
}
|
|
79564
79751
|
const cwd = opts?.cwd ?? stored.cwd;
|
|
79565
79752
|
let proc;
|
|
@@ -79572,7 +79759,7 @@ var init_agent2 = __esm({
|
|
|
79572
79759
|
});
|
|
79573
79760
|
} catch (e) {
|
|
79574
79761
|
if (e?.name === "PiRpcSpawnError") {
|
|
79575
|
-
throw
|
|
79762
|
+
throw RequestError8.internalError({ code: e?.code }, String(e?.message ?? e));
|
|
79576
79763
|
}
|
|
79577
79764
|
throw e;
|
|
79578
79765
|
}
|
|
@@ -79632,7 +79819,7 @@ var init_agent2 = __esm({
|
|
|
79632
79819
|
}
|
|
79633
79820
|
async newSession(params) {
|
|
79634
79821
|
if (!isAbsolute12(params.cwd)) {
|
|
79635
|
-
throw
|
|
79822
|
+
throw RequestError8.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
79636
79823
|
}
|
|
79637
79824
|
this.lastSessionCwd = params.cwd;
|
|
79638
79825
|
const fileCommands = loadSlashCommands(params.cwd, this.environment);
|
|
@@ -79671,16 +79858,16 @@ var init_agent2 = __esm({
|
|
|
79671
79858
|
}
|
|
79672
79859
|
if (availableModelsErr) {
|
|
79673
79860
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
79674
|
-
throw
|
|
79861
|
+
throw RequestError8.internalError({}, String(availableModelsErr?.message ?? availableModelsErr));
|
|
79675
79862
|
}
|
|
79676
79863
|
const rawModelsCount = Array.isArray(availableModels?.models) ? availableModels.models.length : 0;
|
|
79677
79864
|
if (rawModelsCount === 0) {
|
|
79678
79865
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
79679
|
-
throw
|
|
79866
|
+
throw RequestError8.authRequired({ authMethods: getAuthMethods() }, "Configure an API key or log in with an OAuth provider.");
|
|
79680
79867
|
}
|
|
79681
79868
|
if (stateErr && maybeAuthRequiredError(stateErr)) {
|
|
79682
79869
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
79683
|
-
throw
|
|
79870
|
+
throw RequestError8.authRequired({ authMethods: getAuthMethods() }, "Configure an API key or log in with an OAuth provider.");
|
|
79684
79871
|
}
|
|
79685
79872
|
let configuration;
|
|
79686
79873
|
try {
|
|
@@ -79690,7 +79877,7 @@ var init_agent2 = __esm({
|
|
|
79690
79877
|
configuration = await getSessionConfiguration(session.proc, { state, availableModels });
|
|
79691
79878
|
} catch (err) {
|
|
79692
79879
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
79693
|
-
throw maybeAuthRequiredError(err) ??
|
|
79880
|
+
throw maybeAuthRequiredError(err) ?? RequestError8.internalError({}, String(err?.message ?? err));
|
|
79694
79881
|
}
|
|
79695
79882
|
const { configOptions, models, modes } = configuration;
|
|
79696
79883
|
const quietStartup = getQuietStartup(params.cwd, this.environment);
|
|
@@ -80188,7 +80375,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80188
80375
|
signal.throwIfAborted();
|
|
80189
80376
|
const parsed = steerRequestSchema.safeParse(params);
|
|
80190
80377
|
if (!parsed.success) {
|
|
80191
|
-
throw
|
|
80378
|
+
throw RequestError8.invalidParams("Invalid steering request");
|
|
80192
80379
|
}
|
|
80193
80380
|
const session = this.sessions.maybeGet(parsed.data.sessionId);
|
|
80194
80381
|
if (session === void 0) {
|
|
@@ -80229,11 +80416,11 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80229
80416
|
}
|
|
80230
80417
|
async forkSession(params) {
|
|
80231
80418
|
if (!isAbsolute12(params.cwd)) {
|
|
80232
|
-
throw
|
|
80419
|
+
throw RequestError8.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
80233
80420
|
}
|
|
80234
80421
|
const source = this.findStoredSession(params.sessionId);
|
|
80235
80422
|
if (!source) {
|
|
80236
|
-
throw
|
|
80423
|
+
throw RequestError8.invalidParams(`Unknown sessionId: ${params.sessionId}`);
|
|
80237
80424
|
}
|
|
80238
80425
|
this.lastSessionCwd = params.cwd;
|
|
80239
80426
|
const fileCommands = loadSlashCommands(params.cwd, this.environment);
|
|
@@ -80295,13 +80482,13 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80295
80482
|
}
|
|
80296
80483
|
async resumeSession(params) {
|
|
80297
80484
|
if (!isAbsolute12(params.cwd)) {
|
|
80298
|
-
throw
|
|
80485
|
+
throw RequestError8.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
80299
80486
|
}
|
|
80300
80487
|
this.sessions.close(params.sessionId);
|
|
80301
80488
|
this.lastSessionCwd = params.cwd;
|
|
80302
80489
|
const stored = this.findStoredSession(params.sessionId);
|
|
80303
80490
|
if (!stored) {
|
|
80304
|
-
throw
|
|
80491
|
+
throw RequestError8.invalidParams(`Unknown sessionId: ${params.sessionId}`);
|
|
80305
80492
|
}
|
|
80306
80493
|
const session = await this.restoreSession(params.sessionId, {
|
|
80307
80494
|
cwd: params.cwd,
|
|
@@ -80366,13 +80553,13 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80366
80553
|
}
|
|
80367
80554
|
async loadSession(params) {
|
|
80368
80555
|
if (!isAbsolute12(params.cwd)) {
|
|
80369
|
-
throw
|
|
80556
|
+
throw RequestError8.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
80370
80557
|
}
|
|
80371
80558
|
this.sessions.close(params.sessionId);
|
|
80372
80559
|
this.lastSessionCwd = params.cwd;
|
|
80373
80560
|
const stored = this.findStoredSession(params.sessionId);
|
|
80374
80561
|
if (!stored) {
|
|
80375
|
-
throw
|
|
80562
|
+
throw RequestError8.invalidParams(`Unknown sessionId: ${params.sessionId}`);
|
|
80376
80563
|
}
|
|
80377
80564
|
const enableSkillCommands = getEnableSkillCommands(params.cwd, this.environment);
|
|
80378
80565
|
const session = await this.restoreSession(params.sessionId, {
|
|
@@ -80547,7 +80734,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80547
80734
|
const session = await this.restoreSession(params.sessionId);
|
|
80548
80735
|
const mode = params.modeId;
|
|
80549
80736
|
if (typeof mode !== "string" || mode.length === 0) {
|
|
80550
|
-
throw
|
|
80737
|
+
throw RequestError8.invalidParams("Expected nonempty string modeId");
|
|
80551
80738
|
}
|
|
80552
80739
|
await session.proc.setThinkingLevel(mode);
|
|
80553
80740
|
await emitConfigOptionsUpdate(this.conn, session.sessionId, session.proc);
|
|
@@ -80558,18 +80745,18 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80558
80745
|
const configId = String(params.configId);
|
|
80559
80746
|
let modelChanged = false;
|
|
80560
80747
|
if (typeof params.value !== "string") {
|
|
80561
|
-
throw
|
|
80748
|
+
throw RequestError8.invalidParams(`Expected string value for config option: ${configId}`);
|
|
80562
80749
|
}
|
|
80563
80750
|
if (configId === MODEL_CONFIG_ID2) {
|
|
80564
80751
|
await setSessionModel(session.proc, params.value);
|
|
80565
80752
|
modelChanged = true;
|
|
80566
80753
|
} else if (configId === THOUGHT_LEVEL_CONFIG_ID) {
|
|
80567
80754
|
if (params.value.length === 0) {
|
|
80568
|
-
throw
|
|
80755
|
+
throw RequestError8.invalidParams("Expected nonempty thinking level");
|
|
80569
80756
|
}
|
|
80570
80757
|
await session.proc.setThinkingLevel(params.value);
|
|
80571
80758
|
} else {
|
|
80572
|
-
throw
|
|
80759
|
+
throw RequestError8.invalidParams(`Unknown config option: ${configId}`);
|
|
80573
80760
|
}
|
|
80574
80761
|
const configOptions = await emitConfigOptionsUpdate(this.conn, session.sessionId, session.proc);
|
|
80575
80762
|
if (modelChanged) {
|
|
@@ -80582,11 +80769,11 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80582
80769
|
});
|
|
80583
80770
|
|
|
80584
80771
|
// src/acp/harness/pi/upstream/dist/acp/client.js
|
|
80585
|
-
import { methods as
|
|
80772
|
+
import { methods as methods5 } from "@agentclientprotocol/sdk";
|
|
80586
80773
|
function createPiAcpClient(connection, onSessionUpdate) {
|
|
80587
80774
|
return {
|
|
80588
|
-
requestElicitation: async (request, signal) => await connection.client.request(
|
|
80589
|
-
requestPermission: async (request) => await connection.client.request(
|
|
80775
|
+
requestElicitation: async (request, signal) => await connection.client.request(methods5.client.elicitation.create, request, { cancellationSignal: signal }),
|
|
80776
|
+
requestPermission: async (request) => await connection.client.request(methods5.client.session.requestPermission, request),
|
|
80590
80777
|
sessionUpdate: onSessionUpdate
|
|
80591
80778
|
};
|
|
80592
80779
|
}
|
|
@@ -80597,7 +80784,7 @@ var init_client = __esm({
|
|
|
80597
80784
|
});
|
|
80598
80785
|
|
|
80599
80786
|
// src/acp/harness/pi/endpoint.ts
|
|
80600
|
-
import { agent as createAgentApp2, methods as
|
|
80787
|
+
import { agent as createAgentApp2, methods as methods6 } from "@agentclientprotocol/sdk";
|
|
80601
80788
|
function piAgentOrThrow(agent) {
|
|
80602
80789
|
if (agent === null) {
|
|
80603
80790
|
throw new Error("The Pi ACP client is not connected");
|
|
@@ -80632,36 +80819,36 @@ var init_endpoint2 = __esm({
|
|
|
80632
80819
|
piAgent = new PiAcpAgent(createPiAcpClient(connection, options.onSessionUpdate), { environment });
|
|
80633
80820
|
this.#agent = piAgent;
|
|
80634
80821
|
}).onRequest(
|
|
80635
|
-
|
|
80822
|
+
methods6.agent.initialize,
|
|
80636
80823
|
async (context) => await piAgentOrThrow(piAgent).initialize(context.params)
|
|
80637
80824
|
).onRequest(
|
|
80638
|
-
|
|
80825
|
+
methods6.agent.authenticate,
|
|
80639
80826
|
async (context) => await piAgentOrThrow(piAgent).authenticate(context.params)
|
|
80640
80827
|
).onRequest(
|
|
80641
|
-
|
|
80828
|
+
methods6.agent.session.new,
|
|
80642
80829
|
async (context) => await piAgentOrThrow(piAgent).newSession(context.params)
|
|
80643
80830
|
).onRequest(
|
|
80644
|
-
|
|
80831
|
+
methods6.agent.session.load,
|
|
80645
80832
|
async (context) => await piAgentOrThrow(piAgent).loadSession(context.params)
|
|
80646
80833
|
).onRequest(
|
|
80647
|
-
|
|
80834
|
+
methods6.agent.session.resume,
|
|
80648
80835
|
async (context) => await piAgentOrThrow(piAgent).resumeSession(context.params)
|
|
80649
80836
|
).onRequest(
|
|
80650
|
-
|
|
80837
|
+
methods6.agent.session.list,
|
|
80651
80838
|
async (context) => await piAgentOrThrow(piAgent).listSessions(context.params)
|
|
80652
80839
|
).onRequest(
|
|
80653
|
-
|
|
80840
|
+
methods6.agent.session.delete,
|
|
80654
80841
|
async (context) => await piAgentOrThrow(piAgent).deleteSession(context.params)
|
|
80655
80842
|
).onRequest(
|
|
80656
|
-
|
|
80843
|
+
methods6.agent.session.fork,
|
|
80657
80844
|
async (context) => await piAgentOrThrow(piAgent).forkSession(context.params)
|
|
80658
80845
|
).onRequest(
|
|
80659
|
-
|
|
80846
|
+
methods6.agent.session.setMode,
|
|
80660
80847
|
async (context) => await piAgentOrThrow(piAgent).setSessionMode(context.params)
|
|
80661
80848
|
).onRequest(
|
|
80662
|
-
|
|
80849
|
+
methods6.agent.session.setConfigOption,
|
|
80663
80850
|
async (context) => await piAgentOrThrow(piAgent).setSessionConfigOption(context.params)
|
|
80664
|
-
).onRequest(
|
|
80851
|
+
).onRequest(methods6.agent.session.prompt, async (context) => {
|
|
80665
80852
|
const agent = piAgentOrThrow(piAgent);
|
|
80666
80853
|
const cancel = () => {
|
|
80667
80854
|
void agent.cancel({ sessionId: context.params.sessionId });
|
|
@@ -80676,7 +80863,7 @@ var init_endpoint2 = __esm({
|
|
|
80676
80863
|
"_session/steering",
|
|
80677
80864
|
(params) => params,
|
|
80678
80865
|
async (context) => await piAgentOrThrow(piAgent).steer(context.params, context.signal)
|
|
80679
|
-
).onNotification(
|
|
80866
|
+
).onNotification(methods6.agent.session.cancel, async (context) => {
|
|
80680
80867
|
await piAgentOrThrow(piAgent).cancel(context.params);
|
|
80681
80868
|
});
|
|
80682
80869
|
}
|
|
@@ -80701,6 +80888,28 @@ var init_endpoint2 = __esm({
|
|
|
80701
80888
|
}
|
|
80702
80889
|
});
|
|
80703
80890
|
|
|
80891
|
+
// src/acp/adapter/pi/agent-connection.ts
|
|
80892
|
+
var PiAgentConnection;
|
|
80893
|
+
var init_agent_connection3 = __esm({
|
|
80894
|
+
"src/acp/adapter/pi/agent-connection.ts"() {
|
|
80895
|
+
"use strict";
|
|
80896
|
+
init_endpoint_agent_connection();
|
|
80897
|
+
init_endpoint2();
|
|
80898
|
+
PiAgentConnection = class extends EndpointAgentConnection {
|
|
80899
|
+
constructor(options) {
|
|
80900
|
+
const endpoint = new PiAcpEndpoint({
|
|
80901
|
+
command: options.command,
|
|
80902
|
+
cwd: options.cwd,
|
|
80903
|
+
environment: options.environment,
|
|
80904
|
+
onSessionUpdate: options.client.onUpdate,
|
|
80905
|
+
onBackgroundActivity: (active) => options.onBackgroundActivity?.(active)
|
|
80906
|
+
});
|
|
80907
|
+
super(endpoint, options.client);
|
|
80908
|
+
}
|
|
80909
|
+
};
|
|
80910
|
+
}
|
|
80911
|
+
});
|
|
80912
|
+
|
|
80704
80913
|
// src/agent/discovery/agent-probe-error.ts
|
|
80705
80914
|
var AgentProbeError;
|
|
80706
80915
|
var init_agent_probe_error = __esm({
|
|
@@ -80721,20 +80930,20 @@ var init_agent_probe_error = __esm({
|
|
|
80721
80930
|
import { createHash as createHash3 } from "node:crypto";
|
|
80722
80931
|
import { join as join21 } from "node:path";
|
|
80723
80932
|
import {
|
|
80724
|
-
methods as
|
|
80933
|
+
methods as methods7
|
|
80725
80934
|
} from "@agentclientprotocol/sdk";
|
|
80726
80935
|
var ACP_PROBE_TIMEOUT_MILLISECONDS2, PiAgentSpecification;
|
|
80727
80936
|
var init_pi_agent = __esm({
|
|
80728
80937
|
"src/agent/specification/vendors/pi-agent.ts"() {
|
|
80729
80938
|
"use strict";
|
|
80730
|
-
|
|
80939
|
+
init_agent_connection3();
|
|
80731
80940
|
init_agent_probe_error();
|
|
80732
80941
|
init_agent_specification();
|
|
80733
80942
|
ACP_PROBE_TIMEOUT_MILLISECONDS2 = 3e4;
|
|
80734
80943
|
PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
80735
80944
|
acpProbeTimeoutMilliseconds = ACP_PROBE_TIMEOUT_MILLISECONDS2;
|
|
80736
80945
|
agentExecutable = "pi";
|
|
80737
|
-
|
|
80946
|
+
createConnection = (options) => new PiAgentConnection(options);
|
|
80738
80947
|
// The Pi ACP fork inlines embedded prompt resources into the turn message, so Mobius
|
|
80739
80948
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
80740
80949
|
createLaunchEnvironment = async (_agent, context) => {
|
|
@@ -80759,7 +80968,7 @@ var init_pi_agent = __esm({
|
|
|
80759
80968
|
throw new AgentProbeError("acp_incompatible", "Pi ACP adapter does not support session recovery");
|
|
80760
80969
|
}
|
|
80761
80970
|
const session = await connection.agent.request(
|
|
80762
|
-
|
|
80971
|
+
methods7.agent.session.new,
|
|
80763
80972
|
{
|
|
80764
80973
|
additionalDirectories: [],
|
|
80765
80974
|
cwd: defaultWorkspace,
|
|
@@ -80771,7 +80980,7 @@ var init_pi_agent = __esm({
|
|
|
80771
80980
|
throw new AgentProbeError("acp_incompatible", "Pi ACP adapter returned an invalid session");
|
|
80772
80981
|
}
|
|
80773
80982
|
const prompt = await connection.agent.request(
|
|
80774
|
-
|
|
80983
|
+
methods7.agent.session.prompt,
|
|
80775
80984
|
{
|
|
80776
80985
|
prompt: [{ text: "/session", type: "text" }],
|
|
80777
80986
|
sessionId: session.sessionId
|
|
@@ -80967,37 +81176,13 @@ var init_local_executable = __esm({
|
|
|
80967
81176
|
}
|
|
80968
81177
|
});
|
|
80969
81178
|
|
|
80970
|
-
// src/util/value-utils.ts
|
|
80971
|
-
function truncate2(value, maximumLength) {
|
|
80972
|
-
return value.length <= maximumLength ? value : `${value.slice(0, Math.max(0, maximumLength - 1))}\u2026`;
|
|
80973
|
-
}
|
|
80974
|
-
function isRecord3(value) {
|
|
80975
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
80976
|
-
}
|
|
80977
|
-
function readString2(value, fallback = "") {
|
|
80978
|
-
return typeof value === "string" ? value : fallback;
|
|
80979
|
-
}
|
|
80980
|
-
function arraysEqual(left, right) {
|
|
80981
|
-
return left.length === right.length && left.every((value, index2) => value === right[index2]);
|
|
80982
|
-
}
|
|
80983
|
-
function recordsEqual(left, right) {
|
|
80984
|
-
const leftEntries = Object.entries(left);
|
|
80985
|
-
const rightEntries = Object.entries(right);
|
|
80986
|
-
return leftEntries.length === rightEntries.length && leftEntries.every(([name2, value]) => right[name2] === value);
|
|
80987
|
-
}
|
|
80988
|
-
var init_value_utils = __esm({
|
|
80989
|
-
"src/util/value-utils.ts"() {
|
|
80990
|
-
"use strict";
|
|
80991
|
-
}
|
|
80992
|
-
});
|
|
80993
|
-
|
|
80994
81179
|
// src/acp/protocol/session-capabilities.ts
|
|
80995
81180
|
function hasTrueChildField(value, childKey, fieldKey) {
|
|
80996
|
-
if (!
|
|
81181
|
+
if (!isRecord(value)) {
|
|
80997
81182
|
return false;
|
|
80998
81183
|
}
|
|
80999
81184
|
const child = Reflect.get(value, childKey);
|
|
81000
|
-
return
|
|
81185
|
+
return isRecord(child) && Reflect.get(child, fieldKey) === true;
|
|
81001
81186
|
}
|
|
81002
81187
|
function unsupportedSessionCapabilities() {
|
|
81003
81188
|
return Object.freeze({
|
|
@@ -81037,11 +81222,11 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
81037
81222
|
});
|
|
81038
81223
|
}
|
|
81039
81224
|
function restrictAcpSessionCapabilities(capabilities, response) {
|
|
81040
|
-
if (!
|
|
81225
|
+
if (!isRecord(response) || !isRecord(response["_meta"])) {
|
|
81041
81226
|
return capabilities;
|
|
81042
81227
|
}
|
|
81043
81228
|
const steering = response["_meta"]["steering"];
|
|
81044
|
-
if (!
|
|
81229
|
+
if (!isRecord(steering) || steering["supported"] !== false) {
|
|
81045
81230
|
return capabilities;
|
|
81046
81231
|
}
|
|
81047
81232
|
return Object.freeze({ ...capabilities, steering: false });
|
|
@@ -81054,178 +81239,89 @@ var init_session_capabilities = __esm({
|
|
|
81054
81239
|
});
|
|
81055
81240
|
|
|
81056
81241
|
// src/acp/agent/agent-definition.ts
|
|
81057
|
-
var
|
|
81242
|
+
var AcpAgentDefinition;
|
|
81058
81243
|
var init_agent_definition = __esm({
|
|
81059
81244
|
"src/acp/agent/agent-definition.ts"() {
|
|
81060
81245
|
"use strict";
|
|
81061
81246
|
init_local_executable();
|
|
81062
81247
|
init_session_capabilities();
|
|
81063
|
-
|
|
81248
|
+
AcpAgentDefinition = class _AcpAgentDefinition {
|
|
81064
81249
|
agentIdentity;
|
|
81065
81250
|
agentVersion;
|
|
81251
|
+
adapterVersion;
|
|
81066
81252
|
capabilities;
|
|
81067
81253
|
command;
|
|
81068
81254
|
environment;
|
|
81069
81255
|
id;
|
|
81070
81256
|
label;
|
|
81071
|
-
|
|
81257
|
+
runtimeExecutables;
|
|
81258
|
+
#connectionFactory;
|
|
81259
|
+
constructor(id, label, command, createConnection2, environment = {}, agentVersion = "", agentIdentity = readExecutableIdentity(command), capabilities = unsupportedSessionCapabilities(), adapterVersion = agentVersion, runtimeExecutables = [agentIdentity]) {
|
|
81072
81260
|
this.agentIdentity = agentIdentity;
|
|
81073
81261
|
this.agentVersion = agentVersion;
|
|
81262
|
+
this.adapterVersion = adapterVersion;
|
|
81074
81263
|
this.capabilities = Object.freeze({ ...capabilities });
|
|
81075
81264
|
this.command = agentIdentity.realPath;
|
|
81076
81265
|
this.environment = Object.freeze({ ...environment });
|
|
81077
81266
|
this.id = id;
|
|
81078
81267
|
this.label = label;
|
|
81268
|
+
this.runtimeExecutables = Object.freeze([.../* @__PURE__ */ new Set([agentIdentity, ...runtimeExecutables])]);
|
|
81269
|
+
this.#connectionFactory = createConnection2;
|
|
81079
81270
|
}
|
|
81080
|
-
|
|
81081
|
-
|
|
81082
|
-
kind = "acp-adapter-process";
|
|
81083
|
-
adapterIdentity;
|
|
81084
|
-
adapterPath;
|
|
81085
|
-
adapterVersion;
|
|
81086
|
-
arguments;
|
|
81087
|
-
constructor(id, label, command, arguments_, environment = {}, adapterVersion = "", agentVersion = "", adapterIdentity = readExecutableIdentity(command), agentIdentity = adapterIdentity, capabilities = unsupportedSessionCapabilities()) {
|
|
81088
|
-
super(id, label, command, environment, agentVersion, agentIdentity, capabilities);
|
|
81089
|
-
this.adapterIdentity = adapterIdentity;
|
|
81090
|
-
this.adapterPath = adapterIdentity.realPath;
|
|
81091
|
-
this.adapterVersion = adapterVersion;
|
|
81092
|
-
this.arguments = Object.freeze([...arguments_]);
|
|
81093
|
-
}
|
|
81094
|
-
withEnvironment = (environment) => new _LocalAgentDefinition(
|
|
81095
|
-
this.id,
|
|
81096
|
-
this.label,
|
|
81097
|
-
this.command,
|
|
81098
|
-
this.arguments,
|
|
81099
|
-
environment,
|
|
81100
|
-
this.adapterVersion,
|
|
81101
|
-
this.agentVersion,
|
|
81102
|
-
this.adapterIdentity,
|
|
81103
|
-
this.agentIdentity,
|
|
81104
|
-
this.capabilities
|
|
81105
|
-
);
|
|
81106
|
-
};
|
|
81107
|
-
InProcessAcpAgentDefinition = class _InProcessAcpAgentDefinition extends AgentDefinition {
|
|
81108
|
-
kind = "in-process-acp";
|
|
81109
|
-
createEndpoint;
|
|
81110
|
-
constructor(id, label, command, createEndpoint, environment = {}, agentVersion = "", agentIdentity = readExecutableIdentity(command), capabilities = unsupportedSessionCapabilities()) {
|
|
81111
|
-
super(id, label, command, environment, agentVersion, agentIdentity, capabilities);
|
|
81112
|
-
this.createEndpoint = createEndpoint;
|
|
81113
|
-
}
|
|
81114
|
-
withEnvironment = (environment) => new _InProcessAcpAgentDefinition(
|
|
81271
|
+
createConnection = (options) => this.#connectionFactory({ ...options, command: this.command, environment: this.environment });
|
|
81272
|
+
withEnvironment = (environment) => new _AcpAgentDefinition(
|
|
81115
81273
|
this.id,
|
|
81116
81274
|
this.label,
|
|
81117
81275
|
this.command,
|
|
81118
|
-
this
|
|
81276
|
+
this.#connectionFactory,
|
|
81119
81277
|
environment,
|
|
81120
81278
|
this.agentVersion,
|
|
81121
81279
|
this.agentIdentity,
|
|
81122
|
-
this.capabilities
|
|
81280
|
+
this.capabilities,
|
|
81281
|
+
this.adapterVersion,
|
|
81282
|
+
this.runtimeExecutables
|
|
81123
81283
|
);
|
|
81124
81284
|
};
|
|
81125
81285
|
}
|
|
81126
81286
|
});
|
|
81127
81287
|
|
|
81128
|
-
// src/acp/connection/create-client.ts
|
|
81129
|
-
import {
|
|
81130
|
-
client,
|
|
81131
|
-
methods as methods7
|
|
81132
|
-
} from "@agentclientprotocol/sdk";
|
|
81133
|
-
var createAcpClient;
|
|
81134
|
-
var init_create_client = __esm({
|
|
81135
|
-
"src/acp/connection/create-client.ts"() {
|
|
81136
|
-
"use strict";
|
|
81137
|
-
createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
81138
|
-
methods7.client.session.requestPermission,
|
|
81139
|
-
async (context) => await handler.onPermission(context.params, context.signal)
|
|
81140
|
-
).onRequest(
|
|
81141
|
-
methods7.client.elicitation.create,
|
|
81142
|
-
async (context) => await handler.onElicitation(context.params, context.signal)
|
|
81143
|
-
).onNotification(methods7.client.session.update, async (context) => {
|
|
81144
|
-
await handler.onUpdate(context.params);
|
|
81145
|
-
}).onNotification(methods7.client.elicitation.complete, async (context) => {
|
|
81146
|
-
await handler.onElicitationComplete(context.params);
|
|
81147
|
-
});
|
|
81148
|
-
}
|
|
81149
|
-
});
|
|
81150
|
-
|
|
81151
81288
|
// src/agent/discovery/acp-readiness-probe.ts
|
|
81152
|
-
import { spawn as spawn6 } from "node:child_process";
|
|
81153
81289
|
import {
|
|
81154
81290
|
methods as methods8,
|
|
81155
|
-
|
|
81156
|
-
PROTOCOL_VERSION as PROTOCOL_VERSION2,
|
|
81157
|
-
RequestError as RequestError8
|
|
81291
|
+
PROTOCOL_VERSION as PROTOCOL_VERSION2
|
|
81158
81292
|
} from "@agentclientprotocol/sdk";
|
|
81159
|
-
function
|
|
81160
|
-
|
|
81161
|
-
|
|
81162
|
-
|
|
81163
|
-
|
|
81164
|
-
input2.on("data", (chunk) => {
|
|
81165
|
-
if (!open7) {
|
|
81166
|
-
return;
|
|
81167
|
-
}
|
|
81168
|
-
if (!(chunk instanceof Uint8Array)) {
|
|
81169
|
-
open7 = false;
|
|
81170
|
-
controller.error(new Error("ACP adapter produced invalid output"));
|
|
81171
|
-
return;
|
|
81172
|
-
}
|
|
81173
|
-
byteLength += chunk.byteLength;
|
|
81174
|
-
if (byteLength > ACP_OUTPUT_LIMIT_BYTES) {
|
|
81175
|
-
open7 = false;
|
|
81176
|
-
controller.error(new Error("ACP adapter output limit exceeded"));
|
|
81177
|
-
return;
|
|
81178
|
-
}
|
|
81179
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
81180
|
-
});
|
|
81181
|
-
input2.once("end", () => {
|
|
81182
|
-
if (open7) {
|
|
81183
|
-
open7 = false;
|
|
81184
|
-
controller.close();
|
|
81185
|
-
}
|
|
81186
|
-
});
|
|
81187
|
-
input2.once("error", (error62) => {
|
|
81188
|
-
if (open7) {
|
|
81189
|
-
open7 = false;
|
|
81190
|
-
controller.error(error62);
|
|
81191
|
-
}
|
|
81192
|
-
});
|
|
81193
|
-
},
|
|
81194
|
-
cancel() {
|
|
81195
|
-
open7 = false;
|
|
81196
|
-
}
|
|
81197
|
-
});
|
|
81198
|
-
}
|
|
81199
|
-
function writableAcpStream(output2) {
|
|
81200
|
-
return new WritableStream({
|
|
81201
|
-
write(chunk) {
|
|
81202
|
-
return new Promise((resolveWrite, rejectWrite) => {
|
|
81203
|
-
output2.write(chunk, (error62) => {
|
|
81204
|
-
if (error62) {
|
|
81205
|
-
rejectWrite(error62);
|
|
81206
|
-
return;
|
|
81207
|
-
}
|
|
81208
|
-
resolveWrite();
|
|
81209
|
-
});
|
|
81210
|
-
});
|
|
81293
|
+
function filterEnvironment(environment) {
|
|
81294
|
+
const filtered = {};
|
|
81295
|
+
for (const [name2, value] of Object.entries(environment)) {
|
|
81296
|
+
if (typeof value === "string") {
|
|
81297
|
+
filtered[name2] = value;
|
|
81211
81298
|
}
|
|
81212
|
-
}
|
|
81299
|
+
}
|
|
81300
|
+
return filtered;
|
|
81213
81301
|
}
|
|
81214
|
-
async function
|
|
81215
|
-
|
|
81216
|
-
const
|
|
81217
|
-
|
|
81218
|
-
|
|
81219
|
-
|
|
81220
|
-
|
|
81221
|
-
});
|
|
81302
|
+
async function probeAcpReadiness(specification, agent, environment, defaultWorkspace, signal) {
|
|
81303
|
+
signal.throwIfAborted();
|
|
81304
|
+
const controller = new AbortController();
|
|
81305
|
+
let timedOut = false;
|
|
81306
|
+
const timeout = setTimeout(() => {
|
|
81307
|
+
timedOut = true;
|
|
81308
|
+
controller.abort(new Error("ACP probe timed out"));
|
|
81309
|
+
}, specification.acpProbeTimeoutMilliseconds);
|
|
81310
|
+
const abort = () => controller.abort(signal.reason);
|
|
81311
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
81312
|
+
if (signal.aborted) {
|
|
81313
|
+
abort();
|
|
81314
|
+
}
|
|
81222
81315
|
try {
|
|
81223
|
-
const
|
|
81316
|
+
const runtime = agent.withEnvironment({ ...filterEnvironment(environment), ...agent.environment }).createConnection({
|
|
81317
|
+
cwd: defaultWorkspace,
|
|
81318
|
+
client: new DiscoveryAcpHandler()
|
|
81319
|
+
});
|
|
81224
81320
|
try {
|
|
81225
|
-
return await
|
|
81321
|
+
return await runtime.race(
|
|
81226
81322
|
(async () => {
|
|
81227
|
-
await
|
|
81228
|
-
const initialized = await connection.agent.request(
|
|
81323
|
+
await runtime.initialize(controller.signal);
|
|
81324
|
+
const initialized = await runtime.connection.agent.request(
|
|
81229
81325
|
methods8.agent.initialize,
|
|
81230
81326
|
{
|
|
81231
81327
|
clientCapabilities: {},
|
|
@@ -81240,161 +81336,43 @@ async function probeInProcessReadiness(specification, agent, environment, defaul
|
|
|
81240
81336
|
"ACP agent selected an unsupported protocol version"
|
|
81241
81337
|
);
|
|
81242
81338
|
}
|
|
81243
|
-
await specification.verifyAcp(connection, initialized, defaultWorkspace, controller.signal);
|
|
81339
|
+
await specification.verifyAcp(runtime.connection, initialized, defaultWorkspace, controller.signal);
|
|
81244
81340
|
return new VerifiedAcpReadiness(
|
|
81245
81341
|
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
81246
81342
|
normalizeAcpCapabilities(initialized)
|
|
81247
81343
|
);
|
|
81248
81344
|
})(),
|
|
81249
|
-
|
|
81250
|
-
|
|
81251
|
-
|
|
81252
|
-
});
|
|
81253
|
-
})
|
|
81254
|
-
]);
|
|
81255
|
-
} finally {
|
|
81256
|
-
connection.close();
|
|
81257
|
-
}
|
|
81258
|
-
} finally {
|
|
81259
|
-
await inProcess.close();
|
|
81260
|
-
}
|
|
81261
|
-
}
|
|
81262
|
-
function filterEnvironment(environment) {
|
|
81263
|
-
const filtered = {};
|
|
81264
|
-
for (const [name2, value] of Object.entries(environment)) {
|
|
81265
|
-
if (typeof value === "string") {
|
|
81266
|
-
filtered[name2] = value;
|
|
81267
|
-
}
|
|
81268
|
-
}
|
|
81269
|
-
return filtered;
|
|
81270
|
-
}
|
|
81271
|
-
async function probeAcpReadiness(specification, agent, environment, defaultWorkspace, signal) {
|
|
81272
|
-
signal.throwIfAborted();
|
|
81273
|
-
const controller = new AbortController();
|
|
81274
|
-
let timedOut = false;
|
|
81275
|
-
const timeout = setTimeout(() => {
|
|
81276
|
-
timedOut = true;
|
|
81277
|
-
controller.abort(new Error("ACP probe timed out"));
|
|
81278
|
-
}, specification.acpProbeTimeoutMilliseconds);
|
|
81279
|
-
const abort = () => controller.abort(signal.reason);
|
|
81280
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
81281
|
-
if (signal.aborted) {
|
|
81282
|
-
abort();
|
|
81283
|
-
}
|
|
81284
|
-
if (agent.kind === "in-process-acp") {
|
|
81285
|
-
try {
|
|
81286
|
-
return await probeInProcessReadiness(specification, agent, environment, defaultWorkspace, controller);
|
|
81287
|
-
} catch (error62) {
|
|
81288
|
-
if (signal.aborted) {
|
|
81289
|
-
signal.throwIfAborted();
|
|
81290
|
-
}
|
|
81291
|
-
if (timedOut) {
|
|
81292
|
-
throw new AgentProbeError("adapter_probe_timeout", "ACP agent probe timed out", { cause: error62 });
|
|
81293
|
-
}
|
|
81294
|
-
if (error62 instanceof AgentProbeError) {
|
|
81295
|
-
throw error62;
|
|
81296
|
-
}
|
|
81297
|
-
if (error62 instanceof RequestError8 && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
|
|
81298
|
-
throw new AgentProbeError("authentication_required", "Agent authentication is required", {
|
|
81299
|
-
cause: error62
|
|
81300
|
-
});
|
|
81301
|
-
}
|
|
81302
|
-
throw new AgentProbeError("acp_incompatible", "ACP agent initialization failed", { cause: error62 });
|
|
81345
|
+
"The ACP endpoint stopped during initialization",
|
|
81346
|
+
controller.signal
|
|
81347
|
+
);
|
|
81303
81348
|
} finally {
|
|
81304
|
-
|
|
81305
|
-
signal.removeEventListener("abort", abort);
|
|
81306
|
-
}
|
|
81307
|
-
}
|
|
81308
|
-
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
81309
|
-
const child = spawn6(launch.command, [...launch.arguments], {
|
|
81310
|
-
cwd: defaultWorkspace,
|
|
81311
|
-
...platformSpawnOptions,
|
|
81312
|
-
env: { ...environment, ...agent.environment },
|
|
81313
|
-
shell: false,
|
|
81314
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
81315
|
-
});
|
|
81316
|
-
const processExit = new Promise((_resolve, reject2) => {
|
|
81317
|
-
const rejectExit = () => reject2(new Error("ACP adapter exited during initialization"));
|
|
81318
|
-
child.once("error", reject2);
|
|
81319
|
-
child.once("exit", rejectExit);
|
|
81320
|
-
if (child.exitCode !== null || child.signalCode !== null) {
|
|
81321
|
-
rejectExit();
|
|
81322
|
-
}
|
|
81323
|
-
});
|
|
81324
|
-
const stdin = child.stdin;
|
|
81325
|
-
const stdout = child.stdout;
|
|
81326
|
-
const stderr = child.stderr;
|
|
81327
|
-
if (stdin === null || stdout === null || stderr === null) {
|
|
81328
|
-
await stopProcessTree(child);
|
|
81329
|
-
throw new AgentProbeError("acp_incompatible", "ACP adapter streams are unavailable");
|
|
81330
|
-
}
|
|
81331
|
-
let stderrBytes = 0;
|
|
81332
|
-
const consumeStderr = (chunk) => {
|
|
81333
|
-
stderrBytes += chunk.byteLength;
|
|
81334
|
-
if (stderrBytes > ACP_OUTPUT_LIMIT_BYTES) {
|
|
81335
|
-
controller.abort(new Error("ACP adapter output limit exceeded"));
|
|
81336
|
-
}
|
|
81337
|
-
};
|
|
81338
|
-
stderr.on("data", consumeStderr);
|
|
81339
|
-
const connection = createAcpClient(new DiscoveryAcpHandler()).connect(
|
|
81340
|
-
ndJsonStream2(writableAcpStream(stdin), readableAcpStream(stdout))
|
|
81341
|
-
);
|
|
81342
|
-
try {
|
|
81343
|
-
const initialized = await Promise.race([
|
|
81344
|
-
connection.agent.request(
|
|
81345
|
-
methods8.agent.initialize,
|
|
81346
|
-
{
|
|
81347
|
-
clientCapabilities: {},
|
|
81348
|
-
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
81349
|
-
protocolVersion: PROTOCOL_VERSION2
|
|
81350
|
-
},
|
|
81351
|
-
{ cancellationSignal: controller.signal }
|
|
81352
|
-
),
|
|
81353
|
-
processExit
|
|
81354
|
-
]);
|
|
81355
|
-
if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
|
|
81356
|
-
throw new AgentProbeError("acp_incompatible", "ACP adapter selected an unsupported protocol version");
|
|
81349
|
+
await runtime.closeProcess();
|
|
81357
81350
|
}
|
|
81358
|
-
await specification.verifyAcp(connection, initialized, defaultWorkspace, controller.signal);
|
|
81359
|
-
return new VerifiedAcpReadiness(
|
|
81360
|
-
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
81361
|
-
normalizeAcpCapabilities(initialized)
|
|
81362
|
-
);
|
|
81363
81351
|
} catch (error62) {
|
|
81364
|
-
|
|
81365
|
-
signal.throwIfAborted();
|
|
81366
|
-
}
|
|
81352
|
+
signal.throwIfAborted();
|
|
81367
81353
|
if (timedOut) {
|
|
81368
|
-
throw new AgentProbeError("adapter_probe_timeout", "ACP
|
|
81354
|
+
throw new AgentProbeError("adapter_probe_timeout", "ACP agent probe timed out", { cause: error62 });
|
|
81369
81355
|
}
|
|
81370
81356
|
if (error62 instanceof AgentProbeError) {
|
|
81371
81357
|
throw error62;
|
|
81372
81358
|
}
|
|
81373
|
-
if (error62 instanceof
|
|
81359
|
+
if (error62 instanceof AcpExecutionError && error62.code === "authentication_required" && specification.authenticationCommand().length > 0) {
|
|
81374
81360
|
throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error62 });
|
|
81375
81361
|
}
|
|
81376
|
-
throw new AgentProbeError("acp_incompatible", "ACP
|
|
81362
|
+
throw new AgentProbeError("acp_incompatible", "ACP agent initialization failed", { cause: error62 });
|
|
81377
81363
|
} finally {
|
|
81378
81364
|
clearTimeout(timeout);
|
|
81379
81365
|
signal.removeEventListener("abort", abort);
|
|
81380
|
-
const capturedProcesses = await captureProcessTree(child);
|
|
81381
|
-
connection.close();
|
|
81382
|
-
stdin.end();
|
|
81383
|
-
stderr.removeListener("data", consumeStderr);
|
|
81384
|
-
await stopProcessTree(child, capturedProcesses);
|
|
81385
81366
|
}
|
|
81386
81367
|
}
|
|
81387
|
-
var
|
|
81368
|
+
var VerifiedAcpReadiness, DiscoveryAcpHandler;
|
|
81388
81369
|
var init_acp_readiness_probe = __esm({
|
|
81389
81370
|
"src/agent/discovery/acp-readiness-probe.ts"() {
|
|
81390
81371
|
"use strict";
|
|
81391
|
-
|
|
81392
|
-
init_create_client();
|
|
81372
|
+
init_acp_error();
|
|
81393
81373
|
init_session_capabilities();
|
|
81394
|
-
init_executable();
|
|
81395
81374
|
init_agent_probe_error();
|
|
81396
81375
|
init_version_output();
|
|
81397
|
-
ACP_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
81398
81376
|
VerifiedAcpReadiness = class {
|
|
81399
81377
|
adapterVersion;
|
|
81400
81378
|
capabilities;
|
|
@@ -81508,10 +81486,7 @@ async function resolveAgentExecutables(specification, context) {
|
|
|
81508
81486
|
);
|
|
81509
81487
|
}
|
|
81510
81488
|
async function resolveAdapterExecutables(specification, context) {
|
|
81511
|
-
|
|
81512
|
-
return await resolveAgentExecutables(specification, context);
|
|
81513
|
-
}
|
|
81514
|
-
throw new Error("Unsupported local Agent execution topology");
|
|
81489
|
+
return await resolveAgentExecutables(specification, context);
|
|
81515
81490
|
}
|
|
81516
81491
|
async function probeVersion(executable, arguments_, environment, defaultWorkspace, signal, timeoutMilliseconds, normalize4 = normalizeVersionOutput) {
|
|
81517
81492
|
const result = await runBoundedProcess({
|
|
@@ -81532,7 +81507,6 @@ var init_executable_discovery = __esm({
|
|
|
81532
81507
|
"src/agent/discovery/executable-discovery.ts"() {
|
|
81533
81508
|
"use strict";
|
|
81534
81509
|
init_executable();
|
|
81535
|
-
init_agent_specification();
|
|
81536
81510
|
init_version_output();
|
|
81537
81511
|
}
|
|
81538
81512
|
});
|
|
@@ -81633,7 +81607,7 @@ async function discoverAgent(specification, context) {
|
|
|
81633
81607
|
return new MissingAdapter(specification);
|
|
81634
81608
|
}
|
|
81635
81609
|
for (const adapter of adapters) {
|
|
81636
|
-
if (
|
|
81610
|
+
if (adapter.path !== agent.path) {
|
|
81637
81611
|
continue;
|
|
81638
81612
|
}
|
|
81639
81613
|
let adapterVersion = "";
|
|
@@ -81664,26 +81638,16 @@ async function discoverAgent(specification, context) {
|
|
|
81664
81638
|
lastFailure = integrationProbeFailure(specification, error62);
|
|
81665
81639
|
continue;
|
|
81666
81640
|
}
|
|
81667
|
-
const buildDefinition = (verifiedAdapterVersion, capabilities) =>
|
|
81641
|
+
const buildDefinition = (verifiedAdapterVersion, capabilities) => new AcpAgentDefinition(
|
|
81668
81642
|
specification.id,
|
|
81669
81643
|
specification.label,
|
|
81670
81644
|
agent.path,
|
|
81671
|
-
specification.
|
|
81645
|
+
specification.createConnection,
|
|
81672
81646
|
launchEnvironment,
|
|
81673
81647
|
agentVersion.length > 0 ? agentVersion : verifiedAdapterVersion,
|
|
81674
81648
|
agent.identity,
|
|
81675
|
-
capabilities
|
|
81676
|
-
|
|
81677
|
-
specification.id,
|
|
81678
|
-
specification.label,
|
|
81679
|
-
adapter.path,
|
|
81680
|
-
specification.launchArguments,
|
|
81681
|
-
launchEnvironment,
|
|
81682
|
-
verifiedAdapterVersion,
|
|
81683
|
-
agentVersion,
|
|
81684
|
-
adapter.identity,
|
|
81685
|
-
agent.identity,
|
|
81686
|
-
capabilities
|
|
81649
|
+
capabilities,
|
|
81650
|
+
specification instanceof InProcessAcpAgentSpecification ? agentVersion : verifiedAdapterVersion
|
|
81687
81651
|
);
|
|
81688
81652
|
try {
|
|
81689
81653
|
const readiness = await probeWithRetry(
|
|
@@ -82107,244 +82071,6 @@ var init_session_config_protocol = __esm({
|
|
|
82107
82071
|
}
|
|
82108
82072
|
});
|
|
82109
82073
|
|
|
82110
|
-
// src/acp/connection/agent-connection.ts
|
|
82111
|
-
import { spawn as spawn7 } from "node:child_process";
|
|
82112
|
-
import { ndJsonStream as ndJsonStream3, RequestError as RequestError9 } from "@agentclientprotocol/sdk";
|
|
82113
|
-
function requestErrorMessage(error62) {
|
|
82114
|
-
const fallback = truncate2(error62.message, 500);
|
|
82115
|
-
if (error62.message !== "Internal error" || !isRecord3(error62.data)) {
|
|
82116
|
-
return fallback;
|
|
82117
|
-
}
|
|
82118
|
-
const agentError = error62.data["error"];
|
|
82119
|
-
if (isRecord3(agentError)) {
|
|
82120
|
-
const message = agentError["message"];
|
|
82121
|
-
if (typeof message === "string" && message.length > 0) {
|
|
82122
|
-
return truncate2(message, 500);
|
|
82123
|
-
}
|
|
82124
|
-
}
|
|
82125
|
-
const details = error62.data["details"];
|
|
82126
|
-
return typeof details === "string" && details.length > 0 ? truncate2(details, 500) : fallback;
|
|
82127
|
-
}
|
|
82128
|
-
function readableWebStream(input2) {
|
|
82129
|
-
let streamOpen = true;
|
|
82130
|
-
return new ReadableStream({
|
|
82131
|
-
start(controller) {
|
|
82132
|
-
input2.on("data", (chunk) => {
|
|
82133
|
-
if (!streamOpen) {
|
|
82134
|
-
return;
|
|
82135
|
-
}
|
|
82136
|
-
if (chunk instanceof Uint8Array) {
|
|
82137
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
82138
|
-
return;
|
|
82139
|
-
}
|
|
82140
|
-
streamOpen = false;
|
|
82141
|
-
controller.error(new Error("ACP process produced a non-binary chunk"));
|
|
82142
|
-
});
|
|
82143
|
-
input2.once("end", () => {
|
|
82144
|
-
if (!streamOpen) {
|
|
82145
|
-
return;
|
|
82146
|
-
}
|
|
82147
|
-
streamOpen = false;
|
|
82148
|
-
controller.close();
|
|
82149
|
-
});
|
|
82150
|
-
input2.once("error", (error62) => {
|
|
82151
|
-
if (!streamOpen) {
|
|
82152
|
-
return;
|
|
82153
|
-
}
|
|
82154
|
-
streamOpen = false;
|
|
82155
|
-
controller.error(error62);
|
|
82156
|
-
});
|
|
82157
|
-
},
|
|
82158
|
-
cancel() {
|
|
82159
|
-
streamOpen = false;
|
|
82160
|
-
}
|
|
82161
|
-
});
|
|
82162
|
-
}
|
|
82163
|
-
function createWritableAcpStream(output2) {
|
|
82164
|
-
let outputFailure;
|
|
82165
|
-
const pendingWriteFailures = /* @__PURE__ */ new Set();
|
|
82166
|
-
const fail = (error62) => {
|
|
82167
|
-
outputFailure = error62;
|
|
82168
|
-
for (const reject2 of pendingWriteFailures) {
|
|
82169
|
-
reject2(error62);
|
|
82170
|
-
}
|
|
82171
|
-
pendingWriteFailures.clear();
|
|
82172
|
-
};
|
|
82173
|
-
output2.on("error", fail);
|
|
82174
|
-
output2.once("close", () => {
|
|
82175
|
-
if (outputFailure === void 0) {
|
|
82176
|
-
fail(new Error("ACP process input closed"));
|
|
82177
|
-
}
|
|
82178
|
-
});
|
|
82179
|
-
return new WritableStream({
|
|
82180
|
-
write(chunk) {
|
|
82181
|
-
if (outputFailure !== void 0) {
|
|
82182
|
-
return Promise.reject(outputFailure);
|
|
82183
|
-
}
|
|
82184
|
-
return new Promise((resolve21, reject2) => {
|
|
82185
|
-
pendingWriteFailures.add(reject2);
|
|
82186
|
-
output2.write(chunk, (error62) => {
|
|
82187
|
-
pendingWriteFailures.delete(reject2);
|
|
82188
|
-
if (error62) {
|
|
82189
|
-
outputFailure = error62;
|
|
82190
|
-
reject2(error62);
|
|
82191
|
-
return;
|
|
82192
|
-
}
|
|
82193
|
-
if (outputFailure !== void 0) {
|
|
82194
|
-
reject2(outputFailure);
|
|
82195
|
-
return;
|
|
82196
|
-
}
|
|
82197
|
-
resolve21();
|
|
82198
|
-
});
|
|
82199
|
-
});
|
|
82200
|
-
}
|
|
82201
|
-
});
|
|
82202
|
-
}
|
|
82203
|
-
var AgentConnection;
|
|
82204
|
-
var init_agent_connection = __esm({
|
|
82205
|
-
"src/acp/connection/agent-connection.ts"() {
|
|
82206
|
-
"use strict";
|
|
82207
|
-
init_executable();
|
|
82208
|
-
init_value_utils();
|
|
82209
|
-
init_acp_error();
|
|
82210
|
-
init_in_process_endpoint();
|
|
82211
|
-
init_create_client();
|
|
82212
|
-
AgentConnection = class {
|
|
82213
|
-
connection;
|
|
82214
|
-
termination;
|
|
82215
|
-
#process;
|
|
82216
|
-
constructor(agent, cwd, client2, onBackgroundActivity = () => {
|
|
82217
|
-
}) {
|
|
82218
|
-
if (agent.kind === "in-process-acp") {
|
|
82219
|
-
const inProcess = agent.createEndpoint({
|
|
82220
|
-
command: agent.command,
|
|
82221
|
-
cwd,
|
|
82222
|
-
environment: agent.environment,
|
|
82223
|
-
onSessionUpdate: client2.onUpdate,
|
|
82224
|
-
onBackgroundActivity
|
|
82225
|
-
});
|
|
82226
|
-
this.#process = { kind: "in-process", endpoint: inProcess };
|
|
82227
|
-
this.termination = inProcess.terminated;
|
|
82228
|
-
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
82229
|
-
return;
|
|
82230
|
-
}
|
|
82231
|
-
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
82232
|
-
const child = spawn7(launch.command, [...launch.arguments], {
|
|
82233
|
-
cwd,
|
|
82234
|
-
...platformSpawnOptions,
|
|
82235
|
-
env: { ...process.env, ...agent.environment },
|
|
82236
|
-
shell: false,
|
|
82237
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
82238
|
-
});
|
|
82239
|
-
this.#process = { kind: "child", child };
|
|
82240
|
-
const stdin = child.stdin;
|
|
82241
|
-
const stdout = child.stdout;
|
|
82242
|
-
const stderr = child.stderr;
|
|
82243
|
-
if (stdin === null || stdout === null || stderr === null) {
|
|
82244
|
-
child.kill("SIGKILL");
|
|
82245
|
-
throw new AcpExecutionError("ACP process streams are unavailable");
|
|
82246
|
-
}
|
|
82247
|
-
stderr.setEncoding("utf8");
|
|
82248
|
-
stderr.on("data", (chunk) => {
|
|
82249
|
-
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
82250
|
-
});
|
|
82251
|
-
this.termination = new Promise((resolve21) => {
|
|
82252
|
-
child.once("error", (cause) => {
|
|
82253
|
-
resolve21({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
82254
|
-
});
|
|
82255
|
-
child.once("exit", (code, signal) => {
|
|
82256
|
-
resolve21({
|
|
82257
|
-
kind: "failed",
|
|
82258
|
-
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
82259
|
-
});
|
|
82260
|
-
});
|
|
82261
|
-
});
|
|
82262
|
-
const stream = ndJsonStream3(createWritableAcpStream(stdin), readableWebStream(stdout));
|
|
82263
|
-
let pendingUpdates = 0;
|
|
82264
|
-
this.connection = createAcpClient({
|
|
82265
|
-
onElicitation: client2.onElicitation,
|
|
82266
|
-
onElicitationComplete: client2.onElicitationComplete,
|
|
82267
|
-
onPermission: client2.onPermission,
|
|
82268
|
-
// ACP notifications acknowledge transport writes, not their consumption.
|
|
82269
|
-
// Stop reading the child while updates from the current chunk drain;
|
|
82270
|
-
// the OS pipe then backpressures history replay instead of filling our queue.
|
|
82271
|
-
onUpdate: async (notification) => {
|
|
82272
|
-
pendingUpdates += 1;
|
|
82273
|
-
stdout.pause();
|
|
82274
|
-
try {
|
|
82275
|
-
await client2.onUpdate(notification);
|
|
82276
|
-
} finally {
|
|
82277
|
-
pendingUpdates -= 1;
|
|
82278
|
-
if (pendingUpdates === 0) {
|
|
82279
|
-
stdout.resume();
|
|
82280
|
-
}
|
|
82281
|
-
}
|
|
82282
|
-
}
|
|
82283
|
-
}).connect(stream);
|
|
82284
|
-
}
|
|
82285
|
-
get inProcessAgent() {
|
|
82286
|
-
return this.#process.kind === "in-process" ? this.#process.endpoint : null;
|
|
82287
|
-
}
|
|
82288
|
-
closeProcess = async () => {
|
|
82289
|
-
try {
|
|
82290
|
-
if (this.#process.kind === "in-process") {
|
|
82291
|
-
await this.#process.endpoint.close();
|
|
82292
|
-
return;
|
|
82293
|
-
}
|
|
82294
|
-
await stopProcessTree(this.#process.child);
|
|
82295
|
-
} finally {
|
|
82296
|
-
this.connection.close();
|
|
82297
|
-
}
|
|
82298
|
-
};
|
|
82299
|
-
race = async (operation, exitMessage, signal) => {
|
|
82300
|
-
let removeAbortListener = () => {
|
|
82301
|
-
};
|
|
82302
|
-
const aborted2 = new Promise((_resolve, reject2) => {
|
|
82303
|
-
const rejectAbort = () => {
|
|
82304
|
-
reject2(signal.reason ?? new Error("ACP request was cancelled"));
|
|
82305
|
-
};
|
|
82306
|
-
signal.addEventListener("abort", rejectAbort, { once: true });
|
|
82307
|
-
removeAbortListener = () => {
|
|
82308
|
-
signal.removeEventListener("abort", rejectAbort);
|
|
82309
|
-
};
|
|
82310
|
-
if (signal.aborted) {
|
|
82311
|
-
rejectAbort();
|
|
82312
|
-
}
|
|
82313
|
-
});
|
|
82314
|
-
try {
|
|
82315
|
-
try {
|
|
82316
|
-
return await Promise.race([
|
|
82317
|
-
// The caller has already started operation. Even when cancellation
|
|
82318
|
-
// won before entry, observe its later rejection during endpoint cleanup.
|
|
82319
|
-
aborted2,
|
|
82320
|
-
operation,
|
|
82321
|
-
this.termination.then((termination) => {
|
|
82322
|
-
const cause = acpEndpointTerminationError(termination);
|
|
82323
|
-
throw new AcpExecutionError(exitMessage, { cause }, cause.code);
|
|
82324
|
-
})
|
|
82325
|
-
]);
|
|
82326
|
-
} catch (error62) {
|
|
82327
|
-
signal.throwIfAborted();
|
|
82328
|
-
if (error62 instanceof RequestError9 && error62.code === -32e3) {
|
|
82329
|
-
throw new AcpExecutionError(
|
|
82330
|
-
"Agent authentication is required",
|
|
82331
|
-
{ cause: error62 },
|
|
82332
|
-
"authentication_required"
|
|
82333
|
-
);
|
|
82334
|
-
}
|
|
82335
|
-
if (error62 instanceof RequestError9) {
|
|
82336
|
-
throw new AcpExecutionError(requestErrorMessage(error62), { cause: error62 }, "acp_agent_error");
|
|
82337
|
-
}
|
|
82338
|
-
throw error62;
|
|
82339
|
-
}
|
|
82340
|
-
} finally {
|
|
82341
|
-
removeAbortListener();
|
|
82342
|
-
}
|
|
82343
|
-
};
|
|
82344
|
-
};
|
|
82345
|
-
}
|
|
82346
|
-
});
|
|
82347
|
-
|
|
82348
82074
|
// src/acp/connection/agent-update-stream.ts
|
|
82349
82075
|
import { setImmediate as yieldToRuntime } from "node:timers/promises";
|
|
82350
82076
|
var MAX_PENDING_UPDATES, MAX_PENDING_BYTES, MAX_SELECTED_UPDATES, MAX_SELECTED_BYTES, MAX_RUNTIME_QUEUED_BYTES, UPDATES_PER_YIELD, runtimeQueuedBytes, updatesSinceYield, AgentUpdateStream;
|
|
@@ -82481,7 +82207,6 @@ var init_session_events = __esm({
|
|
|
82481
82207
|
init_protocol();
|
|
82482
82208
|
init_value_utils();
|
|
82483
82209
|
init_acp_error();
|
|
82484
|
-
init_agent_connection();
|
|
82485
82210
|
init_agent_update_stream();
|
|
82486
82211
|
init_session_config_protocol();
|
|
82487
82212
|
MAXIMUM_REASONING_UPDATE_CHARACTERS = 1e6;
|
|
@@ -82525,9 +82250,9 @@ var init_session_events = __esm({
|
|
|
82525
82250
|
kind: "commands",
|
|
82526
82251
|
payload,
|
|
82527
82252
|
commands: update.availableCommands.slice(0, 500).map((command) => ({
|
|
82528
|
-
description:
|
|
82529
|
-
inputHint:
|
|
82530
|
-
name:
|
|
82253
|
+
description: truncate(command.description, 500),
|
|
82254
|
+
inputHint: truncate(command.input?.hint ?? "", 255),
|
|
82255
|
+
name: truncate(command.name, 128)
|
|
82531
82256
|
})).filter((command) => command.name.length > 0)
|
|
82532
82257
|
};
|
|
82533
82258
|
break;
|
|
@@ -82544,10 +82269,10 @@ var init_session_events = __esm({
|
|
|
82544
82269
|
case "session_info_update": {
|
|
82545
82270
|
const changes = [];
|
|
82546
82271
|
if (Object.hasOwn(update, "title")) {
|
|
82547
|
-
changes.push({ kind: "title", value:
|
|
82272
|
+
changes.push({ kind: "title", value: truncate(update.title ?? "", 500) });
|
|
82548
82273
|
}
|
|
82549
82274
|
if (Object.hasOwn(update, "updatedAt")) {
|
|
82550
|
-
changes.push({ kind: "updated-at", value:
|
|
82275
|
+
changes.push({ kind: "updated-at", value: truncate(update.updatedAt ?? "", 128) });
|
|
82551
82276
|
}
|
|
82552
82277
|
event = { kind: "info", payload, changes };
|
|
82553
82278
|
break;
|
|
@@ -82592,21 +82317,23 @@ var init_session_events = __esm({
|
|
|
82592
82317
|
onElicitation: options.interactions.onElicitation,
|
|
82593
82318
|
onElicitationComplete: options.interactions.onElicitationComplete
|
|
82594
82319
|
};
|
|
82595
|
-
this.#connection =
|
|
82596
|
-
|
|
82597
|
-
|
|
82320
|
+
this.#connection = options.agent.createConnection({
|
|
82321
|
+
cwd: options.cwd,
|
|
82322
|
+
client: client2,
|
|
82323
|
+
onBackgroundActivity: (active) => {
|
|
82324
|
+
if (this.#lifetime.signal.aborted) {
|
|
82325
|
+
return;
|
|
82326
|
+
}
|
|
82327
|
+
this.#backgroundActivity = active;
|
|
82328
|
+
this.#onBackgroundActivity(active);
|
|
82598
82329
|
}
|
|
82599
|
-
this.#backgroundActivity = active;
|
|
82600
|
-
this.#onBackgroundActivity(active);
|
|
82601
82330
|
});
|
|
82602
82331
|
}
|
|
82603
82332
|
get connection() {
|
|
82604
82333
|
return this.#connection.connection;
|
|
82605
82334
|
}
|
|
82606
|
-
|
|
82607
|
-
|
|
82608
|
-
}
|
|
82609
|
-
agentSettingsModelEffort = () => this.#connection.inProcessAgent?.agentSettingsModelEffort?.() ?? null;
|
|
82335
|
+
initialize = (signal) => this.#connection.initialize(signal);
|
|
82336
|
+
agentSettingsModelEffort = () => this.#connection.agentSettingsModelEffort();
|
|
82610
82337
|
race = (operation, exitMessage, signal) => this.#connection.race(operation, exitMessage, signal);
|
|
82611
82338
|
closeProcess = async () => {
|
|
82612
82339
|
this.#lifetime.abort(new DOMException("The adapter event subscription closed", "AbortError"));
|
|
@@ -82807,7 +82534,7 @@ var init_live_sessions = __esm({
|
|
|
82807
82534
|
"ACP agent exited during steering",
|
|
82808
82535
|
signal
|
|
82809
82536
|
);
|
|
82810
|
-
if (
|
|
82537
|
+
if (isRecord(response)) {
|
|
82811
82538
|
const outcome = response["outcome"];
|
|
82812
82539
|
if (outcome === "injected" || outcome === "startedNewTurn") {
|
|
82813
82540
|
return outcome;
|
|
@@ -82832,7 +82559,7 @@ var init_live_sessions = __esm({
|
|
|
82832
82559
|
renameSession = async (target, title2, signal) => {
|
|
82833
82560
|
signal.throwIfAborted();
|
|
82834
82561
|
const { connection, scope } = this.#resolve(target);
|
|
82835
|
-
const normalized =
|
|
82562
|
+
const normalized = truncate(title2, 500);
|
|
82836
82563
|
if (normalized.length === 0) {
|
|
82837
82564
|
throw new AcpExecutionError("The Session title cannot be empty", {}, "invalid_session_title");
|
|
82838
82565
|
}
|
|
@@ -83712,10 +83439,7 @@ var init_retained_agent_processes = __esm({
|
|
|
83712
83439
|
import { methods as methods11, PROTOCOL_VERSION as PROTOCOL_VERSION3 } from "@agentclientprotocol/sdk";
|
|
83713
83440
|
async function validateAgentRuntime(agent, signal) {
|
|
83714
83441
|
signal.throwIfAborted();
|
|
83715
|
-
const unchanged = await Promise.all(
|
|
83716
|
-
agent.kind === "acp-adapter-process" ? revalidateExecutable(agent.adapterIdentity) : Promise.resolve(true),
|
|
83717
|
-
revalidateExecutable(agent.agentIdentity)
|
|
83718
|
-
]);
|
|
83442
|
+
const unchanged = await Promise.all(agent.runtimeExecutables.map((identity2) => revalidateExecutable(identity2)));
|
|
83719
83443
|
signal.throwIfAborted();
|
|
83720
83444
|
if (unchanged.some((result) => !result)) {
|
|
83721
83445
|
throw new AcpExecutionError(
|
|
@@ -83726,16 +83450,10 @@ async function validateAgentRuntime(agent, signal) {
|
|
|
83726
83450
|
}
|
|
83727
83451
|
}
|
|
83728
83452
|
async function initializeAgentConnection(connection, agentId, verifiedVersion, signal) {
|
|
83729
|
-
|
|
83730
|
-
|
|
83731
|
-
|
|
83732
|
-
|
|
83733
|
-
signal
|
|
83734
|
-
).catch((cause) => {
|
|
83735
|
-
signal.throwIfAborted();
|
|
83736
|
-
throw new RetryableAcpInitializationError(cause);
|
|
83737
|
-
});
|
|
83738
|
-
}
|
|
83453
|
+
await connection.race(connection.initialize(signal), "The Agent runtime exited during initialization", signal).catch((cause) => {
|
|
83454
|
+
signal.throwIfAborted();
|
|
83455
|
+
throw new RetryableAcpInitializationError(cause);
|
|
83456
|
+
});
|
|
83739
83457
|
const initialized = await connection.race(
|
|
83740
83458
|
connection.connection.agent.request(
|
|
83741
83459
|
methods11.agent.initialize,
|
|
@@ -83765,8 +83483,8 @@ async function initializeAgentConnection(connection, agentId, verifiedVersion, s
|
|
|
83765
83483
|
}
|
|
83766
83484
|
return {
|
|
83767
83485
|
capabilities: normalizeAcpCapabilities(initialized),
|
|
83768
|
-
agentName:
|
|
83769
|
-
agentVersion:
|
|
83486
|
+
agentName: truncate(initialized.agentInfo?.title ?? initialized.agentInfo?.name ?? agentId, 255),
|
|
83487
|
+
agentVersion: truncate(
|
|
83770
83488
|
verifiedVersion.length > 0 ? verifiedVersion : initialized.agentInfo?.version ?? "",
|
|
83771
83489
|
128
|
|
83772
83490
|
)
|
|
@@ -90804,11 +90522,14 @@ function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
|
90804
90522
|
};
|
|
90805
90523
|
}
|
|
90806
90524
|
async function unchangedIdentity(agent, signal) {
|
|
90807
|
-
|
|
90808
|
-
|
|
90525
|
+
for (const identity2 of agent.runtimeExecutables) {
|
|
90526
|
+
signal.throwIfAborted();
|
|
90527
|
+
if (!await revalidateExecutable(identity2)) {
|
|
90528
|
+
return false;
|
|
90529
|
+
}
|
|
90809
90530
|
}
|
|
90810
90531
|
signal.throwIfAborted();
|
|
90811
|
-
return
|
|
90532
|
+
return true;
|
|
90812
90533
|
}
|
|
90813
90534
|
var init_resolve_catalog_agent = __esm({
|
|
90814
90535
|
"src/runtime/catalog/resolve-catalog-agent.ts"() {
|
|
@@ -91776,9 +91497,9 @@ async function readJsonResponse(response) {
|
|
|
91776
91497
|
}
|
|
91777
91498
|
}
|
|
91778
91499
|
function readRelayError(value) {
|
|
91779
|
-
if (
|
|
91500
|
+
if (isRecord(value)) {
|
|
91780
91501
|
const error62 = value["error"];
|
|
91781
|
-
if (
|
|
91502
|
+
if (isRecord(error62)) {
|
|
91782
91503
|
const code = error62["code"];
|
|
91783
91504
|
const message = error62["message"];
|
|
91784
91505
|
if (typeof code === "string" && typeof message === "string") {
|
|
@@ -91789,7 +91510,7 @@ function readRelayError(value) {
|
|
|
91789
91510
|
return new PairingClientError("pairing_failed", "The relay could not pair this machine");
|
|
91790
91511
|
}
|
|
91791
91512
|
function decodePairingResponse(value, credentialField, expectedKeys) {
|
|
91792
|
-
if (!
|
|
91513
|
+
if (!isRecord(value) || !hasExactKeys2(value, expectedKeys)) {
|
|
91793
91514
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
91794
91515
|
}
|
|
91795
91516
|
const appId = value["appId"];
|
|
@@ -92108,7 +91829,7 @@ var init_agent_diagnostics = __esm({
|
|
|
92108
91829
|
label;
|
|
92109
91830
|
status = "ready";
|
|
92110
91831
|
constructor(discovery) {
|
|
92111
|
-
this.adapterVersion = discovery.agent.
|
|
91832
|
+
this.adapterVersion = discovery.agent.adapterVersion;
|
|
92112
91833
|
this.agentVersion = discovery.agent.agentVersion;
|
|
92113
91834
|
this.id = discovery.specification.id;
|
|
92114
91835
|
this.label = discovery.specification.label;
|
|
@@ -92643,7 +92364,7 @@ var init_worker_lifecycle_log = __esm({
|
|
|
92643
92364
|
});
|
|
92644
92365
|
|
|
92645
92366
|
// src/daemon/lifecycle/worker-process.ts
|
|
92646
|
-
import { spawn as
|
|
92367
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
92647
92368
|
import { isAbsolute as isAbsolute15 } from "node:path";
|
|
92648
92369
|
async function decodeWorkerLaunch(value) {
|
|
92649
92370
|
const { entry, executable, version: version2 } = workerLaunch.parse(value);
|
|
@@ -92692,7 +92413,7 @@ var init_worker_process = __esm({
|
|
|
92692
92413
|
constructor(launch, signal, environment) {
|
|
92693
92414
|
signal.throwIfAborted();
|
|
92694
92415
|
this.launch = launch;
|
|
92695
|
-
this.#child =
|
|
92416
|
+
this.#child = spawn6(launch.executable, [launch.entry, "__worker"], {
|
|
92696
92417
|
env: environment,
|
|
92697
92418
|
windowsHide: true,
|
|
92698
92419
|
stdio: ["ignore", "pipe", "pipe", "ipc"]
|
|
@@ -92709,7 +92430,7 @@ var init_worker_process = __esm({
|
|
|
92709
92430
|
this.#drained.resolve();
|
|
92710
92431
|
});
|
|
92711
92432
|
this.#child.on("message", (value) => {
|
|
92712
|
-
if (
|
|
92433
|
+
if (isRecord(value) && value["kind"] === "worker-ready") {
|
|
92713
92434
|
if (value["version"] !== launch.version) {
|
|
92714
92435
|
this.#started.reject(
|
|
92715
92436
|
new WorkerStartupError(
|
|
@@ -93211,9 +92932,9 @@ var init_package2 = __esm({
|
|
|
93211
92932
|
});
|
|
93212
92933
|
|
|
93213
92934
|
// src/daemon/lifecycle/manager-client.ts
|
|
93214
|
-
import { spawn as
|
|
92935
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
93215
92936
|
async function spawnManager(launch) {
|
|
93216
|
-
const child =
|
|
92937
|
+
const child = spawn7(launch.executable, [launch.entry, "__manager"], {
|
|
93217
92938
|
detached: true,
|
|
93218
92939
|
windowsHide: true,
|
|
93219
92940
|
env: process.env,
|
|
@@ -93761,11 +93482,11 @@ function normalizeElicitationOptions(schema) {
|
|
|
93761
93482
|
const oneOf = schema["oneOf"];
|
|
93762
93483
|
if (Array.isArray(oneOf)) {
|
|
93763
93484
|
for (const option of oneOf) {
|
|
93764
|
-
if (
|
|
93485
|
+
if (isRecord(option) && typeof option["const"] === "string") {
|
|
93765
93486
|
normalized.push({
|
|
93766
|
-
description:
|
|
93767
|
-
label:
|
|
93768
|
-
value:
|
|
93487
|
+
description: truncate(readString(option["description"]), 500),
|
|
93488
|
+
label: truncate(readString(option["title"], option["const"]), 255),
|
|
93489
|
+
value: truncate(option["const"], 500)
|
|
93769
93490
|
});
|
|
93770
93491
|
}
|
|
93771
93492
|
}
|
|
@@ -93781,7 +93502,7 @@ function normalizeElicitationOptions(schema) {
|
|
|
93781
93502
|
return normalized.slice(0, 200);
|
|
93782
93503
|
}
|
|
93783
93504
|
const items = schema["items"];
|
|
93784
|
-
if (!
|
|
93505
|
+
if (!isRecord(items)) {
|
|
93785
93506
|
return normalized;
|
|
93786
93507
|
}
|
|
93787
93508
|
const anyOf = items["anyOf"];
|
|
@@ -93794,7 +93515,7 @@ function numericString(value) {
|
|
|
93794
93515
|
return typeof value === "number" && Number.isFinite(value) ? value.toString() : "";
|
|
93795
93516
|
}
|
|
93796
93517
|
function normalizeElicitationFields(requestedSchema) {
|
|
93797
|
-
if (!
|
|
93518
|
+
if (!isRecord(requestedSchema) || !isRecord(requestedSchema["properties"])) {
|
|
93798
93519
|
return [];
|
|
93799
93520
|
}
|
|
93800
93521
|
const properties = requestedSchema["properties"];
|
|
@@ -93804,7 +93525,7 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
93804
93525
|
);
|
|
93805
93526
|
const normalized = [];
|
|
93806
93527
|
for (const [name2, property] of Object.entries(properties)) {
|
|
93807
|
-
if (!
|
|
93528
|
+
if (!isRecord(property)) {
|
|
93808
93529
|
continue;
|
|
93809
93530
|
}
|
|
93810
93531
|
const type = elicitationFieldType(property["type"]);
|
|
@@ -93815,20 +93536,20 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
93815
93536
|
normalized.push({
|
|
93816
93537
|
defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
|
|
93817
93538
|
defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
|
|
93818
|
-
defaultStringValue: typeof defaultValue === "string" ?
|
|
93819
|
-
description:
|
|
93820
|
-
format:
|
|
93539
|
+
defaultStringValue: typeof defaultValue === "string" ? truncate(defaultValue, 1e4) : Array.isArray(defaultValue) ? truncate(JSON.stringify(defaultValue), 1e4) : "",
|
|
93540
|
+
description: truncate(readString(property["description"]), 500),
|
|
93541
|
+
format: truncate(readString(property["format"]), 64),
|
|
93821
93542
|
hasDefaultValue: defaultValue !== void 0 && defaultValue !== null,
|
|
93822
93543
|
maximum: numericString(property["maximum"]),
|
|
93823
93544
|
maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
|
|
93824
93545
|
minimum: numericString(property["minimum"]),
|
|
93825
93546
|
minimumLength: numericString(property["minLength"] ?? property["minItems"]),
|
|
93826
|
-
...normalizedType === "string" &&
|
|
93827
|
-
name:
|
|
93547
|
+
...normalizedType === "string" && isRecord(metadata) && metadata["io.mobius/multiline"] === true ? { multiline: true } : {},
|
|
93548
|
+
name: truncate(name2, 128),
|
|
93828
93549
|
options,
|
|
93829
|
-
pattern:
|
|
93550
|
+
pattern: truncate(readString(property["pattern"]), 500),
|
|
93830
93551
|
required: required2.has(name2),
|
|
93831
|
-
title:
|
|
93552
|
+
title: truncate(readString(property["title"], name2), 255),
|
|
93832
93553
|
type: normalizedType
|
|
93833
93554
|
});
|
|
93834
93555
|
}
|
|
@@ -93897,7 +93618,7 @@ function validateElicitationContent(encoded, requestedSchema) {
|
|
|
93897
93618
|
"invalid_elicitation_response"
|
|
93898
93619
|
);
|
|
93899
93620
|
}
|
|
93900
|
-
if (!
|
|
93621
|
+
if (!isRecord(decoded) || !isRecord(requestedSchema) || !isRecord(requestedSchema["properties"])) {
|
|
93901
93622
|
throw new AcpExecutionError(
|
|
93902
93623
|
"Elicitation response does not match the requested form",
|
|
93903
93624
|
{},
|
|
@@ -93917,7 +93638,7 @@ function validateElicitationContent(encoded, requestedSchema) {
|
|
|
93917
93638
|
const validated = {};
|
|
93918
93639
|
for (const [name2, value] of Object.entries(decoded)) {
|
|
93919
93640
|
const property = properties[name2];
|
|
93920
|
-
if (!
|
|
93641
|
+
if (!isRecord(property)) {
|
|
93921
93642
|
throw new AcpExecutionError(
|
|
93922
93643
|
`Elicitation field ${name2} was not requested`,
|
|
93923
93644
|
{},
|
|
@@ -94171,8 +93892,8 @@ var init_session_interactions = __esm({
|
|
|
94171
93892
|
const interactionId = `permission-${crypto.randomUUID()}`;
|
|
94172
93893
|
const options = request.options.slice(0, 20).map((option) => ({
|
|
94173
93894
|
kind: option.kind,
|
|
94174
|
-
name:
|
|
94175
|
-
optionId:
|
|
93895
|
+
name: truncate(option.name, 255),
|
|
93896
|
+
optionId: truncate(option.optionId, 255)
|
|
94176
93897
|
}));
|
|
94177
93898
|
if (options.length === 0) {
|
|
94178
93899
|
throw new AcpExecutionError(
|
|
@@ -94204,9 +93925,9 @@ var init_session_interactions = __esm({
|
|
|
94204
93925
|
kind: SESSION_PERMISSION_REQUESTED_KIND,
|
|
94205
93926
|
options,
|
|
94206
93927
|
sessionId: this.#context.sessionId(),
|
|
94207
|
-
title:
|
|
94208
|
-
toolCallId:
|
|
94209
|
-
toolKind:
|
|
93928
|
+
title: truncate(title2 ?? "Permission required", 500),
|
|
93929
|
+
toolCallId: truncate(request.toolCall.toolCallId, 255),
|
|
93930
|
+
toolKind: truncate(kind ?? "other", 64)
|
|
94210
93931
|
});
|
|
94211
93932
|
return await pending.completion.promise;
|
|
94212
93933
|
} finally {
|
|
@@ -94235,7 +93956,7 @@ var init_session_interactions = __esm({
|
|
|
94235
93956
|
const schemaValue = Reflect.get(request, "requestedSchema");
|
|
94236
93957
|
const requestedSchema = request.mode === "form" ? schemaValue : {};
|
|
94237
93958
|
const elicitationIdValue = Reflect.get(request, "elicitationId");
|
|
94238
|
-
const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ?
|
|
93959
|
+
const elicitationId = request.mode === "url" && typeof elicitationIdValue === "string" ? truncate(elicitationIdValue, 255) : "";
|
|
94239
93960
|
const pending = new PendingElicitation(interactionId, elicitationId, requestedSchema);
|
|
94240
93961
|
this.#pendingElicitations.set(interactionId, pending);
|
|
94241
93962
|
const abort = () => {
|
|
@@ -94250,10 +93971,10 @@ var init_session_interactions = __esm({
|
|
|
94250
93971
|
fields: normalizeElicitationFields(requestedSchema),
|
|
94251
93972
|
interactionId,
|
|
94252
93973
|
kind: SESSION_ELICITATION_REQUESTED_KIND,
|
|
94253
|
-
message:
|
|
93974
|
+
message: truncate(request.message, 2e3),
|
|
94254
93975
|
mode: request.mode,
|
|
94255
93976
|
sessionId: this.#context.sessionId(),
|
|
94256
|
-
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ?
|
|
93977
|
+
url: request.mode === "url" && typeof Reflect.get(request, "url") === "string" ? truncate(readString(Reflect.get(request, "url")), 4096) : ""
|
|
94257
93978
|
});
|
|
94258
93979
|
return await pending.completion.promise;
|
|
94259
93980
|
} finally {
|
|
@@ -94945,7 +94666,7 @@ var init_agent_session = __esm({
|
|
|
94945
94666
|
* directory observes the same title transition.
|
|
94946
94667
|
*/
|
|
94947
94668
|
renameSession = async (title2, signal) => {
|
|
94948
|
-
const normalized =
|
|
94669
|
+
const normalized = truncate(title2, 500);
|
|
94949
94670
|
if (normalized.length === 0) {
|
|
94950
94671
|
throw new AcpExecutionError("The Session title cannot be empty", {}, "invalid_session_title");
|
|
94951
94672
|
}
|
|
@@ -95154,7 +94875,7 @@ var init_agent_session = __esm({
|
|
|
95154
94875
|
}
|
|
95155
94876
|
validatePromptContent(options, this.#capabilities);
|
|
95156
94877
|
if (this.#sessionTitle === null || this.#sessionTitle.length === 0) {
|
|
95157
|
-
this.#sessionTitle =
|
|
94878
|
+
this.#sessionTitle = truncate(options.prompt, 500);
|
|
95158
94879
|
}
|
|
95159
94880
|
this.#prompted = true;
|
|
95160
94881
|
this.writeStoredSession((/* @__PURE__ */ new Date()).toISOString());
|
|
@@ -95202,7 +94923,7 @@ var init_agent_session = __esm({
|
|
|
95202
94923
|
code: failure2.code,
|
|
95203
94924
|
commandId: options.commandId,
|
|
95204
94925
|
kind: "prompt.failed",
|
|
95205
|
-
message:
|
|
94926
|
+
message: truncate(failure2.message, 500)
|
|
95206
94927
|
},
|
|
95207
94928
|
type: "lifecycle-metadata"
|
|
95208
94929
|
});
|
|
@@ -95268,7 +94989,7 @@ var init_agent_session = __esm({
|
|
|
95268
94989
|
code: failure2.code,
|
|
95269
94990
|
commandId: options.commandId,
|
|
95270
94991
|
kind: "prompt.failed",
|
|
95271
|
-
message:
|
|
94992
|
+
message: truncate(failure2.message, 500)
|
|
95272
94993
|
},
|
|
95273
94994
|
type: "lifecycle-metadata"
|
|
95274
94995
|
});
|
|
@@ -97445,7 +97166,8 @@ var init_session_turns = __esm({
|
|
|
97445
97166
|
queued.push({
|
|
97446
97167
|
commandId: candidate.command.commandId,
|
|
97447
97168
|
prompt: candidate.command.prompt,
|
|
97448
|
-
images: candidate.command.images
|
|
97169
|
+
images: candidate.command.images,
|
|
97170
|
+
resources: candidate.command.resources
|
|
97449
97171
|
});
|
|
97450
97172
|
}
|
|
97451
97173
|
return { turn: turnSnapshot ?? null, queued };
|
|
@@ -99063,7 +98785,7 @@ function settingsRevision(agent, reportedAgentVersion, settings, modelEffort) {
|
|
|
99063
98785
|
};
|
|
99064
98786
|
return createHash9("sha256").update(
|
|
99065
98787
|
JSON.stringify({
|
|
99066
|
-
adapterVersion: agent.
|
|
98788
|
+
adapterVersion: agent.adapterVersion,
|
|
99067
98789
|
agentId: agent.id,
|
|
99068
98790
|
agentVersion: agent.agentVersion,
|
|
99069
98791
|
modelEffort: revisionModelEffort,
|