@mono-agent/agent-runtime 0.17.1 → 0.18.1
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/MIGRATION.md +46 -3
- package/README.md +107 -13
- package/package.json +7 -2
- package/src/ai/failure.js +2 -1
- package/src/ai/index.js +2 -0
- package/src/ai/providers/acp-client.js +1149 -0
- package/src/ai/providers/acp-privacy.js +124 -0
- package/src/ai/providers/acp-public.js +21 -0
- package/src/ai/providers/acp-session-tokens.js +282 -0
- package/src/ai/providers/acp-transport.js +356 -0
- package/src/ai/providers/acp.js +539 -0
- package/src/ai/runtime/capabilities.js +16 -0
- package/src/ai/runtime/model-refs.js +20 -1
- package/src/ai/runtime/registry.js +6 -0
- package/src/ai/runtime/router.js +4 -1
- package/src/ai/types.js +11 -5
- package/src/runtime.js +5 -2
- package/types/ai/failure.d.ts +2 -2
- package/types/ai/index.d.ts +2 -0
- package/types/ai/providers/acp-client.d.ts +227 -0
- package/types/ai/providers/acp-privacy.d.ts +25 -0
- package/types/ai/providers/acp-public.d.ts +7 -0
- package/types/ai/providers/acp-session-tokens.d.ts +41 -0
- package/types/ai/providers/acp-transport.d.ts +45 -0
- package/types/ai/providers/acp.d.ts +93 -0
- package/types/ai/runtime/capabilities.d.ts +21 -0
- package/types/ai/types.d.ts +39 -9
package/src/ai/types.js
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
// documents the values active runtimes currently produce.
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @typedef {"claude" | "pi" | "codex" | "opencode" | (string & {})} RuntimeSdkId
|
|
19
|
+
* @typedef {"claude" | "pi" | "codex" | "opencode" | "acp" | (string & {})} RuntimeSdkId
|
|
20
20
|
* Canonical active runtime id. See ACTIVE_RUNTIME_KINDS (model-refs.js) for
|
|
21
21
|
* the enforced-at-runtime vocabulary.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @typedef {"claude" | "claude-code" | "codex-app" | "opencode-app" | "pi" | (string & {})} RuntimeBridgeId
|
|
25
|
+
* @typedef {"claude" | "claude-code" | "codex-app" | "opencode-app" | "pi" | "acp-stdio" | (string & {})} RuntimeBridgeId
|
|
26
26
|
* Registry bridge id (distinct from RuntimeSdkId: a single sdk can be served
|
|
27
27
|
* by more than one bridge, e.g. sdk "claude" is served by both the "claude"
|
|
28
28
|
* SDK bridge and the "claude-code" CLI bridge). See
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
* @typedef {Object} RuntimeRunOptions
|
|
134
134
|
* The options object a host passes to `createRuntime(host).run(systemPrompt, options)`.
|
|
135
135
|
* @property {RuntimeModelRef} model Resolved model reference; see parseRuntimeModelReference.
|
|
136
|
-
* @property {
|
|
136
|
+
* @property {"sdk"|"cli"|"acp"} [executionMode] "sdk" (default), "cli", or "acp"; selects which bridge variant handles the model.
|
|
137
137
|
* @property {string} [sessionId] Host conversation/session key for resumable bridges.
|
|
138
138
|
* @property {string} [providerSessionId] Provider-owned resume id for resumable bridges.
|
|
139
139
|
* @property {typeof import("@anthropic-ai/claude-agent-sdk").query} [claudeAgentQuery] Advanced programmatic/test seam for the Claude SDK route; omitted runs use the runtime's pinned SDK query implementation.
|
|
@@ -163,6 +163,9 @@
|
|
|
163
163
|
* @property {RuntimeToolLimits} [toolLimits] Typed per-run tool-output limits (supported replacement for the deprecated `settings` tool keys).
|
|
164
164
|
* @property {RuntimeCompactionPolicy} [compaction] Typed per-run compaction policy (supported replacement for the deprecated `settings` compaction keys).
|
|
165
165
|
* @property {RuntimePromptOverrides} [prompts] Per-run prompt-fragment overrides (run wins over the host default).
|
|
166
|
+
* @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Per-run ACP profile resolver; wins over the host default.
|
|
167
|
+
* @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Per-run ACP permission/elicitation callback; wins over the host default.
|
|
168
|
+
* @property {Uint8Array} [acpSessionTokenKey] Host-owned 32-byte key for confidential authenticated ACP session handles. Required for every ACP task run.
|
|
166
169
|
* @property {{backend?: "auto"|"searxng"|"keyless", endpoint?: string}} [webSearchConfig] Run-scoped WebSearch backend configuration.
|
|
167
170
|
* @property {{render?: "never"|"auto", browserCommand?: string}} [webFetchConfig] Run-scoped WebFetch extraction/render configuration.
|
|
168
171
|
* @property {"sequential"|"safe-parallel"} [piToolExecutionMode] Pi built-in tool scheduling mode. Safe parallelism is the default.
|
|
@@ -180,7 +183,7 @@
|
|
|
180
183
|
|
|
181
184
|
/**
|
|
182
185
|
* @typedef {RuntimeRunOptions
|
|
183
|
-
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
|
|
186
|
+
* & Pick<AgentRuntimeHostOptions, "resolveCustomPricing" | "resolvePiApiKey" | "resolveAcpProfile" | "onAcpInteractionRequest" | "acpSessionTokenKey" | "persistArtifact" | "onCompactionRecorded" | "onToolApprovalRequest" | "toolRiskTiers" | "approvalDefaultRiskTier" | "approvalTimeoutMs" | "approvalAlwaysAllowTools">
|
|
184
187
|
* & {runtimeBrand: import('../runtime-brand.js').RuntimeBrand, toolContext?: import('../agent/tools/shared/tool-context.js').ToolContext, observerHub: {emit: (event: RuntimeEvent) => void, flush: () => Promise<void>}}
|
|
185
188
|
* } RuntimeRequest
|
|
186
189
|
* The request shape a bridge's `execute(systemPrompt, req)` receives as its
|
|
@@ -360,6 +363,9 @@
|
|
|
360
363
|
* @property {*} [runtimeBrand] See resolveRuntimeBrand (runtime-brand.js); accepts a partial RuntimeBrand.
|
|
361
364
|
* @property {(parsed: {sdk: (string|null), provider?: string, model: string}) => (import('./cost.js').NormalizedPricing|null)} [resolveCustomPricing] See resolvePricing (ai/cost.js).
|
|
362
365
|
* @property {import('../pi-auth.js').PiApiKeyResolver} [resolvePiApiKey] See createPiOAuthApiKeyResolver (pi-auth.js) for a ready-made implementation.
|
|
366
|
+
* @property {import('./providers/acp-client.js').AcpClientHostOptions["resolveAcpProfile"]} [resolveAcpProfile] Default ACP profile resolver; a per-run callback wins.
|
|
367
|
+
* @property {import('./providers/acp-client.js').AcpClientHostOptions["onAcpInteractionRequest"]} [onAcpInteractionRequest] Default ACP interaction callback; a per-run callback wins.
|
|
368
|
+
* @property {Uint8Array} [acpSessionTokenKey] Default host-owned 32-byte key for confidential authenticated ACP session handles.
|
|
363
369
|
* @property {(artifact: {filename: string, buffer: Buffer, toolName: string, toolUseId: (string|null)}) => (string|null)} [persistArtifact]
|
|
364
370
|
* @property {(record: CompactionRecordedPayload) => void} [onCompactionRecorded]
|
|
365
371
|
* @property {(payload: ApprovalRequestPayload) => Promise<ApprovalDecision>} [onToolApprovalRequest]
|
|
@@ -395,4 +401,4 @@
|
|
|
395
401
|
* @property {() => Promise<void>} disposeAllSessions
|
|
396
402
|
*/
|
|
397
403
|
|
|
398
|
-
export const PROVIDER_KIND_VALUES = ["claude", "pi", "codex", "opencode"];
|
|
404
|
+
export const PROVIDER_KIND_VALUES = ["claude", "pi", "codex", "opencode", "acp"];
|
package/src/runtime.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// method that resolves the right provider bridge based on `options.model` +
|
|
9
9
|
// `options.executionMode`.
|
|
10
10
|
//
|
|
11
|
-
// The runtime registry contains a static table for the
|
|
12
|
-
// (
|
|
11
|
+
// The runtime registry contains a static table for the six built-in bridges
|
|
12
|
+
// (ACP, Claude SDK/CLI, Pi-native, Codex app-server, OpenCode app-server) and lazily imports
|
|
13
13
|
// the matching implementation only when a run selects it. Hosts that need finer
|
|
14
14
|
// control can keep using the named exports (resolveRuntimeBridge,
|
|
15
15
|
// generateClaudeResponse, etc.) directly.
|
|
@@ -53,6 +53,9 @@ import { instrumentLiveInputAppliedEvents } from "./ai/runtime/live-input-events
|
|
|
53
53
|
const HOST_KEYS = [
|
|
54
54
|
"resolveCustomPricing",
|
|
55
55
|
"resolvePiApiKey",
|
|
56
|
+
"resolveAcpProfile",
|
|
57
|
+
"onAcpInteractionRequest",
|
|
58
|
+
"acpSessionTokenKey",
|
|
56
59
|
"persistArtifact",
|
|
57
60
|
"onCompactionRecorded",
|
|
58
61
|
"onToolApprovalRequest",
|
package/types/ai/failure.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export function createStderrTail({ limit }?: {
|
|
|
75
75
|
/**
|
|
76
76
|
* @typedef {"spawn" | "timeout" | "stall" | "context_limit" | "usage_limit" | "invalid_result"
|
|
77
77
|
* | "invalid_delegation" | "tool_failure" | "provider_unavailable"
|
|
78
|
-
* | "provider_unavailable_exhausted" | "provider_auth"
|
|
78
|
+
* | "provider_unavailable_exhausted" | "provider_auth" | "provider_protocol"
|
|
79
79
|
* | "skipped_capability_mismatch" | "cancelled" | "cancelled_user"
|
|
80
80
|
* | "cancelled_shutdown" | "cancelled_signal" | "abandoned"
|
|
81
81
|
* | "session_not_found" | "session_busy" | (string & {})} FailureKind
|
|
@@ -123,4 +123,4 @@ export type RetryableProviderFailureInfo = {
|
|
|
123
123
|
* Hosts (e.g. worklab's coordinator) validate against `FAILURE_KINDS` and may
|
|
124
124
|
* define additional kinds — accepting them at the type level is deliberate.
|
|
125
125
|
*/
|
|
126
|
-
export type FailureKind = "spawn" | "timeout" | "stall" | "context_limit" | "usage_limit" | "invalid_result" | "invalid_delegation" | "tool_failure" | "provider_unavailable" | "provider_unavailable_exhausted" | "provider_auth" | "skipped_capability_mismatch" | "cancelled" | "cancelled_user" | "cancelled_shutdown" | "cancelled_signal" | "abandoned" | "session_not_found" | "session_busy" | (string & {});
|
|
126
|
+
export type FailureKind = "spawn" | "timeout" | "stall" | "context_limit" | "usage_limit" | "invalid_result" | "invalid_delegation" | "tool_failure" | "provider_unavailable" | "provider_unavailable_exhausted" | "provider_auth" | "provider_protocol" | "skipped_capability_mismatch" | "cancelled" | "cancelled_user" | "cancelled_shutdown" | "cancelled_signal" | "abandoned" | "session_not_found" | "session_busy" | (string & {});
|
package/types/ai/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./runtime/model-refs.js";
|
|
2
2
|
export * from "./runtime/registry.js";
|
|
3
|
+
export * from "./providers/acp-public.js";
|
|
3
4
|
export { createSessionRegistry, disposeAllProviderSessions, disposeProviderSession, invalidateProviderSession, refreshProviderSession, syncProviderSession } from "./runtime/sessions.js";
|
|
4
5
|
export { createMetricsObserver, createObserverHub } from "./observer.js";
|
|
5
6
|
export { generatePiNativeResponse, piNativeRuntimeBridge } from "./providers/pi-native.js";
|
|
7
|
+
export { generateAcpResponse, acpRuntimeBridge } from "./providers/acp.js";
|
|
6
8
|
export { getPiBuiltinModel, listPiBuiltinModels, loginPiOAuth, reasoningLevelsForPiModel, resolvePiOAuthApiKey } from "./pi-interop.js";
|
|
7
9
|
export { CLAUDE_SDK_CATALOG_VERSION, createClaudeSdkDiscoveryIsolation, curatedClaudeSdkModels, discoverClaudeSdkModels, normalizeClaudeSdkCatalog, normalizeClaudeSdkModelId } from "./providers/claude-sdk-discovery.js";
|
|
8
10
|
export { buildCapabilitiesUsed, toolCompactionAppliedFromWarnings, UNKNOWN_CAPABILITY } from "./runtime/capabilities-used.js";
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open and initialize one owned ACP v1 stdio bridge process.
|
|
3
|
+
* @param {string} profileId
|
|
4
|
+
* @param {AcpClientHostOptions & {operation?: string}} options
|
|
5
|
+
*/
|
|
6
|
+
export function connectAcpProfile(profileId: string, options: AcpClientHostOptions & {
|
|
7
|
+
operation?: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
profileId: string;
|
|
10
|
+
descriptor: AcpProfileDescriptor & {
|
|
11
|
+
args: string[];
|
|
12
|
+
env: Record<string, string>;
|
|
13
|
+
configurationOwner: "client" | "agent";
|
|
14
|
+
workspaceOwner: "client" | "agent";
|
|
15
|
+
mcpOwner: "client" | "agent";
|
|
16
|
+
process: {
|
|
17
|
+
startupTimeoutMs: number;
|
|
18
|
+
requestTimeoutMs: number;
|
|
19
|
+
shutdownGraceMs: number;
|
|
20
|
+
killGraceMs: number;
|
|
21
|
+
stderrTailBytes: number;
|
|
22
|
+
maxLineBytes: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
initializeResult: any;
|
|
26
|
+
clientCapabilities: {
|
|
27
|
+
fs: {
|
|
28
|
+
readTextFile: boolean;
|
|
29
|
+
writeTextFile: boolean;
|
|
30
|
+
};
|
|
31
|
+
terminal: boolean;
|
|
32
|
+
};
|
|
33
|
+
hasCapability: (name: any) => boolean;
|
|
34
|
+
onSessionUpdate: (sessionId: any, listener: any) => () => void;
|
|
35
|
+
request: (method: string, params: any, requestOptions?: {
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
label?: string;
|
|
39
|
+
}) => Promise<any>;
|
|
40
|
+
authenticate(methodId: any): Promise<any>;
|
|
41
|
+
logout(): Promise<any>;
|
|
42
|
+
newSession(params: any): Promise<any>;
|
|
43
|
+
loadSession(params: any): Promise<any>;
|
|
44
|
+
resumeSession(params: any): Promise<any>;
|
|
45
|
+
closeSession(sessionId: any): Promise<any>;
|
|
46
|
+
listSessions(params?: {}): Promise<any>;
|
|
47
|
+
deleteSession(sessionId: any): Promise<any>;
|
|
48
|
+
setSessionMode(sessionId: any, modeId: any): Promise<any>;
|
|
49
|
+
setSessionConfigOption(sessionId: any, configId: any, value: any): Promise<any>;
|
|
50
|
+
cancel(sessionId: any): Promise<void>;
|
|
51
|
+
prompt(sessionId: any, prompt: any, promptOptions?: {}): Promise<any>;
|
|
52
|
+
close: () => Promise<void>;
|
|
53
|
+
}>;
|
|
54
|
+
/** @param {string} profileId @param {AcpClientHostOptions} options */
|
|
55
|
+
export function probeAcpProfile(profileId: string, options: AcpClientHostOptions): Promise<{
|
|
56
|
+
profileId: string;
|
|
57
|
+
protocolVersion: any;
|
|
58
|
+
agentInfo: any;
|
|
59
|
+
agentCapabilities: any;
|
|
60
|
+
authMethods: any;
|
|
61
|
+
}>;
|
|
62
|
+
/** @param {string} profileId @param {string} methodId @param {AcpClientHostOptions} options */
|
|
63
|
+
export function authenticateAcpProfile(profileId: string, methodId: string, options: AcpClientHostOptions): Promise<{
|
|
64
|
+
profileId: string;
|
|
65
|
+
methodId: string;
|
|
66
|
+
authenticated: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
/** @param {string} profileId @param {AcpClientHostOptions} options */
|
|
69
|
+
export function logoutAcpProfile(profileId: string, options: AcpClientHostOptions): Promise<{
|
|
70
|
+
profileId: string;
|
|
71
|
+
loggedOut: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} profileId
|
|
75
|
+
* @param {{cwd?: string|null, cursor?: string|null}} [request]
|
|
76
|
+
* @param {AcpClientHostOptions} [options]
|
|
77
|
+
* @returns {Promise<AcpSessionListResult>}
|
|
78
|
+
*/
|
|
79
|
+
export function listAcpSessions(profileId: string, request?: {
|
|
80
|
+
cwd?: string | null;
|
|
81
|
+
cursor?: string | null;
|
|
82
|
+
}, options?: AcpClientHostOptions): Promise<AcpSessionListResult>;
|
|
83
|
+
/** @param {string} providerSessionId @param {AcpClientHostOptions} options */
|
|
84
|
+
export function deleteAcpSession(providerSessionId: string, options: AcpClientHostOptions): Promise<{
|
|
85
|
+
profileId: string;
|
|
86
|
+
providerSessionId: string;
|
|
87
|
+
deleted: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Product-neutral description of one ACP stdio agent profile. The environment
|
|
91
|
+
* is exact/minimal: agent-runtime never spreads process.env into the child.
|
|
92
|
+
*/
|
|
93
|
+
export type AcpProfileDescriptor = {
|
|
94
|
+
command: string;
|
|
95
|
+
args?: ReadonlyArray<string>;
|
|
96
|
+
cwd?: string;
|
|
97
|
+
env?: Record<string, string>;
|
|
98
|
+
configurationOwner?: "client" | "agent";
|
|
99
|
+
workspaceOwner?: "client" | "agent";
|
|
100
|
+
mcpOwner?: "client" | "agent";
|
|
101
|
+
/**
|
|
102
|
+
* Absolute canonical workspace path; required for agent-owned workspaces.
|
|
103
|
+
*/
|
|
104
|
+
workspacePath?: string;
|
|
105
|
+
capabilityPolicy?: {
|
|
106
|
+
filesystem?: {
|
|
107
|
+
readTextFile?: boolean;
|
|
108
|
+
writeTextFile?: boolean;
|
|
109
|
+
};
|
|
110
|
+
terminal?: boolean;
|
|
111
|
+
auth?: {
|
|
112
|
+
terminal?: boolean;
|
|
113
|
+
};
|
|
114
|
+
elicitation?: {
|
|
115
|
+
form?: boolean;
|
|
116
|
+
url?: boolean;
|
|
117
|
+
};
|
|
118
|
+
sessionConfig?: {
|
|
119
|
+
boolean?: boolean;
|
|
120
|
+
};
|
|
121
|
+
mcp?: {
|
|
122
|
+
stdio?: boolean;
|
|
123
|
+
http?: boolean;
|
|
124
|
+
sse?: boolean;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
sessionConfig?: {
|
|
128
|
+
additionalDirectories?: ReadonlyArray<string>;
|
|
129
|
+
mcpServers?: ReadonlyArray<Record<string, unknown>>;
|
|
130
|
+
resumeStrategy?: "auto" | "load" | "resume";
|
|
131
|
+
modeId?: string;
|
|
132
|
+
configOptions?: Record<string, string | boolean>;
|
|
133
|
+
};
|
|
134
|
+
clientCallbacks?: {
|
|
135
|
+
requestPermission?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").RequestPermissionRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").RequestPermissionResponse> | import("@agentclientprotocol/sdk").RequestPermissionResponse;
|
|
136
|
+
createElicitation?: (request: AcpHostElicitationPayload, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").CreateElicitationResponse> | import("@agentclientprotocol/sdk").CreateElicitationResponse;
|
|
137
|
+
readTextFile?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").ReadTextFileRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").ReadTextFileResponse> | import("@agentclientprotocol/sdk").ReadTextFileResponse;
|
|
138
|
+
writeTextFile?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").WriteTextFileRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").WriteTextFileResponse> | import("@agentclientprotocol/sdk").WriteTextFileResponse;
|
|
139
|
+
createTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").CreateTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").CreateTerminalResponse> | import("@agentclientprotocol/sdk").CreateTerminalResponse;
|
|
140
|
+
terminalOutput?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").TerminalOutputRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").TerminalOutputResponse> | import("@agentclientprotocol/sdk").TerminalOutputResponse;
|
|
141
|
+
waitForTerminalExit?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").WaitForTerminalExitRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").WaitForTerminalExitResponse> | import("@agentclientprotocol/sdk").WaitForTerminalExitResponse;
|
|
142
|
+
killTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").KillTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").KillTerminalResponse> | import("@agentclientprotocol/sdk").KillTerminalResponse;
|
|
143
|
+
releaseTerminal?: (request: AcpHostSessionPayload<import("@agentclientprotocol/sdk").ReleaseTerminalRequest>, context: AcpCallbackContext) => Promise<import("@agentclientprotocol/sdk").ReleaseTerminalResponse> | import("@agentclientprotocol/sdk").ReleaseTerminalResponse;
|
|
144
|
+
sessionUpdate?: (notification: AcpHostSessionPayload<import("@agentclientprotocol/sdk").SessionNotification>, context: AcpCallbackContext) => Promise<void> | void;
|
|
145
|
+
elicitationComplete?: (notification: Omit<import("@agentclientprotocol/sdk").CompleteElicitationNotification, "_meta">, context: AcpCallbackContext) => Promise<void> | void;
|
|
146
|
+
};
|
|
147
|
+
process?: {
|
|
148
|
+
startupTimeoutMs?: number;
|
|
149
|
+
requestTimeoutMs?: number;
|
|
150
|
+
shutdownGraceMs?: number;
|
|
151
|
+
killGraceMs?: number;
|
|
152
|
+
stderrTailBytes?: number;
|
|
153
|
+
maxLineBytes?: number;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Opaque host metadata; never returned in diagnostics.
|
|
157
|
+
*/
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
};
|
|
160
|
+
export type AcpCallbackContext = {
|
|
161
|
+
profileId: string;
|
|
162
|
+
operation: string;
|
|
163
|
+
/**
|
|
164
|
+
* Opaque profile-bound session handle when the callback is session-scoped.
|
|
165
|
+
*/
|
|
166
|
+
providerSessionId?: string;
|
|
167
|
+
signal?: AbortSignal;
|
|
168
|
+
requestId?: unknown;
|
|
169
|
+
hostContext?: Record<string, unknown>;
|
|
170
|
+
};
|
|
171
|
+
export type WithoutSessionId<T> = T extends unknown ? Omit<T, "sessionId"> : never;
|
|
172
|
+
export type AcpHostSessionPayload<T> = T extends unknown ? Omit<T, "sessionId" | "_meta"> : never;
|
|
173
|
+
export type AcpHostElicitationPayload = WithoutSessionId<import("@agentclientprotocol/sdk").CreateElicitationRequest> & Pick<import("@agentclientprotocol/sdk").CreateElicitationRequest, "message" | "mode">;
|
|
174
|
+
export type AcpListedSession = {
|
|
175
|
+
/**
|
|
176
|
+
* Opaque runtime handle for resume/delete.
|
|
177
|
+
*/
|
|
178
|
+
providerSessionId: string;
|
|
179
|
+
cwd: string;
|
|
180
|
+
additionalDirectories?: ReadonlyArray<string>;
|
|
181
|
+
title?: string | null;
|
|
182
|
+
updatedAt?: string | null;
|
|
183
|
+
};
|
|
184
|
+
export type AcpSessionListResult = {
|
|
185
|
+
profileId: string;
|
|
186
|
+
sessions: AcpListedSession[];
|
|
187
|
+
/**
|
|
188
|
+
* Opaque runtime cursor; pass it back unchanged.
|
|
189
|
+
*/
|
|
190
|
+
nextCursor: string | null;
|
|
191
|
+
};
|
|
192
|
+
export type AcpPermissionInteractionPayload = WithoutSessionId<import("@agentclientprotocol/sdk").RequestPermissionRequest>;
|
|
193
|
+
/**
|
|
194
|
+
* `CreateElicitationRequest` includes a future-mode string index signature.
|
|
195
|
+
* Plain `Omit` preserves that openness but widens its named common fields to
|
|
196
|
+
* unknown, so restore the protocol's concrete common-field types explicitly.
|
|
197
|
+
*/
|
|
198
|
+
export type AcpElicitationInteractionPayload = WithoutSessionId<import("@agentclientprotocol/sdk").CreateElicitationRequest> & Pick<import("@agentclientprotocol/sdk").CreateElicitationRequest, "message" | "mode" | "_meta">;
|
|
199
|
+
export type AcpInteractionRequest = {
|
|
200
|
+
kind: "permission";
|
|
201
|
+
profileId: string;
|
|
202
|
+
payload: AcpPermissionInteractionPayload;
|
|
203
|
+
} | {
|
|
204
|
+
kind: "elicitation";
|
|
205
|
+
profileId: string;
|
|
206
|
+
payload: AcpElicitationInteractionPayload;
|
|
207
|
+
};
|
|
208
|
+
export type AcpClientHostOptions = {
|
|
209
|
+
resolveAcpProfile: (profileId: string, context?: Record<string, unknown>) => Promise<AcpProfileDescriptor | null | undefined> | AcpProfileDescriptor | null | undefined;
|
|
210
|
+
onAcpInteractionRequest?: (request: AcpInteractionRequest, context?: AcpCallbackContext) => Promise<unknown> | unknown;
|
|
211
|
+
sandbox?: import("../../agent/sandbox-seam.js").RuntimeSandbox;
|
|
212
|
+
sandboxPolicy?: import("../../agent/sandbox-seam.js").SandboxPolicy;
|
|
213
|
+
sandboxEngine?: import("../../agent/sandbox-seam.js").RuntimeSandboxEngine;
|
|
214
|
+
cwd?: string;
|
|
215
|
+
signal?: AbortSignal;
|
|
216
|
+
context?: Record<string, unknown>;
|
|
217
|
+
/**
|
|
218
|
+
* Host-owned 32-byte key required by operations that emit or consume opaque session handles.
|
|
219
|
+
*/
|
|
220
|
+
acpSessionTokenKey?: Uint8Array;
|
|
221
|
+
};
|
|
222
|
+
import { AcpClientError } from "./acp-session-tokens.js";
|
|
223
|
+
import { encodeAcpProviderSessionId } from "./acp-session-tokens.js";
|
|
224
|
+
import { validateAcpProfileId } from "./acp-session-tokens.js";
|
|
225
|
+
import { validateAcpProviderSessionId } from "./acp-session-tokens.js";
|
|
226
|
+
import { PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
|
|
227
|
+
export { AcpClientError, encodeAcpProviderSessionId, validateAcpProfileId, validateAcpProviderSessionId, PROTOCOL_VERSION as ACP_PROTOCOL_VERSION };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACP protocol session ids are connection state, not host-facing metadata.
|
|
3
|
+
* Remove their canonical keys, discard extension metadata, and redact copies
|
|
4
|
+
* embedded by an agent in otherwise public strings.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} value
|
|
7
|
+
* @param {ReadonlyArray<unknown>} [rawSecrets]
|
|
8
|
+
* @returns {{value: any, truncated: boolean}}
|
|
9
|
+
*/
|
|
10
|
+
export function sanitizeAcpHostValueWithStatus(value: unknown, rawSecrets?: ReadonlyArray<unknown>): {
|
|
11
|
+
value: any;
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compatibility wrapper for callback/list surfaces that intentionally accept
|
|
16
|
+
* a bounded representation. Protocol normalization should use the status form
|
|
17
|
+
* above so it can fail explicitly instead of consuming partial data.
|
|
18
|
+
*
|
|
19
|
+
* @param {unknown} value
|
|
20
|
+
* @param {ReadonlyArray<unknown>} [rawSecrets]
|
|
21
|
+
* @returns {any}
|
|
22
|
+
*/
|
|
23
|
+
export function sanitizeAcpHostValue(value: unknown, rawSecrets?: ReadonlyArray<unknown>): any;
|
|
24
|
+
/** @param {unknown} value @returns {string|null} */
|
|
25
|
+
export function ownAcpSessionUpdateKind(value: unknown): string | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type AcpProfileDescriptor = import("./acp-client.js").AcpProfileDescriptor;
|
|
2
|
+
export type AcpCallbackContext = import("./acp-client.js").AcpCallbackContext;
|
|
3
|
+
export type AcpInteractionRequest = import("./acp-client.js").AcpInteractionRequest;
|
|
4
|
+
export type AcpClientHostOptions = import("./acp-client.js").AcpClientHostOptions;
|
|
5
|
+
export type AcpListedSession = import("./acp-client.js").AcpListedSession;
|
|
6
|
+
export type AcpSessionListResult = import("./acp-client.js").AcpSessionListResult;
|
|
7
|
+
export { ACP_PROTOCOL_VERSION, AcpClientError, authenticateAcpProfile, deleteAcpSession, listAcpSessions, logoutAcpProfile, probeAcpProfile, validateAcpProfileId, validateAcpProviderSessionId } from "./acp-client.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @param {string} profileId @returns {string} */
|
|
2
|
+
export function validateAcpProfileId(profileId: string): string;
|
|
3
|
+
/** @param {unknown} key @returns {Buffer} */
|
|
4
|
+
export function validateAcpSessionTokenKey(key: unknown): Buffer;
|
|
5
|
+
/** @param {string} profileId @param {string} sessionId @param {Uint8Array} key */
|
|
6
|
+
export function encodeAcpProviderSessionId(profileId: string, sessionId: string, key: Uint8Array): string;
|
|
7
|
+
/**
|
|
8
|
+
* Internal protocol-state decoder. This module is not a package export.
|
|
9
|
+
* @param {string} providerSessionId
|
|
10
|
+
* @param {Uint8Array} key
|
|
11
|
+
*/
|
|
12
|
+
export function decodeAcpProviderSessionId(providerSessionId: string, key: Uint8Array): {
|
|
13
|
+
profileId: string;
|
|
14
|
+
sessionId: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Validate an opaque provider-session handle and its profile binding without
|
|
18
|
+
* exposing the remote agent's protocol session id.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} providerSessionId
|
|
21
|
+
* @param {string} expectedProfileId
|
|
22
|
+
* @param {Uint8Array} key Host-owned 32-byte ACP session-token key.
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
export function validateAcpProviderSessionId(providerSessionId: string, expectedProfileId: string, key: Uint8Array): string;
|
|
26
|
+
/** @param {string} profileId @param {string} cursor @param {Uint8Array} key */
|
|
27
|
+
export function encodeAcpSessionCursor(profileId: string, cursor: string, key: Uint8Array): string;
|
|
28
|
+
/** @param {string} profileId @param {unknown} cursor @param {Uint8Array} key */
|
|
29
|
+
export function decodeAcpSessionCursor(profileId: string, cursor: unknown, key: Uint8Array): string;
|
|
30
|
+
export class AcpClientError extends Error {
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} code
|
|
33
|
+
* @param {string} message
|
|
34
|
+
* @param {Record<string, unknown>} [details]
|
|
35
|
+
*/
|
|
36
|
+
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
37
|
+
code: string;
|
|
38
|
+
details: {
|
|
39
|
+
code: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open one SDK connection inside an async context that strips payload-bearing
|
|
3
|
+
* SDK console arguments. The SDK starts its detached receive loop during
|
|
4
|
+
* `connect`, so descendants retain this scope without muting concurrent host
|
|
5
|
+
* work or other ACP connections.
|
|
6
|
+
*
|
|
7
|
+
* @template {{closed: Promise<unknown>}} T
|
|
8
|
+
* @param {() => T} connect
|
|
9
|
+
* @returns {T}
|
|
10
|
+
*/
|
|
11
|
+
export function connectWithSafeAcpSdkDiagnostics<T extends {
|
|
12
|
+
closed: Promise<unknown>;
|
|
13
|
+
}>(connect: () => T): T;
|
|
14
|
+
/**
|
|
15
|
+
* @param {unknown} value
|
|
16
|
+
* @param {number} [fallback]
|
|
17
|
+
* @returns {number}
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeAcpMaxLineBytes(value: unknown, fallback?: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Build the Stream shape consumed by @agentclientprotocol/sdk from a child
|
|
22
|
+
* process's stdin/stdout. Both inbound and outbound payloads are capped.
|
|
23
|
+
*
|
|
24
|
+
* @param {{stdin: import('node:stream').Writable|null, stdout: import('node:stream').Readable|null}} child
|
|
25
|
+
* @param {{maxLineBytes?: number}} [options]
|
|
26
|
+
* @returns {{readable: ReadableStream<any>, writable: WritableStream<any>}}
|
|
27
|
+
*/
|
|
28
|
+
export function createBoundedAcpStdioStream(child: {
|
|
29
|
+
stdin: import("node:stream").Writable | null;
|
|
30
|
+
stdout: import("node:stream").Readable | null;
|
|
31
|
+
}, options?: {
|
|
32
|
+
maxLineBytes?: number;
|
|
33
|
+
}): {
|
|
34
|
+
readable: ReadableStream<any>;
|
|
35
|
+
writable: WritableStream<any>;
|
|
36
|
+
};
|
|
37
|
+
export class AcpTransportError extends Error {
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} code
|
|
40
|
+
* @param {string} message
|
|
41
|
+
*/
|
|
42
|
+
constructor(code: string, message: string);
|
|
43
|
+
code: string;
|
|
44
|
+
}
|
|
45
|
+
export const ACP_DEFAULT_MAX_LINE_BYTES: number;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime bridge for one ACP v1 profile turn.
|
|
3
|
+
* @param {string} systemPrompt
|
|
4
|
+
* @param {any} req
|
|
5
|
+
*/
|
|
6
|
+
export function generateAcpResponse(systemPrompt: string, req: any): Promise<{
|
|
7
|
+
text: string;
|
|
8
|
+
thinking: string;
|
|
9
|
+
events: any[];
|
|
10
|
+
usage: {
|
|
11
|
+
total_tokens: any;
|
|
12
|
+
context_window: any;
|
|
13
|
+
cost: any;
|
|
14
|
+
} | {
|
|
15
|
+
total_tokens?: undefined;
|
|
16
|
+
context_window?: undefined;
|
|
17
|
+
cost?: undefined;
|
|
18
|
+
};
|
|
19
|
+
durationMs: number;
|
|
20
|
+
numTurns: number;
|
|
21
|
+
model: any;
|
|
22
|
+
effort: any;
|
|
23
|
+
sdk: string;
|
|
24
|
+
cancelled: boolean;
|
|
25
|
+
error: string;
|
|
26
|
+
failureKind: string;
|
|
27
|
+
providerSessionId: string;
|
|
28
|
+
runtimeWarnings: any[];
|
|
29
|
+
diagnostics: {
|
|
30
|
+
acp_protocol_version: any;
|
|
31
|
+
acp_profile_id: any;
|
|
32
|
+
acp_session_id_encoded: boolean;
|
|
33
|
+
acp_stop_reason: any;
|
|
34
|
+
acp_resume_method: string;
|
|
35
|
+
acp_mode_applied: boolean;
|
|
36
|
+
acp_config_options_applied: any[];
|
|
37
|
+
};
|
|
38
|
+
capabilitiesUsed: {
|
|
39
|
+
session_resume: boolean;
|
|
40
|
+
session_load: boolean;
|
|
41
|
+
session_config: boolean;
|
|
42
|
+
mcp: boolean;
|
|
43
|
+
};
|
|
44
|
+
structuredResult: any;
|
|
45
|
+
structuredResultSource: any;
|
|
46
|
+
errorDetails?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
text: string;
|
|
49
|
+
thinking: string;
|
|
50
|
+
events: any[];
|
|
51
|
+
usage: {
|
|
52
|
+
total_tokens?: undefined;
|
|
53
|
+
context_window?: undefined;
|
|
54
|
+
cost?: undefined;
|
|
55
|
+
};
|
|
56
|
+
durationMs: number;
|
|
57
|
+
numTurns: number;
|
|
58
|
+
model: any;
|
|
59
|
+
effort: any;
|
|
60
|
+
sdk: string;
|
|
61
|
+
cancelled: boolean;
|
|
62
|
+
error: any;
|
|
63
|
+
errorDetails: {
|
|
64
|
+
acp_error_code: any;
|
|
65
|
+
};
|
|
66
|
+
failureKind: string;
|
|
67
|
+
providerSessionId: string;
|
|
68
|
+
runtimeWarnings: any[];
|
|
69
|
+
diagnostics: {
|
|
70
|
+
acp_profile_id: string;
|
|
71
|
+
acp_session_id_encoded: boolean;
|
|
72
|
+
acp_stop_reason: string;
|
|
73
|
+
acp_protocol_version?: undefined;
|
|
74
|
+
acp_resume_method?: undefined;
|
|
75
|
+
acp_mode_applied?: undefined;
|
|
76
|
+
acp_config_options_applied?: undefined;
|
|
77
|
+
};
|
|
78
|
+
capabilitiesUsed: {
|
|
79
|
+
session_resume?: undefined;
|
|
80
|
+
session_load?: undefined;
|
|
81
|
+
session_config?: undefined;
|
|
82
|
+
mcp?: undefined;
|
|
83
|
+
};
|
|
84
|
+
structuredResult: any;
|
|
85
|
+
structuredResultSource: any;
|
|
86
|
+
}>;
|
|
87
|
+
export namespace acpRuntimeBridge {
|
|
88
|
+
export let id: string;
|
|
89
|
+
export let kind: string;
|
|
90
|
+
export let capabilities: any;
|
|
91
|
+
export function supports(ref: any, options: any): boolean;
|
|
92
|
+
export { generateAcpResponse as execute };
|
|
93
|
+
}
|
|
@@ -55,6 +55,27 @@ export namespace RUNTIME_CAPABILITIES {
|
|
|
55
55
|
let runtime_3: string;
|
|
56
56
|
export { runtime_3 as runtime };
|
|
57
57
|
}
|
|
58
|
+
namespace acp {
|
|
59
|
+
let structured_output_2: boolean;
|
|
60
|
+
export { structured_output_2 as structured_output };
|
|
61
|
+
let supports_session_resume_5: boolean;
|
|
62
|
+
export { supports_session_resume_5 as supports_session_resume };
|
|
63
|
+
let supports_mcp_2: boolean;
|
|
64
|
+
export { supports_mcp_2 as supports_mcp };
|
|
65
|
+
let supports_skills_2: boolean;
|
|
66
|
+
export { supports_skills_2 as supports_skills };
|
|
67
|
+
let supports_builtin_tools_1: boolean;
|
|
68
|
+
export { supports_builtin_tools_1 as supports_builtin_tools };
|
|
69
|
+
let supports_live_input_2: boolean;
|
|
70
|
+
export { supports_live_input_2 as supports_live_input };
|
|
71
|
+
let supports_native_subagents_3: boolean;
|
|
72
|
+
export { supports_native_subagents_3 as supports_native_subagents };
|
|
73
|
+
let supports_request_tool_environment_2: boolean;
|
|
74
|
+
export { supports_request_tool_environment_2 as supports_request_tool_environment };
|
|
75
|
+
export { TOOL_POLICY_ALLOW_ALL_ONLY as tool_policy };
|
|
76
|
+
let runtime_4: string;
|
|
77
|
+
export { runtime_4 as runtime };
|
|
78
|
+
}
|
|
58
79
|
}
|
|
59
80
|
import { TOOL_POLICY_PROJECTED } from "./tool-policy.js";
|
|
60
81
|
import { TOOL_POLICY_ALLOW_ALL_ONLY } from "./tool-policy.js";
|