@humwick/runner 0.0.0-stage → 0.130.1

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 (293) hide show
  1. package/LICENSE +167 -0
  2. package/agent-bin/agent-relay-browser +10 -0
  3. package/agent-bin/humwick +10 -0
  4. package/hooks/fff-search-redirect/fff-search-redirect.cjs +161 -0
  5. package/hooks/fff-search-redirect/hooks.json +13 -0
  6. package/hooks/rg-r-guard/hooks.json +18 -0
  7. package/hooks/rg-r-guard/rg-r-guard.cjs +144 -0
  8. package/hooks/web-tools-redirect/hooks.json +13 -0
  9. package/hooks/web-tools-redirect/web-tools-redirect.cjs +84 -0
  10. package/node_modules/@humwick/offload/LICENSE +167 -0
  11. package/node_modules/@humwick/offload/README.md +57 -0
  12. package/node_modules/@humwick/offload/dist/async-runner.d.ts +18 -0
  13. package/node_modules/@humwick/offload/dist/async-runner.d.ts.map +1 -0
  14. package/node_modules/@humwick/offload/dist/async-runner.js +158 -0
  15. package/node_modules/@humwick/offload/dist/async-runner.js.map +1 -0
  16. package/node_modules/@humwick/offload/dist/envelope.d.ts +25 -0
  17. package/node_modules/@humwick/offload/dist/envelope.d.ts.map +1 -0
  18. package/node_modules/@humwick/offload/dist/envelope.js +80 -0
  19. package/node_modules/@humwick/offload/dist/envelope.js.map +1 -0
  20. package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts +10 -0
  21. package/node_modules/@humwick/offload/dist/fixtures/worker-task.d.ts.map +1 -0
  22. package/node_modules/@humwick/offload/dist/fixtures/worker-task.js +59 -0
  23. package/node_modules/@humwick/offload/dist/fixtures/worker-task.js.map +1 -0
  24. package/node_modules/@humwick/offload/dist/index.d.ts +5 -0
  25. package/node_modules/@humwick/offload/dist/index.d.ts.map +1 -0
  26. package/node_modules/@humwick/offload/dist/index.js +5 -0
  27. package/node_modules/@humwick/offload/dist/index.js.map +1 -0
  28. package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts +62 -0
  29. package/node_modules/@humwick/offload/dist/subprocess-runner.d.ts.map +1 -0
  30. package/node_modules/@humwick/offload/dist/subprocess-runner.js +295 -0
  31. package/node_modules/@humwick/offload/dist/subprocess-runner.js.map +1 -0
  32. package/node_modules/@humwick/offload/dist/types.d.ts +111 -0
  33. package/node_modules/@humwick/offload/dist/types.d.ts.map +1 -0
  34. package/node_modules/@humwick/offload/dist/types.js +176 -0
  35. package/node_modules/@humwick/offload/dist/types.js.map +1 -0
  36. package/node_modules/@humwick/offload/dist/worker-pool.d.ts +23 -0
  37. package/node_modules/@humwick/offload/dist/worker-pool.d.ts.map +1 -0
  38. package/node_modules/@humwick/offload/dist/worker-pool.js +435 -0
  39. package/node_modules/@humwick/offload/dist/worker-pool.js.map +1 -0
  40. package/node_modules/@humwick/offload/dist/worker-runtime.d.ts +2 -0
  41. package/node_modules/@humwick/offload/dist/worker-runtime.d.ts.map +1 -0
  42. package/node_modules/@humwick/offload/dist/worker-runtime.js +27 -0
  43. package/node_modules/@humwick/offload/dist/worker-runtime.js.map +1 -0
  44. package/node_modules/@humwick/offload/dist/worker.d.ts +5 -0
  45. package/node_modules/@humwick/offload/dist/worker.d.ts.map +1 -0
  46. package/node_modules/@humwick/offload/dist/worker.js +1 -0
  47. package/node_modules/@humwick/offload/dist/worker.js.map +1 -0
  48. package/node_modules/@humwick/offload/package.json +42 -0
  49. package/node_modules/@humwick/offload/src/async-runner.ts +170 -0
  50. package/node_modules/@humwick/offload/src/envelope.ts +92 -0
  51. package/node_modules/@humwick/offload/src/fixtures/worker-task.ts +49 -0
  52. package/node_modules/@humwick/offload/src/index.ts +4 -0
  53. package/node_modules/@humwick/offload/src/subprocess-runner.ts +334 -0
  54. package/node_modules/@humwick/offload/src/types.ts +235 -0
  55. package/node_modules/@humwick/offload/src/worker-pool.ts +463 -0
  56. package/node_modules/@humwick/offload/src/worker-runtime.ts +32 -0
  57. package/node_modules/@humwick/offload/src/worker.ts +5 -0
  58. package/package.json +47 -4
  59. package/plugins/browser/skills/playwright-cli/SKILL.md +53 -0
  60. package/plugins/claude/.claude-plugin/plugin.json +8 -0
  61. package/plugins/claude/claude-statusline-probe.cjs +144 -0
  62. package/plugins/claude/hooks/gate-run-guard.provisioned.mjs +914 -0
  63. package/plugins/claude/hooks/gate-run-guard.sh +9 -0
  64. package/plugins/claude/hooks/gate-run-guard.ts +237 -0
  65. package/plugins/claude/hooks/hooks.json +158 -0
  66. package/plugins/claude/hooks/kill-guard.provisioned.mjs +7027 -0
  67. package/plugins/claude/hooks/kill-guard.sh +341 -0
  68. package/plugins/claude/hooks/kill-guard.ts +337 -0
  69. package/plugins/claude/hooks/permission-request.sh +22 -0
  70. package/plugins/claude/hooks/post-compact.sh +10 -0
  71. package/plugins/claude/hooks/post-tool-use.sh +8 -0
  72. package/plugins/claude/hooks/pre-compact.sh +12 -0
  73. package/plugins/claude/hooks/read-only-bash-guard.sh +587 -0
  74. package/plugins/claude/hooks/relay-status.sh +373 -0
  75. package/plugins/claude/hooks/session-end.sh +26 -0
  76. package/plugins/claude/hooks/session-start.sh +31 -0
  77. package/plugins/claude/hooks/shell-trust.ts +28 -0
  78. package/plugins/claude/hooks/stop-failure.sh +47 -0
  79. package/plugins/claude/hooks/stop.sh +48 -0
  80. package/plugins/claude/hooks/subagent-guard.cjs +26 -0
  81. package/plugins/claude/hooks/subagent-skill-policy.cjs +160 -0
  82. package/plugins/claude/hooks/subagent-start.sh +13 -0
  83. package/plugins/claude/hooks/subagent-stop.sh +19 -0
  84. package/plugins/claude/hooks/user-prompt-submit.sh +18 -0
  85. package/plugins/claude/hooks/wait-loop-guard.ts +120 -0
  86. package/plugins/claude/monitors/monitors.json +7 -0
  87. package/plugins/claude/monitors/relay-monitor.provisioned.mjs +786 -0
  88. package/plugins/claude/monitors/relay-monitor.ts +58 -0
  89. package/plugins/claude/skills/disconnect/SKILL.md +16 -0
  90. package/plugins/claude/skills/label/SKILL.md +23 -0
  91. package/plugins/claude/skills/message/SKILL.md +40 -0
  92. package/plugins/claude/skills/pair/SKILL.md +30 -0
  93. package/plugins/claude/skills/react/SKILL.md +18 -0
  94. package/plugins/claude/skills/read-message/SKILL.md +24 -0
  95. package/plugins/claude/skills/reply/SKILL.md +44 -0
  96. package/plugins/claude/skills/send-claimable/SKILL.md +39 -0
  97. package/plugins/claude/skills/slice-first/SKILL.md +32 -0
  98. package/plugins/claude/skills/slice-first/references/plan-recipe.md +46 -0
  99. package/plugins/claude/skills/status/SKILL.md +16 -0
  100. package/plugins/claude/skills/tags/SKILL.md +25 -0
  101. package/plugins/claude/skills/task/SKILL.md +28 -0
  102. package/plugins/claude-output-style/.claude-plugin/plugin.json +5 -0
  103. package/plugins/claude-output-style/output-styles/agent-relay.md +5 -0
  104. package/plugins/codex/skills/disconnect/SKILL.md +15 -0
  105. package/plugins/codex/skills/guide/SKILL.md +15 -0
  106. package/plugins/codex/skills/label/SKILL.md +22 -0
  107. package/plugins/codex/skills/message/SKILL.md +40 -0
  108. package/plugins/codex/skills/pair/SKILL.md +29 -0
  109. package/plugins/codex/skills/react/SKILL.md +17 -0
  110. package/plugins/codex/skills/read-message/SKILL.md +23 -0
  111. package/plugins/codex/skills/reply/SKILL.md +44 -0
  112. package/plugins/codex/skills/send-claimable/SKILL.md +39 -0
  113. package/plugins/codex/skills/slice-first/SKILL.md +32 -0
  114. package/plugins/codex/skills/slice-first/references/plan-recipe.md +46 -0
  115. package/plugins/codex/skills/status/SKILL.md +15 -0
  116. package/plugins/codex/skills/tags/SKILL.md +24 -0
  117. package/plugins/codex/skills/task/SKILL.md +28 -0
  118. package/src/adapter.ts +1061 -0
  119. package/src/adapters/__fixtures__/codex-app-server.ts +47 -0
  120. package/src/adapters/claude-api.ts +243 -0
  121. package/src/adapters/claude-context-command.ts +16 -0
  122. package/src/adapters/claude-credentials.ts +22 -0
  123. package/src/adapters/claude-delivery-lanes.ts +28 -0
  124. package/src/adapters/claude-delivery.ts +166 -0
  125. package/src/adapters/claude-effort.ts +94 -0
  126. package/src/adapters/claude-exit.ts +290 -0
  127. package/src/adapters/claude-headless-mirror.ts +88 -0
  128. package/src/adapters/claude-headless-refusal.ts +51 -0
  129. package/src/adapters/claude-headless.ts +617 -0
  130. package/src/adapters/claude-monitor-delivery-plan.ts +317 -0
  131. package/src/adapters/claude-permission.ts +243 -0
  132. package/src/adapters/claude-prompt-gates.ts +269 -0
  133. package/src/adapters/claude-prompt-hook.ts +145 -0
  134. package/src/adapters/claude-session-capture.ts +293 -0
  135. package/src/adapters/claude-session-probe.ts +414 -0
  136. package/src/adapters/claude-shutdown.ts +190 -0
  137. package/src/adapters/claude-status-detectors.ts +426 -0
  138. package/src/adapters/claude-subagents.ts +93 -0
  139. package/src/adapters/claude-submit-confirmation.ts +287 -0
  140. package/src/adapters/claude-tmux.ts +548 -0
  141. package/src/adapters/claude-token-usage-capture.ts +253 -0
  142. package/src/adapters/claude-tool-policy.ts +165 -0
  143. package/src/adapters/claude-transcript-tail.ts +193 -0
  144. package/src/adapters/claude-transcript.ts +812 -0
  145. package/src/adapters/claude.ts +1097 -0
  146. package/src/adapters/codex-agent-message-capture.ts +189 -0
  147. package/src/adapters/codex-app-server.ts +70 -0
  148. package/src/adapters/codex-client.ts +362 -0
  149. package/src/adapters/codex-effective-config.ts +87 -0
  150. package/src/adapters/codex-launch-config.ts +153 -0
  151. package/src/adapters/codex-rollout-context.ts +272 -0
  152. package/src/adapters/codex-skill-discovery.ts +18 -0
  153. package/src/adapters/codex-token-usage-capture.ts +163 -0
  154. package/src/adapters/codex-tool-output.ts +53 -0
  155. package/src/adapters/codex-turn-outcome.ts +27 -0
  156. package/src/adapters/codex-version.ts +64 -0
  157. package/src/adapters/codex.ts +1442 -0
  158. package/src/adapters/incremental-file.ts +110 -0
  159. package/src/adapters/opencode-api.ts +71 -0
  160. package/src/adapters/opencode-context.ts +277 -0
  161. package/src/adapters/opencode-model-registry.ts +126 -0
  162. package/src/adapters/opencode-provider.ts +169 -0
  163. package/src/adapters/opencode-server-retry.ts +50 -0
  164. package/src/adapters/opencode-soft-steer.ts +302 -0
  165. package/src/adapters/opencode-spawn.ts +145 -0
  166. package/src/adapters/opencode-subscribe.ts +62 -0
  167. package/src/adapters/opencode-token-usage-capture.ts +187 -0
  168. package/src/adapters/opencode-tool-events.ts +302 -0
  169. package/src/adapters/opencode-tools-config.ts +17 -0
  170. package/src/adapters/opencode.ts +2264 -0
  171. package/src/adapters/project-shell.ts +80 -0
  172. package/src/adapters/provider-launch-config.ts +21 -0
  173. package/src/adapters/provider-quota-harvest.ts +127 -0
  174. package/src/adapters/service-access.ts +153 -0
  175. package/src/adapters/tmux-offload.ts +207 -0
  176. package/src/adapters/tool-summary.ts +214 -0
  177. package/src/agent-redact.ts +75 -0
  178. package/src/agent-runner/commands/dispatch.ts +185 -0
  179. package/src/agent-runner/commands/lifecycle.ts +84 -0
  180. package/src/agent-runner/commands/prompt.ts +284 -0
  181. package/src/agent-runner/credentials.ts +208 -0
  182. package/src/agent-runner/http-liveness.ts +85 -0
  183. package/src/agent-runner/lifecycle-milestones.ts +207 -0
  184. package/src/agent-runner/lifecycle-phase.ts +80 -0
  185. package/src/agent-runner/registration.ts +163 -0
  186. package/src/agent-runner/runner-context.ts +158 -0
  187. package/src/agent-runner/session-mirror.ts +278 -0
  188. package/src/agent-runner/task-claims.ts +116 -0
  189. package/src/agent-runner/token-usage-coverage.ts +54 -0
  190. package/src/agent-runner/turn-report.ts +269 -0
  191. package/src/api-budget-accounting.ts +91 -0
  192. package/src/area-memory.ts +255 -0
  193. package/src/artifact-path-materialize.ts +52 -0
  194. package/src/async-guard.ts +35 -0
  195. package/src/attachment-cache-sweep.ts +31 -0
  196. package/src/attachment-cache.ts +195 -0
  197. package/src/background-script-reconcile.ts +106 -0
  198. package/src/bounded-log.ts +59 -0
  199. package/src/bounded-spawn-sync.ts +18 -0
  200. package/src/busy-reconciler.ts +282 -0
  201. package/src/claim-tracker.ts +140 -0
  202. package/src/claude-settings.ts +167 -0
  203. package/src/claude-workspace-trust.ts +289 -0
  204. package/src/config.ts +547 -0
  205. package/src/context-boundary.ts +101 -0
  206. package/src/context-command.ts +151 -0
  207. package/src/context-probe-state.ts +6 -0
  208. package/src/continuation-archive.ts +179 -0
  209. package/src/control-server.ts +730 -0
  210. package/src/delivery-policy.ts +9 -0
  211. package/src/delivery-result.ts +24 -0
  212. package/src/effort-command.ts +125 -0
  213. package/src/empty-turn.ts +816 -0
  214. package/src/free-port.ts +25 -0
  215. package/src/fs-offload.ts +26 -0
  216. package/src/gate-run-config.ts +35 -0
  217. package/src/gate-run-lease-probe.ts +38 -0
  218. package/src/host-asset-plan.ts +450 -0
  219. package/src/host-claude-config-worker.ts +34 -0
  220. package/src/host-sources.ts +40 -0
  221. package/src/inbox-carrier.ts +7 -0
  222. package/src/index.ts +386 -0
  223. package/src/launch-assembly.ts +955 -0
  224. package/src/liveness.ts +105 -0
  225. package/src/logger.ts +108 -0
  226. package/src/mcp-outbox.ts +204 -0
  227. package/src/mcp-preflight.ts +86 -0
  228. package/src/mcp-source-selection.ts +54 -0
  229. package/src/mcp-tool-deferral.ts +35 -0
  230. package/src/mcp-vault-env.ts +25 -0
  231. package/src/message-body-config/config.ts +16 -0
  232. package/src/message-body-config.ts +1 -0
  233. package/src/mid-turn-delivery.ts +43 -0
  234. package/src/native-memory-lever.ts +329 -0
  235. package/src/native-self-resume.ts +244 -0
  236. package/src/outbox.ts +453 -0
  237. package/src/park-post.ts +17 -0
  238. package/src/pending-permission-store.ts +148 -0
  239. package/src/process-meta.ts +9 -0
  240. package/src/profile-home.ts +419 -0
  241. package/src/profile-projection.ts +411 -0
  242. package/src/project-hooks.ts +65 -0
  243. package/src/project-instructions.ts +119 -0
  244. package/src/provider-double.ts +59 -0
  245. package/src/provider-hold.ts +228 -0
  246. package/src/provider-home-marker.ts +3 -0
  247. package/src/provider-home-tombstone.ts +4 -0
  248. package/src/provider-input-queue.ts +134 -0
  249. package/src/provider-integration.ts +93 -0
  250. package/src/provider-processes.ts +17 -0
  251. package/src/provider-submit-failure.ts +15 -0
  252. package/src/providers.ts +35 -0
  253. package/src/provisioning.ts +703 -0
  254. package/src/question-decision.ts +18 -0
  255. package/src/quota.ts +22 -0
  256. package/src/rate-limit.ts +351 -0
  257. package/src/refused-prompt-store.ts +36 -0
  258. package/src/relay-injection-events.ts +161 -0
  259. package/src/relay-instructions.ts +107 -0
  260. package/src/relay-mcp-proxy.long-turn-e2e.ts +183 -0
  261. package/src/relay-mcp-proxy.ts +704 -0
  262. package/src/relay-mcp.ts +583 -0
  263. package/src/reply-obligation-cache.ts +211 -0
  264. package/src/response-capture-report.ts +111 -0
  265. package/src/response-routing.ts +6 -0
  266. package/src/runner-core.ts +2955 -0
  267. package/src/runner-exit.ts +12 -0
  268. package/src/runner-helpers.ts +582 -0
  269. package/src/runner-insights.ts +105 -0
  270. package/src/runner-mcp-proxy.ts +46 -0
  271. package/src/runner-spawn-config.ts +68 -0
  272. package/src/runner-stale-scratch-sweep.ts +21 -0
  273. package/src/runner.ts +9 -0
  274. package/src/runtime-token-file.ts +45 -0
  275. package/src/runtime-token-remint.ts +56 -0
  276. package/src/service-access.ts +88 -0
  277. package/src/session-destroy.ts +27 -0
  278. package/src/session-insights.ts +118 -0
  279. package/src/session-scratch.ts +296 -0
  280. package/src/spawn-input.ts +147 -0
  281. package/src/startup-config-fetch.ts +48 -0
  282. package/src/subreaper.ts +113 -0
  283. package/src/template-resolver.ts +29 -0
  284. package/src/test-run-dedup.ts +435 -0
  285. package/src/transcript-context.ts +99 -0
  286. package/src/transport-errors.ts +48 -0
  287. package/src/turn-opener.ts +55 -0
  288. package/src/turn-reconcile-event.ts +88 -0
  289. package/src/vault-proxy-hop.ts +99 -0
  290. package/src/version.ts +44 -0
  291. package/src/web-tool-call-proxy.ts +128 -0
  292. package/src/web-tools.ts +59 -0
  293. package/README.md +0 -3
@@ -0,0 +1,62 @@
1
+ import { type OffloadDefaults, type OffloadEnvelope } from "./types.js";
2
+ export interface SubprocessSpec {
3
+ command: string[];
4
+ cwd?: string;
5
+ env?: Record<string, string | undefined>;
6
+ /**
7
+ * Exit codes that are a normal ANSWER rather than a failure. Defaults to `[0]`; pass
8
+ * `"any"` when every code is data (a land gate whose failing codes are not enumerable).
9
+ *
10
+ * Probe-shaped callers use a non-zero exit as data — `tmux has-session` exits 1 when the
11
+ * session is absent, `git rev-parse` exits 128 outside a repo, `which` exits 1. Without
12
+ * this they reject AND take an escalation strike for a healthy result, which inverts the
13
+ * signal: the sink pages on a healthy fleet, then latches (it only re-arms on a success,
14
+ * which never comes in that steady state) so the real outage is silent.
15
+ *
16
+ * `"any"` includes SIGNAL DEATHS — a child killed by SIGKILL (137) or SIGSEGV (139)
17
+ * returns as a success and RE-ARMS the strike counter. That is intended for a land gate,
18
+ * where an OOM-killed gate is simply a failed gate, but it means an infrastructure death
19
+ * reads as a healthy answer and will never escalate. Prefer an explicit code list unless
20
+ * the failing codes genuinely cannot be enumerated. Timeout and abort still throw.
21
+ */
22
+ okExitCodes?: readonly number[] | "any";
23
+ }
24
+ export interface SubprocessResult {
25
+ exitCode: number;
26
+ stdout: string;
27
+ stderr: string;
28
+ /** True when either stream hit `maxOutputBytes` and the captured text was cut short. */
29
+ truncated: boolean;
30
+ }
31
+ export interface SubprocessRunnerOptions extends OffloadDefaults {
32
+ concurrency?: number;
33
+ /**
34
+ * How long a child may keep running after SIGTERM before it is SIGKILLed. This is the
35
+ * slack on the deadline: a run cannot outlive `timeoutMs + killGraceMs` (plus a short
36
+ * reap window) even if it traps or ignores SIGTERM. Defaults to 2000ms.
37
+ */
38
+ killGraceMs?: number;
39
+ /** Captured bytes per stream before output is truncated. Defaults to 8 MiB. */
40
+ maxOutputBytes?: number;
41
+ }
42
+ export interface SubprocessRunner {
43
+ run(taskName: string, process: SubprocessSpec, env?: OffloadEnvelope): Promise<SubprocessResult>;
44
+ readonly stats: {
45
+ active: number;
46
+ queued: number;
47
+ };
48
+ /** A subprocess owns the heavy work, so maintenance callers may mark their await window off-thread. */
49
+ readonly offThread: true;
50
+ /** Resolves when everything accepted so far has finished. Does not cancel anything. */
51
+ drain(): Promise<void>;
52
+ /** SIGKILLs and awaits every live child, settles every outstanding caller, and refuses new work. */
53
+ destroy(): Promise<void>;
54
+ }
55
+ /**
56
+ * Bounded wrapper around the repo's standard `Bun.spawn(... { stdout: "pipe", stderr: "pipe" })`
57
+ * pattern. On POSIX, each run gets its own process group so timeout/abort also kills
58
+ * descendants (for example shell, git, or install subprocess trees); Windows falls back
59
+ * to Bun's direct-child kill because POSIX process groups do not exist there.
60
+ */
61
+ export declare function createSubprocessRunner(options?: SubprocessRunnerOptions): SubprocessRunner;
62
+ //# sourceMappingURL=subprocess-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocess-runner.d.ts","sourceRoot":"","sources":["../src/subprocess-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAEtI,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjG,QAAQ,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,uGAAuG;IACvG,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,uFAAuF;IACvF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,oGAAoG;IACpG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAmFD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,gBAAgB,CA4L9F"}
@@ -0,0 +1,295 @@
1
+ import PQueue from "p-queue";
2
+ import { beginRun, finishLog, recordResult, startLog } from "./envelope.js";
3
+ import { OffloadError, StrikeCounter, normalizeError, validateTimeout } from "./types.js";
4
+ const DEFAULT_KILL_GRACE_MS = 2_000;
5
+ const DEFAULT_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
6
+ /** How long to wait for a SIGKILLed child to be reaped before giving its slot back anyway. */
7
+ const REAP_GRACE_MS = 1_000;
8
+ /**
9
+ * `detached` children are reparented rather than reaped when the host dies (#1809 P1-5), so
10
+ * every live group is killed from a single process-level exit hook. One module-scoped hook
11
+ * keeps runner instances from piling up `exit` listeners.
12
+ */
13
+ const liveChildren = new Set();
14
+ let exitHookInstalled = false;
15
+ function killGroup(child, signal) {
16
+ try {
17
+ if (process.platform !== "win32")
18
+ process.kill(-child.pid, signal);
19
+ else
20
+ child.kill();
21
+ }
22
+ catch {
23
+ try {
24
+ child.kill(signal);
25
+ }
26
+ catch { /* the child is already gone */ }
27
+ }
28
+ }
29
+ function trackChild(child) {
30
+ liveChildren.add(child);
31
+ if (exitHookInstalled)
32
+ return;
33
+ exitHookInstalled = true;
34
+ process.on("exit", () => {
35
+ for (const live of liveChildren)
36
+ killGroup(live, "SIGKILL");
37
+ });
38
+ }
39
+ /** Reads a stream up to `limit` bytes, then keeps draining so the child never blocks on a full pipe. */
40
+ async function readCapped(stream, limit) {
41
+ if (!stream)
42
+ return { text: "", truncated: false };
43
+ const reader = stream.getReader();
44
+ const chunks = [];
45
+ let size = 0;
46
+ let truncated = false;
47
+ try {
48
+ for (;;) {
49
+ const { done, value } = await reader.read();
50
+ if (done)
51
+ break;
52
+ if (!value)
53
+ continue;
54
+ const remaining = limit - size;
55
+ if (remaining <= 0) {
56
+ truncated = true;
57
+ continue;
58
+ }
59
+ if (value.byteLength > remaining) {
60
+ chunks.push(value.subarray(0, remaining));
61
+ size = limit;
62
+ truncated = true;
63
+ continue;
64
+ }
65
+ chunks.push(value);
66
+ size += value.byteLength;
67
+ }
68
+ }
69
+ finally {
70
+ reader.releaseLock();
71
+ }
72
+ const buffer = new Uint8Array(size);
73
+ let offset = 0;
74
+ for (const chunk of chunks) {
75
+ buffer.set(chunk, offset);
76
+ offset += chunk.byteLength;
77
+ }
78
+ return { text: new TextDecoder().decode(buffer), truncated };
79
+ }
80
+ /**
81
+ * Bounded wrapper around the repo's standard `Bun.spawn(... { stdout: "pipe", stderr: "pipe" })`
82
+ * pattern. On POSIX, each run gets its own process group so timeout/abort also kills
83
+ * descendants (for example shell, git, or install subprocess trees); Windows falls back
84
+ * to Bun's direct-child kill because POSIX process groups do not exist there.
85
+ */
86
+ export function createSubprocessRunner(options = {}) {
87
+ const queue = new PQueue({ concurrency: options.concurrency ?? 1 });
88
+ const counter = new StrikeCounter(options.escalationThreshold, options.escalationWindowAttempts);
89
+ const killGraceMs = options.killGraceMs ?? DEFAULT_KILL_GRACE_MS;
90
+ const maxOutputBytes = options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
91
+ if (!Number.isFinite(killGraceMs) || killGraceMs < 0)
92
+ throw new RangeError("killGraceMs must be a non-negative finite number");
93
+ if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1)
94
+ throw new RangeError("maxOutputBytes must be a positive integer");
95
+ const live = new Set();
96
+ const children = new Set();
97
+ let destroyed = false;
98
+ const abortedError = (taskName, cause) => new OffloadError({ kind: "aborted", taskName, message: `${taskName} was aborted`, cause });
99
+ const destroyedError = (taskName) => new OffloadError({ kind: "aborted", taskName, message: `${taskName} was cancelled: subprocess runner destroyed` });
100
+ return {
101
+ offThread: true,
102
+ get stats() { return { active: queue.pending, queued: queue.size }; },
103
+ async run(taskName, spec, env) {
104
+ const labels = env?.labels ?? {};
105
+ const logger = env?.logger ?? options.logger;
106
+ const sink = env?.onEscalate ?? options.onEscalate;
107
+ const reportRejection = async (error) => {
108
+ // Rejecting before the run reaches startLog is still a terminal outcome; without this
109
+ // the structured stream shows nothing at all for it.
110
+ finishLog(logger, "subprocess", taskName, labels, performance.now(), error);
111
+ await recordResult({ counter, taskName, backend: "subprocess", labels, error, sink, logger });
112
+ throw error;
113
+ };
114
+ if (!spec.command.length)
115
+ return reportRejection(new OffloadError({ kind: "rejected", taskName, message: "Subprocess command must not be empty" }));
116
+ if (destroyed)
117
+ return reportRejection(destroyedError(taskName));
118
+ if (env?.signal?.aborted)
119
+ return reportRejection(abortedError(taskName, env.signal.reason));
120
+ try {
121
+ validateTimeout(env?.timeoutMs ?? options.defaultTimeoutMs);
122
+ }
123
+ catch (error) {
124
+ return reportRejection(normalizeError(taskName, error, "rejected"));
125
+ }
126
+ let publish;
127
+ let published = false;
128
+ const outcome = new Promise((resolve) => {
129
+ publish = (value) => { if (!published) {
130
+ published = true;
131
+ resolve(value);
132
+ } };
133
+ });
134
+ let started = false;
135
+ let cancelled = false;
136
+ const entry = {
137
+ taskName,
138
+ teardown: new AbortController(),
139
+ settled: outcome.then(() => undefined),
140
+ cancelIfQueued: (error) => {
141
+ if (started || cancelled)
142
+ return;
143
+ cancelled = true;
144
+ // The single funnel for both abort-while-queued and destroy()-cancels-queued, so
145
+ // the one line each terminal path owes the structured stream is emitted here. The
146
+ // callback bails on `cancelled` without logging, which keeps it to exactly one.
147
+ finishLog(logger, "subprocess", taskName, labels, performance.now(), error);
148
+ publish({ ok: false, error });
149
+ },
150
+ };
151
+ live.add(entry);
152
+ // p-queue's own `signal` option used to provide prompt abort for queued runs, but it
153
+ // also released the slot while the child kept running (#1809 P1-7).
154
+ const signal = env?.signal;
155
+ const onQueuedAbort = signal ? () => entry.cancelIfQueued(abortedError(taskName, signal.reason)) : undefined;
156
+ if (signal && onQueuedAbort)
157
+ signal.addEventListener("abort", onQueuedAbort, { once: true });
158
+ const task = queue.add(async () => {
159
+ if (signal && onQueuedAbort)
160
+ signal.removeEventListener("abort", onQueuedAbort);
161
+ let context;
162
+ let child;
163
+ let onAbort;
164
+ let killTimer;
165
+ let abandonTimer;
166
+ let reaped = false;
167
+ let abandon;
168
+ const abandoned = new Promise((resolve) => { abandon = () => resolve("abandoned"); });
169
+ try {
170
+ if (cancelled)
171
+ return;
172
+ if (destroyed || entry.teardown.signal.aborted) {
173
+ const error = destroyedError(taskName);
174
+ finishLog(logger, "subprocess", taskName, labels, performance.now(), error);
175
+ publish({ ok: false, error });
176
+ return;
177
+ }
178
+ started = true;
179
+ context = beginRun(taskName, env, options, entry.teardown.signal);
180
+ const run = context;
181
+ const startedAt = startLog(logger, "subprocess", taskName, labels);
182
+ // SIGTERM alone bounds nothing: a child that traps or ignores it runs to completion
183
+ // while holding the slot (#1809 P0-3). Escalate to a group SIGKILL, then stop
184
+ // waiting altogether so the deadline is real even for an unkillable child.
185
+ onAbort = () => {
186
+ if (!child || reaped)
187
+ return;
188
+ killGroup(child, "SIGTERM");
189
+ killTimer = setTimeout(() => {
190
+ // `reaped` keeps a late timer from signalling a process group whose pid the
191
+ // kernel may already have handed to somebody else.
192
+ if (!child || reaped)
193
+ return;
194
+ killGroup(child, "SIGKILL");
195
+ abandonTimer = setTimeout(abandon, REAP_GRACE_MS);
196
+ }, killGraceMs);
197
+ };
198
+ run.signal.addEventListener("abort", onAbort, { once: true });
199
+ try {
200
+ if (run.signal.aborted)
201
+ throw run.abortError();
202
+ child = Bun.spawn(spec.command, {
203
+ cwd: spec.cwd,
204
+ env: spec.env ? { ...process.env, ...spec.env } : process.env,
205
+ stdin: "ignore", stdout: "pipe", stderr: "pipe",
206
+ detached: process.platform !== "win32",
207
+ });
208
+ trackChild(child);
209
+ children.add(child);
210
+ const exiting = child;
211
+ void exiting.exited.then(() => {
212
+ reaped = true;
213
+ liveChildren.delete(exiting);
214
+ children.delete(exiting);
215
+ });
216
+ const completed = Promise.all([
217
+ readCapped(child.stdout, maxOutputBytes),
218
+ readCapped(child.stderr, maxOutputBytes),
219
+ child.exited,
220
+ ]);
221
+ const settledRun = await Promise.race([completed, abandoned]);
222
+ if (settledRun === "abandoned") {
223
+ throw run.signal.aborted
224
+ ? run.abortError()
225
+ : new OffloadError({ kind: "timeout", taskName, message: `${taskName} did not exit after SIGKILL` });
226
+ }
227
+ const [stdout, stderr, exitCode] = settledRun;
228
+ if (run.signal.aborted)
229
+ throw run.abortError();
230
+ const okExitCodes = spec.okExitCodes ?? [0];
231
+ if (okExitCodes !== "any" && !okExitCodes.includes(exitCode))
232
+ throw new OffloadError({
233
+ kind: "rejected", taskName, code: String(exitCode), message: `${taskName} exited ${exitCode}: ${stderr.text.trim() || stdout.text.trim()}`,
234
+ });
235
+ const result = { exitCode, stdout: stdout.text, stderr: stderr.text, truncated: stdout.truncated || stderr.truncated };
236
+ finishLog(logger, "subprocess", taskName, labels, startedAt);
237
+ await recordResult({ counter, taskName, backend: "subprocess", labels, sink, logger });
238
+ publish({ ok: true, value: result });
239
+ }
240
+ catch (error) {
241
+ const normalized = run.signal.aborted ? run.abortError() : normalizeError(taskName, error);
242
+ finishLog(logger, "subprocess", taskName, labels, startedAt, normalized);
243
+ await recordResult({ counter, taskName, backend: "subprocess", labels, error: normalized, sink, logger });
244
+ publish({ ok: false, error: normalized });
245
+ }
246
+ finally {
247
+ if (onAbort)
248
+ run.signal.removeEventListener("abort", onAbort);
249
+ run.cleanup();
250
+ }
251
+ }
252
+ catch (error) {
253
+ const normalized = normalizeError(taskName, error, "rejected");
254
+ finishLog(logger, "subprocess", taskName, labels, performance.now(), normalized);
255
+ await recordResult({ counter, taskName, backend: "subprocess", labels, error: normalized, sink, logger });
256
+ publish({ ok: false, error: normalized });
257
+ }
258
+ finally {
259
+ context?.cleanup();
260
+ // Keep the slot until the child is actually reaped, so the concurrency cap and
261
+ // `stats` stay true while a kill is in flight (#1809 P1-7). `abandoned` bounds
262
+ // this: the SIGKILL escalation above always ends the wait.
263
+ if (child)
264
+ await Promise.race([child.exited, abandoned]);
265
+ if (killTimer)
266
+ clearTimeout(killTimer);
267
+ if (abandonTimer)
268
+ clearTimeout(abandonTimer);
269
+ live.delete(entry);
270
+ }
271
+ });
272
+ void task.catch(() => undefined);
273
+ const result = await outcome;
274
+ if (!result.ok)
275
+ throw result.error;
276
+ return result.value;
277
+ },
278
+ drain: () => queue.onIdle(),
279
+ async destroy() {
280
+ destroyed = true;
281
+ const outstanding = [...live];
282
+ for (const entry of outstanding) {
283
+ entry.cancelIfQueued(destroyedError(entry.taskName));
284
+ entry.teardown.abort(new DOMException("Subprocess runner destroyed", "AbortError"));
285
+ }
286
+ for (const child of children)
287
+ killGroup(child, "SIGKILL");
288
+ await Promise.all([
289
+ ...outstanding.map((entry) => entry.settled),
290
+ ...[...children].map((child) => child.exited),
291
+ ]);
292
+ },
293
+ };
294
+ }
295
+ //# sourceMappingURL=subprocess-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocess-runner.js","sourceRoot":"","sources":["../src/subprocess-runner.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAA8C,MAAM,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AC;YACH,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAEjC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,MAAM,CAAC,KAAK,CAAC;YACnC,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE;QAC3B,KAAK,CAAC,OAAO;YACX,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;YAC9B,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;gBAChC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACrD,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,6BAA6B,EAAE,YAAY,CAAC,CAAC,CAAC;YACtF,CAAC;YACD,KAAK,MAAM,KAAK,IAAI,QAAQ;gBAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC1D,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;gBAC5C,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ export type OffloadErrorKind = "timeout" | "aborted" | "worker-error" | "worker-exit" | "rejected";
2
+ /** A stable, backend-independent failure surface for callers and escalation sinks. */
3
+ export declare class OffloadError extends Error {
4
+ readonly kind: OffloadErrorKind;
5
+ readonly code?: string;
6
+ readonly taskName: string;
7
+ constructor(options: {
8
+ kind: OffloadErrorKind;
9
+ taskName: string;
10
+ code?: string;
11
+ message?: string;
12
+ cause?: unknown;
13
+ });
14
+ }
15
+ export type OffloadLogFields = Record<string, unknown>;
16
+ /** Deliberately structural: server, runner and orchestrator can pass their existing logger adapters. */
17
+ export interface OffloadLogger {
18
+ debug?(message: string, fields?: OffloadLogFields): void;
19
+ info?(message: string, fields?: OffloadLogFields): void;
20
+ warn?(message: string, fields?: OffloadLogFields): void;
21
+ error?(message: string, fields?: OffloadLogFields): void;
22
+ }
23
+ export interface EscalationEvent {
24
+ taskName: string;
25
+ backend: "worker" | "async" | "subprocess";
26
+ error: OffloadError;
27
+ strikes: number;
28
+ labels: Record<string, string>;
29
+ }
30
+ export type EscalationSink = (event: EscalationEvent) => void | Promise<void>;
31
+ /** The common per-run contract. No backend-specific options leak into this envelope. */
32
+ export interface OffloadEnvelope {
33
+ timeoutMs?: number;
34
+ signal?: AbortSignal;
35
+ logger?: OffloadLogger;
36
+ labels?: Record<string, string>;
37
+ onEscalate?: EscalationSink;
38
+ /**
39
+ * Opt in to automatic re-dispatch after an ambiguous worker death (WorkerPool only; the async
40
+ * and subprocess runners never re-run). Default is AT-MOST-ONCE: if the worker dies with this
41
+ * job in flight, the job is rejected (`worker-exit`) and never re-run — because a re-run would
42
+ * repeat any side effect the job already performed (an HTTP POST, a mutation). Set this ONLY
43
+ * when the job is idempotent/retry-safe (pure compute), in which case a worker death is
44
+ * absorbed by re-dispatching to a fresh worker up to a bounded number of times (#1822 HIGH-1).
45
+ * Command/handler offload (side-effecting) must leave this unset.
46
+ */
47
+ retrySafe?: boolean;
48
+ }
49
+ export interface OffloadDefaults {
50
+ defaultTimeoutMs?: number;
51
+ logger?: OffloadLogger;
52
+ onEscalate?: EscalationSink;
53
+ /** Consecutive failed runs for a task before its injected sink fires. Defaults to 3. */
54
+ escalationThreshold?: number;
55
+ /**
56
+ * Size, in failure-attempts, of the sliding window the strike counter escalates over: a task
57
+ * escalates when it accumulates `escalationThreshold` failures within this many consecutive
58
+ * failure-attempts (counted across ALL tasks). A task with no failure inside the window is
59
+ * forgotten, which is ALSO what bounds memory — the counter holds at most this many failure
60
+ * events, so at most this many distinct names, at once (#1822 items 1 and 4). Adoption keys
61
+ * runs by dynamic names (workspace/agent ids); the window is what keeps that from growing
62
+ * without bound. Defaults to 4096.
63
+ */
64
+ escalationWindowAttempts?: number;
65
+ }
66
+ /**
67
+ * Sliding-window failure counter driving edge-triggered escalation (#1822 F1/F4, round-3
68
+ * redesign). A task escalates when it accumulates `threshold` failures within the last
69
+ * `window` failure-attempts (counted across all tasks); a failure older than the window no
70
+ * longer counts. This is attempt-based — no wall-clock, no timers — so it is deterministic and
71
+ * needs no time injection to test.
72
+ *
73
+ * WHY windowed rather than a size-capped consecutive counter: any hard *count* cap on a
74
+ * consecutive-strike map either scans the map per failure (O(cap); an earlier attempt blocked
75
+ * the event loop ~11s at 40k / ~31s at 100k distinct failures) or silently drops a task that is
76
+ * genuinely accumulating (a missed page — strictly worse than the leak it replaced). The window
77
+ * gives all four invariants at once: no lost escalation, no page storm, amortized O(1) per
78
+ * failure, and a hard memory bound.
79
+ *
80
+ * IMPLEMENTATION — the standard sliding-window multiset over a ring of failure events:
81
+ * - `#ring[(clock-1) % window]` holds the failure event `window` attempts ago. Each new failure
82
+ * overwrites exactly that slot, and the event it evicts is exactly the one aging out — so a
83
+ * failure is pushed once and expired once: amortized O(1), never a scan.
84
+ * - `#live[name]` is the name's failure count still inside the window = its escalation score.
85
+ * - Memory is hard-bounded: the ring holds ≤ `window` events, hence ≤ `window` distinct names.
86
+ * - `succeed()` bumps a per-name `#epoch`; events carry the epoch they were recorded under, so a
87
+ * success invalidates the name's in-window failures (score resets) in O(1) without scanning
88
+ * the ring — the stale events simply don't count as they age out.
89
+ * - Latch (`trip`): a per-name flag so an escalation fires ONCE and does not re-fire while the
90
+ * task stays continuously failing; it clears when the task succeeds or every failure ages out.
91
+ *
92
+ * SEMANTIC NOTE (deliberate change from the first #1822 attempt): escalation is now "threshold
93
+ * failures WITHIN the window", not "threshold consecutive failures ever". Failures spread wider
94
+ * apart than the window decay and never trip — which is the actual flap-detection semantic.
95
+ */
96
+ export declare class StrikeCounter {
97
+ #private;
98
+ readonly threshold: number;
99
+ readonly window: number;
100
+ constructor(threshold?: number, escalationWindowAttempts?: number);
101
+ /** Distinct task names with a failure still inside the window. Bounded by `window`. */
102
+ get size(): number;
103
+ fail(taskName: string): number;
104
+ /** Latch an escalation so it fires once until the task re-arms (succeeds or ages out). */
105
+ trip(taskName: string): void;
106
+ succeed(taskName: string): void;
107
+ }
108
+ export declare function normalizeError(taskName: string, error: unknown, fallback?: OffloadErrorKind): OffloadError;
109
+ export declare function log(logger: OffloadLogger | undefined, level: keyof OffloadLogger, message: string, fields: OffloadLogFields): void;
110
+ export declare function validateTimeout(timeoutMs: number | undefined): number | undefined;
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,UAAU,CAAC;AAEnG,sFAAsF;AACtF,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,YAAY,OAAO,EAAE;QACnB,IAAI,EAAE,gBAAgB,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,EAMA;CACF;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvD,wGA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