agl 43.3.2 → 43.4.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 +12 -0
- package/dist_serve/bundle.js +1377 -1375
- package/dist_serve/bundle.js.map +2 -2
- 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 +22 -5
- package/dist_ts/classes.controller.js +149 -61
- 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.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.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.mcpdeploytools.js +3 -1
- package/dist_ts/functions.promptreply.d.ts +13 -0
- package/dist_ts/functions.promptreply.js +17 -0
- 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/package.json +1 -1
- package/readme.md +29 -11
- 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 +161 -72
- 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.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.deploycli.ts +2 -1
- package/ts/functions.deviceapi.ts +19 -9
- package/ts/functions.mcpdeploytools.ts +2 -0
- package/ts/functions.promptreply.ts +20 -0
- 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_web/00_commitinfo_data.ts +1 -1
- 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
|
@@ -425,6 +425,7 @@ import {
|
|
|
425
425
|
type IReq_DeviceTicketAsk,
|
|
426
426
|
type IReq_DeviceTicketMove,
|
|
427
427
|
type IControllerSessionFeedRow,
|
|
428
|
+
type IControllerInboxElicitationItem,
|
|
428
429
|
type IReq_ControllerInboxList,
|
|
429
430
|
type TControllerInboxAnswer,
|
|
430
431
|
type TControllerElicitation,
|
|
@@ -899,6 +900,7 @@ import { ControllerAgentMessageLimiter } from './classes.agentmessagelimiter.js'
|
|
|
899
900
|
import { agentMessageSubjects, formatAgentMessage, formatOwnerFleetMessage } from './functions.agentmessage.js';
|
|
900
901
|
import { FleetNativeTurnError, type TFleetNativeReply } from './fleet/interfaces.workers.js';
|
|
901
902
|
import { ControllerElicitationReplyError } from './functions.elicitation.js';
|
|
903
|
+
import { ControllerPromptReplyError, promptNoLongerPending } from './functions.promptreply.js';
|
|
902
904
|
import {
|
|
903
905
|
isModelChoiceOffered,
|
|
904
906
|
resolveFlexDefaultModel,
|
|
@@ -2510,15 +2512,30 @@ const canonicalDirectory = async (pathArg: string): Promise<string | undefined>
|
|
|
2510
2512
|
try { return await plugins.fs.promises.realpath(pathArg); } catch { return undefined; }
|
|
2511
2513
|
};
|
|
2512
2514
|
/**
|
|
2513
|
-
* A
|
|
2514
|
-
*
|
|
2515
|
+
* A refused reply as the typed refusal it is: an elicitation's (the answer does not fit the request, or the request is
|
|
2516
|
+
* gone) and a permission's or question's the session no longer holds (`promptNoLongerPending`: `concurrent_change`,
|
|
2517
|
+
* nothing was sent; a device receives it as it is). Its text never carries what the owner entered.
|
|
2515
2518
|
*/
|
|
2516
|
-
const
|
|
2517
|
-
errorArg
|
|
2518
|
-
|
|
2519
|
+
const typedReplyRefusal = (
|
|
2520
|
+
errorArg: ControllerElicitationReplyError | ControllerPromptReplyError,
|
|
2521
|
+
): plugins.typedrequest.TypedResponseError => new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
2522
|
+
|
|
2523
|
+
/** `typedReplyRefusal` for what a harness or the OpenCode client threw on a reply; every other error passes as it is. */
|
|
2524
|
+
const replyRefusal = (errorArg: unknown): unknown => (
|
|
2525
|
+
errorArg instanceof ControllerElicitationReplyError || errorArg instanceof ControllerPromptReplyError
|
|
2526
|
+
? typedReplyRefusal(errorArg)
|
|
2519
2527
|
: errorArg
|
|
2520
2528
|
);
|
|
2521
2529
|
|
|
2530
|
+
/** Sends an answer through the component that holds the request, its refusal typed (`replyRefusal`). */
|
|
2531
|
+
const sendingReply = async <T>(sendArg: () => T | Promise<T>): Promise<T> => {
|
|
2532
|
+
try {
|
|
2533
|
+
return await sendArg();
|
|
2534
|
+
} catch (errorArg) {
|
|
2535
|
+
throw replyRefusal(errorArg);
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2522
2539
|
/** The ticket changes the owner makes from the browser's board or a paired device, each with its audit type. */
|
|
2523
2540
|
type TTicketChangeOperation = 'comment' | 'ask' | 'move';
|
|
2524
2541
|
const ticketChangeAuditTypes = {
|
|
@@ -3613,37 +3630,50 @@ export class OpenCodeController {
|
|
|
3613
3630
|
return { rowId, name: this.sessionFeed?.publishedRow(rowId)?.name ?? (fallbackNameArg.trim() || 'Untitled session') };
|
|
3614
3631
|
}
|
|
3615
3632
|
|
|
3633
|
+
/** An Inbox item's id: its kind, the session that holds the request and the request's id. */
|
|
3634
|
+
private inboxRequestItemId(kindArg: string, requestArg: { id: IControllerRuntimeId }, sessionArg: IControllerRuntimeId): string {
|
|
3635
|
+
return `${kindArg}:${sessionArg.harnessId}:${sessionArg.nativeId}:${requestArg.id.nativeId}`;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3616
3638
|
/**
|
|
3617
|
-
* The items of a session's
|
|
3618
|
-
* nobody and is left out; questions
|
|
3639
|
+
* The items of a session's permissions and questions. A permission that the owner's auto-accept answers
|
|
3640
|
+
* (`autoAcceptedArg`) waits for nobody and is left out; questions are never answered automatically.
|
|
3619
3641
|
*/
|
|
3620
3642
|
private inboxSessionItems(
|
|
3621
3643
|
whereArg: Extract<TControllerInboxWhere, { kind: 'conversation' | 'child' | 'native' | 'driver' }>,
|
|
3622
3644
|
answerArg: TControllerInboxAnswer,
|
|
3623
|
-
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[]
|
|
3645
|
+
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[] },
|
|
3624
3646
|
autoAcceptedArg = false,
|
|
3625
3647
|
): TControllerInboxItem[] {
|
|
3626
|
-
const id = (kindArg: string, requestArg: { id: IControllerRuntimeId }, sessionArg: IControllerRuntimeId) => (
|
|
3627
|
-
`${kindArg}:${sessionArg.harnessId}:${sessionArg.nativeId}:${requestArg.id.nativeId}`
|
|
3628
|
-
);
|
|
3629
3648
|
return [
|
|
3630
3649
|
...(autoAcceptedArg ? [] : attentionArg.permissions).map((permissionArg): TControllerInboxItem => ({
|
|
3631
|
-
id:
|
|
3650
|
+
id: this.inboxRequestItemId('permission', permissionArg, permissionArg.sessionId), kind: 'permission', since: permissionArg.createdAt,
|
|
3632
3651
|
title: inboxTitle(permissionArg.title || permissionArg.type), where: whereArg, answer: answerArg, permission: permissionArg,
|
|
3633
3652
|
})),
|
|
3634
3653
|
...attentionArg.questions.map((questionArg): TControllerInboxItem => ({
|
|
3635
|
-
id:
|
|
3654
|
+
id: this.inboxRequestItemId('question', questionArg, questionArg.sessionId), kind: 'question', since: questionArg.createdAt,
|
|
3636
3655
|
title: inboxTitle(questionArg.questions[0]?.question || questionArg.questions[0]?.header || 'A question'),
|
|
3637
3656
|
where: whereArg, answer: answerArg, question: questionArg,
|
|
3638
3657
|
})),
|
|
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
3658
|
];
|
|
3645
3659
|
}
|
|
3646
3660
|
|
|
3661
|
+
/**
|
|
3662
|
+
* The items of a session's MCP forms, which are never answered automatically. Only Claude Code and Codex hand AGL
|
|
3663
|
+
* MCP forms, so a direct child (an OpenCode subagent) never holds one.
|
|
3664
|
+
*/
|
|
3665
|
+
private inboxElicitationItems(
|
|
3666
|
+
whereArg: IControllerInboxElicitationItem['where'],
|
|
3667
|
+
answerArg: IControllerInboxElicitationItem['answer'],
|
|
3668
|
+
elicitationsArg: readonly TControllerElicitation[],
|
|
3669
|
+
): TControllerInboxItem[] {
|
|
3670
|
+
return elicitationsArg.map((elicitationArg): TControllerInboxItem => ({
|
|
3671
|
+
id: this.inboxRequestItemId('elicitation', elicitationArg, elicitationArg.sessionId), kind: 'elicitation', since: elicitationArg.createdAt,
|
|
3672
|
+
title: inboxTitle(elicitationArg.message || `${elicitationArg.serverName} asks for input`),
|
|
3673
|
+
where: whereArg, answer: answerArg, elicitation: elicitationArg,
|
|
3674
|
+
}));
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3647
3677
|
/** A native session as the Inbox names it: where it runs and how the browser opens it. */
|
|
3648
3678
|
private inboxNativeWhere(harnessArg: 'claude' | 'codex', nativeIdArg: string, titleArg: string): Extract<TControllerInboxWhere, { kind: 'native' }> {
|
|
3649
3679
|
return { kind: 'native', session: { harness: harnessArg, nativeId: nativeIdArg }, harness: harnessArg,
|
|
@@ -3656,13 +3686,21 @@ export class OpenCodeController {
|
|
|
3656
3686
|
if (!harness || harness.closed) return [];
|
|
3657
3687
|
return harness.pendingAttention().flatMap((entryArg) => {
|
|
3658
3688
|
if (entryArg.projectId === undefined) {
|
|
3659
|
-
|
|
3689
|
+
const where = this.inboxNativeWhere('claude', entryArg.nativeId, entryArg.title);
|
|
3690
|
+
return [
|
|
3691
|
+
...this.inboxSessionItems(where, 'native', entryArg.attention),
|
|
3692
|
+
...this.inboxElicitationItems(where, 'native', entryArg.attention.elicitations),
|
|
3693
|
+
];
|
|
3660
3694
|
}
|
|
3661
3695
|
const sessionId = claudeRuntimeId(entryArg.nativeId);
|
|
3662
|
-
|
|
3696
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3663
3697
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'claude',
|
|
3664
3698
|
...this.inboxRow('claude', entryArg.nativeId, entryArg.title),
|
|
3665
|
-
}
|
|
3699
|
+
};
|
|
3700
|
+
return [
|
|
3701
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3702
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3703
|
+
];
|
|
3666
3704
|
});
|
|
3667
3705
|
}
|
|
3668
3706
|
|
|
@@ -3673,14 +3711,22 @@ export class OpenCodeController {
|
|
|
3673
3711
|
: this.codexClient && this.codexSupervisor?.getStatus().healthy ? [this.codexClient] : [];
|
|
3674
3712
|
const conversations = clients.flatMap((clientArg) => clientArg.pendingAttention().flatMap((entryArg) => {
|
|
3675
3713
|
const sessionId = codexRuntimeId(entryArg.threadId);
|
|
3676
|
-
|
|
3714
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3677
3715
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'codex',
|
|
3678
3716
|
...this.inboxRow('codex', entryArg.threadId, entryArg.session.title),
|
|
3679
|
-
}
|
|
3717
|
+
};
|
|
3718
|
+
return [
|
|
3719
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3720
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3721
|
+
];
|
|
3680
3722
|
}));
|
|
3681
|
-
const native = (this.fleetWorkers?.nativePendingAttention('codex') ?? []).flatMap((entryArg) =>
|
|
3682
|
-
this.
|
|
3683
|
-
|
|
3723
|
+
const native = (this.fleetWorkers?.nativePendingAttention('codex') ?? []).flatMap((entryArg) => {
|
|
3724
|
+
const where = this.inboxNativeWhere('codex', entryArg.nativeId, entryArg.title);
|
|
3725
|
+
return [
|
|
3726
|
+
...this.inboxSessionItems(where, 'native', entryArg.attention),
|
|
3727
|
+
...this.inboxElicitationItems(where, 'native', entryArg.attention.elicitations),
|
|
3728
|
+
];
|
|
3729
|
+
});
|
|
3684
3730
|
return [...conversations, ...native];
|
|
3685
3731
|
}
|
|
3686
3732
|
|
|
@@ -3838,7 +3884,7 @@ export class OpenCodeController {
|
|
|
3838
3884
|
let status: IFleetDeployStatus | undefined;
|
|
3839
3885
|
if (goes && this.deployMonitor) {
|
|
3840
3886
|
try {
|
|
3841
|
-
status = await this.deployMonitor.status();
|
|
3887
|
+
status = await this.deployMonitor.status(undefined, signalArg);
|
|
3842
3888
|
} catch (errorArg) {
|
|
3843
3889
|
signalArg.throwIfAborted();
|
|
3844
3890
|
// The go is the owner's either way; what runs where is shown once the monitor answers.
|
|
@@ -3894,6 +3940,7 @@ export class OpenCodeController {
|
|
|
3894
3940
|
unboundDrivers: (signal) => this.listUnboundDrivers(signal),
|
|
3895
3941
|
tickets: async (signal) => (await this.ticketStore.execute('list', {}, undefined, signal)).tickets,
|
|
3896
3942
|
released: () => this.deployMonitor?.reconcileSoon(),
|
|
3943
|
+
landed: () => this.deployMonitor?.reconcileSoon(),
|
|
3897
3944
|
onOperation: (operation, owner, repo) => {
|
|
3898
3945
|
this.requireFleetWorkers().releaseEvent(operation, owner, repo);
|
|
3899
3946
|
if (operation.state === 'succeeded' && operation.ticketKey && operation.result && 'ticketSync' in operation.result && operation.result.ticketSync) {
|
|
@@ -5341,7 +5388,7 @@ export class OpenCodeController {
|
|
|
5341
5388
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
5342
5389
|
if (this.claudeHarness !== harness || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
5343
5390
|
if (harness.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
5344
|
-
harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
5391
|
+
await sendingReply(() => harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
5345
5392
|
}
|
|
5346
5393
|
},
|
|
5347
5394
|
));
|
|
@@ -6156,7 +6203,7 @@ export class OpenCodeController {
|
|
|
6156
6203
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
6157
6204
|
if (this.requireCodexClient(sessionIdArg.nativeId) !== client || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
6158
6205
|
if (client.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
6159
|
-
client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
6206
|
+
await sendingReply(() => client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
6160
6207
|
}
|
|
6161
6208
|
},
|
|
6162
6209
|
));
|
|
@@ -9494,6 +9541,8 @@ export class OpenCodeController {
|
|
|
9494
9541
|
...patch,
|
|
9495
9542
|
...(standardProjectDirectories === undefined ? {} : { standardProjectDirectories }),
|
|
9496
9543
|
});
|
|
9544
|
+
// The standard directories are the roots fleet discovery walks: the deploy monitor's next run walks again.
|
|
9545
|
+
if (standardProjectDirectories !== undefined) this.deployMonitor?.workspaceChanged();
|
|
9497
9546
|
this.defaultModels = settings.defaultModels;
|
|
9498
9547
|
this.sessionIntelligenceModel = settings.sessionIntelligenceModel;
|
|
9499
9548
|
const autoAcceptEnabled = settings.autoAcceptPermissions === true;
|
|
@@ -10483,13 +10532,13 @@ export class OpenCodeController {
|
|
|
10483
10532
|
owner.localCli ? 'driver' : 'owner', owner.localCli?.osUser ?? 'Owner');
|
|
10484
10533
|
return this.submitFleetOperation(operation, input, master.fleet ?? {}, owner.resourceId, actor);
|
|
10485
10534
|
}),
|
|
10486
|
-
deploy: (method, request, signal) => run(signal, async () => {
|
|
10535
|
+
deploy: (method, request, signal) => run(signal, async (operationSignalArg) => {
|
|
10487
10536
|
if (!this.configurationAuthority || typeof request.ownerToken !== 'string') {
|
|
10488
10537
|
throw new plugins.typedrequest.TypedResponseError('Deploy status requires a local-owner capability.', { code: 'unauthorized' });
|
|
10489
10538
|
}
|
|
10490
10539
|
await this.configurationAuthority.verifyOwnerCapability({ token: request.ownerToken });
|
|
10491
10540
|
const { ownerToken: _token, ...input } = request;
|
|
10492
|
-
return this.executeDeploy(method, input);
|
|
10541
|
+
return this.executeDeploy(method, input, operationSignalArg);
|
|
10493
10542
|
}),
|
|
10494
10543
|
tickets: (methodArg, requestArg, signalArg, connectionArg) => run(signalArg, async (operationSignalArg) => {
|
|
10495
10544
|
const { ownerToken, ...request } = requestArg;
|
|
@@ -10839,6 +10888,10 @@ export class OpenCodeController {
|
|
|
10839
10888
|
this.assertStartActive();
|
|
10840
10889
|
this.runtimeConfig = runtimeConfig;
|
|
10841
10890
|
this.controllerId = authDocument.id;
|
|
10891
|
+
// The stored deploy status, and with it the undeployed set the board's AutoLabel reads, loads before anything can
|
|
10892
|
+
// read the board (AGL-1704).
|
|
10893
|
+
await this.requireDeployMonitor().load();
|
|
10894
|
+
this.assertStartActive();
|
|
10842
10895
|
// Messages still queued or steering when the controller stopped are held for the user; the
|
|
10843
10896
|
// prompts of a durable Flex limit hold are restored with that hold instead.
|
|
10844
10897
|
const armedFlexHolds = new Set((await authStore.listArmedFlexLimitHolds()).map((record) => (
|
|
@@ -14793,7 +14846,7 @@ export class OpenCodeController {
|
|
|
14793
14846
|
agl: deviceHostAgl({ version: commitinfo.version, startedAt: this.startedAt, origin: publicOriginArg, gateway: this.gatewayClient?.status() }),
|
|
14794
14847
|
device: deviceHostDevice(device),
|
|
14795
14848
|
...await readDeviceHostSections({
|
|
14796
|
-
deployStatus: () => this.requireDeployMonitor().status(),
|
|
14849
|
+
deployStatus: (operationSignalArg) => this.requireDeployMonitor().status(undefined, operationSignalArg),
|
|
14797
14850
|
capacity: proxyMonitor === undefined ? undefined : (operationSignalArg) => proxyMonitor.capacity({}, operationSignalArg),
|
|
14798
14851
|
authority: () => this.authorityState.getProjection(),
|
|
14799
14852
|
usage: (accountIdArg, loginIdArg, operationSignalArg) => this.accountsActions.usage({ accountId: accountIdArg, loginId: loginIdArg }, operationSignalArg),
|
|
@@ -17796,15 +17849,15 @@ export class OpenCodeController {
|
|
|
17796
17849
|
const pending = kind === 'permission'
|
|
17797
17850
|
? await first.parent.client.listPermissions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal)
|
|
17798
17851
|
: await first.parent.client.listQuestions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal);
|
|
17799
|
-
this.
|
|
17852
|
+
this.assertPromptPending(pending, requestArg.requestId, kind);
|
|
17800
17853
|
const current = await verifyArg(true);
|
|
17801
17854
|
const signal = AbortSignal.any([signalArg, current.parent.runtimeAuthority.signal]);
|
|
17802
17855
|
const { directory } = current.parent.project;
|
|
17803
|
-
const success = 'reply' in requestArg
|
|
17804
|
-
?
|
|
17856
|
+
const success = await sendingReply(() => 'reply' in requestArg
|
|
17857
|
+
? current.parent.client.replyPermission(directory, requestArg.requestId.nativeId, requestArg.reply, requestArg.message, signal)
|
|
17805
17858
|
: requestArg.answers === null
|
|
17806
|
-
?
|
|
17807
|
-
:
|
|
17859
|
+
? current.parent.client.rejectQuestion(directory, requestArg.requestId.nativeId, signal)
|
|
17860
|
+
: current.parent.client.replyQuestion(directory, requestArg.requestId.nativeId, requestArg.answers, signal));
|
|
17808
17861
|
await verifyArg(false);
|
|
17809
17862
|
return { success };
|
|
17810
17863
|
},
|
|
@@ -17858,7 +17911,7 @@ export class OpenCodeController {
|
|
|
17858
17911
|
if (sessionId.harnessId === 'codex') this.requireCodexClient(sessionId.nativeId).replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17859
17912
|
else this.requireClaudeHarness().replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17860
17913
|
} catch (errorArg) {
|
|
17861
|
-
throw
|
|
17914
|
+
throw replyRefusal(errorArg);
|
|
17862
17915
|
}
|
|
17863
17916
|
return { success: true };
|
|
17864
17917
|
});
|
|
@@ -17885,27 +17938,31 @@ export class OpenCodeController {
|
|
|
17885
17938
|
if (sessionId.harnessId === 'codex') {
|
|
17886
17939
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17887
17940
|
signalArg.throwIfAborted();
|
|
17888
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
17941
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
17942
|
+
await sendingReply(() => codex.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17889
17943
|
return { success: true };
|
|
17890
17944
|
});
|
|
17891
17945
|
}
|
|
17892
17946
|
if (sessionId.harnessId === 'claude') {
|
|
17893
17947
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17894
17948
|
signalArg.throwIfAborted();
|
|
17895
|
-
this.requireClaudeHarness()
|
|
17949
|
+
const harness = this.requireClaudeHarness();
|
|
17950
|
+
await sendingReply(() => harness.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17896
17951
|
return { success: true };
|
|
17897
17952
|
});
|
|
17898
17953
|
}
|
|
17899
17954
|
if (sessionId.harnessId === 'flex') {
|
|
17900
17955
|
signalArg.throwIfAborted();
|
|
17901
17956
|
const flexSupervisor = this.requireFlexSupervisor();
|
|
17957
|
+
// The pending permission names the run whose authority answers it; one answered after this read is refused at
|
|
17958
|
+
// the send (`respondToFlexPermission`).
|
|
17902
17959
|
const pendingPermissions = await flexSupervisor.request('permission.list', {
|
|
17903
17960
|
scopeId: projectId,
|
|
17904
17961
|
}, signalArg);
|
|
17905
17962
|
const permission = pendingPermissions.permissions.find(
|
|
17906
17963
|
(candidate) => candidate.permissionId === requestId.nativeId,
|
|
17907
17964
|
);
|
|
17908
|
-
if (!permission) throw
|
|
17965
|
+
if (!permission) throw typedReplyRefusal(promptNoLongerPending('permission'));
|
|
17909
17966
|
const authority = this.flexPermissionAuthority(projectId, permission);
|
|
17910
17967
|
if (
|
|
17911
17968
|
!authority
|
|
@@ -17932,15 +17989,15 @@ export class OpenCodeController {
|
|
|
17932
17989
|
sessionId.nativeId,
|
|
17933
17990
|
signalArg,
|
|
17934
17991
|
);
|
|
17935
|
-
this.
|
|
17992
|
+
this.assertPromptPending(pendingPermissions, requestId, 'permission');
|
|
17936
17993
|
return {
|
|
17937
|
-
success: await this.requireOpenCodeClient().replyPermission(
|
|
17994
|
+
success: await sendingReply(() => this.requireOpenCodeClient().replyPermission(
|
|
17938
17995
|
project.directory,
|
|
17939
17996
|
requestId.nativeId,
|
|
17940
17997
|
reply,
|
|
17941
17998
|
message,
|
|
17942
17999
|
signalArg,
|
|
17943
|
-
),
|
|
18000
|
+
)),
|
|
17944
18001
|
};
|
|
17945
18002
|
},
|
|
17946
18003
|
);
|
|
@@ -17965,14 +18022,16 @@ export class OpenCodeController {
|
|
|
17965
18022
|
if (sessionId.harnessId === 'codex') {
|
|
17966
18023
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17967
18024
|
signalArg.throwIfAborted();
|
|
17968
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
18025
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
18026
|
+
await sendingReply(() => codex.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
17969
18027
|
return { success: true };
|
|
17970
18028
|
});
|
|
17971
18029
|
}
|
|
17972
18030
|
if (sessionId.harnessId === 'claude') {
|
|
17973
18031
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17974
18032
|
signalArg.throwIfAborted();
|
|
17975
|
-
this.requireClaudeHarness()
|
|
18033
|
+
const harness = this.requireClaudeHarness();
|
|
18034
|
+
await sendingReply(() => harness.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
17976
18035
|
return { success: true };
|
|
17977
18036
|
});
|
|
17978
18037
|
}
|
|
@@ -17982,20 +18041,20 @@ export class OpenCodeController {
|
|
|
17982
18041
|
sessionId.nativeId,
|
|
17983
18042
|
signalArg,
|
|
17984
18043
|
);
|
|
17985
|
-
this.
|
|
18044
|
+
this.assertPromptPending(pendingQuestions, requestId, 'question');
|
|
17986
18045
|
return {
|
|
17987
|
-
success: answers === null
|
|
17988
|
-
?
|
|
18046
|
+
success: await sendingReply(() => answers === null
|
|
18047
|
+
? openCodeClient.rejectQuestion(
|
|
17989
18048
|
project.directory,
|
|
17990
18049
|
requestId.nativeId,
|
|
17991
18050
|
signalArg,
|
|
17992
18051
|
)
|
|
17993
|
-
:
|
|
18052
|
+
: openCodeClient.replyQuestion(
|
|
17994
18053
|
project.directory,
|
|
17995
18054
|
requestId.nativeId,
|
|
17996
18055
|
answers,
|
|
17997
18056
|
signalArg,
|
|
17998
|
-
),
|
|
18057
|
+
)),
|
|
17999
18058
|
};
|
|
18000
18059
|
},
|
|
18001
18060
|
);
|
|
@@ -18514,11 +18573,15 @@ export class OpenCodeController {
|
|
|
18514
18573
|
this.boardPump.start();
|
|
18515
18574
|
}
|
|
18516
18575
|
|
|
18517
|
-
/**
|
|
18576
|
+
/**
|
|
18577
|
+
* AGL-911: the loop that observes what each deploy target runs. It stores the deploy status it computes (AGL-1704),
|
|
18578
|
+
* which status and release state answer from; history and where a ticket runs are read when asked.
|
|
18579
|
+
*/
|
|
18518
18580
|
private requireDeployMonitor(): DeployMonitor {
|
|
18519
18581
|
// A stopping controller starts no monitor that its stop would never close.
|
|
18520
18582
|
if (!this.deployMonitor && this.stopRequested) throw new DeployError('deploy_unavailable', 'The controller is stopping.');
|
|
18521
18583
|
this.deployMonitor ??= new DeployMonitor({
|
|
18584
|
+
controllerId: () => this.requireControllerId(),
|
|
18522
18585
|
scope: async () => (this.configurationAuthority ? await this.readFleetScope() : undefined),
|
|
18523
18586
|
discover: async () => this.discoverFleetScope({}),
|
|
18524
18587
|
tickets: async (signalArg) => (await this.ticketStore.execute('list', {}, undefined, signalArg)).tickets,
|
|
@@ -18586,18 +18649,22 @@ export class OpenCodeController {
|
|
|
18586
18649
|
}
|
|
18587
18650
|
|
|
18588
18651
|
/** 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> {
|
|
18652
|
+
private async executeDeploy(methodArg: string, requestArg: unknown, signalArg?: AbortSignal): Promise<unknown> {
|
|
18590
18653
|
const operation = fleetDeployOperation(methodArg);
|
|
18591
18654
|
const monitor = this.requireDeployMonitor();
|
|
18592
18655
|
try {
|
|
18593
|
-
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId);
|
|
18656
|
+
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId, signalArg);
|
|
18594
18657
|
if (operation === 'history') {
|
|
18595
18658
|
const request = assertFleetDeployRequest('history', requestArg);
|
|
18596
18659
|
return await monitor.history(request.targetId, request.limit);
|
|
18597
18660
|
}
|
|
18598
|
-
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId);
|
|
18661
|
+
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId, signalArg);
|
|
18599
18662
|
if (operation === 'ticket') return await monitor.ticketPlacement(assertFleetDeployRequest('ticket', requestArg).ticketKey);
|
|
18600
|
-
|
|
18663
|
+
if (operation === 'refresh') {
|
|
18664
|
+
assertFleetDeployRequest('refresh', requestArg);
|
|
18665
|
+
return await monitor.refresh(signalArg);
|
|
18666
|
+
}
|
|
18667
|
+
return await monitor.releaseStatus(assertFleetDeployRequest('release', requestArg).repo, signalArg);
|
|
18601
18668
|
} catch (errorArg) {
|
|
18602
18669
|
if (errorArg instanceof DeployError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
18603
18670
|
throw errorArg;
|
|
@@ -18820,14 +18887,14 @@ export class OpenCodeController {
|
|
|
18820
18887
|
);
|
|
18821
18888
|
}
|
|
18822
18889
|
|
|
18823
|
-
/** The Deployments view: status, history, a probe now
|
|
18890
|
+
/** The Deployments view: status, history, a probe now, release state and a full check now (AGL-911, AGL-914, AGL-1704). */
|
|
18824
18891
|
private registerDeployHandlers(protectedRouterArg: ControllerProtectedRouter): void {
|
|
18825
18892
|
for (const operation of fleetDeployOperations) {
|
|
18826
18893
|
protectedRouterArg.addHandler<TControllerDeployRequest<TFleetDeployOperation>>(`controller.deploy.${operation}`,
|
|
18827
18894
|
async (requestArg, toolsArg) => {
|
|
18828
18895
|
validateRequest(() => assertFleetDeployRequest(operation, requestArg));
|
|
18829
18896
|
const peer = peerFromLocalData(toolsArg?.localData);
|
|
18830
|
-
return this.runOperation(peer, async () => await this.executeDeploy(`controller.deploy.${operation}`, requestArg) as never,
|
|
18897
|
+
return this.runOperation(peer, async (signalArg) => await this.executeDeploy(`controller.deploy.${operation}`, requestArg, signalArg) as never,
|
|
18831
18898
|
toolsArg?.abortSignal);
|
|
18832
18899
|
});
|
|
18833
18900
|
}
|
|
@@ -19234,9 +19301,14 @@ export class OpenCodeController {
|
|
|
19234
19301
|
): Promise<IControllerAttention> {
|
|
19235
19302
|
const { session, native } = resolvedArg;
|
|
19236
19303
|
if (session.harness === 'codex') return await this.requireFleetWorkers().nativeAttention('codex', native);
|
|
19304
|
+
return this.claudeAttention(native.nativeId);
|
|
19305
|
+
}
|
|
19306
|
+
|
|
19307
|
+
/** The requests AGL's own Claude Code holds for a conversation; none once it no longer runs the conversation. */
|
|
19308
|
+
private claudeAttention(nativeIdArg: string): IControllerAttention {
|
|
19237
19309
|
const harness = this.claudeHarness;
|
|
19238
|
-
return harness && !harness.closed && harness.isRegistered(
|
|
19239
|
-
? harness.attention(
|
|
19310
|
+
return harness && !harness.closed && harness.isRegistered(nativeIdArg)
|
|
19311
|
+
? harness.attention(nativeIdArg)
|
|
19240
19312
|
: { permissions: [], questions: [], elicitations: [] };
|
|
19241
19313
|
}
|
|
19242
19314
|
|
|
@@ -19250,7 +19322,10 @@ export class OpenCodeController {
|
|
|
19250
19322
|
const attention = await this.nativeSessionAttention(resolvedArg);
|
|
19251
19323
|
const pending = kindArg === 'permission' ? attention.permissions : kindArg === 'question' ? attention.questions : attention.elicitations;
|
|
19252
19324
|
if (!pending.some((request) => request.id.nativeId === requestIdArg)) {
|
|
19253
|
-
|
|
19325
|
+
// An elicitation keeps the refusal its harnesses state for it (`ControllerElicitationReplyError`'s `not_found`).
|
|
19326
|
+
throw kindArg === 'elicitation'
|
|
19327
|
+
? new plugins.typedrequest.TypedResponseError('The MCP request is no longer pending.', { code: 'not_found' })
|
|
19328
|
+
: typedReplyRefusal(promptNoLongerPending(kindArg));
|
|
19254
19329
|
}
|
|
19255
19330
|
try {
|
|
19256
19331
|
if (session.harness === 'codex') {
|
|
@@ -19262,7 +19337,7 @@ export class OpenCodeController {
|
|
|
19262
19337
|
else if ('elicitation' in replyArg) harness.replyElicitation(native.nativeId, requestIdArg, replyArg.elicitation);
|
|
19263
19338
|
else harness.replyQuestion(native.nativeId, requestIdArg, replyArg.answers);
|
|
19264
19339
|
} catch (errorArg) {
|
|
19265
|
-
throw
|
|
19340
|
+
throw replyRefusal(errorArg);
|
|
19266
19341
|
}
|
|
19267
19342
|
}
|
|
19268
19343
|
|
|
@@ -19810,7 +19885,7 @@ export class OpenCodeController {
|
|
|
19810
19885
|
} else if (route.kind === 'directreport') {
|
|
19811
19886
|
result = await this.executeDriverDirectReport(route.operation, input, actor, signalArg);
|
|
19812
19887
|
} else if (route.kind === 'deploy') {
|
|
19813
|
-
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input);
|
|
19888
|
+
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input, signalArg);
|
|
19814
19889
|
} else {
|
|
19815
19890
|
const { owner, configuration } = await this.readFleetScope();
|
|
19816
19891
|
if (route.kind === 'worker') {
|
|
@@ -20438,6 +20513,8 @@ export class OpenCodeController {
|
|
|
20438
20513
|
resolvedDirectory.directory,
|
|
20439
20514
|
{ ancestry: resolvedDirectory.ancestry },
|
|
20440
20515
|
);
|
|
20516
|
+
// A project is a root fleet discovery walks: the deploy monitor's next run walks again.
|
|
20517
|
+
if (created) this.deployMonitor?.workspaceChanged();
|
|
20441
20518
|
let reconciliation: IProjectReconciliationResult;
|
|
20442
20519
|
try {
|
|
20443
20520
|
reconciliation = await this.reconcileProjectStateInMutation(
|
|
@@ -20896,6 +20973,8 @@ export class OpenCodeController {
|
|
|
20896
20973
|
{ code: 'concurrent_change' },
|
|
20897
20974
|
);
|
|
20898
20975
|
}
|
|
20976
|
+
// A project being removed is no root fleet discovery walks any more.
|
|
20977
|
+
this.deployMonitor?.workspaceChanged();
|
|
20899
20978
|
project = pending;
|
|
20900
20979
|
}
|
|
20901
20980
|
if (
|
|
@@ -22823,7 +22902,12 @@ export class OpenCodeController {
|
|
|
22823
22902
|
return [...archivedByKey.values()].map((sessionId) => ({ ...sessionId }));
|
|
22824
22903
|
}
|
|
22825
22904
|
|
|
22826
|
-
|
|
22905
|
+
/**
|
|
22906
|
+
* Refuses an answer to a permission or question the session does not hold (`promptNoLongerPending`), read from
|
|
22907
|
+
* OpenCode's pending requests before anything is sent; OpenCode refuses one answered in between itself (its client
|
|
22908
|
+
* throws `promptNoLongerPending`).
|
|
22909
|
+
*/
|
|
22910
|
+
private assertPromptPending(
|
|
22827
22911
|
pendingRequestsArg: ReadonlyArray<{ id: IControllerRuntimeId }>,
|
|
22828
22912
|
requestIdArg: IControllerRuntimeId,
|
|
22829
22913
|
kindArg: 'permission' | 'question',
|
|
@@ -22831,10 +22915,7 @@ export class OpenCodeController {
|
|
|
22831
22915
|
if (pendingRequestsArg.some((request) => (
|
|
22832
22916
|
controllerRuntimeIdKey(request.id) === controllerRuntimeIdKey(requestIdArg)
|
|
22833
22917
|
))) return;
|
|
22834
|
-
throw
|
|
22835
|
-
`The ${kindArg} request does not belong to the selected conversation.`,
|
|
22836
|
-
{ code: 'invalid_request' },
|
|
22837
|
-
);
|
|
22918
|
+
throw typedReplyRefusal(promptNoLongerPending(kindArg));
|
|
22838
22919
|
}
|
|
22839
22920
|
|
|
22840
22921
|
private toFlexMessageBundle(projectedArg: IFlexProjectedMessage): IControllerMessageBundle {
|
|
@@ -27548,7 +27629,15 @@ export class OpenCodeController {
|
|
|
27548
27629
|
permissionId: permissionArg.permissionId,
|
|
27549
27630
|
decision: decisionArg,
|
|
27550
27631
|
}, signalArg);
|
|
27551
|
-
|
|
27632
|
+
try {
|
|
27633
|
+
await response;
|
|
27634
|
+
} catch (errorArg) {
|
|
27635
|
+
// A permission answered or withdrawn since it was read: the Flex child's own check, or FlexHarness's
|
|
27636
|
+
// `FLEX_NOT_FOUND` (`FlexHarnessNotFoundError`), refuses it `NOT_FOUND` before anything is applied.
|
|
27637
|
+
throw errorArg instanceof FlexServiceError && errorArg.code === 'NOT_FOUND'
|
|
27638
|
+
? typedReplyRefusal(promptNoLongerPending('permission'))
|
|
27639
|
+
: errorArg;
|
|
27640
|
+
}
|
|
27552
27641
|
if (ticket) this.activateFlexDelegationTicket(ticket);
|
|
27553
27642
|
} catch (errorArg) {
|
|
27554
27643
|
if (ticket) this.revokeFlexDelegationTicket(ticket);
|
|
@@ -34320,7 +34409,7 @@ export class OpenCodeController {
|
|
|
34320
34409
|
permission.sessionId.nativeId,
|
|
34321
34410
|
this.operationAbortController.signal,
|
|
34322
34411
|
);
|
|
34323
|
-
this.
|
|
34412
|
+
this.assertPromptPending(pending, permission.id, 'permission');
|
|
34324
34413
|
const finalAuthority = await this.resolveOpenCodeFamilyAuthority(
|
|
34325
34414
|
projectId,
|
|
34326
34415
|
permission.sessionId as IControllerRuntimeId & { harnessId: 'opencode' },
|
|
@@ -34352,13 +34441,13 @@ export class OpenCodeController {
|
|
|
34352
34441
|
try {
|
|
34353
34442
|
await this.runAudited(
|
|
34354
34443
|
{ type: 'permission.reply', requestId: permission.id, sessionId: permission.sessionId },
|
|
34355
|
-
async () => openCodeClient.replyPermission(
|
|
34444
|
+
async () => sendingReply(() => openCodeClient.replyPermission(
|
|
34356
34445
|
currentAuthority.parent.project.directory,
|
|
34357
34446
|
permission.id.nativeId,
|
|
34358
34447
|
'once',
|
|
34359
34448
|
undefined,
|
|
34360
34449
|
this.operationAbortController.signal,
|
|
34361
|
-
),
|
|
34450
|
+
)),
|
|
34362
34451
|
);
|
|
34363
34452
|
} catch (errorArg) {
|
|
34364
34453
|
this.autoRepliedPermissionIds.delete(permissionKey);
|
package/ts/classes.mcpclient.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { readTicketRevisionConflict, ticketErrorMessages, type TTicketClientErro
|
|
|
10
10
|
import { assertMcpTicketRequest, assertTicketResponse } from './functions.ticketvalidation.js';
|
|
11
11
|
import { assertSessionFeedWireRequest, assertSessionFeedWireResponse } from './functions.sessionfeedvalidation.js';
|
|
12
12
|
import { assertFleetDeployResponse, assertFleetDeployWireRequest } from './fleet/functions.deployvalidation.js';
|
|
13
|
-
import type
|
|
13
|
+
import { fleetDeployRefreshClientMarginMs, fleetDeployRefreshWaitMs, type IFleetDeployOperations, type TFleetDeployOperation } from '../ts_interfaces/deployments.js';
|
|
14
14
|
import type { IReq_ControllerMcpSessionFeedAcknowledge, IReq_ControllerMcpSessionFeedList } from '../ts_interfaces/sessionfeed.js';
|
|
15
15
|
import { isProxyCapacityAnswer, type IProxyCapacityAnswer, type IProxyCapacityRequest } from '../ts_interfaces/proxycapacity.js';
|
|
16
16
|
import {
|
|
@@ -83,6 +83,8 @@ import {
|
|
|
83
83
|
} from './functions.jobvalidation.js';
|
|
84
84
|
|
|
85
85
|
const defaultRequestTimeoutMs = 30_000;
|
|
86
|
+
/** A deploy `refresh` waits for its check up to `fleetDeployRefreshWaitMs` on the controller before it answers. */
|
|
87
|
+
const deployRefreshRequestTimeoutMs = fleetDeployRefreshWaitMs + fleetDeployRefreshClientMarginMs;
|
|
86
88
|
const maximumSafeServerErrorBytes = 1024;
|
|
87
89
|
const maximumScratchpadCharacters = 32_768;
|
|
88
90
|
const maximumScratchpadBytes = 128 * 1024;
|
|
@@ -778,13 +780,15 @@ export class ControllerMcpClient {
|
|
|
778
780
|
const wireRequest = assertSessionFeedWireRequest('agl.mcp.sessionfeed.acknowledge', request);
|
|
779
781
|
return this.dispatchAfterHandshake('agl.mcp.sessionfeed.acknowledge', wireRequest as IReq_ControllerMcpSessionFeedAcknowledge['request'], signal, true);
|
|
780
782
|
}
|
|
781
|
-
/** Deploy status, history, a probe now
|
|
783
|
+
/** Deploy status, history, a probe now, release state or a full check now, as the local owner asks (`agl deploy`, `agl release status`, MCP). */
|
|
782
784
|
public async deploy<TOperation extends TFleetDeployOperation>(operation: TOperation,
|
|
783
785
|
request: IFleetDeployOperations[TOperation]['request'] & { ownerToken: string }, signal?: AbortSignal,
|
|
784
786
|
): Promise<IFleetDeployOperations[TOperation]['response']> {
|
|
785
787
|
const method = `agl.mcp.deploy.${operation}` as const;
|
|
786
788
|
const wireRequest = assertFleetDeployWireRequest(method, request);
|
|
787
|
-
return this.dispatchAfterHandshake(method, wireRequest as never, signal, operation === 'probe'
|
|
789
|
+
return this.dispatchAfterHandshake(method, wireRequest as never, signal, operation === 'probe' || operation === 'refresh',
|
|
790
|
+
operation === 'refresh' ? Math.max(this.requestTimeoutMs, deployRefreshRequestTimeoutMs) : undefined,
|
|
791
|
+
) as Promise<IFleetDeployOperations[TOperation]['response']>;
|
|
788
792
|
}
|
|
789
793
|
public async fleetStatus(id: string, ownerToken: string, signal?: AbortSignal, ticketKey?: string): Promise<IFleetOperation> {
|
|
790
794
|
return this.dispatchAfterHandshake('agl.mcp.fleet.status', { id, ownerToken, ...(ticketKey ? { ticketKey } : {}) }, signal, false);
|
|
@@ -818,10 +822,12 @@ export class ControllerMcpClient {
|
|
|
818
822
|
requestArg: TRequestForMethod<TMethod>,
|
|
819
823
|
signalArg: AbortSignal | undefined,
|
|
820
824
|
mutatingArg: boolean,
|
|
825
|
+
/** This request's own deadline, for one the controller answers only after a bounded wait; the client's otherwise. */
|
|
826
|
+
timeoutMsArg?: number,
|
|
821
827
|
): Promise<TResponseForMethod<TMethod>> {
|
|
822
828
|
const descriptor = await this.handshake(signalArg);
|
|
823
829
|
try {
|
|
824
|
-
return await this.dispatch(descriptor, methodArg, requestArg, signalArg, mutatingArg);
|
|
830
|
+
return await this.dispatch(descriptor, methodArg, requestArg, signalArg, mutatingArg, timeoutMsArg);
|
|
825
831
|
} catch (errorArg) {
|
|
826
832
|
if (mutatingArg && errorArg instanceof ControllerMcpClientError
|
|
827
833
|
&& (errorArg.code === 'PROTOCOL_MISMATCH' || errorArg.code === 'RESPONSE_LIMIT')) {
|
|
@@ -906,6 +912,7 @@ export class ControllerMcpClient {
|
|
|
906
912
|
requestArg: TRequestForMethod<TMethod>,
|
|
907
913
|
signalArg: AbortSignal | undefined,
|
|
908
914
|
outcomeMayBeUnknownArg: boolean,
|
|
915
|
+
timeoutMsArg?: number,
|
|
909
916
|
): Promise<TResponseForMethod<TMethod>> {
|
|
910
917
|
const requestInstanceId = plugins.crypto.randomBytes(16).toString('base64url');
|
|
911
918
|
const correlationId = plugins.crypto.randomBytes(16).toString('base64url');
|
|
@@ -931,6 +938,7 @@ export class ControllerMcpClient {
|
|
|
931
938
|
body,
|
|
932
939
|
signalArg,
|
|
933
940
|
() => { dispatchFinished = true; },
|
|
941
|
+
timeoutMsArg,
|
|
934
942
|
);
|
|
935
943
|
} catch (errorArg) {
|
|
936
944
|
if (errorArg instanceof ControllerMcpClientError) throw errorArg;
|
|
@@ -1044,8 +1052,9 @@ export class ControllerMcpClient {
|
|
|
1044
1052
|
bodyArg: Buffer,
|
|
1045
1053
|
signalArg: AbortSignal | undefined,
|
|
1046
1054
|
onDispatchFinishedArg: () => void,
|
|
1055
|
+
timeoutMsArg = this.requestTimeoutMs,
|
|
1047
1056
|
): Promise<Buffer> {
|
|
1048
|
-
const timeoutSignal = AbortSignal.timeout(
|
|
1057
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMsArg);
|
|
1049
1058
|
const signal = signalArg === undefined
|
|
1050
1059
|
? timeoutSignal
|
|
1051
1060
|
: AbortSignal.any([signalArg, timeoutSignal]);
|