@oyasmi/pipiclaw 0.9.4-beta.1 → 0.9.4

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 (291) hide show
  1. package/dist/agent/builtin-commands.d.ts +19 -0
  2. package/dist/agent/builtin-commands.js +80 -0
  3. package/dist/agent/channel-runner.d.ts +20 -208
  4. package/dist/agent/channel-runner.js +148 -1245
  5. package/dist/agent/maintenance-context.d.ts +1 -1
  6. package/dist/agent/maintenance-context.js +1 -1
  7. package/dist/agent/prompt/resources.d.ts +3 -0
  8. package/dist/agent/prompt/resources.js +7 -1
  9. package/dist/agent/runner-factory.d.ts +1 -43
  10. package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
  11. package/dist/agent/{command-extension.js → session/command-extension.js} +5 -5
  12. package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
  13. package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
  14. package/dist/agent/session/model-selection.d.ts +47 -0
  15. package/dist/agent/session/model-selection.js +99 -0
  16. package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
  17. package/dist/agent/{session-adapter.js → session/session-adapter.js} +83 -1
  18. package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
  19. package/dist/agent/{session-events.js → session/session-events.js} +10 -10
  20. package/dist/agent/session/session-host.d.ts +200 -0
  21. package/dist/agent/session/session-host.js +621 -0
  22. package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +2 -2
  23. package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
  24. package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
  25. package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
  26. package/dist/agent/{run-queue.js → turn/run-queue.js} +3 -3
  27. package/dist/{memory → agent/turn}/task-digest.js +4 -4
  28. package/dist/agent/turn/turn-context.d.ts +14 -0
  29. package/dist/agent/turn/turn-context.js +64 -0
  30. package/dist/agent/turn/turn-finish.d.ts +50 -0
  31. package/dist/agent/turn/turn-finish.js +188 -0
  32. package/dist/agent/turn/turn-input.d.ts +43 -0
  33. package/dist/agent/turn/turn-input.js +79 -0
  34. package/dist/agent/turn/turn-pipeline.d.ts +68 -0
  35. package/dist/agent/turn/turn-pipeline.js +257 -0
  36. package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
  37. package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
  38. package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
  39. package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
  40. package/dist/agent/types.d.ts +43 -2
  41. package/dist/agent/types.js +1 -1
  42. package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
  43. package/dist/{models/auth-cli.js → app/auth-command.js} +11 -8
  44. package/dist/{runtime/app-home.d.ts → app/home.d.ts} +0 -2
  45. package/dist/{runtime/app-home.js → app/home.js} +4 -75
  46. package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
  47. package/dist/{app-services.js → app/services.js} +10 -10
  48. package/dist/channel/channel-context.d.ts +12 -2
  49. package/dist/channel/channel-context.js +29 -2
  50. package/dist/channel/channel-event.d.ts +10 -2
  51. package/dist/channel/channel-event.js +1 -1
  52. package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
  53. package/dist/{runtime/project-commands.js → channel/commands.js} +1 -1
  54. package/dist/channel/store.js +4 -0
  55. package/dist/commands/catalog.d.ts +3 -3
  56. package/dist/commands/catalog.js +3 -3
  57. package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
  58. package/dist/{runtime/report-commands.js → commands/router.js} +5 -5
  59. package/dist/{settings.d.ts → config/settings.d.ts} +7 -8
  60. package/dist/{settings.js → config/settings.js} +7 -10
  61. package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
  62. package/dist/{tools/config.js → config/tools.js} +5 -2
  63. package/dist/dingtalk/access-token.d.ts +12 -0
  64. package/dist/dingtalk/access-token.js +51 -0
  65. package/dist/dingtalk/api.d.ts +19 -0
  66. package/dist/dingtalk/api.js +67 -0
  67. package/dist/dingtalk/bot.d.ts +97 -0
  68. package/dist/dingtalk/bot.js +389 -0
  69. package/dist/dingtalk/cards.d.ts +56 -0
  70. package/dist/dingtalk/cards.js +318 -0
  71. package/dist/{runtime → dingtalk}/channel-queue.js +3 -0
  72. package/dist/dingtalk/config.d.ts +19 -0
  73. package/dist/dingtalk/config.js +95 -0
  74. package/dist/dingtalk/connection.d.ts +57 -0
  75. package/dist/dingtalk/connection.js +356 -0
  76. package/dist/dingtalk/conversation-meta.d.ts +16 -0
  77. package/dist/dingtalk/conversation-meta.js +77 -0
  78. package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
  79. package/dist/dingtalk/handler.d.ts +90 -0
  80. package/dist/dingtalk/handler.js +1 -0
  81. package/dist/dingtalk/inbound.d.ts +66 -0
  82. package/dist/dingtalk/inbound.js +137 -0
  83. package/dist/dingtalk/media.d.ts +66 -0
  84. package/dist/dingtalk/media.js +214 -0
  85. package/dist/events/{event-commands.js → commands.js} +6 -2
  86. package/dist/events/parse.d.ts +14 -0
  87. package/dist/events/parse.js +114 -0
  88. package/dist/events/types.d.ts +93 -0
  89. package/dist/events/types.js +1 -0
  90. package/dist/events/{event-validation.d.ts → validation.d.ts} +1 -1
  91. package/dist/events/watcher.d.ts +67 -0
  92. package/dist/events/{events.js → watcher.js} +6 -109
  93. package/dist/index.d.ts +6 -4
  94. package/dist/index.js +2 -2
  95. package/dist/jobs/launch.d.ts +42 -0
  96. package/dist/jobs/launch.js +118 -0
  97. package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
  98. package/dist/{agent/job-manager.js → jobs/manager.js} +3 -146
  99. package/dist/jobs/record.d.ts +55 -0
  100. package/dist/jobs/record.js +36 -0
  101. package/dist/main.js +2 -2
  102. package/dist/memory/maintenance-gates.d.ts +2 -2
  103. package/dist/memory/maintenance-tuning.d.ts +15 -0
  104. package/dist/memory/maintenance-tuning.js +3 -0
  105. package/dist/memory/reflect-job.d.ts +2 -2
  106. package/dist/memory/reflect-job.js +4 -2
  107. package/dist/memory/scheduler.d.ts +3 -3
  108. package/dist/memory/scheduler.js +2 -1
  109. package/dist/memory/sidecar-worker.js +1 -1
  110. package/dist/memory/transcript.js +1 -1
  111. package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
  112. package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
  113. package/dist/models/login-identity.d.ts +2 -0
  114. package/dist/models/login-identity.js +83 -0
  115. package/dist/models/provider-login.d.ts +3 -1
  116. package/dist/models/provider-login.js +8 -2
  117. package/dist/models/reference.d.ts +20 -0
  118. package/dist/models/{utils.js → reference.js} +0 -48
  119. package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
  120. package/dist/models/runtime.js +52 -0
  121. package/dist/playbooks/catalog.d.ts +6 -2
  122. package/dist/playbooks/catalog.js +9 -6
  123. package/dist/runtime/bootstrap.d.ts +7 -17
  124. package/dist/runtime/bootstrap.js +37 -755
  125. package/dist/runtime/durable-dispatch.d.ts +17 -4
  126. package/dist/runtime/durable-dispatch.js +60 -18
  127. package/dist/runtime/inbound-images.d.ts +18 -0
  128. package/dist/runtime/inbound-images.js +51 -0
  129. package/dist/runtime/shutdown.d.ts +39 -0
  130. package/dist/runtime/shutdown.js +120 -0
  131. package/dist/runtime/stop-watchdog.d.ts +16 -0
  132. package/dist/runtime/stop-watchdog.js +32 -0
  133. package/dist/runtime/task-driver.d.ts +2 -2
  134. package/dist/runtime/task-driver.js +3 -3
  135. package/dist/runtime/task-migration.js +2 -2
  136. package/dist/runtime/task-spawn.d.ts +1 -1
  137. package/dist/runtime/task-spawn.js +1 -1
  138. package/dist/runtime/turn-handler.d.ts +47 -0
  139. package/dist/runtime/turn-handler.js +318 -0
  140. package/dist/runtime/turn-run.d.ts +52 -0
  141. package/dist/runtime/turn-run.js +318 -0
  142. package/dist/security/command-guard.js +4 -0
  143. package/dist/security/network.js +4 -0
  144. package/dist/security/path-guard.js +4 -0
  145. package/dist/security/types.d.ts +1 -2
  146. package/dist/security/types.js +1 -2
  147. package/dist/shared/exact-keys.d.ts +1 -1
  148. package/dist/shared/host-process.js +1 -1
  149. package/dist/shared/wake-claim.d.ts +1 -1
  150. package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
  151. package/dist/{runtime/skill-commands.js → skills/commands.js} +1 -1
  152. package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
  153. package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
  154. package/dist/skills/workspace.d.ts +33 -0
  155. package/dist/skills/workspace.js +116 -0
  156. package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +4 -3
  157. package/dist/{runtime/subagent-commands.js → subagents/commands.js} +2 -2
  158. package/dist/subagents/completion-wake.d.ts +17 -0
  159. package/dist/subagents/completion-wake.js +76 -0
  160. package/dist/subagents/detached-discovery.js +1 -1
  161. package/dist/subagents/discovery.d.ts +1 -1
  162. package/dist/subagents/discovery.js +2 -2
  163. package/dist/subagents/dispatch.d.ts +33 -0
  164. package/dist/subagents/dispatch.js +190 -0
  165. package/dist/subagents/external/dispatch.d.ts +25 -0
  166. package/dist/subagents/external/dispatch.js +90 -0
  167. package/dist/subagents/external/harness.d.ts +1 -1
  168. package/dist/subagents/external/progress-tail.d.ts +1 -1
  169. package/dist/subagents/external/run.d.ts +2 -1
  170. package/dist/subagents/external/run.js +2 -2
  171. package/dist/subagents/external/settlement.d.ts +1 -1
  172. package/dist/subagents/format.d.ts +1 -1
  173. package/dist/subagents/grace.d.ts +24 -0
  174. package/dist/subagents/grace.js +57 -0
  175. package/dist/subagents/internal/outcome.d.ts +24 -0
  176. package/dist/subagents/internal/outcome.js +149 -0
  177. package/dist/subagents/internal/provider-retry.d.ts +19 -0
  178. package/dist/subagents/internal/provider-retry.js +83 -0
  179. package/dist/subagents/internal/run.d.ts +31 -0
  180. package/dist/subagents/internal/run.js +240 -0
  181. package/dist/subagents/internal/state.d.ts +43 -0
  182. package/dist/subagents/internal/state.js +48 -0
  183. package/dist/subagents/internal/worker.d.ts +51 -0
  184. package/dist/subagents/internal/worker.js +167 -0
  185. package/dist/subagents/result.d.ts +62 -0
  186. package/dist/subagents/result.js +103 -0
  187. package/dist/subagents/run-record.d.ts +222 -0
  188. package/dist/subagents/run-record.js +101 -0
  189. package/dist/subagents/run-registry.d.ts +9 -0
  190. package/dist/subagents/run-registry.js +125 -0
  191. package/dist/subagents/runs.d.ts +7 -243
  192. package/dist/subagents/runs.js +8 -291
  193. package/dist/subagents/task-envelope.d.ts +36 -0
  194. package/dist/subagents/task-envelope.js +168 -0
  195. package/dist/subagents/types.d.ts +154 -0
  196. package/dist/subagents/types.js +1 -0
  197. package/dist/subagents/verification-outcome.d.ts +1 -1
  198. package/dist/tasks/board.d.ts +2 -2
  199. package/dist/tasks/board.js +2 -2
  200. package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
  201. package/dist/tasks/{work-log.js → bound-work.js} +1 -1
  202. package/dist/tasks/brief.js +1 -1
  203. package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
  204. package/dist/{runtime/task-commands.js → tasks/commands.js} +12 -8
  205. package/dist/tasks/contract-input.d.ts +1 -1
  206. package/dist/tasks/contract-input.js +1 -1
  207. package/dist/tasks/create.js +1 -1
  208. package/dist/tasks/{log.js → loop-log.js} +1 -1
  209. package/dist/tasks/mutation-lock.js +1 -1
  210. package/dist/tasks/session-path.js +1 -1
  211. package/dist/tasks/steer.js +1 -1
  212. package/dist/tasks/store.js +2 -2
  213. package/dist/tools/bash.d.ts +1 -1
  214. package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +2 -2
  215. package/dist/tools/{tool-details.js → contract/details.js} +4 -4
  216. package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
  217. package/dist/tools/event-manage.d.ts +1 -1
  218. package/dist/tools/event-manage.js +4 -4
  219. package/dist/tools/index.d.ts +3 -3
  220. package/dist/tools/index.js +7 -6
  221. package/dist/tools/job.d.ts +1 -1
  222. package/dist/tools/registry.d.ts +7 -7
  223. package/dist/tools/registry.js +6 -6
  224. package/dist/tools/session-search.d.ts +1 -1
  225. package/dist/tools/skill.d.ts +2 -34
  226. package/dist/tools/skill.js +8 -116
  227. package/dist/tools/subagent-manage.js +4 -3
  228. package/dist/tools/subagent.d.ts +46 -0
  229. package/dist/tools/subagent.js +127 -0
  230. package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
  231. package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
  232. package/dist/tools/task-manage/lifecycle.js +2 -2
  233. package/dist/tools/task-manage/log-view.js +2 -2
  234. package/dist/tools/task-manage/shared.js +3 -3
  235. package/dist/tools/task-manage/step-end.js +3 -3
  236. package/dist/tools/task-manage/types.d.ts +1 -1
  237. package/dist/tools/web-fetch.d.ts +1 -1
  238. package/dist/tools/web-search.d.ts +1 -1
  239. package/dist/tui/app.d.ts +1 -1
  240. package/dist/tui/app.js +6 -6
  241. package/dist/tui/cli.d.ts +1 -1
  242. package/dist/tui/cli.js +1 -1
  243. package/dist/tui/frontend.d.ts +44 -0
  244. package/dist/tui/frontend.js +13 -0
  245. package/dist/tui/pitui-frontend.d.ts +1 -1
  246. package/dist/tui/plain-frontend.d.ts +1 -1
  247. package/dist/tui/renderer.d.ts +3 -42
  248. package/dist/tui/terminal-context.d.ts +2 -2
  249. package/dist/tui/terminal-media-sender.d.ts +1 -1
  250. package/dist/tui/turn-controller.d.ts +1 -1
  251. package/dist/usage/ledger.js +4 -0
  252. package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
  253. package/dist/web/client.d.ts +5 -1
  254. package/dist/web/client.js +4 -0
  255. package/dist/web/config.d.ts +1 -1
  256. package/dist/web/fetch.d.ts +1 -1
  257. package/dist/web/search-providers.d.ts +1 -1
  258. package/dist/web/search.d.ts +1 -1
  259. package/package.json +10 -7
  260. package/dist/events/events.d.ts +0 -159
  261. package/dist/runtime/dingtalk.d.ts +0 -272
  262. package/dist/runtime/dingtalk.js +0 -1470
  263. package/dist/subagents/tool.d.ts +0 -213
  264. package/dist/subagents/tool.js +0 -1282
  265. /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
  266. /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
  267. /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
  268. /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
  269. /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
  270. /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
  271. /package/dist/agent/{turn-error.d.ts → turn/turn-error.d.ts} +0 -0
  272. /package/dist/agent/{turn-error.js → turn/turn-error.js} +0 -0
  273. /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
  274. /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
  275. /package/dist/{runtime → app}/proxy.d.ts +0 -0
  276. /package/dist/{runtime → app}/proxy.js +0 -0
  277. /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
  278. /package/dist/{runtime → dingtalk}/delivery.js +0 -0
  279. /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
  280. /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
  281. /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
  282. /package/dist/events/{event-validation.js → validation.js} +0 -0
  283. /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
  284. /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
  285. /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
  286. /package/dist/tasks/{ledger.js → contract.js} +0 -0
  287. /package/dist/tasks/{log.d.ts → loop-log.d.ts} +0 -0
  288. /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
  289. /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
  290. /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
  291. /package/dist/{shared/types.js → usage/totals.js} +0 -0
@@ -1,5 +1,4 @@
1
- import type { ChannelEvent } from "../channel/channel-event.js";
2
- import type { DingTalkBot } from "./dingtalk.js";
1
+ import type { ChannelEvent, ChannelEventSink } from "../channel/channel-event.js";
3
2
  type DispatchStatus = "pending" | "queued" | "running" | "exhausted";
4
3
  export interface DurableDispatchRecord {
5
4
  version: 1;
@@ -15,7 +14,7 @@ export interface DurableDispatchRecord {
15
14
  }
16
15
  export interface DurableDispatchOptions {
17
16
  stateDir: string;
18
- bot: Pick<DingTalkBot, "enqueueEvent">;
17
+ bot: ChannelEventSink;
19
18
  leaseMs?: number;
20
19
  intervalMs?: number;
21
20
  /** Called once, at most, when a dispatch id hits `MAX_DELIVERIES` without ever completing —
@@ -56,6 +55,8 @@ export declare class DurableDispatchService {
56
55
  * of running the same wake a second time.
57
56
  */
58
57
  private readonly absorbed;
58
+ /** Bumped by `discardQueuedClaims`; lets an in-flight `absorbPending` notice that its closures were dropped. */
59
+ private readonly discardEpoch;
59
60
  constructor(options: DurableDispatchOptions);
60
61
  start(): void;
61
62
  /**
@@ -68,6 +69,16 @@ export declare class DurableDispatchService {
68
69
  dispatch(event: ChannelEvent): Promise<boolean>;
69
70
  /** Reset any in-flight records for a channel so a stop/abort can redeliver on the next tick, not after the lease expires. */
70
71
  cancelChannel(channelId: string): Promise<number>;
72
+ /**
73
+ * `/stop` just cleared the channel's queued closures, synchronously and before any await, so
74
+ * no queued delivery of an absorbed wake survives to consume its stale-delivery mark. Dropping
75
+ * the marks here records that fact at the moment it is true, independent of when (or whether)
76
+ * `cancelChannel` and the turn's own finish run. Not for non-stop failures: there the closures
77
+ * are alive and the marks are what prevents a duplicate run.
78
+ */
79
+ /** Opaque `/stop` counter; sample it synchronously at admission entry and hand it to `absorbPending`. */
80
+ stopEpoch(channelId: string): number;
81
+ discardQueuedClaims(channelId: string): void;
71
82
  /**
72
83
  * Claim a dispatch for the turn about to run it. Returns false — run nothing — for a stale
73
84
  * delivery of a record another turn already absorbed (see `absorbPending`).
@@ -81,7 +92,9 @@ export declare class DurableDispatchService {
81
92
  * crash mid-turn redelivers each of them on its own, unchanged. Returned events carry their
82
93
  * own redelivery notice, like a normal delivery would.
83
94
  */
84
- absorbPending(channelId: string, primaryId: string, accept: (event: ChannelEvent) => boolean, limit: number): Promise<ChannelEvent[]>;
95
+ absorbPending(channelId: string, primaryId: string, accept: (event: ChannelEvent) => boolean, limit: number,
96
+ /** `stopEpoch` sampled when the caller's admission began; a later `/stop` suppresses the stale-delivery marks. */
97
+ epoch?: number): Promise<ChannelEvent[]>;
85
98
  /** Not started anywhere: still waiting for delivery (`pending`) or queued behind the current turn. */
86
99
  private isAbsorbable;
87
100
  markCompleted(id: string | undefined): Promise<void>;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * The durable outbox for synthetic events (job and delegation completions, task wakes, scheduled events):
3
+ * records are written to disk before they enter the in-memory channel queue, leased, retried and
4
+ * redelivered after a crash — at-least-once.
5
+ */
1
6
  import { createHash } from "node:crypto";
2
7
  import { readdir, readFile, unlink } from "node:fs/promises";
3
8
  import { join } from "node:path";
@@ -144,7 +149,9 @@ export class DurableDispatchService {
144
149
  * own closure waiting in the channel queue; `markStarted` turns that stale delivery away instead
145
150
  * of running the same wake a second time.
146
151
  */
147
- this.absorbed = new Set();
152
+ this.absorbed = new Map();
153
+ /** Bumped by `discardQueuedClaims`; lets an in-flight `absorbPending` notice that its closures were dropped. */
154
+ this.discardEpoch = new Map();
148
155
  this.leaseMs = options.leaseMs ?? DEFAULT_LEASE_MS;
149
156
  }
150
157
  start() {
@@ -228,6 +235,23 @@ export class DurableDispatchService {
228
235
  }
229
236
  return canceled;
230
237
  }
238
+ /**
239
+ * `/stop` just cleared the channel's queued closures, synchronously and before any await, so
240
+ * no queued delivery of an absorbed wake survives to consume its stale-delivery mark. Dropping
241
+ * the marks here records that fact at the moment it is true, independent of when (or whether)
242
+ * `cancelChannel` and the turn's own finish run. Not for non-stop failures: there the closures
243
+ * are alive and the marks are what prevents a duplicate run.
244
+ */
245
+ /** Opaque `/stop` counter; sample it synchronously at admission entry and hand it to `absorbPending`. */
246
+ stopEpoch(channelId) {
247
+ return this.discardEpoch.get(channelId) ?? 0;
248
+ }
249
+ discardQueuedClaims(channelId) {
250
+ this.discardEpoch.set(channelId, (this.discardEpoch.get(channelId) ?? 0) + 1);
251
+ for (const [id, owner] of this.absorbed)
252
+ if (owner === channelId)
253
+ this.absorbed.delete(id);
254
+ }
231
255
  /**
232
256
  * Claim a dispatch for the turn about to run it. Returns false — run nothing — for a stale
233
257
  * delivery of a record another turn already absorbed (see `absorbPending`).
@@ -256,7 +280,9 @@ export class DurableDispatchService {
256
280
  * crash mid-turn redelivers each of them on its own, unchanged. Returned events carry their
257
281
  * own redelivery notice, like a normal delivery would.
258
282
  */
259
- async absorbPending(channelId, primaryId, accept, limit) {
283
+ async absorbPending(channelId, primaryId, accept, limit,
284
+ /** `stopEpoch` sampled when the caller's admission began; a later `/stop` suppresses the stale-delivery marks. */
285
+ epoch = this.stopEpoch(channelId)) {
260
286
  if (limit <= 0)
261
287
  return [];
262
288
  let filenames;
@@ -278,22 +304,38 @@ export class DurableDispatchService {
278
304
  candidates.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
279
305
  const events = [];
280
306
  for (const { id } of candidates.slice(0, limit)) {
281
- await this.queue.run(id, async () => {
282
- // Re-checked under the record's own lock: a drain or its own delivery may have moved it.
283
- const record = await this.read(id);
284
- if (!record || this.running.has(id) || !this.isAbsorbable(record, channelId, accept))
285
- return;
286
- if (record.status === "queued")
287
- this.absorbed.add(id);
288
- else
289
- record.deliveries++;
290
- record.status = "running";
291
- record.leaseExpiresAt = new Date(Date.now() + this.leaseMs).toISOString();
292
- record.nextAttemptAt = undefined;
293
- this.running.add(id);
294
- await this.write(record);
295
- events.push(withRedeliveryNotice({ ...record.event, dispatchId: record.id }, record.deliveries));
296
- });
307
+ try {
308
+ await this.queue.run(id, async () => {
309
+ // Re-checked under the record's own lock: a drain or its own delivery may have moved it.
310
+ const record = await this.read(id);
311
+ if (!record || this.running.has(id) || !this.isAbsorbable(record, channelId, accept))
312
+ return;
313
+ const wasQueued = record.status === "queued";
314
+ if (!wasQueued)
315
+ record.deliveries++;
316
+ record.status = "running";
317
+ record.leaseExpiresAt = new Date(Date.now() + this.leaseMs).toISOString();
318
+ record.nextAttemptAt = undefined;
319
+ await this.write(record);
320
+ // Publish in-process claims only after persistence succeeds. A failed write
321
+ // must leave the original queued delivery / pending drain eligible to run.
322
+ // Unless /stop dropped the closure meanwhile: then there is nothing left to turn away.
323
+ if (wasQueued && this.stopEpoch(channelId) === epoch)
324
+ this.absorbed.set(id, channelId);
325
+ this.running.add(id);
326
+ events.push(withRedeliveryNotice({ ...record.event, dispatchId: record.id }, record.deliveries));
327
+ });
328
+ }
329
+ catch (error) {
330
+ log.logWarn("dispatch.wake.absorb_failed", "Wake coalescing failed", {
331
+ channelId,
332
+ reason: errorMessage(error),
333
+ fields: { dispatchId: id },
334
+ });
335
+ // Earlier claims still belong to this turn: return them for processing and
336
+ // settlement instead of losing their ids through the caller's catch(() => []).
337
+ break;
338
+ }
297
339
  }
298
340
  return events;
299
341
  }
@@ -0,0 +1,18 @@
1
+ import type { InboundImage } from "../channel/channel-event.js";
2
+ /**
3
+ * Absolute `InboundImage.path`s → paths relative to the channel directory, for
4
+ * `LoggedMessage.images` (spec 049). `log.jsonl` already stores everything else channel-relative
5
+ * (it lives inside the channel directory itself); an absolute path there would be dead on any
6
+ * machine other than the one that wrote it, and `~/.pipiclaw` itself can move between backup and
7
+ * restore.
8
+ */
9
+ export declare function relativeImagePaths(workspaceDir: string, channelId: string, images: InboundImage[] | undefined): string[];
10
+ /**
11
+ * Persist one downloaded inbound image under the channel's `inbox/` (spec 049). The runtime owns
12
+ * this, not the transport, because it holds the workspace root; see the doc comment on
13
+ * `DingTalkHandler.persistInboundImage` for the full contract (`mimeType: null` case included).
14
+ */
15
+ export declare function persistInboundImage(workspaceDir: string, channelId: string, image: {
16
+ data: Buffer;
17
+ mimeType: string | null;
18
+ }): Promise<InboundImage | null>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Inbound images on the runtime side: persist a downloaded image under the channel's `inbox/`, and
3
+ * map absolute image paths back to channel-relative ones for the message archive.
4
+ */
5
+ import { mkdir, writeFile } from "fs/promises";
6
+ import { join, relative } from "path";
7
+ import { getChannelDir } from "../channel/channel-paths.js";
8
+ import { extensionForMimeType } from "../dingtalk/inbound-media.js";
9
+ import * as log from "../log.js";
10
+ import { localStampForFilename } from "../shared/local-time.js";
11
+ import { errorMessage } from "../shared/text-utils.js";
12
+ /**
13
+ * Absolute `InboundImage.path`s → paths relative to the channel directory, for
14
+ * `LoggedMessage.images` (spec 049). `log.jsonl` already stores everything else channel-relative
15
+ * (it lives inside the channel directory itself); an absolute path there would be dead on any
16
+ * machine other than the one that wrote it, and `~/.pipiclaw` itself can move between backup and
17
+ * restore.
18
+ */
19
+ export function relativeImagePaths(workspaceDir, channelId, images) {
20
+ if (!images || images.length === 0)
21
+ return [];
22
+ const channelDir = getChannelDir(workspaceDir, channelId);
23
+ return images.map((image) => relative(channelDir, image.path));
24
+ }
25
+ /**
26
+ * Persist one downloaded inbound image under the channel's `inbox/` (spec 049). The runtime owns
27
+ * this, not the transport, because it holds the workspace root; see the doc comment on
28
+ * `DingTalkHandler.persistInboundImage` for the full contract (`mimeType: null` case included).
29
+ */
30
+ export async function persistInboundImage(workspaceDir, channelId, image) {
31
+ try {
32
+ const dir = join(getChannelDir(workspaceDir, channelId), "inbox");
33
+ await mkdir(dir, { recursive: true });
34
+ const extension = extensionForMimeType(image.mimeType);
35
+ const path = join(dir, `image-${localStampForFilename()}-${Math.random().toString(36).slice(2, 8)}.${extension}`);
36
+ await writeFile(path, image.data, { mode: 0o600 });
37
+ return {
38
+ path,
39
+ mimeType: image.mimeType ?? "application/octet-stream",
40
+ byteSize: image.data.byteLength,
41
+ ...(image.mimeType === null ? { unsupportedFormat: true } : {}),
42
+ };
43
+ }
44
+ catch (err) {
45
+ log.logWarn("dingtalk.media.persist_failed", "Inbound image persist failed", {
46
+ channelId: channelId,
47
+ reason: errorMessage(err),
48
+ });
49
+ return null;
50
+ }
51
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Ordered daemon shutdown: stop the schedulers, stop admission, wait for active turns (aborting
3
+ * them past a grace window), dispose idle runners, then flush storage and logs. Idempotent: every
4
+ * call after the first returns the first call's promise.
5
+ */
6
+ import type { AgentRunner } from "../agent/types.js";
7
+ import type { ChannelIndex } from "../channel/channel-index.js";
8
+ import type { ChannelStore } from "../channel/store.js";
9
+ export interface ShutdownDeps {
10
+ taskDriver: {
11
+ stop(): void;
12
+ };
13
+ getDurableDispatch: () => {
14
+ stop(): void;
15
+ } | undefined;
16
+ memoryMaintenanceScheduler: {
17
+ stop(): void;
18
+ };
19
+ eventsWatcher: {
20
+ stop(): void;
21
+ flush?(): Promise<void>;
22
+ };
23
+ runs: {
24
+ stop(): void;
25
+ };
26
+ jobs: {
27
+ stop(): void;
28
+ };
29
+ bot: {
30
+ stop(): Promise<void>;
31
+ };
32
+ store: ChannelStore;
33
+ channelIndex: ChannelIndex;
34
+ channelRunners: Map<string, AgentRunner>;
35
+ activeTasks: Set<Promise<void>>;
36
+ /** Flips the runtime's `isShuttingDown()` the moment shutdown begins. */
37
+ markShuttingDown: () => void;
38
+ }
39
+ export declare function createShutdown(deps: ShutdownDeps): (reason?: NodeJS.Signals | "manual") => Promise<void>;
@@ -0,0 +1,120 @@
1
+ import * as log from "../log.js";
2
+ import { flushSecurityLogs } from "../security/logger.js";
3
+ import { errorMessage } from "../shared/text-utils.js";
4
+ import { getUsageLedger } from "../usage/ledger.js";
5
+ const SHUTDOWN_WAIT_MS = 15000;
6
+ const SHUTDOWN_FLUSH_WAIT_MS = 45000;
7
+ const SHUTDOWN_ABORT_WAIT_MS = 5000;
8
+ const SHUTDOWN_LOG_FLUSH_WAIT_MS = 10_000;
9
+ function waitForTasks(tasks, timeoutMs) {
10
+ if (tasks.length === 0) {
11
+ return Promise.resolve(true);
12
+ }
13
+ return new Promise((resolve) => {
14
+ const timer = setTimeout(() => resolve(false), timeoutMs);
15
+ timer.unref?.();
16
+ void Promise.allSettled(tasks).then(() => {
17
+ clearTimeout(timer);
18
+ resolve(true);
19
+ });
20
+ });
21
+ }
22
+ export function createShutdown(deps) {
23
+ const { taskDriver, memoryMaintenanceScheduler, eventsWatcher, runs, jobs, bot, store, channelIndex, channelRunners, activeTasks, } = deps;
24
+ let shutdownPromise = null;
25
+ return async (reason = "manual") => {
26
+ if (shutdownPromise) {
27
+ return shutdownPromise;
28
+ }
29
+ shutdownPromise = (async () => {
30
+ deps.markShuttingDown();
31
+ log.logInfoEvent("runtime.shutdown.started", "Shutting down", { fields: { reason } });
32
+ taskDriver.stop();
33
+ deps.getDurableDispatch()?.stop();
34
+ memoryMaintenanceScheduler.stop();
35
+ eventsWatcher.stop();
36
+ runs.stop();
37
+ jobs.stop();
38
+ await bot.stop();
39
+ const runningTasks = Array.from(activeTasks);
40
+ if (runningTasks.length > 0) {
41
+ log.logInfoEvent("runtime.shutdown.waiting", "Waiting for active turns to finish", {
42
+ fields: { activeTurns: runningTasks.length },
43
+ });
44
+ const completed = await waitForTasks(runningTasks, SHUTDOWN_WAIT_MS);
45
+ if (!completed) {
46
+ log.logWarn("runtime.shutdown.grace_exceeded", "Shutdown grace period exceeded; aborting active turns", {
47
+ fields: { waitMs: SHUTDOWN_WAIT_MS },
48
+ });
49
+ const aborts = [];
50
+ for (const [channelId, runner] of channelRunners) {
51
+ if (!runner.isBusy())
52
+ continue;
53
+ runner.requestStop();
54
+ log.logInfoEvent("runtime.shutdown.aborting", "Aborting active turn for shutdown", {
55
+ channelId: channelId,
56
+ });
57
+ aborts.push(runner.abort().catch((err) => {
58
+ log.logWarn("runtime.shutdown.abort_failed", "Turn abort during shutdown failed", {
59
+ channelId: channelId,
60
+ reason: errorMessage(err),
61
+ });
62
+ }));
63
+ }
64
+ await Promise.allSettled(aborts);
65
+ const remainingTasks = Array.from(activeTasks);
66
+ if (remainingTasks.length > 0) {
67
+ const abortedCompleted = await waitForTasks(remainingTasks, SHUTDOWN_ABORT_WAIT_MS);
68
+ if (!abortedCompleted) {
69
+ log.logWarn("runtime.shutdown.forced", "Shutdown forced with turns still active", {
70
+ fields: { activeTurns: remainingTasks.length },
71
+ });
72
+ }
73
+ }
74
+ }
75
+ }
76
+ // Idle runners are disposed (flush memory, unsubscribe, release the SDK session); a
77
+ // still-busy one — its turn already aborted above — is just dropped from the cache and
78
+ // left to unwind on its own as the process exits.
79
+ const disposals = [];
80
+ for (const [channelId, runner] of channelRunners) {
81
+ if (runner.isBusy())
82
+ continue;
83
+ disposals.push(runner.dispose().catch((err) => {
84
+ log.logWarn("runtime.shutdown.dispose_failed", "Runner dispose during shutdown failed", {
85
+ channelId: channelId,
86
+ reason: errorMessage(err),
87
+ });
88
+ }));
89
+ }
90
+ if (disposals.length > 0) {
91
+ log.logInfoEvent("runtime.shutdown.disposing", "Disposing idle channel runners", {
92
+ fields: { count: disposals.length },
93
+ });
94
+ const disposed = await waitForTasks(disposals, SHUTDOWN_FLUSH_WAIT_MS);
95
+ if (!disposed) {
96
+ log.logWarn("runtime.shutdown.dispose_timeout", "Runner disposal during shutdown timed out", {
97
+ fields: { waitMs: SHUTDOWN_FLUSH_WAIT_MS },
98
+ });
99
+ }
100
+ }
101
+ channelRunners.clear();
102
+ const storageFlushes = [
103
+ store.close(),
104
+ // Cancels the debounce timer and lands the last activity times.
105
+ channelIndex.close(),
106
+ getUsageLedger().flush?.() ?? Promise.resolve(),
107
+ flushSecurityLogs(),
108
+ ...(eventsWatcher.flush ? [eventsWatcher.flush()] : []),
109
+ ];
110
+ const storageFlushed = await waitForTasks(storageFlushes, SHUTDOWN_LOG_FLUSH_WAIT_MS);
111
+ if (!storageFlushed) {
112
+ log.logWarn("runtime.shutdown.flush_timeout", "Log flush during shutdown timed out", {
113
+ fields: { waitMs: SHUTDOWN_LOG_FLUSH_WAIT_MS },
114
+ });
115
+ }
116
+ await waitForTasks([log.flushLogging()], SHUTDOWN_LOG_FLUSH_WAIT_MS);
117
+ })();
118
+ return shutdownPromise;
119
+ };
120
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The `/stop` watchdog: a stopped turn that never ends is force-released after a grace window, so
3
+ * the channel does not keep reporting "a turn is already running".
4
+ */
5
+ import type { AgentRunner } from "../agent/types.js";
6
+ /**
7
+ * Watchdog for `/stop`: release the channel if the stopped turn has not ended
8
+ * once the grace window elapses. Returns true when it had to force the release.
9
+ */
10
+ export declare function forceEndStuckTurnAfterStop(input: {
11
+ channelId: string;
12
+ runner: AgentRunner;
13
+ graceMs?: number;
14
+ pollMs?: number;
15
+ notify?: (text: string) => Promise<unknown>;
16
+ }): Promise<boolean>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The `/stop` watchdog: a stopped turn that never ends is force-released after a grace window, so
3
+ * the channel does not keep reporting "a turn is already running".
4
+ */
5
+ import { sleepUnref } from "../shared/with-timeout.js";
6
+ /**
7
+ * How long `/stop` waits for the turn to actually end before force-releasing it.
8
+ * `requestStop` + `abort` only reach the agent loop; a turn wedged in its
9
+ * epilogue (delivery drain, session-resource reload, memory flush) ignores both
10
+ * and would otherwise keep the channel reporting "已有回合在运行" indefinitely.
11
+ */
12
+ const STOP_FORCE_END_GRACE_MS = 15_000;
13
+ const STOP_FORCE_END_POLL_MS = 250;
14
+ /**
15
+ * Watchdog for `/stop`: release the channel if the stopped turn has not ended
16
+ * once the grace window elapses. Returns true when it had to force the release.
17
+ */
18
+ export async function forceEndStuckTurnAfterStop(input) {
19
+ const graceMs = input.graceMs ?? STOP_FORCE_END_GRACE_MS;
20
+ const pollMs = input.pollMs ?? STOP_FORCE_END_POLL_MS;
21
+ const deadline = Date.now() + graceMs;
22
+ while (input.runner.isBusy() && Date.now() < deadline) {
23
+ await sleepUnref(Math.min(pollMs, Math.max(1, deadline - Date.now())));
24
+ }
25
+ if (!input.runner.forceEndTurn(`/stop did not take effect within ${graceMs}ms`)) {
26
+ return false;
27
+ }
28
+ await input
29
+ .notify?.(`⚠️ 上一个回合的收尾卡住了,已强制结束以释放会话(后台清理仍在继续)。现在可以正常发消息或使用 \`/new\`、\`/model\`。`)
30
+ .catch(() => undefined);
31
+ return true;
32
+ }
@@ -1,8 +1,8 @@
1
1
  import type { ChannelEvent } from "../channel/channel-event.js";
2
2
  import { type DiscoverOptions } from "../channel/channel-index.js";
3
- import { type PipiclawTaskDriverSettings } from "../settings.js";
3
+ import { type PipiclawTaskDriverSettings } from "../config/settings.js";
4
4
  import { type BudgetBreach } from "../tasks/budget.js";
5
- import { type TaskLedgerEntry } from "../tasks/ledger.js";
5
+ import { type TaskLedgerEntry } from "../tasks/contract.js";
6
6
  export interface TaskDriverOptions {
7
7
  workspaceDir: string;
8
8
  getKnownChannelIds?: () => Iterable<string>;
@@ -2,14 +2,14 @@ import { createHash } from "node:crypto";
2
2
  import { join } from "node:path";
3
3
  import { discoverWorkspaceChannelIds } from "../channel/channel-index.js";
4
4
  import { dedupeChannelIdsByDirectory, getChannelDir, isChannelId } from "../channel/channel-paths.js";
5
+ import { TASK_DRIVER_SETTINGS } from "../config/settings.js";
5
6
  import * as log from "../log.js";
6
7
  import { PLAYBOOKS_DIR } from "../paths.js";
7
- import { TASK_DRIVER_SETTINGS } from "../settings.js";
8
8
  import { errorMessage } from "../shared/text-utils.js";
9
9
  import { checkBudget, IDLE_STEP_LIMIT } from "../tasks/budget.js";
10
+ import { readActiveTasks } from "../tasks/contract.js";
10
11
  import { taskStateLabel } from "../tasks/frontmatter.js";
11
- import { readActiveTasks } from "../tasks/ledger.js";
12
- import { readTaskLog } from "../tasks/log.js";
12
+ import { readTaskLog } from "../tasks/loop-log.js";
13
13
  import { expireTicket, pauseTask, redeemTicket } from "../tasks/store.js";
14
14
  /** Short debounce so a burst of nudges collapses into a single rescan. */
15
15
  const NUDGE_DEBOUNCE_MS = 50;
@@ -8,9 +8,9 @@ import { formatLocalTime } from "../shared/local-time.js";
8
8
  import { errorMessage } from "../shared/text-utils.js";
9
9
  import { isPlainObject } from "../shared/type-guards.js";
10
10
  import { createUsage } from "../tasks/budget.js";
11
+ import { extractTaskTitle, findTaskSectionBounds, normalizeTaskId, parseTaskItems, taskBody, } from "../tasks/contract.js";
11
12
  import { validateTaskContractInput } from "../tasks/contract-input.js";
12
- import { extractTaskTitle, findTaskSectionBounds, normalizeTaskId, parseTaskItems, taskBody } from "../tasks/ledger.js";
13
- import { appendTaskLog } from "../tasks/log.js";
13
+ import { appendTaskLog } from "../tasks/loop-log.js";
14
14
  import { withTaskMutation } from "../tasks/mutation-lock.js";
15
15
  import { ArchiveUndoError, archiveTask, readStoredTask, writeStoredTask } from "../tasks/store.js";
16
16
  import { discoverTaskChannels } from "./task-driver.js";
@@ -1,4 +1,4 @@
1
- import type { SpawnTaskRequest, SpawnTaskResult } from "../events/events.js";
1
+ import type { SpawnTaskRequest, SpawnTaskResult } from "../events/types.js";
2
2
  export interface TaskSpawnerOptions {
3
3
  /** The channel's directory under the workspace. */
4
4
  getChannelDir: (channelId: string) => string;
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import * as log from "../log.js";
3
+ import { readActiveTasks } from "../tasks/contract.js";
3
4
  import { createTaskDocument, instanceStamp } from "../tasks/create.js";
4
5
  import { taskStateLabel } from "../tasks/frontmatter.js";
5
- import { readActiveTasks } from "../tasks/ledger.js";
6
6
  import { archivedTaskPath, taskPath, tasksDir } from "../tasks/store.js";
7
7
  /**
8
8
  * Create the task instance a template event asks for (spec 052, D2).
@@ -0,0 +1,47 @@
1
+ import type { AgentRunner } from "../agent/types.js";
2
+ import type { BootstrapPaths } from "../app/home.js";
3
+ import type { ChannelIndex } from "../channel/channel-index.js";
4
+ import type { ChannelStore } from "../channel/store.js";
5
+ import type { DingTalkHandler } from "../dingtalk/handler.js";
6
+ import type { JobRuntime } from "../jobs/manager.js";
7
+ import type { SubAgentRuntime } from "../subagents/run-registry.js";
8
+ import type { DurableDispatchService } from "./durable-dispatch.js";
9
+ import type { WakeTaskTransitionHooks } from "./task-wake.js";
10
+ import { type ArchivedMessage } from "./turn-run.js";
11
+ export interface TurnHandlerOptions {
12
+ paths: BootstrapPaths;
13
+ /** Override the `/stop` watchdog's grace window (tests use a short one). */
14
+ stopForceEndGraceMs?: number;
15
+ /** Test-only fault seams for the atomic structured-wake task transition. */
16
+ wakeTransitionHooks?: Partial<Record<"job" | "subagent", WakeTaskTransitionHooks>>;
17
+ }
18
+ /**
19
+ * Everything the turn handler needs from `createRuntimeContext`'s scope (review 2026-08-30):
20
+ * pulled out so the handler's dependencies are a reviewable, typed list instead of "however many
21
+ * closures happen to be in scope" in an 850-line inline object literal. The four `get*`/`is*`
22
+ * accessors exist only for state this function's own scope assigns *after* the handler is built
23
+ * (`durableDispatch`, `executor`, `taskDriver`) or mutates later (`shuttingDown`) — a handler
24
+ * method only ever runs long after all of them are set, but a plain value captured at
25
+ * construction time would freeze a stale snapshot instead of observing the real one.
26
+ */
27
+ export interface TurnHandlerDeps {
28
+ options: TurnHandlerOptions;
29
+ store: ChannelStore;
30
+ channelRunners: Map<string, AgentRunner>;
31
+ sessionResetChains: Map<string, Promise<void>>;
32
+ activeTasks: Set<Promise<void>>;
33
+ stopWatchdogs: Set<string>;
34
+ channelIndex: ChannelIndex;
35
+ archiveIncomingMessage: (channelId: string, message: ArchivedMessage, contextLabel: string) => Promise<void>;
36
+ getRunner: (channelId: string) => AgentRunner;
37
+ cliVersion: string;
38
+ startedAt: number;
39
+ isShuttingDown: () => boolean;
40
+ getDurableDispatch: () => DurableDispatchService | undefined;
41
+ getJobs: () => JobRuntime;
42
+ getRuns: () => SubAgentRuntime;
43
+ getTaskDriver: () => {
44
+ nudge?(): void;
45
+ };
46
+ }
47
+ export declare function createTurnHandler(deps: TurnHandlerDeps): DingTalkHandler;