@oyasmi/pipiclaw 0.9.5-beta.2 → 0.9.5-beta.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 (272) hide show
  1. package/README.en.md +9 -11
  2. package/README.md +9 -11
  3. package/dist/agent/channel-runner.d.ts +12 -24
  4. package/dist/agent/channel-runner.js +74 -30
  5. package/dist/agent/maintenance-context.d.ts +2 -0
  6. package/dist/agent/maintenance-context.js +15 -0
  7. package/dist/agent/prompt/sections.js +8 -6
  8. package/dist/agent/prompt/types.d.ts +1 -1
  9. package/dist/agent/runner-factory.js +1 -1
  10. package/dist/agent/session/command-extension.js +11 -0
  11. package/dist/agent/session/compaction-summary.js +6 -2
  12. package/dist/agent/session/execution-trace.d.ts +14 -0
  13. package/dist/agent/session/execution-trace.js +57 -0
  14. package/dist/agent/session/session-events.d.ts +2 -7
  15. package/dist/agent/session/session-events.js +35 -12
  16. package/dist/agent/session/session-host.d.ts +12 -22
  17. package/dist/agent/session/session-host.js +46 -65
  18. package/dist/agent/turn/task-digest.d.ts +1 -2
  19. package/dist/agent/turn/task-digest.js +33 -33
  20. package/dist/agent/turn/turn-context.d.ts +1 -1
  21. package/dist/agent/turn/turn-context.js +1 -1
  22. package/dist/agent/turn/turn-finish.d.ts +2 -2
  23. package/dist/agent/turn/turn-finish.js +3 -2
  24. package/dist/agent/turn/turn-pipeline.d.ts +4 -2
  25. package/dist/agent/turn/turn-pipeline.js +33 -5
  26. package/dist/agent/types.d.ts +64 -14
  27. package/dist/agent/types.js +3 -0
  28. package/dist/app/home.js +3 -4
  29. package/dist/channel/channel-event.d.ts +4 -12
  30. package/dist/channel/ingress.d.ts +1 -9
  31. package/dist/channel/store.d.ts +1 -1
  32. package/dist/commands/catalog.js +25 -19
  33. package/dist/commands/router.d.ts +5 -2
  34. package/dist/commands/router.js +9 -4
  35. package/dist/config/settings.d.ts +5 -12
  36. package/dist/config/settings.js +0 -7
  37. package/dist/config/tools.d.ts +2 -2
  38. package/dist/config/tools.js +2 -2
  39. package/dist/dingtalk/bot.d.ts +2 -0
  40. package/dist/dingtalk/bot.js +4 -0
  41. package/dist/dingtalk/cards.d.ts +7 -0
  42. package/dist/dingtalk/cards.js +32 -2
  43. package/dist/dingtalk/delivery.d.ts +4 -1
  44. package/dist/dingtalk/delivery.js +104 -191
  45. package/dist/dingtalk/progress.d.ts +41 -6
  46. package/dist/dingtalk/progress.js +173 -16
  47. package/dist/file-store.d.ts +4 -0
  48. package/dist/file-store.js +6 -1
  49. package/dist/jobs/completion-observer.d.ts +20 -0
  50. package/dist/jobs/completion-observer.js +107 -0
  51. package/dist/jobs/completion-signal.d.ts +9 -0
  52. package/dist/jobs/completion-signal.js +32 -0
  53. package/dist/jobs/completion-wake.d.ts +1 -1
  54. package/dist/jobs/completion-wake.js +2 -13
  55. package/dist/jobs/manager.d.ts +11 -29
  56. package/dist/jobs/manager.js +103 -176
  57. package/dist/jobs/probe.d.ts +3 -0
  58. package/dist/jobs/probe.js +42 -0
  59. package/dist/jobs/record.d.ts +3 -6
  60. package/dist/jobs/runtime.d.ts +28 -0
  61. package/dist/jobs/runtime.js +69 -0
  62. package/dist/memory/boundary-work.d.ts +2 -0
  63. package/dist/memory/boundary-work.js +79 -37
  64. package/dist/memory/commands.js +4 -1
  65. package/dist/memory/index-budget.js +18 -15
  66. package/dist/memory/journal.js +2 -1
  67. package/dist/memory/lifecycle.d.ts +4 -8
  68. package/dist/memory/lifecycle.js +21 -51
  69. package/dist/memory/reflect-job.d.ts +0 -6
  70. package/dist/memory/reflect-job.js +13 -34
  71. package/dist/memory/reflect.d.ts +4 -0
  72. package/dist/memory/reflect.js +32 -5
  73. package/dist/memory/review-log.d.ts +13 -0
  74. package/dist/memory/review-log.js +49 -0
  75. package/dist/memory/search.js +7 -4
  76. package/dist/memory/source-window.d.ts +18 -1
  77. package/dist/memory/source-window.js +59 -9
  78. package/dist/memory/store.d.ts +2 -0
  79. package/dist/memory/store.js +45 -13
  80. package/dist/playbooks/agent-delegation.md +10 -4
  81. package/dist/playbooks/background-jobs.md +4 -4
  82. package/dist/playbooks/event-scheduling.md +2 -2
  83. package/dist/playbooks/memory-and-learning.md +3 -3
  84. package/dist/playbooks/outbound-media.md +2 -2
  85. package/dist/playbooks/runtime-orientation.md +10 -6
  86. package/dist/playbooks/task-lead.md +54 -33
  87. package/dist/runtime/bootstrap.d.ts +11 -24
  88. package/dist/runtime/bootstrap.js +92 -59
  89. package/dist/runtime/channel-queue.d.ts +2 -0
  90. package/dist/runtime/channel-queue.js +5 -1
  91. package/dist/runtime/durable-dispatch.d.ts +7 -0
  92. package/dist/runtime/durable-dispatch.js +66 -7
  93. package/dist/runtime/ingress-busy.d.ts +1 -2
  94. package/dist/runtime/ingress-busy.js +2 -35
  95. package/dist/runtime/ingress-commands.d.ts +1 -1
  96. package/dist/runtime/ingress-commands.js +28 -20
  97. package/dist/runtime/ingress-deps.d.ts +4 -7
  98. package/dist/runtime/ingress.js +23 -13
  99. package/dist/runtime/shutdown.d.ts +1 -1
  100. package/dist/runtime/shutdown.js +2 -2
  101. package/dist/runtime/task-close.d.ts +4 -0
  102. package/dist/runtime/task-close.js +102 -0
  103. package/dist/runtime/task-control.d.ts +34 -0
  104. package/dist/runtime/task-control.js +225 -0
  105. package/dist/runtime/task-input.d.ts +13 -0
  106. package/dist/runtime/task-input.js +129 -0
  107. package/dist/runtime/task-lane-types.d.ts +123 -0
  108. package/dist/runtime/task-lane-types.js +14 -0
  109. package/dist/runtime/task-lane.d.ts +99 -0
  110. package/dist/runtime/task-lane.js +703 -0
  111. package/dist/runtime/task-pending.d.ts +8 -0
  112. package/dist/runtime/task-pending.js +40 -0
  113. package/dist/runtime/task-spawn.d.ts +4 -4
  114. package/dist/runtime/task-spawn.js +4 -4
  115. package/dist/runtime/task-step.d.ts +32 -0
  116. package/dist/runtime/task-step.js +276 -0
  117. package/dist/runtime/turn-run.d.ts +4 -16
  118. package/dist/runtime/turn-run.js +17 -155
  119. package/dist/runtime/wake-coalescing.d.ts +1 -3
  120. package/dist/runtime/wake-coalescing.js +2 -4
  121. package/dist/shared/format.d.ts +0 -6
  122. package/dist/shared/format.js +0 -17
  123. package/dist/shared/host-process.d.ts +2 -0
  124. package/dist/shared/host-process.js +16 -1
  125. package/dist/shared/jsonl-appender.d.ts +5 -0
  126. package/dist/shared/jsonl-appender.js +25 -2
  127. package/dist/skills/catalog.d.ts +9 -0
  128. package/dist/skills/catalog.js +34 -0
  129. package/dist/skills/commands.d.ts +3 -12
  130. package/dist/skills/commands.js +36 -22
  131. package/dist/skills/loader.d.ts +2 -31
  132. package/dist/skills/loader.js +101 -68
  133. package/dist/skills/roots.d.ts +12 -0
  134. package/dist/skills/roots.js +18 -0
  135. package/dist/skills/types.d.ts +24 -0
  136. package/dist/skills/types.js +1 -0
  137. package/dist/subagents/completion-wake.js +0 -10
  138. package/dist/subagents/discovery.d.ts +1 -1
  139. package/dist/subagents/discovery.js +10 -16
  140. package/dist/subagents/dispatch.js +8 -16
  141. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  142. package/dist/subagents/external/cursor-cli.js +256 -0
  143. package/dist/subagents/external/harness.d.ts +5 -5
  144. package/dist/subagents/external/reconciliation.d.ts +7 -0
  145. package/dist/subagents/external/reconciliation.js +105 -0
  146. package/dist/subagents/external/recovery.d.ts +20 -0
  147. package/dist/subagents/external/recovery.js +71 -0
  148. package/dist/subagents/external/registry.js +2 -0
  149. package/dist/subagents/external/role-warnings.d.ts +17 -0
  150. package/dist/subagents/external/role-warnings.js +42 -0
  151. package/dist/subagents/external/run.js +18 -22
  152. package/dist/subagents/format.d.ts +1 -1
  153. package/dist/subagents/format.js +1 -1
  154. package/dist/subagents/grace.d.ts +2 -2
  155. package/dist/subagents/grace.js +3 -3
  156. package/dist/subagents/internal/run.js +7 -5
  157. package/dist/subagents/internal/worker.js +31 -2
  158. package/dist/subagents/result.js +2 -3
  159. package/dist/subagents/run-record.d.ts +4 -7
  160. package/dist/subagents/run-record.js +2 -2
  161. package/dist/subagents/runs.d.ts +33 -46
  162. package/dist/subagents/runs.js +126 -245
  163. package/dist/subagents/task-settlement.d.ts +3 -0
  164. package/dist/subagents/task-settlement.js +20 -0
  165. package/dist/subagents/types.d.ts +1 -2
  166. package/dist/subagents/workspace-summary.js +5 -1
  167. package/dist/tasks/archive.d.ts +11 -0
  168. package/dist/tasks/archive.js +141 -0
  169. package/dist/tasks/board.d.ts +5 -12
  170. package/dist/tasks/board.js +4 -30
  171. package/dist/tasks/bound-work.d.ts +12 -6
  172. package/dist/tasks/bound-work.js +37 -24
  173. package/dist/tasks/brief.d.ts +38 -14
  174. package/dist/tasks/brief.js +128 -70
  175. package/dist/tasks/budget.d.ts +3 -3
  176. package/dist/tasks/budget.js +9 -4
  177. package/dist/tasks/commands.d.ts +14 -9
  178. package/dist/tasks/commands.js +190 -121
  179. package/dist/tasks/completion.d.ts +12 -0
  180. package/dist/tasks/completion.js +35 -0
  181. package/dist/tasks/contract.d.ts +8 -17
  182. package/dist/tasks/contract.js +41 -43
  183. package/dist/tasks/control.d.ts +138 -0
  184. package/dist/tasks/control.js +1 -0
  185. package/dist/tasks/create.d.ts +1 -1
  186. package/dist/tasks/create.js +3 -3
  187. package/dist/tasks/delivery.d.ts +24 -0
  188. package/dist/tasks/delivery.js +221 -0
  189. package/dist/tasks/file-mutation.d.ts +5 -0
  190. package/dist/tasks/file-mutation.js +38 -0
  191. package/dist/tasks/frontmatter.d.ts +43 -28
  192. package/dist/tasks/frontmatter.js +83 -40
  193. package/dist/tasks/input-receipts.d.ts +7 -0
  194. package/dist/tasks/input-receipts.js +60 -0
  195. package/dist/tasks/loop-log.d.ts +147 -28
  196. package/dist/tasks/loop-log.js +239 -28
  197. package/dist/tasks/receipts.d.ts +19 -0
  198. package/dist/tasks/receipts.js +48 -0
  199. package/dist/tasks/state.d.ts +93 -0
  200. package/dist/tasks/state.js +156 -0
  201. package/dist/tasks/store.d.ts +81 -49
  202. package/dist/tasks/store.js +244 -147
  203. package/dist/tools/bash.d.ts +3 -5
  204. package/dist/tools/bash.js +8 -22
  205. package/dist/tools/contract/details.d.ts +6 -6
  206. package/dist/tools/contract/details.js +6 -6
  207. package/dist/tools/contract/execution-trace.d.ts +4 -0
  208. package/dist/tools/contract/execution-trace.js +23 -0
  209. package/dist/tools/contract/presentation.js +6 -2
  210. package/dist/tools/edit.d.ts +1 -0
  211. package/dist/tools/edit.js +45 -42
  212. package/dist/tools/index.d.ts +8 -12
  213. package/dist/tools/index.js +16 -6
  214. package/dist/tools/memory-manage.js +8 -1
  215. package/dist/tools/registry.d.ts +7 -11
  216. package/dist/tools/registry.js +52 -25
  217. package/dist/tools/skill.d.ts +2 -2
  218. package/dist/tools/skill.js +24 -10
  219. package/dist/tools/subagent-manage.js +7 -4
  220. package/dist/tools/subagent.d.ts +0 -2
  221. package/dist/tools/subagent.js +2 -7
  222. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  223. package/dist/tools/task-manage/control-tools.js +65 -0
  224. package/dist/tools/task-manage/create.js +2 -1
  225. package/dist/tools/task-manage/factory.d.ts +12 -6
  226. package/dist/tools/task-manage/factory.js +72 -57
  227. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  228. package/dist/tools/task-manage/lifecycle.js +118 -66
  229. package/dist/tools/task-manage/log-view.js +8 -5
  230. package/dist/tools/task-manage/schema.d.ts +21 -26
  231. package/dist/tools/task-manage/schema.js +29 -35
  232. package/dist/tools/task-manage/shared.d.ts +8 -39
  233. package/dist/tools/task-manage/shared.js +19 -68
  234. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  235. package/dist/tools/task-manage/step-tools.js +103 -0
  236. package/dist/tools/task-manage/types.d.ts +25 -18
  237. package/dist/tools/write-content.d.ts +1 -0
  238. package/dist/tools/write-content.js +6 -1
  239. package/dist/tools/write.d.ts +1 -0
  240. package/dist/tools/write.js +1 -0
  241. package/dist/usage/ledger.d.ts +4 -4
  242. package/dist/usage/render.js +2 -2
  243. package/dist/web/search-providers.js +0 -33
  244. package/dist/webapi/request-policy.js +1 -1
  245. package/examples/sub-agents/README.md +23 -16
  246. package/examples/sub-agents/agents/claude-high.md +1 -1
  247. package/examples/sub-agents/agents/claude-main.md +1 -1
  248. package/examples/sub-agents/agents/codex-flash.md +1 -1
  249. package/examples/sub-agents/agents/codex-high.md +1 -1
  250. package/examples/sub-agents/agents/codex-main.md +4 -4
  251. package/examples/sub-agents/agents/cursor-high.md +22 -0
  252. package/examples/sub-agents/agents/cursor-main.md +22 -0
  253. package/examples/sub-agents/agents/glm-flash.md +1 -1
  254. package/examples/sub-agents/agents/glm-high.md +2 -2
  255. package/examples/sub-agents/agents/scout.md +30 -0
  256. package/package.json +6 -6
  257. package/dist/runtime/task-driver.d.ts +0 -116
  258. package/dist/runtime/task-driver.js +0 -443
  259. package/dist/runtime/task-wake.d.ts +0 -48
  260. package/dist/runtime/task-wake.js +0 -32
  261. package/dist/shared/wake-claim.d.ts +0 -23
  262. package/dist/shared/wake-claim.js +0 -26
  263. package/dist/skills/validation.d.ts +0 -8
  264. package/dist/skills/validation.js +0 -91
  265. package/dist/skills/workspace.d.ts +0 -33
  266. package/dist/skills/workspace.js +0 -116
  267. package/dist/tasks/steer.d.ts +0 -8
  268. package/dist/tasks/steer.js +0 -81
  269. package/dist/tasks/ticket.d.ts +0 -71
  270. package/dist/tasks/ticket.js +0 -138
  271. package/dist/tools/task-manage/step-end.d.ts +0 -11
  272. package/dist/tools/task-manage/step-end.js +0 -117
@@ -1,443 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { join } from "node:path";
3
- import { TASK_DRIVER_SETTINGS } from "../config/settings.js";
4
- import * as log from "../log.js";
5
- import { PLAYBOOKS_DIR } from "../paths.js";
6
- import { errorMessage } from "../shared/text-utils.js";
7
- import { checkBudget, IDLE_STEP_LIMIT } from "../tasks/budget.js";
8
- import { readActiveTasks } from "../tasks/contract.js";
9
- import { taskStateLabel } from "../tasks/frontmatter.js";
10
- import { readTaskLog } from "../tasks/loop-log.js";
11
- import { expireTicket, pauseTask, redeemTicket } from "../tasks/store.js";
12
- /** Short debounce so a burst of nudges collapses into a single rescan. */
13
- const NUDGE_DEBOUNCE_MS = 50;
14
- /** Never schedule a scan closer than this, so near-now horizons cannot spin the loop. */
15
- const MIN_SLEEP_MS = 250;
16
- /** A task dispatched this recently is assumed still in flight; do not queue it twice. */
17
- const REDISPATCH_GUARD_MS = 30_000;
18
- function attemptKey(desk, taskId) {
19
- return `${desk}\0${taskId}`;
20
- }
21
- /**
22
- * Stable, provenance-derived dispatch id for a task step (spec 031, D1; spec 051 keeps the shape).
23
- * Each step is genuinely new work, so the dispatch moment disambiguates it; collapsing two steps
24
- * onto one durable record would silently drop the later one.
25
- */
26
- function stepDispatchId(desk, entry, nowMs) {
27
- return `task:${desk}:${entry.id}:${nowMs}`;
28
- }
29
- /** The task a `[TASK_DRIVER:<id>]` dispatch text names, if it is one. */
30
- export function parseDriverTaskId(text) {
31
- return /^\[TASK_DRIVER:([A-Za-z0-9._-]+)\]/.exec(text ?? "")?.[1];
32
- }
33
- export function createTaskDriverEvent(desk, channelId, entry, nowMs) {
34
- const repairOnly = !entry.readable;
35
- const repair = repairOnly
36
- ? ` Task metadata is not readable; repair only the frontmatter in tasks/${entry.id}.md, then stop. ` +
37
- `Do not execute the task goal or any external action. Read ${join(PLAYBOOKS_DIR, "task-lead.md")} for the repair path.`
38
- : "";
39
- const capsule = [
40
- `Task capsule: title=${entry.title}; state=${entry.fields.state};`,
41
- entry.fields.usage ? `${entry.fields.usage.steps} steps so far;` : "",
42
- entry.items
43
- ? `items=${entry.items.done}/${entry.items.total} done, current=${entry.items.current?.id ?? "none"};`
44
- : "",
45
- ]
46
- .filter(Boolean)
47
- .join(" ");
48
- return {
49
- source: "wake",
50
- channelId,
51
- producer: "TASK_DRIVER",
52
- text: `[TASK_DRIVER:${entry.id}] Resume task ${entry.id}. ${capsule}${repair} ` +
53
- `Open tasks/${entry.id}.md and read ${join(PLAYBOOKS_DIR, "task-lead.md")} before acting. ` +
54
- (repairOnly
55
- ? "After the metadata is repaired, leave task work for a later step. "
56
- : "Advance the next concrete step under the task's current goal, work items and acceptance state. ") +
57
- "End the step with task_step_end (continue / park / done).",
58
- ts: String(nowMs),
59
- dispatchId: stepDispatchId(desk, entry, nowMs),
60
- desk,
61
- };
62
- }
63
- /**
64
- * The deterministic receipt a runtime stop produces (spec 051, D11). It is delivered directly,
65
- * without opening a model turn: the user needs to know their task stopped, and spending an LLM
66
- * call to phrase that is exactly the kind of cost this design removes. A budget stop also says
67
- * how to resume with more of the dimension that ran out (spec 053, D6).
68
- */
69
- export function taskStopReceipt(desk, channelId, entry, reason, nowMs, breach) {
70
- const usage = entry.fields.usage ? ` · 已用 ${entry.fields.usage.steps} 步` : "";
71
- const grant = breach === "steps" ? " +steps 10" : breach === "usd" ? " +usd 5" : "";
72
- const resumeLabel = grant ? "继续并追加预算" : "继续";
73
- return {
74
- source: "wake",
75
- channelId,
76
- producer: "TASK_DRIVER",
77
- text: `🛑 任务 \`${entry.id}\`(${entry.title})已停止自动执行:${reason}。\n` +
78
- `状态:${taskStateLabel(entry.fields.state)}${usage}\n` +
79
- `查看:\`/tasks show ${entry.id}\`;${resumeLabel}:\`/tasks resume ${entry.id}${grant}\`\n` +
80
- "不再需要:直接告诉我取消该任务。",
81
- ts: String(nowMs),
82
- // Keyed on the cause, not the moment: re-detecting the same stop before the user has acted
83
- // must not queue a second identical receipt, while a different cause still does.
84
- dispatchId: `task:${desk}:${entry.id}:stop:${createHash("sha256").update(reason).digest("hex").slice(0, 12)}`,
85
- desk,
86
- };
87
- }
88
- /**
89
- * Native, ticket-driven scheduler for the persistent task ledger (spec 051, D9; spec 052).
90
- *
91
- * Three jobs, in this order per desk: redeem due `time` tickets, apply the backstop to expired
92
- * ones, and queue one step for a runnable task. `work` and `ask` tickets are never polled — their
93
- * owners push them (a settling delegation or job, `/tasks reply`) — so the scan stays a cheap read
94
- * of a handful of frontmatters. Recurring work is not the driver's business: an event spawns a
95
- * fresh task instance each time (spec 052, D2).
96
- *
97
- * What is deliberately *not* here any more: the ten-field ledger fingerprint, the process-local
98
- * effect ledger, the futile-wake and wake-per-cycle counters, and the three-tier backoff table.
99
- * They existed to guess whether a wake had accomplished anything; in production they fired twice
100
- * in four months while the failure that actually happened — a task parked with no redeemable
101
- * source, silent for 13 days — was invisible to all of them. Stopping is now the loop's own job
102
- * (a budget it can see) and liveness is the ticket's (a backstop the runtime enforces).
103
- */
104
- export class TaskDriver {
105
- constructor(options) {
106
- this.options = options;
107
- this.timer = null;
108
- this.nudgeTimer = null;
109
- this.loopActive = false;
110
- this.running = false;
111
- this.nextDeskIndex = 0;
112
- /** Last dispatch time per task, so one in-flight step is not queued again on the next tick. */
113
- this.lastDispatchMs = new Map();
114
- /**
115
- * Last task id dispatched per desk. Starting the search just after it gives every ready task in
116
- * a desk the same round-robin fairness an actively-progressing task would otherwise monopolise.
117
- */
118
- this.lastDispatchedTaskId = new Map();
119
- /** Tasks currently suspended (D8), so the transition is logged once rather than every scan. */
120
- this.suspended = new Set();
121
- }
122
- observeDispatch(event, accepted) {
123
- try {
124
- this.options.onDispatch?.(event, accepted);
125
- }
126
- catch (error) {
127
- log.logWarn("taskdriver.observer.failed", "Task driver dispatch observer failed", {
128
- reason: errorMessage(error),
129
- });
130
- }
131
- }
132
- start() {
133
- if (this.loopActive)
134
- return;
135
- this.loopActive = true;
136
- log.logInfoEvent("taskdriver.started", "Task driver started", {
137
- fields: { timezone: Intl.DateTimeFormat().resolvedOptions().timeZone },
138
- });
139
- void this.tick();
140
- }
141
- stop() {
142
- this.loopActive = false;
143
- if (this.timer) {
144
- clearTimeout(this.timer);
145
- this.timer = null;
146
- }
147
- if (this.nudgeTimer) {
148
- clearTimeout(this.nudgeTimer);
149
- this.nudgeTimer = null;
150
- }
151
- }
152
- /**
153
- * In-process wake: after a step ends or a task file is written, re-scan promptly instead of
154
- * waiting out the current sleep. This is what makes `outcome: continue` cost nothing — the
155
- * next step is queued on the same nudge rather than after a continuation delay.
156
- */
157
- nudge() {
158
- if (!this.loopActive || this.nudgeTimer)
159
- return;
160
- if (this.timer) {
161
- clearTimeout(this.timer);
162
- this.timer = null;
163
- }
164
- this.nudgeTimer = setTimeout(() => {
165
- this.nudgeTimer = null;
166
- void this.tick();
167
- }, NUDGE_DEBOUNCE_MS);
168
- this.nudgeTimer.unref?.();
169
- }
170
- async tick() {
171
- try {
172
- await this.runOnce();
173
- }
174
- catch (error) {
175
- log.logWarn("taskdriver.tick.failed", "Task driver tick failed", { reason: errorMessage(error) });
176
- }
177
- this.scheduleNext();
178
- }
179
- scheduleNext() {
180
- if (!this.loopActive || this.timer || this.nudgeTimer)
181
- return;
182
- const settings = this.options.settings ?? TASK_DRIVER_SETTINGS;
183
- const capMs = this.options.intervalMs ?? settings.maxSleepMinutes * 60_000;
184
- const untilNext = this.nextWakeMs !== undefined ? this.nextWakeMs - Date.now() : Number.POSITIVE_INFINITY;
185
- const sleepMs = Math.max(MIN_SLEEP_MS, Math.min(capMs, untilNext));
186
- this.timer = setTimeout(() => {
187
- this.timer = null;
188
- void this.tick();
189
- }, sleepMs);
190
- this.timer.unref?.();
191
- }
192
- /** Fold `candidate` into the earliest interesting wake moment. */
193
- noteHorizon(candidate, nowMs) {
194
- if (candidate === undefined || !Number.isFinite(candidate) || candidate <= nowMs)
195
- return;
196
- if (this.nextWakeMs === undefined || candidate < this.nextWakeMs)
197
- this.nextWakeMs = candidate;
198
- }
199
- /** Stop one task and notify. Delivery failure is logged, never fatal: the durable stop already happened. */
200
- async notifyStop(desk, channelId, entry, reason, nowMs, breach) {
201
- try {
202
- await this.options.notify?.(taskStopReceipt(desk, channelId, entry, reason, nowMs, breach));
203
- }
204
- catch (error) {
205
- log.logWarn("taskdriver.receipt.failed", "Task stop receipt failed", {
206
- channelId: channelId,
207
- reason: errorMessage(error),
208
- });
209
- }
210
- }
211
- /**
212
- * Deterministic, zero-token maintenance for one desk's live tasks: redeem due tickets and apply
213
- * expiry backstops. Runs whether or not the delivery channel is busy — only model dispatch is
214
- * gated on an idle channel.
215
- */
216
- async maintain(desk, deskDir, entries, now) {
217
- const nowMs = now.getTime();
218
- let changed = false;
219
- for (const { entry, channelId } of entries) {
220
- if (entry.fields.paused || entry.fields.state !== "parked")
221
- continue;
222
- const ticket = entry.fields.ticket;
223
- if (!ticket)
224
- continue;
225
- // A due timer redeems into an open task.
226
- if (entry.dueMs !== undefined && entry.dueMs <= nowMs) {
227
- if (await redeemTicket(deskDir, entry.id, (current) => current.kind === ticket.kind))
228
- changed = true;
229
- continue;
230
- }
231
- if (entry.expired) {
232
- const expiry = await expireTicket(deskDir, entry.id);
233
- if (!expiry)
234
- continue;
235
- changed = true;
236
- if (expiry.outcome === "paused") {
237
- log.logWarn("taskdriver.task.paused", "Task paused: ticket expired twice", {
238
- channelId: channelId,
239
- reason: expiry.ticket,
240
- fields: { taskId: entry.id, desk, cause: "ticket_expired" },
241
- });
242
- await this.notifyStop(desk, channelId, entry, `等待条件一直未满足(${expiry.ticket}),已连续两次超过最晚检查时间`, nowMs);
243
- }
244
- else {
245
- log.logInfoEvent("taskdriver.task.reopened", "Task reopened after its ticket expired", {
246
- channelId: channelId,
247
- reason: expiry.ticket,
248
- fields: { taskId: entry.id, desk },
249
- });
250
- }
251
- continue;
252
- }
253
- this.noteHorizon(entry.dueMs, nowMs);
254
- this.noteHorizon(new Date(ticket.by).getTime(), nowMs);
255
- }
256
- return changed;
257
- }
258
- /**
259
- * Stop a loop that is talking to itself: two consecutive steps that produced no tool call at
260
- * all. This is the honest replacement for v3's futile-wake counter — the loop log records what
261
- * each step actually did, so "no progress" is an observed fact rather than a fingerprint
262
- * comparison a `echo x` could defeat.
263
- */
264
- async detectIdleLoop(desk, deskDir, entries, nowMs) {
265
- let paused = false;
266
- for (const { entry, channelId } of entries) {
267
- const usage = entry.fields.usage;
268
- if (!usage || usage.steps < IDLE_STEP_LIMIT)
269
- continue;
270
- const steps = (await readTaskLog(deskDir, entry.id, { kinds: ["step"] })).slice(-IDLE_STEP_LIMIT);
271
- if (steps.length < IDLE_STEP_LIMIT)
272
- continue;
273
- const idle = steps.every((record) => record.kind === "step" && record.tools.length === 0);
274
- if (!idle)
275
- continue;
276
- const reason = `连续 ${IDLE_STEP_LIMIT} 步没有任何工具调用,已停下等你确认`;
277
- if (await pauseTask(deskDir, entry.id, { by: "runtime", reason })) {
278
- paused = true;
279
- log.logWarn("taskdriver.task.paused", "Task paused: idle loop", {
280
- channelId: channelId,
281
- reason: reason,
282
- fields: { taskId: entry.id, desk, cause: "idle" },
283
- });
284
- await this.notifyStop(desk, channelId, entry, reason, nowMs);
285
- }
286
- }
287
- return paused;
288
- }
289
- /**
290
- * The tasks of one desk the driver may touch at all (spec 058, D8): those whose delivery channel
291
- * is bound to this desk and reachable. Every other task — no `channel`, or a channel bound elsewhere or nowhere, or on a transport that is off
292
- * — is frozen: no ticket redemption, no backstop, no budget or idle check, no step, no receipt.
293
- * Freezing reads nothing back into the file, so a rebound task resumes from exactly where it was.
294
- */
295
- liveTasks(desk, entries) {
296
- const live = [];
297
- for (const entry of entries) {
298
- const key = attemptKey(desk, entry.id);
299
- const channelId = entry.fields.channel;
300
- if (channelId && this.options.isBoundTo(channelId, desk) && this.options.isReachable(channelId)) {
301
- if (this.suspended.delete(key)) {
302
- log.logInfoEvent("taskdriver.task.resumed", "Task resumed: delivery channel bound again", {
303
- channelId,
304
- fields: { taskId: entry.id, desk },
305
- });
306
- }
307
- live.push({ entry, channelId });
308
- continue;
309
- }
310
- if (!this.suspended.has(key)) {
311
- this.suspended.add(key);
312
- log.logInfoEvent("taskdriver.task.suspended", "Task suspended: delivery channel not usable", {
313
- channelId,
314
- fields: {
315
- taskId: entry.id,
316
- desk,
317
- reason: !channelId
318
- ? "channel_missing"
319
- : this.options.isBoundTo(channelId, desk)
320
- ? "channel_unreachable"
321
- : "channel_not_bound",
322
- },
323
- });
324
- }
325
- }
326
- return live;
327
- }
328
- async runOnce(now = new Date()) {
329
- if (this.options.isEnabled?.() === false || this.running)
330
- return;
331
- const settings = this.options.settings ?? TASK_DRIVER_SETTINGS;
332
- const nowMs = now.getTime();
333
- this.running = true;
334
- this.nextWakeMs = undefined;
335
- try {
336
- const desks = this.options.getActiveDesks();
337
- if (desks.length === 0) {
338
- this.lastDispatchMs.clear();
339
- return;
340
- }
341
- const seen = new Set();
342
- const start = this.nextDeskIndex % desks.length;
343
- let dispatched = 0;
344
- let lastDispatchOffset = -1;
345
- for (let offset = 0; offset < desks.length; offset++) {
346
- const target = desks[(start + offset) % desks.length];
347
- if (!target)
348
- continue;
349
- const { desk, deskDir } = target;
350
- const tasksDir = join(deskDir, "tasks");
351
- const readLive = async () => this.liveTasks(desk, await readActiveTasks(tasksDir, nowMs));
352
- let live = await readLive();
353
- for (const { entry } of live)
354
- seen.add(attemptKey(desk, entry.id));
355
- if (await this.maintain(desk, deskDir, live, now))
356
- live = await readLive();
357
- if (dispatched >= settings.maxDispatchesPerTick)
358
- continue;
359
- // A task that has already run out of budget must not spend one more model call to
360
- // discover that (D6). Checked before dispatch, and paired with a receipt so the user
361
- // learns why it stopped and what to type to give it more rope.
362
- const budgeted = [];
363
- for (const task of live) {
364
- const { entry, channelId } = task;
365
- if (!entry.runnable)
366
- continue;
367
- const status = checkBudget(entry.fields);
368
- if (!status.breach || !status.reason) {
369
- budgeted.push(task);
370
- continue;
371
- }
372
- if (await pauseTask(deskDir, entry.id, { by: "runtime", reason: status.reason })) {
373
- log.logWarn("taskdriver.task.paused", "Task paused: budget exhausted", {
374
- channelId: channelId,
375
- reason: status.reason,
376
- fields: { taskId: entry.id, desk, cause: `budget_${status.breach}` },
377
- });
378
- await this.notifyStop(desk, channelId, entry, status.reason, nowMs, status.breach);
379
- }
380
- }
381
- const idled = await this.detectIdleLoop(desk, deskDir, budgeted, nowMs);
382
- const ready = idled ? (await readLive()).filter(({ entry }) => entry.runnable) : budgeted;
383
- // The busy check is per task: a desk's tasks may deliver to different channels.
384
- const candidates = ready.filter(({ entry, channelId }) => !entry.fields.paused && !this.options.isChannelActive(channelId));
385
- if (candidates.length === 0)
386
- continue;
387
- const lastId = this.lastDispatchedTaskId.get(desk);
388
- const lastIndex = lastId ? candidates.findIndex(({ entry }) => entry.id === lastId) : -1;
389
- const rotated = lastIndex >= 0
390
- ? [...candidates.slice(lastIndex + 1), ...candidates.slice(0, lastIndex + 1)]
391
- : candidates;
392
- // One step per delivery channel per pass: a desk's tasks may deliver to different channels,
393
- // whose queues run independently, so one channel's step must not hold back another's.
394
- // Tasks sharing a channel still take turns (D6 rotation).
395
- const usedChannels = new Set();
396
- for (const { entry, channelId } of rotated) {
397
- if (dispatched >= settings.maxDispatchesPerTick)
398
- break;
399
- if (usedChannels.has(channelId))
400
- continue;
401
- const previous = this.lastDispatchMs.get(attemptKey(desk, entry.id));
402
- if (previous !== undefined && nowMs - previous < REDISPATCH_GUARD_MS) {
403
- this.noteHorizon(previous + REDISPATCH_GUARD_MS, nowMs);
404
- continue;
405
- }
406
- usedChannels.add(channelId);
407
- const event = createTaskDriverEvent(desk, channelId, entry, nowMs);
408
- const accepted = await this.options.dispatch(event);
409
- this.observeDispatch(event, accepted);
410
- this.lastDispatchMs.set(attemptKey(desk, entry.id), nowMs);
411
- this.lastDispatchedTaskId.set(desk, entry.id);
412
- if (accepted) {
413
- dispatched++;
414
- lastDispatchOffset = offset;
415
- log.logDebugEvent("taskdriver.step.enqueued", "Task step enqueued", {
416
- channelId: channelId,
417
- fields: { taskId: entry.id, desk },
418
- });
419
- }
420
- else {
421
- log.logWarn("taskdriver.step.enqueue_failed", "Task step not enqueued: channel queue unavailable", {
422
- channelId: channelId,
423
- fields: { taskId: entry.id, desk },
424
- });
425
- }
426
- }
427
- }
428
- for (const key of this.lastDispatchMs.keys()) {
429
- if (!seen.has(key))
430
- this.lastDispatchMs.delete(key);
431
- }
432
- const deskSet = new Set(desks.map((target) => target.desk));
433
- for (const desk of this.lastDispatchedTaskId.keys()) {
434
- if (!deskSet.has(desk))
435
- this.lastDispatchedTaskId.delete(desk);
436
- }
437
- this.nextDeskIndex = (start + (lastDispatchOffset >= 0 ? lastDispatchOffset + 1 : 1)) % desks.length;
438
- }
439
- finally {
440
- this.running = false;
441
- }
442
- }
443
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * Claiming a background job's or delegation run's completion wake before it may reopen a parked
3
- * task (spec 040, D7/T9). Pure functions over an explicit `event`/`deskDir`/owner, with no
4
- * dependency on `createRuntimeContext`'s closures.
5
- *
6
- * Trust comes from two things only: the producer-created `internalWake` envelope (DingTalk
7
- * inbound parsing never populates it, so user text or an external agent's stdout cannot forge
8
- * one), and the owner's `beginWakeConsumption`, which re-checks that the resource exists, has
9
- * settled, names this task, and that the dispatch id is exactly the one its own completion wake
10
- * carries.
11
- */
12
- import type { WakeEvent } from "../channel/channel-event.js";
13
- /** The slice of `DeskJobManager` / `SubAgentRunManager` a wake claim needs. */
14
- export interface WakeOwner {
15
- beginWakeConsumption(id: string, taskId: string, dispatchId: string): Promise<boolean>;
16
- finishWakeConsumption(id: string, dispatchId: string): Promise<void>;
17
- }
18
- /** Test-only fault seam, kept for the restart/interrupt cases that exercise a failed write. */
19
- export interface WakeTaskTransitionHooks {
20
- beforeActivation?: () => void;
21
- }
22
- export interface ClaimedWake {
23
- taskId: string;
24
- /** True when this wake redeemed the task's `work` ticket. */
25
- activated: boolean;
26
- /**
27
- * True when it is safe to drop this wake without a turn even though it did not redeem a ticket
28
- * itself: the task is already `open` and not paused, so some other wake in the same fan-out
29
- * reopened it and the driver will pick up the result. Every other case — done, archived,
30
- * paused, or the task missing — has nobody left to look at the result if it is dropped, so the
31
- * caller must still route it to a normal turn. Always true when `activated` is true.
32
- */
33
- taskStillDriven: boolean;
34
- /** Mark the wake consumed. Kept separate so the caller finalizes only after it accepted the turn. */
35
- finish(): Promise<void>;
36
- }
37
- /**
38
- * Claim a producer-created completion wake and redeem the task's ticket for it. Returns
39
- * `undefined` for an event with no (or an unverifiable) `internalWake`.
40
- *
41
- * Only a `work` ticket may be redeemed by a settling run or job (any bound run or job settling
42
- * wakes the leader, spec 052, D3): a task parked on a clock or a question to the user is not
43
- * waiting for it, and reopening it here would be exactly the unverified resumption path spec 051
44
- * exists to remove.
45
- */
46
- export declare function claimVerifiedWake(event: WakeEvent,
47
- /** The admitted wake's desk directory — where the task it names lives. */
48
- deskDir: string, owner: WakeOwner, hooks?: WakeTaskTransitionHooks): Promise<ClaimedWake | undefined>;
@@ -1,32 +0,0 @@
1
- import { readStoredTask, redeemTicket } from "../tasks/store.js";
2
- async function isTaskActivelyDriven(deskDir, taskId) {
3
- const document = await readStoredTask(deskDir, taskId).catch(() => undefined);
4
- return document !== undefined && document.fields.state === "open" && !document.fields.paused;
5
- }
6
- /**
7
- * Claim a producer-created completion wake and redeem the task's ticket for it. Returns
8
- * `undefined` for an event with no (or an unverifiable) `internalWake`.
9
- *
10
- * Only a `work` ticket may be redeemed by a settling run or job (any bound run or job settling
11
- * wakes the leader, spec 052, D3): a task parked on a clock or a question to the user is not
12
- * waiting for it, and reopening it here would be exactly the unverified resumption path spec 051
13
- * exists to remove.
14
- */
15
- export async function claimVerifiedWake(event,
16
- /** The admitted wake's desk directory — where the task it names lives. */
17
- deskDir, owner, hooks) {
18
- const wake = event.internalWake;
19
- if (!wake || typeof event.dispatchId !== "string")
20
- return undefined;
21
- if (!(await owner.beginWakeConsumption(wake.resourceId, wake.taskId, event.dispatchId)))
22
- return undefined;
23
- const dispatchId = event.dispatchId;
24
- hooks?.beforeActivation?.();
25
- const redeemed = await redeemTicket(deskDir, wake.taskId, (ticket) => ticket.kind === "work");
26
- return {
27
- taskId: wake.taskId,
28
- activated: redeemed !== undefined,
29
- taskStillDriven: redeemed !== undefined || (await isTaskActivelyDriven(deskDir, wake.taskId)),
30
- finish: () => owner.finishWakeConsumption(wake.resourceId, dispatchId),
31
- };
32
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * The two-phase "claim, then finish" decision shared by `jobs/manager.ts` and `subagents/runs.ts`
3
- * for reserving a completion wake exactly once (spec 040, D7/T9). Both managers persist a
4
- * `RunRecord`/`JobRecord` differently and gate eligibility on a different terminal condition
5
- * (job: `status !== "running"`; run: `settledAt` set), so only the claim/consume decision on the
6
- * two shared fields is factored out here — not the queue, the persistence, or the eligibility check.
7
- */
8
- export interface WakeClaimFields {
9
- wakeClaimDispatchId?: string;
10
- wakeConsumedAt?: number;
11
- }
12
- /**
13
- * Reserve `dispatchId` as the claim on `fields`, if `eligible` (the caller's terminal/taskId/
14
- * dispatch-id-match check) holds and no conflicting claim or consumption already exists. Mutates
15
- * `fields` in place and returns whether the claim was taken; the caller persists the result and
16
- * rolls the mutation back on a failed write.
17
- */
18
- export declare function beginWakeClaim(fields: WakeClaimFields, eligible: boolean, dispatchId: string): boolean;
19
- /**
20
- * Mark a previously claimed wake consumed, if `dispatchId` matches the outstanding claim and it
21
- * has not already been consumed. Mutates `fields` in place and returns whether it changed.
22
- */
23
- export declare function finishWakeClaim(fields: WakeClaimFields, dispatchId: string): boolean;
@@ -1,26 +0,0 @@
1
- /**
2
- * Reserve `dispatchId` as the claim on `fields`, if `eligible` (the caller's terminal/taskId/
3
- * dispatch-id-match check) holds and no conflicting claim or consumption already exists. Mutates
4
- * `fields` in place and returns whether the claim was taken; the caller persists the result and
5
- * rolls the mutation back on a failed write.
6
- */
7
- export function beginWakeClaim(fields, eligible, dispatchId) {
8
- if (!eligible ||
9
- fields.wakeConsumedAt !== undefined ||
10
- (fields.wakeClaimDispatchId !== undefined && fields.wakeClaimDispatchId !== dispatchId)) {
11
- return false;
12
- }
13
- fields.wakeClaimDispatchId = dispatchId;
14
- return true;
15
- }
16
- /**
17
- * Mark a previously claimed wake consumed, if `dispatchId` matches the outstanding claim and it
18
- * has not already been consumed. Mutates `fields` in place and returns whether it changed.
19
- */
20
- export function finishWakeClaim(fields, dispatchId) {
21
- if (fields.wakeClaimDispatchId !== dispatchId || fields.wakeConsumedAt !== undefined) {
22
- return false;
23
- }
24
- fields.wakeConsumedAt = Date.now();
25
- return true;
26
- }
@@ -1,8 +0,0 @@
1
- export interface SkillValidationResult {
2
- ok: boolean;
3
- error?: string;
4
- }
5
- export declare function validateSkillName(name: string): SkillValidationResult;
6
- export declare function validateSkillFrontmatter(content: string, expectedName: string): SkillValidationResult;
7
- export declare function resolveSkillPath(workspaceDir: string, name: string): string;
8
- export declare function scanSkillContent(content: string): SkillValidationResult;
@@ -1,91 +0,0 @@
1
- /**
2
- * Validation of workspace skills: names, frontmatter, content scanning, and confinement of a skill's
3
- * path to `workspace/skills/`.
4
- */
5
- import { resolve } from "node:path";
6
- const SKILL_NAME_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
7
- const FRONTMATTER_REGEX = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/;
8
- const BLOCKED_CONTENT_PATTERNS = [
9
- { pattern: /ignore\s+(all\s+)?(previous|prior)\s+instructions/i, message: "contains prompt-injection wording" },
10
- {
11
- pattern: /disregard\s+(all\s+)?(previous|prior|above)\s+(instructions|rules)/i,
12
- message: "contains prompt-injection wording",
13
- },
14
- { pattern: /you\s+are\s+now\s+(a|an|the)\s+/i, message: "contains prompt-injection wording" },
15
- { pattern: /new\s+system\s+prompt/i, message: "contains prompt-injection wording" },
16
- { pattern: /exfiltrat(e|ion)|steal\s+(secrets?|credentials?|tokens?)/i, message: "contains exfiltration wording" },
17
- { pattern: /rm\s+-rf\s+\/(?:\s|$)/i, message: "contains destructive root removal command" },
18
- { pattern: /curl\b[\s\S]{0,120}\|\s*(?:sh|bash)\b/i, message: "contains pipe-to-shell install command" },
19
- { pattern: /wget\b[\s\S]{0,120}\|\s*(?:sh|bash)\b/i, message: "contains pipe-to-shell install command" },
20
- {
21
- pattern: /cat\s+.*(?:\.env|id_rsa|id_ed25519|credentials|\.ssh\/|\.aws\/)/i,
22
- message: "contains credential file access",
23
- },
24
- { pattern: /chmod\s+(?:777|[+]s)\b/i, message: "contains dangerous permission change" },
25
- { pattern: /dd\s+if=.*of=\/dev\//i, message: "contains raw device write command" },
26
- { pattern: /\b(?:mkfs|fdisk)\b/i, message: "contains disk formatting command" },
27
- { pattern: /[\u200B-\u200D\uFEFF]/u, message: "contains invisible unicode characters" },
28
- ];
29
- function ok() {
30
- return { ok: true };
31
- }
32
- function fail(error) {
33
- return { ok: false, error };
34
- }
35
- function parseFrontmatter(content) {
36
- const match = content.replace(/\r\n/g, "\n").match(FRONTMATTER_REGEX);
37
- if (!match) {
38
- return null;
39
- }
40
- const data = {};
41
- for (const line of (match[1] ?? "").split("\n")) {
42
- const fieldMatch = line.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
43
- if (!fieldMatch) {
44
- continue;
45
- }
46
- data[fieldMatch[1]] = fieldMatch[2].replace(/^["']|["']$/g, "").trim();
47
- }
48
- return { data, body: match[2] ?? "" };
49
- }
50
- export function validateSkillName(name) {
51
- if (!SKILL_NAME_REGEX.test(name)) {
52
- return fail("Skill name must match [a-z0-9]+(-[a-z0-9]+)*.");
53
- }
54
- return ok();
55
- }
56
- export function validateSkillFrontmatter(content, expectedName) {
57
- const parsed = parseFrontmatter(content);
58
- if (!parsed) {
59
- return fail("SKILL.md must start with YAML frontmatter.");
60
- }
61
- if (parsed.data.name !== expectedName) {
62
- return fail(`Skill frontmatter name must be "${expectedName}".`);
63
- }
64
- if (!parsed.data.description) {
65
- return fail("Skill frontmatter must include a non-empty description.");
66
- }
67
- if (!parsed.body.trim()) {
68
- return fail("Skill body must be non-empty.");
69
- }
70
- return ok();
71
- }
72
- export function resolveSkillPath(workspaceDir, name) {
73
- const result = validateSkillName(name);
74
- if (!result.ok) {
75
- throw new Error(result.error);
76
- }
77
- const skillsDir = resolve(workspaceDir, "skills");
78
- const skillDir = resolve(skillsDir, name);
79
- if (!skillDir.startsWith(`${skillsDir}/`)) {
80
- throw new Error("Resolved skill path escaped workspace skills directory.");
81
- }
82
- return skillDir;
83
- }
84
- export function scanSkillContent(content) {
85
- for (const { pattern, message } of BLOCKED_CONTENT_PATTERNS) {
86
- if (pattern.test(content)) {
87
- return fail(message);
88
- }
89
- }
90
- return ok();
91
- }