agl 43.0.4 → 43.1.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/changelog.md +25 -0
- package/dist_serve/bundle.js +5186 -4683
- package/dist_serve/bundle.js.map +2 -2
- package/dist_serve/bundle.js.third-party-notices.json +29 -29
- package/dist_serve/bundle.js.third-party-notices.txt +29 -29
- package/dist_serve/third-party-notices.md +1 -1
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +475 -4
- package/dist_ts/aglapi/interfaces.d.ts +10 -0
- package/dist_ts/aglapi/interfaces.js +3 -1
- package/dist_ts/classes.claudeharness.d.ts +14 -5
- package/dist_ts/classes.claudeharness.js +62 -2
- package/dist_ts/classes.codexclientadapter.d.ts +7 -5
- package/dist_ts/classes.codexclientadapter.js +38 -3
- package/dist_ts/classes.controller.d.ts +9 -2
- package/dist_ts/classes.controller.js +116 -24
- package/dist_ts/classes.flexservice.d.ts +6 -7
- package/dist_ts/classes.flexservice.js +12 -45
- package/dist_ts/classes.flexsupervisor.d.ts +37 -3
- package/dist_ts/classes.flexsupervisor.js +164 -37
- package/dist_ts/classes.inferencegateway.d.ts +8 -5
- package/dist_ts/classes.inferencegateway.js +62 -19
- package/dist_ts/classes.inferencespend.d.ts +9 -3
- package/dist_ts/classes.inferencespend.js +44 -16
- package/dist_ts/classes.mcpclient.d.ts +6 -4
- package/dist_ts/classes.mcpclient.js +6 -2
- package/dist_ts/classes.mcpcontrollerhost.js +5 -1
- package/dist_ts/classes.mcptools.d.ts +1 -1
- package/dist_ts/classes.mcptools.js +17 -4
- package/dist_ts/classes.opencodeclient.js +3 -1
- package/dist_ts/classes.proxycontrol.d.ts +22 -11
- package/dist_ts/classes.proxycontrol.js +6 -3
- package/dist_ts/classes.proxycontrolclient.d.ts +6 -5
- package/dist_ts/classes.proxycontrolclient.js +8 -6
- package/dist_ts/classes.proxydaemon.d.ts +8 -6
- package/dist_ts/classes.proxydaemon.js +35 -21
- package/dist_ts/classes.proxyleaseholder.d.ts +12 -4
- package/dist_ts/classes.proxyleaseholder.js +39 -9
- package/dist_ts/classes.proxystore.d.ts +4 -3
- package/dist_ts/classes.proxystore.js +17 -7
- package/dist_ts/classes.sessionfeed.d.ts +1 -1
- package/dist_ts/classes.validation.d.ts +7 -0
- package/dist_ts/classes.validation.js +49 -2
- package/dist_ts/driver/functions.drivertools.js +2 -2
- package/dist_ts/fleet/classes.codexworkers.d.ts +4 -11
- package/dist_ts/fleet/classes.codexworkers.js +6 -3
- package/dist_ts/fleet/classes.workers.d.ts +25 -13
- package/dist_ts/fleet/classes.workers.js +105 -9
- package/dist_ts/fleet/functions.workervalidation.d.ts +26 -1
- package/dist_ts/fleet/functions.workervalidation.js +40 -11
- package/dist_ts/fleet/interfaces.workers.d.ts +17 -11
- package/dist_ts/fleet/interfaces.workers.js +10 -1
- package/dist_ts/flexharness.child.js +9 -4
- package/dist_ts/functions.confinedrelay.d.ts +21 -0
- package/dist_ts/functions.confinedrelay.js +65 -0
- package/dist_ts/functions.deviceapi.d.ts +4 -2
- package/dist_ts/functions.deviceapi.js +20 -2
- package/dist_ts/functions.elicitation.d.ts +49 -0
- package/dist_ts/functions.elicitation.js +418 -0
- package/dist_ts/functions.flexchildshutdown.d.ts +7 -0
- package/dist_ts/functions.flexchildshutdown.js +18 -1
- package/dist_ts/functions.inferencecli.d.ts +3 -3
- package/dist_ts/functions.inferencecli.js +33 -10
- package/dist_ts/functions.inferencecliarguments.d.ts +2 -1
- package/dist_ts/functions.inferencecliarguments.js +29 -8
- package/dist_ts/functions.inferencelaunch.d.ts +35 -7
- package/dist_ts/functions.inferencelaunch.js +143 -16
- package/dist_ts/functions.mcpfleetworkertools.d.ts +63 -70
- package/dist_ts/functions.mcpfleetworkertools.js +32 -4
- package/dist_ts/functions.proxycontract.d.ts +21 -4
- package/dist_ts/functions.proxycontract.js +12 -5
- package/dist_ts/functions.proxyharnessconfig.d.ts +7 -0
- package/dist_ts/functions.proxyharnessconfig.js +11 -1
- package/dist_ts/interfaces.auth.d.ts +1 -1
- package/dist_ts/interfaces.auth.js +2 -1
- package/dist_ts_interfaces/devices.d.ts +133 -3
- package/dist_ts_interfaces/devices.js +3 -2
- package/dist_ts_interfaces/elicitations.d.ts +125 -0
- package/dist_ts_interfaces/elicitations.js +7 -0
- package/dist_ts_interfaces/fleetworkers.d.ts +119 -5
- package/dist_ts_interfaces/fleetworkers.js +14 -2
- package/dist_ts_interfaces/index.d.ts +1 -0
- package/dist_ts_interfaces/index.js +2 -1
- package/dist_ts_interfaces/interfaces.d.ts +3 -1
- package/dist_ts_interfaces/interfaces.js +2 -2
- package/dist_ts_interfaces/mcprequests.d.ts +5 -1
- package/dist_ts_interfaces/mcprequests.js +2 -1
- package/dist_ts_interfaces/nativesessions.d.ts +14 -0
- package/dist_ts_interfaces/requests.d.ts +3 -3
- package/dist_ts_interfaces/requests.fleetworkers.js +2 -2
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_interfaces/requests.promptreply.d.ts +18 -0
- package/dist_ts_interfaces/sessionfeed.d.ts +3 -2
- package/dist_ts_interfaces/sessionfeed.js +1 -1
- package/dist_ts_migration/index.d.ts +0 -2
- package/dist_ts_migration/index.js +1 -3
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.d.ts +6 -17
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.js +6 -36
- package/package.json +3 -3
- package/readme.md +191 -24
- package/third-party-notices.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +474 -3
- package/ts/aglapi/interfaces.ts +2 -0
- package/ts/classes.claudeharness.ts +80 -9
- package/ts/classes.codexclientadapter.ts +41 -5
- package/ts/classes.controller.ts +142 -29
- package/ts/classes.flexservice.ts +10 -66
- package/ts/classes.flexsupervisor.ts +214 -37
- package/ts/classes.inferencegateway.ts +69 -23
- package/ts/classes.inferencespend.ts +46 -13
- package/ts/classes.mcpclient.ts +8 -4
- package/ts/classes.mcpcontrollerhost.ts +4 -0
- package/ts/classes.mcptools.ts +17 -3
- package/ts/classes.opencodeclient.ts +2 -0
- package/ts/classes.proxycontrol.ts +27 -13
- package/ts/classes.proxycontrolclient.ts +9 -6
- package/ts/classes.proxydaemon.ts +49 -27
- package/ts/classes.proxyleaseholder.ts +43 -11
- package/ts/classes.proxystore.ts +21 -8
- package/ts/classes.sessionfeed.ts +1 -1
- package/ts/classes.validation.ts +52 -0
- package/ts/driver/functions.drivertools.ts +1 -1
- package/ts/fleet/classes.codexworkers.ts +8 -6
- package/ts/fleet/classes.workers.ts +101 -17
- package/ts/fleet/functions.workervalidation.ts +35 -9
- package/ts/fleet/interfaces.workers.ts +11 -4
- package/ts/flexharness.child.ts +8 -3
- package/ts/functions.confinedrelay.ts +65 -0
- package/ts/functions.deviceapi.ts +24 -1
- package/ts/functions.elicitation.ts +443 -0
- package/ts/functions.flexchildshutdown.ts +22 -0
- package/ts/functions.inferencecli.ts +38 -13
- package/ts/functions.inferencecliarguments.ts +26 -5
- package/ts/functions.inferencelaunch.ts +143 -16
- package/ts/functions.mcpfleetworkertools.ts +34 -4
- package/ts/functions.proxycontract.ts +17 -4
- package/ts/functions.proxyharnessconfig.ts +11 -0
- package/ts/interfaces.auth.ts +1 -0
- package/ts_interfaces/devices.schema.json +476 -2
- package/ts_interfaces/devices.ts +146 -2
- package/ts_interfaces/elicitations.ts +148 -0
- package/ts_interfaces/fleetworkers.ts +96 -4
- package/ts_interfaces/index.ts +1 -0
- package/ts_interfaces/interfaces.ts +3 -1
- package/ts_interfaces/mcprequests.ts +1 -0
- package/ts_interfaces/nativesessions.ts +16 -0
- package/ts_interfaces/requests.fleetworkers.ts +1 -1
- package/ts_interfaces/requests.promptreply.ts +22 -0
- package/ts_interfaces/requests.ts +4 -0
- package/ts_interfaces/sessionfeed.ts +3 -2
- package/ts_migration/index.ts +0 -2
- package/ts_migration/v43_flexpostharnessmigrationmarkers.ts +6 -49
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/classes.elicitationcards.ts +106 -0
- package/ts_web/classes.nativesessionstate.ts +38 -1
- package/ts_web/elements.fleetworker.ts +27 -2
- package/ts_web/elements.harnesscontrollerapp.ts +68 -1
- package/ts_web/functions.sessionchat.ts +5 -0
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.d.ts +0 -19
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.js +0 -34
- package/dist_ts_migration/v19_flexprojectmanagement.d.ts +0 -14
- package/dist_ts_migration/v19_flexprojectmanagement.js +0 -23
- package/ts_migration/classes.flexpostharnessmigrationrunner.ts +0 -54
- package/ts_migration/v19_flexprojectmanagement.ts +0 -32
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import { aglProxyConfinedClient, inferenceCredentials, inferencePlanPattern, inferenceProviders,
|
|
3
|
-
type TInferenceProvider } from './functions.proxycontract.js';
|
|
2
|
+
import { aglProxyConfinedClient, aglProxyConfinedCodexClient, inferenceCredentials, inferencePlanPattern, inferenceProviders,
|
|
3
|
+
type TInferenceCredential, type TInferenceProvider } from './functions.proxycontract.js';
|
|
4
4
|
import { InferenceRouter, InferenceRoutingError, inferenceSpendLimitText, type IInferenceAccountUnavailable,
|
|
5
5
|
type IInferenceClaudeRoute, type IInferenceRoute, type IInferenceRoutingPolicy,
|
|
6
6
|
type TInferencePaymentCause } from './classes.inferencerouter.js';
|
|
@@ -10,8 +10,8 @@ import { inferenceSessionId, inferenceSessionKey } from './classes.inferencesess
|
|
|
10
10
|
import type { IInferencePlacementJournal, IInferencePlacementRecord, TInferencePlacementReason } from './classes.inferenceplacement.js';
|
|
11
11
|
import { InferenceClaudeUsageTap, InferenceResponsesUsageTap, type IInferenceUsageTap } from './classes.inferenceusagetap.js';
|
|
12
12
|
import { inferenceAnthropicCheckedBytes, inferenceAnthropicServerToolTypes, inferenceAnthropicSpend,
|
|
13
|
-
inferenceAnthropicUnpricedRequest, inferenceOpenAiCheckedBytes,
|
|
14
|
-
inferenceOpenAiUnpricedRequest } from './classes.inferencespend.js';
|
|
13
|
+
inferenceAnthropicUnpricedRequest, inferenceOpenAiCheckedBytes, inferenceOpenAiServerToolChoiceTypes,
|
|
14
|
+
inferenceOpenAiServerToolTypes, inferenceOpenAiSpend, inferenceOpenAiUnpricedRequest } from './classes.inferencespend.js';
|
|
15
15
|
import { usageSessionPattern, type IInferenceTokenCounts, type IInferenceUsageLedger } from './classes.inferenceusage.js';
|
|
16
16
|
import { claimProxySocketPath } from './functions.proxysocket.js';
|
|
17
17
|
|
|
@@ -92,9 +92,11 @@ export interface IInferenceGatewayOptions {
|
|
|
92
92
|
usageLedger: IInferenceUsageLedger;
|
|
93
93
|
/**
|
|
94
94
|
* The confined listener's Unix socket, bound beside the loopback port and made this user's alone (0600, in a private
|
|
95
|
-
* directory that holds nothing else). It accepts confined credentials alone and serves
|
|
96
|
-
* Code uses (`confinedEndpoints`) of
|
|
97
|
-
* Claude Code on that pool
|
|
95
|
+
* directory that holds nothing else). It accepts confined credentials alone and serves a Claude Code run the three
|
|
96
|
+
* endpoints Claude Code uses (`confinedEndpoints`) of its pool, the Claude or the ChatGPT pool, exactly as the loopback
|
|
97
|
+
* listener serves Claude Code on that pool, and a Codex run Codex's two (`confinedCodexEndpoints`) of the ChatGPT pool's
|
|
98
|
+
* ChatGPT accounts, as the loopback listener serves Codex there, but no request that declares a hosted tool; unset, the
|
|
99
|
+
* gateway has no confined listener and admits no confined credential.
|
|
98
100
|
*/
|
|
99
101
|
confinedSocketPath?: string;
|
|
100
102
|
}
|
|
@@ -231,7 +233,8 @@ export interface IInferenceGatewayClientOptions {
|
|
|
231
233
|
sessionScope?: string;
|
|
232
234
|
/**
|
|
233
235
|
* Where the credential is accepted; `loopback` when unset. A confined credential is a lease of the Claude or the ChatGPT
|
|
234
|
-
* pool, accepted on the confined listener alone, and stays on the pool it was issued for
|
|
236
|
+
* pool, accepted on the confined listener alone, and stays on the pool it was issued for; one whose sessions are those of
|
|
237
|
+
* `aglProxyConfinedCodexClient` is a Codex run's, a lease of the ChatGPT pool's ChatGPT accounts alone.
|
|
235
238
|
*/
|
|
236
239
|
route?: TInferenceGatewayRoute;
|
|
237
240
|
}
|
|
@@ -318,12 +321,21 @@ const maximumErrorBodyBytes = 64 * 1024;
|
|
|
318
321
|
const catalogTag = (modelsArg: unknown): string =>
|
|
319
322
|
`"${plugins.crypto.createHash('sha256').update(JSON.stringify(modelsArg)).digest('base64url')}"`;
|
|
320
323
|
/**
|
|
321
|
-
* What the confined listener serves, by method and path: the endpoints Claude Code uses, of the Claude
|
|
322
|
-
* of the ChatGPT pool. Every other method and path, every `/openai/` path among them, is refused there
|
|
323
|
-
* read or routed.
|
|
324
|
+
* What the confined listener serves a Claude Code run, by method and path: the endpoints Claude Code uses, of the Claude
|
|
325
|
+
* pool or, translated, of the ChatGPT pool. Every other method and path, every `/openai/` path among them, is refused there
|
|
326
|
+
* before anything is read or routed.
|
|
324
327
|
*/
|
|
325
328
|
const confinedEndpoints: ReadonlySet<string> = new Set(['GET /anthropic/v1/models', 'POST /anthropic/v1/messages',
|
|
326
329
|
'POST /anthropic/v1/messages/count_tokens']);
|
|
330
|
+
/**
|
|
331
|
+
* What the confined listener serves a Codex run (AGL-1614), by method and path: Codex's model catalog and its Responses
|
|
332
|
+
* endpoint, of the ChatGPT pool's ChatGPT accounts. Every other method and path -- every `/anthropic/` path,
|
|
333
|
+
* `/openai/v1/messages`, `/responses/compact`, `/memories/*`, `/realtime/*` among them -- and every request that asks to
|
|
334
|
+
* upgrade its connection is refused there before anything is read or routed.
|
|
335
|
+
*/
|
|
336
|
+
const confinedCodexEndpoints: ReadonlySet<string> = new Set(['GET /openai/v1/models', 'POST /openai/v1/responses']);
|
|
337
|
+
/** The session scope of a Codex run's credential (`aglProxyConfinedCodexClient`). */
|
|
338
|
+
const confinedCodexScope = `client:${aglProxyConfinedCodexClient}`;
|
|
327
339
|
const turnStateLimit = 4096;
|
|
328
340
|
const turnStateLifetimeMs = 60 * 60 * 1000;
|
|
329
341
|
const clientVersionPattern = /^\d{1,6}\.\d{1,6}\.\d{1,6}(?:[-+][0-9A-Za-z.-]{1,32})?$/;
|
|
@@ -574,9 +586,11 @@ export const assertInferenceRoutingPolicy = (policyArg: IInferenceRoutingPolicy)
|
|
|
574
586
|
|
|
575
587
|
/**
|
|
576
588
|
* A confined credential is a lease of the Claude or the ChatGPT pool, admitted only by a gateway with a confined listener;
|
|
577
|
-
* `issuedArg` is the policy it was issued with, which a new policy may not move to another pool.
|
|
589
|
+
* `issuedArg` is the policy it was issued with, which a new policy may not move to another pool. A Codex run's
|
|
590
|
+
* (`scopeNameArg` names `aglProxyConfinedCodexClient`) is a lease of the ChatGPT pool's ChatGPT accounts alone, unrestricted,
|
|
591
|
+
* so no request of it reaches an OpenAI API key.
|
|
578
592
|
*/
|
|
579
|
-
const assertConfinedClient = (policyArg: IInferenceRoutingPolicy, nameArg: string | undefined,
|
|
593
|
+
const assertConfinedClient = (policyArg: IInferenceRoutingPolicy, nameArg: string | undefined, scopeNameArg: string | undefined,
|
|
580
594
|
socketPathArg: string | undefined, issuedArg?: IInferenceRoutingPolicy): void => {
|
|
581
595
|
if (socketPathArg === undefined) throw new Error('The gateway has no confined listener.');
|
|
582
596
|
if (nameArg !== undefined || (policyArg.provider !== 'anthropic' && policyArg.provider !== 'openai')) {
|
|
@@ -585,11 +599,18 @@ const assertConfinedClient = (policyArg: IInferenceRoutingPolicy, nameArg: strin
|
|
|
585
599
|
if (issuedArg !== undefined && policyArg.provider !== issuedArg.provider) {
|
|
586
600
|
throw new Error('A confined credential stays on the pool it was issued for.');
|
|
587
601
|
}
|
|
602
|
+
if (scopeNameArg === aglProxyConfinedCodexClient && (policyArg.provider !== 'openai' || policyArg.credential !== 'subscription'
|
|
603
|
+
|| Object.keys(policyArg).length !== 2)) {
|
|
604
|
+
throw new Error('A confined Codex credential is a lease of the ChatGPT pool\'s ChatGPT accounts alone.');
|
|
605
|
+
}
|
|
588
606
|
};
|
|
589
607
|
|
|
608
|
+
/** Whether a client is a confined Codex run's: accepted on the confined listener, its sessions the confined Codex client's. */
|
|
609
|
+
const confinedCodexRun = (clientArg: IClient): boolean => clientArg.route === 'confined' && clientArg.sessionScope === confinedCodexScope;
|
|
610
|
+
|
|
590
611
|
/**
|
|
591
612
|
* Authenticated Responses and Messages endpoints with bounded, cancelable streaming, on a loopback listener and, for
|
|
592
|
-
* confined credentials, a Unix socket that serves Claude Code's endpoints alone.
|
|
613
|
+
* confined credentials, a Unix socket that serves Claude Code's endpoints, or a Codex run Codex's, alone.
|
|
593
614
|
*/
|
|
594
615
|
export class InferenceGateway {
|
|
595
616
|
private readonly clients = new Set<IClient>();
|
|
@@ -672,7 +693,7 @@ export class InferenceGateway {
|
|
|
672
693
|
private async admit(policyArg: IInferenceRoutingPolicy, digestArg: Buffer, scopeNameArg: string | undefined,
|
|
673
694
|
nameArg: string | undefined, routeArg: TInferenceGatewayRoute): Promise<IInferenceGatewayGrant> {
|
|
674
695
|
assertInferenceRoutingPolicy(policyArg);
|
|
675
|
-
if (routeArg === 'confined') assertConfinedClient(policyArg, nameArg, this.options.confinedSocketPath);
|
|
696
|
+
if (routeArg === 'confined') assertConfinedClient(policyArg, nameArg, scopeNameArg, this.options.confinedSocketPath);
|
|
676
697
|
await (this.startTask ??= this.start());
|
|
677
698
|
this.abort.signal.throwIfAborted();
|
|
678
699
|
if (this.clients.size >= 128) throw new Error('The gateway has reached its client limit.');
|
|
@@ -685,7 +706,7 @@ export class InferenceGateway {
|
|
|
685
706
|
this.clients.add(client);
|
|
686
707
|
return { baseUrl: `http://${this.host}`, digest: digestArg.toString('hex'), setPolicy: (nextArg) => {
|
|
687
708
|
assertInferenceRoutingPolicy(nextArg);
|
|
688
|
-
if (routeArg === 'confined') assertConfinedClient(nextArg, nameArg, this.options.confinedSocketPath, client.policy);
|
|
709
|
+
if (routeArg === 'confined') assertConfinedClient(nextArg, nameArg, scopeNameArg, this.options.confinedSocketPath, client.policy);
|
|
689
710
|
client.policy = structuredClone(nextArg);
|
|
690
711
|
}, close: () => {
|
|
691
712
|
this.clients.delete(client);
|
|
@@ -818,17 +839,30 @@ export class InferenceGateway {
|
|
|
818
839
|
let releaseRoute: (() => void) | undefined;
|
|
819
840
|
let protocol: TProtocol | undefined;
|
|
820
841
|
try {
|
|
821
|
-
|
|
842
|
+
const confined = routeArg === 'confined';
|
|
843
|
+
const endpoint = confined ? `${requestArg.method} ${new URL(requestArg.url).pathname}` : '';
|
|
844
|
+
// A refusal on the confined listener before its client is known takes the shape of the API the path names: OpenAI's
|
|
845
|
+
// for an `/openai/` path, which a Codex run asks for, Claude's for any other.
|
|
846
|
+
if (confined) protocol = endpoint.includes(' /openai/') ? undefined : 'claude';
|
|
822
847
|
client = this.authenticate(requestArg, routeArg);
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
848
|
+
const codexRun = confinedCodexRun(client);
|
|
849
|
+
if (confined) protocol = codexRun ? undefined : 'claude';
|
|
850
|
+
// A Codex run is served Codex's two endpoints alone (AGL-1614), as plain HTTP requests: nothing upgrades its
|
|
851
|
+
// connection there, not even to a protocol Codex knows.
|
|
852
|
+
if (codexRun && (!confinedCodexEndpoints.has(endpoint) || requestArg.headers.has('upgrade'))) {
|
|
853
|
+
throw new InferenceRoutingError(404, 'not_found', 'The confined listener serves a Codex run GET /openai/v1/models and '
|
|
854
|
+
+ 'POST /openai/v1/responses alone, without a connection upgrade.');
|
|
855
|
+
}
|
|
856
|
+
// On either pool the confined listener serves a Claude Code run Claude Code's three endpoints alone, as the loopback
|
|
857
|
+
// listener serves Claude Code on that pool; a ChatGPT-pool run never reaches a Responses or OpenAI models endpoint.
|
|
858
|
+
if (confined && !codexRun && !confinedEndpoints.has(endpoint)) {
|
|
826
859
|
throw new InferenceRoutingError(404, 'not_found', 'The confined listener serves GET /anthropic/v1/models, '
|
|
827
860
|
+ 'POST /anthropic/v1/messages and POST /anthropic/v1/messages/count_tokens alone.');
|
|
828
861
|
}
|
|
829
|
-
// From here on a confined request is answered exactly as the loopback listener answers Claude Code
|
|
830
|
-
// errors included; only the refusals above
|
|
831
|
-
|
|
862
|
+
// From here on a confined request is answered exactly as the loopback listener answers Claude Code or Codex on its
|
|
863
|
+
// pool, its errors included; only the refusals above, in Claude's shape for a Claude Code run, and a Codex run's
|
|
864
|
+
// hosted tools below are the confined listener's own.
|
|
865
|
+
if (confined && client.policy.provider !== 'anthropic') protocol = undefined;
|
|
832
866
|
if (this.inFlight >= this.limits.total) throw new InferenceRoutingError(429, 'concurrency_limit', 'The gateway has too many requests in flight.', 1);
|
|
833
867
|
if (client.pending >= this.limits.perClient) throw new InferenceRoutingError(429, 'concurrency_limit', 'This gateway client has too many requests.', 1);
|
|
834
868
|
client.pending += 1;
|
|
@@ -885,6 +919,18 @@ export class InferenceGateway {
|
|
|
885
919
|
if (typeof body.model !== 'string' || !body.model || body.model.length > 256) {
|
|
886
920
|
throw new InferenceRoutingError(400, 'invalid_request', 'A model from /v1/models is required.');
|
|
887
921
|
}
|
|
922
|
+
// A Codex run uses no tool the provider runs (AGL-1614): web search, file search, code interpreter, image generation,
|
|
923
|
+
// remote MCP and every other server tool would reach past the container. Refused before anything is routed, declared
|
|
924
|
+
// or named by `tool_choice` alone, which the route does not leave to the provider to refuse.
|
|
925
|
+
if (codexRun) {
|
|
926
|
+
const hosted = [...inferenceOpenAiServerToolTypes(body), ...inferenceOpenAiServerToolChoiceTypes(body)];
|
|
927
|
+
if (hosted.length) {
|
|
928
|
+
throw new InferenceRoutingError(400, 'hosted_tool_refused', `A confined Codex run uses no hosted tool; this request `
|
|
929
|
+
+ `declares or chooses ${[...new Set(hosted)].slice(0, 8).map((typeArg) => JSON.stringify(refusalText(typeArg, 64))).join(', ')}. `
|
|
930
|
+
+ 'Turn them off in its Codex configuration (web_search = "disabled", features.image_generation = false, '
|
|
931
|
+
+ 'apps and plugins off).');
|
|
932
|
+
}
|
|
933
|
+
}
|
|
888
934
|
const model = body.model;
|
|
889
935
|
const sessionKey = inferenceSessionKey(request.headers, body, client.sessionScope, claude ? 'anthropic' : 'openai');
|
|
890
936
|
if ((this.sessionsInFlight.get(sessionKey) ?? 0) >= this.limits.perSession) {
|
|
@@ -192,25 +192,58 @@ const openAiClientToolTypes: ReadonlySet<string> = new Set(['function', 'custom'
|
|
|
192
192
|
'computer_use_preview']);
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* tool (`openAiClientToolTypes`, a local `shell`); a type that is no string is named as it reads.
|
|
195
|
+
* Every tool a Responses request declares, in `tools` and in the tools its input adds (`additional_tools` and
|
|
196
|
+
* `tool_search_output` items), a namespace's own tools in its place.
|
|
198
197
|
*/
|
|
199
|
-
|
|
200
|
-
const declared = (toolsArg: unknown):
|
|
201
|
-
|
|
202
|
-
const type = tool.type;
|
|
203
|
-
if (type === 'namespace') return declared(tool.tools);
|
|
204
|
-
if ((typeof type === 'string' && openAiClientToolTypes.has(type))
|
|
205
|
-
|| (type === 'shell' && isRecord(tool.environment) && tool.environment.type === 'local')
|
|
206
|
-
|| (type === 'tool_search' && tool.execution === 'client')) return [];
|
|
207
|
-
return [typeof type === 'string' ? type : String(JSON.stringify(type))];
|
|
208
|
-
});
|
|
198
|
+
const declaredOpenAiTools = (bodyArg: Record<string, unknown>): unknown[] => {
|
|
199
|
+
const declared = (toolsArg: unknown): unknown[] => (Array.isArray(toolsArg) ? toolsArg : [])
|
|
200
|
+
.flatMap((toolArg) => isRecord(toolArg) && toolArg.type === 'namespace' ? declared(toolArg.tools) : [toolArg]);
|
|
209
201
|
const added = (Array.isArray(bodyArg.input) ? bodyArg.input : []).flatMap((itemArg) => isRecord(itemArg)
|
|
210
202
|
&& (itemArg.type === 'additional_tools' || itemArg.type === 'tool_search_output') ? declared(itemArg.tools) : []);
|
|
211
203
|
return [...declared(bodyArg.tools), ...added];
|
|
212
204
|
};
|
|
213
205
|
|
|
206
|
+
/** Whether a declared tool is a client tool (`openAiClientToolTypes`, a local `shell`, a client-run `tool_search`). */
|
|
207
|
+
const isOpenAiClientTool = (toolArg: unknown): boolean => {
|
|
208
|
+
const tool: Record<string, unknown> = isRecord(toolArg) ? toolArg : {};
|
|
209
|
+
const type = tool.type;
|
|
210
|
+
return (typeof type === 'string' && openAiClientToolTypes.has(type))
|
|
211
|
+
|| (type === 'shell' && isRecord(tool.environment) && tool.environment.type === 'local')
|
|
212
|
+
|| (type === 'tool_search' && tool.execution === 'client');
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/** A tool's `type` as a refusal names it: a type that is no string as it reads. */
|
|
216
|
+
const openAiToolTypeText = (toolArg: unknown): string => {
|
|
217
|
+
const type = isRecord(toolArg) ? toolArg.type : undefined;
|
|
218
|
+
return typeof type === 'string' ? type : String(JSON.stringify(type));
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The `type` of every server tool a Responses request declares (`declaredOpenAiTools`): each tool that is no client
|
|
223
|
+
* tool (`isOpenAiClientTool`); a type that is no string is named as it reads.
|
|
224
|
+
*/
|
|
225
|
+
export const inferenceOpenAiServerToolTypes = (bodyArg: Record<string, unknown>): string[] =>
|
|
226
|
+
declaredOpenAiTools(bodyArg).filter((toolArg) => !isOpenAiClientTool(toolArg)).map(openAiToolTypeText);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The `type` of every server tool a Responses request's `tool_choice` names (AGL-1614): an object choice, or each tool
|
|
230
|
+
* of an `allowed_tools` choice, whose type is no client tool's (`openAiClientToolTypes`). A `shell` or `tool_search`
|
|
231
|
+
* choice names the request's declared tool of that type, a client tool's only when the request declares that type and
|
|
232
|
+
* every declared tool of it is a client tool. A string choice (`auto`, `none`, `required`) names no type.
|
|
233
|
+
*/
|
|
234
|
+
export const inferenceOpenAiServerToolChoiceTypes = (bodyArg: Record<string, unknown>): string[] => {
|
|
235
|
+
const choice = bodyArg.tool_choice;
|
|
236
|
+
if (!isRecord(choice)) return [];
|
|
237
|
+
const declared = declaredOpenAiTools(bodyArg);
|
|
238
|
+
const named = choice.type === 'allowed_tools' ? Array.isArray(choice.tools) ? choice.tools : [] : [choice];
|
|
239
|
+
return named.filter((namedArg) => {
|
|
240
|
+
const type = isRecord(namedArg) ? namedArg.type : undefined;
|
|
241
|
+
if (typeof type === 'string' && openAiClientToolTypes.has(type)) return false;
|
|
242
|
+
const ofType = declared.filter((toolArg) => isRecord(toolArg) && toolArg.type === type);
|
|
243
|
+
return !((type === 'shell' || type === 'tool_search') && ofType.length > 0 && ofType.every(isOpenAiClientTool));
|
|
244
|
+
}).map(openAiToolTypeText);
|
|
245
|
+
};
|
|
246
|
+
|
|
214
247
|
/**
|
|
215
248
|
* The service tier a Responses request goes to an OpenAI API key with a spend limit on: the one the client named when it
|
|
216
249
|
* named a tier the price table prices for the model, else Standard (`default`), never `auto`, which a project set to Fast
|
package/ts/classes.mcpclient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { fleetWorkerErrorCodes, fleetWorkerReadActions, type TFleetWorkerAction, type TFleetWorkerErrorCode, type TFleetWorkerRequest, type TFleetWorkerResponseTo } from '../ts_interfaces/fleetworkers.js';
|
|
2
2
|
import { assertFleetWorkerWireRequest, assertFleetWorkerResponse } from './fleet/functions.workervalidation.js';
|
|
3
3
|
import * as plugins from './plugins.js';
|
|
4
4
|
import { assertWorkerCallerEnrollmentResponse } from './functions.workercallervalidation.js';
|
|
@@ -110,7 +110,8 @@ export type TControllerMcpClientErrorCode =
|
|
|
110
110
|
| 'MESSAGE_RATE_LIMITED'
|
|
111
111
|
| 'DELIVERY_UNSUPPORTED'
|
|
112
112
|
| 'REQUEST_FAILED'
|
|
113
|
-
| 'OUTCOME_UNKNOWN'
|
|
113
|
+
| 'OUTCOME_UNKNOWN'
|
|
114
|
+
| Uppercase<TFleetWorkerErrorCode>;
|
|
114
115
|
|
|
115
116
|
export class ControllerMcpClientError extends Error {
|
|
116
117
|
public readonly code: TControllerMcpClientErrorCode;
|
|
@@ -728,10 +729,10 @@ export class ControllerMcpClient {
|
|
|
728
729
|
['create', 'update', 'move', 'comment', 'link', 'unlink', 'ask', 'answer'].includes(methodArg)) as Promise<TTicketResponse<TMethod>>;
|
|
729
730
|
}
|
|
730
731
|
|
|
731
|
-
public async fleetWorker<T extends TFleetWorkerAction
|
|
732
|
+
public async fleetWorker<T extends TFleetWorkerAction, R extends TFleetWorkerRequest<T> & { ownerToken: string } = TFleetWorkerRequest<T> & { ownerToken: string }>(action: T, request: R, signal?: AbortSignal): Promise<TFleetWorkerResponseTo<T, R>> {
|
|
732
733
|
const method = `agl.mcp.fleet.worker.${action}` as const;
|
|
733
734
|
const wireRequest = assertFleetWorkerWireRequest(method, request);
|
|
734
|
-
return this.dispatchAfterHandshake(method, wireRequest as never, signal, !
|
|
735
|
+
return this.dispatchAfterHandshake(method, wireRequest as never, signal, !(fleetWorkerReadActions as readonly string[]).includes(action)) as Promise<TFleetWorkerResponseTo<T, R>>;
|
|
735
736
|
}
|
|
736
737
|
|
|
737
738
|
/** The session feed's rows as the local owner reads them; `state` keeps one group. */
|
|
@@ -986,6 +987,9 @@ export class ControllerMcpClient {
|
|
|
986
987
|
if (serverCode === 'agent_messages_disabled') code = 'AGENT_MESSAGES_DISABLED';
|
|
987
988
|
if (serverCode === 'message_rate_limited') code = 'MESSAGE_RATE_LIMITED';
|
|
988
989
|
if (serverCode === 'delivery_unsupported') code = 'DELIVERY_UNSUPPORTED';
|
|
990
|
+
if (methodArg.startsWith('agl.mcp.fleet.worker.') && (fleetWorkerErrorCodes as readonly unknown[]).includes(serverCode)) {
|
|
991
|
+
code = (serverCode as TFleetWorkerErrorCode).toUpperCase() as Uppercase<TFleetWorkerErrorCode>;
|
|
992
|
+
}
|
|
989
993
|
}
|
|
990
994
|
} catch {
|
|
991
995
|
throw new ControllerMcpClientError('PROTOCOL_MISMATCH', 'The controller response is invalid.');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { controllerMcpFleetWorkerMethods, type TControllerMcpFleetWorkerTypedRequest } from '../ts_interfaces/requests.fleetworkers.js';
|
|
2
|
+
import { fleetWorkerErrorCodes } from '../ts_interfaces/fleetworkers.js';
|
|
2
3
|
import type { TFleetWorkerAction, TFleetWorkerResponse } from '../ts_interfaces/fleetworkers.js';
|
|
3
4
|
import type {
|
|
4
5
|
IReq_ControllerMcpBrowserAction,
|
|
@@ -299,6 +300,9 @@ const safeTypedResponseError = (
|
|
|
299
300
|
if (methodArg.startsWith('agl.mcp.deploy.') && (deployErrorCodes as readonly unknown[]).includes(code)) {
|
|
300
301
|
return new plugins.typedrequest.TypedResponseError(errorArg.message.slice(0, 1024), { code });
|
|
301
302
|
}
|
|
303
|
+
if (methodArg.startsWith('agl.mcp.fleet.worker.') && (fleetWorkerErrorCodes as readonly unknown[]).includes(code)) {
|
|
304
|
+
return new plugins.typedrequest.TypedResponseError(errorArg.message.slice(0, 1024), { code });
|
|
305
|
+
}
|
|
302
306
|
if (typeof code === 'string' && /^[a-z0-9_]{1,64}$/.test(code)) {
|
|
303
307
|
const messages: Record<string, string> = {
|
|
304
308
|
...ticketErrorMessages,
|
package/ts/classes.mcptools.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { fleetWorkerToolDefinitions } from './functions.mcpfleetworkertools.js';
|
|
1
|
+
import { fleetWorkerToolDefinitions, waitForFleetWorkerJob } from './functions.mcpfleetworkertools.js';
|
|
2
2
|
import { assertControllerMcpWorkspaceRequest, assertControllerMcpWorkspaceResponse } from './classes.mcpvalidation.js';
|
|
3
3
|
import type { TControllerMcpWorkspaceMethod } from '../ts_interfaces/mcpworkspacerequests.js';
|
|
4
|
+
import type { TFleetWorkerRequest } from '../ts_interfaces/fleetworkers.js';
|
|
4
5
|
import * as plugins from './mcp.plugins.js';
|
|
5
6
|
import {
|
|
6
7
|
controllerAgentMessageMaxTextBytes,
|
|
@@ -89,7 +90,9 @@ export const aglMcpToolNames = [
|
|
|
89
90
|
'fleet_worker_refresh',
|
|
90
91
|
'fleet_worker_move',
|
|
91
92
|
'fleet_worker_list',
|
|
93
|
+
'fleet_worker_get',
|
|
92
94
|
'fleet_worker_status',
|
|
95
|
+
'fleet_worker_job_wait',
|
|
93
96
|
'fleet_watch',
|
|
94
97
|
'fleet_worker_native_message',
|
|
95
98
|
'deploy_status',
|
|
@@ -294,6 +297,11 @@ const safeClientMessages: Record<ControllerMcpClientError['code'], string> = {
|
|
|
294
297
|
JOB_CWD_FORBIDDEN: 'cwd must be an existing directory inside the project, reached without symbolic links.',
|
|
295
298
|
JOB_LOG_UNAVAILABLE: 'The job log no longer exists.',
|
|
296
299
|
JOB_OFFSET_INVALID: 'fromOffset lies beyond the end of the job log; read job_status for its size.',
|
|
300
|
+
JOB_UNAVAILABLE: 'The controller holds no such fleet operation job of this owner: jobs are transient and end with a controller restart or eviction. The job did not fail by this; read the worker with fleet_worker_get.',
|
|
301
|
+
WORKER_NOT_FOUND: 'This owner has no fleet worker of that name or id. Use fleet_worker_list.',
|
|
302
|
+
LIST_CURSOR_MISMATCH: 'The cursor pages another filter (archived, ticketKey, state, harness); repeat that filter or list again without cursor.',
|
|
303
|
+
LIST_CURSOR_STALE: 'The cursor continues after a worker this owner no longer holds as it was; list again without cursor.',
|
|
304
|
+
LIST_CURSOR_INVALID: 'The cursor is not the nextCursor of a fleet_worker_list summary page; list again without cursor.',
|
|
297
305
|
REQUEST_FAILED: 'The private AGL controller request failed.',
|
|
298
306
|
TURN_ENDED: 'The turn the message was to steer has ended; nothing was sent. Read the task before sending again.',
|
|
299
307
|
AGENT_MESSAGES_DISABLED: 'The owner does not accept agent messages for this project.',
|
|
@@ -651,8 +659,14 @@ export class AglMcpTools {
|
|
|
651
659
|
description: definition.description, inputSchema: definition.inputSchema,
|
|
652
660
|
annotations: { readOnlyHint: definition.readOnly, destructiveHint: !definition.readOnly, openWorldHint: true },
|
|
653
661
|
}, async (input, extra) => this.runToolCall(extra, async () => this.withFleetOwner(async (ownerToken) => {
|
|
654
|
-
|
|
655
|
-
|
|
662
|
+
const client = this.client;
|
|
663
|
+
if (!client.fleetWorker) throw new Error('Fleet worker API is unavailable.');
|
|
664
|
+
if (definition.action === 'job-wait') {
|
|
665
|
+
// One private request is bounded by the private request timeout; the wait runs in slices.
|
|
666
|
+
const { id, timeoutMs } = input as TFleetWorkerRequest<'job-wait'>;
|
|
667
|
+
return waitForFleetWorkerJob((sliceMs) => client.fleetWorker!('job-wait', { id, timeoutMs: sliceMs, ownerToken }, extra.signal), timeoutMs);
|
|
668
|
+
}
|
|
669
|
+
return client.fleetWorker(definition.action, { ...input as Record<string, unknown>, ownerToken } as never, extra.signal);
|
|
656
670
|
}))));
|
|
657
671
|
}
|
|
658
672
|
}
|
|
@@ -3881,6 +3881,8 @@ export class OpenCodeClientAdapter implements IOpenCodeSessionIdentitySnapshotCa
|
|
|
3881
3881
|
messagePage,
|
|
3882
3882
|
permissions,
|
|
3883
3883
|
questions,
|
|
3884
|
+
// OpenCode hands AGL no MCP elicitations.
|
|
3885
|
+
elicitations: [],
|
|
3884
3886
|
todos,
|
|
3885
3887
|
...(model ? { model } : {}),
|
|
3886
3888
|
...(effort ? { effort } : {}),
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
proxyClientNamePattern,
|
|
13
13
|
proxyCredentialDeliveries,
|
|
14
14
|
type TInferenceCredential,
|
|
15
|
+
type TAglProxyConfinedHarness,
|
|
15
16
|
type TInferenceProvider,
|
|
16
17
|
type TProxyCredentialDelivery,
|
|
17
18
|
} from './functions.proxycontract.js';
|
|
@@ -74,6 +75,8 @@ export interface IAglProxyConfinedRunStatus {
|
|
|
74
75
|
id: string;
|
|
75
76
|
/** The pool the run is served from: Claude accounts (`anthropic`) or ChatGPT accounts (`openai`). */
|
|
76
77
|
provider: TInferenceProvider;
|
|
78
|
+
/** The harness the run serves: Claude Code on either pool, or Codex on the ChatGPT pool's ChatGPT accounts alone. */
|
|
79
|
+
harness: TAglProxyConfinedHarness;
|
|
77
80
|
createdAt: string;
|
|
78
81
|
/** False while a restarted proxy serves the credential for its reclaim window, waiting for its holder to take it back. */
|
|
79
82
|
held: boolean;
|
|
@@ -149,31 +152,39 @@ export interface IReq_AglProxyReclaim extends ITypedRequest {
|
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
/**
|
|
152
|
-
* A confined run's credential: accepted on the confined listener alone, never on the loopback one
|
|
153
|
-
* the pool `provider` names -- the Claude pool when it names none -- exactly as the loopback listener
|
|
154
|
-
* that pool, its sessions those of the client `aglProxyConfinedClient` on that pool
|
|
155
|
-
* pool's ChatGPT accounts alone, since a translated Messages request never goes to an API key.
|
|
156
|
-
*
|
|
155
|
+
* A confined run's credential: accepted on the confined listener alone, never on the loopback one. A Claude Code run is
|
|
156
|
+
* served there from the pool `provider` names -- the Claude pool when it names none -- exactly as the loopback listener
|
|
157
|
+
* serves Claude Code on that pool, its sessions those of the client `aglProxyConfinedClient` on that pool; a ChatGPT-pool
|
|
158
|
+
* run is served by the pool's ChatGPT accounts alone, since a translated Messages request never goes to an API key. A
|
|
159
|
+
* Codex run (`harness: 'codex'`, of the ChatGPT pool alone) is served Codex's model catalog and Responses endpoint by the
|
|
160
|
+
* ChatGPT pool's ChatGPT accounts alone, never an OpenAI API key, its sessions those of `aglProxyConfinedCodexClient`. Like
|
|
161
|
+
* a lease it lives as long as the connection that asked for it, a restarted proxy keeps it for its holder to take back
|
|
157
162
|
* (`agl.proxy.reclaim`), and the proxy keeps only its digest. `agl.proxy.confined.end` ends it at once.
|
|
158
163
|
*/
|
|
159
164
|
export interface IReq_AglProxyConfined extends ITypedRequest {
|
|
160
165
|
method: 'agl.proxy.confined';
|
|
161
|
-
/**
|
|
162
|
-
|
|
166
|
+
/**
|
|
167
|
+
* An empty request asks for a Claude-pool run, as every proxy since confined runs takes it; `harness: 'codex'` asks for
|
|
168
|
+
* a Codex run, which names no pool or the ChatGPT pool. A proxy before Codex runs refuses the key as an invalid request.
|
|
169
|
+
*/
|
|
170
|
+
request: { provider?: TInferenceProvider; harness?: 'codex' };
|
|
163
171
|
response: IAglProxyConfinedGrant;
|
|
164
172
|
}
|
|
165
173
|
|
|
166
174
|
/**
|
|
167
|
-
* What a confined run is given: its id, its pool, its credential, the confined listener's socket and the
|
|
168
|
-
* with it, and, for a ChatGPT-pool run, the pool's models as the proxy read them when it issued
|
|
169
|
-
* launcher configures Claude Code with as `agl proxy run claude --provider openai` does. A
|
|
170
|
-
* Claude Code reads that pool's models through the confined listener
|
|
175
|
+
* What a confined run is given: its id, its pool and harness, its credential, the confined listener's socket and the
|
|
176
|
+
* origin to name with it, and, for a ChatGPT-pool Claude Code run, the pool's models as the proxy read them when it issued
|
|
177
|
+
* the credential, which the launcher configures Claude Code with as `agl proxy run claude --provider openai` does. A
|
|
178
|
+
* Claude-pool run gets none: Claude Code reads that pool's models through the confined listener; nor does a Codex run,
|
|
179
|
+
* whose Codex reads the pool's Codex catalog there.
|
|
171
180
|
*/
|
|
172
181
|
export interface IAglProxyConfinedGrant {
|
|
173
182
|
/** See `IAglProxyConfinedRunStatus.id`. */
|
|
174
183
|
id: string;
|
|
175
184
|
/** The run's pool; a proxy older than ChatGPT-pool runs names none, and issues Claude-pool runs alone. */
|
|
176
185
|
provider?: TInferenceProvider;
|
|
186
|
+
/** The run's harness; a proxy older than Codex runs names none, and issues Claude Code runs alone. */
|
|
187
|
+
harness?: TAglProxyConfinedHarness;
|
|
177
188
|
token: string;
|
|
178
189
|
socketPath: string;
|
|
179
190
|
baseUrl: string;
|
|
@@ -316,8 +327,11 @@ export class AglProxyControlServer {
|
|
|
316
327
|
return this.handlers!.reclaim(requestArg, connectionArg);
|
|
317
328
|
}));
|
|
318
329
|
this.router.addTypedHandler(handler<IReq_AglProxyConfined>('agl.proxy.confined', (requestArg, connectionArg) => {
|
|
319
|
-
|
|
320
|
-
|
|
330
|
+
// A Codex run is of the ChatGPT pool alone.
|
|
331
|
+
if (!isRecord(requestArg) || Object.keys(requestArg).some((keyArg) => keyArg !== 'provider' && keyArg !== 'harness')
|
|
332
|
+
|| (requestArg.provider !== undefined && !inferenceProviders.includes(requestArg.provider))
|
|
333
|
+
|| (requestArg.harness !== undefined && requestArg.harness !== 'codex')
|
|
334
|
+
|| (requestArg.harness === 'codex' && requestArg.provider !== undefined && requestArg.provider !== 'openai')) {
|
|
321
335
|
throw new AglProxyControlRefusal('Invalid proxy confined request.');
|
|
322
336
|
}
|
|
323
337
|
return this.handlers!.confined(requestArg, connectionArg);
|
|
@@ -16,7 +16,8 @@ import type {
|
|
|
16
16
|
} from './classes.proxycontrol.js';
|
|
17
17
|
import type { IInferenceUsageChangesRequest, IInferenceUsageSnapshotPage, IInferenceUsageSnapshotRequest,
|
|
18
18
|
TInferenceUsageChanges } from './classes.inferenceusage.js';
|
|
19
|
-
import type { TInferenceCredential, TInferenceProvider,
|
|
19
|
+
import type { TAglProxyConfinedRun, TInferenceCredential, TInferenceProvider,
|
|
20
|
+
TProxyCredentialDelivery } from './functions.proxycontract.js';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* The client of the proxy's private control socket. It needs nothing but Node's own modules, so the command a harness
|
|
@@ -190,14 +191,16 @@ export class AglProxyControlClient {
|
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
/**
|
|
193
|
-
* A confined run's credential
|
|
194
|
-
* with it; the credential lives as long as the returned connection (see `IReq_AglProxyConfined`). A Claude-pool run
|
|
195
|
-
* asked for with the empty request every proxy since confined runs takes
|
|
194
|
+
* A confined run's credential for the harness and pool `runArg` names, the confined listener's socket and the origin to
|
|
195
|
+
* name with it; the credential lives as long as the returned connection (see `IReq_AglProxyConfined`). A Claude-pool run
|
|
196
|
+
* is asked for with the empty request every proxy since confined runs takes, a ChatGPT-pool Claude Code run with the
|
|
197
|
+
* pool alone, as proxies since ChatGPT-pool runs take it, and a Codex run with the harness alone.
|
|
196
198
|
*/
|
|
197
|
-
public async confined(
|
|
199
|
+
public async confined(runArg: TAglProxyConfinedRun,
|
|
198
200
|
signalArg: AbortSignal): Promise<IReq_AglProxyConfined['response'] & IAglProxyLeaseConnection> {
|
|
199
201
|
let held: { socket: net.Socket; rest: Buffer } | undefined;
|
|
200
|
-
const request: IReq_AglProxyConfined['request'] =
|
|
202
|
+
const request: IReq_AglProxyConfined['request'] = runArg.harness === 'codex' ? { harness: 'codex' }
|
|
203
|
+
: runArg.provider === 'anthropic' ? {} : { provider: runArg.provider };
|
|
201
204
|
const response = await exchange<IReq_AglProxyConfined['response']>(this.socketPath, 'agl.proxy.confined', request,
|
|
202
205
|
signalArg, (socketArg, restArg) => { held = { socket: socketArg, rest: restArg }; });
|
|
203
206
|
return { ...response, ...leaseConnection(held) };
|