@xi4z/dsh-utils-approval-policy 0.10.0 → 0.11.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/lib/index.d.ts CHANGED
@@ -30,7 +30,14 @@
30
30
  * through untouched — nothing to wait for);
31
31
  * - the window expires → the configured fail-closed default settles the
32
32
  * approval ('rejected'; 'unavailable' also allowed — 'allowed-once' is
33
- * schema-forbidden). The turn proceeds denied instead of hanging;
33
+ * schema-forbidden). The turn proceeds denied instead of hanging, AND the
34
+ * request is withdrawn: the gate fuses a controller into the delegated
35
+ * request's signal, so aborting it once the request settles cancels the
36
+ * forwarded Remote prompt and the still-open Web GUI card / "awaiting
37
+ * approval" badge disappear instead of piling up as decided requests.
38
+ * Every settlement withdraws — the window default, a downstream answer
39
+ * (Web GUI / ACP / auto approval), and an outside answer reported through
40
+ * `ApprovalPolicyInfo.withdraw` (the QQ card click);
34
41
  * - the request's abort signal resolves 'cancelled' upstream — the host
35
42
  * races the signal itself; a late window expiry is simply ignored.
36
43
  *
@@ -94,6 +101,9 @@ export type GatedOutcome = 'rejected' | 'unavailable';
94
101
  * human channel (e.g. the QQ approval card) can echo the real deadline instead
95
102
  * of inventing its own TTL. `describe` reuses the exact predicate the gate
96
103
  * applies to the request, so the card and the window can never disagree.
104
+ * `withdraw` is the write side: a channel that settled the request outside the
105
+ * delegated chain reports that outcome, and every prompt still showing the
106
+ * request on the other surfaces is withdrawn.
97
107
  */
98
108
  export interface ApprovalPolicyInfo {
99
109
  describe(agent: unknown, sessionId: string): {
@@ -104,6 +114,15 @@ export interface ApprovalPolicyInfo {
104
114
  /** What the gate settles with when the window expires. */
105
115
  defaultOutcome: GatedOutcome;
106
116
  };
117
+ /**
118
+ * Settle one gate-held request from outside the delegated chain (e.g. the QQ
119
+ * card click) and withdraw the prompts the other surfaces still show for it.
120
+ * The gate then reports `outcome` instead of waiting out its own window.
121
+ * @param request - the exact waterfall request object the caller received.
122
+ * @param outcome - the decision this channel produced.
123
+ * @returns whether the gate held that request and withdrew it.
124
+ */
125
+ withdraw(request: unknown, outcome: ApprovalOutcome): boolean;
107
126
  }
108
127
  declare module '@deepseek-ai/cordis' {
109
128
  interface Context {
@@ -273,8 +292,52 @@ export interface GateSettlement {
273
292
  * because no answerer produced it. A fast `decision` (including an instant
274
293
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
275
294
  * only a pending decision races the timer.
295
+ *
296
+ * `external` is the third arm: an answer produced OUTSIDE the delegated chain
297
+ * (a human channel ahead of the gate — the QQ card — settles through
298
+ * {@link ApprovalPolicyInfo.withdraw}). It counts as a downstream answer, so
299
+ * the gate reports that outcome instead of abandoning the request to its own
300
+ * timer.
301
+ */
302
+ export declare function raceGate(decision: () => Promise<ApprovalOutcome>, windowMs: number, defaultOutcome: GatedOutcome, external?: Promise<ApprovalOutcome>): Promise<GateSettlement>;
303
+ /**
304
+ * Name carried by the abort reason the gate uses to withdraw a prompt whose
305
+ * window expired. A human channel racing the same deadline (the QQ card
306
+ * answerer) matches this name to tell the gate's own fail-closed settlement
307
+ * apart from a cancelled turn. Kept as a literal in both components on
308
+ * purpose: they are independently published packages, and this name is the
309
+ * only contract between them.
310
+ */
311
+ export declare const WINDOW_EXPIRED_ABORT = "UnattendedApprovalWindowExpired";
312
+ /** Abort reason that withdraws a pending prompt once the window expires. */
313
+ export declare function windowExpiredReason(): Error;
314
+ /**
315
+ * Name carried by the abort reason the gate uses when a request was settled
316
+ * somewhere else (a downstream answerer, another human channel through
317
+ * {@link ApprovalPolicyInfo.withdraw}) and the prompts still open on the
318
+ * remaining surfaces have to go away.
319
+ */
320
+ export declare const SETTLED_ABORT = "UnattendedApprovalSettledElsewhere";
321
+ /** Abort reason that withdraws a prompt because the request was already settled. */
322
+ export declare function settledElsewhereReason(): Error;
323
+ /**
324
+ * Make one delegated request withdrawable.
325
+ *
326
+ * A human surface (the Web GUI's forwarded Remote prompt) drops a pending
327
+ * request only when the Host cancels the Remote event, and the Host watches
328
+ * exactly the request signal it was handed. The caller's signal belongs to the
329
+ * turn — aborting it would cancel the tool call — so the gate fuses a
330
+ * controller it owns into it: aborts from the turn still propagate unchanged,
331
+ * while the gate gains a handle that withdraws the prompt at its deadline
332
+ * without cancelling anything.
333
+ *
334
+ * @param request - the borrowed waterfall request about to be delegated.
335
+ * @param withdraw - the gate-owned controller for this one request.
336
+ * @returns the fused signal now installed on the request.
276
337
  */
277
- export declare function raceGate(decision: () => Promise<ApprovalOutcome>, windowMs: number, defaultOutcome: GatedOutcome): Promise<GateSettlement>;
338
+ export declare function installWithdrawSignal(request: {
339
+ signal?: AbortSignal;
340
+ }, withdraw: AbortController): AbortSignal;
278
341
  /** Whether an approval reason was raised by the experimental auto approval. */
279
342
  export declare function isAutoReviewAsk(reason: string | undefined): boolean;
280
343
  /** One window-rejected auto-review request waiting for its tool result. */
package/lib/index.js CHANGED
@@ -30,7 +30,14 @@
30
30
  * through untouched — nothing to wait for);
31
31
  * - the window expires → the configured fail-closed default settles the
32
32
  * approval ('rejected'; 'unavailable' also allowed — 'allowed-once' is
33
- * schema-forbidden). The turn proceeds denied instead of hanging;
33
+ * schema-forbidden). The turn proceeds denied instead of hanging, AND the
34
+ * request is withdrawn: the gate fuses a controller into the delegated
35
+ * request's signal, so aborting it once the request settles cancels the
36
+ * forwarded Remote prompt and the still-open Web GUI card / "awaiting
37
+ * approval" badge disappear instead of piling up as decided requests.
38
+ * Every settlement withdraws — the window default, a downstream answer
39
+ * (Web GUI / ACP / auto approval), and an outside answer reported through
40
+ * `ApprovalPolicyInfo.withdraw` (the QQ card click);
34
41
  * - the request's abort signal resolves 'cancelled' upstream — the host
35
42
  * races the signal itself; a late window expiry is simply ignored.
36
43
  *
@@ -238,30 +245,89 @@ export function describeGate(config, agent, sessionId) {
238
245
  * because no answerer produced it. A fast `decision` (including an instant
239
246
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
240
247
  * only a pending decision races the timer.
248
+ *
249
+ * `external` is the third arm: an answer produced OUTSIDE the delegated chain
250
+ * (a human channel ahead of the gate — the QQ card — settles through
251
+ * {@link ApprovalPolicyInfo.withdraw}). It counts as a downstream answer, so
252
+ * the gate reports that outcome instead of abandoning the request to its own
253
+ * timer.
241
254
  */
242
- export async function raceGate(decision, windowMs, defaultOutcome) {
255
+ export async function raceGate(decision, windowMs, defaultOutcome, external) {
243
256
  if (windowMs <= 0)
244
257
  return { outcome: defaultOutcome, settledBy: 'window' };
245
258
  // The window timer stays REF'd on purpose: an open window means the host
246
259
  // turn is still owed an outcome, so the process must not drain the event
247
260
  // loop before it settles. It is cleared as soon as the race settles
248
- // (answer, rejection, or expiry) so a fast answer never leaves a stray
249
- // timer holding the loop for the rest of the window.
261
+ // (answer, external answer, rejection, or expiry) so a fast answer never
262
+ // leaves a stray timer holding the loop for the rest of the window.
250
263
  let timer;
251
264
  try {
252
265
  const windowSettlement = new Promise((resolve) => {
253
266
  timer = setTimeout(() => resolve({ outcome: defaultOutcome, settledBy: 'window' }), windowMs);
254
267
  });
255
- return await Promise.race([
268
+ const arms = [
256
269
  decision().then((outcome) => ({ outcome, settledBy: 'downstream' })),
257
270
  windowSettlement,
258
- ]);
271
+ ];
272
+ if (external !== undefined) {
273
+ arms.push(external.then((outcome) => ({ outcome, settledBy: 'downstream' })));
274
+ }
275
+ return await Promise.race(arms);
259
276
  }
260
277
  finally {
261
278
  if (timer !== undefined)
262
279
  clearTimeout(timer);
263
280
  }
264
281
  }
282
+ /**
283
+ * Name carried by the abort reason the gate uses to withdraw a prompt whose
284
+ * window expired. A human channel racing the same deadline (the QQ card
285
+ * answerer) matches this name to tell the gate's own fail-closed settlement
286
+ * apart from a cancelled turn. Kept as a literal in both components on
287
+ * purpose: they are independently published packages, and this name is the
288
+ * only contract between them.
289
+ */
290
+ export const WINDOW_EXPIRED_ABORT = 'UnattendedApprovalWindowExpired';
291
+ /** Abort reason that withdraws a pending prompt once the window expires. */
292
+ export function windowExpiredReason() {
293
+ const error = new Error('The unattended approval window expired, so the pending approval request was withdrawn.');
294
+ error.name = WINDOW_EXPIRED_ABORT;
295
+ return error;
296
+ }
297
+ /**
298
+ * Name carried by the abort reason the gate uses when a request was settled
299
+ * somewhere else (a downstream answerer, another human channel through
300
+ * {@link ApprovalPolicyInfo.withdraw}) and the prompts still open on the
301
+ * remaining surfaces have to go away.
302
+ */
303
+ export const SETTLED_ABORT = 'UnattendedApprovalSettledElsewhere';
304
+ /** Abort reason that withdraws a prompt because the request was already settled. */
305
+ export function settledElsewhereReason() {
306
+ const error = new Error('The approval request was already settled elsewhere, so this pending prompt was withdrawn.');
307
+ error.name = SETTLED_ABORT;
308
+ return error;
309
+ }
310
+ /**
311
+ * Make one delegated request withdrawable.
312
+ *
313
+ * A human surface (the Web GUI's forwarded Remote prompt) drops a pending
314
+ * request only when the Host cancels the Remote event, and the Host watches
315
+ * exactly the request signal it was handed. The caller's signal belongs to the
316
+ * turn — aborting it would cancel the tool call — so the gate fuses a
317
+ * controller it owns into it: aborts from the turn still propagate unchanged,
318
+ * while the gate gains a handle that withdraws the prompt at its deadline
319
+ * without cancelling anything.
320
+ *
321
+ * @param request - the borrowed waterfall request about to be delegated.
322
+ * @param withdraw - the gate-owned controller for this one request.
323
+ * @returns the fused signal now installed on the request.
324
+ */
325
+ export function installWithdrawSignal(request, withdraw) {
326
+ const original = request.signal;
327
+ const fused = original === undefined ? withdraw.signal : AbortSignal.any([original, withdraw.signal]);
328
+ request.signal = fused;
329
+ return fused;
330
+ }
265
331
  /** Whether an approval reason was raised by the experimental auto approval. */
266
332
  export function isAutoReviewAsk(reason) {
267
333
  return typeof reason === 'string' && reason.startsWith(AUTO_REVIEW_REASON_PREFIX);
@@ -367,6 +433,13 @@ export function apply(ctx, config) {
367
433
  });
368
434
  /** Window-rejected auto-review requests, keyed by tool-call id. */
369
435
  const pendingAutoReview = new Map();
436
+ /**
437
+ * Withdrawal handle per delegated request. Keyed by the request object the
438
+ * waterfall hands every listener, so an answerer that settles the request
439
+ * outside the delegated chain (the QQ card) can end the prompts that other
440
+ * surfaces still show. Weak: a request that never settles cannot leak.
441
+ */
442
+ const withdrawals = new WeakMap();
370
443
  /**
371
444
  * Publish the read-only policy view. The service is optional by design: a
372
445
  * composition without this component simply has no approvalPolicyInfo, and
@@ -376,6 +449,15 @@ export function apply(ctx, config) {
376
449
  describe(agent, sessionId) {
377
450
  return describeGate(cfgNow(), agent, sessionId);
378
451
  },
452
+ withdraw(request, outcome) {
453
+ const held = withdrawals.get(request);
454
+ if (held === undefined)
455
+ return false;
456
+ withdrawals.delete(request);
457
+ held.withdraw.abort(settledElsewhereReason());
458
+ held.settle(outcome);
459
+ return true;
460
+ },
379
461
  };
380
462
  const provideService = ctx.provide;
381
463
  if (typeof provideService === 'function') {
@@ -386,7 +468,29 @@ export function apply(ctx, config) {
386
468
  const sessionId = String(request.agent?.id ?? '');
387
469
  if (!shouldGate(cfg, sessionId, readFacts(request.agent)))
388
470
  return next();
389
- const settlement = await raceGate(next, cfg.windowSeconds * 1000, cfg.defaultOutcome);
471
+ const windowMs = Math.max(0, cfg.windowSeconds * 1000);
472
+ // Only a delegated request owns a downstream prompt; a zero window denies
473
+ // without calling next(), so there is nothing to withdraw then.
474
+ const withdraw = windowMs > 0 ? new AbortController() : undefined;
475
+ let externalSettle;
476
+ const external = withdraw === undefined ? undefined : new Promise((resolve) => {
477
+ externalSettle = resolve;
478
+ });
479
+ if (withdraw !== undefined && externalSettle !== undefined) {
480
+ installWithdrawSignal(request, withdraw);
481
+ withdrawals.set(request, { withdraw, settle: externalSettle });
482
+ }
483
+ const settlement = await raceGate(next, windowMs, cfg.defaultOutcome, external);
484
+ if (withdraw !== undefined) {
485
+ // Whoever settled the request ends every prompt still showing it: the
486
+ // window's fail-closed default, a downstream answer (Web GUI, ACP, auto
487
+ // approval), and an outside answer routed through withdraw() all take
488
+ // the prompts left open on the OTHER surfaces away. A prompt kept alive
489
+ // after its decision is only a stale card on the user's panel, and a
490
+ // late click is discarded by the service.
491
+ withdrawals.delete(request);
492
+ withdraw.abort(settlement.settledBy === 'window' ? windowExpiredReason() : settledElsewhereReason());
493
+ }
390
494
  if (settlement.settledBy === 'window'
391
495
  && settlement.outcome === 'rejected'
392
496
  && cfg.autoReviewContent
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAMxC,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAA;AAmCzC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,8HAA8H;IAC9H,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChI,qGAAqG;IACrG,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,oIAAoI;IACpI,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAClE,2EAA2E;IAC3E,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;IACnF;;;;;;;OAOG;IACH,uBAAuB,EAAE,CAAC,CAAC,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C,CAAA;IACrE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAA;IAC7B,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAA;IACpC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAA;AAC9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xi4z/dsh-utils-approval-policy",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "dsh-utils component: unattended approval gate that bounds approval requests and settles fail-closed.",
5
5
  "license": "MIT",
6
6
  "author": "xi4z",
package/src/index.ts CHANGED
@@ -30,7 +30,14 @@
30
30
  * through untouched — nothing to wait for);
31
31
  * - the window expires → the configured fail-closed default settles the
32
32
  * approval ('rejected'; 'unavailable' also allowed — 'allowed-once' is
33
- * schema-forbidden). The turn proceeds denied instead of hanging;
33
+ * schema-forbidden). The turn proceeds denied instead of hanging, AND the
34
+ * request is withdrawn: the gate fuses a controller into the delegated
35
+ * request's signal, so aborting it once the request settles cancels the
36
+ * forwarded Remote prompt and the still-open Web GUI card / "awaiting
37
+ * approval" badge disappear instead of piling up as decided requests.
38
+ * Every settlement withdraws — the window default, a downstream answer
39
+ * (Web GUI / ACP / auto approval), and an outside answer reported through
40
+ * `ApprovalPolicyInfo.withdraw` (the QQ card click);
34
41
  * - the request's abort signal resolves 'cancelled' upstream — the host
35
42
  * races the signal itself; a late window expiry is simply ignored.
36
43
  *
@@ -101,6 +108,9 @@ export type GatedOutcome = 'rejected' | 'unavailable'
101
108
  * human channel (e.g. the QQ approval card) can echo the real deadline instead
102
109
  * of inventing its own TTL. `describe` reuses the exact predicate the gate
103
110
  * applies to the request, so the card and the window can never disagree.
111
+ * `withdraw` is the write side: a channel that settled the request outside the
112
+ * delegated chain reports that outcome, and every prompt still showing the
113
+ * request on the other surfaces is withdrawn.
104
114
  */
105
115
  export interface ApprovalPolicyInfo {
106
116
  describe(agent: unknown, sessionId: string): {
@@ -111,6 +121,15 @@ export interface ApprovalPolicyInfo {
111
121
  /** What the gate settles with when the window expires. */
112
122
  defaultOutcome: GatedOutcome
113
123
  }
124
+ /**
125
+ * Settle one gate-held request from outside the delegated chain (e.g. the QQ
126
+ * card click) and withdraw the prompts the other surfaces still show for it.
127
+ * The gate then reports `outcome` instead of waiting out its own window.
128
+ * @param request - the exact waterfall request object the caller received.
129
+ * @param outcome - the decision this channel produced.
130
+ * @returns whether the gate held that request and withdrew it.
131
+ */
132
+ withdraw(request: unknown, outcome: ApprovalOutcome): boolean
114
133
  }
115
134
 
116
135
  declare module '@deepseek-ai/cordis' {
@@ -346,32 +365,100 @@ export interface GateSettlement {
346
365
  * because no answerer produced it. A fast `decision` (including an instant
347
366
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
348
367
  * only a pending decision races the timer.
368
+ *
369
+ * `external` is the third arm: an answer produced OUTSIDE the delegated chain
370
+ * (a human channel ahead of the gate — the QQ card — settles through
371
+ * {@link ApprovalPolicyInfo.withdraw}). It counts as a downstream answer, so
372
+ * the gate reports that outcome instead of abandoning the request to its own
373
+ * timer.
349
374
  */
350
375
  export async function raceGate(
351
376
  decision: () => Promise<ApprovalOutcome>,
352
377
  windowMs: number,
353
378
  defaultOutcome: GatedOutcome,
379
+ external?: Promise<ApprovalOutcome>,
354
380
  ): Promise<GateSettlement> {
355
381
  if (windowMs <= 0) return { outcome: defaultOutcome, settledBy: 'window' }
356
382
  // The window timer stays REF'd on purpose: an open window means the host
357
383
  // turn is still owed an outcome, so the process must not drain the event
358
384
  // loop before it settles. It is cleared as soon as the race settles
359
- // (answer, rejection, or expiry) so a fast answer never leaves a stray
360
- // timer holding the loop for the rest of the window.
385
+ // (answer, external answer, rejection, or expiry) so a fast answer never
386
+ // leaves a stray timer holding the loop for the rest of the window.
361
387
  let timer: ReturnType<typeof setTimeout> | undefined
362
388
  try {
363
389
  const windowSettlement = new Promise<GateSettlement>((resolve) => {
364
390
  timer = setTimeout(() => resolve({ outcome: defaultOutcome, settledBy: 'window' }), windowMs)
365
391
  })
366
- return await Promise.race([
392
+ const arms: Promise<GateSettlement>[] = [
367
393
  decision().then((outcome): GateSettlement => ({ outcome, settledBy: 'downstream' })),
368
394
  windowSettlement,
369
- ])
395
+ ]
396
+ if (external !== undefined) {
397
+ arms.push(external.then((outcome): GateSettlement => ({ outcome, settledBy: 'downstream' })))
398
+ }
399
+ return await Promise.race(arms)
370
400
  } finally {
371
401
  if (timer !== undefined) clearTimeout(timer)
372
402
  }
373
403
  }
374
404
 
405
+ /**
406
+ * Name carried by the abort reason the gate uses to withdraw a prompt whose
407
+ * window expired. A human channel racing the same deadline (the QQ card
408
+ * answerer) matches this name to tell the gate's own fail-closed settlement
409
+ * apart from a cancelled turn. Kept as a literal in both components on
410
+ * purpose: they are independently published packages, and this name is the
411
+ * only contract between them.
412
+ */
413
+ export const WINDOW_EXPIRED_ABORT = 'UnattendedApprovalWindowExpired'
414
+
415
+ /** Abort reason that withdraws a pending prompt once the window expires. */
416
+ export function windowExpiredReason(): Error {
417
+ const error = new Error('The unattended approval window expired, so the pending approval request was withdrawn.')
418
+ error.name = WINDOW_EXPIRED_ABORT
419
+ return error
420
+ }
421
+
422
+ /**
423
+ * Name carried by the abort reason the gate uses when a request was settled
424
+ * somewhere else (a downstream answerer, another human channel through
425
+ * {@link ApprovalPolicyInfo.withdraw}) and the prompts still open on the
426
+ * remaining surfaces have to go away.
427
+ */
428
+ export const SETTLED_ABORT = 'UnattendedApprovalSettledElsewhere'
429
+
430
+ /** Abort reason that withdraws a prompt because the request was already settled. */
431
+ export function settledElsewhereReason(): Error {
432
+ const error = new Error('The approval request was already settled elsewhere, so this pending prompt was withdrawn.')
433
+ error.name = SETTLED_ABORT
434
+ return error
435
+ }
436
+
437
+ /**
438
+ * Make one delegated request withdrawable.
439
+ *
440
+ * A human surface (the Web GUI's forwarded Remote prompt) drops a pending
441
+ * request only when the Host cancels the Remote event, and the Host watches
442
+ * exactly the request signal it was handed. The caller's signal belongs to the
443
+ * turn — aborting it would cancel the tool call — so the gate fuses a
444
+ * controller it owns into it: aborts from the turn still propagate unchanged,
445
+ * while the gate gains a handle that withdraws the prompt at its deadline
446
+ * without cancelling anything.
447
+ *
448
+ * @param request - the borrowed waterfall request about to be delegated.
449
+ * @param withdraw - the gate-owned controller for this one request.
450
+ * @returns the fused signal now installed on the request.
451
+ */
452
+ export function installWithdrawSignal(
453
+ request: { signal?: AbortSignal },
454
+ withdraw: AbortController,
455
+ ): AbortSignal {
456
+ const original = request.signal
457
+ const fused = original === undefined ? withdraw.signal : AbortSignal.any([original, withdraw.signal])
458
+ request.signal = fused
459
+ return fused
460
+ }
461
+
375
462
  /** Whether an approval reason was raised by the experimental auto approval. */
376
463
  export function isAutoReviewAsk(reason: string | undefined): boolean {
377
464
  return typeof reason === 'string' && reason.startsWith(AUTO_REVIEW_REASON_PREFIX)
@@ -535,6 +622,19 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
535
622
  /** Window-rejected auto-review requests, keyed by tool-call id. */
536
623
  const pendingAutoReview = new Map<string, AutoReviewSettle>()
537
624
 
625
+ /**
626
+ * Withdrawal handle per delegated request. Keyed by the request object the
627
+ * waterfall hands every listener, so an answerer that settles the request
628
+ * outside the delegated chain (the QQ card) can end the prompts that other
629
+ * surfaces still show. Weak: a request that never settles cannot leak.
630
+ */
631
+ const withdrawals = new WeakMap<object, {
632
+ /** Aborts the fused signal: cancels the still-pending forwarded prompts. */
633
+ readonly withdraw: AbortController
634
+ /** Delivers an outside answer into the gate's race. */
635
+ readonly settle: (outcome: ApprovalOutcome) => void
636
+ }>()
637
+
538
638
  /**
539
639
  * Publish the read-only policy view. The service is optional by design: a
540
640
  * composition without this component simply has no approvalPolicyInfo, and
@@ -544,6 +644,14 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
544
644
  describe(agent, sessionId) {
545
645
  return describeGate(cfgNow(), agent as AgentLike, sessionId)
546
646
  },
647
+ withdraw(request, outcome) {
648
+ const held = withdrawals.get(request as object)
649
+ if (held === undefined) return false
650
+ withdrawals.delete(request as object)
651
+ held.withdraw.abort(settledElsewhereReason())
652
+ held.settle(outcome)
653
+ return true
654
+ },
547
655
  }
548
656
  const provideService = (ctx as unknown as { provide?: (name: string, value: unknown) => () => void }).provide
549
657
  if (typeof provideService === 'function') {
@@ -557,7 +665,29 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
557
665
  const cfg = cfgNow()
558
666
  const sessionId = String(request.agent?.id ?? '')
559
667
  if (!shouldGate(cfg, sessionId, readFacts(request.agent))) return next()
560
- const settlement = await raceGate(next, cfg.windowSeconds * 1000, cfg.defaultOutcome)
668
+ const windowMs = Math.max(0, cfg.windowSeconds * 1000)
669
+ // Only a delegated request owns a downstream prompt; a zero window denies
670
+ // without calling next(), so there is nothing to withdraw then.
671
+ const withdraw = windowMs > 0 ? new AbortController() : undefined
672
+ let externalSettle: ((outcome: ApprovalOutcome) => void) | undefined
673
+ const external = withdraw === undefined ? undefined : new Promise<ApprovalOutcome>((resolve) => {
674
+ externalSettle = resolve
675
+ })
676
+ if (withdraw !== undefined && externalSettle !== undefined) {
677
+ installWithdrawSignal(request as { signal?: AbortSignal }, withdraw)
678
+ withdrawals.set(request, { withdraw, settle: externalSettle })
679
+ }
680
+ const settlement = await raceGate(next, windowMs, cfg.defaultOutcome, external)
681
+ if (withdraw !== undefined) {
682
+ // Whoever settled the request ends every prompt still showing it: the
683
+ // window's fail-closed default, a downstream answer (Web GUI, ACP, auto
684
+ // approval), and an outside answer routed through withdraw() all take
685
+ // the prompts left open on the OTHER surfaces away. A prompt kept alive
686
+ // after its decision is only a stale card on the user's panel, and a
687
+ // late click is discarded by the service.
688
+ withdrawals.delete(request)
689
+ withdraw.abort(settlement.settledBy === 'window' ? windowExpiredReason() : settledElsewhereReason())
690
+ }
561
691
  if (settlement.settledBy === 'window'
562
692
  && settlement.outcome === 'rejected'
563
693
  && cfg.autoReviewContent