@capybara-hq/kernel 0.1.0-rc.23 → 0.1.0-rc.24

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 (206) hide show
  1. package/bootstrap.json +25 -25
  2. package/dist/admin/admin.module.d.ts +2 -1
  3. package/dist/admin/admin.module.js +7 -3
  4. package/dist/admin/outbox-dead.controller.d.ts +23 -0
  5. package/dist/admin/outbox-dead.controller.js +62 -0
  6. package/dist/admin/outbox-dead.schemas.d.ts +8 -0
  7. package/dist/admin/outbox-dead.schemas.js +18 -0
  8. package/dist/admin/outbox-dead.service.d.ts +66 -0
  9. package/dist/admin/outbox-dead.service.js +179 -0
  10. package/dist/admin/overview.service.d.ts +40 -5
  11. package/dist/admin/overview.service.js +41 -7
  12. package/dist/agents/from-template.js +1 -1
  13. package/dist/background/finish.d.ts +5 -2
  14. package/dist/background/finish.js +14 -3
  15. package/dist/background/launch.d.ts +2 -1
  16. package/dist/background/launch.js +5 -2
  17. package/dist/background/store.d.ts +8 -0
  18. package/dist/background/store.js +24 -0
  19. package/dist/catalog/admin-catalog.controller.d.ts +21 -2
  20. package/dist/catalog/admin-catalog.controller.js +45 -6
  21. package/dist/catalog/admin-catalog.schemas.d.ts +5 -0
  22. package/dist/catalog/admin-catalog.schemas.js +8 -0
  23. package/dist/catalog/catalog.module.d.ts +2 -1
  24. package/dist/catalog/catalog.module.js +5 -1
  25. package/dist/catalog/marketplaces.service.d.ts +1 -1
  26. package/dist/catalog/platform-import-update.d.ts +50 -0
  27. package/dist/catalog/platform-import-update.js +116 -0
  28. package/dist/catalog/plugin-import.d.ts +36 -1
  29. package/dist/catalog/plugin-import.js +23 -1
  30. package/dist/catalog/plugin-upgrade.d.ts +18 -0
  31. package/dist/catalog/plugin-upgrade.js +19 -0
  32. package/dist/channels/channels.module.d.ts +5 -2
  33. package/dist/channels/channels.module.js +9 -2
  34. package/dist/channels/deliver-job.d.ts +25 -0
  35. package/dist/channels/deliver-job.js +25 -0
  36. package/dist/channels/inbound.d.ts +1 -1
  37. package/dist/channels/inbound.js +2 -15
  38. package/dist/channels/jobs.d.ts +28 -18
  39. package/dist/channels/jobs.js +63 -26
  40. package/dist/config/schema.d.ts +0 -3
  41. package/dist/config/schema.js +11 -20
  42. package/dist/conversations/agent-tree.d.ts +16 -0
  43. package/dist/conversations/agent-tree.js +36 -0
  44. package/dist/conversations/conversations.service.d.ts +44 -14
  45. package/dist/conversations/conversations.service.js +52 -38
  46. package/dist/conversations/event-log.d.ts +7 -10
  47. package/dist/conversations/event-log.js +24 -15
  48. package/dist/conversations/events.js +2 -1
  49. package/dist/conversations/queue.service.d.ts +8 -3
  50. package/dist/conversations/queue.service.js +37 -13
  51. package/dist/conversations/titles.d.ts +21 -8
  52. package/dist/conversations/titles.js +42 -15
  53. package/dist/db/kernel-schema.d.ts +26 -8
  54. package/dist/devices/devices.service.d.ts +12 -3
  55. package/dist/devices/devices.service.js +18 -3
  56. package/dist/errors.d.ts +11 -0
  57. package/dist/errors.js +11 -0
  58. package/dist/evals/run-replay.js +14 -8
  59. package/dist/extensions/extensions.module.js +3 -0
  60. package/dist/extensions/lifecycle.d.ts +6 -1
  61. package/dist/extensions/lifecycle.js +9 -2
  62. package/dist/extensions/usage-subscribers.d.ts +43 -0
  63. package/dist/extensions/usage-subscribers.js +108 -0
  64. package/dist/http/api.module.js +2 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +1 -0
  67. package/dist/infra/cli/kernel-cli.module.js +5 -0
  68. package/dist/infra/events/kernel-events.d.ts +9 -35
  69. package/dist/infra/outbox/outbox-relay.module.d.ts +6 -0
  70. package/dist/infra/outbox/outbox-relay.module.js +18 -0
  71. package/dist/infra/outbox/outbox.dispatcher.d.ts +103 -0
  72. package/dist/infra/outbox/outbox.dispatcher.js +310 -0
  73. package/dist/infra/outbox/outbox.module.d.ts +24 -0
  74. package/dist/infra/outbox/outbox.module.js +50 -0
  75. package/dist/infra/outbox/outbox.relay.d.ts +31 -0
  76. package/dist/infra/outbox/outbox.relay.js +76 -0
  77. package/dist/infra/outbox/outbox.service.d.ts +51 -0
  78. package/dist/infra/outbox/outbox.service.js +131 -0
  79. package/dist/infra/outbox/registry.d.ts +120 -0
  80. package/dist/infra/outbox/registry.js +108 -0
  81. package/dist/infra/queue/queue-names.d.ts +8 -0
  82. package/dist/infra/queue/queue-names.js +16 -0
  83. package/dist/kernel.module.js +3 -0
  84. package/dist/local-devices/device-policy.service.d.ts +4 -0
  85. package/dist/local-devices/device-policy.service.js +61 -3
  86. package/dist/local-devices/machines.d.ts +13 -5
  87. package/dist/local-devices/machines.js +45 -7
  88. package/dist/local-devices/policy-summary.d.ts +44 -1
  89. package/dist/local-devices/policy-summary.js +69 -0
  90. package/dist/models/embeddings.d.ts +9 -9
  91. package/dist/models/embeddings.js +11 -18
  92. package/dist/models/models.module.js +3 -0
  93. package/dist/orgs/orgs.service.js +7 -0
  94. package/dist/overrides.d.ts +20 -3
  95. package/dist/overrides.js +10 -2
  96. package/dist/platform/exclusions.js +5 -0
  97. package/dist/platform/ops/admin.ops.js +18 -2
  98. package/dist/platform/ops/catalog-admin.ops.d.ts +3 -1
  99. package/dist/platform/ops/catalog-admin.ops.js +32 -4
  100. package/dist/platform/ops/outbox.ops.d.ts +21 -0
  101. package/dist/platform/ops/outbox.ops.js +125 -0
  102. package/dist/platform/ops/schedules.ops.js +40 -1
  103. package/dist/platform/platform-ops.module.d.ts +2 -1
  104. package/dist/platform/platform-ops.module.js +3 -0
  105. package/dist/platform/route-schemas.js +3 -0
  106. package/dist/roles/worker.module.js +9 -4
  107. package/dist/runtime/langgraph-loop.js +13 -5
  108. package/dist/runtime/limits.d.ts +15 -0
  109. package/dist/runtime/limits.js +25 -0
  110. package/dist/runtime/loop.d.ts +8 -3
  111. package/dist/runtime/loop.js +2 -1
  112. package/dist/runtime/maintenance.d.ts +4 -2
  113. package/dist/runtime/maintenance.js +17 -2
  114. package/dist/runtime/model-call.d.ts +14 -16
  115. package/dist/runtime/model-call.js +14 -24
  116. package/dist/runtime/queue-lost-jobs.d.ts +24 -0
  117. package/dist/runtime/queue-lost-jobs.js +51 -0
  118. package/dist/runtime/run-control.d.ts +42 -5
  119. package/dist/runtime/run-control.js +66 -12
  120. package/dist/runtime/run-finish.d.ts +39 -12
  121. package/dist/runtime/run-finish.js +97 -14
  122. package/dist/runtime/run-jobs.d.ts +95 -13
  123. package/dist/runtime/run-jobs.js +199 -28
  124. package/dist/runtime/run-orphan-check.job.d.ts +142 -0
  125. package/dist/runtime/run-orphan-check.job.js +339 -0
  126. package/dist/runtime/run-processors.d.ts +16 -9
  127. package/dist/runtime/run-processors.js +1 -1
  128. package/dist/runtime/run-queue.d.ts +64 -55
  129. package/dist/runtime/run-queue.js +147 -284
  130. package/dist/runtime/run-steps.d.ts +1 -2
  131. package/dist/runtime/run-steps.js +8 -11
  132. package/dist/runtime/run-worker.d.ts +6 -17
  133. package/dist/runtime/run-worker.js +32 -34
  134. package/dist/runtime/runtime.module.d.ts +2 -3
  135. package/dist/runtime/runtime.module.js +5 -6
  136. package/dist/runtime/step-log.d.ts +16 -4
  137. package/dist/runtime/step-log.js +26 -6
  138. package/dist/runtime/stream.controller.d.ts +2 -4
  139. package/dist/runtime/stream.controller.js +5 -11
  140. package/dist/runtime/subagents/child.js +1 -1
  141. package/dist/runtime/subagents/definition.d.ts +2 -1
  142. package/dist/runtime/subagents/definition.js +4 -2
  143. package/dist/runtime/subagents/deliveries.d.ts +6 -3
  144. package/dist/runtime/subagents/deliveries.js +16 -7
  145. package/dist/runtime/subagents/dispatch.d.ts +12 -12
  146. package/dist/runtime/subagents/dispatch.js +13 -38
  147. package/dist/runtime/subagents/messages.d.ts +5 -1
  148. package/dist/runtime/subagents/messages.js +11 -3
  149. package/dist/runtime/subagents/skill-fork.d.ts +3 -3
  150. package/dist/runtime/subagents/skill-fork.js +5 -5
  151. package/dist/runtime/subagents/subagents.service.js +1 -1
  152. package/dist/runtime/subagents/tree-jobs.d.ts +61 -0
  153. package/dist/runtime/subagents/tree-jobs.js +86 -0
  154. package/dist/runtime/usage-report-jobs.d.ts +23 -48
  155. package/dist/runtime/usage-report-jobs.js +67 -119
  156. package/dist/runtime/usage-report.d.ts +28 -77
  157. package/dist/runtime/usage-report.js +35 -213
  158. package/dist/runtime/waits.d.ts +48 -198
  159. package/dist/runtime/waits.js +103 -805
  160. package/dist/sandbox/sandbox.service.d.ts +17 -4
  161. package/dist/sandbox/sandbox.service.js +55 -14
  162. package/dist/schedules/calendar.d.ts +134 -0
  163. package/dist/schedules/calendar.js +410 -0
  164. package/dist/schedules/fire.d.ts +1 -3
  165. package/dist/schedules/fire.js +5 -10
  166. package/dist/schedules/run-tracker.d.ts +0 -5
  167. package/dist/schedules/run-tracker.js +0 -13
  168. package/dist/schedules/scan.job.js +15 -20
  169. package/dist/schedules/schedule-math.d.ts +42 -0
  170. package/dist/schedules/schedule-math.js +52 -0
  171. package/dist/schedules/scheduled-tasks.service.d.ts +16 -0
  172. package/dist/schedules/scheduled-tasks.service.js +53 -0
  173. package/dist/schedules/schedules.controller.d.ts +5 -1
  174. package/dist/schedules/schedules.controller.js +15 -1
  175. package/dist/schedules/schedules.schemas.d.ts +35 -0
  176. package/dist/schedules/schedules.schemas.js +27 -0
  177. package/dist/schedules/store.d.ts +5 -0
  178. package/dist/schedules/store.js +20 -0
  179. package/dist/tools/approvals.service.d.ts +26 -7
  180. package/dist/tools/approvals.service.js +88 -10
  181. package/dist/tools/builtin-names.d.ts +5 -3
  182. package/dist/tools/builtin-names.js +12 -4
  183. package/dist/tools/builtins/builtin-tools.d.ts +1 -2
  184. package/dist/tools/builtins/builtin-tools.js +21 -17
  185. package/dist/tools/builtins/sandbox/bash.js +9 -3
  186. package/dist/tools/builtins/sandbox/common.d.ts +18 -1
  187. package/dist/tools/builtins/sandbox/common.js +14 -1
  188. package/dist/tools/builtins/sandbox/index.d.ts +2 -1
  189. package/dist/tools/builtins/sandbox/index.js +4 -1
  190. package/dist/tools/builtins/sandbox/task-list.d.ts +12 -0
  191. package/dist/tools/builtins/sandbox/task-list.js +130 -0
  192. package/dist/tools/builtins/sandbox/task-output.d.ts +8 -1
  193. package/dist/tools/builtins/sandbox/task-output.js +21 -3
  194. package/dist/tools/builtins/web/extract.d.ts +2 -4
  195. package/dist/tools/builtins/web/extract.js +2 -5
  196. package/dist/tools/pipeline.d.ts +1 -1
  197. package/dist/tools/pipeline.js +1 -1
  198. package/dist/tools/questions.service.d.ts +15 -6
  199. package/dist/tools/questions.service.js +20 -8
  200. package/dist/tools/registry.d.ts +4 -2
  201. package/dist/tools/registry.js +4 -3
  202. package/dist/tools/tools.module.js +4 -3
  203. package/package.json +3 -3
  204. package/src/migrations/0118_device_policy_ops.sql +6 -0
  205. package/src/migrations/0119_outbox.sql +22 -0
  206. package/src/migrations/0120_drop_usage_report_sweep.sql +7 -0
@@ -19,7 +19,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
19
19
  import { TransactionHost } from "../infra/database/transaction-host.js";
20
20
  import { Transactional } from "../infra/database/transactional.decorator.js";
21
21
  import { KernelEvents } from "../infra/events/kernel-events.js";
22
- import { KERNEL_LOGGER } from "../infra/tokens.js";
23
22
  import { ProviderRegistry } from "../runtime/providers.js";
24
23
  import { RunControl as RunControlService } from "../runtime/run-control.js";
25
24
  import { rootConversationOf } from "../runtime/subagents/child.js";
@@ -130,7 +129,6 @@ let ConversationsService = class ConversationsService {
130
129
  access;
131
130
  runs;
132
131
  providers;
133
- log;
134
132
  content;
135
133
  attachments;
136
134
  invoker;
@@ -144,7 +142,7 @@ let ConversationsService = class ConversationsService {
144
142
  /** Starts and stops the conversation's runs. */
145
143
  runs,
146
144
  /** Resolves a switched-to model and its declared parameters (UI refresh B). */
147
- providers, log,
145
+ providers,
148
146
  /** Reads `@` resources with the sender's credentials. */
149
147
  content,
150
148
  /** Binds uploaded files to the conversation in the message's transaction. */
@@ -165,7 +163,6 @@ let ConversationsService = class ConversationsService {
165
163
  this.access = access;
166
164
  this.runs = runs;
167
165
  this.providers = providers;
168
- this.log = log;
169
166
  this.content = content;
170
167
  this.attachments = attachments;
171
168
  this.invoker = invoker;
@@ -176,15 +173,6 @@ let ConversationsService = class ConversationsService {
176
173
  this.events = events;
177
174
  this.txHost = txHost;
178
175
  }
179
- /**
180
- * 不阻塞地调用一次 `ensureRun`(打开 SSE、读事件时):它幂等,并顺带清理孤儿运行,
181
- * 会话不会因为某次运行结束后的投递失败而永远停在「运行中」。失败只记日志。
182
- */
183
- kickRun(conversationId) {
184
- this.runs
185
- .ensureRun(conversationId)
186
- .catch((err) => this.log.warn("ensureRun on conversation open failed", { conversationId, err }));
187
- }
188
176
  /**
189
177
  * Creates an empty conversation bound to its device (`pick`, see
190
178
  * {@link ConversationDevices.forNew}); an agent the account cannot use →
@@ -237,7 +225,7 @@ let ConversationsService = class ConversationsService {
237
225
  return raced;
238
226
  }
239
227
  await this.eventLog.notify(id, written.seq);
240
- await this.runs.ensureRun(id);
228
+ await this.startRun(id);
241
229
  return { conversation: await this.rowView(id), event: written, events: all, created: true };
242
230
  }
243
231
  /** The conversation row and its first message (undefined: a concurrent retry committed first). */
@@ -292,9 +280,16 @@ let ConversationsService = class ConversationsService {
292
280
  return null;
293
281
  // what the first send wrote: the log from its start up to the message
294
282
  const events = (await this.eventLog.readAfter(row.id, 0, event.seq)).filter((e) => e.seq <= event.seq);
295
- await this.runs.ensureRun(row.id);
283
+ await this.startRun(row.id);
296
284
  return { conversation: toView(row), event, events, created: false };
297
285
  }
286
+ /**
287
+ * The direct `ensureRun` after a message's commit ({@link RunControl.ensureRunAfterCommit}): a
288
+ * failure never fails the request, since the message's transaction owes the ensure-run backstop.
289
+ */
290
+ startRun(conversationId) {
291
+ return this.runs.ensureRunAfterCommit(conversationId);
292
+ }
298
293
  async rowView(id) {
299
294
  return toView(await this.db
300
295
  .selectFrom("conversations")
@@ -352,7 +347,7 @@ let ConversationsService = class ConversationsService {
352
347
  if (!(e instanceof ApiError && e.code === "run.not_active"))
353
348
  throw e;
354
349
  }
355
- await this.markDeleted(conversationId);
350
+ await this.markDeleted(orgId, conversationId, accountId);
356
351
  // after the mark, so no finish or delivery of the stops below can start a run on the deleted
357
352
  // root (`ensureRun` refuses it). The sandbox's tasks stop first, so the sub-agents' tasks end
358
353
  // as a deletion; the tree stop then only stops a task a sub-agent started in between
@@ -362,13 +357,15 @@ let ConversationsService = class ConversationsService {
362
357
  await this.runs.stopTree(conversationId, accountId, { includeSelf: false });
363
358
  await this.eventLog.publishChanged(conversationId, "deleted");
364
359
  }
365
- // the publish happens after the commit, in the caller
366
- async markDeleted(conversationId) {
360
+ // the publish happens after the commit, in the caller; the tree stop after it is owed here
361
+ // (transactional outbox spec §6), so a process that dies before it still stops the tree
362
+ async markDeleted(orgId, conversationId, accountId) {
367
363
  await this.db
368
364
  .updateTable("conversations")
369
365
  .set({ deleted_at: sql `now()` })
370
366
  .where("id", "=", conversationId)
371
367
  .execute();
368
+ await this.runs.oweStopDeletedTree(conversationId, accountId, orgId);
372
369
  // Queued messages must not start a run on a deleted conversation
373
370
  await this.db
374
371
  .deleteFrom("conversation_queue")
@@ -681,26 +678,28 @@ let ConversationsService = class ConversationsService {
681
678
  return conversationId;
682
679
  return rootConversationOf(this.db.db, row.parent_conversation_id);
683
680
  }
684
- /** 读事件(先做 `get` 的可见性判定);顺带不阻塞地 {@link kickRun}。 */
681
+ /**
682
+ * 读事件(先做 `get` 的可见性判定). A read never changes run state (transactional outbox spec
683
+ * §6): a run nobody runs is the `run-orphan-check`'s to repair.
684
+ */
685
685
  async listEvents(orgId, conversationId, viewerAccountId, afterSeq, limit) {
686
686
  await this.get(orgId, conversationId, viewerAccountId);
687
- this.kickRun(conversationId);
688
687
  return this.eventLog.readAfter(conversationId, afterSeq, limit);
689
688
  }
690
689
  /**
691
690
  * The turn-aligned page of events before `beforeSeq` (`null`: the log's last page), with how
692
691
  * many runs started before it ({@link EventLog.readTurnPageBefore}; history paging spec §2).
693
- * Visibility as {@link get}; kicks a stalled run as {@link listEvents} does.
692
+ * Visibility as {@link get}; a read only, as {@link listEvents}.
694
693
  */
695
694
  async listEventsBefore(orgId, conversationId, viewerAccountId, beforeSeq, limit) {
696
695
  await this.get(orgId, conversationId, viewerAccountId);
697
- this.kickRun(conversationId);
698
696
  return this.eventLog.readTurnPageBefore(conversationId, beforeSeq, limit, EVENTS_TURN_EXTEND);
699
697
  }
700
698
  /**
701
699
  * 追加一条用户消息;带 `clientMessageId` 时重复提交返回同一事件。写入后调用 `ensureRun`:
702
700
  * 没有进行中的运行时投递一轮;运行中则由当前运行在步骤间隙吸收,或在它结束时再次 `ensureRun`。
703
- * 投递失败时抛错(消息已写入;客户端带同一 `clientMessageId` 重试会再次触发投递)。
701
+ * A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
702
+ * backstop, which starts the run once the queue is reachable (transactional outbox spec §6).
704
703
  *
705
704
  * `attachments`(`@` 资源引用):内核以发送者的凭据读取资源(打码、限长),作为用户文本之后的额外文本块写入同一条
706
705
  * user_message,并在 `payload.attachments` 记录元数据(第 i 个附件对应 `content[i + 1]`)。读取失败整条不写。
@@ -719,7 +718,7 @@ let ConversationsService = class ConversationsService {
719
718
  input.clientMessageId !== undefined) {
720
719
  const existing = await this.eventLog.findByIdem(conversationId, userMessageIdemKey(input.clientMessageId));
721
720
  if (existing) {
722
- await this.runs.ensureRun(conversationId);
721
+ await this.startRun(conversationId);
723
722
  return existing;
724
723
  }
725
724
  }
@@ -750,7 +749,7 @@ let ConversationsService = class ConversationsService {
750
749
  .execute();
751
750
  await this.eventLog.publishChanged(conversationId, "archived");
752
751
  }
753
- await this.runs.ensureRun(conversationId);
752
+ await this.startRun(conversationId);
754
753
  return event;
755
754
  }
756
755
  /**
@@ -812,10 +811,19 @@ let ConversationsService = class ConversationsService {
812
811
  * conversations (network ask-to-allow spec §6.7). The queue's "send now" uses it as the direct
813
812
  * send does; announce after the commit with {@link announceSkipped}. `toSeq` is the highest seq
814
813
  * written in this conversation (null: none).
814
+ *
815
+ * Lock order: this (root) conversation (the caller's), its pending questions, the sub-agents'
816
+ * conversations with a pending network ask (id order), the asks themselves (the root's and the
817
+ * sub-agents'), and only then the run rows, as each skipped wait's run resumes in this
818
+ * transaction. Every run row comes after every conversation and decided row (ruling R19); a
819
+ * sub-agent's conversation comes after the root's questions, which only this path locks with a
820
+ * sub-agent conversation after them.
815
821
  */
816
822
  async skipWaitsIn(conversationId, accountId, messageSeq) {
817
823
  const q = await this.questions.skipPendingIn(conversationId, accountId, messageSeq);
818
824
  const n = await this.approvals.skipNetworkIn(conversationId, accountId);
825
+ for (const w of [...q.records, ...n.records])
826
+ await this.runs.resumeIn(w.runId, w.id);
819
827
  const here = n.seqs.get(conversationId);
820
828
  const toSeq = q.toSeq === null && here === undefined ? null : Math.max(q.toSeq ?? 0, here ?? 0);
821
829
  return { skipped: { questions: q.records, network: n.records, seqs: n.seqs }, toSeq };
@@ -823,7 +831,8 @@ let ConversationsService = class ConversationsService {
823
831
  /**
824
832
  * After the commit: announces each skipped question (`question.answered`, outcome `skipped`) and
825
833
  * network ask (`approval.decided`, status `skipped`; a sub-agent's conversation is notified
826
- * first), so its run resumes (waits) and its IM card updates (channel jobs).
834
+ * first) as domain events with no kernel subscriber: the IM card updates are owed by the skips'
835
+ * appends (transactional outbox spec §8.1); the run resumed in the message's transaction.
827
836
  */
828
837
  async announceSkipped(skipped) {
829
838
  for (const q of skipped.questions) {
@@ -877,6 +886,10 @@ let ConversationsService = class ConversationsService {
877
886
  events.push(this.userMessage(accountId, input, extra, blocks, invoked, context, internal.schedule));
878
887
  const { events: written, fresh } = await this.eventLog.appendInReport(conversationId, events);
879
888
  const message = written.at(-1);
889
+ // the run this message starts is owed with it: the direct ensureRun after the commit may never
890
+ // happen (the process died) or fail (transactional outbox spec §6)
891
+ if (fresh.at(-1) === true)
892
+ await this.runs.oweEnsureRun(conversationId, message.seq, orgId);
880
893
  const skips = fresh.at(-1) === true
881
894
  ? await this.skipWaitsIn(conversationId, accountId, message.seq)
882
895
  : { skipped: NO_REPLY_SKIPS, toSeq: null };
@@ -995,13 +1008,15 @@ let ConversationsService = class ConversationsService {
995
1008
  throw new ApiError("run.not_active", "No active run to abort");
996
1009
  const runs = this.runs;
997
1010
  // 等待中:直接结束;没成功(刚被续跑、已回到 queued)则按下面的常规路径中止。
1011
+ // the stop's terminal transaction owed the ensure-run backstop; the direct call starts what
1012
+ // waited for the stopped run now
998
1013
  if (run.status === "waiting" && (await runs.abortWaiting(conversationId, run.id, accountId))) {
999
- this.kickRun(conversationId);
1014
+ await runs.ensureRunAfterCommit(conversationId);
1000
1015
  return run.id;
1001
1016
  }
1002
1017
  // 孤儿运行没有 worker 在听中止广播:直接写成 aborted,之后再看有没有等待中的消息要起新一轮。
1003
1018
  if (await runs.abortIfOrphaned(conversationId, run.id, accountId)) {
1004
- this.kickRun(conversationId);
1019
+ await runs.ensureRunAfterCommit(conversationId);
1005
1020
  return run.id;
1006
1021
  }
1007
1022
  await runs.requestAbort(run.id, accountId);
@@ -1034,15 +1049,14 @@ ConversationsService = __decorate([
1034
1049
  __param(3, Inject(ConversationAccess)),
1035
1050
  __param(4, Inject(RunControlService)),
1036
1051
  __param(5, Inject(ProviderRegistry)),
1037
- __param(6, Inject(KERNEL_LOGGER)),
1038
- __param(7, Inject(ConnectorContent)),
1039
- __param(8, Inject(AttachmentsService)),
1040
- __param(9, Inject(SkillInvoker)),
1041
- __param(10, Inject(BackgroundTaskStopper)),
1042
- __param(11, Inject(ConversationDevices)),
1043
- __param(12, Inject(QuestionsService)),
1044
- __param(13, Inject(ApprovalsService)),
1045
- __param(14, Inject(KernelEvents)),
1046
- __param(15, Inject(TransactionHost))
1052
+ __param(6, Inject(ConnectorContent)),
1053
+ __param(7, Inject(AttachmentsService)),
1054
+ __param(8, Inject(SkillInvoker)),
1055
+ __param(9, Inject(BackgroundTaskStopper)),
1056
+ __param(10, Inject(ConversationDevices)),
1057
+ __param(11, Inject(QuestionsService)),
1058
+ __param(12, Inject(ApprovalsService)),
1059
+ __param(13, Inject(KernelEvents)),
1060
+ __param(14, Inject(TransactionHost))
1047
1061
  ], ConversationsService);
1048
1062
  export { ConversationsService };
@@ -1,6 +1,6 @@
1
1
  import { KernelDb } from "../infra/database/kernel-db.js";
2
2
  import { TransactionHost } from "../infra/database/transaction-host.js";
3
- import { KernelEvents } from "../infra/events/kernel-events.js";
3
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
4
4
  import type { KernelLogger } from "../log.js";
5
5
  import { type ConversationEvent, type ConversationEventType } from "./events.js";
6
6
  /** 事件日志依赖的总线:内核 bus(命名空间 `kernel`)。 */
@@ -74,17 +74,17 @@ export type ConversationChange = (typeof CONVERSATION_CHANGES)[number];
74
74
  * seq 由 `conversations.last_seq` 在会话行锁内连续分配(多副本并发写同一会话时串行化);
75
75
  * 幂等键的「先查后写」也在同一把行锁内完成。
76
76
  *
77
- * Every published advance (`notify`) is also announced in-process as `conversation.event-appended`
78
- * on {@link KernelEvents} (the channel outbound delivery enqueues from it), on this replica, right
79
- * after the bus publish, in append order.
77
+ * An append to a conversation with a channel target (`channel_deliveries`, read with the row lock)
78
+ * owes the conversation's IM delivery in the append's transaction (transactional outbox spec
79
+ * §8.1); a conversation without one writes nothing more.
80
80
  */
81
81
  export declare class EventLog {
82
82
  private readonly db;
83
83
  private readonly bus;
84
84
  private readonly log;
85
- private readonly events;
85
+ private readonly outbox;
86
86
  readonly txHost: TransactionHost;
87
- constructor(db: KernelDb, bus: EventBus, log: Pick<KernelLogger, "warn">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost);
87
+ constructor(db: KernelDb, bus: EventBus, log: Pick<KernelLogger, "warn">, outbox: Pick<OutboxService, "add">, txHost: TransactionHost);
88
88
  /**
89
89
  * 追加事件,返回与输入一一对应的事件(幂等命中的为已有事件)。
90
90
  * 自开一个独立事务(`requires_new`,与调用方的事务无关),提交后发布 `conv.<id>`。
@@ -107,10 +107,7 @@ export declare class EventLog {
107
107
  fresh: boolean[];
108
108
  }>;
109
109
  private appendOwn;
110
- /**
111
- * 发布「日志已推进到 toSeq」;发布失败只记日志(事件已提交,订阅方可按 seq 补读)。Then announces
112
- * it in-process (`conversation.event-appended`); a failing subscriber is logged by KernelEvents.
113
- */
110
+ /** 发布「日志已推进到 toSeq」;发布失败只记日志(事件已提交,订阅方可按 seq 补读)。 */
114
111
  notify(conversationId: string, toSeq: number): Promise<void>;
115
112
  /**
116
113
  * Publishes a `changed` frame on the conversation topic (rename, generated title, selection, ...).
@@ -9,11 +9,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable, Module } from "@nestjs/common";
11
11
  import { sql } from "kysely";
12
+ import { oweDelivery } from "../channels/deliver-job.js";
12
13
  import { ApiError } from "../errors.js";
13
14
  import { KernelDb } from "../infra/database/kernel-db.js";
14
15
  import { TransactionHost } from "../infra/database/transaction-host.js";
15
16
  import { Transactional } from "../infra/database/transactional.decorator.js";
16
- import { KernelEvents } from "../infra/events/kernel-events.js";
17
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
17
18
  import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
18
19
  import { ConversationEventSchema, } from "./events.js";
19
20
  /**
@@ -75,21 +76,21 @@ const EVENT_COLUMNS = [
75
76
  * seq 由 `conversations.last_seq` 在会话行锁内连续分配(多副本并发写同一会话时串行化);
76
77
  * 幂等键的「先查后写」也在同一把行锁内完成。
77
78
  *
78
- * Every published advance (`notify`) is also announced in-process as `conversation.event-appended`
79
- * on {@link KernelEvents} (the channel outbound delivery enqueues from it), on this replica, right
80
- * after the bus publish, in append order.
79
+ * An append to a conversation with a channel target (`channel_deliveries`, read with the row lock)
80
+ * owes the conversation's IM delivery in the append's transaction (transactional outbox spec
81
+ * §8.1); a conversation without one writes nothing more.
81
82
  */
82
83
  let EventLog = class EventLog {
83
84
  db;
84
85
  bus;
85
86
  log;
86
- events;
87
+ outbox;
87
88
  txHost;
88
- constructor(db, bus, log, events, txHost) {
89
+ constructor(db, bus, log, outbox, txHost) {
89
90
  this.db = db;
90
91
  this.bus = bus;
91
92
  this.log = log;
92
- this.events = events;
93
+ this.outbox = outbox;
93
94
  this.txHost = txHost;
94
95
  }
95
96
  /**
@@ -126,10 +127,7 @@ let EventLog = class EventLog {
126
127
  const { events: out, toSeq } = await this.write(conversationId, events, bodies);
127
128
  return { events: out, toSeq };
128
129
  }
129
- /**
130
- * 发布「日志已推进到 toSeq」;发布失败只记日志(事件已提交,订阅方可按 seq 补读)。Then announces
131
- * it in-process (`conversation.event-appended`); a failing subscriber is logged by KernelEvents.
132
- */
130
+ /** 发布「日志已推进到 toSeq」;发布失败只记日志(事件已提交,订阅方可按 seq 补读)。 */
133
131
  async notify(conversationId, toSeq) {
134
132
  const msg = { kind: "events", toSeq };
135
133
  try {
@@ -138,7 +136,6 @@ let EventLog = class EventLog {
138
136
  catch (err) {
139
137
  this.log.warn("conversation event notify failed", { conversationId, toSeq, err });
140
138
  }
141
- await this.events.emit("conversation.event-appended", { conversationId, toSeq });
142
139
  }
143
140
  /**
144
141
  * Publishes a `changed` frame on the conversation topic (rename, generated title, selection, ...).
@@ -300,10 +297,20 @@ let EventLog = class EventLog {
300
297
  /** The append itself, in the context's transaction (both callers open or join one). */
301
298
  async write(conversationId, events, bodies) {
302
299
  const t = this.db;
303
- // 先锁会话行:之后的幂等查询与 seq 分配都在这把锁内,并发 append 依次执行。
300
+ // 先锁会话行:之后的幂等查询与 seq 分配都在这把锁内,并发 append 依次执行。The same statement
301
+ // reads whether the conversation has a channel target (its primary key), under the lock that
302
+ // `ChannelJobs.bind` takes too
304
303
  const conv = await t
305
304
  .selectFrom("conversations")
306
- .select("id")
305
+ .select((eb) => [
306
+ "org_id",
307
+ eb
308
+ .exists(eb
309
+ .selectFrom("channel_deliveries")
310
+ .select("channel_deliveries.conversation_id")
311
+ .whereRef("channel_deliveries.conversation_id", "=", "conversations.id"))
312
+ .as("im"),
313
+ ])
307
314
  .where("id", "=", conversationId)
308
315
  .forUpdate()
309
316
  .executeTakeFirst();
@@ -378,6 +385,8 @@ let EventLog = class EventLog {
378
385
  }))
379
386
  .returning(EVENT_COLUMNS)
380
387
  .execute();
388
+ if (conv.im)
389
+ await oweDelivery(this.outbox, { conversationId, orgId: conv.org_id, seq: toSeq });
381
390
  const bySeq = new Map(inserted.map((r) => [Number(r.seq), toEvent(r)]));
382
391
  return {
383
392
  events: plan.map((p) => p.kind === "old" ? p.event : bySeq.get(base + p.index + 1)),
@@ -400,7 +409,7 @@ EventLog = __decorate([
400
409
  __param(0, Inject(KernelDb)),
401
410
  __param(1, Inject(KERNEL_BUS)),
402
411
  __param(2, Inject(KERNEL_LOGGER)),
403
- __param(3, Inject(KernelEvents)),
412
+ __param(3, Inject(OutboxService)),
404
413
  __param(4, Inject(TransactionHost))
405
414
  ], EventLog);
406
415
  export { EventLog };
@@ -776,7 +776,8 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
776
776
  * naming a template's skills the child loads first (skills default-on spec §6.1).
777
777
  */
778
778
  preamble: z.string(),
779
- maxSteps: z.number().int().positive(),
779
+ /** The child's step limit; 0 = no limit (`runtime.maxSteps` 0, no template limit). */
780
+ maxSteps: z.number().int().nonnegative(),
780
781
  warnings: z.array(z.string()).optional(),
781
782
  })),
782
783
  /**
@@ -12,12 +12,12 @@ export declare class ConversationQueue {
12
12
  private readonly db;
13
13
  private readonly eventLog;
14
14
  private readonly conversations;
15
- /** Starts the conversation's next run (`ensureRun`). */
15
+ /** Starts the conversation's next run after a commit (a failure is logged, never thrown). */
16
16
  private readonly runs;
17
17
  readonly txHost: TransactionHost;
18
18
  constructor(db: KernelDb, eventLog: Pick<EventLog, "appendIn" | "notify" | "publishChanged" | "findByIdem">, conversations: Pick<ConversationsService, "get" | "writable" | "resolveExtra" | "bindIn" | "checkPick" | "prepareQueuedSkill" | "skipWaitsIn" | "announceSkipped">,
19
- /** Starts the conversation's next run (`ensureRun`). */
20
- runs: Pick<RunControl, "ensureRun" | "wakeHeldTree">, txHost: TransactionHost);
19
+ /** Starts the conversation's next run after a commit (a failure is logged, never thrown). */
20
+ runs: Pick<RunControl, "ensureRunAfterCommit" | "oweEnsureRun" | "wakeHeldTree" | "oweHeldTreeIn">, txHost: TransactionHost);
21
21
  list(orgId: string, conversationId: string, accountId: string): Promise<{
22
22
  items: QueueItem[];
23
23
  paused: boolean;
@@ -60,6 +60,11 @@ export declare class ConversationQueue {
60
60
  private sendNowIn;
61
61
  /** "Continue sending": clears the pause and lets `ensureRun` send the head item. */
62
62
  resume(orgId: string, conversationId: string, accountId: string): Promise<void>;
63
+ /**
64
+ * Clears the pause and owes the ensure-run backstop that sends the head item (no event of its
65
+ * own, so under the conversation's newest seq; transactional outbox spec §6).
66
+ */
67
+ private resumeIn;
63
68
  /** A queued item or a sent message for this client id (outside any transaction). */
64
69
  private prior;
65
70
  private lockConversation;
@@ -31,7 +31,7 @@ let ConversationQueue = class ConversationQueue {
31
31
  runs;
32
32
  txHost;
33
33
  constructor(db, eventLog, conversations,
34
- /** Starts the conversation's next run (`ensureRun`). */
34
+ /** Starts the conversation's next run after a commit (a failure is logged, never thrown). */
35
35
  runs, txHost) {
36
36
  this.db = db;
37
37
  this.eventLog = eventLog;
@@ -101,16 +101,16 @@ let ConversationQueue = class ConversationQueue {
101
101
  }
102
102
  if (out.created) {
103
103
  await this.eventLog.publishChanged(conversationId, "queue");
104
- await this.runs.ensureRun(conversationId);
104
+ await this.runs.ensureRunAfterCommit(conversationId);
105
105
  }
106
106
  return { item: toItem(out.row), created: out.created };
107
107
  }
108
108
  // its own transaction: the caller notifies and publishes after the commit
109
109
  async addIn(orgId, conversationId, accountId, input, files, skill, extra, internal) {
110
110
  const t = this.db.db;
111
- await t
111
+ const conv = await t
112
112
  .selectFrom("conversations")
113
- .select("id")
113
+ .select("last_seq")
114
114
  .where("id", "=", conversationId)
115
115
  .forUpdate()
116
116
  .executeTakeFirstOrThrow();
@@ -168,6 +168,9 @@ let ConversationQueue = class ConversationQueue {
168
168
  })
169
169
  .returning(COLUMNS)
170
170
  .executeTakeFirstOrThrow();
171
+ // on an idle conversation the item goes out at once: owed with it (no event of its own, so
172
+ // under the conversation's newest seq; transactional outbox spec §6)
173
+ await this.runs.oweEnsureRun(conversationId, conv.last_seq, orgId);
171
174
  return { row, created: true };
172
175
  }
173
176
  /**
@@ -253,6 +256,8 @@ let ConversationQueue = class ConversationQueue {
253
256
  // a task's queued message deleted by a person: its run is skipped (scheduled tasks §6)
254
257
  await releaseQueuedTaskRunIn(t, gone.schedule);
255
258
  await unpauseIfEmpty(t, conversationId);
259
+ // the wakes an unpause releases for the tree are owed with it (transactional outbox spec §6)
260
+ await this.runs.oweHeldTreeIn(conversationId);
256
261
  }
257
262
  /**
258
263
  * Sends a queued item now: it leaves the queue and is posted as a user message in the same
@@ -263,7 +268,7 @@ let ConversationQueue = class ConversationQueue {
263
268
  */
264
269
  async sendNow(orgId, conversationId, accountId, itemId) {
265
270
  await this.conversations.writable(orgId, conversationId, accountId);
266
- const { event, fresh, switched, unarchived, skipped, toSeq } = await this.sendNowIn(conversationId, itemId);
271
+ const { event, fresh, switched, unarchived, skipped, toSeq } = await this.sendNowIn(orgId, conversationId, itemId);
267
272
  if (fresh)
268
273
  await this.eventLog.notify(conversationId, toSeq);
269
274
  await this.conversations.announceSkipped(skipped);
@@ -272,12 +277,12 @@ let ConversationQueue = class ConversationQueue {
272
277
  if (unarchived)
273
278
  await this.eventLog.publishChanged(conversationId, "archived");
274
279
  await this.eventLog.publishChanged(conversationId, "queue");
275
- await this.runs.ensureRun(conversationId);
280
+ await this.runs.ensureRunAfterCommit(conversationId);
276
281
  await this.runs.wakeHeldTree(conversationId);
277
282
  return event;
278
283
  }
279
284
  // its own transaction: the caller notifies and publishes after the commit
280
- async sendNowIn(conversationId, itemId) {
285
+ async sendNowIn(orgId, conversationId, itemId) {
281
286
  const t = this.db.db;
282
287
  await this.lockConversation(conversationId);
283
288
  const head = await t
@@ -313,6 +318,10 @@ let ConversationQueue = class ConversationQueue {
313
318
  const skips = sent
314
319
  ? { skipped: NO_REPLY_SKIPS, toSeq: null }
315
320
  : await this.conversations.skipWaitsIn(conversationId, row.account_id, out.event.seq);
321
+ // the run the sent message starts is owed with it (transactional outbox spec §6), and so are
322
+ // the wakes the unpause releases for the tree
323
+ await this.runs.oweEnsureRun(conversationId, out.event.seq, orgId);
324
+ await this.runs.oweHeldTreeIn(conversationId);
316
325
  return {
317
326
  ...out,
318
327
  fresh: !sent,
@@ -323,16 +332,28 @@ let ConversationQueue = class ConversationQueue {
323
332
  /** "Continue sending": clears the pause and lets `ensureRun` send the head item. */
324
333
  async resume(orgId, conversationId, accountId) {
325
334
  await this.conversations.writable(orgId, conversationId, accountId);
326
- await this.db
327
- .updateTable("conversations")
328
- .set({ queue_paused: false, queue_pause_reason: null })
329
- .where("id", "=", conversationId)
330
- .execute();
335
+ await this.resumeIn(orgId, conversationId);
331
336
  await this.eventLog.publishChanged(conversationId, "queue");
332
- await this.runs.ensureRun(conversationId);
337
+ await this.runs.ensureRunAfterCommit(conversationId);
333
338
  // a paused root holds the wakes of its whole tree (agent map spec §5.3)
334
339
  await this.runs.wakeHeldTree(conversationId);
335
340
  }
341
+ /**
342
+ * Clears the pause and owes the ensure-run backstop that sends the head item (no event of its
343
+ * own, so under the conversation's newest seq; transactional outbox spec §6).
344
+ */
345
+ // its own transaction: the caller publishes and starts the run after the commit
346
+ async resumeIn(orgId, conversationId) {
347
+ const conv = await this.db.db
348
+ .updateTable("conversations")
349
+ .set({ queue_paused: false, queue_pause_reason: null })
350
+ .where("id", "=", conversationId)
351
+ .returning("last_seq")
352
+ .executeTakeFirstOrThrow();
353
+ await this.runs.oweEnsureRun(conversationId, conv.last_seq, orgId);
354
+ // the wakes the root held for its tree (agent map spec §5.3) are owed with the unpause
355
+ await this.runs.oweHeldTreeIn(conversationId);
356
+ }
336
357
  /** A queued item or a sent message for this client id (outside any transaction). */
337
358
  async prior(conversationId, clientMessageId) {
338
359
  const row = await this.db
@@ -370,6 +391,9 @@ __decorate([
370
391
  __decorate([
371
392
  Transactional({ propagation: "requires_new" })
372
393
  ], ConversationQueue.prototype, "sendNowIn", null);
394
+ __decorate([
395
+ Transactional({ propagation: "requires_new" })
396
+ ], ConversationQueue.prototype, "resumeIn", null);
373
397
  __decorate([
374
398
  Transactional({ propagation: "mandatory" })
375
399
  ], ConversationQueue.prototype, "lockConversation", null);
@@ -5,7 +5,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
6
  import { ModelPurposesService } from "../models/purposes.js";
7
7
  import { type AuditEntry, type HookRunner } from "../runtime/hook-calls.js";
8
- import { UsageReporter } from "../runtime/usage-report.js";
8
+ import { UsageReportJobs } from "../runtime/usage-report-jobs.js";
9
9
  import { EventLog } from "./event-log.js";
10
10
  import { type ConversationEvent } from "./events.js";
11
11
  /**
@@ -56,7 +56,7 @@ export declare function titleExcerpt(firstUser: string, firstReply: string): str
56
56
  export declare function cleanTitle(reply: string): string | null;
57
57
  export interface TitleDeps {
58
58
  db: KernelSchemaDb;
59
- eventLog: Pick<EventLog, "append" | "appendIn" | "readAfter" | "latestOfType" | "notify" | "publishChanged">;
59
+ eventLog: Pick<EventLog, "appendInReport" | "readAfter" | "latestOfType" | "notify" | "publishChanged">;
60
60
  purposes: Pick<ModelPurposesService, "chat">;
61
61
  log: Pick<Logger, "warn">;
62
62
  /**
@@ -64,11 +64,10 @@ export interface TitleDeps {
64
64
  * title and uses up the attempt) and `model.response` with `purpose: "title"`, like compaction.
65
65
  */
66
66
  hooks?: HookRunner;
67
- usageReport?: Pick<UsageReporter, "enqueue">;
68
67
  /** Aborts the call (worker shutdown). */
69
68
  signal?: AbortSignal;
70
69
  /** The job's transactional writes ({@link TitleGenerator}). */
71
- writes: Pick<TitleGenerator, "writeResult" | "auditDenied">;
70
+ writes: Pick<TitleGenerator, "writeResult" | "writeUsage" | "auditDenied">;
72
71
  }
73
72
  /** The attempt number to enqueue for this conversation, or null when no title job is due. */
74
73
  export declare function titleAttemptDue(db: KernelSchemaDb, conversationId: string): Promise<number | null>;
@@ -93,19 +92,22 @@ export declare class TitleGenerator {
93
92
  private readonly purposes;
94
93
  /** The title call fires the plugin hooks (`model.request`, `model.response`). */
95
94
  private readonly host;
96
- private readonly usageReport;
95
+ /** The title call's `usage.report` delivery, owed with its usage event. */
96
+ private readonly usage;
97
97
  private readonly log;
98
98
  readonly txHost: TransactionHost;
99
99
  constructor(kdb: KernelDb, eventLog: TitleDeps["eventLog"], purposes: Pick<ModelPurposesService, "chat">,
100
100
  /** The title call fires the plugin hooks (`model.request`, `model.response`). */
101
101
  host: {
102
102
  readonly hooks?: HookRunner;
103
- } | undefined, usageReport: Pick<UsageReporter, "enqueue"> | undefined, log: Pick<Logger, "warn">, txHost: TransactionHost);
103
+ } | undefined,
104
+ /** The title call's `usage.report` delivery, owed with its usage event. */
105
+ usage: Pick<UsageReportJobs, "oweEvents">, log: Pick<Logger, "warn">, txHost: TransactionHost);
104
106
  /** One attempt ({@link runTitleJob}); `signal` aborts the call (the worker stopping). */
105
107
  run(conversationId: string, attempt: number, signal?: AbortSignal): Promise<void>;
106
108
  /**
107
- * Appends the call's `usage` event and writes the title while `title_source IS NULL` (a rename
108
- * wins), in one transaction.
109
+ * Appends the call's `usage` event (owing its `usage.report` delivery) and writes the title while
110
+ * `title_source IS NULL` (a rename wins), in one transaction.
109
111
  */
110
112
  writeResult(conversationId: string, attempt: number, out: {
111
113
  provider: string;
@@ -115,6 +117,17 @@ export declare class TitleGenerator {
115
117
  written: boolean;
116
118
  usage: ConversationEvent | undefined;
117
119
  }>;
120
+ /**
121
+ * Appends the usage event of a call that failed after it was sent (billed, so reported) and owes
122
+ * its `usage.report` delivery, in one transaction.
123
+ */
124
+ writeUsage(conversationId: string, attempt: number, u: {
125
+ provider: string;
126
+ model: string;
127
+ usage: ModelUsage;
128
+ }): Promise<ConversationEvent | undefined>;
129
+ /** The usage event and its owed delivery (only when this call wrote it, not on a retry's hit). */
130
+ private appendUsage;
118
131
  /** The `hook.denied` audit row of a denied title call. */
119
132
  auditDenied(entry: AuditEntry): Promise<void>;
120
133
  }