@oyasmi/pipiclaw 0.9.5 → 0.9.6-beta.2

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 (345) hide show
  1. package/README.en.md +300 -142
  2. package/README.md +295 -140
  3. package/dist/agent/builtin-commands.d.ts +1 -1
  4. package/dist/agent/builtin-commands.js +1 -1
  5. package/dist/agent/channel-runner.d.ts +4 -3
  6. package/dist/agent/channel-runner.js +17 -28
  7. package/dist/agent/maintenance-context.js +2 -2
  8. package/dist/agent/prompt/builder.d.ts +1 -1
  9. package/dist/agent/prompt/builder.js +1 -1
  10. package/dist/agent/prompt/extension.d.ts +1 -1
  11. package/dist/agent/prompt/extension.js +1 -1
  12. package/dist/agent/prompt/manifest.d.ts +6 -1
  13. package/dist/agent/prompt/manifest.js +12 -5
  14. package/dist/agent/prompt/resources.d.ts +0 -3
  15. package/dist/agent/prompt/resources.js +0 -6
  16. package/dist/agent/prompt/sections.d.ts +2 -2
  17. package/dist/agent/prompt/sections.js +36 -26
  18. package/dist/agent/prompt/types.d.ts +3 -2
  19. package/dist/agent/runner-factory.js +1 -1
  20. package/dist/agent/session/command-extension.js +3 -1
  21. package/dist/agent/session/compaction-summary.js +3 -6
  22. package/dist/agent/session/compaction.d.ts +2 -0
  23. package/dist/agent/session/compaction.js +22 -14
  24. package/dist/agent/session/event-guards.d.ts +2 -1
  25. package/dist/agent/session/event-guards.js +6 -0
  26. package/dist/agent/session/model-selection.d.ts +2 -1
  27. package/dist/agent/session/model-selection.js +5 -5
  28. package/dist/agent/session/session-events.js +31 -4
  29. package/dist/agent/session/session-host.d.ts +5 -3
  30. package/dist/agent/session/session-host.js +20 -16
  31. package/dist/agent/status-render.js +3 -0
  32. package/dist/agent/stop-watchdog.js +5 -1
  33. package/dist/agent/turn/task-digest.d.ts +2 -5
  34. package/dist/agent/turn/task-digest.js +25 -45
  35. package/dist/agent/turn/turn-context.js +4 -6
  36. package/dist/agent/turn/turn-error.d.ts +1 -1
  37. package/dist/agent/turn/turn-error.js +9 -0
  38. package/dist/agent/turn/turn-pipeline.d.ts +10 -5
  39. package/dist/agent/turn/turn-pipeline.js +36 -7
  40. package/dist/agent/turn/turn-prompt.d.ts +2 -0
  41. package/dist/agent/turn/turn-prompt.js +2 -1
  42. package/dist/agent/turn/turn-recovery.js +4 -1
  43. package/dist/agent/turn/turn-state.d.ts +2 -0
  44. package/dist/agent/turn/turn-state.js +2 -1
  45. package/dist/agent/types.d.ts +23 -3
  46. package/dist/agent/types.js +2 -0
  47. package/dist/app/auth-command.d.ts +25 -0
  48. package/dist/app/auth-command.js +200 -67
  49. package/dist/app/home.d.ts +7 -8
  50. package/dist/app/home.js +143 -56
  51. package/dist/channel/attachments.d.ts +4 -0
  52. package/dist/channel/attachments.js +4 -0
  53. package/dist/channel/channel-context.d.ts +6 -0
  54. package/dist/channel/config.d.ts +3 -0
  55. package/dist/channel/config.js +11 -5
  56. package/dist/channel/store.d.ts +1 -1
  57. package/dist/commands/catalog.js +42 -10
  58. package/dist/commands/router.js +5 -1
  59. package/dist/desk/commands.d.ts +44 -5
  60. package/dist/desk/commands.js +162 -28
  61. package/dist/desk/paths.d.ts +6 -0
  62. package/dist/desk/paths.js +21 -1
  63. package/dist/desk/registry.d.ts +17 -2
  64. package/dist/desk/registry.js +122 -12
  65. package/dist/desk/types.d.ts +83 -1
  66. package/dist/dingtalk/bot.d.ts +1 -1
  67. package/dist/dingtalk/bot.js +4 -3
  68. package/dist/dingtalk/config.js +10 -10
  69. package/dist/dingtalk/delivery.js +15 -8
  70. package/dist/dingtalk/inbound-media.d.ts +36 -14
  71. package/dist/dingtalk/inbound-media.js +71 -12
  72. package/dist/dingtalk/inbound.d.ts +9 -2
  73. package/dist/dingtalk/inbound.js +17 -2
  74. package/dist/dingtalk/media.d.ts +4 -10
  75. package/dist/dingtalk/media.js +58 -32
  76. package/dist/events/commands.d.ts +2 -0
  77. package/dist/events/commands.js +13 -8
  78. package/dist/events/history.d.ts +9 -0
  79. package/dist/events/history.js +66 -0
  80. package/dist/events/parse.js +7 -3
  81. package/dist/events/types.d.ts +3 -0
  82. package/dist/events/watcher.d.ts +4 -8
  83. package/dist/events/watcher.js +53 -58
  84. package/dist/jobs/kill.d.ts +23 -0
  85. package/dist/jobs/kill.js +65 -0
  86. package/dist/jobs/manager.d.ts +19 -18
  87. package/dist/jobs/manager.js +36 -103
  88. package/dist/main.js +15 -3
  89. package/dist/memory/boundary-work.d.ts +2 -1
  90. package/dist/memory/boundary-work.js +1 -1
  91. package/dist/memory/lifecycle.d.ts +2 -1
  92. package/dist/memory/lifecycle.js +2 -2
  93. package/dist/memory/reflect-job.d.ts +2 -1
  94. package/dist/memory/reflect-job.js +1 -1
  95. package/dist/memory/reflect.d.ts +2 -1
  96. package/dist/memory/reflect.js +25 -4
  97. package/dist/memory/scheduler.d.ts +2 -1
  98. package/dist/memory/scheduler.js +1 -1
  99. package/dist/memory/session-corpus.d.ts +1 -1
  100. package/dist/memory/session-corpus.js +76 -1
  101. package/dist/memory/session-search.d.ts +2 -1
  102. package/dist/memory/session-search.js +14 -12
  103. package/dist/memory/sidecar-worker.d.ts +2 -1
  104. package/dist/memory/sidecar-worker.js +2 -4
  105. package/dist/memory/store.d.ts +2 -0
  106. package/dist/memory/store.js +19 -9
  107. package/dist/models/credential-work.d.ts +7 -0
  108. package/dist/models/credential-work.js +36 -0
  109. package/dist/models/login-ui.js +4 -4
  110. package/dist/models/provider-login.js +7 -6
  111. package/dist/models/requests.d.ts +8 -0
  112. package/dist/models/requests.js +69 -0
  113. package/dist/models/runtime.d.ts +3 -1
  114. package/dist/models/runtime.js +9 -2
  115. package/dist/playbooks/agent-delegation.md +20 -45
  116. package/dist/playbooks/background-jobs.md +1 -1
  117. package/dist/playbooks/catalog.js +1 -1
  118. package/dist/playbooks/delegation-inline.md +25 -0
  119. package/dist/playbooks/delegation-recovery.md +28 -0
  120. package/dist/playbooks/event-scheduling.md +18 -37
  121. package/dist/playbooks/event-sensors.md +26 -0
  122. package/dist/playbooks/event-task-template.md +22 -0
  123. package/dist/playbooks/learning-and-skills.md +26 -0
  124. package/dist/playbooks/memory-operations.md +36 -0
  125. package/dist/playbooks/outbound-media.md +2 -2
  126. package/dist/playbooks/runtime-files.md +29 -0
  127. package/dist/playbooks/runtime-operations.md +25 -0
  128. package/dist/playbooks/runtime-orientation.md +18 -53
  129. package/dist/playbooks/task-lead.md +22 -68
  130. package/dist/playbooks/task-manage.md +38 -0
  131. package/dist/playbooks/task-recovery.md +24 -0
  132. package/dist/playbooks/task-verify.md +22 -0
  133. package/dist/runtime/bootstrap.d.ts +10 -0
  134. package/dist/runtime/bootstrap.js +93 -29
  135. package/dist/runtime/daemon-lock.js +3 -3
  136. package/dist/runtime/desk-runtime.d.ts +40 -7
  137. package/dist/runtime/desk-runtime.js +330 -44
  138. package/dist/runtime/durable-dispatch.d.ts +14 -2
  139. package/dist/runtime/durable-dispatch.js +207 -65
  140. package/dist/runtime/ingress-busy.js +17 -8
  141. package/dist/runtime/ingress-commands.js +24 -4
  142. package/dist/runtime/ingress-deps.d.ts +4 -1
  143. package/dist/runtime/ingress.js +6 -1
  144. package/dist/runtime/request-execution.js +7 -6
  145. package/dist/runtime/shutdown.d.ts +4 -1
  146. package/dist/runtime/shutdown.js +88 -35
  147. package/dist/runtime/task-close.d.ts +1 -1
  148. package/dist/runtime/task-close.js +6 -3
  149. package/dist/runtime/task-control.d.ts +2 -3
  150. package/dist/runtime/task-control.js +38 -11
  151. package/dist/runtime/task-input.js +1 -1
  152. package/dist/runtime/task-lane-types.d.ts +12 -2
  153. package/dist/runtime/task-lane-types.js +9 -0
  154. package/dist/runtime/task-lane.d.ts +2 -0
  155. package/dist/runtime/task-lane.js +38 -20
  156. package/dist/runtime/task-step.d.ts +3 -3
  157. package/dist/runtime/task-step.js +34 -16
  158. package/dist/runtime/transports.js +6 -5
  159. package/dist/runtime/turn-run.js +103 -66
  160. package/dist/security/command-guard.d.ts +1 -1
  161. package/dist/security/command-guard.js +259 -314
  162. package/dist/security/path-guard.js +48 -7
  163. package/dist/security/shell-parse.d.ts +10 -0
  164. package/dist/security/shell-parse.js +224 -0
  165. package/dist/security/types.d.ts +2 -0
  166. package/dist/subagents/commands.d.ts +1 -1
  167. package/dist/subagents/commands.js +14 -5
  168. package/dist/subagents/completion-wake.js +6 -0
  169. package/dist/subagents/detached-discovery.d.ts +1 -1
  170. package/dist/subagents/discovery.d.ts +18 -199
  171. package/dist/subagents/discovery.js +35 -289
  172. package/dist/subagents/dispatch.d.ts +1 -2
  173. package/dist/subagents/dispatch.js +50 -29
  174. package/dist/subagents/external/antigravity-cli.d.ts +2 -0
  175. package/dist/subagents/external/antigravity-cli.js +517 -0
  176. package/dist/subagents/external/claude-code.js +8 -17
  177. package/dist/subagents/external/codex-cli.js +8 -18
  178. package/dist/subagents/external/cursor-cli.js +34 -31
  179. package/dist/subagents/external/dispatch.d.ts +21 -7
  180. package/dist/subagents/external/dispatch.js +146 -12
  181. package/dist/subagents/external/exec.js +3 -0
  182. package/dist/subagents/external/harness.d.ts +57 -33
  183. package/dist/subagents/external/harness.js +69 -40
  184. package/dist/subagents/external/reconciliation.js +1 -0
  185. package/dist/subagents/external/registry.js +4 -1
  186. package/dist/subagents/external/role-warnings.d.ts +4 -13
  187. package/dist/subagents/external/role-warnings.js +4 -28
  188. package/dist/subagents/external/run.d.ts +1 -2
  189. package/dist/subagents/external/run.js +16 -26
  190. package/dist/subagents/external/settlement.d.ts +2 -0
  191. package/dist/subagents/external/settlement.js +13 -3
  192. package/dist/subagents/format.d.ts +1 -1
  193. package/dist/subagents/format.js +1 -1
  194. package/dist/subagents/internal/outcome.d.ts +1 -2
  195. package/dist/subagents/internal/outcome.js +19 -12
  196. package/dist/subagents/internal/provider-retry.d.ts +1 -2
  197. package/dist/subagents/internal/provider-retry.js +2 -4
  198. package/dist/subagents/internal/run.d.ts +2 -3
  199. package/dist/subagents/internal/run.js +27 -4
  200. package/dist/subagents/internal/state.d.ts +2 -5
  201. package/dist/subagents/internal/state.js +1 -2
  202. package/dist/subagents/internal/worker.d.ts +1 -2
  203. package/dist/subagents/internal/worker.js +20 -10
  204. package/dist/subagents/resolve.d.ts +56 -0
  205. package/dist/subagents/resolve.js +202 -0
  206. package/dist/subagents/result.d.ts +6 -4
  207. package/dist/subagents/result.js +39 -6
  208. package/dist/subagents/run-record.d.ts +54 -2
  209. package/dist/subagents/run-record.js +7 -0
  210. package/dist/subagents/runs.d.ts +6 -31
  211. package/dist/subagents/runs.js +26 -31
  212. package/dist/subagents/task-envelope.d.ts +1 -2
  213. package/dist/subagents/task-envelope.js +13 -4
  214. package/dist/subagents/task-settlement.js +1 -0
  215. package/dist/subagents/types.d.ts +105 -6
  216. package/dist/subagents/types.js +16 -1
  217. package/dist/subagents/workspace-lease.d.ts +41 -24
  218. package/dist/subagents/workspace-lease.js +159 -24
  219. package/dist/subagents/worktree.d.ts +52 -0
  220. package/dist/subagents/worktree.js +363 -0
  221. package/dist/tasks/archive.js +4 -0
  222. package/dist/tasks/brief.d.ts +5 -1
  223. package/dist/tasks/brief.js +19 -5
  224. package/dist/tasks/commands.d.ts +6 -1
  225. package/dist/tasks/commands.js +32 -7
  226. package/dist/tasks/control.d.ts +11 -0
  227. package/dist/tasks/delivery.d.ts +2 -0
  228. package/dist/tasks/delivery.js +141 -21
  229. package/dist/tasks/loop-log.d.ts +12 -0
  230. package/dist/tasks/loop-log.js +10 -1
  231. package/dist/tasks/receipts.d.ts +7 -3
  232. package/dist/tasks/receipts.js +34 -5
  233. package/dist/tools/bash.d.ts +3 -0
  234. package/dist/tools/bash.js +29 -15
  235. package/dist/tools/contract/presentation.js +7 -5
  236. package/dist/tools/edit-diff.d.ts +11 -0
  237. package/dist/tools/edit-diff.js +148 -0
  238. package/dist/tools/edit-match.d.ts +18 -0
  239. package/dist/tools/edit-match.js +242 -0
  240. package/dist/tools/edit.d.ts +10 -2
  241. package/dist/tools/edit.js +91 -361
  242. package/dist/tools/event-manage.d.ts +2 -1
  243. package/dist/tools/event-manage.js +46 -39
  244. package/dist/tools/file-observations.d.ts +9 -0
  245. package/dist/tools/file-observations.js +50 -0
  246. package/dist/tools/glob-match.d.ts +3 -1
  247. package/dist/tools/glob-match.js +40 -17
  248. package/dist/tools/glob.d.ts +1 -0
  249. package/dist/tools/glob.js +39 -19
  250. package/dist/tools/grep-command.d.ts +13 -0
  251. package/dist/tools/grep-command.js +77 -0
  252. package/dist/tools/grep.js +96 -201
  253. package/dist/tools/index.d.ts +6 -2
  254. package/dist/tools/index.js +9 -4
  255. package/dist/tools/job.js +12 -11
  256. package/dist/tools/read.d.ts +2 -0
  257. package/dist/tools/read.js +10 -2
  258. package/dist/tools/registry.d.ts +16 -11
  259. package/dist/tools/registry.js +32 -12
  260. package/dist/tools/send-media.js +9 -5
  261. package/dist/tools/session-search.d.ts +2 -1
  262. package/dist/tools/session-search.js +15 -5
  263. package/dist/tools/skill.js +13 -12
  264. package/dist/tools/subagent-manage.d.ts +1 -1
  265. package/dist/tools/subagent-manage.js +25 -152
  266. package/dist/tools/subagent.d.ts +24 -2
  267. package/dist/tools/subagent.js +24 -18
  268. package/dist/tools/task-manage/control-tools.js +1 -1
  269. package/dist/tools/task-manage/factory.d.ts +2 -2
  270. package/dist/tools/task-manage/factory.js +40 -4
  271. package/dist/tools/task-manage/lifecycle.d.ts +3 -3
  272. package/dist/tools/task-manage/lifecycle.js +56 -13
  273. package/dist/tools/task-manage/schema.d.ts +4 -1
  274. package/dist/tools/task-manage/schema.js +4 -1
  275. package/dist/tools/task-manage/shared.d.ts +1 -1
  276. package/dist/tools/task-manage/types.d.ts +5 -1
  277. package/dist/tools/write-content.d.ts +7 -1
  278. package/dist/tools/write-content.js +18 -6
  279. package/dist/tools/write.d.ts +3 -0
  280. package/dist/tools/write.js +6 -2
  281. package/dist/tui/cli.d.ts +6 -6
  282. package/dist/tui/cli.js +120 -28
  283. package/dist/tui/client.d.ts +7 -0
  284. package/dist/tui/client.js +67 -16
  285. package/dist/tui/frontend.d.ts +2 -0
  286. package/dist/tui/pitui-frontend.d.ts +4 -0
  287. package/dist/tui/pitui-frontend.js +27 -0
  288. package/dist/tui/render.d.ts +1 -0
  289. package/dist/tui/render.js +5 -0
  290. package/dist/tui/session.js +6 -0
  291. package/dist/usage/ledger.d.ts +1 -1
  292. package/dist/usage/render.js +1 -1
  293. package/dist/web/client.d.ts +1 -0
  294. package/dist/web/client.js +11 -0
  295. package/dist/web/fetch.js +6 -3
  296. package/dist/webapi/auth.d.ts +0 -3
  297. package/dist/webapi/auth.js +3 -7
  298. package/dist/webapi/config.js +17 -14
  299. package/dist/webapi/key-command.js +41 -41
  300. package/dist/webapi/response-state.d.ts +7 -1
  301. package/dist/webapi/response-state.js +166 -3
  302. package/dist/webapi/routes/websocket.js +24 -1
  303. package/dist/webapi/server.d.ts +3 -1
  304. package/dist/webapi/server.js +32 -1
  305. package/dist/webapi/service.js +8 -0
  306. package/dist/webapi/transport.d.ts +2 -0
  307. package/dist/webapi/transport.js +11 -1
  308. package/examples/sub-agents/README.md +43 -75
  309. package/examples/sub-agents/agy-main.md +21 -0
  310. package/examples/sub-agents/claude-high.md +21 -0
  311. package/examples/sub-agents/claude-main.md +21 -0
  312. package/examples/sub-agents/codex-flash.md +21 -0
  313. package/examples/sub-agents/codex-high.md +21 -0
  314. package/examples/sub-agents/codex-main.md +21 -0
  315. package/examples/sub-agents/codex-review.md +20 -0
  316. package/examples/sub-agents/cursor-high.md +20 -0
  317. package/examples/sub-agents/cursor-main.md +20 -0
  318. package/examples/sub-agents/glm-flash.md +21 -0
  319. package/examples/sub-agents/glm-high.md +21 -0
  320. package/examples/sub-agents/pi-scout.md +20 -0
  321. package/package.json +11 -12
  322. package/dist/agent/session/request-tools.d.ts +0 -3
  323. package/dist/agent/session/request-tools.js +0 -20
  324. package/dist/models/api-keys.d.ts +0 -11
  325. package/dist/models/api-keys.js +0 -22
  326. package/dist/playbooks/memory-and-learning.md +0 -55
  327. package/examples/sub-agents/agents/claude-high.md +0 -23
  328. package/examples/sub-agents/agents/claude-main.md +0 -23
  329. package/examples/sub-agents/agents/codex-flash.md +0 -23
  330. package/examples/sub-agents/agents/codex-high.md +0 -23
  331. package/examples/sub-agents/agents/codex-main.md +0 -23
  332. package/examples/sub-agents/agents/codex-review.md +0 -23
  333. package/examples/sub-agents/agents/cursor-high.md +0 -22
  334. package/examples/sub-agents/agents/cursor-main.md +0 -22
  335. package/examples/sub-agents/agents/glm-flash.md +0 -23
  336. package/examples/sub-agents/agents/glm-high.md +0 -23
  337. package/examples/sub-agents/agents/scout.md +0 -30
  338. package/examples/sub-agents/roles/builder-hard.md +0 -34
  339. package/examples/sub-agents/roles/builder.md +0 -34
  340. package/examples/sub-agents/roles/explorer.md +0 -39
  341. package/examples/sub-agents/roles/git-committer.md +0 -43
  342. package/examples/sub-agents/roles/planner.md +0 -33
  343. package/examples/sub-agents/roles/reviewer.md +0 -33
  344. package/examples/sub-agents/roles/verifier.md +0 -35
  345. package/examples/sub-agents/roles/worker.md +0 -34
@@ -11,14 +11,17 @@
11
11
  import { readdir, readFile } from "node:fs/promises";
12
12
  import { join } from "node:path";
13
13
  import { loadBindings, writeBindings } from "../desk/bindings.js";
14
- import { getDeskDir, isDeskName, normalizeDeskName } from "../desk/paths.js";
15
- import { allocateConversation, createDeskRecord, findConversation, readDeskRecord } from "../desk/registry.js";
14
+ import { buildDeskList } from "../desk/commands.js";
15
+ import { DEFAULT_DESK, DESK_RECORD_FILENAME, getDeskDir, isDeskName, normalizeDeskName } from "../desk/paths.js";
16
+ import { allocateConversation, createDeskRecord, findConversation, listDesks, readDeskRecord, readDeskRecordSync, setDeskArchived, setDeskCwd, validateCustomCwd, } from "../desk/registry.js";
16
17
  import { StartupRefusal } from "../desk/startup-error.js";
17
18
  import { parseScheduledEventContent } from "../events/parse.js";
18
19
  import * as log from "../log.js";
20
+ import { fileStamp } from "../shared/format.js";
19
21
  import { createSerialQueue } from "../shared/serial-queue.js";
20
22
  import { errorMessage } from "../shared/text-utils.js";
21
23
  import { readActiveTasks } from "../tasks/contract.js";
24
+ import { readTaskDeliveries } from "../tasks/delivery.js";
22
25
  /** The desk a resolution names, bound or not; `undefined` for a channel with no binding. */
23
26
  export function resolvedDesk(resolution) {
24
27
  switch (resolution.kind) {
@@ -43,8 +46,9 @@ export class DeskRuntime {
43
46
  constructor(options) {
44
47
  this.options = options;
45
48
  this.bindings = { version: 1, bindings: {} };
46
- /** Every desk a binding points at, as last read from disk. */
49
+ /** Every desk a binding or scan has touched, kept fresh when `desk.json`'s stamp changes. */
47
50
  this.records = new Map();
51
+ this.recordStamps = new Map();
48
52
  this.active = new Set();
49
53
  this.watchers = new Map();
50
54
  /** Activation and dormancy of one desk run in order, so interleaved calls settle on the last one. */
@@ -80,6 +84,8 @@ export class DeskRuntime {
80
84
  async refreshRecord(desk) {
81
85
  const summary = await readDeskRecord(this.options.workspaceDir, desk);
82
86
  this.records.set(desk, summary);
87
+ if (summary.deskDir)
88
+ this.recordStamps.set(desk, deskRecordStamp(summary.deskDir));
83
89
  if (summary.availability !== "available") {
84
90
  log.logWarn("desk.record.unavailable", "Bound desk is unavailable", {
85
91
  reason: summary.reason,
@@ -88,11 +94,33 @@ export class DeskRuntime {
88
94
  }
89
95
  return summary;
90
96
  }
97
+ syncRecordIfChanged(desk) {
98
+ if (!isDeskName(desk))
99
+ return this.records.get(desk);
100
+ const deskDir = getDeskDir(this.options.workspaceDir, desk);
101
+ const stamp = deskRecordStamp(deskDir);
102
+ if (this.recordStamps.get(desk) === stamp && this.records.has(desk)) {
103
+ return this.records.get(desk);
104
+ }
105
+ const prevCwd = this.records.get(desk)?.record?.cwd;
106
+ const summary = readDeskRecordSync(this.options.workspaceDir, desk);
107
+ this.records.set(desk, summary);
108
+ this.recordStamps.set(desk, stamp);
109
+ const nextCwd = summary.record?.cwd;
110
+ if (prevCwd !== nextCwd && this.active.has(desk) && this.servicesStarted) {
111
+ void this.stopWatcher(desk).then(() => {
112
+ if (this.active.has(desk) && this.servicesStarted && !summary.record?.archivedAt) {
113
+ this.startWatcher(desk);
114
+ }
115
+ });
116
+ }
117
+ return summary;
118
+ }
91
119
  resolve(channelId) {
92
120
  const binding = this.bindings.bindings[channelId];
93
121
  if (!binding)
94
122
  return { kind: "unbound" };
95
- const summary = this.records.get(binding.desk);
123
+ const summary = this.syncRecordIfChanged(binding.desk);
96
124
  if (!summary?.record) {
97
125
  return { kind: "unavailable", desk: binding.desk, reason: summary?.reason ?? "desk not loaded" };
98
126
  }
@@ -102,6 +130,29 @@ export class DeskRuntime {
102
130
  }
103
131
  return { kind: "bound", conversation };
104
132
  }
133
+ /** Effective working directory of `desk`, independent of whether any channel is currently bound to it. */
134
+ deskCwd(desk) {
135
+ const summary = this.syncRecordIfChanged(desk);
136
+ return summary?.record ? (summary.record.cwd ?? summary.deskDir) : undefined;
137
+ }
138
+ /**
139
+ * Build the `DeskConversation` a task runner in `desk` needs for `channelId`, even after
140
+ * `channelId` has rebound to another desk (Direction 1.2: background task execution is decoupled
141
+ * from current chat binding; `desk.json` retains the registered conversation record).
142
+ */
143
+ taskConversation(desk, channelId) {
144
+ const summary = this.syncRecordIfChanged(desk);
145
+ if (!summary?.record || summary.record.archivedAt)
146
+ return undefined;
147
+ return (findConversation(summary.record, summary.deskDir, channelId) ?? {
148
+ desk,
149
+ deskDir: summary.deskDir,
150
+ cwd: summary.record.cwd ?? summary.deskDir,
151
+ channelId,
152
+ conversation: "task",
153
+ conversationDir: join(summary.deskDir, "tasks", ".sessions"),
154
+ });
155
+ }
105
156
  /** The producer- and admission-side check of INV-5: is this channel bound to this (available) desk? */
106
157
  isBoundTo(channelId, desk) {
107
158
  const resolution = this.resolve(channelId);
@@ -141,9 +192,22 @@ export class DeskRuntime {
141
192
  .filter(([, binding]) => binding.desk === desk)
142
193
  .map(([channelId]) => channelId);
143
194
  }
144
- /** Startup: activate every desk that has at least one binding. */
195
+ /** Startup: activate every non-archived desk that has a binding or retained background work. */
145
196
  async activateBound() {
146
- for (const desk of new Set(Object.values(this.bindings.bindings).map((binding) => binding.desk))) {
197
+ const candidates = new Set(Object.values(this.bindings.bindings).map((binding) => binding.desk));
198
+ for (const summary of await listDesks(this.options.workspaceDir)) {
199
+ this.records.set(summary.name, summary);
200
+ if (summary.deskDir)
201
+ this.recordStamps.set(summary.name, deskRecordStamp(summary.deskDir));
202
+ if (summary.availability === "available" &&
203
+ summary.record &&
204
+ !summary.record.archivedAt &&
205
+ !candidates.has(summary.name) &&
206
+ (await hasRetainedBackgroundWork(summary.deskDir))) {
207
+ candidates.add(summary.name);
208
+ }
209
+ }
210
+ for (const desk of candidates) {
147
211
  await this.activate(desk);
148
212
  }
149
213
  }
@@ -156,20 +220,22 @@ export class DeskRuntime {
156
220
  if (this.active.has(desk))
157
221
  return;
158
222
  const summary = await this.refreshRecord(desk);
159
- if (!summary.record)
223
+ if (!summary.record || summary.record.archivedAt)
160
224
  return;
161
225
  const conversations = this.boundChannelsOf(desk).flatMap((channelId) => {
162
226
  const resolution = this.resolve(channelId);
163
227
  return resolution.kind === "bound" ? [resolution.conversation] : [];
164
228
  });
165
- try {
166
- await this.options.recover(conversations);
167
- }
168
- catch (error) {
169
- log.logWarn("desk.activate.recover_failed", "Interrupted-turn repair failed during activation", {
170
- reason: errorMessage(error),
171
- fields: { desk },
172
- });
229
+ if (conversations.length > 0) {
230
+ try {
231
+ await this.options.recover(conversations);
232
+ }
233
+ catch (error) {
234
+ log.logWarn("desk.activate.recover_failed", "Interrupted-turn repair failed during activation", {
235
+ reason: errorMessage(error),
236
+ fields: { desk },
237
+ });
238
+ }
173
239
  }
174
240
  this.active.add(desk);
175
241
  if (this.servicesStarted)
@@ -187,10 +253,27 @@ export class DeskRuntime {
187
253
  log.logInfoEvent("desk.deactivated", "Desk went dormant: no bound channel", { fields: { desk } });
188
254
  });
189
255
  }
256
+ /** Put an unbound desk to sleep once its last runnable task and task-spawning event are gone. */
257
+ reconcileActivity(desk) {
258
+ if (!this.active.has(desk) || this.boundChannelsOf(desk).length > 0)
259
+ return Promise.resolve();
260
+ return this.lifecycle.run(desk, async () => {
261
+ if (!this.active.has(desk) || this.boundChannelsOf(desk).length > 0)
262
+ return;
263
+ const summary = await this.refreshRecord(desk);
264
+ if (!summary.record || summary.record.archivedAt || !(await hasRetainedBackgroundWork(summary.deskDir))) {
265
+ await this.stopWatcher(desk);
266
+ this.active.delete(desk);
267
+ log.logInfoEvent("desk.deactivated", "Desk went dormant: background work finished", { fields: { desk } });
268
+ }
269
+ });
270
+ }
190
271
  startWatcher(desk) {
191
272
  if (this.watchers.has(desk))
192
273
  return;
193
- const watcher = this.options.createWatcher({ desk, deskDir: getDeskDir(this.options.workspaceDir, desk) });
274
+ const deskDir = getDeskDir(this.options.workspaceDir, desk);
275
+ const cwd = this.records.get(desk)?.record?.cwd ?? deskDir;
276
+ const watcher = this.options.createWatcher({ desk, deskDir, cwd });
194
277
  this.watchers.set(desk, watcher);
195
278
  watcher.start();
196
279
  }
@@ -203,8 +286,160 @@ export class DeskRuntime {
203
286
  await watcher.flush?.().catch(() => undefined);
204
287
  }
205
288
  /** `/desk new`: an empty desk, bound to nothing and therefore dormant (D5). */
206
- create(name) {
207
- return Promise.resolve(createDeskRecord(this.options.workspaceDir, normalizeDeskName(name), new Date()));
289
+ create(name, cwd) {
290
+ return Promise.resolve(createDeskRecord(this.options.workspaceDir, normalizeDeskName(name), new Date(), cwd));
291
+ }
292
+ /** `/desk list` rows enriched with live background task and pending-delivery counts. */
293
+ async listDeskItems(askingChannelId, labelOf) {
294
+ const desks = await listDesks(this.options.workspaceDir);
295
+ const activity = new Map();
296
+ await Promise.all(desks.map(async (summary) => {
297
+ if (summary.availability !== "available" || !summary.record || summary.record.archivedAt)
298
+ return;
299
+ const activeTasks = (await readActiveTasks(join(summary.deskDir, "tasks")).catch(() => [])).filter((entry) => !entry.fields.outcome && entry.fields.state !== "paused").length;
300
+ const pendingDeliveries = (await readTaskDeliveries(summary.deskDir).catch(() => [])).filter((item) => !item.sentAt).length;
301
+ activity.set(summary.name, {
302
+ activeTasks,
303
+ pendingDeliveries,
304
+ active: this.active.has(summary.name),
305
+ });
306
+ }));
307
+ return buildDeskList(desks, this.bindingTable(), this.boundDesk(askingChannelId), labelOf, activity);
308
+ }
309
+ /** `/desk cwd`: view or update the working directory of `channelId`'s bound desk. */
310
+ async cwd(channelId, input) {
311
+ const resolution = this.resolve(channelId);
312
+ if (resolution.kind !== "bound") {
313
+ return { kind: "unavailable", desk: resolvedDesk(resolution) ?? "" };
314
+ }
315
+ const { desk, deskDir } = resolution.conversation;
316
+ const summary = await this.refreshRecord(desk);
317
+ if (!summary.record)
318
+ return { kind: "unavailable", desk };
319
+ const currentEffective = summary.record.cwd ?? deskDir;
320
+ if (!input.cwd && !input.reset) {
321
+ return { kind: "ok", desk, cwd: currentEffective, isDefault: summary.record.cwd === undefined };
322
+ }
323
+ let targetEffective = deskDir;
324
+ if (!input.reset) {
325
+ const checked = validateCustomCwd(input.cwd ?? "");
326
+ if (!checked.ok)
327
+ return { kind: "invalid_cwd", cwd: input.cwd ?? "", reason: checked.reason };
328
+ targetEffective = checked.cwd;
329
+ }
330
+ if (targetEffective === currentEffective) {
331
+ return { kind: "ok", desk, cwd: currentEffective, isDefault: summary.record.cwd === undefined };
332
+ }
333
+ if (this.boundChannelsOf(desk).some((boundChannel) => this.options.isChannelBusy(boundChannel))) {
334
+ return { kind: "busy", desk, reason: "有聊天回合正在运行" };
335
+ }
336
+ const busyReason = this.options.isDeskBusy?.(desk, currentEffective);
337
+ if (busyReason) {
338
+ return { kind: "busy", desk, reason: busyReason };
339
+ }
340
+ const outcome = await setDeskCwd(this.options.workspaceDir, desk, input.reset ? null : targetEffective);
341
+ if (outcome.kind !== "ok")
342
+ return outcome;
343
+ await this.refreshRecord(desk);
344
+ if (this.active.has(desk) && this.servicesStarted) {
345
+ await this.stopWatcher(desk);
346
+ this.startWatcher(desk);
347
+ }
348
+ for (const boundChannel of this.boundChannelsOf(desk)) {
349
+ if (!this.options.isChannelBusy(boundChannel)) {
350
+ await this.options.releaseRunner(boundChannel).catch(() => undefined);
351
+ }
352
+ }
353
+ return outcome;
354
+ }
355
+ /** `/desk archive <name>`: retire an idle desk, unbinding stale terminal sessions and stopping events. */
356
+ archive(askingChannelId, name) {
357
+ return this.bindingWrites.run("bindings", async () => {
358
+ const desk = normalizeDeskName(name);
359
+ if (!isDeskName(desk))
360
+ return { kind: "invalid", desk };
361
+ if (desk === DEFAULT_DESK)
362
+ return { kind: "default" };
363
+ const summary = await readDeskRecord(this.options.workspaceDir, desk);
364
+ if (summary.availability === "missing")
365
+ return { kind: "unknown", desk };
366
+ if (!summary.record)
367
+ return { kind: "unavailable", desk };
368
+ if (summary.record.archivedAt)
369
+ return { kind: "already_archived", desk };
370
+ const bound = this.boundChannelsOf(desk);
371
+ if (askingChannelId && bound.includes(askingChannelId)) {
372
+ return { kind: "current_channel", desk };
373
+ }
374
+ const nonTerminals = bound.filter((channelId) => this.options.conversationKindOf(channelId) !== "webapi");
375
+ if (nonTerminals.length > 0) {
376
+ return {
377
+ kind: "bound_channels",
378
+ desk,
379
+ channels: nonTerminals.map((channelId) => this.options.describeChannel?.(channelId) ?? channelId),
380
+ };
381
+ }
382
+ const terminals = bound.filter((channelId) => this.options.conversationKindOf(channelId) === "webapi");
383
+ if (terminals.some((channelId) => this.options.isChannelBusy(channelId))) {
384
+ return { kind: "busy", desk, reason: "有正在运行的终端回合" };
385
+ }
386
+ const busyReason = this.options.isDeskBusy?.(desk, summary.record.cwd ?? summary.deskDir);
387
+ if (busyReason)
388
+ return { kind: "busy", desk, reason: busyReason };
389
+ const openTasks = (await readActiveTasks(join(summary.deskDir, "tasks")).catch(() => [])).filter((entry) => !entry.fields.outcome);
390
+ if (openTasks.length > 0) {
391
+ return { kind: "open_tasks", desk, count: openTasks.length, sampleId: openTasks[0].id };
392
+ }
393
+ if (terminals.length > 0) {
394
+ const nextBindings = { ...this.bindings.bindings };
395
+ for (const channelId of terminals)
396
+ delete nextBindings[channelId];
397
+ const next = { ...this.bindings, bindings: nextBindings };
398
+ await writeBindings(this.options.workspaceDir, next);
399
+ this.bindings = next;
400
+ for (const channelId of terminals) {
401
+ log.logInfoEvent("desk.unbound", "Terminal channel unbound on desk archive", {
402
+ channelId,
403
+ fields: { desk },
404
+ });
405
+ this.options.onBindingChanged?.(channelId);
406
+ await this.options.releaseRunner(channelId).catch(() => undefined);
407
+ }
408
+ }
409
+ const stoppedEvents = await countScheduledEvents(summary.deskDir);
410
+ await setDeskArchived(this.options.workspaceDir, desk, new Date().toISOString());
411
+ await this.refreshRecord(desk);
412
+ await this.deactivate(desk);
413
+ log.logInfoEvent("desk.archived", "Desk archived", {
414
+ fields: { desk, unboundTerminals: terminals.length, stoppedEvents },
415
+ });
416
+ return { kind: "archived", desk, unboundTerminals: terminals.length, stoppedEvents };
417
+ });
418
+ }
419
+ /** `/desk unarchive <name>`: clear `archivedAt` and re-activate if work is waiting. */
420
+ unarchive(name) {
421
+ return this.bindingWrites.run("bindings", async () => {
422
+ const desk = normalizeDeskName(name);
423
+ if (!isDeskName(desk))
424
+ return { kind: "invalid", desk };
425
+ const summary = await readDeskRecord(this.options.workspaceDir, desk);
426
+ if (summary.availability === "missing")
427
+ return { kind: "unknown", desk };
428
+ if (!summary.record)
429
+ return { kind: "unavailable", desk };
430
+ if (!summary.record.archivedAt)
431
+ return { kind: "not_archived", desk };
432
+ await setDeskArchived(this.options.workspaceDir, desk, null);
433
+ await this.refreshRecord(desk);
434
+ if (this.boundChannelsOf(desk).length > 0 || (await hasRetainedBackgroundWork(summary.deskDir))) {
435
+ await this.activate(desk);
436
+ this.options.onActivated?.(desk);
437
+ }
438
+ log.logInfoEvent("desk.unarchived", "Desk unarchived", {
439
+ fields: { desk, activated: this.active.has(desk) },
440
+ });
441
+ return { kind: "unarchived", desk, activated: this.active.has(desk) };
442
+ });
208
443
  }
209
444
  /** `/desk bind` from `channelId`, in D5's order. Throws only when the bindings write itself fails. */
210
445
  bind(channelId, name) {
@@ -248,8 +483,13 @@ export class DeskRuntime {
248
483
  if (this.options.isChannelBusy(channelId))
249
484
  return { kind: "busy", desk };
250
485
  const previous = this.bindings.bindings[channelId]?.desk;
251
- if (previous === desk)
486
+ if (previous === desk && !summary.record.archivedAt)
252
487
  return { kind: "same", desk };
488
+ let unarchived = false;
489
+ if (summary.record.archivedAt) {
490
+ await setDeskArchived(this.options.workspaceDir, desk, null);
491
+ unarchived = true;
492
+ }
253
493
  this.records.set(desk, summary);
254
494
  // 2–3. Give the channel its conversation in the target, then commit the binding. Until the
255
495
  // write succeeds nothing has changed for the channel and nothing in the target has started.
@@ -271,6 +511,7 @@ export class DeskRuntime {
271
511
  // cannot undo the committed binding; the next restart activates the desk again.
272
512
  try {
273
513
  await this.activate(desk);
514
+ this.options.onActivated?.(desk);
274
515
  }
275
516
  catch (error) {
276
517
  log.logWarn("desk.bind.activate_failed", "Activating the desk after a bind failed", {
@@ -290,26 +531,36 @@ export class DeskRuntime {
290
531
  fields: { desk, previousDesk: previous },
291
532
  });
292
533
  }
293
- // 6. The old desk: dormant if it lost its last channel, otherwise report what is now suspended.
294
- if (!previous)
295
- return { kind: "bound", desk };
296
- if (this.boundChannelsOf(previous).length === 0) {
534
+ // 6. The old desk: stays active while it still has open tasks or task-spawning events; goes
535
+ // dormant only when both bound channels and runnable background work are gone.
536
+ if (!previous || previous === desk) {
537
+ return { kind: "bound", desk, ...(unarchived ? { unarchived: true } : {}) };
538
+ }
539
+ const previousDir = getDeskDir(this.options.workspaceDir, previous);
540
+ const departure = await inspectChannelDeparture(previousDir, channelId);
541
+ if (this.boundChannelsOf(previous).length === 0 && !(await hasRetainedBackgroundWork(previousDir))) {
297
542
  await this.deactivate(previous);
298
- return { kind: "bound", desk, previousDesk: previous, previousDeskDormant: true };
543
+ return {
544
+ kind: "bound",
545
+ desk,
546
+ ...(unarchived ? { unarchived: true } : {}),
547
+ previousDesk: previous,
548
+ previousDeskDormant: true,
549
+ };
299
550
  }
300
- const suspended = await countDeliveringTo(getDeskDir(this.options.workspaceDir, previous), channelId);
301
551
  return {
302
552
  kind: "bound",
303
553
  desk,
554
+ ...(unarchived ? { unarchived: true } : {}),
304
555
  previousDesk: previous,
305
- suspendedTasks: suspended.tasks,
306
- suspendedEvents: suspended.events,
556
+ ...(departure.backgroundTasks > 0 ? { backgroundTasks: departure.backgroundTasks } : {}),
557
+ ...(departure.suspendedEvents > 0 ? { suspendedEvents: departure.suspendedEvents } : {}),
307
558
  };
308
559
  }
309
560
  /**
310
561
  * The channel is gone for good (a Web API conversation was deleted): drop its binding, its
311
- * runner, and — when it was the desk's last channel — the desk's activity. Its conversation
312
- * directory stays in the desk as history. Whether there was a binding to drop.
562
+ * runner, and — when it was the desk's last channel and no background work remains — the desk's
563
+ * activity. Its conversation directory stays in the desk as history. Whether there was a binding to drop.
313
564
  */
314
565
  unbind(channelId) {
315
566
  return this.bindingWrites.run("bindings", async () => {
@@ -332,8 +583,10 @@ export class DeskRuntime {
332
583
  fields: { desk: previous },
333
584
  });
334
585
  }
335
- if (this.boundChannelsOf(previous).length === 0)
586
+ if (this.boundChannelsOf(previous).length === 0 &&
587
+ !(await hasRetainedBackgroundWork(getDeskDir(this.options.workspaceDir, previous)))) {
336
588
  await this.deactivate(previous);
589
+ }
337
590
  return true;
338
591
  });
339
592
  }
@@ -367,36 +620,69 @@ export class DeskRuntime {
367
620
  await Promise.all([...this.watchers.values()].map((watcher) => watcher.flush?.() ?? Promise.resolve()));
368
621
  }
369
622
  }
370
- /**
371
- * Open tasks and events in a desk whose delivery channel is `channelId` — what a rebind away from
372
- * the desk suspends (D8). Read-only, and best effort: an unreadable file is simply not counted.
373
- */
374
- async function countDeliveringTo(deskDir, channelId) {
375
- let tasks = 0;
623
+ function deskRecordStamp(deskDir) {
624
+ return fileStamp(join(deskDir, DESK_RECORD_FILENAME)) ?? "missing";
625
+ }
626
+ /** Whether `deskDir` still owns work that can execute without any bound chat channel. */
627
+ async function hasRetainedBackgroundWork(deskDir) {
376
628
  try {
377
- tasks = (await readActiveTasks(join(deskDir, "tasks"))).filter((entry) => entry.fields.channel === channelId).length;
629
+ const closing = await readdir(join(deskDir, "tasks", ".closing"));
630
+ if (closing.some((name) => name.endsWith(".json")))
631
+ return true;
632
+ }
633
+ catch {
634
+ // No `.closing` directory.
635
+ }
636
+ try {
637
+ const open = await readActiveTasks(join(deskDir, "tasks"));
638
+ if (open.some((entry) => !entry.fields.outcome && entry.fields.state !== "paused"))
639
+ return true;
378
640
  }
379
641
  catch {
380
- // No readable tasks directory: nothing suspended there.
642
+ // No readable tasks directory.
381
643
  }
382
- let events = 0;
644
+ for (const event of await readValidScheduledEvents(deskDir)) {
645
+ if (event.task)
646
+ return true;
647
+ }
648
+ return false;
649
+ }
650
+ async function readValidScheduledEvents(deskDir) {
383
651
  const eventsDir = join(deskDir, "events");
384
652
  let filenames = [];
385
653
  try {
386
654
  filenames = (await readdir(eventsDir)).filter((filename) => filename.endsWith(".json"));
387
655
  }
388
656
  catch {
389
- // No events directory.
657
+ return [];
390
658
  }
659
+ const events = [];
391
660
  for (const filename of filenames) {
392
661
  try {
393
- const event = parseScheduledEventContent(await readFile(join(eventsDir, filename), "utf8"), filename);
394
- if (event.channelId === channelId)
395
- events++;
662
+ events.push(parseScheduledEventContent(await readFile(join(eventsDir, filename), "utf8"), filename));
396
663
  }
397
664
  catch {
398
665
  // An invalid definition never fires anyway.
399
666
  }
400
667
  }
401
- return { tasks, events };
668
+ return events;
669
+ }
670
+ async function countScheduledEvents(deskDir) {
671
+ return (await readValidScheduledEvents(deskDir)).length;
672
+ }
673
+ /**
674
+ * Open tasks in `deskDir` that keep running in the background while `channelId` is away, plus
675
+ * chat-wake events delivering to `channelId` that pause until `channelId` binds back.
676
+ */
677
+ async function inspectChannelDeparture(deskDir, channelId) {
678
+ let backgroundTasks = 0;
679
+ try {
680
+ backgroundTasks = (await readActiveTasks(join(deskDir, "tasks"))).filter((entry) => !entry.fields.outcome && entry.fields.state !== "paused" && entry.fields.channel === channelId).length;
681
+ }
682
+ catch {
683
+ // No readable tasks directory.
684
+ }
685
+ const events = await readValidScheduledEvents(deskDir);
686
+ const suspendedEvents = events.filter((event) => event.channelId === channelId && !event.task).length;
687
+ return { backgroundTasks, suspendedEvents };
402
688
  }
@@ -11,6 +11,8 @@ export interface DurableDispatchRecord {
11
11
  /** Set by `markRetryable` to back off a repeatedly-failing structured wake instead of
12
12
  * redelivering on the very next drain tick (spec 031's redelivery has no such gate). */
13
13
  nextAttemptAt?: string;
14
+ /** Set when the record hits `MAX_DELIVERIES`; starts the dead-letter retention window. */
15
+ exhaustedAt?: string;
14
16
  }
15
17
  export interface DurableDispatchOptions {
16
18
  stateDir: string;
@@ -23,10 +25,12 @@ export interface DurableDispatchOptions {
23
25
  isReachable?: (channelId: string) => boolean;
24
26
  leaseMs?: number;
25
27
  intervalMs?: number;
28
+ /** Retention window for `exhausted` dead-letter records before `drainOnce` unlinks them (default 7 days). */
29
+ exhaustedRetentionMs?: number;
26
30
  /** Called once, at most, when a dispatch id hits `MAX_DELIVERIES` without ever completing —
27
31
  * e.g. a structured wake whose claim/finish step fails deterministically (disk full,
28
- * permissions). The record is left on disk (not deleted) so the failure is inspectable; the
29
- * caller is expected to notify the channel. */
32
+ * permissions). The record is kept on disk for the retention window so the failure is inspectable;
33
+ * the caller is expected to notify the channel. */
30
34
  onExhausted?: (record: DurableDispatchRecord) => void | Promise<void>;
31
35
  }
32
36
  /**
@@ -46,7 +50,13 @@ export declare class DurableDispatchService {
46
50
  private readonly capacityRejected;
47
51
  private readonly capacityDrains;
48
52
  private readonly queue;
53
+ private readonly pendingWrites;
54
+ private run;
55
+ /** stop() closes background admission; after active turns settle, wait for started writes
56
+ * before another process can acquire the daemon lock. A hung write keeps that lock retained. */
57
+ flush(): Promise<void>;
49
58
  private readonly leaseMs;
59
+ private readonly exhaustedRetentionMs;
50
60
  private timer;
51
61
  /**
52
62
  * Dispatch ids whose turn this process is still running (spec 031, D2).
@@ -123,6 +133,8 @@ export declare class DurableDispatchService {
123
133
  markRetryable(id: string | undefined): Promise<void>;
124
134
  drainOnce(now?: number): Promise<void>;
125
135
  private drainRecord;
136
+ private idFromFilename;
137
+ private reportRecordFault;
126
138
  private read;
127
139
  private write;
128
140
  }