@automatalabs/acp-agents 0.16.0 → 0.17.0
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-client.d.ts +16 -1
- package/dist/acp-client.d.ts.map +1 -1
- package/dist/acp-client.js +103 -4
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +13 -0
- package/dist/errors-map.d.ts +8 -1
- package/dist/errors-map.d.ts.map +1 -1
- package/dist/errors-map.js +23 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +13 -1
- package/dist/protocol-coverage.d.ts +3 -1
- package/dist/protocol-coverage.d.ts.map +1 -1
- package/dist/protocol-coverage.js +8 -6
- package/dist/runner.d.ts +46 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +179 -31
- package/package.json +2 -2
package/dist/acp-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CreateElicitationResponse, type ContentBlock, type AgentNotificationMethod, type AgentNotificationParamsByMethod, type AgentRequestMethod, type AgentRequestParamsByMethod, type AgentRequestResponsesByMethod, type DeleteSessionRequest, type ListSessionsRequest, type ListSessionsResponse, type PromptRequest, type PromptResponse, type RequestPermissionResponse, type SendRequestOptions, type SessionConfigOption, type SessionModeState, type SessionNotification, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type SetSessionModeRequest, type SetSessionModeResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { type AuthenticateRequest, type AuthenticateResponse, type AuthMethod, type CreateElicitationResponse, type ContentBlock, type AgentNotificationMethod, type AgentNotificationParamsByMethod, type AgentRequestMethod, type AgentRequestParamsByMethod, type AgentRequestResponsesByMethod, type DeleteSessionRequest, type DisableProviderRequest, type DisableProviderResponse, type ListSessionsRequest, type ListSessionsResponse, type ListProvidersRequest, type ListProvidersResponse, type LogoutRequest, type LogoutResponse, type PromptRequest, type PromptResponse, type RequestPermissionResponse, type SendRequestOptions, type SessionConfigOption, type SessionModeState, type SessionNotification, type SetProviderRequest, type SetProviderResponse, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type SetSessionModeRequest, type SetSessionModeResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { TSchema } from "typebox";
|
|
3
3
|
import { type AgentHistoryEntry, type McpServerConfig } from "@automatalabs/shared-types";
|
|
4
4
|
import type { Backend, BackendId, StructuredSource } from "./backend.js";
|
|
@@ -147,6 +147,7 @@ export declare class PooledConnection {
|
|
|
147
147
|
private assertSupportedMcpServers;
|
|
148
148
|
private sessionRequestMeta;
|
|
149
149
|
private assertLifecycleSupported;
|
|
150
|
+
private assertAuthProviderSupported;
|
|
150
151
|
/** Mark this connection dead exactly once, then ask the pool to evict it. Idempotent. */
|
|
151
152
|
private die;
|
|
152
153
|
private stderrSuffix;
|
|
@@ -170,6 +171,18 @@ export declare class PooledConnection {
|
|
|
170
171
|
listSessions(request: ListSessionsRequest, label?: string): Promise<ListSessionsResponse>;
|
|
171
172
|
/** session/delete on a dedicated connection, gated on the initialize advertisement. */
|
|
172
173
|
deleteSession(request: DeleteSessionRequest, label?: string): Promise<void>;
|
|
174
|
+
/** Authentication methods advertised in initialize, available without opening a session. */
|
|
175
|
+
authMethods(): Promise<AuthMethod[]>;
|
|
176
|
+
/** authenticate has no AgentCapabilities gate; authMethods advertises choices, not method support. */
|
|
177
|
+
authenticate(request: AuthenticateRequest, label?: string): Promise<AuthenticateResponse | void>;
|
|
178
|
+
/** providers/list on a dedicated connection, gated on the unstable providers advertisement. */
|
|
179
|
+
listProviders(request: ListProvidersRequest, label?: string): Promise<ListProvidersResponse>;
|
|
180
|
+
/** providers/set on a dedicated connection, gated on the unstable providers advertisement. */
|
|
181
|
+
setProvider(request: SetProviderRequest, label?: string): Promise<SetProviderResponse | void>;
|
|
182
|
+
/** providers/disable on a dedicated connection, gated on the unstable providers advertisement. */
|
|
183
|
+
disableProvider(request: DisableProviderRequest, label?: string): Promise<DisableProviderResponse | void>;
|
|
184
|
+
/** logout on a dedicated connection, gated on agentCapabilities.auth.logout. */
|
|
185
|
+
logout(request: LogoutRequest, label?: string): Promise<LogoutResponse | void>;
|
|
173
186
|
/** session/prompt on this connection, raced against process death. */
|
|
174
187
|
prompt(request: PromptRequest): Promise<PromptResponse>;
|
|
175
188
|
/** session/set_config_option on this connection, raced against process death. */
|
|
@@ -221,6 +234,8 @@ export declare class SessionHandle implements StructuredSource {
|
|
|
221
234
|
get text(): string;
|
|
222
235
|
/** Agent-advertised session mode catalog plus the currently active mode, if supported. */
|
|
223
236
|
get modes(): SessionModeState | null | undefined;
|
|
237
|
+
/** The connection-level initialize response parsed before this session was opened. */
|
|
238
|
+
get capabilities(): NegotiatedCapabilities | undefined;
|
|
224
239
|
/**
|
|
225
240
|
* Select the model for this session from the agent-advertised config options (§5.4).
|
|
226
241
|
* Returns `matched:false` (the caller fires onModelFallback) when the catalog has no value
|
package/dist/acp-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAwBA,OAAO,
|
|
1
|
+
{"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAwBA,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAQf,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAGlC,KAAK,oBAAoB,EAEzB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAG5B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,q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C;IAc5C,yEAAyE;IACnE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAoB7G,2DAA2D;IAC3D,eAAe,IAAI,MAAM;IAIzB,qFAAqF;IACrF,mBAAmB,IAAI,OAAO;IAI9B,gGAAgG;IAC1F,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,6EAA6E;IACvE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
package/dist/acp-client.js
CHANGED
|
@@ -24,7 +24,7 @@ import { spawn } from "node:child_process";
|
|
|
24
24
|
import { Readable, Writable } from "node:stream";
|
|
25
25
|
import { AGENT_METHODS, client, CLIENT_METHODS, ndJsonStream, PROTOCOL_VERSION, RequestError, } from "@agentclientprotocol/sdk";
|
|
26
26
|
import { META_KEYS, WorkflowError, WorkflowErrorCode, } from "@automatalabs/shared-types";
|
|
27
|
-
import { adaptPromptContent, describeLifecycleAdvertisement, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
|
|
27
|
+
import { adaptPromptContent, describeAuthProviderAdvertisement, describeLifecycleAdvertisement, gateCustomMeta, isSupportedProtocolVersion, negotiateCapabilities, unsupportedMcpServer, } from "./capabilities.js";
|
|
28
28
|
import { emitSessionUpdate } from "./events.js";
|
|
29
29
|
import { decidePermission, } from "./permissions.js";
|
|
30
30
|
import { UsageAccumulator } from "./usage.js";
|
|
@@ -552,6 +552,18 @@ function lifecycleCapabilityError(backendId, method, capabilities, label) {
|
|
|
552
552
|
: "initialize did not complete";
|
|
553
553
|
return new WorkflowError(`ACP agent (${backendId}) does not advertise ${method}; advertised lifecycle capabilities: ${advertised}`, WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: label });
|
|
554
554
|
}
|
|
555
|
+
function authProviderCapabilityError(backendId, method, capabilities, label) {
|
|
556
|
+
const advertised = capabilities
|
|
557
|
+
? describeAuthProviderAdvertisement(capabilities.agent, capabilities.authMethods)
|
|
558
|
+
: "initialize did not complete";
|
|
559
|
+
return new WorkflowError(`ACP agent (${backendId}) does not advertise ${method}; advertised auth/provider capabilities: ${advertised}`, WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: label });
|
|
560
|
+
}
|
|
561
|
+
function isMethodNotFound(error) {
|
|
562
|
+
return Boolean(error && typeof error === "object" && error.code === -32601);
|
|
563
|
+
}
|
|
564
|
+
function agentMethodNotFoundError(backendId, method, label, cause) {
|
|
565
|
+
return new WorkflowError(`ACP agent (${backendId}) does not implement ${method}: ${thrownMessage(cause)}`, WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: label, details: cause });
|
|
566
|
+
}
|
|
555
567
|
function thrownMessage(error) {
|
|
556
568
|
if (error instanceof Error)
|
|
557
569
|
return error.message;
|
|
@@ -764,6 +776,18 @@ export class PooledConnection {
|
|
|
764
776
|
return;
|
|
765
777
|
throw lifecycleCapabilityError(this.backendId, method, this.negotiated, label);
|
|
766
778
|
}
|
|
779
|
+
assertAuthProviderSupported(method, label) {
|
|
780
|
+
const supported = method === AGENT_METHODS.logout
|
|
781
|
+
? this.negotiated?.supportsLogout
|
|
782
|
+
: method === AGENT_METHODS.providers_list ||
|
|
783
|
+
method === AGENT_METHODS.providers_set ||
|
|
784
|
+
method === AGENT_METHODS.providers_disable
|
|
785
|
+
? this.negotiated?.supportsProviders
|
|
786
|
+
: true;
|
|
787
|
+
if (supported)
|
|
788
|
+
return;
|
|
789
|
+
throw authProviderCapabilityError(this.backendId, method, this.negotiated, label);
|
|
790
|
+
}
|
|
767
791
|
/** Mark this connection dead exactly once, then ask the pool to evict it. Idempotent. */
|
|
768
792
|
die(error) {
|
|
769
793
|
if (!this._alive)
|
|
@@ -888,9 +912,10 @@ export class PooledConnection {
|
|
|
888
912
|
return this.reattachSession(AGENT_METHODS.session_resume, sessionId, opts);
|
|
889
913
|
}
|
|
890
914
|
rawAgentRequest(method, params) {
|
|
891
|
-
// SDK
|
|
892
|
-
//
|
|
893
|
-
//
|
|
915
|
+
// Some SDK ClientContext convenience methods collapse responses through emptyObjectResponse
|
|
916
|
+
// (session/load in 1.2.0, plus auth/provider methods with optional _meta). Driven wrappers
|
|
917
|
+
// need the wire response as-is. This bypasses only the SDK response mapper, not JSON-RPC
|
|
918
|
+
// validation/racing.
|
|
894
919
|
const agent = this.connection.agent;
|
|
895
920
|
return this.race(agent.sendRequest(method, params));
|
|
896
921
|
}
|
|
@@ -944,6 +969,76 @@ export class PooledConnection {
|
|
|
944
969
|
this.assertLifecycleSupported(AGENT_METHODS.session_delete, label);
|
|
945
970
|
await this.race(this.connection.agent.request(AGENT_METHODS.session_delete, request));
|
|
946
971
|
}
|
|
972
|
+
/** Authentication methods advertised in initialize, available without opening a session. */
|
|
973
|
+
async authMethods() {
|
|
974
|
+
await this.ready;
|
|
975
|
+
return [...(this.negotiated?.authMethods ?? [])];
|
|
976
|
+
}
|
|
977
|
+
/** authenticate has no AgentCapabilities gate; authMethods advertises choices, not method support. */
|
|
978
|
+
async authenticate(request, label) {
|
|
979
|
+
await this.ready;
|
|
980
|
+
try {
|
|
981
|
+
return await this.rawAgentRequest(AGENT_METHODS.authenticate, request);
|
|
982
|
+
}
|
|
983
|
+
catch (error) {
|
|
984
|
+
if (isMethodNotFound(error))
|
|
985
|
+
throw agentMethodNotFoundError(this.backendId, AGENT_METHODS.authenticate, label, error);
|
|
986
|
+
throw error;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
/** providers/list on a dedicated connection, gated on the unstable providers advertisement. */
|
|
990
|
+
async listProviders(request, label) {
|
|
991
|
+
await this.ready;
|
|
992
|
+
this.assertAuthProviderSupported(AGENT_METHODS.providers_list, label);
|
|
993
|
+
try {
|
|
994
|
+
return await this.rawAgentRequest(AGENT_METHODS.providers_list, request);
|
|
995
|
+
}
|
|
996
|
+
catch (error) {
|
|
997
|
+
if (isMethodNotFound(error))
|
|
998
|
+
throw agentMethodNotFoundError(this.backendId, AGENT_METHODS.providers_list, label, error);
|
|
999
|
+
throw error;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
/** providers/set on a dedicated connection, gated on the unstable providers advertisement. */
|
|
1003
|
+
async setProvider(request, label) {
|
|
1004
|
+
await this.ready;
|
|
1005
|
+
this.assertAuthProviderSupported(AGENT_METHODS.providers_set, label);
|
|
1006
|
+
try {
|
|
1007
|
+
return await this.rawAgentRequest(AGENT_METHODS.providers_set, request);
|
|
1008
|
+
}
|
|
1009
|
+
catch (error) {
|
|
1010
|
+
if (isMethodNotFound(error))
|
|
1011
|
+
throw agentMethodNotFoundError(this.backendId, AGENT_METHODS.providers_set, label, error);
|
|
1012
|
+
throw error;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
/** providers/disable on a dedicated connection, gated on the unstable providers advertisement. */
|
|
1016
|
+
async disableProvider(request, label) {
|
|
1017
|
+
await this.ready;
|
|
1018
|
+
this.assertAuthProviderSupported(AGENT_METHODS.providers_disable, label);
|
|
1019
|
+
try {
|
|
1020
|
+
return await this.rawAgentRequest(AGENT_METHODS.providers_disable, request);
|
|
1021
|
+
}
|
|
1022
|
+
catch (error) {
|
|
1023
|
+
if (isMethodNotFound(error)) {
|
|
1024
|
+
throw agentMethodNotFoundError(this.backendId, AGENT_METHODS.providers_disable, label, error);
|
|
1025
|
+
}
|
|
1026
|
+
throw error;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
/** logout on a dedicated connection, gated on agentCapabilities.auth.logout. */
|
|
1030
|
+
async logout(request, label) {
|
|
1031
|
+
await this.ready;
|
|
1032
|
+
this.assertAuthProviderSupported(AGENT_METHODS.logout, label);
|
|
1033
|
+
try {
|
|
1034
|
+
return await this.rawAgentRequest(AGENT_METHODS.logout, request);
|
|
1035
|
+
}
|
|
1036
|
+
catch (error) {
|
|
1037
|
+
if (isMethodNotFound(error))
|
|
1038
|
+
throw agentMethodNotFoundError(this.backendId, AGENT_METHODS.logout, label, error);
|
|
1039
|
+
throw error;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
947
1042
|
/** session/prompt on this connection, raced against process death. */
|
|
948
1043
|
prompt(request) {
|
|
949
1044
|
return this.race(this.connection.agent.request(AGENT_METHODS.session_prompt, request));
|
|
@@ -1087,6 +1182,10 @@ export class SessionHandle {
|
|
|
1087
1182
|
get modes() {
|
|
1088
1183
|
return this.state.modes;
|
|
1089
1184
|
}
|
|
1185
|
+
/** The connection-level initialize response parsed before this session was opened. */
|
|
1186
|
+
get capabilities() {
|
|
1187
|
+
return this.pooled.capabilities;
|
|
1188
|
+
}
|
|
1090
1189
|
/**
|
|
1091
1190
|
* Select the model for this session from the agent-advertised config options (§5.4).
|
|
1092
1191
|
* Returns `matched:false` (the caller fires onModelFallback) when the catalog has no value
|
package/dist/capabilities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentCapabilities, type ContentBlock, type Implementation, type InitializeResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { type AgentCapabilities, type AuthMethod, type ContentBlock, type Implementation, type InitializeResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { type McpServerConfig } from "@automatalabs/shared-types";
|
|
3
3
|
import type { Backend } from "./backend.js";
|
|
4
4
|
/** The bare `_meta` keys whose emission is gated by Codex's custom-capability advertisement.
|
|
@@ -16,6 +16,10 @@ export interface NegotiatedCapabilities {
|
|
|
16
16
|
agent: AgentCapabilities;
|
|
17
17
|
/** The agent's self-identification, when it sent agentInfo. */
|
|
18
18
|
agentInfo: Implementation | undefined;
|
|
19
|
+
/** Authentication methods advertised by the agent in initialize, defaulting to [] when absent. */
|
|
20
|
+
authMethods: AuthMethod[];
|
|
21
|
+
/** Initialize-response `_meta`, when the agent sent it. */
|
|
22
|
+
initializeMeta: InitializeResponse["_meta"] | undefined;
|
|
19
23
|
/** Whether session/close is advertised (gates the best-effort release-time close). */
|
|
20
24
|
supportsClose: boolean;
|
|
21
25
|
/** Whether session/load is advertised. The current SDK keeps this as the legacy top-level
|
|
@@ -27,6 +31,10 @@ export interface NegotiatedCapabilities {
|
|
|
27
31
|
supportsDeleteSession: boolean;
|
|
28
32
|
/** Whether session/resume is advertised. */
|
|
29
33
|
supportsResumeSession: boolean;
|
|
34
|
+
/** Whether logout is advertised under agentCapabilities.auth.logout. */
|
|
35
|
+
supportsLogout: boolean;
|
|
36
|
+
/** Whether the unstable provider-configuration block is advertised. */
|
|
37
|
+
supportsProviders: boolean;
|
|
30
38
|
/** The parsed backend-declared custom-capability block (the namespaced `_meta` object), or
|
|
31
39
|
* undefined when the backend declared none or the agent did not advertise it — passthrough. */
|
|
32
40
|
customMetaSupport: Record<string, unknown> | undefined;
|
|
@@ -38,6 +46,8 @@ export interface NegotiatedCapabilities {
|
|
|
38
46
|
export declare function negotiateCapabilities(response: InitializeResponse, customCapabilities?: Backend["customCapabilities"]): NegotiatedCapabilities;
|
|
39
47
|
/** Human-readable lifecycle advertisement summary for strict wrapper gate errors. */
|
|
40
48
|
export declare function describeLifecycleAdvertisement(agent: AgentCapabilities): string;
|
|
49
|
+
/** Human-readable auth/provider advertisement summary for strict wrapper gate errors. */
|
|
50
|
+
export declare function describeAuthProviderAdvertisement(agent: AgentCapabilities, authMethods?: readonly AuthMethod[]): string;
|
|
41
51
|
/** True only when the agent selected EXACTLY PROTOCOL_VERSION. This client implements that one wire
|
|
42
52
|
* version and adapts its behavior to no other, so any other selected version — older or newer —
|
|
43
53
|
* means close the connection per the ACP spec's SHOULD-close rule. Per the spec the agent echoes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAkBA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK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AW,GAAE,SAAS,UAAU,EAAO,GACtC,MAAM,CAOR;AAaD;;;;+DAI+D;AAC/D,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;gEAGgE;AAChE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC5C,SAAS,GAAE,SAAS,MAAM,EAA2B,GACpD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAWrC;AAED;;;;;2EAK2E;AAC3E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EAAE,EACtB,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,GAChB,YAAY,EAAE,CAchB;AAkCD;;;;kEAIkE;AAClE,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,EAAE,GAAG,SAAS,EACtC,KAAK,EAAE,iBAAiB,EACxB,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,SAAS,CAkBpF"}
|
package/dist/capabilities.js
CHANGED
|
@@ -40,11 +40,15 @@ export function negotiateCapabilities(response, customCapabilities) {
|
|
|
40
40
|
protocolVersion: response.protocolVersion,
|
|
41
41
|
agent,
|
|
42
42
|
agentInfo: response.agentInfo ?? undefined,
|
|
43
|
+
authMethods: response.authMethods ?? [],
|
|
44
|
+
initializeMeta: response._meta ?? undefined,
|
|
43
45
|
supportsClose: advertised(sessionCapabilities?.close),
|
|
44
46
|
supportsLoadSession: agent.loadSession === true || advertised(sessionCapabilities?.load),
|
|
45
47
|
supportsListSessions: advertised(sessionCapabilities?.list),
|
|
46
48
|
supportsDeleteSession: advertised(sessionCapabilities?.delete),
|
|
47
49
|
supportsResumeSession: advertised(sessionCapabilities?.resume),
|
|
50
|
+
supportsLogout: advertised(agent.auth?.logout),
|
|
51
|
+
supportsProviders: advertised(agent.providers),
|
|
48
52
|
customMetaSupport: customCapabilities
|
|
49
53
|
? readCustomNamespace(agent._meta, customCapabilities.namespace)
|
|
50
54
|
: undefined,
|
|
@@ -73,6 +77,15 @@ export function describeLifecycleAdvertisement(agent) {
|
|
|
73
77
|
`sessionCapabilities=${session.length > 0 ? session.join(", ") : "none"}`,
|
|
74
78
|
].join("; ");
|
|
75
79
|
}
|
|
80
|
+
/** Human-readable auth/provider advertisement summary for strict wrapper gate errors. */
|
|
81
|
+
export function describeAuthProviderAdvertisement(agent, authMethods = []) {
|
|
82
|
+
const methodIds = authMethods.map((method) => method.id).filter(Boolean);
|
|
83
|
+
return [
|
|
84
|
+
`authMethods=${methodIds.length > 0 ? methodIds.join(", ") : "none"}`,
|
|
85
|
+
`auth.logout=${advertised(agent.auth?.logout) ? "true" : "false"}`,
|
|
86
|
+
`providers=${advertised(agent.providers) ? "true" : "false"}`,
|
|
87
|
+
].join("; ");
|
|
88
|
+
}
|
|
76
89
|
function readCustomNamespace(meta, namespace) {
|
|
77
90
|
if (!meta || typeof meta !== "object")
|
|
78
91
|
return undefined;
|
package/dist/errors-map.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { WorkflowError } from "@automatalabs/shared-types";
|
|
2
|
+
import type { AuthMethod } from "@agentclientprotocol/sdk";
|
|
3
|
+
export declare const ACP_AUTH_REQUIRED_ERROR_CODE = -32000;
|
|
4
|
+
export interface ErrorMapContext {
|
|
5
|
+
label?: string;
|
|
6
|
+
backendId?: string;
|
|
7
|
+
authMethods?: readonly AuthMethod[];
|
|
8
|
+
}
|
|
2
9
|
export declare function errorText(error: unknown): string;
|
|
3
10
|
/** Map any thrown error from the run path onto a seam-level WorkflowError. */
|
|
4
|
-
export declare function mapThrownError(error: unknown,
|
|
11
|
+
export declare function mapThrownError(error: unknown, labelOrContext?: string | ErrorMapContext): WorkflowError;
|
|
5
12
|
//# sourceMappingURL=errors-map.d.ts.map
|
package/dist/errors-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-map.d.ts","sourceRoot":"","sources":["../src/errors-map.ts"],"names":[],"mappings":"AAYA,OAAO,EAA0C,aAAa,EAAqB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"errors-map.d.ts","sourceRoot":"","sources":["../src/errors-map.ts"],"names":[],"mappings":"AAYA,OAAO,EAA0C,aAAa,EAAqB,MAAM,4BAA4B,CAAC;AACtH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,eAAO,MAAM,4BAA4B,SAAS,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CACrC;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAahD;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,aAAa,CA4BvG"}
|
package/dist/errors-map.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// the engine retries). WorkflowErrors raised inside the ladder (SCHEMA_NONCOMPLIANCE,
|
|
12
12
|
// AGENT_EMPTY_OUTPUT) pass through unchanged.
|
|
13
13
|
import { classifyProviderLimit, isWorkflowError, WorkflowError, WorkflowErrorCode } from "@automatalabs/shared-types";
|
|
14
|
+
export const ACP_AUTH_REQUIRED_ERROR_CODE = -32000;
|
|
14
15
|
export function errorText(error) {
|
|
15
16
|
if (error instanceof Error)
|
|
16
17
|
return error.message;
|
|
@@ -30,18 +31,37 @@ export function errorText(error) {
|
|
|
30
31
|
return String(error);
|
|
31
32
|
}
|
|
32
33
|
/** Map any thrown error from the run path onto a seam-level WorkflowError. */
|
|
33
|
-
export function mapThrownError(error,
|
|
34
|
+
export function mapThrownError(error, labelOrContext) {
|
|
34
35
|
// Already a seam error (e.g. SCHEMA_NONCOMPLIANCE / AGENT_EMPTY_OUTPUT raised in-band).
|
|
35
36
|
if (isWorkflowError(error))
|
|
36
37
|
return error;
|
|
38
|
+
const context = typeof labelOrContext === "string" ? { label: labelOrContext } : (labelOrContext ?? {});
|
|
37
39
|
const message = errorText(error);
|
|
40
|
+
if (isAcpAuthRequired(error, message)) {
|
|
41
|
+
return new WorkflowError(authRequiredMessage(message, context), WorkflowErrorCode.AUTH_REQUIRED, {
|
|
42
|
+
recoverable: false,
|
|
43
|
+
agentLabel: context.label,
|
|
44
|
+
details: error,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
38
47
|
const { matched, resetHint } = classifyProviderLimit(message);
|
|
39
48
|
if (matched) {
|
|
40
|
-
return new WorkflowError(message || "Provider usage/quota limit reached", WorkflowErrorCode.PROVIDER_USAGE_LIMIT, { recoverable: false, agentLabel: label, resetHint, details: error });
|
|
49
|
+
return new WorkflowError(message || "Provider usage/quota limit reached", WorkflowErrorCode.PROVIDER_USAGE_LIMIT, { recoverable: false, agentLabel: context.label, resetHint, details: error });
|
|
41
50
|
}
|
|
42
51
|
return new WorkflowError(message || "Subagent execution failed", WorkflowErrorCode.AGENT_EXECUTION_ERROR, {
|
|
43
52
|
recoverable: true,
|
|
44
|
-
agentLabel: label,
|
|
53
|
+
agentLabel: context.label,
|
|
45
54
|
details: error,
|
|
46
55
|
});
|
|
47
56
|
}
|
|
57
|
+
function isAcpAuthRequired(error, message) {
|
|
58
|
+
return (Boolean(error && typeof error === "object" && error.code === ACP_AUTH_REQUIRED_ERROR_CODE) &&
|
|
59
|
+
/^Authentication required\b/i.test(message));
|
|
60
|
+
}
|
|
61
|
+
function authRequiredMessage(message, context) {
|
|
62
|
+
const backend = context.backendId ? ` (${context.backendId})` : "";
|
|
63
|
+
const detail = message.replace(/^Authentication required:?\s*/i, "").trim();
|
|
64
|
+
const methodIds = (context.authMethods ?? []).map((method) => method.id).filter(Boolean);
|
|
65
|
+
const hint = methodIds.length > 0 ? `; run authenticate() with one of: ${methodIds.join(", ")}` : "";
|
|
66
|
+
return `ACP agent${backend} requires authentication${detail ? `: ${detail}` : ""}${hint}`;
|
|
67
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { AcpAgentRunner, createAcpRunner, selectBackend } from "./runner.js";
|
|
2
|
-
export type { AcpRunnerOptions, DeleteSessionOptions, ListSessionsOptions, ReattachSessionOptions, } from "./runner.js";
|
|
2
|
+
export type { AcpRunnerOptions, AuthenticateOptions, AuthMethodsOptions, DisableProviderOptions, DeleteSessionOptions, ListProvidersOptions, ListSessionsOptions, LogoutOptions, ReattachSessionOptions, SetProviderOptions, } from "./runner.js";
|
|
3
3
|
export { InteractiveSession } from "./interactive.js";
|
|
4
4
|
export type { InteractiveSessionOptions, InteractiveTurn } from "./interactive.js";
|
|
5
5
|
export { AGENT_METHODS, CLIENT_METHODS } from "@agentclientprotocol/sdk";
|
|
6
|
-
export type { AgentNotificationMethod, AgentNotificationParamsByMethod, AgentRequestMethod, AgentRequestParamsByMethod, AgentRequestResponsesByMethod, CompleteElicitationNotification, ConnectMcpRequest, ConnectMcpResponse, CreateElicitationRequest, CreateElicitationResponse, DeleteSessionRequest, DeleteSessionResponse, DisconnectMcpRequest, DisconnectMcpResponse, ElicitationAcceptAction, ElicitationCapabilities, ElicitationContentValue, ElicitationFormCapabilities, ElicitationFormMode, ElicitationId, ElicitationPropertySchema, ElicitationRequestScope, ElicitationSchema, ElicitationSchemaType, ElicitationSessionScope, ElicitationUrlCapabilities, ElicitationUrlMode, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, McpConnectionId, McpServerAcp, McpServerAcpId, MessageMcpNotification, MessageMcpRequest, MessageMcpResponse, ResumeSessionRequest, ResumeSessionResponse, SessionMode, SessionModeState, SessionInfo, SendRequestOptions, } from "@agentclientprotocol/sdk";
|
|
6
|
+
export type { AgentNotificationMethod, AgentNotificationParamsByMethod, AgentAuthCapabilities, AgentRequestMethod, AgentRequestParamsByMethod, AgentRequestResponsesByMethod, AuthCapabilities, AuthEnvVar, AuthenticateRequest, AuthenticateResponse, AuthMethod, AuthMethodAgent, AuthMethodEnvVar, AuthMethodId, AuthMethodTerminal, DisableProviderRequest, DisableProviderResponse, CompleteElicitationNotification, ConnectMcpRequest, ConnectMcpResponse, CreateElicitationRequest, CreateElicitationResponse, DeleteSessionRequest, DeleteSessionResponse, DisconnectMcpRequest, DisconnectMcpResponse, ElicitationAcceptAction, ElicitationCapabilities, ElicitationContentValue, ElicitationFormCapabilities, ElicitationFormMode, ElicitationId, ElicitationPropertySchema, ElicitationRequestScope, ElicitationSchema, ElicitationSchemaType, ElicitationSessionScope, ElicitationUrlCapabilities, ElicitationUrlMode, ListProvidersRequest, ListProvidersResponse, ListSessionsRequest, ListSessionsResponse, LlmProtocol, LoadSessionRequest, LoadSessionResponse, LogoutCapabilities, LogoutRequest, LogoutResponse, McpConnectionId, McpServerAcp, McpServerAcpId, MessageMcpNotification, MessageMcpRequest, MessageMcpResponse, ResumeSessionRequest, ResumeSessionResponse, ProviderCurrentConfig, ProviderId, ProviderInfo, ProvidersCapabilities, SessionMode, SessionModeState, SessionInfo, SendRequestOptions, SetProviderRequest, SetProviderResponse, } from "@agentclientprotocol/sdk";
|
|
7
7
|
export { BACKENDS_ENV, registryWithRunBackends, resolveBackendRegistry } from "./registry.js";
|
|
8
8
|
export type { BackendRegistry, CustomBackendConfig, RegisteredBackend } from "./registry.js";
|
|
9
9
|
export { PooledConnection, SessionHandle } from "./acp-client.js";
|
|
@@ -29,5 +29,6 @@ export type { McpAcpServerConfig, McpServerConfig } from "@automatalabs/shared-t
|
|
|
29
29
|
export { toJsonSchema, toStrictJsonSchema } from "./schema-strict.js";
|
|
30
30
|
export { extractValidated, findJsonBlock, parseFinalJson, resolveStructuredOutput, validateValue, } from "./structured-output.js";
|
|
31
31
|
export type { ResolveOptions, StructuredSession } from "./structured-output.js";
|
|
32
|
-
export { errorText, mapThrownError } from "./errors-map.js";
|
|
32
|
+
export { ACP_AUTH_REQUIRED_ERROR_CODE, errorText, mapThrownError } from "./errors-map.js";
|
|
33
|
+
export type { ErrorMapContext } from "./errors-map.js";
|
|
33
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACzE,YAAY,EACV,uBAAuB,EACvB,+BAA+B,EAC/B,qBAAqB,EACrB,kBAAkB,EAClB,0BAA0B,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AkB,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC1F,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,4 +27,4 @@ export { decidePermission } from "./permissions.js";
|
|
|
27
27
|
export { UsageAccumulator } from "./usage.js";
|
|
28
28
|
export { toJsonSchema, toStrictJsonSchema } from "./schema-strict.js";
|
|
29
29
|
export { extractValidated, findJsonBlock, parseFinalJson, resolveStructuredOutput, validateValue, } from "./structured-output.js";
|
|
30
|
-
export { errorText, mapThrownError } from "./errors-map.js";
|
|
30
|
+
export { ACP_AUTH_REQUIRED_ERROR_CODE, errorText, mapThrownError } from "./errors-map.js";
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAa,MAAM,cAAc,CAAC;AACvD,OAAO,EAAoB,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK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,CAAC,cAAc;IAStB,+DAA+D;IAC/D,OAAO,CAAC,IAAI;IAOZ,iEAAiE;IAC3D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAMtB,gGAAgG;IAChG,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/pool.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PooledConnection } from "./acp-client.js";
|
|
2
2
|
import { validateClientHandlers } from "./client-handlers.js";
|
|
3
|
+
import { mapThrownError } from "./errors-map.js";
|
|
3
4
|
const DEFAULT_POOL_SIZE = 1;
|
|
4
5
|
const POOL_SIZE_ENV = "AGENTPRISM_ACP_POOL_SIZE";
|
|
5
6
|
/** Resolve the per-backend pool size: explicit option wins, else env, else 1. Clamped to >= 1. */
|
|
@@ -34,7 +35,18 @@ export class AcpAgentPool {
|
|
|
34
35
|
if (this.disposed)
|
|
35
36
|
throw new Error("ACP agent pool is disposed");
|
|
36
37
|
const connection = this.selectConnection(backend);
|
|
37
|
-
|
|
38
|
+
try {
|
|
39
|
+
return await connection.openSession(opts);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (opts.signal?.aborted)
|
|
43
|
+
throw error;
|
|
44
|
+
throw mapThrownError(error, {
|
|
45
|
+
label: opts.label,
|
|
46
|
+
backendId: connection.backendId,
|
|
47
|
+
authMethods: connection.capabilities?.authMethods,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
/**
|
|
40
52
|
* Pick the connection to host the next session. Runs SYNCHRONOUSLY (no await) through to the
|
|
@@ -7,7 +7,9 @@ export type ClientMethodCoverage = "served" | "pending";
|
|
|
7
7
|
* the client rejects it until a driven wrapper can route updates, permissions, and terminals. */
|
|
8
8
|
export type AgentMethodCoverage = "driven" | "passthrough" | "guarded";
|
|
9
9
|
/** Enforceable definition of "full ACP spec support": every SDK method constant is classified
|
|
10
|
-
* here, and the tripwire test fails when an SDK bump silently widens or shrinks the protocol.
|
|
10
|
+
* here, and the tripwire test fails when an SDK bump silently widens or shrinks the protocol.
|
|
11
|
+
* Agent side: 15 operational methods are driven (plus initialize), 1 is guarded (session/fork),
|
|
12
|
+
* and the passthrough remainder is nes/*, document/*, and mcp/message. */
|
|
11
13
|
export declare const CLIENT_METHOD_COVERAGE: Record<ClientMethod, ClientMethodCoverage>;
|
|
12
14
|
export declare const AGENT_METHOD_COVERAGE: Record<AgentMethod, AgentMethodCoverage>;
|
|
13
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-coverage.d.ts","sourceRoot":"","sources":["../src/protocol-coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzE,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7B,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,cAAc,CAAC,CAAC;AACnD,KAAK,WAAW,GAAG,OAAO,CAAC,OAAO,aAAa,CAAC,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AACxD;kGACkG;AAClG,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvE;
|
|
1
|
+
{"version":3,"file":"protocol-coverage.d.ts","sourceRoot":"","sources":["../src/protocol-coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzE,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7B,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,cAAc,CAAC,CAAC;AACnD,KAAK,WAAW,GAAG,OAAO,CAAC,OAAO,aAAa,CAAC,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AACxD;kGACkG;AAClG,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvE;;;2EAG2E;AAC3E,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAe7E,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,WAAW,EAAE,mBAAmB,CA6B1E,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AGENT_METHODS, CLIENT_METHODS } from "@agentclientprotocol/sdk";
|
|
2
2
|
/** Enforceable definition of "full ACP spec support": every SDK method constant is classified
|
|
3
|
-
* here, and the tripwire test fails when an SDK bump silently widens or shrinks the protocol.
|
|
3
|
+
* here, and the tripwire test fails when an SDK bump silently widens or shrinks the protocol.
|
|
4
|
+
* Agent side: 15 operational methods are driven (plus initialize), 1 is guarded (session/fork),
|
|
5
|
+
* and the passthrough remainder is nes/*, document/*, and mcp/message. */
|
|
4
6
|
export const CLIENT_METHOD_COVERAGE = {
|
|
5
7
|
[CLIENT_METHODS.session_request_permission]: "served",
|
|
6
8
|
[CLIENT_METHODS.session_update]: "served",
|
|
@@ -19,10 +21,10 @@ export const CLIENT_METHOD_COVERAGE = {
|
|
|
19
21
|
};
|
|
20
22
|
export const AGENT_METHOD_COVERAGE = {
|
|
21
23
|
[AGENT_METHODS.initialize]: "driven",
|
|
22
|
-
[AGENT_METHODS.authenticate]: "
|
|
23
|
-
[AGENT_METHODS.providers_list]: "
|
|
24
|
-
[AGENT_METHODS.providers_set]: "
|
|
25
|
-
[AGENT_METHODS.providers_disable]: "
|
|
24
|
+
[AGENT_METHODS.authenticate]: "driven",
|
|
25
|
+
[AGENT_METHODS.providers_list]: "driven",
|
|
26
|
+
[AGENT_METHODS.providers_set]: "driven",
|
|
27
|
+
[AGENT_METHODS.providers_disable]: "driven",
|
|
26
28
|
[AGENT_METHODS.session_new]: "driven",
|
|
27
29
|
[AGENT_METHODS.session_load]: "driven",
|
|
28
30
|
[AGENT_METHODS.session_set_mode]: "driven",
|
|
@@ -35,7 +37,7 @@ export const AGENT_METHOD_COVERAGE = {
|
|
|
35
37
|
[AGENT_METHODS.session_fork]: "guarded",
|
|
36
38
|
[AGENT_METHODS.session_resume]: "driven",
|
|
37
39
|
[AGENT_METHODS.session_close]: "driven",
|
|
38
|
-
[AGENT_METHODS.logout]: "
|
|
40
|
+
[AGENT_METHODS.logout]: "driven",
|
|
39
41
|
[AGENT_METHODS.nes_start]: "passthrough",
|
|
40
42
|
[AGENT_METHODS.nes_suggest]: "passthrough",
|
|
41
43
|
[AGENT_METHODS.nes_accept]: "passthrough",
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AgentResult, type AgentRunner, type RunOptions } from "@automatalabs/shared-types";
|
|
2
|
-
import type { ListSessionsResponse } from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { AuthenticateRequest, AuthenticateResponse, AuthMethod, DisableProviderRequest, DisableProviderResponse, ListProvidersResponse, ListSessionsResponse, LogoutResponse, SetProviderRequest, SetProviderResponse } from "@agentclientprotocol/sdk";
|
|
3
3
|
import type { TSchema } from "typebox";
|
|
4
4
|
import { type AcpPoolOptions } from "./pool.js";
|
|
5
5
|
import { type AcpEventListener, type AcpEventName } from "./events.js";
|
|
@@ -17,6 +17,13 @@ interface LifecycleRoutingOptions {
|
|
|
17
17
|
/** Host-owned cancellation while the lifecycle request is in flight. */
|
|
18
18
|
signal?: AbortSignal;
|
|
19
19
|
}
|
|
20
|
+
/** Options for AcpAgentRunner.authMethods(). */
|
|
21
|
+
export interface AuthMethodsOptions {
|
|
22
|
+
/** Model spec used only to select the backend process. */
|
|
23
|
+
model?: string;
|
|
24
|
+
/** Coarse tier consulted only when `model` is unset. */
|
|
25
|
+
tier?: string;
|
|
26
|
+
}
|
|
20
27
|
/** Options for AcpAgentRunner.listSessions(). */
|
|
21
28
|
export interface ListSessionsOptions extends LifecycleRoutingOptions {
|
|
22
29
|
/** Optional absolute working-directory filter. */
|
|
@@ -33,6 +40,32 @@ export interface DeleteSessionOptions extends LifecycleRoutingOptions {
|
|
|
33
40
|
/** Generic ACP `_meta` passthrough for session/delete. */
|
|
34
41
|
meta?: Record<string, unknown>;
|
|
35
42
|
}
|
|
43
|
+
interface AuthProviderRoutingOptions extends LifecycleRoutingOptions {
|
|
44
|
+
/** Generic ACP `_meta` passthrough for the request. */
|
|
45
|
+
meta?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
/** Options for AcpAgentRunner.authenticate(). */
|
|
48
|
+
export interface AuthenticateOptions extends AuthProviderRoutingOptions {
|
|
49
|
+
/** Authentication method id advertised by runner.authMethods(). */
|
|
50
|
+
methodId: AuthenticateRequest["methodId"];
|
|
51
|
+
}
|
|
52
|
+
/** Options for AcpAgentRunner.listProviders(). */
|
|
53
|
+
export interface ListProvidersOptions extends AuthProviderRoutingOptions {
|
|
54
|
+
}
|
|
55
|
+
/** Options for AcpAgentRunner.setProvider(). */
|
|
56
|
+
export interface SetProviderOptions extends AuthProviderRoutingOptions {
|
|
57
|
+
providerId: SetProviderRequest["providerId"];
|
|
58
|
+
apiType: SetProviderRequest["apiType"];
|
|
59
|
+
baseUrl: SetProviderRequest["baseUrl"];
|
|
60
|
+
headers?: SetProviderRequest["headers"];
|
|
61
|
+
}
|
|
62
|
+
/** Options for AcpAgentRunner.disableProvider(). */
|
|
63
|
+
export interface DisableProviderOptions extends AuthProviderRoutingOptions {
|
|
64
|
+
providerId: DisableProviderRequest["providerId"];
|
|
65
|
+
}
|
|
66
|
+
/** Options for AcpAgentRunner.logout(). */
|
|
67
|
+
export interface LogoutOptions extends AuthProviderRoutingOptions {
|
|
68
|
+
}
|
|
36
69
|
/** Options for AcpAgentRunner.loadSession() and resumeSession(). */
|
|
37
70
|
export interface ReattachSessionOptions extends InteractiveSessionOptions {
|
|
38
71
|
/** Existing backend session id to route before the lifecycle request is sent. */
|
|
@@ -99,6 +132,18 @@ export declare class AcpAgentRunner implements AgentRunner {
|
|
|
99
132
|
* is one).
|
|
100
133
|
*/
|
|
101
134
|
openSession(opts: InteractiveSessionOptions): Promise<InteractiveSession>;
|
|
135
|
+
/** Return the selected backend's initialize-advertised authentication methods. */
|
|
136
|
+
authMethods(opts?: AuthMethodsOptions): Promise<AuthMethod[]>;
|
|
137
|
+
/** Drive ACP authenticate on the selected backend. */
|
|
138
|
+
authenticate(opts: AuthenticateOptions): Promise<AuthenticateResponse | void>;
|
|
139
|
+
/** List configurable providers from the selected backend. */
|
|
140
|
+
listProviders(opts?: ListProvidersOptions): Promise<ListProvidersResponse>;
|
|
141
|
+
/** Configure one provider on the selected backend. */
|
|
142
|
+
setProvider(opts: SetProviderOptions): Promise<SetProviderResponse | void>;
|
|
143
|
+
/** Disable one provider on the selected backend. */
|
|
144
|
+
disableProvider(opts: DisableProviderOptions): Promise<DisableProviderResponse | void>;
|
|
145
|
+
/** Logout through the selected backend. */
|
|
146
|
+
logout(opts?: LogoutOptions): Promise<LogoutResponse | void>;
|
|
102
147
|
/** List persisted ACP sessions from the selected backend. */
|
|
103
148
|
listSessions(opts?: ListSessionsOptions): Promise<ListSessionsResponse>;
|
|
104
149
|
/** Delete a persisted ACP session from the selected backend. */
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAA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C;IA2G1B;qGACiG;IAC3F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAShB,wBAAwB;IA+DtC,OAAO,CAAC,yBAAyB;IAWjC;kGAC8F;IAC9F,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;IAMtB,gGAAgG;IAChG,OAAO,CAAC,WAAW;CAGpB;AAED;;;qDAGqD;AACrD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAE1E;AAsDD;;;;oCAIoC;AACpC,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAM1G"}
|
package/dist/runner.js
CHANGED
|
@@ -98,6 +98,137 @@ export class AcpAgentRunner {
|
|
|
98
98
|
async openSession(opts) {
|
|
99
99
|
return this.createInteractiveSession(opts, "openSession", (connection, prepared) => connection.openSession(prepared.sessionOptions));
|
|
100
100
|
}
|
|
101
|
+
/** Return the selected backend's initialize-advertised authentication methods. */
|
|
102
|
+
async authMethods(opts = {}) {
|
|
103
|
+
if (this.disposed)
|
|
104
|
+
throw new Error("ACP agent runner is disposed");
|
|
105
|
+
const backend = selectBackend(opts, this.backends);
|
|
106
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
107
|
+
try {
|
|
108
|
+
if (this.disposed)
|
|
109
|
+
throw new Error("ACP agent runner is disposed");
|
|
110
|
+
return await connection.authMethods();
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
await disposeBestEffort(connection);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Drive ACP authenticate on the selected backend. */
|
|
117
|
+
async authenticate(opts) {
|
|
118
|
+
if (this.disposed)
|
|
119
|
+
throw new Error("ACP agent runner is disposed");
|
|
120
|
+
validateRequiredString(opts.methodId, opts.label, "authenticate", "methodId");
|
|
121
|
+
opts.signal?.throwIfAborted();
|
|
122
|
+
const backend = selectBackend(opts, this.backends);
|
|
123
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
124
|
+
try {
|
|
125
|
+
const request = {
|
|
126
|
+
methodId: opts.methodId,
|
|
127
|
+
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
128
|
+
};
|
|
129
|
+
const response = await connection.authenticate(request, opts.label);
|
|
130
|
+
opts.signal?.throwIfAborted();
|
|
131
|
+
if (this.disposed)
|
|
132
|
+
throw new Error("ACP agent runner is disposed");
|
|
133
|
+
return response;
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
await disposeBestEffort(connection);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** List configurable providers from the selected backend. */
|
|
140
|
+
async listProviders(opts = {}) {
|
|
141
|
+
if (this.disposed)
|
|
142
|
+
throw new Error("ACP agent runner is disposed");
|
|
143
|
+
opts.signal?.throwIfAborted();
|
|
144
|
+
const backend = selectBackend(opts, this.backends);
|
|
145
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
146
|
+
try {
|
|
147
|
+
const request = {
|
|
148
|
+
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
149
|
+
};
|
|
150
|
+
const response = await connection.listProviders(request, opts.label);
|
|
151
|
+
opts.signal?.throwIfAborted();
|
|
152
|
+
if (this.disposed)
|
|
153
|
+
throw new Error("ACP agent runner is disposed");
|
|
154
|
+
return response;
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
await disposeBestEffort(connection);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Configure one provider on the selected backend. */
|
|
161
|
+
async setProvider(opts) {
|
|
162
|
+
if (this.disposed)
|
|
163
|
+
throw new Error("ACP agent runner is disposed");
|
|
164
|
+
validateRequiredString(opts.providerId, opts.label, "setProvider", "providerId");
|
|
165
|
+
validateRequiredString(opts.apiType, opts.label, "setProvider", "apiType");
|
|
166
|
+
validateRequiredString(opts.baseUrl, opts.label, "setProvider", "baseUrl");
|
|
167
|
+
opts.signal?.throwIfAborted();
|
|
168
|
+
const backend = selectBackend(opts, this.backends);
|
|
169
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
170
|
+
try {
|
|
171
|
+
const request = {
|
|
172
|
+
providerId: opts.providerId,
|
|
173
|
+
apiType: opts.apiType,
|
|
174
|
+
baseUrl: opts.baseUrl,
|
|
175
|
+
...(opts.headers ? { headers: opts.headers } : {}),
|
|
176
|
+
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
177
|
+
};
|
|
178
|
+
const response = await connection.setProvider(request, opts.label);
|
|
179
|
+
opts.signal?.throwIfAborted();
|
|
180
|
+
if (this.disposed)
|
|
181
|
+
throw new Error("ACP agent runner is disposed");
|
|
182
|
+
return response;
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
await disposeBestEffort(connection);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Disable one provider on the selected backend. */
|
|
189
|
+
async disableProvider(opts) {
|
|
190
|
+
if (this.disposed)
|
|
191
|
+
throw new Error("ACP agent runner is disposed");
|
|
192
|
+
validateRequiredString(opts.providerId, opts.label, "disableProvider", "providerId");
|
|
193
|
+
opts.signal?.throwIfAborted();
|
|
194
|
+
const backend = selectBackend(opts, this.backends);
|
|
195
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
196
|
+
try {
|
|
197
|
+
const request = {
|
|
198
|
+
providerId: opts.providerId,
|
|
199
|
+
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
200
|
+
};
|
|
201
|
+
const response = await connection.disableProvider(request, opts.label);
|
|
202
|
+
opts.signal?.throwIfAborted();
|
|
203
|
+
if (this.disposed)
|
|
204
|
+
throw new Error("ACP agent runner is disposed");
|
|
205
|
+
return response;
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
await disposeBestEffort(connection);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** Logout through the selected backend. */
|
|
212
|
+
async logout(opts = {}) {
|
|
213
|
+
if (this.disposed)
|
|
214
|
+
throw new Error("ACP agent runner is disposed");
|
|
215
|
+
opts.signal?.throwIfAborted();
|
|
216
|
+
const backend = selectBackend(opts, this.backends);
|
|
217
|
+
const connection = this.createDedicatedConnection(backend, () => undefined);
|
|
218
|
+
try {
|
|
219
|
+
const request = {
|
|
220
|
+
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
221
|
+
};
|
|
222
|
+
const response = await connection.logout(request, opts.label);
|
|
223
|
+
opts.signal?.throwIfAborted();
|
|
224
|
+
if (this.disposed)
|
|
225
|
+
throw new Error("ACP agent runner is disposed");
|
|
226
|
+
return response;
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
await disposeBestEffort(connection);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
101
232
|
/** List persisted ACP sessions from the selected backend. */
|
|
102
233
|
async listSessions(opts = {}) {
|
|
103
234
|
if (this.disposed)
|
|
@@ -180,22 +311,24 @@ export class AcpAgentRunner {
|
|
|
180
311
|
registry,
|
|
181
312
|
signal: opts.signal,
|
|
182
313
|
});
|
|
183
|
-
|
|
314
|
+
let session;
|
|
184
315
|
try {
|
|
316
|
+
session = await this.pool.acquire(prepared.backend, prepared.sessionOptions);
|
|
317
|
+
const activeSession = session;
|
|
185
318
|
opts.signal?.throwIfAborted();
|
|
186
319
|
// For a CUSTOM backend chosen by its registered name, the name itself is routing, not a
|
|
187
320
|
// model id: "browser" selects nothing; "browser/foo" selects "foo". Built-ins get the
|
|
188
321
|
// full spec unchanged (their catalogs match provider-prefixed and bare ids).
|
|
189
|
-
await applyModelSelection(
|
|
322
|
+
await applyModelSelection(activeSession, prepared.modelSpec, opts);
|
|
190
323
|
opts.signal?.throwIfAborted();
|
|
191
324
|
if (opts.mode)
|
|
192
|
-
await
|
|
325
|
+
await activeSession.setMode(opts.mode);
|
|
193
326
|
const text = buildRunPrompt(prompt, opts, schema, prepared.backend);
|
|
194
327
|
const initialPrompt = opts.images && opts.images.length > 0 ? promptWithImages(text, opts.images) : text;
|
|
195
328
|
// Generic turn-scoped _meta passthrough merged UNDER the backend-computed keys (e.g. the
|
|
196
329
|
// outputSchema forward when a schema is set) — user meta never clobbers the schema channel.
|
|
197
330
|
const promptMeta = mergeTurnMeta(opts.promptMeta, prepared.backend.promptMeta(schema));
|
|
198
|
-
const response = await
|
|
331
|
+
const response = await activeSession.prompt(initialPrompt, promptMeta);
|
|
199
332
|
opts.signal?.throwIfAborted();
|
|
200
333
|
// Inspect the turn's stop reason BEFORE the text/schema path: a refusal or truncation
|
|
201
334
|
// must surface distinctly here, never be misread as empty output or burned through the
|
|
@@ -204,13 +337,13 @@ export class AcpAgentRunner {
|
|
|
204
337
|
if (schema) {
|
|
205
338
|
const structuredSession = {
|
|
206
339
|
prompt: async (repromptText) => {
|
|
207
|
-
const repromptResponse = await
|
|
340
|
+
const repromptResponse = await activeSession.prompt(repromptText, promptMeta);
|
|
208
341
|
// A repair turn that refuses / truncates / cancels must also surface distinctly
|
|
209
342
|
// instead of silently continuing the ladder.
|
|
210
343
|
assertNormalStopReason(repromptResponse.stopReason, opts.label);
|
|
211
344
|
},
|
|
212
|
-
lastText: () =>
|
|
213
|
-
tryNative: () => prepared.backend.nativeStructured(
|
|
345
|
+
lastText: () => activeSession.currentTurnText(),
|
|
346
|
+
tryNative: () => prepared.backend.nativeStructured(activeSession),
|
|
214
347
|
};
|
|
215
348
|
const result = await resolveStructuredOutput(structuredSession, schema, {
|
|
216
349
|
maxSchemaRetries: opts.maxSchemaRetries,
|
|
@@ -219,7 +352,7 @@ export class AcpAgentRunner {
|
|
|
219
352
|
});
|
|
220
353
|
return result;
|
|
221
354
|
}
|
|
222
|
-
const finalText =
|
|
355
|
+
const finalText = activeSession.currentTurnText().trim();
|
|
223
356
|
if (!finalText) {
|
|
224
357
|
throw new WorkflowError("Subagent produced no assistant output", WorkflowErrorCode.AGENT_EMPTY_OUTPUT, {
|
|
225
358
|
recoverable: true,
|
|
@@ -232,28 +365,34 @@ export class AcpAgentRunner {
|
|
|
232
365
|
// Abort is the engine's concern (throwIfAborted before/after the call) — re-throw it raw.
|
|
233
366
|
if (opts.signal?.aborted)
|
|
234
367
|
throw error;
|
|
235
|
-
throw mapThrownError(error,
|
|
368
|
+
throw mapThrownError(error, {
|
|
369
|
+
label: opts.label,
|
|
370
|
+
backendId: prepared.backend.id,
|
|
371
|
+
authMethods: session?.capabilities?.authMethods,
|
|
372
|
+
});
|
|
236
373
|
}
|
|
237
374
|
finally {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
375
|
+
if (session) {
|
|
376
|
+
// Read real usage on BOTH success and error so partial usage is never lost.
|
|
377
|
+
try {
|
|
378
|
+
opts.onUsage?.(session.usage.toAgentUsage());
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
// usage is best-effort; never let it mask the real result/error.
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
opts.onHistory?.(session.history);
|
|
385
|
+
}
|
|
386
|
+
catch {
|
|
387
|
+
// history is diagnostic only.
|
|
388
|
+
}
|
|
389
|
+
// Release the SESSION (best-effort session/close) WITHOUT killing the pooled process.
|
|
390
|
+
try {
|
|
391
|
+
await session.release();
|
|
392
|
+
}
|
|
393
|
+
catch {
|
|
394
|
+
// release is best-effort (session already untracked); never mask the real result/error.
|
|
395
|
+
}
|
|
257
396
|
}
|
|
258
397
|
}
|
|
259
398
|
}
|
|
@@ -320,7 +459,13 @@ export class AcpAgentRunner {
|
|
|
320
459
|
// best-effort: lifecycle setup failed, so teardown must never mask the real error.
|
|
321
460
|
}
|
|
322
461
|
await disposeBestEffort(connection);
|
|
323
|
-
|
|
462
|
+
if (opts.signal?.aborted)
|
|
463
|
+
throw error;
|
|
464
|
+
throw mapThrownError(error, {
|
|
465
|
+
label: opts.label,
|
|
466
|
+
backendId: prepared.backend.id,
|
|
467
|
+
authMethods: connection.capabilities?.authMethods,
|
|
468
|
+
});
|
|
324
469
|
}
|
|
325
470
|
}
|
|
326
471
|
createDedicatedConnection(backend, onDead) {
|
|
@@ -491,8 +636,11 @@ function validateOptionalLifecycleCwd(cwd, label, methodName) {
|
|
|
491
636
|
validateInteractiveCwd(cwd, label, methodName);
|
|
492
637
|
}
|
|
493
638
|
function validateLifecycleSessionId(sessionId, label, methodName) {
|
|
494
|
-
|
|
495
|
-
|
|
639
|
+
validateRequiredString(sessionId, label, methodName, "sessionId");
|
|
640
|
+
}
|
|
641
|
+
function validateRequiredString(value, label, methodName, fieldName) {
|
|
642
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
643
|
+
throw new WorkflowError(`${methodName} requires ${fieldName} to be a non-empty string`, WorkflowErrorCode.SCRIPT_VALIDATION_ERROR, { recoverable: false, agentLabel: label });
|
|
496
644
|
}
|
|
497
645
|
}
|
|
498
646
|
async function disposeBestEffort(connection) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automatalabs/acp-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@agentclientprotocol/claude-agent-acp": "0.56.0",
|
|
32
32
|
"@automatalabs/codex-acp": "1.4.0",
|
|
33
33
|
"typebox": "1.3.2",
|
|
34
|
-
"@automatalabs/shared-types": "0.
|
|
34
|
+
"@automatalabs/shared-types": "0.11.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -b",
|