agl 43.3.1 → 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 +22 -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 +33 -9
- package/dist_ts/classes.controller.js +173 -113
- package/dist_ts/classes.flexservice.d.ts +12 -1
- package/dist_ts/classes.flexservice.js +44 -13
- package/dist_ts/classes.flexstore.d.ts +20 -0
- package/dist_ts/classes.flexstore.js +30 -1
- 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.flexipc.d.ts +17 -9
- package/dist_ts/interfaces.flexipc.js +19 -20
- 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 +5 -5
- package/readme.md +30 -12
- 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 +188 -128
- package/ts/classes.flexservice.ts +57 -14
- package/ts/classes.flexstore.ts +40 -0
- 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.flexipc.ts +43 -27
- 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,
|
|
@@ -1100,7 +1102,6 @@ const maxOpenCodeOperationRecoveryFailures = 3;
|
|
|
1100
1102
|
const maxOpenCodeOperationRecoveryPages = 8;
|
|
1101
1103
|
const openCodeFailClosedRetryMs = 1_000;
|
|
1102
1104
|
const openCodeSessionErrorCleanupRetryMs = 1_000;
|
|
1103
|
-
const maxFlexSessionIdentitySnapshotEntries = 2_048;
|
|
1104
1105
|
const sessionIntelligenceOrphanGraceMs = 30 * 60 * 1000;
|
|
1105
1106
|
const sessionIntelligenceCleanupIntervalMs = 15 * 60 * 1000;
|
|
1106
1107
|
const sessionIntelligenceCleanupTimeoutMs = 15_000;
|
|
@@ -2511,15 +2512,30 @@ const canonicalDirectory = async (pathArg: string): Promise<string | undefined>
|
|
|
2511
2512
|
try { return await plugins.fs.promises.realpath(pathArg); } catch { return undefined; }
|
|
2512
2513
|
};
|
|
2513
2514
|
/**
|
|
2514
|
-
* A
|
|
2515
|
-
*
|
|
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.
|
|
2516
2518
|
*/
|
|
2517
|
-
const
|
|
2518
|
-
errorArg
|
|
2519
|
-
|
|
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)
|
|
2520
2527
|
: errorArg
|
|
2521
2528
|
);
|
|
2522
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
|
+
|
|
2523
2539
|
/** The ticket changes the owner makes from the browser's board or a paired device, each with its audit type. */
|
|
2524
2540
|
type TTicketChangeOperation = 'comment' | 'ask' | 'move';
|
|
2525
2541
|
const ticketChangeAuditTypes = {
|
|
@@ -3614,37 +3630,50 @@ export class OpenCodeController {
|
|
|
3614
3630
|
return { rowId, name: this.sessionFeed?.publishedRow(rowId)?.name ?? (fallbackNameArg.trim() || 'Untitled session') };
|
|
3615
3631
|
}
|
|
3616
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
|
+
|
|
3617
3638
|
/**
|
|
3618
|
-
* The items of a session's
|
|
3619
|
-
* 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.
|
|
3620
3641
|
*/
|
|
3621
3642
|
private inboxSessionItems(
|
|
3622
3643
|
whereArg: Extract<TControllerInboxWhere, { kind: 'conversation' | 'child' | 'native' | 'driver' }>,
|
|
3623
3644
|
answerArg: TControllerInboxAnswer,
|
|
3624
|
-
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[]
|
|
3645
|
+
attentionArg: { permissions: readonly IControllerPermission[]; questions: readonly IControllerQuestion[] },
|
|
3625
3646
|
autoAcceptedArg = false,
|
|
3626
3647
|
): TControllerInboxItem[] {
|
|
3627
|
-
const id = (kindArg: string, requestArg: { id: IControllerRuntimeId }, sessionArg: IControllerRuntimeId) => (
|
|
3628
|
-
`${kindArg}:${sessionArg.harnessId}:${sessionArg.nativeId}:${requestArg.id.nativeId}`
|
|
3629
|
-
);
|
|
3630
3648
|
return [
|
|
3631
3649
|
...(autoAcceptedArg ? [] : attentionArg.permissions).map((permissionArg): TControllerInboxItem => ({
|
|
3632
|
-
id:
|
|
3650
|
+
id: this.inboxRequestItemId('permission', permissionArg, permissionArg.sessionId), kind: 'permission', since: permissionArg.createdAt,
|
|
3633
3651
|
title: inboxTitle(permissionArg.title || permissionArg.type), where: whereArg, answer: answerArg, permission: permissionArg,
|
|
3634
3652
|
})),
|
|
3635
3653
|
...attentionArg.questions.map((questionArg): TControllerInboxItem => ({
|
|
3636
|
-
id:
|
|
3654
|
+
id: this.inboxRequestItemId('question', questionArg, questionArg.sessionId), kind: 'question', since: questionArg.createdAt,
|
|
3637
3655
|
title: inboxTitle(questionArg.questions[0]?.question || questionArg.questions[0]?.header || 'A question'),
|
|
3638
3656
|
where: whereArg, answer: answerArg, question: questionArg,
|
|
3639
3657
|
})),
|
|
3640
|
-
...(attentionArg.elicitations ?? []).map((elicitationArg): TControllerInboxItem => ({
|
|
3641
|
-
id: id('elicitation', elicitationArg, elicitationArg.sessionId), kind: 'elicitation', since: elicitationArg.createdAt,
|
|
3642
|
-
title: inboxTitle(elicitationArg.message || `${elicitationArg.serverName} asks for input`),
|
|
3643
|
-
where: whereArg, answer: answerArg, elicitation: elicitationArg,
|
|
3644
|
-
})),
|
|
3645
3658
|
];
|
|
3646
3659
|
}
|
|
3647
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
|
+
|
|
3648
3677
|
/** A native session as the Inbox names it: where it runs and how the browser opens it. */
|
|
3649
3678
|
private inboxNativeWhere(harnessArg: 'claude' | 'codex', nativeIdArg: string, titleArg: string): Extract<TControllerInboxWhere, { kind: 'native' }> {
|
|
3650
3679
|
return { kind: 'native', session: { harness: harnessArg, nativeId: nativeIdArg }, harness: harnessArg,
|
|
@@ -3657,13 +3686,21 @@ export class OpenCodeController {
|
|
|
3657
3686
|
if (!harness || harness.closed) return [];
|
|
3658
3687
|
return harness.pendingAttention().flatMap((entryArg) => {
|
|
3659
3688
|
if (entryArg.projectId === undefined) {
|
|
3660
|
-
|
|
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
|
+
];
|
|
3661
3694
|
}
|
|
3662
3695
|
const sessionId = claudeRuntimeId(entryArg.nativeId);
|
|
3663
|
-
|
|
3696
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3664
3697
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'claude',
|
|
3665
3698
|
...this.inboxRow('claude', entryArg.nativeId, entryArg.title),
|
|
3666
|
-
}
|
|
3699
|
+
};
|
|
3700
|
+
return [
|
|
3701
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3702
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3703
|
+
];
|
|
3667
3704
|
});
|
|
3668
3705
|
}
|
|
3669
3706
|
|
|
@@ -3674,14 +3711,22 @@ export class OpenCodeController {
|
|
|
3674
3711
|
: this.codexClient && this.codexSupervisor?.getStatus().healthy ? [this.codexClient] : [];
|
|
3675
3712
|
const conversations = clients.flatMap((clientArg) => clientArg.pendingAttention().flatMap((entryArg) => {
|
|
3676
3713
|
const sessionId = codexRuntimeId(entryArg.threadId);
|
|
3677
|
-
|
|
3714
|
+
const where: Extract<TControllerInboxWhere, { kind: 'conversation' }> = {
|
|
3678
3715
|
kind: 'conversation', projectId: entryArg.projectId, sessionId, harness: 'codex',
|
|
3679
3716
|
...this.inboxRow('codex', entryArg.threadId, entryArg.session.title),
|
|
3680
|
-
}
|
|
3717
|
+
};
|
|
3718
|
+
return [
|
|
3719
|
+
...this.inboxSessionItems(where, 'conversation', entryArg.attention, this.isProjectAutoAcceptedSession(entryArg.projectId, sessionId)),
|
|
3720
|
+
...this.inboxElicitationItems(where, 'conversation', entryArg.attention.elicitations),
|
|
3721
|
+
];
|
|
3681
3722
|
}));
|
|
3682
|
-
const native = (this.fleetWorkers?.nativePendingAttention('codex') ?? []).flatMap((entryArg) =>
|
|
3683
|
-
this.
|
|
3684
|
-
|
|
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
|
+
});
|
|
3685
3730
|
return [...conversations, ...native];
|
|
3686
3731
|
}
|
|
3687
3732
|
|
|
@@ -3839,7 +3884,7 @@ export class OpenCodeController {
|
|
|
3839
3884
|
let status: IFleetDeployStatus | undefined;
|
|
3840
3885
|
if (goes && this.deployMonitor) {
|
|
3841
3886
|
try {
|
|
3842
|
-
status = await this.deployMonitor.status();
|
|
3887
|
+
status = await this.deployMonitor.status(undefined, signalArg);
|
|
3843
3888
|
} catch (errorArg) {
|
|
3844
3889
|
signalArg.throwIfAborted();
|
|
3845
3890
|
// The go is the owner's either way; what runs where is shown once the monitor answers.
|
|
@@ -3895,6 +3940,7 @@ export class OpenCodeController {
|
|
|
3895
3940
|
unboundDrivers: (signal) => this.listUnboundDrivers(signal),
|
|
3896
3941
|
tickets: async (signal) => (await this.ticketStore.execute('list', {}, undefined, signal)).tickets,
|
|
3897
3942
|
released: () => this.deployMonitor?.reconcileSoon(),
|
|
3943
|
+
landed: () => this.deployMonitor?.reconcileSoon(),
|
|
3898
3944
|
onOperation: (operation, owner, repo) => {
|
|
3899
3945
|
this.requireFleetWorkers().releaseEvent(operation, owner, repo);
|
|
3900
3946
|
if (operation.state === 'succeeded' && operation.ticketKey && operation.result && 'ticketSync' in operation.result && operation.result.ticketSync) {
|
|
@@ -5342,7 +5388,7 @@ export class OpenCodeController {
|
|
|
5342
5388
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
5343
5389
|
if (this.claudeHarness !== harness || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
5344
5390
|
if (harness.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
5345
|
-
harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
5391
|
+
await sendingReply(() => harness.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
5346
5392
|
}
|
|
5347
5393
|
},
|
|
5348
5394
|
));
|
|
@@ -6157,7 +6203,7 @@ export class OpenCodeController {
|
|
|
6157
6203
|
this.assertSessionMutationAdmission(projectIdArg, sessionIdArg);
|
|
6158
6204
|
if (this.requireCodexClient(sessionIdArg.nativeId) !== client || !this.isProjectAutoAcceptedSession(projectIdArg, sessionIdArg)) return;
|
|
6159
6205
|
if (client.attention(sessionIdArg.nativeId).permissions.some((entry) => entry.id.nativeId === permission.id.nativeId)) {
|
|
6160
|
-
client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once');
|
|
6206
|
+
await sendingReply(() => client.replyPermission(sessionIdArg.nativeId, permission.id.nativeId, 'once'));
|
|
6161
6207
|
}
|
|
6162
6208
|
},
|
|
6163
6209
|
));
|
|
@@ -9495,6 +9541,8 @@ export class OpenCodeController {
|
|
|
9495
9541
|
...patch,
|
|
9496
9542
|
...(standardProjectDirectories === undefined ? {} : { standardProjectDirectories }),
|
|
9497
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();
|
|
9498
9546
|
this.defaultModels = settings.defaultModels;
|
|
9499
9547
|
this.sessionIntelligenceModel = settings.sessionIntelligenceModel;
|
|
9500
9548
|
const autoAcceptEnabled = settings.autoAcceptPermissions === true;
|
|
@@ -10484,13 +10532,13 @@ export class OpenCodeController {
|
|
|
10484
10532
|
owner.localCli ? 'driver' : 'owner', owner.localCli?.osUser ?? 'Owner');
|
|
10485
10533
|
return this.submitFleetOperation(operation, input, master.fleet ?? {}, owner.resourceId, actor);
|
|
10486
10534
|
}),
|
|
10487
|
-
deploy: (method, request, signal) => run(signal, async () => {
|
|
10535
|
+
deploy: (method, request, signal) => run(signal, async (operationSignalArg) => {
|
|
10488
10536
|
if (!this.configurationAuthority || typeof request.ownerToken !== 'string') {
|
|
10489
10537
|
throw new plugins.typedrequest.TypedResponseError('Deploy status requires a local-owner capability.', { code: 'unauthorized' });
|
|
10490
10538
|
}
|
|
10491
10539
|
await this.configurationAuthority.verifyOwnerCapability({ token: request.ownerToken });
|
|
10492
10540
|
const { ownerToken: _token, ...input } = request;
|
|
10493
|
-
return this.executeDeploy(method, input);
|
|
10541
|
+
return this.executeDeploy(method, input, operationSignalArg);
|
|
10494
10542
|
}),
|
|
10495
10543
|
tickets: (methodArg, requestArg, signalArg, connectionArg) => run(signalArg, async (operationSignalArg) => {
|
|
10496
10544
|
const { ownerToken, ...request } = requestArg;
|
|
@@ -10840,6 +10888,10 @@ export class OpenCodeController {
|
|
|
10840
10888
|
this.assertStartActive();
|
|
10841
10889
|
this.runtimeConfig = runtimeConfig;
|
|
10842
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();
|
|
10843
10895
|
// Messages still queued or steering when the controller stopped are held for the user; the
|
|
10844
10896
|
// prompts of a durable Flex limit hold are restored with that hold instead.
|
|
10845
10897
|
const armedFlexHolds = new Set((await authStore.listArmedFlexLimitHolds()).map((record) => (
|
|
@@ -12047,62 +12099,32 @@ export class OpenCodeController {
|
|
|
12047
12099
|
) throw new Error('The Flex session identity generation is no longer current.');
|
|
12048
12100
|
}
|
|
12049
12101
|
|
|
12102
|
+
/**
|
|
12103
|
+
* A project's Flex session identities, in one answer the child reads from the project's metadata:
|
|
12104
|
+
* the snapshot is atomic and never waits for a load of the sessions' histories (AGL-1713). The
|
|
12105
|
+
* supervisor has proven the answer: bounded, strictly ordered and generation-bearing.
|
|
12106
|
+
*/
|
|
12050
12107
|
private async readFlexSessionIdentitySnapshot(
|
|
12051
12108
|
supervisorArg: FlexSupervisor,
|
|
12052
12109
|
projectIdArg: string,
|
|
12053
12110
|
signalArg: AbortSignal,
|
|
12054
12111
|
): Promise<IControllerSessionSnapshotEntry[]> {
|
|
12055
|
-
|
|
12056
|
-
const sessions
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
) throw new Error('Flex returned an invalid bounded identity session snapshot.');
|
|
12072
|
-
expectedTotal ??= page.total;
|
|
12073
|
-
if (page.sessions.length === 0 && sessions.length < page.total) {
|
|
12074
|
-
throw new Error('Flex returned an incomplete identity session snapshot page.');
|
|
12075
|
-
}
|
|
12076
|
-
sessions.push(...page.sessions);
|
|
12077
|
-
const truncated = sessions.length < page.total;
|
|
12078
|
-
if (page.truncated !== truncated || sessions.length > page.total) {
|
|
12079
|
-
throw new Error('Flex identity session snapshot pagination changed during its fence.');
|
|
12080
|
-
}
|
|
12081
|
-
if (!truncated) break;
|
|
12082
|
-
}
|
|
12083
|
-
return sessions.map((sessionArg) => {
|
|
12084
|
-
if (
|
|
12085
|
-
typeof sessionArg.sessionId !== 'string'
|
|
12086
|
-
|| sessionArg.sessionId.length === 0
|
|
12087
|
-
|| typeof sessionArg.sessionGenerationId !== 'string'
|
|
12088
|
-
|| sessionArg.sessionGenerationId.length === 0
|
|
12089
|
-
|| typeof sessionArg.sessionGenerationSequence !== 'number'
|
|
12090
|
-
|| !Number.isSafeInteger(sessionArg.sessionGenerationSequence)
|
|
12091
|
-
|| sessionArg.sessionGenerationSequence < 1
|
|
12092
|
-
) throw new Error('Flex returned a session without canonical generation metadata.');
|
|
12093
|
-
return {
|
|
12094
|
-
nativeId: sessionArg.sessionId,
|
|
12095
|
-
sessionGenerationId: sessionArg.sessionGenerationId,
|
|
12096
|
-
sessionGenerationSequence: sessionArg.sessionGenerationSequence,
|
|
12097
|
-
providerSessionGeneration: flexSessionProviderGeneration(
|
|
12098
|
-
sessionArg.sessionGenerationId,
|
|
12099
|
-
sessionArg.sessionGenerationSequence,
|
|
12100
|
-
),
|
|
12101
|
-
...(sessionArg.parentSessionId === undefined
|
|
12102
|
-
? {}
|
|
12103
|
-
: { parentNativeId: sessionArg.parentSessionId }),
|
|
12104
|
-
};
|
|
12105
|
-
}).sort((leftArg, rightArg) => leftArg.nativeId.localeCompare(rightArg.nativeId));
|
|
12112
|
+
signalArg.throwIfAborted();
|
|
12113
|
+
const { sessions } = await supervisorArg.request('session.identities', {
|
|
12114
|
+
scopeId: projectIdArg,
|
|
12115
|
+
}, signalArg);
|
|
12116
|
+
return sessions.map((sessionArg) => ({
|
|
12117
|
+
nativeId: sessionArg.sessionId,
|
|
12118
|
+
sessionGenerationId: sessionArg.sessionGenerationId,
|
|
12119
|
+
sessionGenerationSequence: sessionArg.sessionGenerationSequence,
|
|
12120
|
+
providerSessionGeneration: flexSessionProviderGeneration(
|
|
12121
|
+
sessionArg.sessionGenerationId,
|
|
12122
|
+
sessionArg.sessionGenerationSequence,
|
|
12123
|
+
),
|
|
12124
|
+
...(sessionArg.parentSessionId === undefined
|
|
12125
|
+
? {}
|
|
12126
|
+
: { parentNativeId: sessionArg.parentSessionId }),
|
|
12127
|
+
})).sort((leftArg, rightArg) => leftArg.nativeId.localeCompare(rightArg.nativeId));
|
|
12106
12128
|
}
|
|
12107
12129
|
|
|
12108
12130
|
private async captureFlexCleanupCohort(
|
|
@@ -14824,7 +14846,7 @@ export class OpenCodeController {
|
|
|
14824
14846
|
agl: deviceHostAgl({ version: commitinfo.version, startedAt: this.startedAt, origin: publicOriginArg, gateway: this.gatewayClient?.status() }),
|
|
14825
14847
|
device: deviceHostDevice(device),
|
|
14826
14848
|
...await readDeviceHostSections({
|
|
14827
|
-
deployStatus: () => this.requireDeployMonitor().status(),
|
|
14849
|
+
deployStatus: (operationSignalArg) => this.requireDeployMonitor().status(undefined, operationSignalArg),
|
|
14828
14850
|
capacity: proxyMonitor === undefined ? undefined : (operationSignalArg) => proxyMonitor.capacity({}, operationSignalArg),
|
|
14829
14851
|
authority: () => this.authorityState.getProjection(),
|
|
14830
14852
|
usage: (accountIdArg, loginIdArg, operationSignalArg) => this.accountsActions.usage({ accountId: accountIdArg, loginId: loginIdArg }, operationSignalArg),
|
|
@@ -17827,15 +17849,15 @@ export class OpenCodeController {
|
|
|
17827
17849
|
const pending = kind === 'permission'
|
|
17828
17850
|
? await first.parent.client.listPermissions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal)
|
|
17829
17851
|
: await first.parent.client.listQuestions(first.parent.project.directory, requestArg.childSessionId.nativeId, firstSignal);
|
|
17830
|
-
this.
|
|
17852
|
+
this.assertPromptPending(pending, requestArg.requestId, kind);
|
|
17831
17853
|
const current = await verifyArg(true);
|
|
17832
17854
|
const signal = AbortSignal.any([signalArg, current.parent.runtimeAuthority.signal]);
|
|
17833
17855
|
const { directory } = current.parent.project;
|
|
17834
|
-
const success = 'reply' in requestArg
|
|
17835
|
-
?
|
|
17856
|
+
const success = await sendingReply(() => 'reply' in requestArg
|
|
17857
|
+
? current.parent.client.replyPermission(directory, requestArg.requestId.nativeId, requestArg.reply, requestArg.message, signal)
|
|
17836
17858
|
: requestArg.answers === null
|
|
17837
|
-
?
|
|
17838
|
-
:
|
|
17859
|
+
? current.parent.client.rejectQuestion(directory, requestArg.requestId.nativeId, signal)
|
|
17860
|
+
: current.parent.client.replyQuestion(directory, requestArg.requestId.nativeId, requestArg.answers, signal));
|
|
17839
17861
|
await verifyArg(false);
|
|
17840
17862
|
return { success };
|
|
17841
17863
|
},
|
|
@@ -17889,7 +17911,7 @@ export class OpenCodeController {
|
|
|
17889
17911
|
if (sessionId.harnessId === 'codex') this.requireCodexClient(sessionId.nativeId).replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17890
17912
|
else this.requireClaudeHarness().replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
|
|
17891
17913
|
} catch (errorArg) {
|
|
17892
|
-
throw
|
|
17914
|
+
throw replyRefusal(errorArg);
|
|
17893
17915
|
}
|
|
17894
17916
|
return { success: true };
|
|
17895
17917
|
});
|
|
@@ -17916,27 +17938,31 @@ export class OpenCodeController {
|
|
|
17916
17938
|
if (sessionId.harnessId === 'codex') {
|
|
17917
17939
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17918
17940
|
signalArg.throwIfAborted();
|
|
17919
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
17941
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
17942
|
+
await sendingReply(() => codex.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17920
17943
|
return { success: true };
|
|
17921
17944
|
});
|
|
17922
17945
|
}
|
|
17923
17946
|
if (sessionId.harnessId === 'claude') {
|
|
17924
17947
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17925
17948
|
signalArg.throwIfAborted();
|
|
17926
|
-
this.requireClaudeHarness()
|
|
17949
|
+
const harness = this.requireClaudeHarness();
|
|
17950
|
+
await sendingReply(() => harness.replyPermission(sessionId.nativeId, requestId.nativeId, reply));
|
|
17927
17951
|
return { success: true };
|
|
17928
17952
|
});
|
|
17929
17953
|
}
|
|
17930
17954
|
if (sessionId.harnessId === 'flex') {
|
|
17931
17955
|
signalArg.throwIfAborted();
|
|
17932
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`).
|
|
17933
17959
|
const pendingPermissions = await flexSupervisor.request('permission.list', {
|
|
17934
17960
|
scopeId: projectId,
|
|
17935
17961
|
}, signalArg);
|
|
17936
17962
|
const permission = pendingPermissions.permissions.find(
|
|
17937
17963
|
(candidate) => candidate.permissionId === requestId.nativeId,
|
|
17938
17964
|
);
|
|
17939
|
-
if (!permission) throw
|
|
17965
|
+
if (!permission) throw typedReplyRefusal(promptNoLongerPending('permission'));
|
|
17940
17966
|
const authority = this.flexPermissionAuthority(projectId, permission);
|
|
17941
17967
|
if (
|
|
17942
17968
|
!authority
|
|
@@ -17963,15 +17989,15 @@ export class OpenCodeController {
|
|
|
17963
17989
|
sessionId.nativeId,
|
|
17964
17990
|
signalArg,
|
|
17965
17991
|
);
|
|
17966
|
-
this.
|
|
17992
|
+
this.assertPromptPending(pendingPermissions, requestId, 'permission');
|
|
17967
17993
|
return {
|
|
17968
|
-
success: await this.requireOpenCodeClient().replyPermission(
|
|
17994
|
+
success: await sendingReply(() => this.requireOpenCodeClient().replyPermission(
|
|
17969
17995
|
project.directory,
|
|
17970
17996
|
requestId.nativeId,
|
|
17971
17997
|
reply,
|
|
17972
17998
|
message,
|
|
17973
17999
|
signalArg,
|
|
17974
|
-
),
|
|
18000
|
+
)),
|
|
17975
18001
|
};
|
|
17976
18002
|
},
|
|
17977
18003
|
);
|
|
@@ -17996,14 +18022,16 @@ export class OpenCodeController {
|
|
|
17996
18022
|
if (sessionId.harnessId === 'codex') {
|
|
17997
18023
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
17998
18024
|
signalArg.throwIfAborted();
|
|
17999
|
-
this.requireCodexClient(sessionId.nativeId)
|
|
18025
|
+
const codex = this.requireCodexClient(sessionId.nativeId);
|
|
18026
|
+
await sendingReply(() => codex.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
18000
18027
|
return { success: true };
|
|
18001
18028
|
});
|
|
18002
18029
|
}
|
|
18003
18030
|
if (sessionId.harnessId === 'claude') {
|
|
18004
18031
|
return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
|
|
18005
18032
|
signalArg.throwIfAborted();
|
|
18006
|
-
this.requireClaudeHarness()
|
|
18033
|
+
const harness = this.requireClaudeHarness();
|
|
18034
|
+
await sendingReply(() => harness.replyQuestion(sessionId.nativeId, requestId.nativeId, answers));
|
|
18007
18035
|
return { success: true };
|
|
18008
18036
|
});
|
|
18009
18037
|
}
|
|
@@ -18013,20 +18041,20 @@ export class OpenCodeController {
|
|
|
18013
18041
|
sessionId.nativeId,
|
|
18014
18042
|
signalArg,
|
|
18015
18043
|
);
|
|
18016
|
-
this.
|
|
18044
|
+
this.assertPromptPending(pendingQuestions, requestId, 'question');
|
|
18017
18045
|
return {
|
|
18018
|
-
success: answers === null
|
|
18019
|
-
?
|
|
18046
|
+
success: await sendingReply(() => answers === null
|
|
18047
|
+
? openCodeClient.rejectQuestion(
|
|
18020
18048
|
project.directory,
|
|
18021
18049
|
requestId.nativeId,
|
|
18022
18050
|
signalArg,
|
|
18023
18051
|
)
|
|
18024
|
-
:
|
|
18052
|
+
: openCodeClient.replyQuestion(
|
|
18025
18053
|
project.directory,
|
|
18026
18054
|
requestId.nativeId,
|
|
18027
18055
|
answers,
|
|
18028
18056
|
signalArg,
|
|
18029
|
-
),
|
|
18057
|
+
)),
|
|
18030
18058
|
};
|
|
18031
18059
|
},
|
|
18032
18060
|
);
|
|
@@ -18545,11 +18573,15 @@ export class OpenCodeController {
|
|
|
18545
18573
|
this.boardPump.start();
|
|
18546
18574
|
}
|
|
18547
18575
|
|
|
18548
|
-
/**
|
|
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
|
+
*/
|
|
18549
18580
|
private requireDeployMonitor(): DeployMonitor {
|
|
18550
18581
|
// A stopping controller starts no monitor that its stop would never close.
|
|
18551
18582
|
if (!this.deployMonitor && this.stopRequested) throw new DeployError('deploy_unavailable', 'The controller is stopping.');
|
|
18552
18583
|
this.deployMonitor ??= new DeployMonitor({
|
|
18584
|
+
controllerId: () => this.requireControllerId(),
|
|
18553
18585
|
scope: async () => (this.configurationAuthority ? await this.readFleetScope() : undefined),
|
|
18554
18586
|
discover: async () => this.discoverFleetScope({}),
|
|
18555
18587
|
tickets: async (signalArg) => (await this.ticketStore.execute('list', {}, undefined, signalArg)).tickets,
|
|
@@ -18617,18 +18649,22 @@ export class OpenCodeController {
|
|
|
18617
18649
|
}
|
|
18618
18650
|
|
|
18619
18651
|
/** One deploy request, from the browser, `agl deploy` or the driver; a refusal carries its code. */
|
|
18620
|
-
private async executeDeploy(methodArg: string, requestArg: unknown): Promise<unknown> {
|
|
18652
|
+
private async executeDeploy(methodArg: string, requestArg: unknown, signalArg?: AbortSignal): Promise<unknown> {
|
|
18621
18653
|
const operation = fleetDeployOperation(methodArg);
|
|
18622
18654
|
const monitor = this.requireDeployMonitor();
|
|
18623
18655
|
try {
|
|
18624
|
-
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId);
|
|
18656
|
+
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId, signalArg);
|
|
18625
18657
|
if (operation === 'history') {
|
|
18626
18658
|
const request = assertFleetDeployRequest('history', requestArg);
|
|
18627
18659
|
return await monitor.history(request.targetId, request.limit);
|
|
18628
18660
|
}
|
|
18629
|
-
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId);
|
|
18661
|
+
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId, signalArg);
|
|
18630
18662
|
if (operation === 'ticket') return await monitor.ticketPlacement(assertFleetDeployRequest('ticket', requestArg).ticketKey);
|
|
18631
|
-
|
|
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);
|
|
18632
18668
|
} catch (errorArg) {
|
|
18633
18669
|
if (errorArg instanceof DeployError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
18634
18670
|
throw errorArg;
|
|
@@ -18851,14 +18887,14 @@ export class OpenCodeController {
|
|
|
18851
18887
|
);
|
|
18852
18888
|
}
|
|
18853
18889
|
|
|
18854
|
-
/** 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). */
|
|
18855
18891
|
private registerDeployHandlers(protectedRouterArg: ControllerProtectedRouter): void {
|
|
18856
18892
|
for (const operation of fleetDeployOperations) {
|
|
18857
18893
|
protectedRouterArg.addHandler<TControllerDeployRequest<TFleetDeployOperation>>(`controller.deploy.${operation}`,
|
|
18858
18894
|
async (requestArg, toolsArg) => {
|
|
18859
18895
|
validateRequest(() => assertFleetDeployRequest(operation, requestArg));
|
|
18860
18896
|
const peer = peerFromLocalData(toolsArg?.localData);
|
|
18861
|
-
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,
|
|
18862
18898
|
toolsArg?.abortSignal);
|
|
18863
18899
|
});
|
|
18864
18900
|
}
|
|
@@ -19265,9 +19301,14 @@ export class OpenCodeController {
|
|
|
19265
19301
|
): Promise<IControllerAttention> {
|
|
19266
19302
|
const { session, native } = resolvedArg;
|
|
19267
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 {
|
|
19268
19309
|
const harness = this.claudeHarness;
|
|
19269
|
-
return harness && !harness.closed && harness.isRegistered(
|
|
19270
|
-
? harness.attention(
|
|
19310
|
+
return harness && !harness.closed && harness.isRegistered(nativeIdArg)
|
|
19311
|
+
? harness.attention(nativeIdArg)
|
|
19271
19312
|
: { permissions: [], questions: [], elicitations: [] };
|
|
19272
19313
|
}
|
|
19273
19314
|
|
|
@@ -19281,7 +19322,10 @@ export class OpenCodeController {
|
|
|
19281
19322
|
const attention = await this.nativeSessionAttention(resolvedArg);
|
|
19282
19323
|
const pending = kindArg === 'permission' ? attention.permissions : kindArg === 'question' ? attention.questions : attention.elicitations;
|
|
19283
19324
|
if (!pending.some((request) => request.id.nativeId === requestIdArg)) {
|
|
19284
|
-
|
|
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));
|
|
19285
19329
|
}
|
|
19286
19330
|
try {
|
|
19287
19331
|
if (session.harness === 'codex') {
|
|
@@ -19293,7 +19337,7 @@ export class OpenCodeController {
|
|
|
19293
19337
|
else if ('elicitation' in replyArg) harness.replyElicitation(native.nativeId, requestIdArg, replyArg.elicitation);
|
|
19294
19338
|
else harness.replyQuestion(native.nativeId, requestIdArg, replyArg.answers);
|
|
19295
19339
|
} catch (errorArg) {
|
|
19296
|
-
throw
|
|
19340
|
+
throw replyRefusal(errorArg);
|
|
19297
19341
|
}
|
|
19298
19342
|
}
|
|
19299
19343
|
|
|
@@ -19841,7 +19885,7 @@ export class OpenCodeController {
|
|
|
19841
19885
|
} else if (route.kind === 'directreport') {
|
|
19842
19886
|
result = await this.executeDriverDirectReport(route.operation, input, actor, signalArg);
|
|
19843
19887
|
} else if (route.kind === 'deploy') {
|
|
19844
|
-
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input);
|
|
19888
|
+
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input, signalArg);
|
|
19845
19889
|
} else {
|
|
19846
19890
|
const { owner, configuration } = await this.readFleetScope();
|
|
19847
19891
|
if (route.kind === 'worker') {
|
|
@@ -20469,6 +20513,8 @@ export class OpenCodeController {
|
|
|
20469
20513
|
resolvedDirectory.directory,
|
|
20470
20514
|
{ ancestry: resolvedDirectory.ancestry },
|
|
20471
20515
|
);
|
|
20516
|
+
// A project is a root fleet discovery walks: the deploy monitor's next run walks again.
|
|
20517
|
+
if (created) this.deployMonitor?.workspaceChanged();
|
|
20472
20518
|
let reconciliation: IProjectReconciliationResult;
|
|
20473
20519
|
try {
|
|
20474
20520
|
reconciliation = await this.reconcileProjectStateInMutation(
|
|
@@ -20927,6 +20973,8 @@ export class OpenCodeController {
|
|
|
20927
20973
|
{ code: 'concurrent_change' },
|
|
20928
20974
|
);
|
|
20929
20975
|
}
|
|
20976
|
+
// A project being removed is no root fleet discovery walks any more.
|
|
20977
|
+
this.deployMonitor?.workspaceChanged();
|
|
20930
20978
|
project = pending;
|
|
20931
20979
|
}
|
|
20932
20980
|
if (
|
|
@@ -22854,7 +22902,12 @@ export class OpenCodeController {
|
|
|
22854
22902
|
return [...archivedByKey.values()].map((sessionId) => ({ ...sessionId }));
|
|
22855
22903
|
}
|
|
22856
22904
|
|
|
22857
|
-
|
|
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(
|
|
22858
22911
|
pendingRequestsArg: ReadonlyArray<{ id: IControllerRuntimeId }>,
|
|
22859
22912
|
requestIdArg: IControllerRuntimeId,
|
|
22860
22913
|
kindArg: 'permission' | 'question',
|
|
@@ -22862,10 +22915,7 @@ export class OpenCodeController {
|
|
|
22862
22915
|
if (pendingRequestsArg.some((request) => (
|
|
22863
22916
|
controllerRuntimeIdKey(request.id) === controllerRuntimeIdKey(requestIdArg)
|
|
22864
22917
|
))) return;
|
|
22865
|
-
throw
|
|
22866
|
-
`The ${kindArg} request does not belong to the selected conversation.`,
|
|
22867
|
-
{ code: 'invalid_request' },
|
|
22868
|
-
);
|
|
22918
|
+
throw typedReplyRefusal(promptNoLongerPending(kindArg));
|
|
22869
22919
|
}
|
|
22870
22920
|
|
|
22871
22921
|
private toFlexMessageBundle(projectedArg: IFlexProjectedMessage): IControllerMessageBundle {
|
|
@@ -27579,7 +27629,15 @@ export class OpenCodeController {
|
|
|
27579
27629
|
permissionId: permissionArg.permissionId,
|
|
27580
27630
|
decision: decisionArg,
|
|
27581
27631
|
}, signalArg);
|
|
27582
|
-
|
|
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
|
+
}
|
|
27583
27641
|
if (ticket) this.activateFlexDelegationTicket(ticket);
|
|
27584
27642
|
} catch (errorArg) {
|
|
27585
27643
|
if (ticket) this.revokeFlexDelegationTicket(ticket);
|
|
@@ -29427,10 +29485,12 @@ export class OpenCodeController {
|
|
|
29427
29485
|
/**
|
|
29428
29486
|
* The reversion requests that settle what a Flex session already recorded: a capture's inspection
|
|
29429
29487
|
* and finalization, a pending undo or redo, a release. A project reconciling its session authority
|
|
29430
|
-
* admits them.
|
|
29431
|
-
*
|
|
29432
|
-
*
|
|
29433
|
-
*
|
|
29488
|
+
* admits them. The first full load of the project's sessions in the child (the child's recovery
|
|
29489
|
+
* load once it is ready, a held prompt's settlement or a managed creation's recovery during the
|
|
29490
|
+
* reconciliation, any session read; never `session.identities`) settles each session's pending
|
|
29491
|
+
* capture and apply before it answers; a refused settlement fails that load, and with it a
|
|
29492
|
+
* reconciliation waiting for it, which then never succeeds. The ending turn of a run closes its
|
|
29493
|
+
* capture with the same requests. A new capture
|
|
29434
29494
|
* (`reversion.prepare`) is new work and stays refused while authority is uncertain.
|
|
29435
29495
|
*/
|
|
29436
29496
|
private flexHostMethodSettlesRecordedReversion(methodArg: TFlexHostRequestMethod): boolean {
|
|
@@ -34349,7 +34409,7 @@ export class OpenCodeController {
|
|
|
34349
34409
|
permission.sessionId.nativeId,
|
|
34350
34410
|
this.operationAbortController.signal,
|
|
34351
34411
|
);
|
|
34352
|
-
this.
|
|
34412
|
+
this.assertPromptPending(pending, permission.id, 'permission');
|
|
34353
34413
|
const finalAuthority = await this.resolveOpenCodeFamilyAuthority(
|
|
34354
34414
|
projectId,
|
|
34355
34415
|
permission.sessionId as IControllerRuntimeId & { harnessId: 'opencode' },
|
|
@@ -34381,13 +34441,13 @@ export class OpenCodeController {
|
|
|
34381
34441
|
try {
|
|
34382
34442
|
await this.runAudited(
|
|
34383
34443
|
{ type: 'permission.reply', requestId: permission.id, sessionId: permission.sessionId },
|
|
34384
|
-
async () => openCodeClient.replyPermission(
|
|
34444
|
+
async () => sendingReply(() => openCodeClient.replyPermission(
|
|
34385
34445
|
currentAuthority.parent.project.directory,
|
|
34386
34446
|
permission.id.nativeId,
|
|
34387
34447
|
'once',
|
|
34388
34448
|
undefined,
|
|
34389
34449
|
this.operationAbortController.signal,
|
|
34390
|
-
),
|
|
34450
|
+
)),
|
|
34391
34451
|
);
|
|
34392
34452
|
} catch (errorArg) {
|
|
34393
34453
|
this.autoRepliedPermissionIds.delete(permissionKey);
|