@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,48 +1,9 @@
1
1
  /**
2
- * Rendering + input contracts for the terminal TUI.
3
- *
4
- * `TranscriptRenderer` is the output-only surface the delivery controller
5
- * (`terminal-context.ts`) writes to — progress, final answers, notices. It is
6
- * deliberately small so it is trivial to fake in tests.
7
- *
8
- * `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
9
- * plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
10
- * (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
11
- * for non-TTY / piped / `--print` use.
2
+ * Frontend selection for the terminal TUI: the rich pi-tui UI on a TTY, else the plain stream.
3
+ * The contracts themselves (`TranscriptRenderer`, `Frontend`) live in `frontend.ts`.
12
4
  */
13
5
  import type { SlashCommand } from "@earendil-works/pi-tui";
14
- export interface TranscriptRenderer {
15
- /** A streamed progress line (tool call, thinking, assistant increment, error). */
16
- appendProgress(text: string): void;
17
- /** The final answer for a turn, rendered prominently (Markdown where supported). */
18
- showFinal(markdown: string): void;
19
- /** A side notice (skill change, model fallback), rendered subtly. */
20
- showNotice(text: string): void;
21
- /** Collapse the current turn's progress region (used before a replacing final / silence). */
22
- clearProgress(): void;
23
- /** Toggle the working indicator (spinner). */
24
- setWorking(on: boolean): void;
25
- }
26
- export interface FrontendCallbacks {
27
- /** User submitted a line of input. */
28
- onSubmit(text: string): void;
29
- /** User pressed the interrupt key (Ctrl-C). Two-stage policy lives in the app. */
30
- onInterrupt(): void;
31
- /** End of input (Ctrl-D on an empty line, or stdin closed). */
32
- onEof(): void;
33
- }
34
- export interface Frontend extends TranscriptRenderer {
35
- /** Begin surfacing input events. Non-blocking. */
36
- start(callbacks: FrontendCallbacks): void;
37
- /** Update the status line (model, context %, hints). */
38
- setStatus(text: string): void;
39
- /** Mark a turn in-flight: disable input echo of a new turn and show the spinner. */
40
- setBusy(busy: boolean): void;
41
- /** Show a one-time welcome banner at startup. */
42
- showBanner(text: string): void;
43
- /** Tear down: restore the terminal, stop reading input. */
44
- stop(): void;
45
- }
6
+ import type { Frontend } from "./frontend.js";
46
7
  export interface FrontendOptions {
47
8
  /** Force the plain frontend even on a TTY. */
48
9
  plain?: boolean;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Terminal implementation of the `ChannelContext` delivery contract.
3
3
  *
4
- * The DingTalk delivery controller (`runtime/delivery.ts`) drives AI Card
4
+ * The DingTalk delivery controller (`dingtalk/delivery.ts`) drives AI Card
5
5
  * streaming; the terminal has none of that protocol, so this controller is a
6
6
  * thin mapping from the contract onto a `TranscriptRenderer`. Archiving
7
7
  * semantics mirror `delivery.ts` so a channel produces the same conversation log
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import type { ChannelContext, FinalDelivery, ProgressStyle } from "../channel/channel-context.js";
13
13
  import type { ChannelStore } from "../channel/store.js";
14
- import type { TranscriptRenderer } from "./renderer.js";
14
+ import type { TranscriptRenderer } from "./frontend.js";
15
15
  /** The minimal per-turn input the terminal context needs (no DingTalk types). */
16
16
  export interface TurnInput {
17
17
  text: string;
@@ -1,5 +1,5 @@
1
+ import type { BootstrapIO } from "../app/home.js";
1
2
  import type { MediaSender } from "../channel/channel-context.js";
2
- import type { BootstrapIO } from "../runtime/app-home.js";
3
3
  /**
4
4
  * Terminal implementation of the `MediaSender` port. There is no chat surface to
5
5
  * push a file to, and the bytes already came from a local file, so "sending" here
@@ -9,7 +9,7 @@
9
9
  import type { AgentRunner } from "../agent/types.js";
10
10
  import type { ChannelStore } from "../channel/store.js";
11
11
  import { type DispatchDeps } from "./commands.js";
12
- import type { Frontend } from "./renderer.js";
12
+ import type { Frontend } from "./frontend.js";
13
13
  import { type DeliveryTraits } from "./terminal-context.js";
14
14
  export interface TurnControllerDeps {
15
15
  runner: AgentRunner;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * The usage ledger: an append-only JSONL record of every model spend (turns, sub-agent runs, sidecar
3
+ * work) so the totals add up to real cost without double counting.
4
+ */
1
5
  import { readFile, stat } from "node:fs/promises";
2
6
  import { join } from "node:path";
3
7
  import * as log from "../log.js";
@@ -1,3 +1,6 @@
1
+ /**
2
+ * `UsageTotals` and the accumulators over it.
3
+ */
1
4
  export interface UsageTotals {
2
5
  input: number;
3
6
  output: number;
@@ -1,6 +1,10 @@
1
+ /**
2
+ * The shared HTTP client behind the web tools: request/response shapes, DNS pinning for
3
+ * validated targets, and proxy agent selection.
4
+ */
1
5
  import { Buffer } from "node:buffer";
6
+ import type { PipiclawWebToolsConfig } from "../config/tools.js";
2
7
  import type { SecurityConfig } from "../security/types.js";
3
- import type { PipiclawWebToolsConfig } from "../tools/config.js";
4
8
  export declare const WEB_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Pipiclaw/0.5";
5
9
  export interface WebRuntimeContext {
6
10
  webConfig: PipiclawWebToolsConfig;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * The shared HTTP client behind the web tools: request/response shapes, DNS pinning for
3
+ * validated targets, and proxy agent selection.
4
+ */
1
5
  import { Buffer } from "node:buffer";
2
6
  import { Agent as HttpAgent } from "node:http";
3
7
  import { Agent as HttpsAgent } from "node:https";
@@ -1,4 +1,4 @@
1
- import type { PipiclawWebFetchConfig, PipiclawWebSearchConfig } from "../tools/config.js";
1
+ import type { PipiclawWebFetchConfig, PipiclawWebSearchConfig } from "../config/tools.js";
2
2
  export interface ResolvedWebSearchRequest {
3
3
  query: string;
4
4
  count: number;
@@ -1,7 +1,7 @@
1
1
  import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
2
+ import type { PipiclawWebToolsConfig } from "../config/tools.js";
2
3
  import type { SecurityConfig } from "../security/types.js";
3
4
  import { RecoverableToolError } from "../shared/recoverable-error.js";
4
- import type { PipiclawWebToolsConfig } from "../tools/config.js";
5
5
  import { type FormattedFetchDetails } from "./format.js";
6
6
  export interface WebFetchExecutionContext {
7
7
  webConfig: PipiclawWebToolsConfig;
@@ -1,4 +1,4 @@
1
- import type { PipiclawWebSearchConfig, WebSearchProvider as WebSearchProviderName } from "../tools/config.js";
1
+ import type { PipiclawWebSearchConfig, WebSearchProvider as WebSearchProviderName } from "../config/tools.js";
2
2
  import type { WebHttpClient } from "./client.js";
3
3
  import type { WebSearchResultItem } from "./format.js";
4
4
  export declare class WebSearchProviderError extends Error {
@@ -1,5 +1,5 @@
1
+ import type { PipiclawWebToolsConfig } from "../config/tools.js";
1
2
  import type { SecurityConfig } from "../security/types.js";
2
- import type { PipiclawWebToolsConfig } from "../tools/config.js";
3
3
  import { type WebSearchResultItem } from "./format.js";
4
4
  export interface WebSearchExecutionContext {
5
5
  webConfig: PipiclawWebToolsConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.9.4-beta.1",
3
+ "version": "0.9.4",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,9 +28,11 @@
28
28
  "playbooks:measure": "node --experimental-strip-types scripts/measure-playbooks.mjs",
29
29
  "lint": "biome check .",
30
30
  "typecheck": "tsc --noEmit -p tsconfig.json",
31
+ "arch": "node scripts/check-architecture.mjs",
31
32
  "deadcode": "knip",
32
33
  "test": "vitest --run",
33
- "test:e2e": "vitest --run --config vitest.config.e2e.ts test/e2e/deterministic",
34
+ "pretest:e2e": "npm run build",
35
+ "test:e2e": "vitest --run --config vitest.config.e2e.ts test/e2e/deterministic --fileParallelism --maxWorkers=2",
34
36
  "test:e2e:live": "vitest --run --config vitest.config.e2e.ts test/e2e/live",
35
37
  "test:e2e:external": "vitest --run --config vitest.config.e2e.ts test/e2e/external",
36
38
  "eval:build": "tsc -p tsconfig.evals.json && node scripts/copy-md-assets.mjs dist-evals/src",
@@ -43,15 +45,16 @@
43
45
  "eval:promote": "npm run eval:build && node dist-evals/evals/harness/promote.js",
44
46
  "eval:prune": "node scripts/prune-eval-results.mjs",
45
47
  "test:coverage": "vitest --run --coverage",
46
- "check": "npm run lint && npm run typecheck && npm run deadcode && npm run test",
48
+ "check": "npm run lint && npm run typecheck && npm run arch && npm run deadcode && npm run test",
47
49
  "prepublishOnly": "npm run clean && npm run build && npm run check",
50
+ "pretest:evals": "npm run eval:build",
48
51
  "test:evals": "vitest --run --config vitest.config.evals.ts"
49
52
  },
50
53
  "dependencies": {
51
- "@earendil-works/pi-agent-core": "0.84.3",
52
- "@earendil-works/pi-ai": "0.84.3",
53
- "@earendil-works/pi-coding-agent": "0.84.3",
54
- "@earendil-works/pi-tui": "0.84.3",
54
+ "@earendil-works/pi-agent-core": "1.2.0",
55
+ "@earendil-works/pi-ai": "1.2.0",
56
+ "@earendil-works/pi-coding-agent": "1.2.0",
57
+ "@earendil-works/pi-tui": "1.2.0",
55
58
  "@mozilla/readability": "^0.6.0",
56
59
  "axios": "^1.7.0",
57
60
  "croner": "^9.1.0",
@@ -1,159 +0,0 @@
1
- import type { ChannelEvent } from "../channel/channel-event.js";
2
- import type { Executor } from "../executor.js";
3
- import type { DingTalkBot } from "../runtime/dingtalk.js";
4
- import type { SecurityConfig } from "../security/types.js";
5
- import { type TaskCreateInput } from "../tasks/contract-input.js";
6
- export interface EventAction {
7
- type: "bash";
8
- command: string;
9
- timeout?: number;
10
- }
11
- /**
12
- * What an event delivers when it fires: a chat `text`, or a `task` template that spawns a fresh
13
- * task instance (spec 052, D2). Exactly one is present — `parseScheduledEventContent` enforces it.
14
- */
15
- interface EventPayload {
16
- text?: string;
17
- task?: TaskCreateInput;
18
- }
19
- export interface OneShotEvent extends EventPayload {
20
- type: "one-shot";
21
- channelId: string;
22
- at: string;
23
- preAction?: EventAction;
24
- }
25
- export interface PeriodicEvent extends EventPayload {
26
- type: "periodic";
27
- channelId: string;
28
- schedule: string;
29
- preAction?: EventAction;
30
- }
31
- export type ScheduledEvent = OneShotEvent | PeriodicEvent;
32
- export type EventHistoryAction = "loaded" | "scheduled" | "triggered" | "skipped" | "enqueued" | "queue_full" | "deleted" | "invalid" | "pre_action_started" | "pre_action_passed" | "pre_action_blocked" | "pre_action_failed" | "cancelled";
33
- export type EventHistoryResult = "ok" | "error" | "skipped";
34
- export interface EventHistoryRecord {
35
- ts: string;
36
- eventName: string;
37
- eventPath: string;
38
- eventType: ScheduledEvent["type"] | "unknown";
39
- channelId?: string;
40
- action: EventHistoryAction;
41
- result: EventHistoryResult;
42
- reason?: string;
43
- schedule?: string;
44
- at?: string;
45
- nextRunAt?: string;
46
- textPreview?: string;
47
- preAction?: {
48
- type: "bash";
49
- command: string;
50
- timeoutMs: number;
51
- exitCode?: number | null;
52
- durationMs?: number;
53
- };
54
- queue?: {
55
- accepted: boolean;
56
- };
57
- }
58
- /** One occurrence of a template event asking for a task instance (spec 052, D2). */
59
- export interface SpawnTaskRequest {
60
- /** The event's name (filename without `.json`); becomes the instance's `origin`. */
61
- eventName: string;
62
- channelId: string;
63
- template: TaskCreateInput;
64
- /** The moment this occurrence was due — deterministic per occurrence, so a replay maps to the same instance. */
65
- occurrence: Date;
66
- }
67
- export type SpawnTaskResult =
68
- /** A new instance was created. */
69
- {
70
- outcome: "spawned";
71
- id: string;
72
- }
73
- /** This occurrence's instance already exists: an idempotent replay. */
74
- | {
75
- outcome: "exists";
76
- id: string;
77
- }
78
- /** Another instance of the same event is still running; the user was told. */
79
- | {
80
- outcome: "skipped";
81
- id: string;
82
- };
83
- export interface EventsWatcherOptions {
84
- historyPath?: string;
85
- /**
86
- * Creates the task instance a template event asks for. Injected by the runtime so the events
87
- * subsystem never reads or writes task files (spec 052, INV-8).
88
- */
89
- spawnTask?: (request: SpawnTaskRequest) => Promise<SpawnTaskResult>;
90
- /** Persist synthetic work before it enters the in-memory channel queue. */
91
- dispatch?: (event: ChannelEvent) => boolean | Promise<boolean>;
92
- }
93
- /** The one-line description of what an event delivers, for history records and listings. */
94
- export declare function describeEventPayload(event: Pick<ScheduledEvent, "text" | "task">): string;
95
- export declare function parseScheduledEventContent(content: string, filename: string): ScheduledEvent;
96
- export declare class EventsWatcher {
97
- private eventsDir;
98
- private bot;
99
- private executor;
100
- private commandGuardConfig?;
101
- private options;
102
- private timers;
103
- private crons;
104
- private debounceTimers;
105
- private startTime;
106
- private watcher;
107
- private started;
108
- private knownFiles;
109
- private readonly historyAppender?;
110
- constructor(eventsDir: string, bot: DingTalkBot, executor: Executor, commandGuardConfig?: SecurityConfig["commandGuard"] | undefined, options?: EventsWatcherOptions);
111
- start(): void;
112
- stop(): void;
113
- flush(): Promise<void>;
114
- private ensureHistoryFile;
115
- private appendHistory;
116
- private appendEventHistory;
117
- private debounce;
118
- private scanExisting;
119
- private handleFileChange;
120
- /**
121
- * Watch callbacks are the top of their own stack, so a rejection here reaches nobody — and
122
- * `handleFile` can reject: reloading a due one-shot dispatches it inline, and dispatch
123
- * writes to disk. `scanExisting` already wraps its own calls; this is the same guard for
124
- * the live path. One bad file must not take the watcher, or the process, down with it.
125
- */
126
- private handleFileSafely;
127
- private handleDelete;
128
- private cancelScheduled;
129
- private handleFile;
130
- private parseEvent;
131
- /**
132
- * The admission gate (spec 031, D4). `event_manage` applies the same rules first, but the
133
- * events directory is agent-writable, so a file that arrived any other way is only ever
134
- * stopped here. Returns the rejection reason, or undefined when the event may be scheduled.
135
- */
136
- private admissionFailure;
137
- private wasWrittenAfterStart;
138
- private handleOneShot;
139
- private handlePeriodic;
140
- private execute;
141
- /**
142
- * Deliver a template event: ask the runtime for a fresh task instance (spec 052, D2). The
143
- * occurrence is the one this trigger was *due* for — a one-shot's `at`, a periodic's cron tick —
144
- * so a post-restart replay of the same occurrence lands on the same instance instead of making a
145
- * second one.
146
- */
147
- private spawnTaskInstance;
148
- private runPreAction;
149
- private deleteFile;
150
- private getInvalidMarkerPath;
151
- private markInvalid;
152
- private clearInvalidMarker;
153
- private sleep;
154
- }
155
- /**
156
- * Create and start an events watcher.
157
- */
158
- export declare function createEventsWatcher(workspaceDir: string, bot: DingTalkBot, executor: Executor, commandGuardConfig?: SecurityConfig["commandGuard"], historyPath?: string, dispatch?: EventsWatcherOptions["dispatch"], spawnTask?: EventsWatcherOptions["spawnTask"]): EventsWatcher;
159
- export {};
@@ -1,272 +0,0 @@
1
- import type { FinalDelivery, MediaSender, MediaSendResult, OutboundMedia, ProgressStyle } from "../channel/channel-context.js";
2
- import type { ChannelEvent, InboundImage } from "../channel/channel-event.js";
3
- import type { ChannelObservation } from "../channel/channel-index.js";
4
- import { type RuntimeCommandName } from "../commands/catalog.js";
5
- export type BusyMessageMode = "steer" | "followUp";
6
- export type BusyMessageDefaultConfig = BusyMessageMode | "followup";
7
- export type ResponseMode = "full_progress_then_plain_final" | "rolling_progress_then_plain_final" | "final_card_only";
8
- export declare function progressStyleOf(mode: ResponseMode): ProgressStyle;
9
- export declare function finalDeliveryOf(mode: ResponseMode): FinalDelivery;
10
- export declare function isBusyMessageDefaultConfig(value: unknown): value is BusyMessageDefaultConfig;
11
- export declare function isResponseModeConfig(value: unknown): value is ResponseMode;
12
- export declare function normalizeBusyMessageDefault(value: unknown): BusyMessageMode;
13
- export declare function normalizeResponseMode(value: unknown): ResponseMode;
14
- export interface DingTalkConfig {
15
- clientId: string;
16
- clientSecret: string;
17
- robotCode?: string;
18
- cardTemplateId?: string;
19
- cardTemplateKey?: string;
20
- allowFrom?: string[];
21
- stateDir?: string;
22
- busyMessageDefault?: BusyMessageDefaultConfig;
23
- responseMode?: ResponseMode;
24
- cardAutoLayout?: boolean;
25
- }
26
- /**
27
- * `DingTalkEvent` is kept as the public name (spec 035 D4: `src/index.ts`'s barrel is a
28
- * compatibility promise, so exported names there stay stable). Internally the type now lives in
29
- * `channel-event.ts` as `ChannelEvent`: most producers of this shape are not DingTalk at all
30
- * (job-manager, task-driver, events, subagents/runs all synthesize wakes), so `ChannelEvent` is
31
- * what the rest of the runtime imports.
32
- */
33
- export type DingTalkEvent = ChannelEvent;
34
- export type BusyMessageResult = {
35
- kind: "handled";
36
- } | {
37
- kind: "requeue";
38
- text: string;
39
- };
40
- /**
41
- * What `/stop` actually did. Stopping a task-driven turn also pauses that task, which the user
42
- * has to be told: a disabled task is never picked up again until `/tasks resume <id>`, so silence
43
- * here reads as "the turn was interrupted" while the whole task has in fact gone quiet.
44
- */
45
- export interface StopOutcome {
46
- pausedTaskId?: string;
47
- }
48
- export interface DingTalkHandler {
49
- isRunning(channelId: string): boolean;
50
- /**
51
- * Note that a real person just wrote in this channel. Called once per accepted inbound
52
- * message, before any busy/command routing, and never for synthetic wakes — see the
53
- * maintenance contract in `channel-index.ts`. Must stay synchronous and cheap.
54
- */
55
- noteChannelActivity?(observation: ChannelObservation): void;
56
- /**
57
- * Synchronously reserve an inbound turn before the queued async body yields.
58
- * The transport calls this hook, when provided, immediately before `handleEvent`.
59
- */
60
- reserveEvent?(event: DingTalkEvent): void;
61
- handleEvent(event: DingTalkEvent, bot: DingTalkBot, isEvent?: boolean): Promise<void>;
62
- handleStop(channelId: string, bot: DingTalkBot): Promise<StopOutcome>;
63
- /** `/new` bypasses the old per-channel queue and live SDK session. */
64
- handleNewSession(event: DingTalkEvent, bot: DingTalkBot): Promise<void>;
65
- /**
66
- * Render one of the stateless report commands (events/tasks/status/usage/context/subagents) to
67
- * text. Single dispatch point shared by the busy-turn switch below and bootstrap's idle-turn
68
- * switch — both used to hand-copy the same six-case table.
69
- */
70
- runRuntimeCommand(event: DingTalkEvent, name: RuntimeCommandName, args: string): Promise<string>;
71
- handleBusyMessage(event: DingTalkEvent, bot: DingTalkBot, mode: BusyMessageMode, queueText: string): Promise<BusyMessageResult>;
72
- /**
73
- * Persist one downloaded inbound image under the channel's `inbox/` (spec 049). Owned by
74
- * bootstrap — it holds the workspace root — not the transport, which only knows how to fetch
75
- * bytes over the DingTalk API. `mimeType` is `null` when magic-byte sniffing did not recognize
76
- * a supported image format; the file is still persisted (for the archive/record) but the
77
- * transport excludes it from the model-facing text marker. Returns `null` on a local I/O
78
- * failure, surfaced to the user as "保存失败" — the rest of the message is still delivered.
79
- */
80
- persistInboundImage?(channelId: string, image: {
81
- data: Buffer;
82
- mimeType: string | null;
83
- }): Promise<InboundImage | null>;
84
- }
85
- export declare class DingTalkBot implements MediaSender {
86
- private handler;
87
- private config;
88
- private accessToken;
89
- private tokenExpiry;
90
- private tokenRefreshPromise;
91
- private activeCards;
92
- private cardGenerations;
93
- private cardCreationAttempted;
94
- private cardCreationInFlight;
95
- private convMeta;
96
- private channelLastActiveAt;
97
- private queues;
98
- private inboundIngestQueue;
99
- private pendingInboundIngestCount;
100
- private client;
101
- private lastSocketAvailableTime;
102
- private activeMessageProcessing;
103
- private keepAliveTimer;
104
- private reconnectTimer;
105
- private reconnectDelayTimer;
106
- private reconnectDelayResolve;
107
- private channelCacheSweepTimer;
108
- private isReconnecting;
109
- private isStopped;
110
- private reconnectAttempts;
111
- private hasReportedReady;
112
- private processedIds;
113
- private processedIdsOrder;
114
- constructor(handler: DingTalkHandler, config: DingTalkConfig);
115
- get busyMessageDefault(): BusyMessageMode;
116
- get responseMode(): ResponseMode;
117
- get progressStyle(): ProgressStyle;
118
- get finalDelivery(): FinalDelivery;
119
- /**
120
- * Mark an ID as processed. Returns true if this is a new ID, false if already seen.
121
- * Maintains a FIFO buffer of at most 200 entries.
122
- */
123
- private markProcessed;
124
- private getSocket;
125
- private isSocketLike;
126
- private setTrackedTimeout;
127
- private setTrackedInterval;
128
- private clearKeepAliveTimer;
129
- private clearReconnectTimer;
130
- private clearReconnectDelay;
131
- private clearAllTimers;
132
- private waitForDelay;
133
- private waitForSocketState;
134
- private markClientDisconnected;
135
- private clearClientSocketReference;
136
- private cleanupSocket;
137
- private connectWithTimeout;
138
- private scheduleReconnect;
139
- start(): Promise<void>;
140
- private handleRawMessage;
141
- private doReconnect;
142
- stop(): Promise<void>;
143
- /**
144
- * Enqueue an event for processing.
145
- * Returns true if enqueued, false if queue is full (max 5).
146
- */
147
- enqueueEvent(event: DingTalkEvent): boolean;
148
- private enqueueStreamMessage;
149
- /** Capture the current turn's identity; close, /stop and /new invalidate it. */
150
- getCardGeneration(channelId: string): symbol;
151
- isCardGenerationCurrent(channelId: string, generation: symbol): boolean;
152
- /** Get or create an AI card without joining an earlier turn's in-flight creation. */
153
- ensureCard(channelId: string, generation?: symbol): Promise<void>;
154
- /**
155
- * Replace the active card content with a full snapshot.
156
- */
157
- replaceCard(channelId: string, content: string, finalize?: boolean, failed?: boolean, generation?: symbol): Promise<boolean>;
158
- /**
159
- * Append a delta to the active card transcript.
160
- */
161
- appendToCard(channelId: string, content: string, finalize?: boolean, failed?: boolean, generation?: symbol): Promise<boolean>;
162
- /**
163
- * Shared body of `replaceCard`/`appendToCard`: whether to open a fresh card differs between the
164
- * two (a full-snapshot replace opens one for a finalize/failed close too; a delta append only
165
- * opens one for genuinely new content), so that predicate stays keyed on `append` rather than
166
- * being collapsed away — everything after it (stream, then drop the card on finalize/failed/a
167
- * failed stream) is identical either way.
168
- */
169
- private writeCard;
170
- /**
171
- * Finalize and remove the active card for a channel.
172
- */
173
- finalizeCard(channelId: string, content: string, generation?: symbol): Promise<boolean>;
174
- /** Finish progress only: never create a card or send a fallback chat message. */
175
- finalizeExistingCard(channelId: string, content: string, generation?: symbol): Promise<boolean>;
176
- /** Invalidate this turn's local state. This is not a remote message deletion. */
177
- discardCard(channelId: string, generation?: symbol | undefined): void;
178
- /**
179
- * Send a normal message natively mapping DM and Group to correct endpoints (fallback when no card).
180
- *
181
- * Only the message shape is decided here; the DM-vs-group routing and the POST itself belong to
182
- * `sendRobotMessage`, which every other outbound message type already goes through.
183
- *
184
- * `opts` lets a caller that already knows what it produced (a command reply) state the format
185
- * and a real title instead of the regex guess below, which exists only for callers — free-form
186
- * notices, `replaceWithFinal` — that do not know their own content ahead of time (review
187
- * 2026-08-24 §1.3c).
188
- */
189
- sendPlain(channelId: string, text: string, opts?: {
190
- title?: string;
191
- markdown?: boolean;
192
- }): Promise<boolean>;
193
- /**
194
- * Deliver a local file to a channel as a native attachment. Uploads the bytes
195
- * to get a `media_id`, then sends a `sampleImageMsg` (inline image) or
196
- * `sampleFile` (downloadable file) robot message. `channelId` is supplied by
197
- * the runtime (the tool is bound to its channel at build time), never by the
198
- * model, so an agent cannot target a channel other than its own.
199
- */
200
- sendMedia(channelId: string, media: OutboundMedia): Promise<MediaSendResult>;
201
- /**
202
- * Upload raw bytes to DingTalk and return the reusable `media_id`, or null on
203
- * failure. The upload endpoint lives on the legacy oapi host and answers 200
204
- * with a non-zero `errcode` on failure, so the body is inspected explicitly.
205
- */
206
- private uploadMedia;
207
- /**
208
- * Two-step DingTalk inbound file download (spec 049): `messageFiles/download` exchanges the
209
- * message's `downloadCode` for a short-lived `downloadUrl`, then that URL is fetched for the
210
- * actual bytes. Both hops reuse `getAccessToken()` — the same app access token works across
211
- * DingTalk's hosts, as the comment on `DINGTALK_OAPI` above explains for the outbound side.
212
- *
213
- * This runs from `onStreamMessage`'s per-channel ingestion queue, never from inside a turn: a
214
- * busy channel can queue a message for minutes (`USER_MESSAGE_QUEUE_LIMIT`), and by the time a
215
- * queued turn actually ran, a `downloadCode`/`downloadUrl` fetched only then could easily have
216
- * already expired.
217
- *
218
- * `protected` so the deterministic e2e harness can override it and run this path with zero
219
- * network, the same pattern `HarnessDingTalkBot` already uses for outbound calls.
220
- */
221
- protected downloadMessageFile(downloadCode: string): Promise<{
222
- data: Buffer;
223
- } | null>;
224
- /**
225
- * Resolve one parsed message's image credentials into persisted `InboundImage`s and a text
226
- * with every `[图片N]` marker either left as-is (success) or replaced with a reason (spec 049
227
- * D8): a download failure, an unrecognized format, an oversized file, or a message that
228
- * simply carried more images than `MAX_INBOUND_IMAGES_PER_MESSAGE` allows. A failure on one
229
- * image never drops the rest of the message — only that one marker changes.
230
- *
231
- * No-op (no network call at all) when the message carries no image credentials, so a plain
232
- * text message never pays for this method's existence.
233
- */
234
- private resolveInboundAttachments;
235
- /**
236
- * POST a robot message with an arbitrary msgKey/msgParam, routing DM vs group
237
- * to the correct endpoint. The single outbound path for every non-card message:
238
- * plain text/markdown, images, and files.
239
- */
240
- private sendRobotMessage;
241
- private createCard;
242
- private createCardUncached;
243
- private streamCard;
244
- private streamCardRequest;
245
- private getAccessToken;
246
- private refreshAccessToken;
247
- private onStreamMessage;
248
- /**
249
- * Command / busy / `/new` routing for one inbound event, ending in `enqueueStreamMessage`
250
- * for a normal message. Split out of `onStreamMessage` so the deterministic e2e harness
251
- * (spec 048) can exercise the real transport queue and busy semantics without a socket.
252
- */
253
- routeInboundEvent(event: DingTalkEvent): Promise<void>;
254
- /**
255
- * Drop queued-but-not-started messages for a channel (e.g. on /stop) so they
256
- * do not run after the user halts the current task. Returns dropped count.
257
- */
258
- clearPendingMessages(channelId: string): number;
259
- /**
260
- * Detach all queued work from the previous session generation. The in-flight callback may
261
- * still unwind on its old queue object, while subsequent messages get a fresh queue.
262
- */
263
- resetChannelQueue(channelId: string): number;
264
- /** Test seam (spec 048): true when no channel queue has pending or in-flight work. */
265
- allChannelQueuesIdle(): boolean;
266
- private getQueue;
267
- private getConversationMeta;
268
- private setConversationMeta;
269
- private getConversationMetaPath;
270
- private touchChannel;
271
- private cleanupIdleChannelCaches;
272
- }