agl 43.0.3 → 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.
Files changed (30) hide show
  1. package/changelog.md +11 -0
  2. package/dist_serve/bundle.js +1 -1
  3. package/dist_serve/bundle.js.map +1 -1
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/classes.flexframedtransport.d.ts +16 -0
  6. package/dist_ts/classes.flexframedtransport.js +35 -20
  7. package/dist_ts/classes.flexservice.d.ts +7 -1
  8. package/dist_ts/classes.flexservice.js +26 -22
  9. package/dist_ts/classes.flexstore.js +4 -1
  10. package/dist_ts/classes.flexsupervisor.d.ts +10 -0
  11. package/dist_ts/classes.flexsupervisor.js +22 -2
  12. package/dist_ts_migration/classes.flexpostharnessmigrationrunner.d.ts +9 -0
  13. package/dist_ts_migration/classes.flexpostharnessmigrationrunner.js +24 -5
  14. package/dist_ts_migration/index.d.ts +1 -0
  15. package/dist_ts_migration/index.js +2 -1
  16. package/dist_ts_migration/v19_flexprojectmanagement.d.ts +3 -0
  17. package/dist_ts_migration/v19_flexprojectmanagement.js +3 -1
  18. package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.d.ts +44 -0
  19. package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.js +146 -0
  20. package/package.json +1 -1
  21. package/ts/00_commitinfo_data.ts +1 -1
  22. package/ts/classes.flexframedtransport.ts +42 -17
  23. package/ts/classes.flexservice.ts +36 -27
  24. package/ts/classes.flexstore.ts +6 -0
  25. package/ts/classes.flexsupervisor.ts +28 -1
  26. package/ts_migration/classes.flexpostharnessmigrationrunner.ts +37 -5
  27. package/ts_migration/index.ts +1 -0
  28. package/ts_migration/v19_flexprojectmanagement.ts +4 -0
  29. package/ts_migration/v43_flexpostharnessmigrationmarkers.ts +109 -0
  30. package/ts_web/00_commitinfo_data.ts +1 -1
@@ -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
+ }
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.0.3',
6
+ version: '43.0.4',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }