agl 44.0.1 → 44.0.3

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.
@@ -135,6 +135,8 @@ interface IFlexPendingRequest {
135
135
  cancellationGraceTimeout?: NodeJS.Timeout;
136
136
  cancelled?: true;
137
137
  dispatched?: true;
138
+ dispatchedAt?: number;
139
+ cancelledAt?: number;
138
140
  }
139
141
 
140
142
  interface IFlexChildLifecycle {
@@ -817,6 +819,12 @@ export class FlexSupervisor {
817
819
  this.handleProtocolFailure();
818
820
  return;
819
821
  }
822
+ if (pending.method === 'session.get' && pending.dispatchedAt !== undefined) {
823
+ const elapsedMs = Date.now() - pending.dispatchedAt;
824
+ if (pending.cancelledAt !== undefined || elapsedMs >= 2_000) {
825
+ this.reportSessionGetTiming(messageArg.requestId, pending, 'response', elapsedMs);
826
+ }
827
+ }
820
828
  this.clearPendingRequest(messageArg.requestId, pending);
821
829
  if (pending.cancelled) return;
822
830
  if (!messageArg.ok) {
@@ -1266,6 +1274,7 @@ export class FlexSupervisor {
1266
1274
  }
1267
1275
  if (this.pendingRequests.get(requestId) !== pending || pending.cancelled) return;
1268
1276
  pending.dispatched = true;
1277
+ pending.dispatchedAt = Date.now();
1269
1278
  void transport.send(createMessageArg(requestId)).catch((errorArg: unknown) => {
1270
1279
  const pending = this.pendingRequests.get(requestId);
1271
1280
  if (errorArg instanceof FlexIpcNotSentError) {
@@ -1309,6 +1318,15 @@ export class FlexSupervisor {
1309
1318
  pendingArg.abortListener = undefined;
1310
1319
  }
1311
1320
  pendingArg.cancelled = true;
1321
+ pendingArg.cancelledAt = Date.now();
1322
+ if (pendingArg.method === 'session.get' && pendingArg.dispatchedAt !== undefined) {
1323
+ this.reportSessionGetTiming(
1324
+ requestIdArg,
1325
+ pendingArg,
1326
+ 'cancel_issued',
1327
+ pendingArg.cancelledAt - pendingArg.dispatchedAt,
1328
+ );
1329
+ }
1312
1330
  pendingArg.reject(rejectionArg);
1313
1331
  if (!pendingArg.dispatched) {
1314
1332
  this.clearPendingRequest(requestIdArg, pendingArg);
@@ -1316,10 +1334,17 @@ export class FlexSupervisor {
1316
1334
  }
1317
1335
  pendingArg.cancellationGraceTimeout = setTimeout(() => {
1318
1336
  if (this.pendingRequests.get(requestIdArg) !== pendingArg) return;
1337
+ const elapsedMs = pendingArg.dispatchedAt === undefined
1338
+ ? undefined
1339
+ : Date.now() - pendingArg.dispatchedAt;
1340
+ if (pendingArg.method === 'session.get' && elapsedMs !== undefined) {
1341
+ this.reportSessionGetTiming(requestIdArg, pendingArg, 'cancel_grace_expired', elapsedMs);
1342
+ }
1319
1343
  this.clearPendingRequest(requestIdArg, pendingArg);
1320
1344
  this.failClosedChildGeneration(
1321
1345
  new Error(
1322
- `The Flex child did not settle a cancelled ${pendingArg.method ?? pendingArg.kind} request within ${this.cancellationGraceTimeoutMs} ms.`,
1346
+ `The Flex child did not settle a cancelled ${pendingArg.method ?? pendingArg.kind} request within ${this.cancellationGraceTimeoutMs} ms.`
1347
+ + (elapsedMs === undefined ? '' : ` Request age: ${elapsedMs} ms; request ID: ${requestIdArg}.`),
1323
1348
  ),
1324
1349
  transportArg,
1325
1350
  childArg,
@@ -1343,6 +1368,30 @@ export class FlexSupervisor {
1343
1368
  });
1344
1369
  }
1345
1370
 
1371
+ /** Only method and timing cross into the controller log; request payloads never do. */
1372
+ private reportSessionGetTiming(
1373
+ requestIdArg: string,
1374
+ pendingArg: IFlexPendingRequest,
1375
+ eventArg: 'cancel_issued' | 'response' | 'cancel_grace_expired',
1376
+ elapsedMsArg: number,
1377
+ ): void {
1378
+ try {
1379
+ this.writeControllerLog(`Flex session.get timing: ${JSON.stringify({
1380
+ requestId: requestIdArg,
1381
+ event: eventArg,
1382
+ at: new Date().toISOString(),
1383
+ elapsedMs: elapsedMsArg,
1384
+ ...(pendingArg.cancelledAt === undefined ? {} : {
1385
+ sinceCancelMs: Date.now() - pendingArg.cancelledAt,
1386
+ }),
1387
+ pendingRequests: this.pendingRequests.size,
1388
+ childGeneration: this.childGenerations,
1389
+ })}`);
1390
+ } catch {
1391
+ // Diagnostics cannot change how a request or child generation settles.
1392
+ }
1393
+ }
1394
+
1346
1395
  private clearPendingRequest(requestIdArg: string, pendingArg: IFlexPendingRequest): void {
1347
1396
  if (this.pendingRequests.get(requestIdArg) === pendingArg) {
1348
1397
  this.pendingRequests.delete(requestIdArg);
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '44.0.1',
6
+ version: '44.0.3',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }