agl 43.0.2 → 43.0.4
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 +17 -0
- package/dist_serve/bundle.js +749 -749
- package/dist_serve/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +37 -2
- package/dist_ts/classes.claudeharness.js +19 -6
- package/dist_ts/classes.codexclientadapter.d.ts +2 -1
- package/dist_ts/classes.codexclientadapter.js +11 -6
- package/dist_ts/classes.codexprojection.d.ts +8 -1
- package/dist_ts/classes.codexprojection.js +22 -2
- package/dist_ts/classes.flexframedtransport.d.ts +16 -0
- package/dist_ts/classes.flexframedtransport.js +35 -20
- package/dist_ts/classes.flexservice.d.ts +7 -1
- package/dist_ts/classes.flexservice.js +26 -22
- package/dist_ts/classes.flexstore.js +4 -1
- package/dist_ts/classes.flexsupervisor.d.ts +10 -0
- package/dist_ts/classes.flexsupervisor.js +22 -2
- package/dist_ts/classes.sessionfeed.d.ts +20 -2
- package/dist_ts/classes.sessionfeed.js +63 -24
- package/dist_ts/fleet/classes.claudeworkers.d.ts +4 -1
- package/dist_ts/fleet/classes.claudeworkers.js +52 -6
- package/dist_ts/fleet/classes.codexworkers.d.ts +2 -1
- package/dist_ts/fleet/classes.codexworkers.js +34 -9
- package/dist_ts/fleet/classes.workers.js +9 -5
- package/dist_ts/fleet/functions.workervalidation.js +4 -2
- package/dist_ts/fleet/interfaces.workers.d.ts +27 -2
- package/dist_ts/fleet/interfaces.workers.js +7 -1
- package/dist_ts_interfaces/fleetworkers.d.ts +17 -1
- package/dist_ts_interfaces/interfaces.d.ts +20 -0
- package/dist_ts_interfaces/interfaces.js +2 -1
- package/dist_ts_interfaces/requests.fleetworkers.d.ts +11 -2
- package/dist_ts_interfaces/sessionfeed.d.ts +12 -2
- package/dist_ts_interfaces/sessionfeed.js +1 -1
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.d.ts +9 -0
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.js +24 -5
- package/dist_ts_migration/index.d.ts +1 -0
- package/dist_ts_migration/index.js +2 -1
- package/dist_ts_migration/v19_flexprojectmanagement.d.ts +3 -0
- package/dist_ts_migration/v19_flexprojectmanagement.js +3 -1
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.d.ts +44 -0
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.js +146 -0
- package/package.json +2 -2
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +36 -1
- package/ts/classes.claudeharness.ts +19 -3
- package/ts/classes.codexclientadapter.ts +9 -6
- package/ts/classes.codexprojection.ts +23 -2
- package/ts/classes.flexframedtransport.ts +42 -17
- package/ts/classes.flexservice.ts +36 -27
- package/ts/classes.flexstore.ts +6 -0
- package/ts/classes.flexsupervisor.ts +28 -1
- package/ts/classes.sessionfeed.ts +77 -29
- package/ts/fleet/classes.claudeworkers.ts +57 -9
- package/ts/fleet/classes.codexworkers.ts +35 -11
- package/ts/fleet/classes.workers.ts +8 -4
- package/ts/fleet/functions.workervalidation.ts +3 -1
- package/ts/fleet/interfaces.workers.ts +25 -2
- package/ts_interfaces/fleetworkers.ts +17 -1
- package/ts_interfaces/interfaces.ts +22 -0
- package/ts_interfaces/requests.fleetworkers.ts +11 -2
- package/ts_interfaces/sessionfeed.ts +12 -2
- package/ts_migration/classes.flexpostharnessmigrationrunner.ts +37 -5
- package/ts_migration/index.ts +1 -0
- package/ts_migration/v19_flexprojectmanagement.ts +4 -0
- package/ts_migration/v43_flexpostharnessmigrationmarkers.ts +109 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/classes.controllersocketclient.ts +10 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as plugins from './plugins.js';
|
|
2
|
-
import type { IControllerRuntimeId } from './interfaces.js';
|
|
2
|
+
import type { IControllerNativeWait, IControllerRuntimeId } from './interfaces.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The session feed: one read model of every session of every harness AGL knows — the conversations it tracks, the
|
|
@@ -8,7 +8,10 @@ import type { IControllerRuntimeId } from './interfaces.js';
|
|
|
8
8
|
* automatic session list. Its row mirrors dees-catalog's `IHarnessSessionRow` without importing it, plus where a row opens.
|
|
9
9
|
*/
|
|
10
10
|
export type TControllerSessionFeedHarness = 'claude' | 'codex' | 'flex' | 'opencode';
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* `needs_input`: a question or permission AGL holds, or a wait the harness signals in its own client, waits for the
|
|
13
|
+
* owner; `failed`: the session reports an error, its newest turn failed or it is gone.
|
|
14
|
+
*/
|
|
12
15
|
export type TControllerSessionFeedState = 'needs_input' | 'working' | 'completed' | 'failed';
|
|
13
16
|
export const controllerSessionFeedStates: readonly TControllerSessionFeedState[] = ['needs_input', 'working', 'completed', 'failed'];
|
|
14
17
|
|
|
@@ -42,6 +45,13 @@ export interface IControllerSessionFeedRow {
|
|
|
42
45
|
/** Unix milliseconds of the session's last activity. */
|
|
43
46
|
updatedAt: number;
|
|
44
47
|
open: TControllerSessionFeedOpen;
|
|
48
|
+
/**
|
|
49
|
+
* On a `needs_input` row AGL holds no question or permission for: the harness waits in its own client, which AGL
|
|
50
|
+
* cannot answer, for `reason`. A `needs_input` row without it holds a request the owner answers in AGL.
|
|
51
|
+
*/
|
|
52
|
+
nativeWait?: IControllerNativeWait;
|
|
53
|
+
/** On a `completed` row: its newest turn was interrupted. */
|
|
54
|
+
interrupted?: true;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
@@ -1,22 +1,54 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
FlexProjectManagementMigration,
|
|
4
|
+
flexProjectManagementMigrationId,
|
|
5
|
+
} from './v19_flexprojectmanagement.js';
|
|
6
|
+
import type {
|
|
7
|
+
IFlexPostHarnessMigrationMarkers,
|
|
8
|
+
TFlexPostHarnessMigrationId,
|
|
9
|
+
} from './v43_flexpostharnessmigrationmarkers.js';
|
|
3
10
|
|
|
4
11
|
export interface IFlexPostHarnessMigrationRunnerOptions<TScope> {
|
|
5
12
|
harness: plugins.flexharness.FlexHarness<TScope>;
|
|
13
|
+
/** The storage keys each migration already completed for, which it never walks again. */
|
|
14
|
+
markers: IFlexPostHarnessMigrationMarkers;
|
|
6
15
|
scopeIds: Iterable<string>;
|
|
7
16
|
}
|
|
8
17
|
|
|
18
|
+
interface IFlexPostHarnessMigration {
|
|
19
|
+
readonly id: TFlexPostHarnessMigrationId;
|
|
20
|
+
run(scopeIdArg: string, signalArg?: AbortSignal): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs each post-harness migration for every storage key it has not completed for, and records
|
|
25
|
+
* the completion only once the key's walk finished: a failed or aborted walk records nothing.
|
|
26
|
+
*/
|
|
9
27
|
export class FlexPostHarnessMigrationRunner<TScope> {
|
|
10
|
-
private readonly
|
|
28
|
+
private readonly markers: IFlexPostHarnessMigrationMarkers;
|
|
29
|
+
private readonly scopeIds: string[];
|
|
30
|
+
private readonly migrations: IFlexPostHarnessMigration[];
|
|
11
31
|
|
|
12
32
|
constructor(optionsArg: IFlexPostHarnessMigrationRunnerOptions<TScope>) {
|
|
13
|
-
this.
|
|
33
|
+
this.markers = optionsArg.markers;
|
|
34
|
+
this.scopeIds = [...new Set(optionsArg.scopeIds)].sort();
|
|
35
|
+
this.migrations = [{
|
|
36
|
+
id: flexProjectManagementMigrationId,
|
|
37
|
+
run: (scopeIdArg, signalArg) => new FlexProjectManagementMigration({
|
|
38
|
+
harness: optionsArg.harness,
|
|
39
|
+
scopeIds: [scopeIdArg],
|
|
40
|
+
}).run(signalArg),
|
|
41
|
+
}];
|
|
14
42
|
}
|
|
15
43
|
|
|
16
44
|
public async run(signalArg?: AbortSignal): Promise<void> {
|
|
17
45
|
for (const migration of this.migrations) {
|
|
18
|
-
|
|
19
|
-
|
|
46
|
+
for (const scopeId of this.scopeIds) {
|
|
47
|
+
signalArg?.throwIfAborted();
|
|
48
|
+
if (await this.markers.completed(scopeId, migration.id)) continue;
|
|
49
|
+
await migration.run(scopeId, signalArg);
|
|
50
|
+
await this.markers.record(scopeId, migration.id);
|
|
51
|
+
}
|
|
20
52
|
}
|
|
21
53
|
}
|
|
22
54
|
}
|
package/ts_migration/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
+
import type { TFlexPostHarnessMigrationId } from './v43_flexpostharnessmigrationmarkers.js';
|
|
3
|
+
|
|
4
|
+
/** The name its completion is recorded under (`FlexPostHarnessMigrationMarkers`). */
|
|
5
|
+
export const flexProjectManagementMigrationId: TFlexPostHarnessMigrationId = 'v19_flexprojectmanagement';
|
|
2
6
|
|
|
3
7
|
export interface IFlexProjectManagementMigrationOptions<TScope> {
|
|
4
8
|
harness: plugins.flexharness.FlexHarness<TScope>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
|
|
3
|
+
/** The Flex migrations that run through FlexHarness once the harness is up, by name. */
|
|
4
|
+
export type TFlexPostHarnessMigrationId = 'v19_flexprojectmanagement';
|
|
5
|
+
|
|
6
|
+
/** One post-harness migration that completed for one storage key (a Flex project). */
|
|
7
|
+
export interface IFlexPostHarnessMigrationMarkerDocument {
|
|
8
|
+
/** `flexPostHarnessMigrationMarkerId(controllerId, storageKey, migration)`. */
|
|
9
|
+
id: string;
|
|
10
|
+
controllerId: string;
|
|
11
|
+
storageKey: string;
|
|
12
|
+
/** The migration's name, such as `v19_flexprojectmanagement`. */
|
|
13
|
+
migration: string;
|
|
14
|
+
completedAt: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const markerSchema = plugins.z.object({
|
|
18
|
+
id: plugins.z.string().regex(/^flex-post-harness-migration:[0-9a-f]{64}$/u),
|
|
19
|
+
controllerId: plugins.z.string().min(1).max(512),
|
|
20
|
+
storageKey: plugins.z.string().min(1).max(512),
|
|
21
|
+
migration: plugins.z.string().regex(/^v[0-9]+_[a-z0-9]+$/u),
|
|
22
|
+
completedAt: plugins.z.iso.datetime(),
|
|
23
|
+
}).strict();
|
|
24
|
+
|
|
25
|
+
export const flexPostHarnessMigrationMarkerId = (
|
|
26
|
+
controllerIdArg: string,
|
|
27
|
+
storageKeyArg: string,
|
|
28
|
+
migrationArg: TFlexPostHarnessMigrationId,
|
|
29
|
+
): string => `flex-post-harness-migration:${plugins.crypto.createHash('sha256')
|
|
30
|
+
.update(controllerIdArg, 'utf8')
|
|
31
|
+
.update('\0', 'utf8')
|
|
32
|
+
.update(storageKeyArg, 'utf8')
|
|
33
|
+
.update('\0', 'utf8')
|
|
34
|
+
.update(migrationArg, 'utf8')
|
|
35
|
+
.digest('hex')}`;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* One record per post-harness migration and storage key, written once the migration walked every
|
|
39
|
+
* session of that key: a key with a marker is never walked again, by any later Flex child. A walk
|
|
40
|
+
* that failed or was aborted records nothing, so the next registration walks the key again.
|
|
41
|
+
*/
|
|
42
|
+
@plugins.nosqldb.managed({ collectionName: 'flex_post_harness_migrations' })
|
|
43
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: (input: unknown) => { markerSchema.parse(input); } })
|
|
44
|
+
export class FlexPostHarnessMigrationMarkerModel extends plugins.nosqldb.SmartDataDbDoc<
|
|
45
|
+
FlexPostHarnessMigrationMarkerModel,
|
|
46
|
+
IFlexPostHarnessMigrationMarkerDocument
|
|
47
|
+
> {
|
|
48
|
+
declare static exact: plugins.nosqldb.TExact<FlexPostHarnessMigrationMarkerModel>;
|
|
49
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
50
|
+
@plugins.nosqldb.svDb() public controllerId!: string;
|
|
51
|
+
@plugins.nosqldb.svDb() public storageKey!: string;
|
|
52
|
+
@plugins.nosqldb.svDb() public migration!: string;
|
|
53
|
+
@plugins.nosqldb.svDb() public completedAt!: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const registerFlexPostHarnessMigrationMarkerModel = (
|
|
57
|
+
managerArg: { db: plugins.nosqldb.SmartdataDb },
|
|
58
|
+
): void => {
|
|
59
|
+
plugins.nosqldb.setDefaultManagerForDoc(managerArg, FlexPostHarnessMigrationMarkerModel);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const initFlexPostHarnessMigrationMarkerModel = async (): Promise<void> => {
|
|
63
|
+
await FlexPostHarnessMigrationMarkerModel.exact.prepare();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Which post-harness migrations completed for a storage key; see `FlexPostHarnessMigrationRunner`. */
|
|
67
|
+
export interface IFlexPostHarnessMigrationMarkers {
|
|
68
|
+
completed(storageKeyArg: string, migrationArg: TFlexPostHarnessMigrationId): Promise<boolean>;
|
|
69
|
+
/** Records the completion; recording one that is already recorded changes nothing. */
|
|
70
|
+
record(storageKeyArg: string, migrationArg: TFlexPostHarnessMigrationId): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The markers of one controller, in its Flex database's `flex_post_harness_migrations`. */
|
|
74
|
+
export class FlexPostHarnessMigrationMarkers implements IFlexPostHarnessMigrationMarkers {
|
|
75
|
+
constructor(private readonly controllerId: string) {}
|
|
76
|
+
|
|
77
|
+
public async completed(
|
|
78
|
+
storageKeyArg: string,
|
|
79
|
+
migrationArg: TFlexPostHarnessMigrationId,
|
|
80
|
+
): Promise<boolean> {
|
|
81
|
+
const id = flexPostHarnessMigrationMarkerId(this.controllerId, storageKeyArg, migrationArg);
|
|
82
|
+
const stored = await FlexPostHarnessMigrationMarkerModel.exact.findStoredOne({ id });
|
|
83
|
+
if (!stored) return false;
|
|
84
|
+
const marker = FlexPostHarnessMigrationMarkerModel.exact.toPersisted(stored);
|
|
85
|
+
if (
|
|
86
|
+
marker.controllerId !== this.controllerId
|
|
87
|
+
|| marker.storageKey !== storageKeyArg
|
|
88
|
+
|| marker.migration !== migrationArg
|
|
89
|
+
) throw new Error('The Flex post-harness migration marker names another migration.');
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public async record(
|
|
94
|
+
storageKeyArg: string,
|
|
95
|
+
migrationArg: TFlexPostHarnessMigrationId,
|
|
96
|
+
): Promise<void> {
|
|
97
|
+
const inserted = await FlexPostHarnessMigrationMarkerModel.exact.insert({
|
|
98
|
+
id: flexPostHarnessMigrationMarkerId(this.controllerId, storageKeyArg, migrationArg),
|
|
99
|
+
controllerId: this.controllerId,
|
|
100
|
+
storageKey: storageKeyArg,
|
|
101
|
+
migration: migrationArg,
|
|
102
|
+
completedAt: new Date().toISOString(),
|
|
103
|
+
});
|
|
104
|
+
// A conflict is a marker with the same id recorded earlier, with its own completion time.
|
|
105
|
+
if (inserted.status === 'conflict' && !await this.completed(storageKeyArg, migrationArg)) {
|
|
106
|
+
throw new Error('The Flex post-harness migration marker could not be recorded.');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -527,8 +527,9 @@ export const isControllerWorkspaceChanged = (
|
|
|
527
527
|
};
|
|
528
528
|
|
|
529
529
|
const sessionFeedRowKeys = contractKeys<interfaces.IControllerSessionFeedRow>({
|
|
530
|
-
id: true, harness: true, state: true, name: true, excerpt: true, tickets: true, updatedAt: true, open: true,
|
|
530
|
+
id: true, harness: true, state: true, name: true, excerpt: true, tickets: true, updatedAt: true, open: true, nativeWait: true, interrupted: true,
|
|
531
531
|
});
|
|
532
|
+
const nativeWaitReasons: ReadonlySet<unknown> = new Set(interfaces.controllerNativeWaitReasons);
|
|
532
533
|
const sessionFeedTicketKeys = contractKeys<interfaces.IControllerSessionFeedTicket>({ key: true, title: true });
|
|
533
534
|
const sessionFeedHarnesses: ReadonlySet<string> = new Set<interfaces.TControllerSessionFeedHarness>(['claude', 'codex', 'flex', 'opencode']);
|
|
534
535
|
const sessionFeedStates: ReadonlySet<string> = new Set(interfaces.controllerSessionFeedStates);
|
|
@@ -577,7 +578,14 @@ export const isControllerSessionFeedRow = (valueArg: unknown): valueArg is inter
|
|
|
577
578
|
})
|
|
578
579
|
))
|
|
579
580
|
&& typeof candidate.updatedAt === 'number' && Number.isFinite(candidate.updatedAt) && candidate.updatedAt >= 0
|
|
580
|
-
&& isSessionFeedOpen(candidate.open)
|
|
581
|
+
&& isSessionFeedOpen(candidate.open)
|
|
582
|
+
&& (candidate.nativeWait === undefined || (
|
|
583
|
+
candidate.state === 'needs_input'
|
|
584
|
+
&& typeof candidate.nativeWait === 'object' && candidate.nativeWait !== null && !Array.isArray(candidate.nativeWait)
|
|
585
|
+
&& Object.keys(candidate.nativeWait).every((keyArg) => keyArg === 'reason')
|
|
586
|
+
&& nativeWaitReasons.has(candidate.nativeWait.reason)
|
|
587
|
+
))
|
|
588
|
+
&& (candidate.interrupted === undefined || (candidate.interrupted === true && candidate.state === 'completed'));
|
|
581
589
|
};
|
|
582
590
|
|
|
583
591
|
export const isControllerSessionFeedDelta = (valueArg: unknown): valueArg is interfaces.TControllerSessionFeedDelta => {
|