agl 42.2.2 → 43.0.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 +16 -0
- package/dist_serve/bundle.js +6697 -5287
- package/dist_serve/bundle.js.map +2 -2
- package/dist_serve/bundle.js.third-party-notices.json +29 -29
- package/dist_serve/bundle.js.third-party-notices.txt +29 -29
- package/dist_serve/third-party-notices.md +597 -8
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +114 -16
- package/dist_ts/aglapi/interfaces.d.ts +30 -0
- package/dist_ts/aglapi/interfaces.js +7 -1
- package/dist_ts/classes.authstore.d.ts +7 -0
- package/dist_ts/classes.authstore.js +12 -1
- package/dist_ts/classes.cli.js +10 -1
- package/dist_ts/classes.controller.d.ts +41 -11
- package/dist_ts/classes.controller.js +224 -48
- package/dist_ts/classes.harnessoperationmanager.d.ts +44 -0
- package/dist_ts/classes.harnessoperationmanager.js +15 -10
- package/dist_ts/classes.mcpclient.d.ts +5 -0
- package/dist_ts/classes.mcpclient.js +15 -3
- package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -0
- package/dist_ts/classes.mcpcontrollerhost.js +14 -2
- package/dist_ts/classes.mcptools.d.ts +4 -3
- package/dist_ts/classes.mcptools.js +20 -1
- package/dist_ts/classes.mcpvalidation.js +4 -1
- package/dist_ts/classes.ticketstore.d.ts +71 -3
- package/dist_ts/classes.ticketstore.js +299 -12
- package/dist_ts/classes.validation.d.ts +2 -0
- package/dist_ts/classes.validation.js +27 -5
- package/dist_ts/driver/classes.directreports.d.ts +23 -3
- package/dist_ts/driver/classes.directreports.js +59 -2
- package/dist_ts/driver/classes.drivereventrelay.js +3 -2
- package/dist_ts/driver/functions.driverinstructions.d.ts +1 -1
- package/dist_ts/driver/functions.driverinstructions.js +12 -3
- package/dist_ts/driver/functions.drivertools.d.ts +4 -0
- package/dist_ts/driver/functions.drivertools.js +8 -2
- package/dist_ts/fleet/classes.boardpump.d.ts +53 -3
- package/dist_ts/fleet/classes.boardpump.js +237 -32
- package/dist_ts/fleet/classes.claudeworkers.d.ts +10 -3
- package/dist_ts/fleet/classes.claudeworkers.js +43 -19
- package/dist_ts/fleet/classes.codexworkers.d.ts +5 -3
- package/dist_ts/fleet/classes.codexworkers.js +26 -9
- package/dist_ts/fleet/classes.deploymonitor.d.ts +253 -0
- package/dist_ts/fleet/classes.deploymonitor.js +821 -0
- package/dist_ts/fleet/classes.gitfacts.d.ts +61 -0
- package/dist_ts/fleet/classes.gitfacts.js +125 -0
- package/dist_ts/fleet/classes.releasereconciler.d.ts +51 -0
- package/dist_ts/fleet/classes.releasereconciler.js +101 -0
- package/dist_ts/fleet/classes.service.d.ts +13 -1
- package/dist_ts/fleet/classes.service.js +76 -7
- package/dist_ts/fleet/classes.ticketeffects.d.ts +13 -0
- package/dist_ts/fleet/classes.ticketeffects.js +42 -8
- package/dist_ts/fleet/classes.workers.d.ts +10 -3
- package/dist_ts/fleet/classes.workers.js +18 -3
- package/dist_ts/fleet/functions.controllerbuild.d.ts +23 -0
- package/dist_ts/fleet/functions.controllerbuild.js +75 -0
- package/dist_ts/fleet/functions.deployprobes.d.ts +39 -0
- package/dist_ts/fleet/functions.deployprobes.js +82 -0
- package/dist_ts/fleet/functions.deployvalidation.d.ts +27 -0
- package/dist_ts/fleet/functions.deployvalidation.js +43 -0
- package/dist_ts/fleet/functions.release.d.ts +2 -1
- package/dist_ts/fleet/functions.release.js +32 -5
- package/dist_ts/fleet/functions.releasefacts.d.ts +45 -0
- package/dist_ts/fleet/functions.releasefacts.js +68 -0
- package/dist_ts/fleet/functions.validation.d.ts +3 -3
- package/dist_ts/fleet/functions.validation.js +4 -7
- package/dist_ts/fleet/functions.watchprobes.js +7 -9
- package/dist_ts/fleet/functions.workervalidation.js +4 -3
- package/dist_ts/fleet/interfaces.workers.d.ts +30 -3
- package/dist_ts/fleet/interfaces.workers.js +14 -1
- package/dist_ts/functions.deploycli.d.ts +33 -0
- package/dist_ts/functions.deploycli.js +155 -0
- package/dist_ts/functions.mcpdeploytools.d.ts +13 -0
- package/dist_ts/functions.mcpdeploytools.js +16 -0
- package/dist_ts/functions.mcptickettools.d.ts +54 -0
- package/dist_ts/functions.mcptickettools.js +8 -7
- package/dist_ts/functions.ticketautolabels.d.ts +2 -0
- package/dist_ts/functions.ticketautolabels.js +9 -3
- package/dist_ts/functions.ticketcli.d.ts +16 -2
- package/dist_ts/functions.ticketcli.js +105 -27
- package/dist_ts/functions.ticketvalidation.d.ts +55 -0
- package/dist_ts/functions.ticketvalidation.js +26 -8
- package/dist_ts_interfaces/deployments.d.ts +241 -0
- package/dist_ts_interfaces/deployments.js +5 -6
- package/dist_ts_interfaces/fleet.d.ts +12 -0
- package/dist_ts_interfaces/fleetworkers.d.ts +21 -1
- package/dist_ts_interfaces/interfaces.d.ts +4 -2
- package/dist_ts_interfaces/interfaces.js +4 -2
- package/dist_ts_interfaces/mcprequests.d.ts +3 -2
- package/dist_ts_interfaces/mcprequests.js +3 -1
- package/dist_ts_interfaces/requests.d.ts +3 -2
- package/dist_ts_interfaces/requests.directreports.d.ts +58 -6
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_interfaces/requests.tickets.d.ts +25 -5
- package/dist_ts_interfaces/requests.tickets.js +2 -2
- package/dist_ts_interfaces/tickets.d.ts +71 -6
- package/dist_ts_interfaces/tickets.js +34 -6
- package/dist_ts_migration/classes.documentmigrationrunner.d.ts +7 -0
- package/dist_ts_migration/classes.documentmigrationrunner.js +14 -1
- package/dist_ts_migration/index.d.ts +2 -0
- package/dist_ts_migration/index.js +3 -1
- package/dist_ts_migration/v41_ticketclosedcolumn.d.ts +20 -0
- package/dist_ts_migration/v41_ticketclosedcolumn.js +118 -0
- package/dist_ts_migration/v41_ticketlinkrepos.d.ts +24 -0
- package/dist_ts_migration/v41_ticketlinkrepos.js +101 -0
- package/package.json +6 -2
- package/readme.md +306 -36
- package/third-party-notices.md +597 -8
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +113 -15
- package/ts/aglapi/interfaces.ts +6 -0
- package/ts/classes.authstore.ts +13 -0
- package/ts/classes.cli.ts +9 -0
- package/ts/classes.controller.ts +238 -59
- package/ts/classes.harnessoperationmanager.ts +20 -14
- package/ts/classes.mcpclient.ts +17 -2
- package/ts/classes.mcpcontrollerhost.ts +15 -1
- package/ts/classes.mcptools.ts +21 -2
- package/ts/classes.mcpvalidation.ts +2 -0
- package/ts/classes.ticketstore.ts +312 -13
- package/ts/classes.validation.ts +28 -4
- package/ts/driver/classes.directreports.ts +58 -3
- package/ts/driver/classes.drivereventrelay.ts +2 -1
- package/ts/driver/functions.driverinstructions.ts +11 -2
- package/ts/driver/functions.drivertools.ts +10 -2
- package/ts/fleet/classes.boardpump.ts +235 -28
- package/ts/fleet/classes.claudeworkers.ts +36 -15
- package/ts/fleet/classes.codexworkers.ts +24 -7
- package/ts/fleet/classes.deploymonitor.ts +854 -0
- package/ts/fleet/classes.gitfacts.ts +135 -0
- package/ts/fleet/classes.releasereconciler.ts +103 -0
- package/ts/fleet/classes.service.ts +81 -8
- package/ts/fleet/classes.ticketeffects.ts +38 -6
- package/ts/fleet/classes.workers.ts +19 -5
- package/ts/fleet/functions.controllerbuild.ts +84 -0
- package/ts/fleet/functions.deployprobes.ts +84 -0
- package/ts/fleet/functions.deployvalidation.ts +50 -0
- package/ts/fleet/functions.release.ts +32 -3
- package/ts/fleet/functions.releasefacts.ts +91 -0
- package/ts/fleet/functions.validation.ts +3 -6
- package/ts/fleet/functions.watchprobes.ts +6 -8
- package/ts/fleet/functions.workervalidation.ts +3 -2
- package/ts/fleet/interfaces.workers.ts +23 -3
- package/ts/functions.deploycli.ts +151 -0
- package/ts/functions.mcpdeploytools.ts +18 -0
- package/ts/functions.mcptickettools.ts +7 -6
- package/ts/functions.ticketautolabels.ts +10 -2
- package/ts/functions.ticketcli.ts +100 -24
- package/ts/functions.ticketvalidation.ts +26 -7
- package/ts_interfaces/deployments.ts +194 -0
- package/ts_interfaces/fleet.ts +17 -2
- package/ts_interfaces/fleetworkers.ts +20 -0
- package/ts_interfaces/interfaces.ts +3 -1
- package/ts_interfaces/mcprequests.ts +3 -0
- package/ts_interfaces/requests.directreports.ts +52 -8
- package/ts_interfaces/requests.tickets.ts +20 -4
- package/ts_interfaces/requests.ts +6 -1
- package/ts_interfaces/tickets.ts +53 -6
- package/ts_migration/classes.documentmigrationrunner.ts +15 -0
- package/ts_migration/index.ts +2 -0
- package/ts_migration/v41_ticketclosedcolumn.ts +106 -0
- package/ts_migration/v41_ticketlinkrepos.ts +91 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements.deployments.ts +1066 -0
- package/ts_web/elements.directreport.ts +2 -2
- package/ts_web/elements.directreportsession.ts +5 -5
- package/ts_web/elements.harnesscontrollerapp.ts +179 -13
- package/ts_web/elements.makedirectreport.ts +444 -0
- package/ts_web/elements.nativesession.ts +29 -1
- package/ts_web/elements.ticketboard.ts +74 -18
- package/ts_web/functions.deployments.ts +225 -0
- package/ts_web/functions.sessionchat.ts +2 -0
package/ts/classes.controller.ts
CHANGED
|
@@ -494,11 +494,17 @@ import {
|
|
|
494
494
|
import { ControllerJobError } from './classes.joberror.js';
|
|
495
495
|
import { ControllerJobManager } from './classes.jobmanager.js';
|
|
496
496
|
import { ControllerJobStore } from './classes.jobstore.js';
|
|
497
|
-
import { TicketStore, TicketError } from './classes.ticketstore.js';
|
|
497
|
+
import { TicketStore, TicketError, type ITicketDeployTargetFacts } from './classes.ticketstore.js';
|
|
498
498
|
import { TicketNotifier } from './classes.ticketnotifier.js';
|
|
499
|
-
import { BoardPump } from './fleet/classes.boardpump.js';
|
|
499
|
+
import { BoardPump, boardPumpActor } from './fleet/classes.boardpump.js';
|
|
500
|
+
import { DeployError, DeployMonitor, closeDeployPlanTicket } from './fleet/classes.deploymonitor.js';
|
|
501
|
+
import { packageRepositorySlug, readControllerBuild, type IFleetControllerBuild } from './fleet/functions.controllerbuild.js';
|
|
502
|
+
import { runFleetCommand } from './fleet/classes.runtime.js';
|
|
503
|
+
import { assertFleetDeployRequest, fleetDeployOperation } from './fleet/functions.deployvalidation.js';
|
|
504
|
+
import { fleetDeployOperations, type IFleetDeployTargetStatus, type TControllerDeployRequest, type TFleetDeployOperation } from '../ts_interfaces/deployments.js';
|
|
500
505
|
import { FleetService } from './fleet/classes.service.js';
|
|
501
|
-
import type { IFleetConfiguration, IFleetDriverConfiguration, IFleetScope, IFleetUnboundDriver, TFleetOperation, TFleetRequest } from '../ts_interfaces/fleet.js';
|
|
506
|
+
import type { IFleetConfiguration, IFleetDriverConfiguration, IFleetOperation, IFleetScope, IFleetUnboundDriver, TFleetOperation, TFleetRequest } from '../ts_interfaces/fleet.js';
|
|
507
|
+
import { findFleetRepository, fleetRepositorySlug } from './fleet/functions.releasefacts.js';
|
|
502
508
|
import { discoverFleetRepositories } from './fleet/functions.discovery.js';
|
|
503
509
|
import { DriverError, DriverService } from './driver/classes.driverservice.js';
|
|
504
510
|
import { DriverEventRelay, driverRelayMaximumMessageBytes } from './driver/classes.drivereventrelay.js';
|
|
@@ -519,7 +525,7 @@ import type {
|
|
|
519
525
|
IReq_ControllerNativeSessionSend,
|
|
520
526
|
} from '../ts_interfaces/nativesessions.js';
|
|
521
527
|
import { ControllerUploadManager, type IControllerUploadHandle } from './classes.uploadmanager.js';
|
|
522
|
-
import type { IReq_ControllerDirectReportAdopt, IReq_ControllerDirectReportAppoint, IReq_ControllerDirectReportList, IReq_ControllerDirectReportMessage, IReq_ControllerDirectReportRead, IReq_ControllerDirectReportRetire, TDirectReportPage } from '../ts_interfaces/requests.directreports.js';
|
|
528
|
+
import type { IReq_ControllerDirectReportAdopt, IReq_ControllerDirectReportAppoint, IReq_ControllerDirectReportList, IReq_ControllerDirectReportMessage, IReq_ControllerDirectReportPreflight, IReq_ControllerDirectReportRead, IReq_ControllerDirectReportRetire, TDirectReportPage } from '../ts_interfaces/requests.directreports.js';
|
|
523
529
|
import { SessionFeed, SessionFeedAcknowledgementError, SessionFeedTranscripts, type ISessionFeedTerminal, type TSessionFeedProjectRead } from './classes.sessionfeed.js';
|
|
524
530
|
import { SessionFeedAcknowledgementStore } from './classes.sessionfeedacknowledgements.js';
|
|
525
531
|
import { HarnessReleaseNotices, type THarnessReleaseSource } from './classes.harnessreleases.js';
|
|
@@ -532,7 +538,7 @@ import type { IReq_ControllerUsageUnwatch, IReq_ControllerUsageWatch, TControlle
|
|
|
532
538
|
import { ticketActorFromCaller } from './functions.ticketactor.js';
|
|
533
539
|
import { ticketOwnerActor, ticketOwnerPrincipalId, resolveTicketOwnerAssignment } from './functions.ticketowner.js';
|
|
534
540
|
import { ticketInputSchemas } from './functions.ticketvalidation.js';
|
|
535
|
-
import { readTicketRevisionConflict, type ITicketActor, type TTicketOperation, type TTicketRequest, type TTicketFleetEvent, type ITicketFleetEventResult } from '../ts_interfaces/tickets.js';
|
|
541
|
+
import { readTicketRevisionConflict, type ITicket, type ITicketActor, type TTicketOperation, type TTicketRequest, type TTicketFleetEvent, type ITicketFleetEventResult } from '../ts_interfaces/tickets.js';
|
|
536
542
|
import type { TControllerTicketRequest } from '../ts_interfaces/requests.tickets.js';
|
|
537
543
|
import { ControllerJobSupervisor } from './classes.jobsupervisor.js';
|
|
538
544
|
import {
|
|
@@ -698,6 +704,7 @@ import {
|
|
|
698
704
|
assertDirectReportListRequest,
|
|
699
705
|
assertDirectReportAppointRequest,
|
|
700
706
|
assertDirectReportAdoptRequest,
|
|
707
|
+
assertDirectReportPreflightRequest,
|
|
701
708
|
assertDirectReportRetireRequest,
|
|
702
709
|
assertDirectReportMessageRequest,
|
|
703
710
|
assertDirectReportReadRequest,
|
|
@@ -814,6 +821,7 @@ import {
|
|
|
814
821
|
} from './constants.upgradeenvironment.js';
|
|
815
822
|
import { ControllerAgentMessageLimiter } from './classes.agentmessagelimiter.js';
|
|
816
823
|
import { agentMessageSubjects, formatAgentMessage, formatOwnerFleetMessage } from './functions.agentmessage.js';
|
|
824
|
+
import { FleetNativeTurnError } from './fleet/interfaces.workers.js';
|
|
817
825
|
import {
|
|
818
826
|
isModelChoiceOffered,
|
|
819
827
|
resolveFlexDefaultModel,
|
|
@@ -836,8 +844,10 @@ const operationAbortControllerPeerStateKey = '__harnessControllerOperationAbortC
|
|
|
836
844
|
// fail-closes the connection (and with it the per-connection auth).
|
|
837
845
|
// Typed request envelopes still carry transcripts and inline attachments.
|
|
838
846
|
/** The ticket operations that write: a CLI caller's proved Claude Code session is recorded on these. */
|
|
839
|
-
const ticketWriteOperations: ReadonlySet<TTicketOperation> = new Set<TTicketOperation>(['create', 'update', 'move', 'comment', 'link', 'ask', 'answer']);
|
|
847
|
+
const ticketWriteOperations: ReadonlySet<TTicketOperation> = new Set<TTicketOperation>(['create', 'update', 'move', 'comment', 'link', 'unlink', 'ask', 'answer']);
|
|
840
848
|
const websocketPayloadLimit = 16 * 1024 * 1024;
|
|
849
|
+
/** The Claude Code folder AGL's own Claude Code reads and writes. */
|
|
850
|
+
const ownClaudeHome = (): string => process.env.CLAUDE_CONFIG_DIR || plugins.path.join(plugins.os.homedir(), '.claude');
|
|
841
851
|
const browserViewActivationTimeoutMs = 15_000;
|
|
842
852
|
const browserViewCleanupRetryMs = 1_000;
|
|
843
853
|
const browserViewTransportCleanupTimeoutMs = 9_000;
|
|
@@ -1022,6 +1032,10 @@ const sessionHarnessRestartServeTimeoutMs = 60_000;
|
|
|
1022
1032
|
const openCodeRestartInitialDelayMs = 1_000;
|
|
1023
1033
|
const openCodeRestartMaximumDelayMs = 30_000;
|
|
1024
1034
|
const flexRestartInitialDelayMs = 1_000;
|
|
1035
|
+
/** The package this controller runs from, and the repository it is released from, as its package.json names it (AGL-909). */
|
|
1036
|
+
const controllerPackageRoot = plugins.path.resolve(plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url)), '..');
|
|
1037
|
+
const controllerRepository = packageRepositorySlug(controllerPackageRoot);
|
|
1038
|
+
|
|
1025
1039
|
/**
|
|
1026
1040
|
* Boot-time Flex startup may not delay controller readiness beyond this
|
|
1027
1041
|
* budget. Detached `agl start` and the upgrade worker wait a bounded time for
|
|
@@ -1029,6 +1043,7 @@ const flexRestartInitialDelayMs = 1_000;
|
|
|
1029
1043
|
* projects) can legitimately take minutes under its 30 minute lifecycle
|
|
1030
1044
|
* deadline; past the budget the harness continues through Flex recovery.
|
|
1031
1045
|
*/
|
|
1046
|
+
|
|
1032
1047
|
export const controllerFlexBootStartupBudgetMs = 30_000;
|
|
1033
1048
|
const flexRestartMaximumDelayMs = 30_000;
|
|
1034
1049
|
|
|
@@ -3221,6 +3236,14 @@ export class OpenCodeController {
|
|
|
3221
3236
|
if (!worker?.nativeId) throw new Error('The relaunched fleet worker is unavailable.');
|
|
3222
3237
|
return worker;
|
|
3223
3238
|
},
|
|
3239
|
+
nativeSession: async (ref) => await this.nativeSessions.resolve(ref),
|
|
3240
|
+
claudeProfiles: async () => {
|
|
3241
|
+
const own = ownClaudeHome();
|
|
3242
|
+
return ((await this.readFleetScope()).configuration.workerProfiles ?? []).flatMap((profile) => profile.harness !== 'claude' ? []
|
|
3243
|
+
: [{ id: profile.id, ...(profile.home && plugins.path.resolve(profile.home) !== plugins.path.resolve(own) ? { home: profile.home } : {}) }]);
|
|
3244
|
+
},
|
|
3245
|
+
relaunchBlocker: async ({ profile, nativeId, cwd }) =>
|
|
3246
|
+
await this.requireFleetWorkers().relaunchBlocker((await this.readFleetScope()).configuration, profile, nativeId, cwd),
|
|
3224
3247
|
reportFailure: (message, error) => console.error(message, error),
|
|
3225
3248
|
// The Driver view lists the reports again.
|
|
3226
3249
|
changed: () => {
|
|
@@ -3373,9 +3396,15 @@ export class OpenCodeController {
|
|
|
3373
3396
|
}
|
|
3374
3397
|
private ticketNotifier?: TicketNotifier;
|
|
3375
3398
|
private boardPump?: BoardPump;
|
|
3399
|
+
private deployMonitor?: DeployMonitor;
|
|
3400
|
+
/** What this controller was built from, read once: its dependency tree does not change while it runs. */
|
|
3401
|
+
private controllerBuild?: Promise<IFleetControllerBuild>;
|
|
3376
3402
|
private requireFleetService(): FleetService {
|
|
3377
3403
|
this.fleetService ??= new FleetService({ ticketEffects: this.requireFleetTicketEffects(), reconcileSessions: (owner) => this.requireFleetWorkers().reconcileSessions(owner),
|
|
3378
|
-
unboundDrivers: (signal) => this.listUnboundDrivers(signal),
|
|
3404
|
+
unboundDrivers: (signal) => this.listUnboundDrivers(signal),
|
|
3405
|
+
tickets: async (signal) => (await this.ticketStore.execute('list', {}, undefined, signal)).tickets,
|
|
3406
|
+
released: () => this.deployMonitor?.reconcileSoon(),
|
|
3407
|
+
onOperation: (operation, owner, repo) => {
|
|
3379
3408
|
this.requireFleetWorkers().releaseEvent(operation, owner, repo);
|
|
3380
3409
|
if (operation.state === 'succeeded' && operation.ticketKey && operation.result && 'ticketSync' in operation.result && operation.result.ticketSync) {
|
|
3381
3410
|
this.requireFleetWorkers().ticketEvent(owner, operation.ticketKey, operation.result.ticketSync, undefined, operation.id);
|
|
@@ -3388,11 +3417,15 @@ export class OpenCodeController {
|
|
|
3388
3417
|
private readonly ticketStore = new TicketStore((revisionArg, ticketIdsArg) => {
|
|
3389
3418
|
void this.pushControllerEvent({ type: 'tickets.changed', ticketRevision: revisionArg,
|
|
3390
3419
|
ticketIds: ticketIdsArg, timestamp: Date.now() }).catch(() => undefined);
|
|
3420
|
+
// A release link, a move or a closed ticket changes which tickets run nowhere yet.
|
|
3421
|
+
this.deployMonitor?.ticketsChanged();
|
|
3391
3422
|
}, (observationArg) => {
|
|
3392
3423
|
this.ticketNotifier?.observe(observationArg);
|
|
3393
3424
|
// A refused stale edit changed nothing on the board.
|
|
3394
3425
|
if (observationArg.revision !== undefined) this.driverService?.boardChanged();
|
|
3395
|
-
})
|
|
3426
|
+
}, { resolveReleasePlanRepo: (repoArg) => this.resolveReleasePlanRepo(repoArg),
|
|
3427
|
+
undeployedTickets: () => this.deployMonitor?.undeployed() ?? new Set<string>(),
|
|
3428
|
+
deployTarget: (idArg) => this.deployTargetFacts(idArg) });
|
|
3396
3429
|
public applyFleetEvent(eventArg: TTicketFleetEvent, signalArg?: AbortSignal, originArg?: string): Promise<ITicketFleetEventResult> {
|
|
3397
3430
|
return this.ticketStore.applyFleetEvent(eventArg, signalArg, originArg);
|
|
3398
3431
|
}
|
|
@@ -9775,9 +9808,15 @@ export class OpenCodeController {
|
|
|
9775
9808
|
const operation = method.slice('agl.mcp.fleet.'.length) as TFleetOperation;
|
|
9776
9809
|
const actor = ticketOwnerActor(await this.requireAuthStore().getState(),
|
|
9777
9810
|
owner.localCli ? 'driver' : 'owner', owner.localCli?.osUser ?? 'Owner');
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9811
|
+
return this.submitFleetOperation(operation, input, master.fleet ?? {}, owner.resourceId, actor);
|
|
9812
|
+
}),
|
|
9813
|
+
deploy: (method, request, signal) => run(signal, async () => {
|
|
9814
|
+
if (!this.configurationAuthority || typeof request.ownerToken !== 'string') {
|
|
9815
|
+
throw new plugins.typedrequest.TypedResponseError('Deploy status requires a local-owner capability.', { code: 'unauthorized' });
|
|
9816
|
+
}
|
|
9817
|
+
await this.configurationAuthority.verifyOwnerCapability({ token: request.ownerToken });
|
|
9818
|
+
const { ownerToken: _token, ...input } = request;
|
|
9819
|
+
return this.executeDeploy(method, input);
|
|
9781
9820
|
}),
|
|
9782
9821
|
tickets: (methodArg, requestArg, signalArg, connectionArg) => run(signalArg, async (operationSignalArg) => {
|
|
9783
9822
|
const { ownerToken, ...request } = requestArg;
|
|
@@ -10076,6 +10115,7 @@ export class OpenCodeController {
|
|
|
10076
10115
|
masterSaved: () => {
|
|
10077
10116
|
this.driverService?.configurationChanged();
|
|
10078
10117
|
this.boardPump?.configurationChanged();
|
|
10118
|
+
this.deployMonitor?.configurationChanged();
|
|
10079
10119
|
},
|
|
10080
10120
|
nativeVersionObserved: (targetIdArg, versionArg) => {
|
|
10081
10121
|
if (targetIdArg === 'claude') this.observeClaudeRelease(versionArg, 'configuration');
|
|
@@ -10105,6 +10145,8 @@ export class OpenCodeController {
|
|
|
10105
10145
|
this.assertStartActive();
|
|
10106
10146
|
const authDocument = await authStore.resolveOrCreateRuntimeConfig(runtimeConfig);
|
|
10107
10147
|
await authStore.migrateTicketOwnerPrincipal();
|
|
10148
|
+
const closed = await authStore.migrateTicketClosedColumn();
|
|
10149
|
+
if (closed.length) console.log(`Moved ${closed.length} tickets released without a release link or any code link to closed (AGL-916): ${closed.join(', ')}.`);
|
|
10108
10150
|
this.assertStartActive();
|
|
10109
10151
|
this.runtimeConfig = runtimeConfig;
|
|
10110
10152
|
this.controllerId = authDocument.id;
|
|
@@ -10747,6 +10789,9 @@ export class OpenCodeController {
|
|
|
10747
10789
|
publish: (eventArg) => this.fleetWorkers?.events.publish(eventArg),
|
|
10748
10790
|
});
|
|
10749
10791
|
this.startBoardPump();
|
|
10792
|
+
this.requireDeployMonitor().start();
|
|
10793
|
+
void this.trackOperationPromise(this.normalizeTicketLinkRepos())
|
|
10794
|
+
.catch((errorArg) => console.error('Naming the repositories of ticket links as org/name failed.', errorArg));
|
|
10750
10795
|
// Retained uploads of earlier controllers go once untouched for 24 h, even while no upload follows to sweep them.
|
|
10751
10796
|
this.retainedUploads ??= new ControllerUploadManager({ retained: true });
|
|
10752
10797
|
void this.trackOperationPromise(this.retainedUploads.sweepEarlierRoots())
|
|
@@ -13110,6 +13155,7 @@ export class OpenCodeController {
|
|
|
13110
13155
|
});
|
|
13111
13156
|
await stopPart(async () => { await this.fleetService?.close(); this.fleetService = undefined; });
|
|
13112
13157
|
await stopPart(async () => { await this.boardPump?.close(); this.boardPump = undefined; });
|
|
13158
|
+
await stopPart(async () => { await this.deployMonitor?.close(); this.deployMonitor = undefined; });
|
|
13113
13159
|
await stopPart(async () => { await this.ticketNotifier?.close(); this.ticketNotifier = undefined; });
|
|
13114
13160
|
await stopPart(async () => { await this.sessionFeed?.close(); this.sessionFeed = undefined; });
|
|
13115
13161
|
await stopPart(async () => { await this.usageFeed?.stop(); this.usageFeed = undefined; });
|
|
@@ -13664,6 +13710,7 @@ export class OpenCodeController {
|
|
|
13664
13710
|
this.registerDirectReportHandlers(protectedRouter);
|
|
13665
13711
|
this.registerNativeSessionHandlers(protectedRouter);
|
|
13666
13712
|
this.registerSessionFeedHandlers(protectedRouter);
|
|
13713
|
+
this.registerDeployHandlers(protectedRouter);
|
|
13667
13714
|
this.registerUsageFeedHandlers(protectedRouter);
|
|
13668
13715
|
this.registerTerminalHandlers(protectedRouter);
|
|
13669
13716
|
this.registerDevicesHandlers(protectedRouter);
|
|
@@ -17237,16 +17284,129 @@ export class OpenCodeController {
|
|
|
17237
17284
|
steer: (sessionIdArg, ticketKeyArg, textArg) => this.requireFleetWorkers().notify(sessionIdArg, ticketKeyArg, textArg),
|
|
17238
17285
|
publish: (eventArg, ownerArg) => this.requireFleetWorkers().events.publish(eventArg, ownerArg),
|
|
17239
17286
|
unboundDrivers: () => this.listUnboundDrivers(),
|
|
17287
|
+
deployStatus: () => this.requireDeployMonitor().status(),
|
|
17288
|
+
repositories: () => this.requireDeployMonitor().repositories(),
|
|
17289
|
+
planDeploy: (requestArg) => this.planDeploy(requestArg),
|
|
17240
17290
|
effects: this.requireFleetTicketEffects(),
|
|
17241
17291
|
});
|
|
17242
17292
|
this.boardPump.start();
|
|
17243
17293
|
}
|
|
17244
17294
|
|
|
17295
|
+
/** AGL-911: the loop that observes what each deploy target runs; status and history are computed from it when read. */
|
|
17296
|
+
private requireDeployMonitor(): DeployMonitor {
|
|
17297
|
+
// A stopping controller starts no monitor that its stop would never close.
|
|
17298
|
+
if (!this.deployMonitor && this.stopRequested) throw new DeployError('deploy_unavailable', 'The controller is stopping.');
|
|
17299
|
+
this.deployMonitor ??= new DeployMonitor({
|
|
17300
|
+
scope: async () => (this.configurationAuthority ? await this.readFleetScope() : undefined),
|
|
17301
|
+
discover: async () => this.discoverFleetScope({}),
|
|
17302
|
+
tickets: async (signalArg) => (await this.ticketStore.execute('list', {}, undefined, signalArg)).tickets,
|
|
17303
|
+
boardRevision: () => this.ticketStore.boardRevision(),
|
|
17304
|
+
publish: (eventArg, ownerArg) => this.requireFleetWorkers().events.publish(eventArg, ownerArg),
|
|
17305
|
+
controller: () => ({ version: commitinfo.version, startedAt: this.startedAt, host: plugins.os.hostname(),
|
|
17306
|
+
...(controllerRepository ? { repo: controllerRepository } : {}) }),
|
|
17307
|
+
controllerBuild: () => (this.controllerBuild ??= readControllerBuild(controllerPackageRoot, runFleetCommand)),
|
|
17308
|
+
effects: this.requireFleetTicketEffects(),
|
|
17309
|
+
busySessions: () => this.harnessOperationManager.activeSessions().sessionsByKey.size,
|
|
17310
|
+
deployQuestion: (ticketKeyArg, questionIdArg) => this.ticketStore.question(ticketKeyArg, questionIdArg),
|
|
17311
|
+
closeDeployPlan: (planArg, textArg) => closeDeployPlanTicket(this.ticketStore, planArg, textArg),
|
|
17312
|
+
// The board shows the AutoLabel as the store computes it now; its revision did not move.
|
|
17313
|
+
undeployedChanged: (ticketKeysArg) => {
|
|
17314
|
+
void this.pushControllerEvent({ type: 'tickets.changed', ticketIds: ticketKeysArg, timestamp: Date.now() }).catch(() => undefined);
|
|
17315
|
+
},
|
|
17316
|
+
changed: () => {
|
|
17317
|
+
void this.pushControllerEvent({ type: 'deployments.changed', timestamp: Date.now() }).catch(() => undefined);
|
|
17318
|
+
},
|
|
17319
|
+
});
|
|
17320
|
+
return this.deployMonitor;
|
|
17321
|
+
}
|
|
17322
|
+
|
|
17323
|
+
/**
|
|
17324
|
+
* Once (migration v41_ticketlinkrepos, AGL-909): the links and release plans that name a discovered repository by its
|
|
17325
|
+
* fleet id or checkout path name it as `org/name`. It runs after start, since it needs fleet discovery.
|
|
17326
|
+
*/
|
|
17327
|
+
private async normalizeTicketLinkRepos(): Promise<void> {
|
|
17328
|
+
const repositories = await this.requireDeployMonitor().repositories();
|
|
17329
|
+
const changed = await this.requireAuthStore().migrateTicketLinkRepos((nameArg) => {
|
|
17330
|
+
const repo = findFleetRepository(repositories, nameArg);
|
|
17331
|
+
return repo ? fleetRepositorySlug(repo) : undefined;
|
|
17332
|
+
}, repositories.length);
|
|
17333
|
+
if (!changed.length) return;
|
|
17334
|
+
console.log(`Named the repositories of ${changed.length} tickets' links as org/name (AGL-909): ${changed.join(', ')}.`);
|
|
17335
|
+
void this.pushControllerEvent({ type: 'tickets.changed', ticketIds: changed, timestamp: Date.now() }).catch(() => undefined);
|
|
17336
|
+
}
|
|
17337
|
+
|
|
17338
|
+
/**
|
|
17339
|
+
* The board pump plans a deploy (AGL-909): a ticket on the target's board project whose deploy plan asks the owner. A
|
|
17340
|
+
* direct report whose projects hold that project deploys it, so the ticket is assigned to it and the owner's answer
|
|
17341
|
+
* reaches it; on the driver's own subject it stays unassigned.
|
|
17342
|
+
*/
|
|
17343
|
+
private async planDeploy(requestArg: { target: IFleetDeployTargetStatus; version: string; title: string; description: string }): Promise<ITicket> {
|
|
17344
|
+
const { owner } = await this.readFleetScope();
|
|
17345
|
+
const report = (await this.requireDirectReports().list(owner, false)).find((viewArg) => viewArg.report.state === 'active'
|
|
17346
|
+
&& viewArg.report.projects.includes(requestArg.target.target.project))?.report;
|
|
17347
|
+
const harness = report?.sessionId.split(':')[0];
|
|
17348
|
+
return (await this.ticketStore.execute('create', { project: requestArg.target.target.project, title: requestArg.title,
|
|
17349
|
+
description: requestArg.description, columnId: 'ready', deployPlan: { target: requestArg.target.target.id, version: requestArg.version },
|
|
17350
|
+
...(report ? { assignee: { id: report.sessionId, name: report.name, sessionId: report.sessionId,
|
|
17351
|
+
...(harness === 'claude' || harness === 'codex' ? { kind: harness } : {}) } } : {}) }, boardPumpActor)).ticket;
|
|
17352
|
+
}
|
|
17353
|
+
|
|
17354
|
+
/**
|
|
17355
|
+
* The deploy target a maintenance window or a deploy plan names, as the ticket store checks it before its transaction
|
|
17356
|
+
* (AGL-909): its name and where it runs, and when its deploys may run.
|
|
17357
|
+
*/
|
|
17358
|
+
private async deployTargetFacts(idArg: string): Promise<ITicketDeployTargetFacts> {
|
|
17359
|
+
const scope = await this.readFleetScope();
|
|
17360
|
+
const target = this.requireDeployMonitor().targets(scope.configuration).find((targetArg) => targetArg.id === idArg);
|
|
17361
|
+
if (!target) throw new Error(`No deploy target is named ${idArg}.`);
|
|
17362
|
+
return { id: target.id, name: target.name ?? target.id, ...(target.environment ? { environment: target.environment } : {}),
|
|
17363
|
+
deployWhen: target.probe.kind === 'controller' ? 'idle' : target.deployWhen ?? 'anytime' };
|
|
17364
|
+
}
|
|
17365
|
+
|
|
17366
|
+
/** One deploy request, from the browser, `agl deploy` or the driver; a refusal carries its code. */
|
|
17367
|
+
private async executeDeploy(methodArg: string, requestArg: unknown): Promise<unknown> {
|
|
17368
|
+
const operation = fleetDeployOperation(methodArg);
|
|
17369
|
+
const monitor = this.requireDeployMonitor();
|
|
17370
|
+
try {
|
|
17371
|
+
if (operation === 'status') return await monitor.status(assertFleetDeployRequest('status', requestArg).targetId);
|
|
17372
|
+
if (operation === 'history') {
|
|
17373
|
+
const request = assertFleetDeployRequest('history', requestArg);
|
|
17374
|
+
return await monitor.history(request.targetId, request.limit);
|
|
17375
|
+
}
|
|
17376
|
+
if (operation === 'probe') return await monitor.probe(assertFleetDeployRequest('probe', requestArg).targetId);
|
|
17377
|
+
if (operation === 'ticket') return await monitor.ticketPlacement(assertFleetDeployRequest('ticket', requestArg).ticketKey);
|
|
17378
|
+
return await monitor.releaseStatus(assertFleetDeployRequest('release', requestArg).repo);
|
|
17379
|
+
} catch (errorArg) {
|
|
17380
|
+
if (errorArg instanceof DeployError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
17381
|
+
throw errorArg;
|
|
17382
|
+
}
|
|
17383
|
+
}
|
|
17384
|
+
|
|
17245
17385
|
private async readDriverConfiguration(): Promise<IFleetDriverConfiguration | undefined> {
|
|
17246
17386
|
if (!this.configurationAuthority) return undefined;
|
|
17247
17387
|
return (await this.readFleetScope()).configuration.driver;
|
|
17248
17388
|
}
|
|
17249
17389
|
|
|
17390
|
+
/**
|
|
17391
|
+
* Queues a fleet operation for the owner; its ticket must exist. A release checks the board's release plans itself,
|
|
17392
|
+
* against the repository it resolved (AGL-909).
|
|
17393
|
+
*/
|
|
17394
|
+
private async submitFleetOperation(operationArg: TFleetOperation, inputArg: Record<string, unknown>,
|
|
17395
|
+
configurationArg: IFleetConfiguration, ownerArg: string, actorArg: ITicketActor, signalArg?: AbortSignal): Promise<IFleetOperation> {
|
|
17396
|
+
const ticketKey = typeof inputArg.ticketKey === 'string' ? inputArg.ticketKey : undefined;
|
|
17397
|
+
if (ticketKey !== undefined && operationArg !== 'audit') await this.ticketStore.execute('get', { ticketId: ticketKey, limit: 1 }, actorArg, signalArg);
|
|
17398
|
+
const scope = await this.discoverFleetScope(configurationArg);
|
|
17399
|
+
return this.requireFleetService().submit(operationArg, inputArg as unknown as TFleetRequest<typeof operationArg>, scope, ownerArg, actorArg);
|
|
17400
|
+
}
|
|
17401
|
+
|
|
17402
|
+
/**
|
|
17403
|
+
* The repository a release plan or an `affects` link names, as `org/name` of the one discovered fleet repository it
|
|
17404
|
+
* matches; the deploy monitor's discovery of the last minute answers, and walks again only for a name it lacks.
|
|
17405
|
+
*/
|
|
17406
|
+
private async resolveReleasePlanRepo(repoArg: string): Promise<string> {
|
|
17407
|
+
return fleetRepositorySlug(await this.requireDeployMonitor().resolveRepository(repoArg));
|
|
17408
|
+
}
|
|
17409
|
+
|
|
17250
17410
|
/** The fleet owner and configuration the driver's fleet and worker tools act on. */
|
|
17251
17411
|
private async readFleetScope(): Promise<{ owner: string; configuration: IFleetConfiguration }> {
|
|
17252
17412
|
const authority = this.configurationAuthority;
|
|
@@ -17433,6 +17593,19 @@ export class OpenCodeController {
|
|
|
17433
17593
|
);
|
|
17434
17594
|
}
|
|
17435
17595
|
|
|
17596
|
+
/** The Deployments view: status, history, a probe now and release state (AGL-911, AGL-914). */
|
|
17597
|
+
private registerDeployHandlers(protectedRouterArg: ControllerProtectedRouter): void {
|
|
17598
|
+
for (const operation of fleetDeployOperations) {
|
|
17599
|
+
protectedRouterArg.addHandler<TControllerDeployRequest<TFleetDeployOperation>>(`controller.deploy.${operation}`,
|
|
17600
|
+
async (requestArg, toolsArg) => {
|
|
17601
|
+
validateRequest(() => assertFleetDeployRequest(operation, requestArg));
|
|
17602
|
+
const peer = peerFromLocalData(toolsArg?.localData);
|
|
17603
|
+
return this.runOperation(peer, async () => await this.executeDeploy(`controller.deploy.${operation}`, requestArg) as never,
|
|
17604
|
+
toolsArg?.abortSignal);
|
|
17605
|
+
});
|
|
17606
|
+
}
|
|
17607
|
+
}
|
|
17608
|
+
|
|
17436
17609
|
private registerSessionFeedHandlers(protectedRouterArg: ControllerProtectedRouter): void {
|
|
17437
17610
|
protectedRouterArg.addHandler<IReq_ControllerSessionFeedList>(
|
|
17438
17611
|
'controller.sessionfeed.list',
|
|
@@ -18075,6 +18248,16 @@ export class OpenCodeController {
|
|
|
18075
18248
|
})), toolsArg?.abortSignal);
|
|
18076
18249
|
},
|
|
18077
18250
|
);
|
|
18251
|
+
protectedRouterArg.addHandler<IReq_ControllerDirectReportPreflight>(
|
|
18252
|
+
'controller.directreport.preflight',
|
|
18253
|
+
async (requestArg, toolsArg) => {
|
|
18254
|
+
const request = validateRequest(() => assertDirectReportPreflightRequest(requestArg));
|
|
18255
|
+
const peer = peerFromLocalData(toolsArg?.localData);
|
|
18256
|
+
return this.runOperation(peer, (signalArg) => serve(signalArg, async (ownerArg) => (
|
|
18257
|
+
await this.requireDirectReports().preflight(ownerArg, request)
|
|
18258
|
+
)), toolsArg?.abortSignal);
|
|
18259
|
+
},
|
|
18260
|
+
);
|
|
18078
18261
|
protectedRouterArg.addHandler<IReq_ControllerDirectReportRetire>(
|
|
18079
18262
|
'controller.directreport.retire',
|
|
18080
18263
|
async (requestArg, toolsArg) => {
|
|
@@ -18107,11 +18290,10 @@ export class OpenCodeController {
|
|
|
18107
18290
|
if (channel.kind === 'session') {
|
|
18108
18291
|
if (attachments) {
|
|
18109
18292
|
throw new plugins.typedrequest.TypedResponseError(
|
|
18110
|
-
'A Codex thread report takes text only
|
|
18293
|
+
'A Codex thread report takes text only.', { code: 'invalid_request' },
|
|
18111
18294
|
);
|
|
18112
18295
|
}
|
|
18113
|
-
const { delivery, turnId } = await this.messageDirectReportSession(channel, 'owner', peer.id,
|
|
18114
|
-
text, expectedTurnId, signalArg);
|
|
18296
|
+
const { delivery, turnId } = await this.messageDirectReportSession(channel, 'owner', peer.id, text, expectedTurnId);
|
|
18115
18297
|
return { delivery, ...(turnId === undefined ? {} : { turnId }) };
|
|
18116
18298
|
}
|
|
18117
18299
|
if (expectedTurnId !== undefined) throw new Error('expectedTurnId names the turn of a Codex thread; a fleet worker report is steered through its ticket.');
|
|
@@ -18205,37 +18387,38 @@ export class OpenCodeController {
|
|
|
18205
18387
|
}
|
|
18206
18388
|
const text = String(inputArg.text), expectedTurnId = typeof inputArg.expectedTurnId === 'string' ? inputArg.expectedTurnId : undefined;
|
|
18207
18389
|
const channel = await directReports.channelOf(owner, name);
|
|
18208
|
-
if (channel.kind === 'session') return await this.messageDirectReportSession(channel, 'driver', peerId, text, expectedTurnId
|
|
18390
|
+
if (channel.kind === 'session') return await this.messageDirectReportSession(channel, 'driver', peerId, text, expectedTurnId);
|
|
18209
18391
|
if (expectedTurnId !== undefined) throw new Error('expectedTurnId names the turn of a Codex thread; a fleet worker report is steered through its ticket.');
|
|
18210
18392
|
return await this.requireFleetWorkers().execute('steer', { messages: [{ name: channel.workerName, text }], ticketKey: channel.report.driverTicketKey },
|
|
18211
18393
|
configuration, owner, signalArg, actorArg);
|
|
18212
18394
|
}
|
|
18213
18395
|
|
|
18214
18396
|
/**
|
|
18215
|
-
* The newest `limit` bundles of the active direct report `name`: its fleet worker's transcript, or
|
|
18216
|
-
*
|
|
18397
|
+
* The newest `limit` bundles of the active direct report `name`: its fleet worker's transcript, or its Codex thread
|
|
18398
|
+
* read through the shared server that owns it, outside every project, as a session read audited for `peerIdArg`.
|
|
18217
18399
|
*/
|
|
18218
18400
|
private async readDirectReport(ownerArg: string, nameArg: string, limitArg: number, peerIdArg: string, signalArg: AbortSignal): Promise<TDirectReportPage> {
|
|
18219
18401
|
const channel = await this.requireDirectReports().channelOf(ownerArg, nameArg);
|
|
18220
18402
|
if (channel.kind === 'fleet-worker') {
|
|
18221
18403
|
return { kind: 'fleet-worker', report: nameArg, ...await this.requireFleetWorkers().history(ownerArg, channel.workerName, limitArg, signalArg) };
|
|
18222
18404
|
}
|
|
18223
|
-
const {
|
|
18405
|
+
const { nativeId, cwd } = channel, sessionId: IControllerRuntimeId = { harnessId: 'codex', nativeId };
|
|
18224
18406
|
return await this.runAudited({ type: 'session.read', peerId: peerIdArg, sessionId }, async () => {
|
|
18225
|
-
|
|
18226
|
-
const page = await
|
|
18227
|
-
|
|
18407
|
+
const fleetWorkers = this.requireFleetWorkers(), native = { nativeId, cwd };
|
|
18408
|
+
const [page, turnId] = await Promise.all([fleetWorkers.nativeHistory('codex', native, limitArg), fleetWorkers.nativeTurn('codex', native)]);
|
|
18409
|
+
signalArg.throwIfAborted();
|
|
18228
18410
|
return {
|
|
18229
|
-
kind: 'session' as const, report: nameArg,
|
|
18230
|
-
|
|
18411
|
+
kind: 'session' as const, report: nameArg, sessionId, cwd, bundles: page.bundles, earlier: page.earlier,
|
|
18412
|
+
...(turnId === undefined ? {} : { turnId }),
|
|
18231
18413
|
};
|
|
18232
18414
|
});
|
|
18233
18415
|
}
|
|
18234
18416
|
|
|
18235
18417
|
/**
|
|
18236
|
-
* Sends a direct report's Codex thread a message from the owner or the Driver as
|
|
18237
|
-
*
|
|
18238
|
-
* another Codex client runs takes it only with `expectedTurnIdArg`.
|
|
18418
|
+
* Sends a direct report's Codex thread a message from the owner or the Driver as an agent message, behind the header
|
|
18419
|
+
* naming its sender, through the shared server that owns the thread: steered into the running turn or else the next
|
|
18420
|
+
* one. A turn another Codex client runs takes it only with `expectedTurnIdArg`. The report is the owner's, reached
|
|
18421
|
+
* outside every project, so no project's agent message switch applies.
|
|
18239
18422
|
*/
|
|
18240
18423
|
private async messageDirectReportSession(
|
|
18241
18424
|
channelArg: Extract<TDirectReportChannel, { kind: 'session' }>,
|
|
@@ -18243,34 +18426,33 @@ export class OpenCodeController {
|
|
|
18243
18426
|
peerIdArg: string,
|
|
18244
18427
|
textArg: string,
|
|
18245
18428
|
expectedTurnIdArg: string | undefined,
|
|
18246
|
-
signalArg: AbortSignal,
|
|
18247
18429
|
): Promise<IReq_ControllerMcpSessionMessage['response']> {
|
|
18248
|
-
const {
|
|
18249
|
-
const
|
|
18250
|
-
return await this.runAudited(
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18430
|
+
const { nativeId, cwd } = channelArg, sessionId: IControllerRuntimeId = { harnessId: 'codex', nativeId };
|
|
18431
|
+
const label = fromArg === 'owner' ? 'Owner' : 'Driver';
|
|
18432
|
+
return await this.runAudited({ type: 'session.message', peerId: peerIdArg, sessionId, senderLabel: label }, async () => {
|
|
18433
|
+
if (Buffer.byteLength(textArg, 'utf8') > controllerAgentMessageMaxTextBytes) {
|
|
18434
|
+
throw new plugins.typedrequest.TypedResponseError(
|
|
18435
|
+
`An agent message holds at most ${controllerAgentMessageMaxTextBytes / 1024} KiB of text.`,
|
|
18436
|
+
{ code: 'invalid_request' },
|
|
18437
|
+
);
|
|
18438
|
+
}
|
|
18439
|
+
if (!this.agentMessageLimiter.admit(`${peerIdArg}\0\0${controllerRuntimeIdKey(sessionId)}`)) {
|
|
18440
|
+
throw new plugins.typedrequest.TypedResponseError(
|
|
18441
|
+
'Too many agent messages to this task; wait before sending another.',
|
|
18442
|
+
{ code: 'message_rate_limited' },
|
|
18443
|
+
);
|
|
18444
|
+
}
|
|
18445
|
+
const sender: IControllerPromptSender = { kind: 'agent', label, subject: agentMessageSubjects[fromArg] };
|
|
18446
|
+
try {
|
|
18447
|
+
const receipt = await this.requireFleetWorkers().nativeSend('codex', { nativeId, cwd }, formatAgentMessage(sender, textArg), () => {}, {
|
|
18448
|
+
agentMessage: true, ...(expectedTurnIdArg === undefined ? {} : { expectedTurnId: expectedTurnIdArg }),
|
|
18449
|
+
});
|
|
18450
|
+
return { accepted: true as const, delivery: receipt.steered ? 'steer' as const : 'next-turn' as const, ...(receipt.turnId === undefined ? {} : { turnId: receipt.turnId }) };
|
|
18451
|
+
} catch (errorArg) {
|
|
18452
|
+
if (errorArg instanceof FleetNativeTurnError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
|
|
18453
|
+
throw errorArg;
|
|
18454
|
+
}
|
|
18455
|
+
});
|
|
18274
18456
|
}
|
|
18275
18457
|
|
|
18276
18458
|
/**
|
|
@@ -18312,6 +18494,8 @@ export class OpenCodeController {
|
|
|
18312
18494
|
result = await this.executeDriverNotes(route.operation, payloadArg, input, signalArg);
|
|
18313
18495
|
} else if (route.kind === 'directreport') {
|
|
18314
18496
|
result = await this.executeDriverDirectReport(route.operation, input, actor, signalArg);
|
|
18497
|
+
} else if (route.kind === 'deploy') {
|
|
18498
|
+
result = await this.executeDeploy(`driver.deploy.${route.operation}`, input);
|
|
18315
18499
|
} else {
|
|
18316
18500
|
const { owner, configuration } = await this.readFleetScope();
|
|
18317
18501
|
if (route.kind === 'worker') {
|
|
@@ -18324,12 +18508,7 @@ export class OpenCodeController {
|
|
|
18324
18508
|
} else if (route.operation === 'status') {
|
|
18325
18509
|
result = this.requireFleetService().status(String(input.id), owner, ticketKey);
|
|
18326
18510
|
} else {
|
|
18327
|
-
|
|
18328
|
-
await this.ticketStore.execute('get', { ticketId: ticketKey }, actor, signalArg);
|
|
18329
|
-
}
|
|
18330
|
-
result = this.requireFleetService().submit(
|
|
18331
|
-
route.operation, input as unknown as TFleetRequest<typeof route.operation>, await this.discoverFleetScope(configuration), owner, actor,
|
|
18332
|
-
);
|
|
18511
|
+
result = await this.submitFleetOperation(route.operation, input, configuration, owner, actor, signalArg);
|
|
18333
18512
|
}
|
|
18334
18513
|
}
|
|
18335
18514
|
const json = JSON.stringify(result ?? null);
|
|
@@ -1528,20 +1528,7 @@ export class ControllerHarnessOperationManager {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
const token = plugins.crypto.randomBytes(16).toString('base64url');
|
|
1530
1530
|
this.operationBarrier = { token, ...(harnessIdArg ? { harnessId: harnessIdArg } : {}) };
|
|
1531
|
-
const operations =
|
|
1532
|
-
harnessIdArg === undefined || operation.reservation.sessionId.harnessId === harnessIdArg
|
|
1533
|
-
));
|
|
1534
|
-
const sessionsByKey = new Map<string, {
|
|
1535
|
-
projectId: string;
|
|
1536
|
-
sessionId: IControllerRuntimeId;
|
|
1537
|
-
}>();
|
|
1538
|
-
for (const operation of operations) {
|
|
1539
|
-
const { projectId, sessionId } = operation.reservation;
|
|
1540
|
-
sessionsByKey.set(this.sessionKey(projectId, sessionId), {
|
|
1541
|
-
projectId,
|
|
1542
|
-
sessionId: { ...sessionId },
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1531
|
+
const { operations, sessionsByKey } = this.activeSessions(harnessIdArg);
|
|
1545
1532
|
if (sessionsByKey.size > maximumSessionsArg) {
|
|
1546
1533
|
this.operationBarrier = undefined;
|
|
1547
1534
|
throw new ControllerHarnessOperationLimitError(
|
|
@@ -1556,6 +1543,25 @@ export class ControllerHarnessOperationManager {
|
|
|
1556
1543
|
};
|
|
1557
1544
|
}
|
|
1558
1545
|
|
|
1546
|
+
/**
|
|
1547
|
+
* The sessions with work admitted and not settled, of one harness or of all: the sessions an upgrade must stop. The
|
|
1548
|
+
* AGL controller's deploy target reads their number: it is upgraded only when none is busy (AGL-909).
|
|
1549
|
+
*/
|
|
1550
|
+
public activeSessions(harnessIdArg?: TControllerSessionHarnessId): {
|
|
1551
|
+
operations: IActiveHarnessOperation[];
|
|
1552
|
+
sessionsByKey: Map<string, { projectId: string; sessionId: IControllerRuntimeId }>;
|
|
1553
|
+
} {
|
|
1554
|
+
const operations = [...this.operationsBySession.values()].flat().filter((operation) => (
|
|
1555
|
+
harnessIdArg === undefined || operation.reservation.sessionId.harnessId === harnessIdArg
|
|
1556
|
+
));
|
|
1557
|
+
const sessionsByKey = new Map<string, { projectId: string; sessionId: IControllerRuntimeId }>();
|
|
1558
|
+
for (const operation of operations) {
|
|
1559
|
+
const { projectId, sessionId } = operation.reservation;
|
|
1560
|
+
sessionsByKey.set(this.sessionKey(projectId, sessionId), { projectId, sessionId: { ...sessionId } });
|
|
1561
|
+
}
|
|
1562
|
+
return { operations, sessionsByKey };
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1559
1565
|
public beginUpgradeBarrier(maximumSessionsArg = 64): IControllerHarnessOperationBarrier {
|
|
1560
1566
|
const barrier = this.beginOperationBarrier(undefined, maximumSessionsArg);
|
|
1561
1567
|
this.operationBarrier!.upgrade = true;
|
package/ts/classes.mcpclient.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { assertFleetOperation, assertFleetWireRequest } from './fleet/functions.
|
|
|
9
9
|
import { readTicketRevisionConflict, ticketErrorMessages, type TTicketClientErrorCode, type TTicketOperation, type TTicketRequest, type TTicketResponse } from '../ts_interfaces/tickets.js';
|
|
10
10
|
import { assertMcpTicketRequest, assertTicketResponse } from './functions.ticketvalidation.js';
|
|
11
11
|
import { assertSessionFeedWireRequest, assertSessionFeedWireResponse } from './functions.sessionfeedvalidation.js';
|
|
12
|
+
import { assertFleetDeployResponse, assertFleetDeployWireRequest } from './fleet/functions.deployvalidation.js';
|
|
13
|
+
import type { IFleetDeployOperations, TFleetDeployOperation } from '../ts_interfaces/deployments.js';
|
|
12
14
|
import type { IReq_ControllerMcpSessionFeedAcknowledge, IReq_ControllerMcpSessionFeedList } from '../ts_interfaces/sessionfeed.js';
|
|
13
15
|
import {
|
|
14
16
|
controllerMcpSessionDetailFields,
|
|
@@ -338,6 +340,10 @@ const assertResponsePayload = (
|
|
|
338
340
|
assertSessionFeedWireResponse(methodArg, valueArg);
|
|
339
341
|
return;
|
|
340
342
|
}
|
|
343
|
+
if (methodArg.startsWith('agl.mcp.deploy.')) {
|
|
344
|
+
assertFleetDeployResponse(methodArg, valueArg);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
341
347
|
if (methodArg.startsWith('agl.mcp.ticket.')) {
|
|
342
348
|
assertTicketResponse(methodArg, valueArg);
|
|
343
349
|
return;
|
|
@@ -719,7 +725,7 @@ export class ControllerMcpClient {
|
|
|
719
725
|
const method = `agl.mcp.ticket.${methodArg}` as const;
|
|
720
726
|
const request = assertMcpTicketRequest(method, requestArg);
|
|
721
727
|
return this.dispatchAfterHandshake(method, request as never, signalArg,
|
|
722
|
-
['create', 'update', 'move', 'comment', 'link', 'ask', 'answer'].includes(methodArg)) as Promise<TTicketResponse<TMethod>>;
|
|
728
|
+
['create', 'update', 'move', 'comment', 'link', 'unlink', 'ask', 'answer'].includes(methodArg)) as Promise<TTicketResponse<TMethod>>;
|
|
723
729
|
}
|
|
724
730
|
|
|
725
731
|
public async fleetWorker<T extends TFleetWorkerAction>(action: T, request: TFleetWorkerRequest<T> & { ownerToken: string }, signal?: AbortSignal): Promise<TFleetWorkerResponse<T>> {
|
|
@@ -738,6 +744,14 @@ export class ControllerMcpClient {
|
|
|
738
744
|
const wireRequest = assertSessionFeedWireRequest('agl.mcp.sessionfeed.acknowledge', request);
|
|
739
745
|
return this.dispatchAfterHandshake('agl.mcp.sessionfeed.acknowledge', wireRequest as IReq_ControllerMcpSessionFeedAcknowledge['request'], signal, true);
|
|
740
746
|
}
|
|
747
|
+
/** Deploy status, history, a probe now or release state as the local owner reads them (`agl deploy`, `agl release status`). */
|
|
748
|
+
public async deploy<TOperation extends TFleetDeployOperation>(operation: TOperation,
|
|
749
|
+
request: IFleetDeployOperations[TOperation]['request'] & { ownerToken: string }, signal?: AbortSignal,
|
|
750
|
+
): Promise<IFleetDeployOperations[TOperation]['response']> {
|
|
751
|
+
const method = `agl.mcp.deploy.${operation}` as const;
|
|
752
|
+
const wireRequest = assertFleetDeployWireRequest(method, request);
|
|
753
|
+
return this.dispatchAfterHandshake(method, wireRequest as never, signal, operation === 'probe') as Promise<IFleetDeployOperations[TOperation]['response']>;
|
|
754
|
+
}
|
|
741
755
|
public async fleetStatus(id: string, ownerToken: string, signal?: AbortSignal, ticketKey?: string): Promise<IFleetOperation> {
|
|
742
756
|
return this.dispatchAfterHandshake('agl.mcp.fleet.status', { id, ownerToken, ...(ticketKey ? { ticketKey } : {}) }, signal, false);
|
|
743
757
|
}
|
|
@@ -916,7 +930,8 @@ export class ControllerMcpClient {
|
|
|
916
930
|
|| decoded.method !== methodArg
|
|
917
931
|
|| !plugins.util.isDeepStrictEqual(
|
|
918
932
|
decoded.request,
|
|
919
|
-
(methodArg.startsWith('agl.mcp.configuration.') || methodArg.startsWith('agl.mcp.ticket.') || methodArg.startsWith('agl.mcp.fleet.')
|
|
933
|
+
(methodArg.startsWith('agl.mcp.configuration.') || methodArg.startsWith('agl.mcp.ticket.') || methodArg.startsWith('agl.mcp.fleet.')
|
|
934
|
+
|| methodArg.startsWith('agl.mcp.deploy.'))
|
|
920
935
|
? { ...requestArg, ...(Object.hasOwn(requestArg, 'ownerToken') ? { ownerToken: '[redacted]' } : {}),
|
|
921
936
|
...(methodArg === 'agl.mcp.configuration.master.save' ? { masterJson: '[redacted]' } : {}) }
|
|
922
937
|
: requestArg,
|