agl 43.3.2 → 43.5.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 +33 -0
- package/dist_serve/bundle.js +2248 -2236
- 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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/interfaces.d.ts +5 -0
- package/dist_ts/aglapi/interfaces.js +2 -1
- package/dist_ts/classes.authstore.js +5 -2
- package/dist_ts/classes.claudeharness.js +4 -3
- package/dist_ts/classes.codexclientadapter.d.ts +5 -0
- package/dist_ts/classes.codexclientadapter.js +12 -6
- package/dist_ts/classes.controller.d.ts +32 -6
- package/dist_ts/classes.controller.js +165 -62
- package/dist_ts/classes.inferencegateway.js +14 -2
- package/dist_ts/classes.inferencerouter.d.ts +9 -1
- package/dist_ts/classes.inferencerouter.js +68 -14
- package/dist_ts/classes.mcpclient.d.ts +2 -2
- package/dist_ts/classes.mcpclient.js +14 -9
- package/dist_ts/classes.mcptools.d.ts +1 -1
- package/dist_ts/classes.mcptools.js +2 -1
- package/dist_ts/classes.opencodeclient.js +20 -4
- package/dist_ts/driver/functions.driverinstructions.d.ts +1 -1
- package/dist_ts/driver/functions.driverinstructions.js +2 -1
- package/dist_ts/fleet/classes.claudeworkers.d.ts +8 -5
- package/dist_ts/fleet/classes.claudeworkers.js +13 -8
- package/dist_ts/fleet/classes.deploymodels.d.ts +58 -1
- package/dist_ts/fleet/classes.deploymodels.js +121 -2
- package/dist_ts/fleet/classes.deploymonitor.d.ts +193 -47
- package/dist_ts/fleet/classes.deploymonitor.js +548 -180
- package/dist_ts/fleet/classes.gitfacts.d.ts +4 -1
- package/dist_ts/fleet/classes.gitfacts.js +13 -10
- package/dist_ts/fleet/classes.service.d.ts +2 -0
- package/dist_ts/fleet/classes.service.js +6 -3
- package/dist_ts/fleet/functions.deployprobes.js +21 -2
- package/dist_ts/fleet/functions.deploystatus.d.ts +26 -0
- package/dist_ts/fleet/functions.deploystatus.js +33 -0
- package/dist_ts/fleet/functions.deployvalidation.d.ts +1 -0
- package/dist_ts/fleet/functions.deployvalidation.js +5 -2
- package/dist_ts/functions.claudecoderelease.d.ts +1 -1
- package/dist_ts/functions.claudecoderelease.js +1 -1
- package/dist_ts/functions.deploycli.js +3 -2
- package/dist_ts/functions.deviceapi.d.ts +7 -6
- package/dist_ts/functions.deviceapi.js +13 -5
- package/dist_ts/functions.inferencecli.js +10 -2
- package/dist_ts/functions.inferencelaunch.d.ts +19 -8
- package/dist_ts/functions.inferencelaunch.js +23 -12
- package/dist_ts/functions.mcpdeploytools.js +3 -1
- package/dist_ts/functions.promptreply.d.ts +13 -0
- package/dist_ts/functions.promptreply.js +17 -0
- package/dist_ts/functions.proxyharnessconfig.d.ts +18 -0
- package/dist_ts/functions.proxyharnessconfig.js +30 -1
- package/dist_ts_authswitch/authority-renewal.d.ts +12 -3
- package/dist_ts_authswitch/authority-renewal.js +14 -5
- package/dist_ts_authswitch/classes.claudenative.d.ts +8 -8
- package/dist_ts_authswitch/classes.claudenative.js +13 -13
- package/dist_ts_interfaces/deployments.d.ts +38 -6
- package/dist_ts_interfaces/deployments.js +7 -3
- package/dist_ts_interfaces/devices.d.ts +2 -1
- package/dist_ts_interfaces/devices.js +1 -1
- package/dist_ts_interfaces/inbox.d.ts +10 -1
- package/dist_ts_interfaces/inbox.js +1 -1
- package/dist_ts_interfaces/mcprequests.d.ts +1 -1
- package/dist_ts_interfaces/requests.accounts.d.ts +5 -0
- package/dist_ts_interfaces/requests.accounts.js +3 -1
- package/docs/authswitch.md +5 -4
- package/package.json +2 -2
- package/readme.md +49 -21
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/interfaces.ts +1 -0
- package/ts/classes.authstore.ts +4 -1
- package/ts/classes.claudeharness.ts +3 -2
- package/ts/classes.codexclientadapter.ts +11 -5
- package/ts/classes.controller.ts +177 -73
- package/ts/classes.inferencegateway.ts +15 -1
- package/ts/classes.inferencerouter.ts +72 -13
- package/ts/classes.mcpclient.ts +14 -5
- package/ts/classes.mcptools.ts +1 -0
- package/ts/classes.opencodeclient.ts +23 -3
- package/ts/driver/functions.driverinstructions.ts +1 -0
- package/ts/fleet/classes.claudeworkers.ts +12 -7
- package/ts/fleet/classes.deploymodels.ts +113 -1
- package/ts/fleet/classes.deploymonitor.ts +565 -179
- package/ts/fleet/classes.gitfacts.ts +10 -8
- package/ts/fleet/classes.service.ts +7 -1
- package/ts/fleet/functions.deployprobes.ts +16 -1
- package/ts/fleet/functions.deploystatus.ts +56 -0
- package/ts/fleet/functions.deployvalidation.ts +4 -1
- package/ts/functions.claudecoderelease.ts +1 -1
- package/ts/functions.deploycli.ts +2 -1
- package/ts/functions.deviceapi.ts +19 -9
- package/ts/functions.inferencecli.ts +7 -1
- package/ts/functions.inferencelaunch.ts +35 -14
- package/ts/functions.mcpdeploytools.ts +2 -0
- package/ts/functions.promptreply.ts +20 -0
- package/ts/functions.proxyharnessconfig.ts +32 -0
- package/ts_authswitch/authority-renewal.ts +14 -4
- package/ts_authswitch/classes.claudenative.ts +12 -12
- package/ts_authswitch/native-contracts.md +250 -28
- package/ts_interfaces/deployments.ts +39 -6
- package/ts_interfaces/devices.schema.json +1 -1
- package/ts_interfaces/devices.ts +2 -1
- package/ts_interfaces/inbox.ts +8 -1
- package/ts_interfaces/requests.accounts.ts +2 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/classes.accountsreadmodel.ts +19 -7
- package/ts_web/elements.accounts.ts +31 -18
- package/ts_web/elements.deployments.ts +20 -4
- package/ts_web/elements.harnesscontrollerapp.ts +43 -13
- package/ts_web/elements.inbox.ts +3 -3
|
@@ -53,19 +53,21 @@ export class FleetGitFacts {
|
|
|
53
53
|
return result.code === 0 ? undefined : (result.stderr.trim() || `git fetch exited with ${result.code}`).slice(0, 512);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Remote main and the remote's release tags as the last fetch mirrored them. Remote main is absent before the first
|
|
58
|
+
* fetch; tags that cannot be listed throw, since no release is not the same as releases that could not be read.
|
|
59
|
+
*/
|
|
57
60
|
public async remote(repoArg: IFleetRepository): Promise<IFleetRemoteState> {
|
|
58
61
|
const main = await this.git('git', ['rev-parse', '--verify', '--quiet', `${fleetRemoteMainRef}^{commit}`], repoArg.path);
|
|
59
62
|
const tags = await this.git('git', ['for-each-ref', '--format=%(refname:lstrip=3)%09%(objectname)%09%(*objectname)%09%(creatordate:iso-strict)',
|
|
60
63
|
`${fleetRemoteTagRefs}/v*`], repoArg.path);
|
|
64
|
+
if (tags.code !== 0) throw new Error((tags.stderr.trim() || `git for-each-ref exited with ${tags.code}`).slice(0, 512));
|
|
61
65
|
const releases: IFleetDeployRelease[] = [];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
releases.push({ version, sha: peeled || object, ...(taggedAt ? { taggedAt: new Date(taggedAt).toISOString() } : {}) });
|
|
68
|
-
}
|
|
66
|
+
for (const line of tags.stdout.split('\n')) {
|
|
67
|
+
const [name = '', object = '', peeled = '', taggedAt = ''] = line.split('\t');
|
|
68
|
+
const version = fleetVersion(name);
|
|
69
|
+
if (!version || !name.startsWith('v')) continue;
|
|
70
|
+
releases.push({ version, sha: peeled || object, ...(taggedAt ? { taggedAt: new Date(taggedAt).toISOString() } : {}) });
|
|
69
71
|
}
|
|
70
72
|
const sha = main.code === 0 ? main.stdout.trim() : '';
|
|
71
73
|
return { ...(fullSha.test(sha) ? { main: sha } : {}), releases: releases.sort((leftArg, rightArg) => compareFleetVersions(rightArg.version, leftArg.version)) };
|
|
@@ -22,6 +22,8 @@ export interface IFleetServiceOptions {
|
|
|
22
22
|
tickets?: (signal: AbortSignal) => Promise<ITicket[]>;
|
|
23
23
|
/** A release went out: the release reconciler links and releases the landed tickets its tag holds, now rather than at its next pass. */
|
|
24
24
|
released?: (repo: IFleetRepository) => void;
|
|
25
|
+
/** A landing pushed remote main: the deploy status says what the next release ships from it now rather than at its next pass. */
|
|
26
|
+
landed?: (repo: IFleetRepository) => void;
|
|
25
27
|
}
|
|
26
28
|
interface IFleetOwnedOperation { owner: string; snapshot: IFleetOperation; completion: Promise<void> }
|
|
27
29
|
const queues = new Map<string, Promise<unknown>>();
|
|
@@ -131,7 +133,11 @@ export class FleetService {
|
|
|
131
133
|
const repo = withHostEnvironment(repositories[0]!, configuration.environment);
|
|
132
134
|
return this.exclusive(runtime, repo, async () => {
|
|
133
135
|
running();
|
|
134
|
-
if (operation === 'land')
|
|
136
|
+
if (operation === 'land') {
|
|
137
|
+
const landing = await this.land(runtime, repo, input as IFleetLandRequest);
|
|
138
|
+
this.options.landed?.(repo);
|
|
139
|
+
return landing as TFleetResult<T>;
|
|
140
|
+
}
|
|
135
141
|
if (operation === 'tooling') return await toolingFleetRepository(runtime, repo, input as TFleetRequest<'tooling'>) as TFleetResult<T>;
|
|
136
142
|
const release = await releaseFleetRepository(runtime, repo, input as TFleetRequest<'release'>, {},
|
|
137
143
|
await this.releaseGuard(runtime, repo, input as TFleetRequest<'release'>));
|
|
@@ -60,6 +60,21 @@ export const readJsonPointer = (valueArg: unknown, pointerArg: string): unknown
|
|
|
60
60
|
|
|
61
61
|
export type TFleetDeployProbeResult = { state: 'up'; version: string; sha?: string } | { state: 'down'; error: string };
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A probe's failure text without its URL's query and fragment (AGL-1704): the Configuration master may give a probe a
|
|
65
|
+
* token there, and the text reaches the views, the stored deploy status and the driver. The URL is named without them.
|
|
66
|
+
*/
|
|
67
|
+
const probeErrorWithoutSecrets = (textArg: string, urlArg: string): string => {
|
|
68
|
+
if (!URL.canParse(urlArg)) return textArg.replaceAll(urlArg, 'the probe URL');
|
|
69
|
+
const url = new URL(urlArg);
|
|
70
|
+
const shown = new URL(urlArg);
|
|
71
|
+
shown.search = ''; shown.hash = '';
|
|
72
|
+
let text = textArg;
|
|
73
|
+
for (const full of new Set([urlArg, url.href])) text = text.replaceAll(full, shown.href);
|
|
74
|
+
for (const part of [url.search, url.hash]) if (part.length > 1) text = text.replaceAll(part, '');
|
|
75
|
+
return text;
|
|
76
|
+
};
|
|
77
|
+
|
|
63
78
|
/**
|
|
64
79
|
* Asks an HTTP target what it runs: a GET of its URL, the version at `versionPointer` (default `/version`) and the commit
|
|
65
80
|
* at `shaPointer`. An error status, an answer that is no JSON or holds no semantic version is down, with the reason.
|
|
@@ -71,7 +86,7 @@ export const probeFleetHttpTarget = async (probeArg: Extract<TFleetDeployProbe,
|
|
|
71
86
|
try { answer = await fetchFleetProbe(probeArg.url, optionsArg, { json: true, redirect: 'error' }); }
|
|
72
87
|
catch (errorArg) {
|
|
73
88
|
optionsArg.signal.throwIfAborted();
|
|
74
|
-
return { state: 'down', error: fleetProbeErrorText(errorArg).slice(0, 1024) };
|
|
89
|
+
return { state: 'down', error: probeErrorWithoutSecrets(fleetProbeErrorText(errorArg), probeArg.url).slice(0, 1024) };
|
|
75
90
|
}
|
|
76
91
|
if (answer.status >= 400) return { state: 'down', error: `HTTP ${answer.status}` };
|
|
77
92
|
const pointer = probeArg.versionPointer ?? '/version';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IFleetDeployPlan, IFleetDeployStatus, IFleetDeployTargetStatus, IFleetDeployWindow, TFleetMaintenanceWindowState,
|
|
3
|
+
} from '../../ts_interfaces/deployments.js';
|
|
4
|
+
import type { TDeployStatusContent, TDeployStoredPlan, TDeployStoredTarget, TDeployStoredWindow } from './classes.deploymodels.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the deploy monitor computed, as the views read it at a moment (AGL-1704): the stored content and when it was
|
|
8
|
+
* computed. Where a window stands, whether a deploy may run and the busy sessions depend on the clock and the sessions,
|
|
9
|
+
* never on what was computed, so they are derived here when read, never stored.
|
|
10
|
+
*/
|
|
11
|
+
export interface IDeployStatusModel {
|
|
12
|
+
computedAt: string;
|
|
13
|
+
content: TDeployStatusContent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Where a maintenance window stands at `nowArg`: before it, in it, or after it. */
|
|
17
|
+
export const deployWindowState = (windowArg: Pick<TDeployStoredWindow, 'from' | 'to'>, nowArg: number): TFleetMaintenanceWindowState => (
|
|
18
|
+
nowArg < Date.parse(windowArg.from) ? 'scheduled' : nowArg < Date.parse(windowArg.to) ? 'active' : 'done'
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** A stored window as the views show it at `nowArg`. */
|
|
22
|
+
export const deployWindowAt = (windowArg: TDeployStoredWindow, nowArg: number): IFleetDeployWindow => ({
|
|
23
|
+
...structuredClone(windowArg), state: deployWindowState(windowArg, nowArg),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/** The windows planned for a target that have not ended, the earliest first as `windowsArg` lists them. */
|
|
27
|
+
export const deployTargetWindows = (windowsArg: IFleetDeployWindow[], targetIdArg: string): IFleetDeployWindow[] => (
|
|
28
|
+
windowsArg.filter((windowArg) => windowArg.state !== 'done' && windowArg.targets.includes(targetIdArg))
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
/** A target's deploy plans, each queued for `window` into the next window the owner gave for the target. */
|
|
32
|
+
export const deployPlansAt = (plansArg: TDeployStoredPlan[], targetWindowsArg: IFleetDeployWindow[]): IFleetDeployPlan[] => {
|
|
33
|
+
const next = targetWindowsArg.find((windowArg) => windowArg.go === 'given');
|
|
34
|
+
return plansArg.map((planArg) => ({ ...structuredClone(planArg), ...(planArg.go === 'window' && next ? { window: structuredClone(next) } : {}) }));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A stored target as the views show it, given every window at the moment read and the busy sessions: any time; in a
|
|
39
|
+
* window, open while one the owner gave is active; the AGL controller when no session is busy (AGL-909).
|
|
40
|
+
*/
|
|
41
|
+
export const deployTargetAt = (targetArg: TDeployStoredTarget, windowsArg: IFleetDeployWindow[], busySessionsArg: number): IFleetDeployTargetStatus => {
|
|
42
|
+
const { deployPlans, ...stored } = targetArg;
|
|
43
|
+
const windows = deployTargetWindows(windowsArg, targetArg.target.id);
|
|
44
|
+
const busySessions = targetArg.deployWhen === 'idle' ? busySessionsArg : undefined;
|
|
45
|
+
const deployOpen = targetArg.deployWhen === 'anytime'
|
|
46
|
+
|| (targetArg.deployWhen === 'window' ? windows.some((windowArg) => windowArg.state === 'active' && windowArg.go === 'given') : busySessions === 0);
|
|
47
|
+
return { ...structuredClone(stored), ...(busySessions === undefined ? {} : { busySessions }), deployOpen, windows: structuredClone(windows),
|
|
48
|
+
deployPlans: deployPlansAt(deployPlans, windows) };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** The deploy status at `nowArg` with `busySessionsArg` sessions busy, from what was computed; it reads nothing else. */
|
|
52
|
+
export const deployStatusAt = (modelArg: IDeployStatusModel, nowArg: number, busySessionsArg: number): IFleetDeployStatus => {
|
|
53
|
+
const windows = modelArg.content.status.windows.map((windowArg) => deployWindowAt(windowArg, nowArg));
|
|
54
|
+
return { checkedAt: modelArg.computedAt, targets: modelArg.content.status.targets.map((targetArg) => deployTargetAt(targetArg, windows, busySessionsArg)),
|
|
55
|
+
windows };
|
|
56
|
+
};
|
|
@@ -11,6 +11,7 @@ export const fleetDeployRequestSchemas = {
|
|
|
11
11
|
probe: plugins.z.object({ targetId }).strict(),
|
|
12
12
|
release: plugins.z.object({ repo: plugins.z.string().min(1).max(1024).refine((valueArg) => !/[\0\r\n]/u.test(valueArg)).optional() }).strict(),
|
|
13
13
|
ticket: plugins.z.object({ ticketKey: plugins.z.string().regex(/^AGL-[1-9][0-9]*$/u) }).strict(),
|
|
14
|
+
refresh: plugins.z.object({}).strict(),
|
|
14
15
|
} as const satisfies Record<TFleetDeployOperation, plugins.z.ZodType>;
|
|
15
16
|
|
|
16
17
|
export const assertFleetDeployRequest = <TOperation extends TFleetDeployOperation>(
|
|
@@ -37,7 +38,8 @@ export const assertFleetDeployResponse = (methodArg: string, valueArg: unknown):
|
|
|
37
38
|
probe: plugins.z.object({ state: plugins.z.enum(['up', 'down', 'unknown']) }).passthrough() }).passthrough();
|
|
38
39
|
const schemas = {
|
|
39
40
|
status: plugins.z.object({ checkedAt: plugins.z.string(), targets: plugins.z.array(target),
|
|
40
|
-
windows: plugins.z.array(plugins.z.object({ key: plugins.z.string(), from: plugins.z.string(), to: plugins.z.string() }).passthrough())
|
|
41
|
+
windows: plugins.z.array(plugins.z.object({ key: plugins.z.string(), from: plugins.z.string(), to: plugins.z.string() }).passthrough()),
|
|
42
|
+
failure: plugins.z.object({ at: plugins.z.string(), message: plugins.z.string(), reference: plugins.z.string() }).strict().optional() }).strict(),
|
|
41
43
|
history: plugins.z.object({ targetId, observations: plugins.z.array(plugins.z.object({ targetId, version: plugins.z.string(),
|
|
42
44
|
observedAt: plugins.z.string() }).passthrough()) }).strict(),
|
|
43
45
|
probe: target,
|
|
@@ -45,6 +47,7 @@ export const assertFleetDeployResponse = (methodArg: string, valueArg: unknown):
|
|
|
45
47
|
id: plugins.z.string() }).passthrough()) }).strict(),
|
|
46
48
|
ticket: plugins.z.object({ ticketKey: plugins.z.string(), landed: plugins.z.array(plugins.z.unknown()), runs: plugins.z.array(plugins.z.unknown()),
|
|
47
49
|
foundIn: plugins.z.array(plugins.z.unknown()) }).passthrough(),
|
|
50
|
+
refresh: plugins.z.object({ state: plugins.z.enum(['refreshed', 'refreshing']), checkedAt: plugins.z.string().optional() }).strict(),
|
|
48
51
|
};
|
|
49
52
|
schemas[operation].parse(valueArg);
|
|
50
53
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/** The newest Claude Code release AGL verified: the line above which a release is new and mentioned once. */
|
|
11
|
-
export const claudeCodeVerifiedRelease = '2.1.
|
|
11
|
+
export const claudeCodeVerifiedRelease = '2.1.322';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The oldest Claude Code release the fleet runs: the oldest whose fleet output the tests still pin. It rises only when
|
|
@@ -114,7 +114,8 @@ export const deployStatusLines = (statusArg: IFleetDeployStatus): string[] => [.
|
|
|
114
114
|
deployWhenText(targetArg),
|
|
115
115
|
targetArg.deployPlans.map(deployPlanText).join('; ') || '-',
|
|
116
116
|
]),
|
|
117
|
-
]), ...windowLines(statusArg.windows)
|
|
117
|
+
]), ...windowLines(statusArg.windows), ...(statusArg.failure ? ['', `The last check failed at ${minute(statusArg.failure.at)}: ${statusArg.failure.message} `
|
|
118
|
+
+ `What is shown is from ${minute(statusArg.checkedAt)}. (ref ${statusArg.failure.reference})`] : [])];
|
|
118
119
|
|
|
119
120
|
export const deployHistoryLines = (historyArg: { targetId: string; observations: IFleetDeployObservation[] }): string[] => (
|
|
120
121
|
historyArg.observations.length ? historyArg.observations.map((observationArg) => [minute(observationArg.observedAt), observationArg.version,
|
|
@@ -121,6 +121,7 @@ import { ticketColumns, ticketAutoLabels, type ticketErrorMessages } from '../ts
|
|
|
121
121
|
import type { TAuthErrorCode } from './interfaces.auth.js';
|
|
122
122
|
import { configurationErrorCodes, type TConfigurationErrorCode } from './configuration/classes.configurationerror.js';
|
|
123
123
|
import type { ControllerElicitationReplyError } from './functions.elicitation.js';
|
|
124
|
+
import type { ControllerPromptReplyError } from './functions.promptreply.js';
|
|
124
125
|
import type { FleetNativeTurnError } from './fleet/interfaces.workers.js';
|
|
125
126
|
import type { TClaudeDispatchRefusal } from './classes.claudeharness.js';
|
|
126
127
|
import type { INativeSessionFailedErrorData } from './classes.nativesessions.js';
|
|
@@ -178,14 +179,15 @@ export const deviceRefusalCodes: ReadonlySet<string> = new Set([...Object.keys({
|
|
|
178
179
|
/**
|
|
179
180
|
* Every code the controller refuses a device's request with before the device error translation: the codes of the
|
|
180
181
|
* typed errors `asTypedResponseError` passes on as their own (the auth store's, the configuration authority's, an
|
|
181
|
-
* elicitation reply's, a native Codex turn's), the codes it gives the others
|
|
182
|
-
* under a failure journal reference), and the codes the browser's shared
|
|
183
|
-
* reads and sends, native sessions, answers, direct children).
|
|
182
|
+
* elicitation reply's, a permission or question reply's, a native Codex turn's), the codes it gives the others
|
|
183
|
+
* (`controller_operation_failed` for a fault under a failure journal reference), and the codes the browser's shared
|
|
184
|
+
* functions a device runs refuse with (session reads and sends, native sessions, answers, direct children).
|
|
184
185
|
*/
|
|
185
186
|
export type TControllerRefusalCode =
|
|
186
187
|
| TAuthErrorCode
|
|
187
188
|
| TConfigurationErrorCode
|
|
188
189
|
| ControllerElicitationReplyError['code']
|
|
190
|
+
| ControllerPromptReplyError['code']
|
|
189
191
|
| FleetNativeTurnError['code']
|
|
190
192
|
| typeof controllerOperationFailedErrorCode
|
|
191
193
|
| 'concurrent_change'
|
|
@@ -268,7 +270,8 @@ export const deviceControllerRefusals: Readonly<Record<Exclude<TControllerRefusa
|
|
|
268
270
|
// The configuration authority the driver, the direct reports and the deploy monitor read.
|
|
269
271
|
invalid_argument: 'controller_failed',
|
|
270
272
|
conflict: 'concurrent_change',
|
|
271
|
-
//
|
|
273
|
+
// An elicitation answered or withdrawn meanwhile, or a configuration record gone (a permission or question the session
|
|
274
|
+
// no longer holds is refused `concurrent_change` already).
|
|
272
275
|
not_found: 'concurrent_change',
|
|
273
276
|
unsupported: 'controller_failed',
|
|
274
277
|
unbound: 'controller_unavailable',
|
|
@@ -666,8 +669,8 @@ const deviceAuthorityUnavailable: Readonly<Record<Exclude<TControllerAuthorityDa
|
|
|
666
669
|
|
|
667
670
|
/** What `device.host.get` reads besides the AGL and the device, each section from its owner. */
|
|
668
671
|
export interface IDeviceHostSources {
|
|
669
|
-
/** The deploy monitor's status of every target, as the Deployments view reads it; never a probe. */
|
|
670
|
-
deployStatus: () => Promise<IFleetDeployStatus>;
|
|
672
|
+
/** The deploy monitor's stored status of every target, as the Deployments view reads it; never a probe. */
|
|
673
|
+
deployStatus: (signalArg: AbortSignal) => Promise<IFleetDeployStatus>;
|
|
671
674
|
/** The inference proxy's pools; absent while no proxy runs here. */
|
|
672
675
|
capacity: ((signalArg: AbortSignal) => Promise<IProxyCapacityAnswer>) | undefined;
|
|
673
676
|
/** The accounts service as the controller holds it. */
|
|
@@ -720,10 +723,12 @@ const readDeviceApiKeys = async (sourcesArg: Pick<IDeviceHostSources, 'authority
|
|
|
720
723
|
|
|
721
724
|
/**
|
|
722
725
|
* Why a section's owner did not answer, when that is a state of the host rather than a fault: the configuration
|
|
723
|
-
* service the deploy monitor reads its targets from, or the inference proxy and the accounts service behind it.
|
|
726
|
+
* service the deploy monitor reads its targets from, or the inference proxy and the accounts service behind it. A
|
|
727
|
+
* deploy monitor whose first computation still runs or failed is running (AGL-1704): it reads as `failed`, with the
|
|
728
|
+
* monitor's own reference when it failed (see `readDeviceSection`).
|
|
724
729
|
*/
|
|
725
730
|
const deviceHostUnavailableReason = (errorArg: unknown): Exclude<TDeviceHostUnavailableReason, 'failed'> | undefined => {
|
|
726
|
-
if (errorArg instanceof DeployError) return errorArg.
|
|
731
|
+
if (errorArg instanceof DeployError) return errorArg.unavailable === 'not_running' ? 'not_running' : undefined;
|
|
727
732
|
if (errorArg instanceof AglProxyUnavailableError) return 'not_running';
|
|
728
733
|
if (errorArg instanceof AglProxyRefusedError) return errorArg.code === 'authority_unavailable' ? 'not_running' : undefined;
|
|
729
734
|
if (errorArg instanceof AglProxyOutdatedError) return 'outdated';
|
|
@@ -744,6 +749,11 @@ const readDeviceSection = async <T>(operationArg: string, whatArg: string, signa
|
|
|
744
749
|
if (signalArg.aborted) throw errorArg;
|
|
745
750
|
const reason = deviceHostUnavailableReason(errorArg);
|
|
746
751
|
if (reason !== undefined) return { state: 'unavailable', reason };
|
|
752
|
+
// A deploy monitor without a stored status (AGL-1704) is no fault of this read: nothing is journaled. A first
|
|
753
|
+
// computation that failed was journaled once by the monitor, whose reference the device gets; one that still runs has none.
|
|
754
|
+
if (errorArg instanceof DeployError && errorArg.unavailable) {
|
|
755
|
+
return { state: 'unavailable', reason: 'failed', ...(errorArg.reference ? { reference: errorArg.reference } : {}) };
|
|
756
|
+
}
|
|
747
757
|
const reference = controllerFailureJournal.record({ operation: operationArg, cause: errorArg });
|
|
748
758
|
console.error(`Reading ${whatArg} for a device failed (ref ${reference}):`, errorArg);
|
|
749
759
|
return { state: 'unavailable', reason: 'failed', reference };
|
|
@@ -759,7 +769,7 @@ const readDeviceHostSection = <T>(sectionArg: string, signalArg: AbortSignal,
|
|
|
759
769
|
export const readDeviceHostSections = async (sourcesArg: IDeviceHostSources, nowArg: number, signalArg: AbortSignal):
|
|
760
770
|
Promise<Pick<IReq_DeviceHostGet['response'], 'deploys' | 'pools' | 'apiKeys'>> => {
|
|
761
771
|
const [deploys, pools, apiKeys] = await Promise.all([
|
|
762
|
-
readDeviceHostSection<IDeviceHostDeploys>('deploys', signalArg, async () => deviceHostDeploys(await sourcesArg.deployStatus())),
|
|
772
|
+
readDeviceHostSection<IDeviceHostDeploys>('deploys', signalArg, async () => deviceHostDeploys(await sourcesArg.deployStatus(signalArg))),
|
|
763
773
|
readDeviceHostSection<IDeviceHostPools>('pools', signalArg, async () => (
|
|
764
774
|
sourcesArg.capacity === undefined ? { state: 'unavailable', reason: 'not_running' } : deviceHostPools(await sourcesArg.capacity(signalArg))
|
|
765
775
|
)),
|
|
@@ -13,6 +13,7 @@ import { aglProxyConfinedMountPoint, aglProxyRelayMountPoint, aglProxyUnitName,
|
|
|
13
13
|
type TAglProxyConfinedRun } from './functions.proxycontract.js';
|
|
14
14
|
import { writeConfinedRelay } from './functions.confinedrelay.js';
|
|
15
15
|
import { inferenceCliHelp, parseInferenceCliArguments, type IInferenceCliArguments } from './functions.inferencecliarguments.js';
|
|
16
|
+
import { claudeHookSwitchNotice } from './functions.proxyharnessconfig.js';
|
|
16
17
|
import { runProxyCredentialCommand } from './functions.proxycredentialcli.js';
|
|
17
18
|
import { runProxyCapacity } from './functions.proxycapacitycli.js';
|
|
18
19
|
import { isProxyCapacityAnswer } from '../ts_interfaces/proxycapacity.js';
|
|
@@ -178,7 +179,8 @@ const serve = (portArg: number): Promise<void> => withSignals(async (signalArg)
|
|
|
178
179
|
|
|
179
180
|
/**
|
|
180
181
|
* Runs a harness on a proxy lease. A proxy that restarts meanwhile hands the lease back, so the harness keeps its
|
|
181
|
-
* credential; a lease it does not hand back stops the harness, and the run ends with the reason.
|
|
182
|
+
* credential; a lease it does not hand back stops the harness, and the run ends with the reason. Claude Code's run
|
|
183
|
+
* says on stderr which inherited hook switches it does not get (`claudeHookSwitchNotice`).
|
|
182
184
|
*/
|
|
183
185
|
const run = (optionsArg: IInferenceCliArguments): Promise<void> => withSignals(async (signalArg) => {
|
|
184
186
|
await preflightAGLHomeMigration();
|
|
@@ -193,6 +195,8 @@ const run = (optionsArg: IInferenceCliArguments): Promise<void> => withSignals(a
|
|
|
193
195
|
const launch = inferenceHarnessLaunch({ harness: optionsArg.harness!, baseUrl: lease.baseUrl, token: lease.token,
|
|
194
196
|
catalog: lease.catalog, modelId: optionsArg.modelId, args: optionsArg.args, environment,
|
|
195
197
|
claudeConfigDirectory: paths.claudeOnChatGpt });
|
|
198
|
+
const hookSwitches = claudeHookSwitchNotice('AGL proxy run', launch.droppedHookSwitches);
|
|
199
|
+
if (hookSwitches) process.stderr.write(`${hookSwitches}\n`);
|
|
196
200
|
signalArg.throwIfAborted();
|
|
197
201
|
const child = plugins.childProcess.spawn(optionsArg.harness!, launch.args, { env: launch.environment, stdio: 'inherit', shell: false });
|
|
198
202
|
let killTimer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -259,6 +263,8 @@ const confinedContainer = async (optionsArg: IInferenceCliArguments, signalArg:
|
|
|
259
263
|
? `, Codex on the ChatGPT pool (ChatGPT accounts only), AGL's relay at ${aglProxyRelayMountPoint}`
|
|
260
264
|
: run.provider === 'openai' ? ', served from the ChatGPT pool' : ''}; `
|
|
261
265
|
+ `end it at once with \`agl proxy confined end ${run.id}\`.\n`);
|
|
266
|
+
const hookSwitches = claudeHookSwitchNotice('AGL proxy confined run', launch.droppedHookSwitches);
|
|
267
|
+
if (hookSwitches) process.stderr.write(`${hookSwitches}\n`);
|
|
262
268
|
signalArg.throwIfAborted();
|
|
263
269
|
const child = plugins.childProcess.spawn(launch.command, launch.args, { env: launch.environment, stdio: 'inherit', shell: false });
|
|
264
270
|
let killTimer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -3,7 +3,7 @@ import type { TInferenceModel } from './classes.inferencerouter.js';
|
|
|
3
3
|
import type { TAglProxyLeaseCatalog } from './classes.proxycontrol.js';
|
|
4
4
|
import { aglProxyConfinedMountPoint, aglProxyRelayMountPoint } from './functions.proxycontract.js';
|
|
5
5
|
import { aglProxyProviderId, claudeProxyEnvironment, claudeProxyReservedVariables, claudeRoutingVariables, codexProxyProvider,
|
|
6
|
-
codexRoutingVariables, openCodeProxyProvider, proxyHarnessModels } from './functions.proxyharnessconfig.js';
|
|
6
|
+
codexRoutingVariables, dropClaudeHookSwitches, openCodeProxyProvider, proxyHarnessModels } from './functions.proxyharnessconfig.js';
|
|
7
7
|
|
|
8
8
|
export type TInferenceHarness = 'codex' | 'claude' | 'opencode';
|
|
9
9
|
export interface IInferenceLaunchOptions {
|
|
@@ -17,15 +17,27 @@ export interface IInferenceLaunchOptions {
|
|
|
17
17
|
claudeConfigDirectory: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* A harness's launch overlay: its arguments and environment, and the hook switches (`dropClaudeHookSwitches`) the
|
|
22
|
+
* environment held and Claude Code does not get; none for Codex and OpenCode.
|
|
23
|
+
*/
|
|
24
|
+
export interface IInferenceLaunch {
|
|
25
|
+
args: string[];
|
|
26
|
+
environment: NodeJS.ProcessEnv;
|
|
27
|
+
droppedHookSwitches: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* Claude Code on a Claude pool: its own configuration and home, with only its endpoint and credential pointed at
|
|
22
32
|
* the proxy, which sends its requests on to the account unchanged. The proxy's credential replaces any claude.ai
|
|
23
33
|
* login for the run (`ANTHROPIC_AUTH_TOKEN` takes precedence over a stored login), and the login itself is left
|
|
24
|
-
* as it is. Claude Code reads the pool's models from the proxy and sends nothing beyond its model requests.
|
|
34
|
+
* as it is. Claude Code reads the pool's models from the proxy and sends nothing beyond its model requests. An inherited
|
|
35
|
+
* hook switch is dropped, so the hooks of the user's settings run.
|
|
25
36
|
*/
|
|
26
|
-
const claudeNativeLaunch = (optionsArg: IInferenceLaunchOptions & { catalog: { provider: 'anthropic' } }):
|
|
37
|
+
const claudeNativeLaunch = (optionsArg: IInferenceLaunchOptions & { catalog: { provider: 'anthropic' } }): IInferenceLaunch => {
|
|
27
38
|
const environment = { ...optionsArg.environment };
|
|
28
39
|
for (const name of claudeRoutingVariables) delete environment[name];
|
|
40
|
+
const droppedHookSwitches = dropClaudeHookSwitches(environment);
|
|
29
41
|
if (optionsArg.modelId !== undefined && !optionsArg.catalog.models.some((entry) => entry.modelId === optionsArg.modelId)) {
|
|
30
42
|
throw new Error('The requested model is not offered by every Claude account of this pool.');
|
|
31
43
|
}
|
|
@@ -33,7 +45,7 @@ const claudeNativeLaunch = (optionsArg: IInferenceLaunchOptions & { catalog: { p
|
|
|
33
45
|
...claudeProxyEnvironment(optionsArg.baseUrl),
|
|
34
46
|
ANTHROPIC_AUTH_TOKEN: optionsArg.token,
|
|
35
47
|
...(optionsArg.modelId === undefined ? {} : { ANTHROPIC_MODEL: optionsArg.modelId }),
|
|
36
|
-
} };
|
|
48
|
+
}, droppedHookSwitches };
|
|
37
49
|
};
|
|
38
50
|
|
|
39
51
|
/**
|
|
@@ -107,8 +119,11 @@ const dottedFields = (prefixArg: string, valueArg: Record<string, unknown>): Rec
|
|
|
107
119
|
? Object.entries(dottedFields(`${prefixArg}.${key}`, value as Record<string, unknown>))
|
|
108
120
|
: [[`${prefixArg}.${key}`, value]]));
|
|
109
121
|
|
|
110
|
-
/**
|
|
111
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Ephemeral launch overlays; native credentials and generated configuration are never changed. Claude Code, on either
|
|
124
|
+
* pool, gets no inherited hook switch (`dropClaudeHookSwitches`).
|
|
125
|
+
*/
|
|
126
|
+
export const inferenceHarnessLaunch = (optionsArg: IInferenceLaunchOptions): IInferenceLaunch => {
|
|
112
127
|
const catalog = optionsArg.catalog;
|
|
113
128
|
if (catalog.provider === 'anthropic') {
|
|
114
129
|
if (optionsArg.harness !== 'claude') throw new Error('Codex and OpenCode run on a ChatGPT pool; a Claude pool serves Claude Code.');
|
|
@@ -135,15 +150,17 @@ export const inferenceHarnessLaunch = (optionsArg: IInferenceLaunchOptions): { a
|
|
|
135
150
|
...dottedFields(`model_providers.${aglProxyProviderId}`, codexProxyProvider({ baseUrl: optionsArg.baseUrl,
|
|
136
151
|
auth: { command: 'printenv', args: ['MODELPROFILE_PROXY_TOKEN'] } })),
|
|
137
152
|
};
|
|
138
|
-
return { environment, args: [...Object.entries(configuration).flatMap(([key, value]) => ['-c', `${key}=${JSON.stringify(value)}`]), ...args]
|
|
153
|
+
return { environment, args: [...Object.entries(configuration).flatMap(([key, value]) => ['-c', `${key}=${JSON.stringify(value)}`]), ...args],
|
|
154
|
+
droppedHookSwitches: [] };
|
|
139
155
|
}
|
|
140
156
|
if (optionsArg.harness === 'claude') {
|
|
141
157
|
rejects(['--settings', '--model', '--fallback-model', '--betas']);
|
|
142
158
|
for (const name of claudeRoutingVariables) delete environment[name];
|
|
159
|
+
const droppedHookSwitches = dropClaudeHookSwitches(environment);
|
|
143
160
|
const launch = claudeChatGptLaunch({ baseUrl: `${optionsArg.baseUrl}/anthropic`, token: optionsArg.token,
|
|
144
161
|
configDirectory: optionsArg.claudeConfigDirectory,
|
|
145
162
|
models: [model, ...models.filter((entry) => entry !== model)].map((entry) => ({ ...entry, isDefault: entry === model })) });
|
|
146
|
-
return { environment: { ...environment, ...launch.environment }, args: [...launch.args, ...args] };
|
|
163
|
+
return { environment: { ...environment, ...launch.environment }, args: [...launch.args, ...args], droppedHookSwitches };
|
|
147
164
|
}
|
|
148
165
|
rejects(['-m', '--model', '--attach']);
|
|
149
166
|
if (environment.OPENCODE_CONFIG_CONTENT) throw new Error('Unset OPENCODE_CONFIG_CONTENT before starting an AGL proxy harness.');
|
|
@@ -156,8 +173,9 @@ export const inferenceHarnessLaunch = (optionsArg: IInferenceLaunchOptions): { a
|
|
|
156
173
|
// Only `run` and the TUI (OpenCode's default command) take `--model`; every other command refuses it and runs on the
|
|
157
174
|
// configuration's `model` above.
|
|
158
175
|
const selection = ['--model', `${aglProxyProviderId}/${model.modelId}`];
|
|
159
|
-
if (args[0] === 'run') return { environment, args: ['run', ...selection, ...args.slice(1)] };
|
|
160
|
-
return { environment, args: args[0] !== undefined && openCodeCommands.has(args[0]) ? args : [...selection, ...args]
|
|
176
|
+
if (args[0] === 'run') return { environment, args: ['run', ...selection, ...args.slice(1)], droppedHookSwitches: [] };
|
|
177
|
+
return { environment, args: args[0] !== undefined && openCodeCommands.has(args[0]) ? args : [...selection, ...args],
|
|
178
|
+
droppedHookSwitches: [] };
|
|
161
179
|
};
|
|
162
180
|
|
|
163
181
|
/**
|
|
@@ -291,9 +309,10 @@ const assertMountable = (directoryArg: string, whatArg: string): void => {
|
|
|
291
309
|
* gets each variable by name from the docker command's environment, so the credential never appears on a command line;
|
|
292
310
|
* that environment drops every variable that would give the harness another login or route -- Claude Code's always, and
|
|
293
311
|
* for a Codex run Codex's and OpenAI's (`codexRoutingVariables`) -- and on the ChatGPT pool every model variable a Claude
|
|
294
|
-
* Code run sets, so `-e NAME` of one of them passes nothing.
|
|
295
|
-
*
|
|
296
|
-
*
|
|
312
|
+
* Code run sets, so `-e NAME` of one of them passes nothing. A Claude Code run's environment also drops every hook switch
|
|
313
|
+
* (`dropClaudeHookSwitches`), so `-e NAME` of one passes nothing either, while one typed with its value (`-e NAME=1`) is the
|
|
314
|
+
* command's own and stays. The mount is the socket's own directory, which holds nothing else and survives a proxy restart,
|
|
315
|
+
* unlike a mount of the socket file. Only `docker run` and `docker container run` are taken.
|
|
297
316
|
*/
|
|
298
317
|
export const confinedDockerLaunch = (optionsArg: {
|
|
299
318
|
args: readonly string[];
|
|
@@ -304,7 +323,7 @@ export const confinedDockerLaunch = (optionsArg: {
|
|
|
304
323
|
token: string;
|
|
305
324
|
environment: NodeJS.ProcessEnv;
|
|
306
325
|
pool: TConfinedLaunchPool;
|
|
307
|
-
}): { command: string; args: string[]; environment: NodeJS.ProcessEnv } => {
|
|
326
|
+
}): { command: string; args: string[]; environment: NodeJS.ProcessEnv; droppedHookSwitches: string[] } => {
|
|
308
327
|
const [command, ...args] = optionsArg.args;
|
|
309
328
|
const runAt = args[0] === 'run' ? 1 : args[0] === 'container' && args[1] === 'run' ? 2 : 0;
|
|
310
329
|
if (command === undefined || path.basename(command) !== 'docker' || runAt === 0) {
|
|
@@ -334,6 +353,7 @@ export const confinedDockerLaunch = (optionsArg: {
|
|
|
334
353
|
for (const name of claudeProxyReservedVariables) delete environment[name];
|
|
335
354
|
if ('harness' in pool) for (const name of codexRoutingVariables) delete environment[name];
|
|
336
355
|
else if (pool.provider === 'openai') for (const name of claudeChatGptVariables) delete environment[name];
|
|
356
|
+
const droppedHookSwitches = 'harness' in pool ? [] : dropClaudeHookSwitches(environment);
|
|
337
357
|
return {
|
|
338
358
|
command,
|
|
339
359
|
args: [...args.slice(0, runAt),
|
|
@@ -343,5 +363,6 @@ export const confinedDockerLaunch = (optionsArg: {
|
|
|
343
363
|
...Object.keys(variables).flatMap((nameArg) => ['--env', nameArg]),
|
|
344
364
|
...args.slice(runAt)],
|
|
345
365
|
environment: { ...environment, ...variables },
|
|
366
|
+
droppedHookSwitches,
|
|
346
367
|
};
|
|
347
368
|
};
|
|
@@ -13,6 +13,8 @@ export const deployToolDefinitions: readonly { name: string; operation: TFleetDe
|
|
|
13
13
|
description: 'The versions a deploy target ran, newest first: one observation each time its probe answered another version, with the version before it (a newer one means a rollback).' },
|
|
14
14
|
{ name: 'deploy_probe', operation: 'probe', readOnly: false, inputSchema: fleetDeployRequestSchemas.probe,
|
|
15
15
|
description: 'Probe one deploy target now and answer its status. Run it after any deploy; it records what the target answers and claims nothing itself.' },
|
|
16
|
+
{ name: 'deploy_refresh', operation: 'refresh', readOnly: false, inputSchema: fleetDeployRequestSchemas.refresh,
|
|
17
|
+
description: 'Check every deploy target now: fetch the repositories\' remotes and release tags, probe every target and compute the deploy status again, as the five-minute check does; a check already running is followed by one this call shares with any other. It waits at most 60 seconds: refreshed once the check ended, refreshing while it runs on (deploy_status then shows the stored status until it ends). checkedAt says when the status was computed. Call it when deploy_status must show a change at once, not by habit.' },
|
|
16
18
|
{ name: 'release_status', operation: 'release', readOnly: true, inputSchema: fleetDeployRequestSchemas.release,
|
|
17
19
|
description: 'The release state of a repository (repo as org/name, fleet id or checkout path), or of every repository a deploy target runs, a ticket plans or a landed ticket names: its newest release tag, the tickets planning its next release, and the landed tickets the newest release does not hold.' },
|
|
18
20
|
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A refused answer to a permission or question (AGL-1687): the session no longer holds the request, because it was
|
|
3
|
+
* answered meanwhile (in another client, or by auto-accept) or withdrawn as its turn moved on. AGL lost a race before it
|
|
4
|
+
* sent anything, so `concurrent_change`: nothing was done; read again, then decide. The component that holds the
|
|
5
|
+
* request throws it (Claude Code's harness, the Codex adapter, the OpenCode client), and the controller hands it on as
|
|
6
|
+
* the typed refusal it is, as it does `ControllerElicitationReplyError`.
|
|
7
|
+
*/
|
|
8
|
+
export class ControllerPromptReplyError extends Error {
|
|
9
|
+
public readonly code = 'concurrent_change';
|
|
10
|
+
|
|
11
|
+
constructor(messageArg: string) {
|
|
12
|
+
super(messageArg);
|
|
13
|
+
this.name = 'ControllerPromptReplyError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The refusal of an answer to a permission or question the session no longer holds; nothing was sent. */
|
|
18
|
+
export const promptNoLongerPending = (kindArg: 'permission' | 'question'): ControllerPromptReplyError => (
|
|
19
|
+
new ControllerPromptReplyError(`This ${kindArg} was answered or changed meanwhile, so nothing was sent. Read it again, then decide.`)
|
|
20
|
+
);
|
|
@@ -53,6 +53,38 @@ export const claudeRoutingVariables: readonly string[] = ['ANTHROPIC_API_KEY', '
|
|
|
53
53
|
'CLAUDE_CODE_USE_VERTEX', 'CLAUDE_CODE_USE_FOUNDRY', 'CLAUDE_CODE_USE_ANTHROPIC_AWS', 'CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD',
|
|
54
54
|
'CLAUDE_CODE_USE_MANTLE', 'CLAUDE_CODE_USE_GATEWAY', 'ANTHROPIC_UNIX_SOCKET'];
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The variables that, inherited, keep the hooks of the user's Claude Code settings from running, and with them AGL's
|
|
58
|
+
* policy hook (AGL-1783): bare mode, safe mode, restricted mode, no recorded workspace trust, and review mode, which
|
|
59
|
+
* needs four variables at once and is cut at `CLAUDE_CODE_REMOTE_SESSION_ORIGIN`, the most specific of them.
|
|
60
|
+
* Membership: one name per path on which the environment alone stops a hook of the user's settings; for a path that
|
|
61
|
+
* needs several variables together, its most specific one. A name that only adds a notice (`CLAUDE_CODE_PERSONAL_HOOKS_OFF`)
|
|
62
|
+
* is none. `dropClaudeHookSwitches` deletes them; ts_authswitch/native-contracts.md ("Claude Code compatibility check")
|
|
63
|
+
* says how a new release is read for them.
|
|
64
|
+
*/
|
|
65
|
+
export const claudeHookSwitchVariables: readonly string[] = ['CLAUDE_CODE_SIMPLE', 'CLAUDE_CODE_SAFE_MODE', 'CLAUDE_CODE_RESTRICTED',
|
|
66
|
+
'CLAUDE_CODE_IGNORE_PERSISTED_TRUST', 'CLAUDE_CODE_REMOTE_SESSION_ORIGIN'];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Deletes every `claudeHookSwitchVariables` name from the environment a Claude Code session is started with, whatever
|
|
70
|
+
* its value, and answers those that held one, in the list's order. Only inherited variables go: a flag typed for the
|
|
71
|
+
* run (`--bare`, `--safe-mode`) is an argument and stays.
|
|
72
|
+
*/
|
|
73
|
+
export const dropClaudeHookSwitches = (environmentArg: NodeJS.ProcessEnv): string[] => {
|
|
74
|
+
const dropped: string[] = [];
|
|
75
|
+
for (const name of claudeHookSwitchVariables) {
|
|
76
|
+
if (environmentArg[name] !== undefined) dropped.push(name);
|
|
77
|
+
delete environmentArg[name];
|
|
78
|
+
}
|
|
79
|
+
return dropped;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** The one line that says which hook switches `starterArg` dropped (`dropClaudeHookSwitches`); none when it dropped none. */
|
|
83
|
+
export const claudeHookSwitchNotice = (starterArg: string, droppedArg: readonly string[]): string | undefined =>
|
|
84
|
+
droppedArg.length === 0 ? undefined : `${starterArg} drops ${droppedArg.join(', ')} from the environment it starts Claude Code `
|
|
85
|
+
+ `with: inherited, ${droppedArg.length === 1 ? 'it can keep' : 'each can keep'} the hooks of the user's Claude Code settings, `
|
|
86
|
+
+ 'AGL\'s policy hook among them, from running.';
|
|
87
|
+
|
|
56
88
|
/**
|
|
57
89
|
* The variables that make Codex authenticate or route another way than through the proxy's provider, or read a home of
|
|
58
90
|
* its own choosing: an OpenAI or Codex key, token or login, an OpenAI endpoint, organization or project, workload
|
|
@@ -9,16 +9,26 @@
|
|
|
9
9
|
* The module imports nothing, so it bundles for a browser as it is.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The instants a renewal anchor may name, in epoch milliseconds, both included: the first of the year 2000 and the
|
|
14
|
+
* last of the year 9999, in UTC. A view that bounds a date picker with it takes what `isAuthSwitchRenewsAt` takes.
|
|
15
|
+
*/
|
|
16
|
+
export const authSwitchRenewsAtRange: Readonly<{ min: number; max: number }> = Object.freeze({
|
|
17
|
+
min: Date.UTC(2000, 0, 1),
|
|
18
|
+
max: Date.UTC(10000, 0, 1) - 1,
|
|
19
|
+
});
|
|
20
|
+
|
|
12
21
|
/**
|
|
13
22
|
* The renewal anchor rule, the one the authority applies to `authswitch.authority.renewal`: a date-time `Date.parse`
|
|
14
|
-
* reads, in any year from 2000 to 9999, as the lapse date rule (`isAuthSwitchLapsesAt`). A
|
|
15
|
-
* next renewal is a whole number of months after it. A consumer validates with this rather
|
|
16
|
-
* authority stores the anchor as its ISO 8601 UTC form and answers any other value with the
|
|
23
|
+
* reads, in any year from 2000 to 9999 (`authSwitchRenewsAtRange`), as the lapse date rule (`isAuthSwitchLapsesAt`). A
|
|
24
|
+
* past anchor is valid: the next renewal is a whole number of months after it. A consumer validates with this rather
|
|
25
|
+
* than restating it; the authority stores the anchor as its ISO 8601 UTC form and answers any other value with the
|
|
26
|
+
* `invalid_input` refusal.
|
|
17
27
|
*/
|
|
18
28
|
export const isAuthSwitchRenewsAt = (value: unknown): value is string => {
|
|
19
29
|
if (typeof value !== 'string' || value.length > 64) return false;
|
|
20
30
|
const at = Date.parse(value);
|
|
21
|
-
return Number.isFinite(at) && at >=
|
|
31
|
+
return Number.isFinite(at) && at >= authSwitchRenewsAtRange.min && at <= authSwitchRenewsAtRange.max;
|
|
22
32
|
};
|
|
23
33
|
|
|
24
34
|
/** The renewal `monthsArg` months after the anchor: the anchor's UTC day clamped to that month, at the anchor's UTC time. */
|
|
@@ -16,12 +16,12 @@ export const CLAUDE_NATIVE_MINIMUM_VERSION = '2.1.273';
|
|
|
16
16
|
* (native-contracts.md). The usage of an adopted home's login is read from the home only while every Claude Code
|
|
17
17
|
* session running there runs one of these or a release from `CLAUDE_NATIVE_READ_AS_VERIFIED_FROM` on
|
|
18
18
|
* (`claudeNativeReleaseReadsAsVerified`, owner ruling 2026-10-22, AGL-685); an installed release below that line that
|
|
19
|
-
* is not listed is read from only while no session runs in that home. The controller's verified release (2.1.
|
|
20
|
-
* AGL-686) and its fleet floor (2.1.282) are listed. 2.1.288, the release AGL's own Claude
|
|
21
|
-
* SDK, had these items read from the SDK's binary (AGL-688) and is listed for the usage
|
|
22
|
-
* it, so it is never the fleet's floor or the verified release.
|
|
19
|
+
* is not listed is read from only while no session runs in that home. The controller's verified release (2.1.322,
|
|
20
|
+
* AGL-1780; 2.1.306 before it, AGL-686) and its fleet floor (2.1.282) are listed. 2.1.288, the release AGL's own Claude
|
|
21
|
+
* chats run through the Agent SDK, had these items read from the SDK's binary (AGL-688) and is listed for the usage
|
|
22
|
+
* read only: the fleet never ran it, so it is never the fleet's floor or the verified release.
|
|
23
23
|
*/
|
|
24
|
-
export const CLAUDE_NATIVE_VERIFIED_RELEASES: readonly string[] = ['2.1.273', '2.1.282', '2.1.288', '2.1.306'];
|
|
24
|
+
export const CLAUDE_NATIVE_VERIFIED_RELEASES: readonly string[] = ['2.1.273', '2.1.282', '2.1.288', '2.1.306', '2.1.322'];
|
|
25
25
|
/**
|
|
26
26
|
* The line from which the usage read takes any release, listed or not, as verified (owner ruling 2026-10-22, AGL-685):
|
|
27
27
|
* the controller's fleet floor (`claudeCodeFleetFloor`), which a test holds equal to it. It does not move when a newer
|
|
@@ -38,7 +38,7 @@ export const CLAUDE_NATIVE_READ_AS_VERIFIED_FROM = '2.1.282';
|
|
|
38
38
|
* never which login a process selects (`CLAUDE_NATIVE_VERIFIED_RELEASES`). 2.1.288 is the release bundled with the
|
|
39
39
|
* Agent SDK that AGL's own Claude chats run (`CLAUDE_NATIVE_AGENT_SDK_RELEASES`), read from the SDK's binary.
|
|
40
40
|
*/
|
|
41
|
-
export const CLAUDE_NATIVE_CUSTODY_RELEASES: readonly string[] = ['2.1.280', '2.1.281', '2.1.282', '2.1.288', '2.1.306'];
|
|
41
|
+
export const CLAUDE_NATIVE_CUSTODY_RELEASES: readonly string[] = ['2.1.280', '2.1.281', '2.1.282', '2.1.288', '2.1.306', '2.1.322'];
|
|
42
42
|
/** An Agent SDK version and the Claude Code release it bundles. */
|
|
43
43
|
export interface IClaudeNativeAgentSdkRelease {
|
|
44
44
|
/** The SDK version, as its platform package's manifest beside the binary names it. */
|
|
@@ -69,11 +69,11 @@ const PROFILE_TIMEOUT_MS = 10_000;
|
|
|
69
69
|
/**
|
|
70
70
|
* The account-bound keys of `.claude.json` a login change invalidates, beside `oauthAccount` itself: the caches
|
|
71
71
|
* Claude Code's own logout clears (`performLogout`), in every listed release (2.1.288 adds the two `metricsStatus`
|
|
72
|
-
* caches to 2.1.282's, 2.1.306 `unusedLimitResetStatusCache`).
|
|
72
|
+
* caches to 2.1.282's, 2.1.306 `unusedLimitResetStatusCache`, 2.1.322 `managedSettingsNoticeSeenOrg`).
|
|
73
73
|
*/
|
|
74
74
|
export const CLAUDE_NATIVE_ACCOUNT_CACHES: readonly string[] = [
|
|
75
|
-
'
|
|
76
|
-
'modelAccessCache', 'orgModelDefaultCache', 'cachedArtifactRoster', 'artifactRosterDenied',
|
|
75
|
+
'managedSettingsNoticeSeenOrg', 'additionalModelOptionsCache', 'additionalModelOptionsAnsweredAt',
|
|
76
|
+
'additionalModelCostsCache', 'modelAccessCache', 'orgModelDefaultCache', 'cachedArtifactRoster', 'artifactRosterDenied',
|
|
77
77
|
'lastSeenOrgDefaultUpdatedAt', 'clientDataCache', 'clientDataCacheSlots', 'autoCompactWindowsCache',
|
|
78
78
|
'cachedUsageUtilization', 'metricsStatusCache', 'metricsStatusCacheByPrincipal', 'githubWebConnectionStatusCache',
|
|
79
79
|
'unusedLimitResetStatusCache', 'startupPrefetchedAt',
|
|
@@ -458,9 +458,9 @@ const selectedNativeHome = (env: NodeJS.ProcessEnv): string | null => env.CLAUDE
|
|
|
458
458
|
|
|
459
459
|
/**
|
|
460
460
|
* The directory a Claude Code process keeps its credential store in and takes its OAuth refresh lock in, as its
|
|
461
|
-
* environment selects it (2.1.282 `pw`, 2.1.288 `OS`, 2.1.306 `TL`): `CLAUDE_SECURESTORAGE_CONFIG_DIR`
|
|
462
|
-
* NFC-normalised, its empty value meaning `.claude` in the home directory (`os.homedir()`, read here
|
|
463
|
-
* its native home otherwise. Null when the environment does not determine it.
|
|
461
|
+
* environment selects it (2.1.282 `pw`, 2.1.288 `OS`, 2.1.306 `TL`, 2.1.322 `SB`): `CLAUDE_SECURESTORAGE_CONFIG_DIR`
|
|
462
|
+
* when it is set, NFC-normalised, its empty value meaning `.claude` in the home directory (`os.homedir()`, read here
|
|
463
|
+
* from `HOME`), and its native home otherwise. Null when the environment does not determine it.
|
|
464
464
|
*/
|
|
465
465
|
export const claudeNativeCredentialStoreDirectory = (env: NodeJS.ProcessEnv): string | null => {
|
|
466
466
|
const store = env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|