@automatalabs/acp-agents 0.23.3 → 0.24.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/README.md +1 -1
- package/dist/acp-client.d.ts +19 -0
- package/dist/acp-client.d.ts.map +1 -1
- package/dist/acp-client.js +45 -2
- package/dist/auth/auth-profiles.d.ts +2 -1
- package/dist/auth/auth-profiles.d.ts.map +1 -1
- package/dist/auth/auth-profiles.js +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/pool.d.ts +13 -1
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +29 -2
- package/dist/provider-store.d.ts +34 -0
- package/dist/provider-store.d.ts.map +1 -0
- package/dist/provider-store.js +53 -0
- package/dist/runner.d.ts +27 -3
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +29 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ From [`src/index.ts`](./src/index.ts):
|
|
|
177
177
|
|
|
178
178
|
- **`createAcpRunner(options?)`** — factory returning an `AcpAgentRunner` (this is what `@automatalabs/workflows` injects into the engine).
|
|
179
179
|
- **`AcpAgentRunner`** — the `AgentRunner` implementation; `run(prompt, options)`, `openSession(options)`, `dispose()`, and `[Symbol.asyncDispose]()` for `await using`. The caller that constructs a runner owns its lifecycle.
|
|
180
|
-
- **Auth/provider lifecycle methods** — `describeAuthMethods()`, `completeAuth()`, `runner.auth`, `authMethods()`, `authenticate()`, `listProviders()`, `setProvider()`, `disableProvider()`, and `logout()`; see [docs/api.md](../../docs/api.md) for capability gating and installed adapter support.
|
|
180
|
+
- **Auth/provider lifecycle methods** — `describeAuthMethods()`, `completeAuth()`, `runner.auth`, `authMethods()`, `authenticate()`, `listProviders()`, `setProvider()`, `disableProvider()`, and `logout()`; see [docs/api.md](../../docs/api.md) for capability gating and installed adapter support. A successful `setProvider()` records a durable routing intent (`ProviderStore`) replayed on every fresh connection's `initialize` — provider config is in-process agent state for e.g. codex-acp, so record → recycle → replay is what makes it stick across the pool.
|
|
181
181
|
- **Session lifecycle methods** — `listSessions()`, `deleteSession()`, `loadSession()`, `resumeSession()`, and `forkSession()` for backends that advertise session persistence; see [docs/api.md](../../docs/api.md).
|
|
182
182
|
- **`InteractiveSession` / `InteractiveSessionOptions` / `InteractiveTurn`** — the held-open multi-turn session surface returned by `openSession()`.
|
|
183
183
|
- **`AcpRunnerOptions.onElicitation`** — runner-wide ACP elicitation responder; sessions can override with `InteractiveSessionOptions.onElicitation`.
|
package/dist/acp-client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { type ElicitationResolver, type PermissionResolver, type ToolPolicy } fr
|
|
|
8
8
|
import { UsageAccumulator } from "./usage.js";
|
|
9
9
|
import { type ClientHandlers } from "./client-handlers.js";
|
|
10
10
|
import { type AuthStore, type BackendAuthMachine, type ConnectionAuthStamp } from "./auth/auth-store.js";
|
|
11
|
+
import type { ProviderStore } from "./provider-store.js";
|
|
11
12
|
interface RawResultSuccess {
|
|
12
13
|
type: string;
|
|
13
14
|
subtype: string;
|
|
@@ -117,6 +118,11 @@ export interface PooledConnectionDeps {
|
|
|
117
118
|
* collected `env_var` values, and carries a generation stamp the pool gates selection on.
|
|
118
119
|
* Undefined => no auth wiring, byte-identical to the pre-auth baseline (default-OFF). */
|
|
119
120
|
authStore?: AuthStore;
|
|
121
|
+
/** The runner's single provider-intent store. When present, this connection replays the recorded
|
|
122
|
+
* `providers/set` intents at the end of `initialize` (provider routing is in-process agent state
|
|
123
|
+
* for e.g. codex-acp — the same dispose-after-configure class as auth gap 3) and carries a
|
|
124
|
+
* generation stamp the pool gates selection on. Undefined or empty => byte-identical baseline. */
|
|
125
|
+
providerStore?: ProviderStore;
|
|
120
126
|
/** Client-side ACP fs/terminal handlers advertised once and routed by sessionId. */
|
|
121
127
|
clientHandlers?: ClientHandlers;
|
|
122
128
|
}
|
|
@@ -141,9 +147,14 @@ export declare class PooledConnection {
|
|
|
141
147
|
private readonly advertiseElicitation;
|
|
142
148
|
private readonly authCapabilities;
|
|
143
149
|
private readonly authStore;
|
|
150
|
+
private readonly providerStore;
|
|
144
151
|
/** Which intent-generation THIS process reflects (§2.4). Starts at -1/false so a connection with
|
|
145
152
|
* no applied intent is stale against a machine that has ever advanced past generation 0. */
|
|
146
153
|
authStamp: ConnectionAuthStamp;
|
|
154
|
+
/** Which provider-store generation THIS process replayed at initialize. Starts at 0 (== the
|
|
155
|
+
* store's empty-pool generation), so the pre-provider baseline is never stale; the first
|
|
156
|
+
* recorded intent advances the store past it and recycles older processes. */
|
|
157
|
+
providerStamp: number;
|
|
147
158
|
/** Set by the pool when a busy stale connection must be recycled once it drains (§2.6). While set,
|
|
148
159
|
* the connection is never handed a new session and is disposed-and-dropped on release. */
|
|
149
160
|
recyclePending: boolean;
|
|
@@ -212,6 +223,14 @@ export declare class PooledConnection {
|
|
|
212
223
|
* on a JSON-RPC response that will never come. */
|
|
213
224
|
race<T>(op: Promise<T>): Promise<T>;
|
|
214
225
|
private initialize;
|
|
226
|
+
/** Replay the recorded `providers/set` intents at the end of `initialize`, then stamp the
|
|
227
|
+
* generation this process reflects. Advertise-gated: an agent that does not advertise the
|
|
228
|
+
* unstable providers block gets no replay (an intent can only have been recorded against an
|
|
229
|
+
* advertising agent, so a skip here means the agent surface changed under us — the stamp still
|
|
230
|
+
* marks this process current because no better state is reachable). A replay FAILURE throws,
|
|
231
|
+
* failing the connection loudly: silently opening sessions without the host-configured gateway
|
|
232
|
+
* routing would mis-route traffic. */
|
|
233
|
+
private applyProviderIntents;
|
|
215
234
|
/**
|
|
216
235
|
* Open a new per-agent session on this pooled connection: session/new { cwd }, register its
|
|
217
236
|
* accumulator for routing, and return a SessionHandle. `activeSessions` is reserved
|
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":[],"m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FAEkF;IAC5E,OAAO,CAAC,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAOnE"}
|
package/dist/acp-client.js
CHANGED
|
@@ -666,9 +666,14 @@ export class PooledConnection {
|
|
|
666
666
|
advertiseElicitation;
|
|
667
667
|
authCapabilities;
|
|
668
668
|
authStore;
|
|
669
|
+
providerStore;
|
|
669
670
|
/** Which intent-generation THIS process reflects (§2.4). Starts at -1/false so a connection with
|
|
670
671
|
* no applied intent is stale against a machine that has ever advanced past generation 0. */
|
|
671
672
|
authStamp = { appliedGeneration: -1, applied: false, trippedAuthRequired: false };
|
|
673
|
+
/** Which provider-store generation THIS process replayed at initialize. Starts at 0 (== the
|
|
674
|
+
* store's empty-pool generation), so the pre-provider baseline is never stale; the first
|
|
675
|
+
* recorded intent advances the store past it and recycles older processes. */
|
|
676
|
+
providerStamp = 0;
|
|
672
677
|
/** Set by the pool when a busy stale connection must be recycled once it drains (§2.6). While set,
|
|
673
678
|
* the connection is never handed a new session and is disposed-and-dropped on release. */
|
|
674
679
|
recyclePending = false;
|
|
@@ -694,6 +699,7 @@ export class PooledConnection {
|
|
|
694
699
|
this.advertiseElicitation = deps.advertiseElicitation ?? Boolean(deps.elicitationResolver);
|
|
695
700
|
this.authCapabilities = deps.authCapabilities;
|
|
696
701
|
this.authStore = deps.authStore;
|
|
702
|
+
this.providerStore = deps.providerStore;
|
|
697
703
|
this.client = new MultiplexClient(this.backendId, this.onEvent, deps.clientHandlers, deps.permissionResolver, deps.elicitationResolver);
|
|
698
704
|
const { command, args, env } = backend.spawnConfig();
|
|
699
705
|
// Spawn-env auth overlay (§2.8): host-collected `env_var` values (and, for a profiled backend,
|
|
@@ -1007,11 +1013,40 @@ export class PooledConnection {
|
|
|
1007
1013
|
machine.send({ t: "initialize_ok", connectionId: this.id, advertised: negotiated.authMethods });
|
|
1008
1014
|
await this.applyAuthIntent(machine);
|
|
1009
1015
|
}
|
|
1016
|
+
// Replay recorded provider-routing intents (the providers/* sibling of the auth replay
|
|
1017
|
+
// above): provider config is in-process agent state for e.g. codex-acp, so every fresh
|
|
1018
|
+
// process must be re-routed here or its sessions would silently run on default routing.
|
|
1019
|
+
await this.applyProviderIntents();
|
|
1010
1020
|
}
|
|
1011
1021
|
finally {
|
|
1012
1022
|
clearTimeout(timer);
|
|
1013
1023
|
}
|
|
1014
1024
|
}
|
|
1025
|
+
/** Replay the recorded `providers/set` intents at the end of `initialize`, then stamp the
|
|
1026
|
+
* generation this process reflects. Advertise-gated: an agent that does not advertise the
|
|
1027
|
+
* unstable providers block gets no replay (an intent can only have been recorded against an
|
|
1028
|
+
* advertising agent, so a skip here means the agent surface changed under us — the stamp still
|
|
1029
|
+
* marks this process current because no better state is reachable). A replay FAILURE throws,
|
|
1030
|
+
* failing the connection loudly: silently opening sessions without the host-configured gateway
|
|
1031
|
+
* routing would mis-route traffic. */
|
|
1032
|
+
async applyProviderIntents() {
|
|
1033
|
+
const store = this.providerStore;
|
|
1034
|
+
if (!store)
|
|
1035
|
+
return;
|
|
1036
|
+
const poolKey = this.backend.poolKey ?? this.backend.id;
|
|
1037
|
+
const generation = store.generation(poolKey);
|
|
1038
|
+
if (this.negotiated?.supportsProviders === true) {
|
|
1039
|
+
for (const intent of store.intentsFor(poolKey)) {
|
|
1040
|
+
await this.rawAgentRequest(AGENT_METHODS.providers_set, {
|
|
1041
|
+
providerId: intent.providerId,
|
|
1042
|
+
apiType: intent.apiType,
|
|
1043
|
+
baseUrl: intent.baseUrl,
|
|
1044
|
+
...(intent.headers ? { headers: intent.headers } : {}),
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
this.providerStamp = generation;
|
|
1049
|
+
}
|
|
1015
1050
|
/**
|
|
1016
1051
|
* Open a new per-agent session on this pooled connection: session/new { cwd }, register its
|
|
1017
1052
|
* accumulator for routing, and return a SessionHandle. `activeSessions` is reserved
|
|
@@ -1634,8 +1669,10 @@ function flattenSelectOptions(options) {
|
|
|
1634
1669
|
}
|
|
1635
1670
|
/**
|
|
1636
1671
|
* Best-effort match of a model spec (`provider/modelId`, a bare `modelId`, or a tier word)
|
|
1637
|
-
* against the agent's catalog. Tries, in priority order: exact spec, exact
|
|
1638
|
-
*
|
|
1672
|
+
* against the agent's catalog. Tries, in priority order: exact spec, the exact spec with its
|
|
1673
|
+
* `[effort]` bracket stripped (so `zai/glm-5.2[max]` matches its own provider's `zai/glm-5.2`
|
|
1674
|
+
* before any cross-provider lookalike), exact id-after-slash, the bare base id (bracket
|
|
1675
|
+
* stripped, so `gpt-5.1-codex[high]` matches a
|
|
1639
1676
|
* bare `gpt-5.1-codex` model value while the bracket separately drives reasoning_effort), the
|
|
1640
1677
|
* Codex `base[effort]` encoding, exact option name, then substring fallbacks. The effort
|
|
1641
1678
|
* bracket itself is applied via applyModelModifiers, not folded into the model select.
|
|
@@ -1643,10 +1680,16 @@ function flattenSelectOptions(options) {
|
|
|
1643
1680
|
function matchModelValue(values, spec) {
|
|
1644
1681
|
const afterSlash = spec.includes("/") ? spec.slice(spec.indexOf("/") + 1) : spec;
|
|
1645
1682
|
const fullLower = spec.toLowerCase();
|
|
1683
|
+
const fullBaseLower = stripEffortBracket(fullLower);
|
|
1646
1684
|
const idLower = afterSlash.toLowerCase();
|
|
1647
1685
|
const baseLower = stripEffortBracket(afterSlash).toLowerCase();
|
|
1648
1686
|
const tests = [
|
|
1649
1687
|
(value) => value.value.toLowerCase() === fullLower,
|
|
1688
|
+
// The provider-prefixed spec with the bracket stripped ("zai/glm-5.2[max]" ->
|
|
1689
|
+
// "zai/glm-5.2") — without this, a bracketed spec whose provider serves a model
|
|
1690
|
+
// that OTHER providers also list never exact-matches and falls through to the
|
|
1691
|
+
// substring tests, which can pick a different provider's entry for the same model.
|
|
1692
|
+
(value) => value.value.toLowerCase() === fullBaseLower,
|
|
1650
1693
|
(value) => value.value.toLowerCase() === idLower,
|
|
1651
1694
|
(value) => value.value.toLowerCase() === baseLower,
|
|
1652
1695
|
(value) => value.value.toLowerCase().startsWith(`${baseLower}[`),
|
|
@@ -47,7 +47,8 @@ export interface AuthProfile {
|
|
|
47
47
|
* unchanged. No `spawnAuthEnv` — Claude has no `DEFAULT_AUTH_REQUEST`-style pre-auth channel and is
|
|
48
48
|
* consumed client-side only (§3.2 spawn-time). */
|
|
49
49
|
export declare const claudeAuthProfile: AuthProfile;
|
|
50
|
-
/** Codex — `@automatalabs/codex-acp
|
|
50
|
+
/** Codex — `@automatalabs/codex-acp`, our fork (§3.3; the spec heading tracks the installed
|
|
51
|
+
* version). Advertises no `terminal` method (its
|
|
51
52
|
* `api-key` reads env internally and `chat-gpt`/`gateway` are `agent`-type), so terminal is always
|
|
52
53
|
* false; `gateway` follows an `onAuth` resolver. The `spawnAuthEnv` lever emits `DEFAULT_AUTH_REQUEST`
|
|
53
54
|
* for `api-key`/`gateway` intents so a freshly recycled process pre-authenticates before its first
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-profiles.d.ts","sourceRoot":"","sources":["../../src/auth/auth-profiles.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;gDACgD;AAChD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;qFAEqF;AACrF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE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— `@automatalabs/codex-acp
|
|
14
|
+
/** Codex — `@automatalabs/codex-acp`, our fork (§3.3; the spec heading tracks the installed
|
|
15
|
+
* version). Advertises no `terminal` method (its
|
|
15
16
|
* `api-key` reads env internally and `chat-gpt`/`gateway` are `agent`-type), so terminal is always
|
|
16
17
|
* false; `gateway` follows an `onAuth` resolver. The `spawnAuthEnv` lever emits `DEFAULT_AUTH_REQUEST`
|
|
17
18
|
* for `api-key`/`gateway` intents so a freshly recycled process pre-authenticates before its first
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { AcpAgentRunner, createAcpRunner, selectBackend } from "./runner.js";
|
|
2
|
-
export type { AcpRunnerOptions, AuthenticateOptions, AuthMethodsOptions, AuthCapableRunner, AuthController, AuthOutcome, AuthStatusSnapshot, CompleteAuthOptions, DisableProviderOptions, DeleteSessionOptions, ListProvidersOptions, ListSessionsOptions, LogoutOptions, ReattachSessionOptions, SetProviderOptions, } from "./runner.js";
|
|
2
|
+
export type { AcpRunnerOptions, AuthenticateOptions, AuthMethodsOptions, AuthCapableRunner, AuthController, AuthOutcome, AuthStatusSnapshot, CompleteAuthOptions, DisableProviderOptions, DeleteSessionOptions, ListProvidersOptions, ListSessionsOptions, LogoutOptions, ProviderCapableRunner, ReattachSessionOptions, SetProviderOptions, } from "./runner.js";
|
|
3
3
|
export { buildAuthDescriptor, buildAuthDescriptors, isGatewayShapedMeta } from "./auth/auth-types.js";
|
|
4
4
|
export type { AuthContext, AuthMethodDescriptor, AuthResolution, AuthResolver } from "./auth/auth-types.js";
|
|
5
5
|
export { AuthStore, BackendAuthMachine, classifyCredential, redactSecrets, } from "./auth/auth-store.js";
|
|
6
6
|
export type { AuthEvent, AuthIntent, AuthMethodType, BackendAuthState, ConnectionAuthStamp, CredentialClass, RedactedIntent, } from "./auth/auth-store.js";
|
|
7
|
+
export { ProviderStore } from "./provider-store.js";
|
|
8
|
+
export type { ProviderIntent } from "./provider-store.js";
|
|
7
9
|
export { claudeAuthProfile, codexAuthProfile, opencodeAuthProfile } from "./auth/auth-profiles.js";
|
|
8
10
|
export type { AuthProfile, TerminalLaunch } from "./auth/auth-profiles.js";
|
|
9
11
|
export { InteractiveSession } from "./interactive.js";
|
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,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtG,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC5G,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnG,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA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AAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEvG,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7F,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
|
@@ -8,6 +8,9 @@ export { AcpAgentRunner, createAcpRunner, selectBackend } from "./runner.js";
|
|
|
8
8
|
// Type-driven auth contracts (§1.3) and the AuthStore lifecycle spine (§2).
|
|
9
9
|
export { buildAuthDescriptor, buildAuthDescriptors, isGatewayShapedMeta } from "./auth/auth-types.js";
|
|
10
10
|
export { AuthStore, BackendAuthMachine, classifyCredential, redactSecrets, } from "./auth/auth-store.js";
|
|
11
|
+
// The provider-routing intent store — the providers/* sibling of the AuthStore: recorded on a
|
|
12
|
+
// successful setProvider, replayed on every connection's initialize, generation-gated by the pool.
|
|
13
|
+
export { ProviderStore } from "./provider-store.js";
|
|
11
14
|
// Per-agent auth profiles (§3): the pure-data adapters wired onto the built-in backends. Custom
|
|
12
15
|
// backends supply none (conformance-by-absence, §3.5).
|
|
13
16
|
export { claudeAuthProfile, codexAuthProfile, opencodeAuthProfile } from "./auth/auth-profiles.js";
|
package/dist/pool.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type ClientHandlers } from "./client-handlers.js";
|
|
|
4
4
|
import type { AcpEventSink } from "./events.js";
|
|
5
5
|
import type { ElicitationResolver, PermissionResolver } from "./permissions.js";
|
|
6
6
|
import type { AuthStore } from "./auth/auth-store.js";
|
|
7
|
+
import type { ProviderStore } from "./provider-store.js";
|
|
7
8
|
export interface AcpPoolOptions {
|
|
8
9
|
/** Long-lived processes to keep PER backend. Default 1; falls back to AGENTPRISM_ACP_POOL_SIZE. */
|
|
9
10
|
size?: number;
|
|
@@ -27,6 +28,11 @@ export interface AcpPoolDeps {
|
|
|
27
28
|
* no session is ever opened on a connection whose applied intent-generation is stale. Undefined
|
|
28
29
|
* => no gating, byte-identical to the pre-auth baseline. */
|
|
29
30
|
authStore?: AuthStore;
|
|
31
|
+
/** The runner's single provider-intent store. When present, connection selection is also gated
|
|
32
|
+
* on the provider-routing generation, so no session is ever opened on a process still running
|
|
33
|
+
* under stale (or missing) client-configured provider routing. Undefined or never-recorded =>
|
|
34
|
+
* no gating, byte-identical baseline. */
|
|
35
|
+
providerStore?: ProviderStore;
|
|
30
36
|
}
|
|
31
37
|
/** Resolve the per-backend pool size: explicit option wins, else env, else 1. Clamped to >= 1. */
|
|
32
38
|
export declare function resolvePoolSize(option?: number): number;
|
|
@@ -56,8 +62,14 @@ export declare class AcpAgentPool {
|
|
|
56
62
|
* connections are DRAINED (recycled on release), not disposed synchronously, so in-flight prompts
|
|
57
63
|
* finish under the auth they started with. Never blocks. */
|
|
58
64
|
private reconcileStale;
|
|
65
|
+
/** Reconcile every live connection for a key to the current provider-routing generation. There
|
|
66
|
+
* is no live re-apply lane here (provider changes are rare host-level config): an idle stale
|
|
67
|
+
* process is recycled now, a busy one drains and recycles on release — mirroring the
|
|
68
|
+
* disk/spawn-env branches of reconcileStale. Never blocks. */
|
|
69
|
+
private reconcileProviderStale;
|
|
59
70
|
/** Public: reconcile every live connection for a backend to the current generation (§2.6). Called
|
|
60
|
-
* by the runner immediately after a host-completed auth
|
|
71
|
+
* by the runner immediately after a host-completed auth — or a provider-routing change — so a
|
|
72
|
+
* subsequent run() lands current. */
|
|
61
73
|
recycle(poolKey: string): void;
|
|
62
74
|
/** Spawn a fresh pooled connection (a fresh process primes the current intent at initialize). */
|
|
63
75
|
private spawn;
|
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,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAsB,MAAM,sBAAsB,CAAC;
|
|
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,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAsB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD,MAAM,WAAW,cAAc;IAC7B,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,cAAc,CAAC,EAAE,cAAc,CAAC;C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OAAO,CAAC,aAAa,CAAC;IAezB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;iEAE6D;IAC7D,OAAO,CAAC,cAAc;IActB;;;mEAG+D;IAC/D,OAAO,CAAC,sBAAsB;IAc9B;;0CAEsC;IACtC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO9B,iGAAiG;IACjG,OAAO,CAAC,KAAK;IAiBb,OAAO,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
|
@@ -83,7 +83,11 @@ export class AcpAgentPool {
|
|
|
83
83
|
const connections = this.connectionsFor(key);
|
|
84
84
|
if (machine)
|
|
85
85
|
this.reconcileStale(key, machine);
|
|
86
|
-
|
|
86
|
+
this.reconcileProviderStale(key);
|
|
87
|
+
const usable = connections.filter((c) => c.alive &&
|
|
88
|
+
!c.recyclePending &&
|
|
89
|
+
!machine?.isStale(c.authStamp) &&
|
|
90
|
+
!this.deps.providerStore?.isStale(key, c.providerStamp));
|
|
87
91
|
const idle = usable.find((c) => c.activeSessions === 0);
|
|
88
92
|
if (idle)
|
|
89
93
|
return idle;
|
|
@@ -113,14 +117,36 @@ export class AcpAgentPool {
|
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
119
|
}
|
|
120
|
+
/** Reconcile every live connection for a key to the current provider-routing generation. There
|
|
121
|
+
* is no live re-apply lane here (provider changes are rare host-level config): an idle stale
|
|
122
|
+
* process is recycled now, a busy one drains and recycles on release — mirroring the
|
|
123
|
+
* disk/spawn-env branches of reconcileStale. Never blocks. */
|
|
124
|
+
reconcileProviderStale(key) {
|
|
125
|
+
const store = this.deps.providerStore;
|
|
126
|
+
if (!store)
|
|
127
|
+
return;
|
|
128
|
+
for (const c of this.connectionsFor(key).filter((c) => c.alive)) {
|
|
129
|
+
if (!store.isStale(key, c.providerStamp))
|
|
130
|
+
continue;
|
|
131
|
+
if (c.activeSessions === 0) {
|
|
132
|
+
void c.dispose();
|
|
133
|
+
this.drop(key, c);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
c.recyclePending = true; // BUSY: drain, then dispose-and-drop on release
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
116
140
|
/** Public: reconcile every live connection for a backend to the current generation (§2.6). Called
|
|
117
|
-
* by the runner immediately after a host-completed auth
|
|
141
|
+
* by the runner immediately after a host-completed auth — or a provider-routing change — so a
|
|
142
|
+
* subsequent run() lands current. */
|
|
118
143
|
recycle(poolKey) {
|
|
119
144
|
if (this.disposed)
|
|
120
145
|
return;
|
|
121
146
|
const machine = this.deps.authStore?.existing(poolKey);
|
|
122
147
|
if (machine)
|
|
123
148
|
this.reconcileStale(poolKey, machine);
|
|
149
|
+
this.reconcileProviderStale(poolKey);
|
|
124
150
|
}
|
|
125
151
|
/** Spawn a fresh pooled connection (a fresh process primes the current intent at initialize). */
|
|
126
152
|
spawn(key, backend) {
|
|
@@ -133,6 +159,7 @@ export class AcpAgentPool {
|
|
|
133
159
|
advertiseElicitation: this.deps.advertiseElicitation,
|
|
134
160
|
authCapabilities: this.deps.authCapabilities,
|
|
135
161
|
authStore: this.deps.authStore,
|
|
162
|
+
providerStore: this.deps.providerStore,
|
|
136
163
|
clientHandlers: this.clientHandlers,
|
|
137
164
|
});
|
|
138
165
|
this.connectionsFor(key).push(connection);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SetProviderRequest } from "@agentclientprotocol/sdk";
|
|
2
|
+
/** One recorded `providers/set` — the full replacement configuration for one provider. The
|
|
3
|
+
* request-scoped `_meta` passthrough is deliberately NOT recorded: it rides the immediate wire
|
|
4
|
+
* call only, while the intent captures the durable routing config. */
|
|
5
|
+
export interface ProviderIntent {
|
|
6
|
+
providerId: SetProviderRequest["providerId"];
|
|
7
|
+
apiType: SetProviderRequest["apiType"];
|
|
8
|
+
baseUrl: SetProviderRequest["baseUrl"];
|
|
9
|
+
/** SECRET gateway headers, replayed verbatim and never surfaced anywhere else. */
|
|
10
|
+
headers?: SetProviderRequest["headers"];
|
|
11
|
+
}
|
|
12
|
+
/** The runner's single in-memory provider-intent store. Default-OFF by construction: until the
|
|
13
|
+
* first successful `setProvider`, no entry exists, `isStale` is always false, and replay is a
|
|
14
|
+
* no-op — byte-identical to the pre-provider baseline. */
|
|
15
|
+
export declare class ProviderStore {
|
|
16
|
+
private readonly byPool;
|
|
17
|
+
/** Record the full replacement configuration for one provider and advance the generation. The
|
|
18
|
+
* stored copy is store-owned, so a superseded copy's header values are zeroized (§2.14-style
|
|
19
|
+
* hygiene) before it is replaced. */
|
|
20
|
+
record(poolKey: string, intent: ProviderIntent): void;
|
|
21
|
+
/** Drop the recorded intent for one provider (after a successful `providers/disable`) —
|
|
22
|
+
* zeroizing its stored header values — and advance the generation so routed processes recycle.
|
|
23
|
+
* Removing an unrecorded id still advances — disable is idempotent agent-side and an extra
|
|
24
|
+
* recycle is harmless. */
|
|
25
|
+
remove(poolKey: string, providerId: string): void;
|
|
26
|
+
/** The recorded intents for one pool key, in insertion order (replay order). */
|
|
27
|
+
intentsFor(poolKey: string): ProviderIntent[];
|
|
28
|
+
/** The current generation for one pool key; 0 when nothing was ever recorded. */
|
|
29
|
+
generation(poolKey: string): number;
|
|
30
|
+
/** True when a connection stamped at `stamp` no longer reflects the recorded routing. A pool
|
|
31
|
+
* key with no entry is never stale (the default-OFF baseline). */
|
|
32
|
+
isStale(poolKey: string, stamp: number): boolean;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=provider-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-store.d.ts","sourceRoot":"","sources":["../src/provider-store.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;uEAEuE;AACvE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC7C,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACvC,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACvC,kFAAkF;IAClF,OAAO,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACzC;AAWD;;2DAE2D;AAC3D,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IAEvD;;0CAEsC;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IAWrD;;;+BAG2B;IAC3B,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAQjD,gFAAgF;IAChF,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAK7C,iFAAiF;IACjF,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAInC;uEACmE;IACnE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;CAIjD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** The runner's single in-memory provider-intent store. Default-OFF by construction: until the
|
|
2
|
+
* first successful `setProvider`, no entry exists, `isStale` is always false, and replay is a
|
|
3
|
+
* no-op — byte-identical to the pre-provider baseline. */
|
|
4
|
+
export class ProviderStore {
|
|
5
|
+
byPool = new Map();
|
|
6
|
+
/** Record the full replacement configuration for one provider and advance the generation. The
|
|
7
|
+
* stored copy is store-owned, so a superseded copy's header values are zeroized (§2.14-style
|
|
8
|
+
* hygiene) before it is replaced. */
|
|
9
|
+
record(poolKey, intent) {
|
|
10
|
+
let entry = this.byPool.get(poolKey);
|
|
11
|
+
if (!entry) {
|
|
12
|
+
entry = { generation: 0, intents: new Map() };
|
|
13
|
+
this.byPool.set(poolKey, entry);
|
|
14
|
+
}
|
|
15
|
+
zeroizeHeaders(entry.intents.get(intent.providerId));
|
|
16
|
+
entry.intents.set(intent.providerId, { ...intent, ...(intent.headers ? { headers: { ...intent.headers } } : {}) });
|
|
17
|
+
entry.generation += 1;
|
|
18
|
+
}
|
|
19
|
+
/** Drop the recorded intent for one provider (after a successful `providers/disable`) —
|
|
20
|
+
* zeroizing its stored header values — and advance the generation so routed processes recycle.
|
|
21
|
+
* Removing an unrecorded id still advances — disable is idempotent agent-side and an extra
|
|
22
|
+
* recycle is harmless. */
|
|
23
|
+
remove(poolKey, providerId) {
|
|
24
|
+
const entry = this.byPool.get(poolKey);
|
|
25
|
+
if (!entry)
|
|
26
|
+
return; // nothing recorded => nothing to replay or recycle
|
|
27
|
+
zeroizeHeaders(entry.intents.get(providerId));
|
|
28
|
+
entry.intents.delete(providerId);
|
|
29
|
+
entry.generation += 1;
|
|
30
|
+
}
|
|
31
|
+
/** The recorded intents for one pool key, in insertion order (replay order). */
|
|
32
|
+
intentsFor(poolKey) {
|
|
33
|
+
const entry = this.byPool.get(poolKey);
|
|
34
|
+
return entry ? [...entry.intents.values()] : [];
|
|
35
|
+
}
|
|
36
|
+
/** The current generation for one pool key; 0 when nothing was ever recorded. */
|
|
37
|
+
generation(poolKey) {
|
|
38
|
+
return this.byPool.get(poolKey)?.generation ?? 0;
|
|
39
|
+
}
|
|
40
|
+
/** True when a connection stamped at `stamp` no longer reflects the recorded routing. A pool
|
|
41
|
+
* key with no entry is never stale (the default-OFF baseline). */
|
|
42
|
+
isStale(poolKey, stamp) {
|
|
43
|
+
const entry = this.byPool.get(poolKey);
|
|
44
|
+
return entry !== undefined && stamp < entry.generation;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Overwrite a store-owned intent copy's SECRET header values before dropping the reference. */
|
|
48
|
+
function zeroizeHeaders(intent) {
|
|
49
|
+
if (!intent?.headers)
|
|
50
|
+
return;
|
|
51
|
+
for (const key of Object.keys(intent.headers))
|
|
52
|
+
intent.headers[key] = "";
|
|
53
|
+
}
|
package/dist/runner.d.ts
CHANGED
|
@@ -129,6 +129,18 @@ export interface AuthCapableRunner {
|
|
|
129
129
|
listBackends(): string[];
|
|
130
130
|
readonly auth: AuthController;
|
|
131
131
|
}
|
|
132
|
+
/** Structural capability interface the MCP composition root duck-types to register the provider
|
|
133
|
+
* tools, symmetric to AuthCapableRunner and equally seam-preserving. `AcpAgentRunner` implements
|
|
134
|
+
* it. This is the GENERIC base-spec `providers/*` surface: every method is advertise-gated per
|
|
135
|
+
* backend (`agentCapabilities.providers`), so any spec-conformant agent that advertises the
|
|
136
|
+
* unstable providers block is served with zero agent-specific code. */
|
|
137
|
+
export interface ProviderCapableRunner {
|
|
138
|
+
listProviders(opts?: ListProvidersOptions): Promise<ListProvidersResponse>;
|
|
139
|
+
setProvider(opts: SetProviderOptions): Promise<SetProviderResponse | void>;
|
|
140
|
+
disableProvider(opts: DisableProviderOptions): Promise<DisableProviderResponse | void>;
|
|
141
|
+
/** Ids of every configured backend (built-ins + AcpRunnerOptions.backends). */
|
|
142
|
+
listBackends(): string[];
|
|
143
|
+
}
|
|
132
144
|
/** Constructor options for the runner: pool sizing, client-side handlers, and the custom-backend
|
|
133
145
|
* registry. `backends` merges over (and wins against) env-declared AGENTPRISM_BACKENDS entries. */
|
|
134
146
|
export interface AcpRunnerOptions extends AcpPoolOptions {
|
|
@@ -161,7 +173,7 @@ export interface AcpRunnerOptions extends AcpPoolOptions {
|
|
|
161
173
|
* pass it into managers/runs as needed, then call dispose() (or use `await using`) when that
|
|
162
174
|
* owner is done with the pooled and dedicated backend processes.
|
|
163
175
|
*/
|
|
164
|
-
export declare class AcpAgentRunner implements AgentRunner, AuthCapableRunner {
|
|
176
|
+
export declare class AcpAgentRunner implements AgentRunner, AuthCapableRunner, ProviderCapableRunner {
|
|
165
177
|
private readonly pool;
|
|
166
178
|
/** The resolved custom-backend registry (env + option, validated at construction). */
|
|
167
179
|
private readonly backends;
|
|
@@ -185,6 +197,11 @@ export declare class AcpAgentRunner implements AgentRunner, AuthCapableRunner {
|
|
|
185
197
|
* home for credential material in the library. Threaded into the pool and every dedicated
|
|
186
198
|
* connection so all connection types reconcile to the same intent. */
|
|
187
199
|
private readonly authStore;
|
|
200
|
+
/** The single per-runner provider-intent store — the providers/* sibling of the AuthStore.
|
|
201
|
+
* setProvider records here after the wire call succeeds; every connection (pooled and
|
|
202
|
+
* dedicated) replays the recorded routing at initialize, so client-configured providers
|
|
203
|
+
* survive pool recycles and dispose-after-use dedicated connections. */
|
|
204
|
+
private readonly providerStore;
|
|
188
205
|
/** The auth verbs as one addressable object (§2.10). */
|
|
189
206
|
readonly auth: AuthController;
|
|
190
207
|
private readonly structuredOutputTools;
|
|
@@ -244,9 +261,16 @@ export declare class AcpAgentRunner implements AgentRunner, AuthCapableRunner {
|
|
|
244
261
|
listBackends(): string[];
|
|
245
262
|
/** List configurable providers from the selected backend. */
|
|
246
263
|
listProviders(opts?: ListProvidersOptions): Promise<ListProvidersResponse>;
|
|
247
|
-
/** Configure one provider on the selected backend.
|
|
264
|
+
/** Configure one provider on the selected backend. The wire call validates against the live
|
|
265
|
+
* agent (unknown providerId/apiType errors surface immediately); on success the routing is
|
|
266
|
+
* recorded as a durable intent — provider config is in-process agent state for e.g. codex-acp,
|
|
267
|
+
* so without the record this dedicated connection's dispose would silently discard it (the
|
|
268
|
+
* providers/* sibling of the dispose-after-authenticate bug). Every later connection replays
|
|
269
|
+
* the intent at initialize, and the pool recycles so no session runs under stale routing.
|
|
270
|
+
* The request-scoped `meta` passthrough rides the immediate call only; it is not replayed. */
|
|
248
271
|
setProvider(opts: SetProviderOptions): Promise<SetProviderResponse | void>;
|
|
249
|
-
/** Disable one provider on the selected backend
|
|
272
|
+
/** Disable one provider on the selected backend, drop its recorded routing intent, and recycle
|
|
273
|
+
* the pool so no future session replays it. Idempotent like the wire method. */
|
|
250
274
|
disableProvider(opts: DisableProviderOptions): Promise<DisableProviderResponse | void>;
|
|
251
275
|
/** Logout through the selected backend. REBUILT (§2.9): first clear the AuthStore machine
|
|
252
276
|
* (zeroizing `authenticateMeta`/`envValues`, §2.14) and recycle the pool so no pooled process
|
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,EAIL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EAEV,sBAAsB,EACtB,uBAAuB,EAEvB,qBAAqB,EAErB,oBAAoB,EAEpB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAKtF,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[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AAC,cAAc;IAMtB,gGAAgG;IAChG,OAAO,CAAC,WAAW;CAGpB;AAED;;;qDAGqD;AACrD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAE1E;AA6ED;;;;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
|
@@ -30,6 +30,7 @@ import { registryWithRunBackends, resolveBackendRegistry, } from "./registry.js"
|
|
|
30
30
|
import { mapThrownError } from "./errors-map.js";
|
|
31
31
|
import { buildAuthDescriptor, } from "./auth/auth-types.js";
|
|
32
32
|
import { AuthStore, classifyCredential, } from "./auth/auth-store.js";
|
|
33
|
+
import { ProviderStore } from "./provider-store.js";
|
|
33
34
|
import { resolveStructuredOutput } from "./structured-output.js";
|
|
34
35
|
import { STRUCTURED_OUTPUT_SERVER_NAME, StructuredOutputToolHost, } from "./structured-tool.js";
|
|
35
36
|
import { buildRunPrompt, mergeTurnMeta, promptWithImages, validatePromptImages, } from "./prompt.js";
|
|
@@ -63,6 +64,11 @@ export class AcpAgentRunner {
|
|
|
63
64
|
* home for credential material in the library. Threaded into the pool and every dedicated
|
|
64
65
|
* connection so all connection types reconcile to the same intent. */
|
|
65
66
|
authStore = new AuthStore();
|
|
67
|
+
/** The single per-runner provider-intent store — the providers/* sibling of the AuthStore.
|
|
68
|
+
* setProvider records here after the wire call succeeds; every connection (pooled and
|
|
69
|
+
* dedicated) replays the recorded routing at initialize, so client-configured providers
|
|
70
|
+
* survive pool recycles and dispose-after-use dedicated connections. */
|
|
71
|
+
providerStore = new ProviderStore();
|
|
66
72
|
/** The auth verbs as one addressable object (§2.10). */
|
|
67
73
|
auth;
|
|
68
74
|
structuredOutputTools = new StructuredOutputToolHost();
|
|
@@ -94,6 +100,7 @@ export class AcpAgentRunner {
|
|
|
94
100
|
advertiseElicitation: Boolean(options.onElicitation),
|
|
95
101
|
authCapabilities: this.authCapabilities,
|
|
96
102
|
authStore: this.authStore,
|
|
103
|
+
providerStore: this.providerStore,
|
|
97
104
|
});
|
|
98
105
|
this.backends = resolveBackendRegistry(options.backends);
|
|
99
106
|
this.auth = {
|
|
@@ -228,7 +235,13 @@ export class AcpAgentRunner {
|
|
|
228
235
|
await disposeBestEffort(connection);
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
|
-
/** Configure one provider on the selected backend.
|
|
238
|
+
/** Configure one provider on the selected backend. The wire call validates against the live
|
|
239
|
+
* agent (unknown providerId/apiType errors surface immediately); on success the routing is
|
|
240
|
+
* recorded as a durable intent — provider config is in-process agent state for e.g. codex-acp,
|
|
241
|
+
* so without the record this dedicated connection's dispose would silently discard it (the
|
|
242
|
+
* providers/* sibling of the dispose-after-authenticate bug). Every later connection replays
|
|
243
|
+
* the intent at initialize, and the pool recycles so no session runs under stale routing.
|
|
244
|
+
* The request-scoped `meta` passthrough rides the immediate call only; it is not replayed. */
|
|
232
245
|
async setProvider(opts) {
|
|
233
246
|
if (this.disposed)
|
|
234
247
|
throw new Error("ACP agent runner is disposed");
|
|
@@ -247,6 +260,13 @@ export class AcpAgentRunner {
|
|
|
247
260
|
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
248
261
|
};
|
|
249
262
|
const response = await connection.setProvider(request, opts.label);
|
|
263
|
+
this.providerStore.record(backend.poolKey ?? backend.id, {
|
|
264
|
+
providerId: opts.providerId,
|
|
265
|
+
apiType: opts.apiType,
|
|
266
|
+
baseUrl: opts.baseUrl,
|
|
267
|
+
...(opts.headers ? { headers: opts.headers } : {}),
|
|
268
|
+
});
|
|
269
|
+
this.pool.recycle(backend.poolKey ?? backend.id);
|
|
250
270
|
opts.signal?.throwIfAborted();
|
|
251
271
|
if (this.disposed)
|
|
252
272
|
throw new Error("ACP agent runner is disposed");
|
|
@@ -256,7 +276,8 @@ export class AcpAgentRunner {
|
|
|
256
276
|
await disposeBestEffort(connection);
|
|
257
277
|
}
|
|
258
278
|
}
|
|
259
|
-
/** Disable one provider on the selected backend
|
|
279
|
+
/** Disable one provider on the selected backend, drop its recorded routing intent, and recycle
|
|
280
|
+
* the pool so no future session replays it. Idempotent like the wire method. */
|
|
260
281
|
async disableProvider(opts) {
|
|
261
282
|
if (this.disposed)
|
|
262
283
|
throw new Error("ACP agent runner is disposed");
|
|
@@ -270,6 +291,8 @@ export class AcpAgentRunner {
|
|
|
270
291
|
...(opts.meta ? { _meta: opts.meta } : {}),
|
|
271
292
|
};
|
|
272
293
|
const response = await connection.disableProvider(request, opts.label);
|
|
294
|
+
this.providerStore.remove(backend.poolKey ?? backend.id, opts.providerId);
|
|
295
|
+
this.pool.recycle(backend.poolKey ?? backend.id);
|
|
273
296
|
opts.signal?.throwIfAborted();
|
|
274
297
|
if (this.disposed)
|
|
275
298
|
throw new Error("ACP agent runner is disposed");
|
|
@@ -685,9 +708,11 @@ export class AcpAgentRunner {
|
|
|
685
708
|
elicitationResolver: this.elicitationResolver,
|
|
686
709
|
advertiseElicitation: Boolean(this.elicitationResolver),
|
|
687
710
|
authCapabilities: this.authCapabilities,
|
|
688
|
-
// Same
|
|
689
|
-
// initialize (§2.5) — the direct fix for the
|
|
711
|
+
// Same stores as the pool: a dedicated connection re-primes the durable auth intent AND the
|
|
712
|
+
// recorded provider routing at its own initialize (§2.5) — the direct fix for the
|
|
713
|
+
// dispose-after-authenticate bug (gap 3) and its providers/* sibling.
|
|
690
714
|
authStore: this.authStore,
|
|
715
|
+
providerStore: this.providerStore,
|
|
691
716
|
clientHandlers: this.clientHandlers,
|
|
692
717
|
});
|
|
693
718
|
}
|