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
package/ts/classes.controller.ts
CHANGED
|
@@ -55,6 +55,7 @@ import type { TAglProxyLeaseCatalog } from './classes.proxycontrol.js';
|
|
|
55
55
|
import { AglProxyLeaseHolder } from './classes.proxyleaseholder.js';
|
|
56
56
|
import { AglProxyOutdatedError, AglProxyRefusedError, AglProxyUnavailableError } from './classes.proxycontrolclient.js';
|
|
57
57
|
import { inferenceHarnessLaunch } from './functions.inferencelaunch.js';
|
|
58
|
+
import { claudeHookSwitchNotice, dropClaudeHookSwitches } from './functions.proxyharnessconfig.js';
|
|
58
59
|
import type { IControllerTerminalAgentInferenceSession } from './classes.terminalmanager.js';
|
|
59
60
|
import type { TConfigurationHostClaudeLogin } from './configuration/classes.inferencereview.js';
|
|
60
61
|
import { AuthorityState } from './classes.authoritystate.js';
|
|
@@ -425,6 +426,7 @@ import {
|
|
|
425
426
|
type IReq_DeviceTicketAsk,
|
|
426
427
|
type IReq_DeviceTicketMove,
|
|
427
428
|
type IControllerSessionFeedRow,
|
|
429
|
+
type IControllerInboxElicitationItem,
|
|
428
430
|
type IReq_ControllerInboxList,
|
|
429
431
|
type TControllerInboxAnswer,
|
|
430
432
|
type TControllerElicitation,
|
|
@@ -899,6 +901,7 @@ import { ControllerAgentMessageLimiter } from './classes.agentmessagelimiter.js'
|
|
|
899
901
|
import { agentMessageSubjects, formatAgentMessage, formatOwnerFleetMessage } from './functions.agentmessage.js';
|
|
900
902
|
import { FleetNativeTurnError, type TFleetNativeReply } from './fleet/interfaces.workers.js';
|
|
901
903
|
import { ControllerElicitationReplyError } from './functions.elicitation.js';
|
|
904
|
+
import { ControllerPromptReplyError, promptNoLongerPending } from './functions.promptreply.js';
|
|
902
905
|
import {
|
|
903
906
|
isModelChoiceOffered,
|
|
904
907
|
resolveFlexDefaultModel,
|
|
@@ -2510,15 +2513,30 @@ const canonicalDirectory = async (pathArg: string): Promise<string | undefined>
|
|
|
2510
2513
|
try { return await plugins.fs.promises.realpath(pathArg); } catch { return undefined; }
|
|
2511
2514
|
};
|
|
2512
2515
|
/**
|
|
2513
|
-
* A
|
|
2514
|
-
*
|
|
2516
|
+
* A refused reply as the typed refusal it is: an elicitation's (the answer does not fit the request, or the request is
|
|
2517
|
+
* gone) and a permission's or question's the session no longer holds (`promptNoLongerPending`: `concurrent_change`,
|
|
2518
|
+
* nothing was sent; a device receives it as it is). Its text never carries what the owner entered.
|
|
2515
2519
|
*/
|
|
2516
|
-
const
|
|
2517
|
-
errorArg
|
|
2518
|
-
|
|
2520
|
+
const typedReplyRefusal = (
|
|
2521
|
+
errorArg: ControllerElicitationReplyError | ControllerPromptReplyError,
|
|
2522
|
+
): plugins.typedrequest.TypedResponseError => new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
2523
|
+
|
|
2524
|
+
/** `typedReplyRefusal` for what a harness or the OpenCode client threw on a reply; every other error passes as it is. */
|
|
2525
|
+
const replyRefusal = (errorArg: unknown): unknown => (
|
|
2526
|
+
errorArg instanceof ControllerElicitationReplyError || errorArg instanceof ControllerPromptReplyError
|
|
2527
|
+
? typedReplyRefusal(errorArg)
|
|
2519
2528
|
: errorArg
|
|
2520
2529
|
);
|
|
2521
2530
|
|
|
2531
|
+
/** Sends an answer through the component that holds the request, its refusal typed (`replyRefusal`). */
|
|
2532
|
+
const sendingReply = async <T>(sendArg: () => T | Promise<T>): Promise<T> => {
|
|
2533
|
+
try {
|
|
2534
|
+
return await sendArg();
|
|
2535
|
+
} catch (errorArg) {
|
|
2536
|
+
throw replyRefusal(errorArg);
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2522
2540
|
/** The ticket changes the owner makes from the browser's board or a paired device, each with its audit type. */
|
|
2523
2541
|
type TTicketChangeOperation = 'comment' | 'ask' | 'move';
|
|
2524
2542
|
const ticketChangeAuditTypes = {
|
|
@@ -3613,37 +3631,50 @@ export class OpenCodeController {
|
|
|
3613
3631
|
return { rowId, name: this.sessionFeed?.publishedRow(rowId)?.name ?? (fallbackNameArg.trim() || 'Untitled session') };
|
|
3614
3632
|
}
|
|
3615
3633
|
|
|
3634
|
+
/** An Inbox item's id: its kind, the session that holds the request and the request's id. */
|
|
3635
|
+
private inboxRequestItemId(kindArg: string, requestArg: { id: IControllerRuntimeId }, sessionArg: IControllerRuntimeId): string {
|
|
3636
|
+
return `${kindArg}:${sessionArg.harnessId}:${sessionArg.nativeId}:${requestArg.id.nativeId}`;
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3616
3639
|
/**
|
|
3617
|
-
* The items of a session's
|
|
3618
|
-
* nobody and is left out; questions
|
|
3640
|
+
* The items of a session's permissions and questions. A permission that the owner's auto-accept answers
|
|
3641
|
+
* (`autoAcceptedArg`) waits for nobody and is left out; questions are never answered automatically.
|
|
3619
3642
|
*/
|
|
3620
3643
|
private inboxSessionItems(
|
|
3621
3644
|
whereArg: Extract<TControllerInboxWhere, { kind: 'conversation' | 'child' | 'native' | 'driver' }>,
|
|
3622
3645
|
answerArg: TControllerInboxAnswer,
|
|
3623
|
-
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[]
|
|
3646
|
+
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[] },
|
|
3624
3647
|
autoAcceptedArg = false,
|
|
3625
3648
|
): TControllerInboxItem[] {
|
|
3626
|
-
const id = (kindArg: string, requestArg: { id: IControllerRuntimeId }, sessionArg: IControllerRuntimeId) => (
|
|
3627
|
-
`${kindArg}:${sessionArg.harnessId}:${sessionArg.nativeId}:${requestArg.id.nativeId}`
|
|
3628
|
-
);
|
|
3629
3649
|
return [
|
|
3630
3650
|
...(autoAcceptedArg ? [] : attentionArg.permissions).map((permissionArg): TControllerInboxItem => ({
|
|
3631
|
-
id:
|
|
3651
|
+
id: this.inboxRequestItemId('permission', permissionArg, permissionArg.sessionId), kind: 'permission', since: permissionArg.createdAt,
|
|
3632
3652
|
title: inboxTitle(permissionArg.title || permissionArg.type), where: whereArg, answer: answerArg, permission: permissionArg,
|
|
3633
3653
|
})),
|
|
3634
3654
|
...attentionArg.questions.map((questionArg): TControllerInboxItem => ({
|
|
3635
|
-
id:
|
|
3655
|
+
id: this.inboxRequestItemId('question', questionArg, questionArg.sessionId), kind: 'question', since: questionArg.createdAt,
|
|
3636
3656
|
title: inboxTitle(questionArg.questions[0]?.question || questionArg.questions[0]?.header || 'A question'),
|
|
3637
3657
|
where: whereArg, answer: answerArg, question: questionArg,
|
|
3638
3658
|
})),
|
|
3639
|
-
...(attentionArg.elicitations ?? []).map((elicitationArg): TControllerInboxItem => ({
|
|
3640
|
-
id: id('elicitation', elicitationArg, elicitationArg.sessionId), kind: 'elicitation', since: elicitationArg.createdAt,
|
|
3641
|
-
title: inboxTitle(elicitationArg.message || `${elicitationArg.serverName} asks for input`),
|
|
3642
|
-
where: whereArg, answer: answerArg, elicitation: elicitationArg,
|
|
3643
|
-
})),
|
|
3644
3659
|
];
|
|
3645
3660
|
}
|
|
3646
3661
|
|
|
3662
|
+
/**
|
|
3663
|
+
* The items of a session's MCP forms, which are never answered automatically. Only Claude Code and Codex hand AGL
|
|
3664
|
+
* MCP forms, so a direct child (an OpenCode subagent) never holds one.
|
|
3665
|
+
*/
|
|
3666
|
+
private inboxElicitationItems(
|
|
3667
|
+
whereArg: IControllerInboxElicitationItem['where'],
|
|
3668
|
+
answerArg: IControllerInboxElicitationItem['answer'],
|
|
3669
|
+
elicitationsArg: readonly TControllerElicitation[],
|
|
3670
|
+
): TControllerInboxItem[] {
|
|
3671
|
+
return elicitationsArg.map((elicitationArg): TControllerInboxItem => ({
|
|
3672
|
+
id: this.inboxRequestItemId('elicitation', elicitationArg, elicitationArg.sessionId), kind: 'elicitation', since: elicitationArg.createdAt,
|
|
3673
|
+
title: inboxTitle(elicitationArg.message || `${elicitationArg.serverName} asks for input`),
|
|
3674
|
+
where: whereArg, answer: answerArg, elicitation: elicitationArg,
|
|
3675
|
+
}));
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3647
3678
|
/** A native session as the Inbox names it: where it runs and how the browser opens it. */
|
|
3648
3679
|
private inboxNativeWhere(harnessArg: 'claude' | 'codex', nativeIdArg: string, titleArg: string): Extract<TControllerInboxWhere, { kind: 'native' }> {
|
|
3649
3680
|
return { kind: 'native', session: { harness: harnessArg, nativeId: nativeIdArg }, harness: harnessArg,
|
|
@@ -3656,13 +3687,21 @@ export class OpenCodeController {
|
|
|
3656
3687
|
if (!harness || harness.closed) return [];
|
|
3657
3688
|
return harness.pendingAttention().flatMap((entryArg) => {
|
|
3658
3689
|
if (entryArg.projectId === undefined) {
|
|
3659
|
-
|
|
3690
|
+
const where = this.inboxNativeWhere('claude', entryArg.nativeId, entryArg.title);
|
|
3691
|
+
return [
|
|
3692
|
+
...this.inboxSessionItems(where, 'native', entryArg.attention),
|
|
3693
|
+
...this.inboxElicitationItems(where, 'native', entryArg.attention.elicitations),
|
|
3694
|
+
];
|
|
3660
3695
|
}
|
|
3661
3696
|
const sessionId = claudeRuntimeId(entryArg.nativeId);
|
|
3662
|
-
|
|
3697
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3663
3698
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'claude',
|
|
3664
3699
|
...this.inboxRow('claude', entryArg.nativeId, entryArg.title),
|
|
3665
|
-
}
|
|
3700
|
+
};
|
|
3701
|
+
return [
|
|
3702
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3703
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3704
|
+
];
|
|
3666
3705
|
});
|
|
3667
3706
|
}
|
|
3668
3707
|
|
|
@@ -3673,14 +3712,22 @@ export class OpenCodeController {
|
|
|
3673
3712
|
: this.codexClient && this.codexSupervisor?.getStatus().healthy ? [this.codexClient] : [];
|
|
3674
3713
|
const conversations = clients.flatMap((clientArg) => clientArg.pendingAttention().flatMap((entryArg) => {
|
|
3675
3714
|
const sessionId = codexRuntimeId(entryArg.threadId);
|
|
3676
|
-
|
|
3715
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3677
3716
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'codex',
|
|
3678
3717
|
...this.inboxRow('codex', entryArg.threadId, entryArg.session.title),
|
|
3679
|
-
}
|
|
3718
|
+
};
|
|
3719
|
+
return [
|
|
3720
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3721
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3722
|
+
];
|
|
3680
3723
|
}));
|
|
3681
|
-
const native = (this.fleetWorkers?.nativePendingAttention('codex') ?? []).flatMap((entryArg) =>
|
|
3682
|
-
this.
|
|
3683
|
-
|
|
3724
|
+
const native = (this.fleetWorkers?.nativePendingAttention('codex') ?? []).flatMap((entryArg) => {
|
|
3725
|
+
const where = this.inboxNativeWhere('codex', entryArg.nativeId, entryArg.title);
|
|
3726
|
+
return [
|
|
3727
|
+
...this.inboxSessionItems(where, 'native', entryArg.attention),
|
|
3728
|
+
...this.inboxElicitationItems(where, 'native', entryArg.attention.elicitations),
|
|
3729
|
+
];
|
|
3730
|
+
});
|
|
3684
3731
|
return [...conversations, ...native];
|
|
3685
3732
|
}
|
|
3686
3733
|
|
|
@@ -3838,7 +3885,7 @@ export class OpenCodeController {
|
|
|
3838
3885
|
let status: IFleetDeployStatus | undefined;
|
|
3839
3886
|
if (goes && this.deployMonitor) {
|
|
3840
3887
|
try {
|
|
3841
|
-
status = await this.deployMonitor.status();
|
|
3888
|
+
status = await this.deployMonitor.status(undefined, signalArg);
|
|
3842
3889
|
} catch (errorArg) {
|
|
3843
3890
|
signalArg.throwIfAborted();
|
|
3844
3891
|
// The go is the owner's either way; what runs where is shown once the monitor answers.
|
|
@@ -3894,6 +3941,7 @@ export class OpenCodeController {
|
|
|
3894
3941
|
unboundDrivers: (signal) => this.listUnboundDrivers(signal),
|
|
3895
3942
|
tickets: async (signal) => (await this.ticketStore.execute('list', {}, undefined, signal)).tickets,
|
|
3896
3943
|
released: () => this.deployMonitor?.reconcileSoon(),
|
|
3944
|
+
landed: () => this.deployMonitor?.reconcileSoon(),
|
|
3897
3945
|
onOperation: (operation, owner, repo) => {
|
|
3898
3946
|
this.requireFleetWorkers().releaseEvent(operation, owner, repo);
|
|
3899
3947
|
if (operation.state === 'succeeded' && operation.ticketKey && operation.result && 'ticketSync' in operation.result && operation.result.ticketSync) {
|
|
@@ -5258,7 +5306,10 @@ export class OpenCodeController {
|
|
|
5258
5306
|
}
|
|
5259
5307
|
}
|
|
5260
5308
|
|
|
5261
|
-
/**
|
|
5309
|
+
/**
|
|
5310
|
+
* How a Claude Code process starts: the controller's environment with only its endpoint and credential on the lease,
|
|
5311
|
+
* and without its hook switches (`inferenceHarnessLaunch`).
|
|
5312
|
+
*/
|
|
5262
5313
|
private async claudeLaunch(signalArg: AbortSignal): Promise<IClaudeLaunch> {
|
|
5263
5314
|
const lease = await this.claudeLease(signalArg);
|
|
5264
5315
|
if (lease.state === 'lost' || lease.state === 'closed' || lease.catalog.provider !== 'anthropic') {
|
|
@@ -5341,7 +5392,7 @@ export class OpenCodeController {
|
|
|
5341
5392
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
5342
5393
|
if (this.claudeHarness !== harness || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
5343
5394
|
if (harness.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
5344
|
-
harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
5395
|
+
await sendingReply(() => harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
5345
5396
|
}
|
|
5346
5397
|
},
|
|
5347
5398
|
));
|
|
@@ -6156,7 +6207,7 @@ export class OpenCodeController {
|
|
|
6156
6207
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
6157
6208
|
if (this.requireCodexClient(sessionIdArg.nativeId) !== client || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
6158
6209
|
if (client.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
6159
|
-
client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
6210
|
+
await sendingReply(() => client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
6160
6211
|
}
|
|
6161
6212
|
},
|
|
6162
6213
|
));
|
|
@@ -9494,6 +9545,8 @@ export class OpenCodeController {
|
|
|
9494
9545
|
...patch,
|
|
9495
9546
|
...(standardProjectDirectories === undefined ? {} : { standardProjectDirectories }),
|
|
9496
9547
|
});
|
|
9548
|
+
// The standard directories are the roots fleet discovery walks: the deploy monitor's next run walks again.
|
|
9549
|
+
if (standardProjectDirectories !== undefined) this.deployMonitor?.workspaceChanged();
|
|
9497
9550
|
this.defaultModels = settings.defaultModels;
|
|
9498
9551
|
this.sessionIntelligenceModel = settings.sessionIntelligenceModel;
|
|
9499
9552
|
const autoAcceptEnabled = settings.autoAcceptPermissions === true;
|
|
@@ -10483,13 +10536,13 @@ export class OpenCodeController {
|
|
|
10483
10536
|
owner.localCli ? 'driver' : 'owner', owner.localCli?.osUser ?? 'Owner');
|
|
10484
10537
|
return this.submitFleetOperation(operation, input, master.fleet ?? {}, owner.resourceId, actor);
|
|
10485
10538
|
}),
|
|
10486
|
-
deploy: (method, request, signal) => run(signal, async () => {
|
|
10539
|
+
deploy: (method, request, signal) => run(signal, async (operationSignalArg) => {
|
|
10487
10540
|
if (!this.configurationAuthority || typeof request.ownerToken !== 'string') {
|
|
10488
10541
|
throw new plugins.typedrequest.TypedResponseError('Deploy status requires a local-owner capability.', { code: 'unauthorized' });
|
|
10489
10542
|
}
|
|
10490
10543
|
await this.configurationAuthority.verifyOwnerCapability({ token: request.ownerToken });
|
|
10491
10544
|
const { ownerToken: _token, ...input } = request;
|
|
10492
|
-
return this.executeDeploy(method, input);
|
|
10545
|
+
return this.executeDeploy(method, input, operationSignalArg);
|
|
10493
10546
|
}),
|
|
10494
10547
|
tickets: (methodArg, requestArg, signalArg, connectionArg) => run(signalArg, async (operationSignalArg) => {
|
|
10495
10548
|
const { ownerToken, ...request } = requestArg;
|
|
@@ -10618,10 +10671,21 @@ export class OpenCodeController {
|
|
|
10618
10671
|
};
|
|
10619
10672
|
}
|
|
10620
10673
|
|
|
10674
|
+
/**
|
|
10675
|
+
* Says once at start which hook switches (`claudeHookSwitchVariables`) the controller's own environment holds: the Claude
|
|
10676
|
+
* Code sessions it starts, its chats and its fleet's workers, get none of them (AGL-1783). On stderr, which a detached
|
|
10677
|
+
* controller keeps in its log file.
|
|
10678
|
+
*/
|
|
10679
|
+
private noteClaudeHookSwitches(): void {
|
|
10680
|
+
const notice = claudeHookSwitchNotice('The AGL controller', dropClaudeHookSwitches({ ...process.env }));
|
|
10681
|
+
if (notice) console.error(notice);
|
|
10682
|
+
}
|
|
10683
|
+
|
|
10621
10684
|
private async performStart(): Promise<IControllerStartResult> {
|
|
10622
10685
|
process.env.AGL_HOME = resolveAGLHomePaths().root;
|
|
10623
10686
|
this.lifecycleState = 'starting';
|
|
10624
10687
|
this.captureInheritedUpgradeCoordination();
|
|
10688
|
+
this.noteClaudeHookSwitches();
|
|
10625
10689
|
const identity = await readControllerProcessIdentity(process.pid);
|
|
10626
10690
|
this.assertStartActive();
|
|
10627
10691
|
if (identity) {
|
|
@@ -10839,6 +10903,10 @@ export class OpenCodeController {
|
|
|
10839
10903
|
this.assertStartActive();
|
|
10840
10904
|
this.runtimeConfig = runtimeConfig;
|
|
10841
10905
|
this.controllerId = authDocument.id;
|
|
10906
|
+
// The stored deploy status, and with it the undeployed set the board's AutoLabel reads, loads before anything can
|
|
10907
|
+
// read the board (AGL-1704).
|
|
10908
|
+
await this.requireDeployMonitor().load();
|
|
10909
|
+
this.assertStartActive();
|
|
10842
10910
|
// Messages still queued or steering when the controller stopped are held for the user; the
|
|
10843
10911
|
// prompts of a durable Flex limit hold are restored with that hold instead.
|
|
10844
10912
|
const armedFlexHolds = new Set((await authStore.listArmedFlexLimitHolds()).map((record) => (
|
|
@@ -14793,7 +14861,7 @@ export class OpenCodeController {
|
|
|
14793
14861
|
agl: deviceHostAgl({ version: commitinfo.version, startedAt: this.startedAt, origin: publicOriginArg, gateway: this.gatewayClient?.status() }),
|
|
14794
14862
|
device: deviceHostDevice(device),
|
|
14795
14863
|
...await readDeviceHostSections({
|
|
14796
|
-
deployStatus: () => this.requireDeployMonitor().status(),
|
|
14864
|
+
deployStatus: (operationSignalArg) => this.requireDeployMonitor().status(undefined, operationSignalArg),
|
|
14797
14865
|
capacity: proxyMonitor === undefined ? undefined : (operationSignalArg) => proxyMonitor.capacity({}, operationSignalArg),
|
|
14798
14866
|
authority: () => this.authorityState.getProjection(),
|
|
14799
14867
|
usage: (accountIdArg, loginIdArg, operationSignalArg) => this.accountsActions.usage({ accountId: accountIdArg, loginId: loginIdArg }, operationSignalArg),
|
|
@@ -17796,15 +17864,15 @@ export class OpenCodeController {
|
|
|
17796
17864
|
const pending = kind === 'permission'
|
|
17797
17865
|
? await first.parent.client.listPermissions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal)
|
|
17798
17866
|
: await first.parent.client.listQuestions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal);
|
|
17799
|
-
this.
|
|
17867
|
+
this.assertPromptPending(pending, requestArg.requestId, kind);
|
|
17800
17868
|
const current = await verifyArg(true);
|
|
17801
17869
|
const signal = AbortSignal.any([signalArg, current.parent.runtimeAuthority.signal]);
|
|
17802
17870
|
const { directory } = current.parent.project;
|
|
17803
|
-
const success = 'reply' in requestArg
|
|
17804
|
-
?
|
|
17871
|
+
const success = await sendingReply(() => 'reply' in requestArg
|
|
17872
|
+
? current.parent.client.replyPermission(directory, requestArg.requestId.nativeId, requestArg.reply, requestArg.message, signal)
|
|
17805
17873
|
: requestArg.answers === null
|
|
17806
|
-
?
|
|
17807
|
-
:
|
|
17874
|
+
? current.parent.client.rejectQuestion(directory, requestArg.requestId.nativeId, signal)
|
|
17875
|
+
: current.parent.client.replyQuestion(directory, requestArg.requestId.nativeId, requestArg.answers, signal));
|
|
17808
17876
|
await verifyArg(false);
|
|
17809
17877
|
return { success };
|
|
17810
17878
|
},
|
|
@@ -17858,7 +17926,7 @@ export class OpenCodeController {
|
|
|
17858
17926
|
if (sessionId.harnessId === 'codex') this.requireCodexClient(sessionId.nativeId).replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17859
17927
|
else this.requireClaudeHarness().replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17860
17928
|
} catch (errorArg) {
|
|
17861
|
-
throw
|
|
17929
|
+
throw replyRefusal(errorArg);
|
|
17862
17930
|
}
|
|
17863
17931
|
return { success: true };
|
|
17864
17932
|
});
|
|
@@ -17885,27 +17953,31 @@ export class OpenCodeController {
|
|
|
17885
17953
|
if (sessionId.harnessId === 'codex') {
|
|
17886
17954
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17887
17955
|
signalArg.throwIfAborted();
|
|
17888
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
17956
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
17957
|
+
await sendingReply(() => codex.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17889
17958
|
return { success: true };
|
|
17890
17959
|
});
|
|
17891
17960
|
}
|
|
17892
17961
|
if (sessionId.harnessId === 'claude') {
|
|
17893
17962
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17894
17963
|
signalArg.throwIfAborted();
|
|
17895
|
-
this.requireClaudeHarness()
|
|
17964
|
+
const harness = this.requireClaudeHarness();
|
|
17965
|
+
await sendingReply(() => harness.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17896
17966
|
return { success: true };
|
|
17897
17967
|
});
|
|
17898
17968
|
}
|
|
17899
17969
|
if (sessionId.harnessId === 'flex') {
|
|
17900
17970
|
signalArg.throwIfAborted();
|
|
17901
17971
|
const flexSupervisor = this.requireFlexSupervisor();
|
|
17972
|
+
// The pending permission names the run whose authority answers it; one answered after this read is refused at
|
|
17973
|
+
// the send (`respondToFlexPermission`).
|
|
17902
17974
|
const pendingPermissions = await flexSupervisor.request('permission.list', {
|
|
17903
17975
|
scopeId: projectId,
|
|
17904
17976
|
}, signalArg);
|
|
17905
17977
|
const permission = pendingPermissions.permissions.find(
|
|
17906
17978
|
(candidate) => candidate.permissionId === requestId.nativeId,
|
|
17907
17979
|
);
|
|
17908
|
-
if (!permission) throw
|
|
17980
|
+
if (!permission) throw typedReplyRefusal(promptNoLongerPending('permission'));
|
|
17909
17981
|
const authority = this.flexPermissionAuthority(projectId, permission);
|
|
17910
17982
|
if (
|
|
17911
17983
|
!authority
|
|
@@ -17932,15 +18004,15 @@ export class OpenCodeController {
|
|
|
17932
18004
|
sessionId.nativeId,
|
|
17933
18005
|
signalArg,
|
|
17934
18006
|
);
|
|
17935
|
-
this.
|
|
18007
|
+
this.assertPromptPending(pendingPermissions, requestId, 'permission');
|
|
17936
18008
|
return {
|
|
17937
|
-
success: await this.requireOpenCodeClient().replyPermission(
|
|
18009
|
+
success: await sendingReply(() => this.requireOpenCodeClient().replyPermission(
|
|
17938
18010
|
project.directory,
|
|
17939
18011
|
requestId.nativeId,
|
|
17940
18012
|
reply,
|
|
17941
18013
|
message,
|
|
17942
18014
|
signalArg,
|
|
17943
|
-
),
|
|
18015
|
+
)),
|
|
17944
18016
|
};
|
|
17945
18017
|
},
|
|
17946
18018
|
);
|
|
@@ -17965,14 +18037,16 @@ export class OpenCodeController {
|
|
|
17965
18037
|
if (sessionId.harnessId === 'codex') {
|
|
17966
18038
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17967
18039
|
signalArg.throwIfAborted();
|
|
17968
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
18040
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
18041
|
+
await sendingReply(() => codex.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
17969
18042
|
return { success: true };
|
|
17970
18043
|
});
|
|
17971
18044
|
}
|
|
17972
18045
|
if (sessionId.harnessId === 'claude') {
|
|
17973
18046
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17974
18047
|
signalArg.throwIfAborted();
|
|
17975
|
-
this.requireClaudeHarness()
|
|
18048
|
+
const harness = this.requireClaudeHarness();
|
|
18049
|
+
await sendingReply(() => harness.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
17976
18050
|
return { success: true };
|
|
17977
18051
|
});
|
|
17978
18052
|
}
|
|
@@ -17982,20 +18056,20 @@ export class OpenCodeController {
|
|
|
17982
18056
|
sessionId.nativeId,
|
|
17983
18057
|
signalArg,
|
|
17984
18058
|
);
|
|
17985
|
-
this.
|
|
18059
|
+
this.assertPromptPending(pendingQuestions, requestId, 'question');
|
|
17986
18060
|
return {
|
|
17987
|
-
success: answers === null
|
|
17988
|
-
?
|
|
18061
|
+
success: await sendingReply(() => answers === null
|
|
18062
|
+
? openCodeClient.rejectQuestion(
|
|
17989
18063
|
project.directory,
|
|
17990
18064
|
requestId.nativeId,
|
|
17991
18065
|
signalArg,
|
|
17992
18066
|
)
|
|
17993
|
-
:
|
|
18067
|
+
: openCodeClient.replyQuestion(
|
|
17994
18068
|
project.directory,
|
|
17995
18069
|
requestId.nativeId,
|
|
17996
18070
|
answers,
|
|
17997
18071
|
signalArg,
|
|
17998
|
-
),
|
|
18072
|
+
)),
|
|
17999
18073
|
};
|
|
18000
18074
|
},
|
|
18001
18075
|
);
|
|
@@ -18514,11 +18588,15 @@ export class OpenCodeController {
|
|
|
18514
18588
|
this.boardPump.start();
|
|
18515
18589
|
}
|
|
18516
18590
|
|
|
18517
|
-
/**
|
|
18591
|
+
/**
|
|
18592
|
+
* AGL-911: the loop that observes what each deploy target runs. It stores the deploy status it computes (AGL-1704),
|
|
18593
|
+
* which status and release state answer from; history and where a ticket runs are read when asked.
|
|
18594
|
+
*/
|
|
18518
18595
|
private requireDeployMonitor(): DeployMonitor {
|
|
18519
18596
|
// A stopping controller starts no monitor that its stop would never close.
|
|
18520
18597
|
if (!this.deployMonitor && this.stopRequested) throw new DeployError('deploy_unavailable', 'The controller is stopping.');
|
|
18521
18598
|
this.deployMonitor ??= new DeployMonitor({
|
|
18599
|
+
controllerId: () => this.requireControllerId(),
|
|
18522
18600
|
scope: async () => (this.configurationAuthority ? await this.readFleetScope() : undefined),
|
|
18523
18601
|
discover: async () => this.discoverFleetScope({}),
|
|
18524
18602
|
tickets: async (signalArg) => (await this.ticketStore.execute('list', {}, undefined, signalArg)).tickets,
|
|
@@ -18586,18 +18664,22 @@ export class OpenCodeController {
|
|
|
18586
18664
|
}
|
|
18587
18665
|
|
|
18588
18666
|
/** One deploy request, from the browser, `agl deploy` or the driver; a refusal carries its code. */
|
|
18589
|
-
private async executeDeploy(methodArg: string, requestArg: unknown): Promise<unknown> {
|
|
18667
|
+
private async executeDeploy(methodArg: string, requestArg: unknown, signalArg?: AbortSignal): Promise<unknown> {
|
|
18590
18668
|
const operation = fleetDeployOperation(methodArg);
|
|
18591
18669
|
const monitor = this.requireDeployMonitor();
|
|
18592
18670
|
try {
|
|
18593
|
-
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId);
|
|
18671
|
+
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId, signalArg);
|
|
18594
18672
|
if (operation === 'history') {
|
|
18595
18673
|
const request = assertFleetDeployRequest('history', requestArg);
|
|
18596
18674
|
return await monitor.history(request.targetId, request.limit);
|
|
18597
18675
|
}
|
|
18598
|
-
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId);
|
|
18676
|
+
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId, signalArg);
|
|
18599
18677
|
if (operation === 'ticket') return await monitor.ticketPlacement(assertFleetDeployRequest('ticket', requestArg).ticketKey);
|
|
18600
|
-
|
|
18678
|
+
if (operation === 'refresh') {
|
|
18679
|
+
assertFleetDeployRequest('refresh', requestArg);
|
|
18680
|
+
return await monitor.refresh(signalArg);
|
|
18681
|
+
}
|
|
18682
|
+
return await monitor.releaseStatus(assertFleetDeployRequest('release', requestArg).repo, signalArg);
|
|
18601
18683
|
} catch (errorArg) {
|
|
18602
18684
|
if (errorArg instanceof DeployError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
18603
18685
|
throw errorArg;
|
|
@@ -18820,14 +18902,14 @@ export class OpenCodeController {
|
|
|
18820
18902
|
);
|
|
18821
18903
|
}
|
|
18822
18904
|
|
|
18823
|
-
/** The Deployments view: status, history, a probe now
|
|
18905
|
+
/** The Deployments view: status, history, a probe now, release state and a full check now (AGL-911, AGL-914, AGL-1704). */
|
|
18824
18906
|
private registerDeployHandlers(protectedRouterArg: ControllerProtectedRouter): void {
|
|
18825
18907
|
for (const operation of fleetDeployOperations) {
|
|
18826
18908
|
protectedRouterArg.addHandler<TControllerDeployRequest<TFleetDeployOperation>>(`controller.deploy.${operation}`,
|
|
18827
18909
|
async (requestArg, toolsArg) => {
|
|
18828
18910
|
validateRequest(() => assertFleetDeployRequest(operation, requestArg));
|
|
18829
18911
|
const peer = peerFromLocalData(toolsArg?.localData);
|
|
18830
|
-
return this.runOperation(peer, async () => await this.executeDeploy(`controller.deploy.${operation}`, requestArg) as never,
|
|
18912
|
+
return this.runOperation(peer, async (signalArg) => await this.executeDeploy(`controller.deploy.${operation}`, requestArg, signalArg) as never,
|
|
18831
18913
|
toolsArg?.abortSignal);
|
|
18832
18914
|
});
|
|
18833
18915
|
}
|
|
@@ -19234,9 +19316,14 @@ export class OpenCodeController {
|
|
|
19234
19316
|
): Promise<IControllerAttention> {
|
|
19235
19317
|
const { session, native } = resolvedArg;
|
|
19236
19318
|
if (session.harness === 'codex') return await this.requireFleetWorkers().nativeAttention('codex', native);
|
|
19319
|
+
return this.claudeAttention(native.nativeId);
|
|
19320
|
+
}
|
|
19321
|
+
|
|
19322
|
+
/** The requests AGL's own Claude Code holds for a conversation; none once it no longer runs the conversation. */
|
|
19323
|
+
private claudeAttention(nativeIdArg: string): IControllerAttention {
|
|
19237
19324
|
const harness = this.claudeHarness;
|
|
19238
|
-
return harness && !harness.closed && harness.isRegistered(
|
|
19239
|
-
? harness.attention(
|
|
19325
|
+
return harness && !harness.closed && harness.isRegistered(nativeIdArg)
|
|
19326
|
+
? harness.attention(nativeIdArg)
|
|
19240
19327
|
: { permissions: [], questions: [], elicitations: [] };
|
|
19241
19328
|
}
|
|
19242
19329
|
|
|
@@ -19250,7 +19337,10 @@ export class OpenCodeController {
|
|
|
19250
19337
|
const attention = await this.nativeSessionAttention(resolvedArg);
|
|
19251
19338
|
const pending = kindArg === 'permission' ? attention.permissions : kindArg === 'question' ? attention.questions : attention.elicitations;
|
|
19252
19339
|
if (!pending.some((request) => request.id.nativeId === requestIdArg)) {
|
|
19253
|
-
|
|
19340
|
+
// An elicitation keeps the refusal its harnesses state for it (`ControllerElicitationReplyError`'s `not_found`).
|
|
19341
|
+
throw kindArg === 'elicitation'
|
|
19342
|
+
? new plugins.typedrequest.TypedResponseError('The MCP request is no longer pending.', { code: 'not_found' })
|
|
19343
|
+
: typedReplyRefusal(promptNoLongerPending(kindArg));
|
|
19254
19344
|
}
|
|
19255
19345
|
try {
|
|
19256
19346
|
if (session.harness === 'codex') {
|
|
@@ -19262,7 +19352,7 @@ export class OpenCodeController {
|
|
|
19262
19352
|
else if ('elicitation' in replyArg) harness.replyElicitation(native.nativeId, requestIdArg, replyArg.elicitation);
|
|
19263
19353
|
else harness.replyQuestion(native.nativeId, requestIdArg, replyArg.answers);
|
|
19264
19354
|
} catch (errorArg) {
|
|
19265
|
-
throw
|
|
19355
|
+
throw replyRefusal(errorArg);
|
|
19266
19356
|
}
|
|
19267
19357
|
}
|
|
19268
19358
|
|
|
@@ -19810,7 +19900,7 @@ export class OpenCodeController {
|
|
|
19810
19900
|
} else if (route.kind === 'directreport') {
|
|
19811
19901
|
result = await this.executeDriverDirectReport(route.operation, input, actor, signalArg);
|
|
19812
19902
|
} else if (route.kind === 'deploy') {
|
|
19813
|
-
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input);
|
|
19903
|
+
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input, signalArg);
|
|
19814
19904
|
} else {
|
|
19815
19905
|
const { owner, configuration } = await this.readFleetScope();
|
|
19816
19906
|
if (route.kind === 'worker') {
|
|
@@ -20438,6 +20528,8 @@ export class OpenCodeController {
|
|
|
20438
20528
|
resolvedDirectory.directory,
|
|
20439
20529
|
{ ancestry: resolvedDirectory.ancestry },
|
|
20440
20530
|
);
|
|
20531
|
+
// A project is a root fleet discovery walks: the deploy monitor's next run walks again.
|
|
20532
|
+
if (created) this.deployMonitor?.workspaceChanged();
|
|
20441
20533
|
let reconciliation: IProjectReconciliationResult;
|
|
20442
20534
|
try {
|
|
20443
20535
|
reconciliation = await this.reconcileProjectStateInMutation(
|
|
@@ -20896,6 +20988,8 @@ export class OpenCodeController {
|
|
|
20896
20988
|
{ code: 'concurrent_change' },
|
|
20897
20989
|
);
|
|
20898
20990
|
}
|
|
20991
|
+
// A project being removed is no root fleet discovery walks any more.
|
|
20992
|
+
this.deployMonitor?.workspaceChanged();
|
|
20899
20993
|
project = pending;
|
|
20900
20994
|
}
|
|
20901
20995
|
if (
|
|
@@ -22823,7 +22917,12 @@ export class OpenCodeController {
|
|
|
22823
22917
|
return [...archivedByKey.values()].map((sessionId) => ({ ...sessionId }));
|
|
22824
22918
|
}
|
|
22825
22919
|
|
|
22826
|
-
|
|
22920
|
+
/**
|
|
22921
|
+
* Refuses an answer to a permission or question the session does not hold (`promptNoLongerPending`), read from
|
|
22922
|
+
* OpenCode's pending requests before anything is sent; OpenCode refuses one answered in between itself (its client
|
|
22923
|
+
* throws `promptNoLongerPending`).
|
|
22924
|
+
*/
|
|
22925
|
+
private assertPromptPending(
|
|
22827
22926
|
pendingRequestsArg: ReadonlyArray<{ id: IControllerRuntimeId }>,
|
|
22828
22927
|
requestIdArg: IControllerRuntimeId,
|
|
22829
22928
|
kindArg: 'permission' | 'question',
|
|
@@ -22831,10 +22930,7 @@ export class OpenCodeController {
|
|
|
22831
22930
|
if (pendingRequestsArg.some((request) => (
|
|
22832
22931
|
controllerRuntimeIdKey(request.id) === controllerRuntimeIdKey(requestIdArg)
|
|
22833
22932
|
))) return;
|
|
22834
|
-
throw
|
|
22835
|
-
`The ${kindArg} request does not belong to the selected conversation.`,
|
|
22836
|
-
{ code: 'invalid_request' },
|
|
22837
|
-
);
|
|
22933
|
+
throw typedReplyRefusal(promptNoLongerPending(kindArg));
|
|
22838
22934
|
}
|
|
22839
22935
|
|
|
22840
22936
|
private toFlexMessageBundle(projectedArg: IFlexProjectedMessage): IControllerMessageBundle {
|
|
@@ -27548,7 +27644,15 @@ export class OpenCodeController {
|
|
|
27548
27644
|
permissionId: permissionArg.permissionId,
|
|
27549
27645
|
decision: decisionArg,
|
|
27550
27646
|
}, signalArg);
|
|
27551
|
-
|
|
27647
|
+
try {
|
|
27648
|
+
await response;
|
|
27649
|
+
} catch (errorArg) {
|
|
27650
|
+
// A permission answered or withdrawn since it was read: the Flex child's own check, or FlexHarness's
|
|
27651
|
+
// `FLEX_NOT_FOUND` (`FlexHarnessNotFoundError`), refuses it `NOT_FOUND` before anything is applied.
|
|
27652
|
+
throw errorArg instanceof FlexServiceError && errorArg.code === 'NOT_FOUND'
|
|
27653
|
+
? typedReplyRefusal(promptNoLongerPending('permission'))
|
|
27654
|
+
: errorArg;
|
|
27655
|
+
}
|
|
27552
27656
|
if (ticket) this.activateFlexDelegationTicket(ticket);
|
|
27553
27657
|
} catch (errorArg) {
|
|
27554
27658
|
if (ticket) this.revokeFlexDelegationTicket(ticket);
|
|
@@ -34320,7 +34424,7 @@ export class OpenCodeController {
|
|
|
34320
34424
|
permission.sessionId.nativeId,
|
|
34321
34425
|
this.operationAbortController.signal,
|
|
34322
34426
|
);
|
|
34323
|
-
this.
|
|
34427
|
+
this.assertPromptPending(pending, permission.id, 'permission');
|
|
34324
34428
|
const finalAuthority = await this.resolveOpenCodeFamilyAuthority(
|
|
34325
34429
|
projectId,
|
|
34326
34430
|
permission.sessionId as IControllerRuntimeId & { harnessId: 'opencode' },
|
|
@@ -34352,13 +34456,13 @@ export class OpenCodeController {
|
|
|
34352
34456
|
try {
|
|
34353
34457
|
await this.runAudited(
|
|
34354
34458
|
{ type: 'permission.reply', requestId: permission.id, sessionId: permission.sessionId },
|
|
34355
|
-
async () => openCodeClient.replyPermission(
|
|
34459
|
+
async () => sendingReply(() => openCodeClient.replyPermission(
|
|
34356
34460
|
currentAuthority.parent.project.directory,
|
|
34357
34461
|
permission.id.nativeId,
|
|
34358
34462
|
'once',
|
|
34359
34463
|
undefined,
|
|
34360
34464
|
this.operationAbortController.signal,
|
|
34361
|
-
),
|
|
34465
|
+
)),
|
|
34362
34466
|
);
|
|
34363
34467
|
} catch (errorArg) {
|
|
34364
34468
|
this.autoRepliedPermissionIds.delete(permissionKey);
|
|
@@ -166,6 +166,18 @@ const writeStreamCut = (cutArg: IInferenceGatewayStreamCut): void => {
|
|
|
166
166
|
+ `${cutArg.cause} (${cutArg.error})\n`);
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* The proxy's journal line for a provider 429 (AGL-1797): the account by its id's first twelve characters, the model,
|
|
171
|
+
* and what the provider stated -- its `Retry-After` and its rate-limit headers, which name the limit that was met. The
|
|
172
|
+
* Codex turn-state token is left out (`isCodexResponseHeader`): it routes one turn on the account that issued it.
|
|
173
|
+
*/
|
|
174
|
+
const writeProvider429 = (routeArg: { provider: string; accountId: string; model: { modelId: string } }, headersArg: Headers): void => {
|
|
175
|
+
const stated = [...headersArg].filter(([name]) => name === 'retry-after' || name.startsWith('anthropic-ratelimit-')
|
|
176
|
+
|| name.startsWith('x-ratelimit-') || isCodexResponseHeader(name)).map(([name, value]) => `${name}=${value.slice(0, 80)}`);
|
|
177
|
+
process.stderr.write(`AGL proxy met a provider 429 (${routeArg.provider}) on account ${routeArg.accountId.slice(0, 12)} for `
|
|
178
|
+
+ `${routeArg.model.modelId}: ${stated.length ? stated.join(', ') : 'no Retry-After or rate-limit header'}\n`);
|
|
179
|
+
};
|
|
180
|
+
|
|
169
181
|
const refusalRepeatWindowMs = 60_000;
|
|
170
182
|
|
|
171
183
|
/**
|
|
@@ -1106,7 +1118,9 @@ export class InferenceGateway {
|
|
|
1106
1118
|
}
|
|
1107
1119
|
if (response.status === 429) {
|
|
1108
1120
|
const seconds = this.options.router.retryAfterSeconds(response.headers);
|
|
1109
|
-
this.options.router.reportQuota(route.accountId, seconds
|
|
1121
|
+
this.options.router.reportQuota(route.accountId, seconds,
|
|
1122
|
+
route.provider === 'anthropic' && route.credential === 'subscription' ? route.model.modelId : undefined);
|
|
1123
|
+
writeProvider429(route, response.headers);
|
|
1110
1124
|
exhaustedPlans.add(route.plan);
|
|
1111
1125
|
quotaError = new InferenceRoutingError(429, 'accounts_exhausted', 'The eligible accounts reached their provider limits.',
|
|
1112
1126
|
seconds, [...exhaustedPlans]);
|