@xi4z/dsh-utils-approval-policy 0.9.2 → 0.10.1

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
  *
@@ -49,7 +56,14 @@
49
56
  * those sessions are shared with humans: only machine-driven turns
50
57
  * gate, and a human steering afterwards (last provenance message =
51
58
  * human — 'user', or a timed-ask late reply 'user-question-reply')
52
- * keeps the interactive default.
59
+ * keeps the interactive default;
60
+ * - interactive: the complement of the machine origins — a HUMAN-driven
61
+ * turn (last provenance message is 'user' / 'user-question-reply' and
62
+ * the session is not a subagent) is gated too, so approvals raised
63
+ * while an ordinary session is in progress get the same bounded window.
64
+ * Reachable alone or composed with the machine origins (e.g.
65
+ * [subagent, scheduled, interactive] ≈ everything but cron); 'all'
66
+ * remains the blunt escape hatch that also covers unknown provenance.
53
67
  *
54
68
  * The listener registers with prepend: true — the gate sits ahead of the
55
69
  * interactive answerers (web remote answerer, dsh-feishu card) regardless of
@@ -75,7 +89,7 @@ import type { ApprovalOutcome } from '@deepseek-ai/dsh-user-approval/types';
75
89
  import type { ContentBlock } from '@deepseek-ai/dsh-llm';
76
90
  export declare const name = "dsh-approval-policy";
77
91
  /** Origins a deployment may declare unattended (config vocabulary). */
78
- export type UnattendedOrigin = 'subagent' | 'scheduled' | 'cron' | 'all';
92
+ export type UnattendedOrigin = 'subagent' | 'scheduled' | 'cron' | 'interactive' | 'all';
79
93
  /**
80
94
  * The only outcomes a gate may settle with. 'allowed-once' is deliberately
81
95
  * absent from this union AND from the config enum: an unattended default
@@ -87,6 +101,9 @@ export type GatedOutcome = 'rejected' | 'unavailable';
87
101
  * human channel (e.g. the QQ approval card) can echo the real deadline instead
88
102
  * of inventing its own TTL. `describe` reuses the exact predicate the gate
89
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.
90
107
  */
91
108
  export interface ApprovalPolicyInfo {
92
109
  describe(agent: unknown, sessionId: string): {
@@ -97,6 +114,15 @@ export interface ApprovalPolicyInfo {
97
114
  /** What the gate settles with when the window expires. */
98
115
  defaultOutcome: GatedOutcome;
99
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;
100
126
  }
101
127
  declare module '@deepseek-ai/cordis' {
102
128
  interface Context {
@@ -105,8 +131,8 @@ declare module '@deepseek-ai/cordis' {
105
131
  }
106
132
  /** Settings-page schema; each key arrives as a volatile live reference. */
107
133
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
108
- /** Session/turn origins treated as unattended. Default: subagent + scheduled. */
109
- origins: z<NoInfer<("subagent" | "scheduled" | "cron" | "all")[]>, NoInfer<("subagent" | "scheduled" | "cron" | "all")[]>, "volatile-defined">;
134
+ /** Session/turn origins treated as unattended. Default: subagent + scheduled; 'interactive' also gates human-driven turns. */
135
+ origins: z<NoInfer<("subagent" | "scheduled" | "cron" | "interactive" | "all")[]>, NoInfer<("subagent" | "scheduled" | "cron" | "interactive" | "all")[]>, "volatile-defined">;
110
136
  /** Glob patterns matched against the requesting agent id; a hit gates every turn of that session. */
111
137
  sessions: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
112
138
  /** Answer window in seconds (whole seconds; no .int() chain exists — min/max bound it); 0 denies without delegating. Default 60. */
@@ -129,8 +155,8 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
129
155
  */
130
156
  autoReviewContent: z<boolean, boolean, "volatile-defined">;
131
157
  }>>, Schemastery.ObjectT<NoInfer<{
132
- /** Session/turn origins treated as unattended. Default: subagent + scheduled. */
133
- origins: z<NoInfer<("subagent" | "scheduled" | "cron" | "all")[]>, NoInfer<("subagent" | "scheduled" | "cron" | "all")[]>, "volatile-defined">;
158
+ /** Session/turn origins treated as unattended. Default: subagent + scheduled; 'interactive' also gates human-driven turns. */
159
+ origins: z<NoInfer<("subagent" | "scheduled" | "cron" | "interactive" | "all")[]>, NoInfer<("subagent" | "scheduled" | "cron" | "interactive" | "all")[]>, "volatile-defined">;
134
160
  /** Glob patterns matched against the requesting agent id; a hit gates every turn of that session. */
135
161
  sessions: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
136
162
  /** Answer window in seconds (whole seconds; no .int() chain exists — min/max bound it); 0 denies without delegating. Default 60. */
@@ -266,8 +292,52 @@ export interface GateSettlement {
266
292
  * because no answerer produced it. A fast `decision` (including an instant
267
293
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
268
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.
269
337
  */
270
- 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;
271
341
  /** Whether an approval reason was raised by the experimental auto approval. */
272
342
  export declare function isAutoReviewAsk(reason: string | undefined): boolean;
273
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
  *
@@ -49,7 +56,14 @@
49
56
  * those sessions are shared with humans: only machine-driven turns
50
57
  * gate, and a human steering afterwards (last provenance message =
51
58
  * human — 'user', or a timed-ask late reply 'user-question-reply')
52
- * keeps the interactive default.
59
+ * keeps the interactive default;
60
+ * - interactive: the complement of the machine origins — a HUMAN-driven
61
+ * turn (last provenance message is 'user' / 'user-question-reply' and
62
+ * the session is not a subagent) is gated too, so approvals raised
63
+ * while an ordinary session is in progress get the same bounded window.
64
+ * Reachable alone or composed with the machine origins (e.g.
65
+ * [subagent, scheduled, interactive] ≈ everything but cron); 'all'
66
+ * remains the blunt escape hatch that also covers unknown provenance.
53
67
  *
54
68
  * The listener registers with prepend: true — the gate sits ahead of the
55
69
  * interactive answerers (web remote answerer, dsh-feishu card) regardless of
@@ -73,8 +87,8 @@ import z from '@deepseek-ai/schemastery';
73
87
  export const name = 'dsh-approval-policy';
74
88
  /** Settings-page schema; each key arrives as a volatile live reference. */
75
89
  export const Config = z.object({
76
- /** Session/turn origins treated as unattended. Default: subagent + scheduled. */
77
- origins: z.array(z.union(['subagent', 'scheduled', 'cron', 'all'])).default(['subagent', 'scheduled']).volatile(),
90
+ /** Session/turn origins treated as unattended. Default: subagent + scheduled; 'interactive' also gates human-driven turns. */
91
+ origins: z.array(z.union(['subagent', 'scheduled', 'cron', 'interactive', 'all'])).default(['subagent', 'scheduled']).volatile(),
78
92
  /** Glob patterns matched against the requesting agent id; a hit gates every turn of that session. */
79
93
  sessions: z.array(z.string()).default([]).volatile(),
80
94
  /** Answer window in seconds (whole seconds; no .int() chain exists — min/max bound it); 0 denies without delegating. Default 60. */
@@ -201,6 +215,13 @@ export function shouldGate(config, sessionId, facts) {
201
215
  return true;
202
216
  if (kind === 'cron' && origins.includes('cron'))
203
217
  return true;
218
+ // 'interactive' is the complement of the machine origins: gate a turn only
219
+ // when both provenance reads positively say a human is driving it — a real
220
+ // user message and no subagent header. Unknown facts stay ungated (use
221
+ // 'all' for the fail-closed escape hatch).
222
+ if (origins.includes('interactive') && facts.headerOrigin !== 'subagent'
223
+ && (kind === 'user' || kind === 'user-question-reply'))
224
+ return true;
204
225
  return false;
205
226
  }
206
227
  /**
@@ -224,30 +245,89 @@ export function describeGate(config, agent, sessionId) {
224
245
  * because no answerer produced it. A fast `decision` (including an instant
225
246
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
226
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.
227
254
  */
228
- export async function raceGate(decision, windowMs, defaultOutcome) {
255
+ export async function raceGate(decision, windowMs, defaultOutcome, external) {
229
256
  if (windowMs <= 0)
230
257
  return { outcome: defaultOutcome, settledBy: 'window' };
231
258
  // The window timer stays REF'd on purpose: an open window means the host
232
259
  // turn is still owed an outcome, so the process must not drain the event
233
260
  // loop before it settles. It is cleared as soon as the race settles
234
- // (answer, rejection, or expiry) so a fast answer never leaves a stray
235
- // 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.
236
263
  let timer;
237
264
  try {
238
265
  const windowSettlement = new Promise((resolve) => {
239
266
  timer = setTimeout(() => resolve({ outcome: defaultOutcome, settledBy: 'window' }), windowMs);
240
267
  });
241
- return await Promise.race([
268
+ const arms = [
242
269
  decision().then((outcome) => ({ outcome, settledBy: 'downstream' })),
243
270
  windowSettlement,
244
- ]);
271
+ ];
272
+ if (external !== undefined) {
273
+ arms.push(external.then((outcome) => ({ outcome, settledBy: 'downstream' })));
274
+ }
275
+ return await Promise.race(arms);
245
276
  }
246
277
  finally {
247
278
  if (timer !== undefined)
248
279
  clearTimeout(timer);
249
280
  }
250
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
+ }
251
331
  /** Whether an approval reason was raised by the experimental auto approval. */
252
332
  export function isAutoReviewAsk(reason) {
253
333
  return typeof reason === 'string' && reason.startsWith(AUTO_REVIEW_REASON_PREFIX);
@@ -353,6 +433,13 @@ export function apply(ctx, config) {
353
433
  });
354
434
  /** Window-rejected auto-review requests, keyed by tool-call id. */
355
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();
356
443
  /**
357
444
  * Publish the read-only policy view. The service is optional by design: a
358
445
  * composition without this component simply has no approvalPolicyInfo, and
@@ -362,6 +449,15 @@ export function apply(ctx, config) {
362
449
  describe(agent, sessionId) {
363
450
  return describeGate(cfgNow(), agent, sessionId);
364
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
+ },
365
461
  };
366
462
  const provideService = ctx.provide;
367
463
  if (typeof provideService === 'function') {
@@ -372,7 +468,29 @@ export function apply(ctx, config) {
372
468
  const sessionId = String(request.agent?.id ?? '');
373
469
  if (!shouldGate(cfg, sessionId, readFacts(request.agent)))
374
470
  return next();
375
- 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
+ }
376
494
  if (settlement.settledBy === 'window'
377
495
  && settlement.outcome === 'rejected'
378
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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AAO,KAAK,SAAS;YAAE,OAAM;QACjC,IAAI,sBAAsB,CAAC;YACzB,UAAU;YACV,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACjC,WAAW,EAAE,OAAO,CAAC,aAAa;YAClC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC;SACpC,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACtC,CAAC,CAAA;IAED,sEAAsE;IACtE,iEAAiE;IACjE,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,kBAAkB,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3E,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM,kBAAkB,GAAG,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACvF,MAAM,UAAU,GAAG,GAAG,CAAC,EAAE,CAAC,eAAe,EAAE,gBAAyB,CAAC,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.9.2",
3
+ "version": "0.10.1",
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
  *
@@ -49,7 +56,14 @@
49
56
  * those sessions are shared with humans: only machine-driven turns
50
57
  * gate, and a human steering afterwards (last provenance message =
51
58
  * human — 'user', or a timed-ask late reply 'user-question-reply')
52
- * keeps the interactive default.
59
+ * keeps the interactive default;
60
+ * - interactive: the complement of the machine origins — a HUMAN-driven
61
+ * turn (last provenance message is 'user' / 'user-question-reply' and
62
+ * the session is not a subagent) is gated too, so approvals raised
63
+ * while an ordinary session is in progress get the same bounded window.
64
+ * Reachable alone or composed with the machine origins (e.g.
65
+ * [subagent, scheduled, interactive] ≈ everything but cron); 'all'
66
+ * remains the blunt escape hatch that also covers unknown provenance.
53
67
  *
54
68
  * The listener registers with prepend: true — the gate sits ahead of the
55
69
  * interactive answerers (web remote answerer, dsh-feishu card) regardless of
@@ -80,7 +94,7 @@ import type {} from '@deepseek-ai/dsh-agent'
80
94
  export const name = 'dsh-approval-policy'
81
95
 
82
96
  /** Origins a deployment may declare unattended (config vocabulary). */
83
- export type UnattendedOrigin = 'subagent' | 'scheduled' | 'cron' | 'all'
97
+ export type UnattendedOrigin = 'subagent' | 'scheduled' | 'cron' | 'interactive' | 'all'
84
98
 
85
99
  /**
86
100
  * The only outcomes a gate may settle with. 'allowed-once' is deliberately
@@ -94,6 +108,9 @@ export type GatedOutcome = 'rejected' | 'unavailable'
94
108
  * human channel (e.g. the QQ approval card) can echo the real deadline instead
95
109
  * of inventing its own TTL. `describe` reuses the exact predicate the gate
96
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.
97
114
  */
98
115
  export interface ApprovalPolicyInfo {
99
116
  describe(agent: unknown, sessionId: string): {
@@ -104,6 +121,15 @@ export interface ApprovalPolicyInfo {
104
121
  /** What the gate settles with when the window expires. */
105
122
  defaultOutcome: GatedOutcome
106
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
107
133
  }
108
134
 
109
135
  declare module '@deepseek-ai/cordis' {
@@ -114,8 +140,8 @@ declare module '@deepseek-ai/cordis' {
114
140
 
115
141
  /** Settings-page schema; each key arrives as a volatile live reference. */
116
142
  export const Config = z.object({
117
- /** Session/turn origins treated as unattended. Default: subagent + scheduled. */
118
- origins: z.array(z.union(['subagent', 'scheduled', 'cron', 'all'])).default(['subagent', 'scheduled']).volatile(),
143
+ /** Session/turn origins treated as unattended. Default: subagent + scheduled; 'interactive' also gates human-driven turns. */
144
+ origins: z.array(z.union(['subagent', 'scheduled', 'cron', 'interactive', 'all'])).default(['subagent', 'scheduled']).volatile(),
119
145
  /** Glob patterns matched against the requesting agent id; a hit gates every turn of that session. */
120
146
  sessions: z.array(z.string()).default([]).volatile(),
121
147
  /** Answer window in seconds (whole seconds; no .int() chain exists — min/max bound it); 0 denies without delegating. Default 60. */
@@ -290,6 +316,12 @@ export function shouldGate(
290
316
  const kind = facts.lastUserMessageKind
291
317
  if (kind === 'schedule' && origins.includes('scheduled')) return true
292
318
  if (kind === 'cron' && origins.includes('cron')) return true
319
+ // 'interactive' is the complement of the machine origins: gate a turn only
320
+ // when both provenance reads positively say a human is driving it — a real
321
+ // user message and no subagent header. Unknown facts stay ungated (use
322
+ // 'all' for the fail-closed escape hatch).
323
+ if (origins.includes('interactive') && facts.headerOrigin !== 'subagent'
324
+ && (kind === 'user' || kind === 'user-question-reply')) return true
293
325
  return false
294
326
  }
295
327
 
@@ -333,32 +365,100 @@ export interface GateSettlement {
333
365
  * because no answerer produced it. A fast `decision` (including an instant
334
366
  * fail-closed 'unavailable' from an empty chain) passes through untouched;
335
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.
336
374
  */
337
375
  export async function raceGate(
338
376
  decision: () => Promise<ApprovalOutcome>,
339
377
  windowMs: number,
340
378
  defaultOutcome: GatedOutcome,
379
+ external?: Promise<ApprovalOutcome>,
341
380
  ): Promise<GateSettlement> {
342
381
  if (windowMs <= 0) return { outcome: defaultOutcome, settledBy: 'window' }
343
382
  // The window timer stays REF'd on purpose: an open window means the host
344
383
  // turn is still owed an outcome, so the process must not drain the event
345
384
  // loop before it settles. It is cleared as soon as the race settles
346
- // (answer, rejection, or expiry) so a fast answer never leaves a stray
347
- // 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.
348
387
  let timer: ReturnType<typeof setTimeout> | undefined
349
388
  try {
350
389
  const windowSettlement = new Promise<GateSettlement>((resolve) => {
351
390
  timer = setTimeout(() => resolve({ outcome: defaultOutcome, settledBy: 'window' }), windowMs)
352
391
  })
353
- return await Promise.race([
392
+ const arms: Promise<GateSettlement>[] = [
354
393
  decision().then((outcome): GateSettlement => ({ outcome, settledBy: 'downstream' })),
355
394
  windowSettlement,
356
- ])
395
+ ]
396
+ if (external !== undefined) {
397
+ arms.push(external.then((outcome): GateSettlement => ({ outcome, settledBy: 'downstream' })))
398
+ }
399
+ return await Promise.race(arms)
357
400
  } finally {
358
401
  if (timer !== undefined) clearTimeout(timer)
359
402
  }
360
403
  }
361
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
+
362
462
  /** Whether an approval reason was raised by the experimental auto approval. */
363
463
  export function isAutoReviewAsk(reason: string | undefined): boolean {
364
464
  return typeof reason === 'string' && reason.startsWith(AUTO_REVIEW_REASON_PREFIX)
@@ -522,6 +622,19 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
522
622
  /** Window-rejected auto-review requests, keyed by tool-call id. */
523
623
  const pendingAutoReview = new Map<string, AutoReviewSettle>()
524
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
+
525
638
  /**
526
639
  * Publish the read-only policy view. The service is optional by design: a
527
640
  * composition without this component simply has no approvalPolicyInfo, and
@@ -531,6 +644,14 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
531
644
  describe(agent, sessionId) {
532
645
  return describeGate(cfgNow(), agent as AgentLike, sessionId)
533
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
+ },
534
655
  }
535
656
  const provideService = (ctx as unknown as { provide?: (name: string, value: unknown) => () => void }).provide
536
657
  if (typeof provideService === 'function') {
@@ -544,7 +665,29 @@ export function apply(ctx: Context, config: GateRuntimeConfig): void {
544
665
  const cfg = cfgNow()
545
666
  const sessionId = String(request.agent?.id ?? '')
546
667
  if (!shouldGate(cfg, sessionId, readFacts(request.agent))) return next()
547
- 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
+ }
548
691
  if (settlement.settledBy === 'window'
549
692
  && settlement.outcome === 'rejected'
550
693
  && cfg.autoReviewContent