@weavecode/weave 0.1.7 → 0.1.9

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 (431) hide show
  1. package/node_modules/@modelcontextprotocol/sdk/node_modules/@hono/node-server/dist/index.cjs +31 -6
  2. package/node_modules/@modelcontextprotocol/sdk/node_modules/@hono/node-server/dist/index.mjs +31 -6
  3. package/node_modules/@modelcontextprotocol/sdk/node_modules/@hono/node-server/package.json +1 -1
  4. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.cjs +1 -1
  5. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.mjs +1 -1
  6. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/node_modules/ip-address/README.md +39 -39
  7. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/node_modules/ip-address/dist/ipv6.js +1 -1
  8. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/node_modules/ip-address/package.json +1 -1
  9. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/package.json +1 -1
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/context.js +1 -1
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/helper/css/common.js +3 -5
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/hono-base.js +4 -10
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/hono.js +0 -1
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  23. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  24. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  25. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  26. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
  27. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/utils/mount.js +35 -0
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/utils/url.js +10 -0
  29. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/cjs/validator/validator.js +1 -1
  30. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/context.js +1 -1
  31. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/helper/css/common.js +3 -5
  32. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/hono-base.js +4 -10
  33. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/hono.js +0 -1
  34. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
  35. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
  36. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  37. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  38. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  39. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/language/language.js +1 -1
  40. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/middleware/mount/index.js +4 -4
  41. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  42. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  43. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  44. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  45. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
  46. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  47. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  48. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  49. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/types/utils/url.d.ts +1 -0
  50. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
  51. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/utils/mount.js +34 -0
  52. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/utils/url.js +10 -1
  53. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/dist/validator/validator.js +1 -1
  54. package/node_modules/@modelcontextprotocol/sdk/node_modules/hono/package.json +1 -1
  55. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
  56. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  57. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
  58. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  59. package/node_modules/@weavecode/cli/dist/cli.js +4 -4
  60. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  61. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  62. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  63. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
  64. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  65. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  66. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  67. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  68. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  69. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +3 -3
  70. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +7 -0
  71. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +3 -3
  72. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  73. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  74. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +5 -5
  75. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  76. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  77. package/node_modules/@weavecode/cli/dist/init/git-exclude.d.ts +20 -0
  78. package/node_modules/@weavecode/cli/dist/init/git-exclude.js +7 -0
  79. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  80. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  81. package/node_modules/@weavecode/cli/dist/init/instruction-files.d.ts +14 -0
  82. package/node_modules/@weavecode/cli/dist/init/instruction-files.js +1 -0
  83. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  84. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  85. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  86. package/node_modules/@weavecode/cli/dist/init/provision.js +1 -1
  87. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  88. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  89. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  90. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  91. package/node_modules/@weavecode/cli/package.json +5 -5
  92. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  93. package/node_modules/@weavecode/core/dist/harness.d.ts +115 -0
  94. package/node_modules/@weavecode/core/dist/harness.js +1 -1
  95. package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
  96. package/node_modules/@weavecode/core/dist/index.js +1 -1
  97. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  98. package/node_modules/@weavecode/core/dist/types.d.ts +4 -4
  99. package/node_modules/@weavecode/core/dist/types.js +1 -1
  100. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  101. package/node_modules/@weavecode/core/package.json +1 -1
  102. package/node_modules/@weavecode/harness/dist/claude/assets.js +3 -3
  103. package/node_modules/@weavecode/harness/dist/claude/capture.js +9 -9
  104. package/node_modules/@weavecode/harness/dist/claude/commands.d.ts +2 -0
  105. package/node_modules/@weavecode/harness/dist/claude/commands.js +3 -2
  106. package/node_modules/@weavecode/harness/dist/claude/config.js +2 -2
  107. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  108. package/node_modules/@weavecode/harness/dist/claude/edits.js +1 -1
  109. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  110. package/node_modules/@weavecode/harness/dist/claude/images.js +2 -2
  111. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  112. package/node_modules/@weavecode/harness/dist/claude/liveness.js +1 -1
  113. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
  114. package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
  115. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
  116. package/node_modules/@weavecode/harness/dist/claude/narration.js +1 -1
  117. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  118. package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -1
  119. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  120. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  121. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  122. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
  123. package/node_modules/@weavecode/harness/dist/claude/resume.js +1 -1
  124. package/node_modules/@weavecode/harness/dist/claude/rewind.js +1 -1
  125. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
  126. package/node_modules/@weavecode/harness/dist/claude/side-question.js +2 -2
  127. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.d.ts +6 -0
  128. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +21 -14
  129. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -1
  130. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -2
  131. package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.js +2 -2
  132. package/node_modules/@weavecode/harness/dist/claude/transcript.js +7 -7
  133. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  134. package/node_modules/@weavecode/harness/dist/codex/capture.js +2 -2
  135. package/node_modules/@weavecode/harness/dist/codex/commands.js +4 -4
  136. package/node_modules/@weavecode/harness/dist/codex/config.js +2 -2
  137. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  138. package/node_modules/@weavecode/harness/dist/codex/event-source.js +2 -2
  139. package/node_modules/@weavecode/harness/dist/codex/images.js +1 -1
  140. package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
  141. package/node_modules/@weavecode/harness/dist/codex/liveness.js +1 -1
  142. package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -1
  143. package/node_modules/@weavecode/harness/dist/codex/messaging.js +2 -2
  144. package/node_modules/@weavecode/harness/dist/codex/narration.js +1 -1
  145. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  146. package/node_modules/@weavecode/harness/dist/codex/plugins.js +3 -3
  147. package/node_modules/@weavecode/harness/dist/codex/provision.js +1 -1
  148. package/node_modules/@weavecode/harness/dist/codex/questions.js +2 -2
  149. package/node_modules/@weavecode/harness/dist/codex/rollout.js +5 -5
  150. package/node_modules/@weavecode/harness/dist/codex/side-question.js +4 -4
  151. package/node_modules/@weavecode/harness/dist/codex/titles.js +4 -4
  152. package/node_modules/@weavecode/harness/dist/codex/toml.js +13 -13
  153. package/node_modules/@weavecode/harness/dist/codex/transcript.js +2 -2
  154. package/node_modules/@weavecode/harness/dist/driver.d.ts +6 -0
  155. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  156. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
  157. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  158. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  159. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  160. package/node_modules/@weavecode/harness/dist/shared/json-cap.js +1 -1
  161. package/node_modules/@weavecode/harness/package.json +2 -2
  162. package/node_modules/@weavecode/server/dist/config/dotted.js +1 -1
  163. package/node_modules/@weavecode/server/dist/config/profiles.js +2 -2
  164. package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
  165. package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
  166. package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
  167. package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -3
  168. package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
  169. package/node_modules/@weavecode/server/dist/daemon/auto-start.js +3 -3
  170. package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
  171. package/node_modules/@weavecode/server/dist/daemon/config-routes.js +1 -1
  172. package/node_modules/@weavecode/server/dist/daemon/cron.js +1 -1
  173. package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
  174. package/node_modules/@weavecode/server/dist/daemon/dashboard-pusher.js +1 -1
  175. package/node_modules/@weavecode/server/dist/daemon/decision-config.js +2 -2
  176. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  177. package/node_modules/@weavecode/server/dist/daemon/entry.js +2 -2
  178. package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
  179. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  180. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  181. package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
  182. package/node_modules/@weavecode/server/dist/daemon/liveness.js +1 -1
  183. package/node_modules/@weavecode/server/dist/daemon/mcp-orchestration.js +1 -1
  184. package/node_modules/@weavecode/server/dist/daemon/narration-watcher.js +2 -2
  185. package/node_modules/@weavecode/server/dist/daemon/opener/backend-ghostty.js +1 -1
  186. package/node_modules/@weavecode/server/dist/daemon/opener/backend-iterm.js +1 -1
  187. package/node_modules/@weavecode/server/dist/daemon/opener/backend-konsole.js +2 -2
  188. package/node_modules/@weavecode/server/dist/daemon/opener/backend-terminal-app.js +1 -1
  189. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wezterm.js +1 -1
  190. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wt.js +1 -1
  191. package/node_modules/@weavecode/server/dist/daemon/opener/backend.js +1 -1
  192. package/node_modules/@weavecode/server/dist/daemon/opener/pty-terminals.js +1 -1
  193. package/node_modules/@weavecode/server/dist/daemon/opener/shared.js +1 -1
  194. package/node_modules/@weavecode/server/dist/daemon/opener/wezterm-mux.js +1 -1
  195. package/node_modules/@weavecode/server/dist/daemon/opener/wt.js +3 -3
  196. package/node_modules/@weavecode/server/dist/daemon/opener.js +1 -1
  197. package/node_modules/@weavecode/server/dist/daemon/pet-seed.d.ts +4 -0
  198. package/node_modules/@weavecode/server/dist/daemon/pet-seed.js +2 -0
  199. package/node_modules/@weavecode/server/dist/daemon/pet-window.d.ts +17 -0
  200. package/node_modules/@weavecode/server/dist/daemon/pet-window.js +2 -0
  201. package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
  202. package/node_modules/@weavecode/server/dist/daemon/project-files.d.ts +1 -1
  203. package/node_modules/@weavecode/server/dist/daemon/project-files.js +2 -2
  204. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
  205. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
  206. package/node_modules/@weavecode/server/dist/daemon/prompt-images.js +1 -1
  207. package/node_modules/@weavecode/server/dist/daemon/routes/hooks-admin.js +1 -1
  208. package/node_modules/@weavecode/server/dist/daemon/routes/installations.d.ts +29 -0
  209. package/node_modules/@weavecode/server/dist/daemon/routes/installations.js +1 -0
  210. package/node_modules/@weavecode/server/dist/daemon/routes/market.js +1 -1
  211. package/node_modules/@weavecode/server/dist/daemon/routes/orchestration.js +1 -1
  212. package/node_modules/@weavecode/server/dist/daemon/routes/path-refs.js +1 -1
  213. package/node_modules/@weavecode/server/dist/daemon/routes/pets.d.ts +3 -0
  214. package/node_modules/@weavecode/server/dist/daemon/routes/pets.js +1 -0
  215. package/node_modules/@weavecode/server/dist/daemon/routes/project-files.js +1 -1
  216. package/node_modules/@weavecode/server/dist/daemon/routes/projects.js +1 -1
  217. package/node_modules/@weavecode/server/dist/daemon/routes/search.js +1 -1
  218. package/node_modules/@weavecode/server/dist/daemon/routes/session-control.js +1 -1
  219. package/node_modules/@weavecode/server/dist/daemon/routes/session-insights.js +1 -1
  220. package/node_modules/@weavecode/server/dist/daemon/routes/settings-statusline.js +1 -1
  221. package/node_modules/@weavecode/server/dist/daemon/routes/uploads.js +1 -1
  222. package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.js +2 -1
  223. package/node_modules/@weavecode/server/dist/daemon/routes/watches.js +1 -1
  224. package/node_modules/@weavecode/server/dist/daemon/server.d.ts +4 -0
  225. package/node_modules/@weavecode/server/dist/daemon/server.js +8 -8
  226. package/node_modules/@weavecode/server/dist/daemon/session-open.js +1 -1
  227. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  228. package/node_modules/@weavecode/server/dist/daemon/settings.d.ts +21 -0
  229. package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
  230. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.js +1 -1
  231. package/node_modules/@weavecode/server/dist/daemon/sse-hub.js +1 -1
  232. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  233. package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
  234. package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
  235. package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.js +1 -1
  236. package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
  237. package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
  238. package/node_modules/@weavecode/server/dist/daemon/upload-sessions.js +1 -1
  239. package/node_modules/@weavecode/server/dist/db/db.d.ts +4 -1
  240. package/node_modules/@weavecode/server/dist/db/db.js +2 -2
  241. package/node_modules/@weavecode/server/dist/db/layout.d.ts +5 -0
  242. package/node_modules/@weavecode/server/dist/db/layout.js +2 -1
  243. package/node_modules/@weavecode/server/dist/db/paths.d.ts +9 -0
  244. package/node_modules/@weavecode/server/dist/db/paths.js +1 -1
  245. package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
  246. package/node_modules/@weavecode/server/dist/hooks/dashboard-rate.js +1 -1
  247. package/node_modules/@weavecode/server/dist/hooks/decision-judge.js +1 -1
  248. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.js +1 -1
  249. package/node_modules/@weavecode/server/dist/hooks/delivery/channels.js +1 -1
  250. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.js +1 -1
  251. package/node_modules/@weavecode/server/dist/hooks/delivery/queue.js +1 -1
  252. package/node_modules/@weavecode/server/dist/hooks/delivery/relay.js +1 -1
  253. package/node_modules/@weavecode/server/dist/hooks/delivery/send.js +2 -2
  254. package/node_modules/@weavecode/server/dist/hooks/delivery/views.js +1 -1
  255. package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
  256. package/node_modules/@weavecode/server/dist/hooks/edge-extract.js +1 -1
  257. package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
  258. package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
  259. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -2
  260. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  261. package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
  262. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +5 -5
  263. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  264. package/node_modules/@weavecode/server/dist/hooks/orchestration-engine.js +7 -7
  265. package/node_modules/@weavecode/server/dist/hooks/orchestration-graph.js +1 -1
  266. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
  267. package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
  268. package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
  269. package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
  270. package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
  271. package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
  272. package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
  273. package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
  274. package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
  275. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  276. package/node_modules/@weavecode/server/dist/hooks/side-questions.js +1 -1
  277. package/node_modules/@weavecode/server/dist/hooks/synthetic-sessions.js +1 -1
  278. package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
  279. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  280. package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
  281. package/node_modules/@weavecode/server/dist/index.d.ts +1 -1
  282. package/node_modules/@weavecode/server/dist/index.js +1 -1
  283. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  284. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  285. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  286. package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
  287. package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
  288. package/node_modules/@weavecode/server/dist/install/global-config.js +1 -1
  289. package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
  290. package/node_modules/@weavecode/server/dist/install/init-files.d.ts +0 -9
  291. package/node_modules/@weavecode/server/dist/install/init-files.js +2 -2
  292. package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
  293. package/node_modules/@weavecode/server/dist/install/installer.js +1 -1
  294. package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
  295. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  296. package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
  297. package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
  298. package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
  299. package/node_modules/@weavecode/server/dist/install/project-config.js +1 -1
  300. package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
  301. package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
  302. package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
  303. package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
  304. package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
  305. package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
  306. package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
  307. package/node_modules/@weavecode/server/dist/market/import.js +2 -2
  308. package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
  309. package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
  310. package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
  311. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  312. package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +4 -4
  313. package/node_modules/@weavecode/server/dist/repositories/hook-events.d.ts +6 -0
  314. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +8 -5
  315. package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
  316. package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
  317. package/node_modules/@weavecode/server/dist/repositories/orchestrations.js +7 -7
  318. package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
  319. package/node_modules/@weavecode/server/dist/repositories/projects.js +1 -1
  320. package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
  321. package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
  322. package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
  323. package/node_modules/@weavecode/server/dist/repositories/uploads.js +11 -11
  324. package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
  325. package/node_modules/@weavecode/server/dist/statusline/generator.js +1 -1
  326. package/node_modules/@weavecode/server/dist/statusline/manager.js +3 -3
  327. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  328. package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
  329. package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
  330. package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
  331. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
  332. package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
  333. package/node_modules/@weavecode/server/package.json +4 -4
  334. package/node_modules/@weavecode/server/web/dist/assets/abnfDiagram-WEYOIA3C-S1lL1V_n.js +1 -0
  335. package/node_modules/@weavecode/server/web/dist/assets/{arc-CRZTRyjb.js → arc-CoTNHyHV.js} +1 -1
  336. package/node_modules/@weavecode/server/web/dist/assets/architectureDiagram-ZHVYKT53-C6ttfnzW.js +36 -0
  337. package/node_modules/@weavecode/server/web/dist/assets/{blockDiagram-RJAE7QA3-BIH8mSIZ.js → blockDiagram-RJAE7QA3-CYr3Cpu9.js} +2 -2
  338. package/node_modules/@weavecode/server/web/dist/assets/{c4Diagram-XDPPPE54-5YoKWFOD.js → c4Diagram-XDPPPE54-BFS7PhLD.js} +2 -2
  339. package/node_modules/@weavecode/server/web/dist/assets/channel-DxQHp3Yc.js +1 -0
  340. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2E7WHVMD-B653kMXt.js → chunk-2E7WHVMD-DJ7X_Shu.js} +1 -1
  341. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2Q5K7J3B-f_A4_eDz.js → chunk-2Q5K7J3B-B8nr2rdz.js} +1 -1
  342. package/node_modules/@weavecode/server/web/dist/assets/{chunk-4EMNKR2T-v5j5qNGj.js → chunk-4EMNKR2T-DmnZmUMU.js} +1 -1
  343. package/node_modules/@weavecode/server/web/dist/assets/chunk-55XCU76K-Xz9a8dmp.js +1 -0
  344. package/node_modules/@weavecode/server/web/dist/assets/{chunk-5VM5RSS4-BeROhLXN.js → chunk-5VM5RSS4-Dg9mg7pf.js} +1 -1
  345. package/node_modules/@weavecode/server/web/dist/assets/{chunk-JWPE2WC7-D6dXb_jr.js → chunk-JWPE2WC7-CmjTZO8o.js} +1 -1
  346. package/node_modules/@weavecode/server/web/dist/assets/{chunk-VQ5W62QI-CnHdSEMi.js → chunk-VQ5W62QI-D3YDdJ3E.js} +1 -1
  347. package/node_modules/@weavecode/server/web/dist/assets/chunk-XXDRQBXY-s1OG9sqW.js +1 -0
  348. package/node_modules/@weavecode/server/web/dist/assets/chunk-ZCHMQSOR-C3hINQU3.js +2 -0
  349. package/node_modules/@weavecode/server/web/dist/assets/{classDiagram-v2-4MYWR3UA-DQe1b_k8.js → classDiagram-v2-4MYWR3UA-BTsbYrVl.js} +2 -2
  350. package/node_modules/@weavecode/server/web/dist/assets/cose-bilkent-JH36ORCC-C0W8Y-jI.js +1 -0
  351. package/node_modules/@weavecode/server/web/dist/assets/{cynefin-EF2NZ3EQ-OZotFKUu.js → cynefin-EF2NZ3EQ-stAu4Rh-.js} +1 -1
  352. package/node_modules/@weavecode/server/web/dist/assets/cynefinDiagram-WF24UDRP-CqYibiiv.js +62 -0
  353. package/node_modules/@weavecode/server/web/dist/assets/dagre-NK4GIZVX-qqcoJAqB.js +4 -0
  354. package/node_modules/@weavecode/server/web/dist/assets/diagram-CBK3MWTC-D0YTopb7.js +24 -0
  355. package/node_modules/@weavecode/server/web/dist/assets/diagram-I5XIIV2D-Csvw6aYr.js +24 -0
  356. package/node_modules/@weavecode/server/web/dist/assets/{diagram-ODIL2UCW-D9A6W8oB.js → diagram-ODIL2UCW-Dl0tYLkF.js} +2 -2
  357. package/node_modules/@weavecode/server/web/dist/assets/{diagram-PFBEJUXE-PeI-eyu2.js → diagram-PFBEJUXE-BCPSWZPe.js} +2 -2
  358. package/node_modules/@weavecode/server/web/dist/assets/diagram-RJA3I4VV-ETg-BrAJ.js +41 -0
  359. package/node_modules/@weavecode/server/web/dist/assets/{diagram-TYUNFSNR-D5KieEw5.js → diagram-TYUNFSNR-_M6ZxBG7.js} +2 -2
  360. package/node_modules/@weavecode/server/web/dist/assets/ebnfDiagram-V4P3TTPT-C-e_W7qx.js +1 -0
  361. package/node_modules/@weavecode/server/web/dist/assets/{elk-QONTBCTQ-D3xrVg0U.js → elk-QONTBCTQ-B5TBharB.js} +3 -3
  362. package/node_modules/@weavecode/server/web/dist/assets/{erDiagram-KYQIGQAA-y_V1cor7.js → erDiagram-KYQIGQAA-D08rj2pv.js} +2 -2
  363. package/node_modules/@weavecode/server/web/dist/assets/{flowDiagram-IUGLLWBU-BJ8Z0MkF.js → flowDiagram-IUGLLWBU-BALTxsKh.js} +1 -1
  364. package/node_modules/@weavecode/server/web/dist/assets/ganttDiagram-R7GPNTJY-Cts193jT.js +292 -0
  365. package/node_modules/@weavecode/server/web/dist/assets/gitGraphDiagram-PDYL7XHY-L9qYUX0v.js +106 -0
  366. package/node_modules/@weavecode/server/web/dist/assets/infoDiagram-MVDRKAX5-Bv47rgU0.js +2 -0
  367. package/node_modules/@weavecode/server/web/dist/assets/{ishikawaDiagram-HPEHV2GE-ChEnND76.js → ishikawaDiagram-HPEHV2GE-Da8_s6cs.js} +2 -2
  368. package/node_modules/@weavecode/server/web/dist/assets/{journeyDiagram-BOSHW7O7-DHcNtpYF.js → journeyDiagram-BOSHW7O7-Bj3CjZOf.js} +2 -2
  369. package/node_modules/@weavecode/server/web/dist/assets/{kanban-definition-FNSA4HC5-Dft7qpW5.js → kanban-definition-FNSA4HC5-D1hicmMu.js} +2 -2
  370. package/node_modules/@weavecode/server/web/dist/assets/linear-CWQg2iA1.js +1 -0
  371. package/node_modules/@weavecode/server/web/dist/assets/main-XLn3EZFh.css +11 -0
  372. package/node_modules/@weavecode/server/web/dist/assets/main-bsb0lQoL.js +1096 -0
  373. package/node_modules/@weavecode/server/web/dist/assets/{mermaid.core-D_Dp_Kl2.js → mermaid.core-C-wP0Zg2.js} +4 -4
  374. package/node_modules/@weavecode/server/web/dist/assets/{mindmap-definition-6OY57UG3-CM6OAd_-.js → mindmap-definition-6OY57UG3-Dk0VKqre.js} +2 -2
  375. package/node_modules/@weavecode/server/web/dist/assets/modulepreload-polyfill-B5Qt9EMX.js +1 -0
  376. package/node_modules/@weavecode/server/web/dist/assets/pegDiagram-ECIUJNBX-Bp1K_F9z.js +1 -0
  377. package/node_modules/@weavecode/server/web/dist/assets/pet-J6izA90s.js +1 -0
  378. package/node_modules/@weavecode/server/web/dist/assets/pieDiagram-GNMPY74T-BZ4rGy3t.js +39 -0
  379. package/node_modules/@weavecode/server/web/dist/assets/{quadrantDiagram-D57K4MC3-D8pQ_PU2.js → quadrantDiagram-D57K4MC3-B4N5KRsR.js} +4 -4
  380. package/node_modules/@weavecode/server/web/dist/assets/railroadDiagram-Y72NRBL7-C8nx8oHf.js +1 -0
  381. package/node_modules/@weavecode/server/web/dist/assets/{requirementDiagram-EQYSW5RA-C90DU5Ny.js → requirementDiagram-EQYSW5RA-VSH57d0d.js} +2 -2
  382. package/node_modules/@weavecode/server/web/dist/assets/{sankeyDiagram-SY24JHO5-B_poYGgJ.js → sankeyDiagram-SY24JHO5-jUb1hcya.js} +2 -2
  383. package/node_modules/@weavecode/server/web/dist/assets/{sequenceDiagram-BLEHNHQU-DDW7b2Dn.js → sequenceDiagram-BLEHNHQU-E2BioCNi.js} +2 -2
  384. package/node_modules/@weavecode/server/web/dist/assets/sizeCapture-INFHLROL-BdKrbRmI.js +1 -0
  385. package/node_modules/@weavecode/server/web/dist/assets/{stateDiagram-v2-A6IESKWZ-CkVMAyxG.js → stateDiagram-v2-A6IESKWZ-tFz7uNM7.js} +2 -2
  386. package/node_modules/@weavecode/server/web/dist/assets/swimlanes-B3ENRKFQ-B9BAPDWw.js +1 -0
  387. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-DQ2NPLl9.js +8 -0
  388. package/node_modules/@weavecode/server/web/dist/assets/{timeline-definition-JXYKGLGB-DnhkRGLb.js → timeline-definition-JXYKGLGB-CofNnFTK.js} +2 -2
  389. package/node_modules/@weavecode/server/web/dist/assets/{usecaseDiagram-WPOLBNNX-_TdIjC6Z.js → usecaseDiagram-WPOLBNNX-DOvjhJjJ.js} +2 -2
  390. package/node_modules/@weavecode/server/web/dist/assets/{vennDiagram-Q3Y3IDCW-FzgsymXB.js → vennDiagram-Q3Y3IDCW-BcFHWnhS.js} +2 -2
  391. package/node_modules/@weavecode/server/web/dist/assets/{wardleyDiagram-IVAIDKWA-BwqimStC.js → wardleyDiagram-IVAIDKWA-Bz2aqRAs.js} +2 -2
  392. package/node_modules/@weavecode/server/web/dist/assets/{xychartDiagram-4URNHDU4-CFjjVPIV.js → xychartDiagram-4URNHDU4-DpNF6Vsq.js} +2 -2
  393. package/node_modules/@weavecode/server/web/dist/index.html +3 -2
  394. package/node_modules/@weavecode/server/web/dist/pet.html +130 -0
  395. package/node_modules/@weavecode/templates/dist/index.d.ts +2 -0
  396. package/node_modules/@weavecode/templates/dist/index.js +1 -1
  397. package/node_modules/@weavecode/templates/dist/resources/pets/weave-spider/pet.json +7 -0
  398. package/node_modules/@weavecode/templates/dist/resources/pets/weave-spider/spritesheet.png +0 -0
  399. package/node_modules/@weavecode/templates/dist/resources/weave-market/.claude-plugin/marketplace.json +6 -0
  400. package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-pet-hatcher/.claude-plugin/plugin.json +8 -0
  401. package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-pet-hatcher/skills/weave-pet-hatcher/SKILL.md +121 -0
  402. package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-pet-hatcher/skills/weave-pet-hatcher/scripts/assemble-pet.mjs +308 -0
  403. package/node_modules/@weavecode/templates/dist/resources/weave-market/plugins/core-skills/weave-pet-hatcher/weave.json +4 -0
  404. package/node_modules/@weavecode/templates/package.json +2 -2
  405. package/package.json +11 -7
  406. package/scripts/preinstall.mjs +108 -0
  407. package/node_modules/@weavecode/server/web/dist/assets/abnfDiagram-WEYOIA3C-DDeQkTf5.js +0 -1
  408. package/node_modules/@weavecode/server/web/dist/assets/architectureDiagram-ZHVYKT53-Dj54DE3O.js +0 -36
  409. package/node_modules/@weavecode/server/web/dist/assets/channel-5VM93AJ8.js +0 -1
  410. package/node_modules/@weavecode/server/web/dist/assets/chunk-55XCU76K-CgEqeP7j.js +0 -1
  411. package/node_modules/@weavecode/server/web/dist/assets/chunk-XXDRQBXY-BkG_e6PE.js +0 -1
  412. package/node_modules/@weavecode/server/web/dist/assets/chunk-ZCHMQSOR-DxR-fxzs.js +0 -2
  413. package/node_modules/@weavecode/server/web/dist/assets/cose-bilkent-JH36ORCC-DThrA8S5.js +0 -1
  414. package/node_modules/@weavecode/server/web/dist/assets/cynefinDiagram-WF24UDRP-DJjq2hfT.js +0 -62
  415. package/node_modules/@weavecode/server/web/dist/assets/dagre-NK4GIZVX-C2vH93HT.js +0 -4
  416. package/node_modules/@weavecode/server/web/dist/assets/diagram-CBK3MWTC-DrF_ScM-.js +0 -24
  417. package/node_modules/@weavecode/server/web/dist/assets/diagram-I5XIIV2D-D1qoUJ4t.js +0 -24
  418. package/node_modules/@weavecode/server/web/dist/assets/diagram-RJA3I4VV-DITY0Rd8.js +0 -41
  419. package/node_modules/@weavecode/server/web/dist/assets/ebnfDiagram-V4P3TTPT-DDylK-gz.js +0 -1
  420. package/node_modules/@weavecode/server/web/dist/assets/ganttDiagram-R7GPNTJY-C0q-CS1T.js +0 -292
  421. package/node_modules/@weavecode/server/web/dist/assets/gitGraphDiagram-PDYL7XHY-BYTComiB.js +0 -106
  422. package/node_modules/@weavecode/server/web/dist/assets/index-BKxAxaVG.js +0 -1091
  423. package/node_modules/@weavecode/server/web/dist/assets/index-C0Sd4MH7.css +0 -11
  424. package/node_modules/@weavecode/server/web/dist/assets/infoDiagram-MVDRKAX5-DtixgjLP.js +0 -2
  425. package/node_modules/@weavecode/server/web/dist/assets/linear-DEo11t-X.js +0 -1
  426. package/node_modules/@weavecode/server/web/dist/assets/pegDiagram-ECIUJNBX-_QkY0h8Q.js +0 -1
  427. package/node_modules/@weavecode/server/web/dist/assets/pieDiagram-GNMPY74T-ZGr5vtDj.js +0 -39
  428. package/node_modules/@weavecode/server/web/dist/assets/railroadDiagram-Y72NRBL7-DUIo-WmA.js +0 -1
  429. package/node_modules/@weavecode/server/web/dist/assets/sizeCapture-INFHLROL-CmKoqX6K.js +0 -1
  430. package/node_modules/@weavecode/server/web/dist/assets/swimlanes-B3ENRKFQ-Dm_Omzky.js +0 -1
  431. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-Bjj8ZA4d.js +0 -8
@@ -1,2 +1,2 @@
1
- import{HARNESS_EVENTS as _}from"@weavecode/core";import{capFields as a}from"../shared/json-cap.js";import{CLAUDE_EVENT_SOURCE as g}from"../claude/event-source.js";const u={Interrupt:"TurnAborted"};export const CANONICAL_TO_WIRE=Object.fromEntries(Object.entries(u).map(([n,t])=>[t,n]));export function metaOfLine(n){if(n.type!=="session_meta")return null;const t=n.payload??{};return typeof t.session_id!="string"||!t.session_id?null:{sessionId:t.session_id,cwd:typeof t.cwd=="string"&&t.cwd?t.cwd:null}}function i(n){return Array.isArray(n)&&n.map(e=>{const o=e;return(typeof o?.type=="string"?o.type.toLowerCase():"")==="text"&&typeof o.text=="string"?o.text:""}).filter(Boolean).join(`
2
- `)||null}export function promptOfLine(n){const t=n.payload??{};if(t.type==="user_message")return typeof t.message=="string"&&t.message?t.message:null;if(t.type!=="item_completed")return null;const e=t.item;return e?.type!=="UserMessage"?null:i(e.content)}function p(n){const t=n.payload??{};if(t.type!=="item_completed")return null;const e=t.item;if(!e||typeof e!="object")return null;const o=e.type;return typeof o=="string"?{type:o,item:e}:null}export class CodexTurnBuffer{last=null;report(t){const e=t.payload??{},o=typeof e.type=="string"?e.type:null,s=p(t);if(o==="agent_message")return typeof e.message=="string"&&e.message&&(this.last=e.message),null;if(s?.type==="AgentMessage"){const r=i(s.item.content);return r&&(this.last=r),null}if(promptOfLine(t)!==null)return this.last=null,{eventType:"UserPromptSubmit",payload:{line:t}};if(t.type==="session_meta")return{eventType:"SessionStart",payload:{line:t}};if(o==="task_started")return this.last=null,null;if(o==="task_complete"){const r=this.last;return this.last=null,{eventType:"Stop",payload:{line:t,lastAgentMessage:r}}}return o==="turn_aborted"?{eventType:"TurnAborted",payload:{line:t}}:o==="exec_command_end"||o==="patch_apply_end"?{eventType:"PostToolUse",payload:{line:t}}:s?.type==="CommandExecution"||s?.type==="FileChange"||s?.type==="McpToolCall"?{eventType:"PostToolUse",payload:{line:t}}:null}}function c(n){return Array.isArray(n)?n.filter(t=>typeof t=="string").join(" "):typeof n=="string"?n:null}function x(n){const t=n.payload??{};if(t.type==="exec_command_end")return{toolName:"exec_command",toolInput:{command:c(t.command),cwd:t.cwd??null},toolResponse:{exit_code:t.exit_code??null,status:t.status??null}};if(t.type==="patch_apply_end"){const o=t.changes&&typeof t.changes=="object"?t.changes:{};return{toolName:"apply_patch",toolInput:{paths:Object.keys(o)},toolResponse:{success:t.success??null}}}const e=p(n);if(e?.type==="CommandExecution")return{toolName:"exec_command",toolInput:{command:c(e.item.command),cwd:e.item.cwd??null},toolResponse:{exit_code:e.item.exit_code??null,status:e.item.status??null}};if(e?.type==="FileChange"){const o=e.item.changes&&typeof e.item.changes=="object"?e.item.changes:{};return{toolName:"apply_patch",toolInput:{paths:Object.keys(o)},toolResponse:{status:e.item.status??null}}}return e?.type==="McpToolCall"?{toolName:typeof e.item.name=="string"?e.item.name:"mcp_tool_call",toolInput:e.item.arguments??null,toolResponse:e.item.result??e.item.status??null}:{toolName:null,toolInput:null,toolResponse:null}}function T(n,t){return typeof n.last_agent_message=="string"&&n.last_agent_message?n.last_agent_message:t??null}function h(n){const t=n.error;if(typeof t=="string"&&t)return t;if(t&&typeof t=="object"){const e=t.message;if(typeof e=="string"&&e)return e}return null}export class CodexEventSource{source="codex";events=_.codex;normalize(t,e){const o=t??{};return typeof o.payload=="string"?O(o,e):w(o,e)}}function O(n,t){const e=n.eventType||"unknown",o=u[e]??e;return{...g.normalize({...n,eventType:o},t),source:"codex"}}function w(n,t){const e=n.payload?.line??{},o=e.payload??{},s=n.eventType||"unknown",r={};if(s==="UserPromptSubmit")r.prompt=promptOfLine(e)??"";else if(s==="Stop"){r.last_assistant_message=T(o,n.payload?.lastAgentMessage);const l=h(o);l&&(r.error=l)}else s==="TurnAborted"?(r.reason=o.reason??null,r.duration_ms=o.duration_ms??null):s==="SessionStart"&&(r.source="rollout");e.ordinal!==void 0&&(r.seq=e.ordinal);const{toolName:m,toolInput:f,toolResponse:y}=x(e),d={eventType:s,toolName:m,toolInput:a(f),toolResponse:a(y),cwd:n.cwd??null,raw:{...r,turn_id:o.turn_id??null,call_id:o.call_id??null}};return{projectId:t,source:"codex",eventType:s,sessionId:n.sessionId,payload:JSON.stringify(d)}}export const CODEX_EVENT_SOURCE=new CodexEventSource;
1
+ import{HARNESS_EVENTS as _}from"@weavecode/core";import{capFields as a}from"../shared/json-cap.js";import{CLAUDE_EVENT_SOURCE as g}from"../claude/event-source.js";const i={Interrupt:"TurnAborted"};export const CANONICAL_TO_WIRE=Object.fromEntries(Object.entries(i).map(([n,e])=>[e,n]));export function metaOfLine(n){if(n.type!=="session_meta")return null;const e=n.payload??{};return typeof e.session_id!="string"||!e.session_id?null:{sessionId:e.session_id,cwd:typeof e.cwd=="string"&&e.cwd?e.cwd:null}}function p(n){return Array.isArray(n)&&n.map(e=>{const t=e;return(typeof t?.type=="string"?t.type.toLowerCase():"")==="text"&&typeof t.text=="string"?t.text:""}).filter(Boolean).join(`
2
+ `)||null}export function promptOfLine(n){const e=n.payload??{};if(e.type==="user_message")return typeof e.message=="string"&&e.message?e.message:null;if(e.type!=="item_completed")return null;const t=e.item;return t?.type!=="UserMessage"?null:p(t.content)}function u(n){const e=n.payload??{};if(e.type!=="item_completed")return null;const t=e.item;if(!t||typeof t!="object")return null;const o=t.type;return typeof o=="string"?{type:o,item:t}:null}export class CodexTurnBuffer{last=null;report(e){const t=e.payload??{},o=typeof t.type=="string"?t.type:null,l=u(e);if(o==="agent_message")return typeof t.message=="string"&&t.message&&(this.last=t.message),null;if(l?.type==="AgentMessage"){const s=p(l.item.content);return s&&(this.last=s),null}if(promptOfLine(e)!==null)return this.last=null,{eventType:"UserPromptSubmit",payload:{line:e}};if(e.type==="session_meta")return{eventType:"SessionStart",payload:{line:e}};if(o==="task_started")return this.last=null,null;if(o==="task_complete"){const s=this.last;return this.last=null,{eventType:"Stop",payload:{line:e,lastAgentMessage:s}}}return o==="turn_aborted"?{eventType:"TurnAborted",payload:{line:e}}:o==="exec_command_end"||o==="patch_apply_end"?{eventType:"PostToolUse",payload:{line:e}}:l?.type==="CommandExecution"||l?.type==="FileChange"||l?.type==="McpToolCall"?{eventType:"PostToolUse",payload:{line:e}}:null}}function c(n){return Array.isArray(n)?n.filter(e=>typeof e=="string").join(" "):typeof n=="string"?n:null}function x(n){const e=n.payload??{};if(e.type==="exec_command_end")return{toolName:"exec_command",toolInput:{command:c(e.command),cwd:e.cwd??null},toolResponse:{exit_code:e.exit_code??null,status:e.status??null}};if(e.type==="patch_apply_end"){const o=e.changes&&typeof e.changes=="object"?e.changes:{};return{toolName:"apply_patch",toolInput:{paths:Object.keys(o)},toolResponse:{success:e.success??null}}}const t=u(n);if(t?.type==="CommandExecution")return{toolName:"exec_command",toolInput:{command:c(t.item.command),cwd:t.item.cwd??null},toolResponse:{exit_code:t.item.exit_code??null,status:t.item.status??null}};if(t?.type==="FileChange"){const o=t.item.changes&&typeof t.item.changes=="object"?t.item.changes:{};return{toolName:"apply_patch",toolInput:{paths:Object.keys(o)},toolResponse:{status:t.item.status??null}}}return t?.type==="McpToolCall"?{toolName:typeof t.item.name=="string"?t.item.name:"mcp_tool_call",toolInput:t.item.arguments??null,toolResponse:t.item.result??t.item.status??null}:{toolName:null,toolInput:null,toolResponse:null}}function T(n,e){return typeof n.last_agent_message=="string"&&n.last_agent_message?n.last_agent_message:e??null}function h(n){const e=n.error;if(typeof e=="string"&&e)return e;if(e&&typeof e=="object"){const t=e.message;if(typeof t=="string"&&t)return t}return null}export class CodexEventSource{source="codex";events=_.codex;normalize(e,t){const o=e??{};return typeof o.payload=="string"?E(o,t):w(o,t)}}function E(n,e){const t=n.eventType||"unknown",o=i[t]??t;return{...g.normalize({...n,eventType:o},e),source:"codex"}}function w(n,e){const t=n.payload?.line??{},o=t.payload??{},l=n.eventType||"unknown",s={};if(l==="UserPromptSubmit")s.prompt=promptOfLine(t)??"";else if(l==="Stop"){s.last_assistant_message=T(o,n.payload?.lastAgentMessage);const r=h(o);r&&(s.error=r)}else l==="TurnAborted"?(s.reason=o.reason??null,s.duration_ms=o.duration_ms??null):l==="SessionStart"&&(s.source="rollout");t.ordinal!==void 0&&(s.seq=t.ordinal);const{toolName:m,toolInput:y,toolResponse:d}=x(t),f={eventType:l,toolName:m,toolInput:a(y),toolResponse:a(d),cwd:n.cwd??null,raw:{...s,turn_id:o.turn_id??null,call_id:o.call_id??null}};return{projectId:e,source:"codex",eventType:l,sessionId:n.sessionId,payload:JSON.stringify(f)}}export const CODEX_EVENT_SOURCE=new CodexEventSource;
@@ -1 +1 @@
1
- import{createReadStream as f}from"node:fs";import{createInterface as u}from"node:readline";const m=new Set(["image/png","image/jpeg","image/gif","image/webp"]),p=10*1024*1024,l=/^data:([^;,]+);base64,(.*)$/s;function y(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!i||typeof i!="object")continue;const o=i;if(o.type!=="image")continue;const n=typeof o.image_url=="string"?o.image_url:null;if(!n)continue;const c=l.exec(n);if(!c)continue;const r=c[1];if(!m.has(r))continue;const s=Buffer.from(c[2],"base64");s.length===0||s.length>p||t.push({mediaType:r,bytes:s})}return t}function g(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&t.type==="text"?String(t.text??""):"").join(""):""}export const CODEX_IMAGES={async sessionImages({transcriptPath:e}){if(!e)return null;const t=[],i=u({input:f(e,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const o of i){if(!o.includes('"type":"image"'))continue;const n=JSON.parse(o);if(n.type!=="event_msg")continue;const c=n.payload;if(c?.type!=="item_completed")continue;const r=c.item;if(r?.type!=="UserMessage")continue;const s=r.content,a=y(s);a.length!==0&&t.push({text:g(s),at:typeof n.timestamp=="string"?n.timestamp:null,images:a})}}catch{return null}finally{i.close()}return t}};
1
+ import{createReadStream as f}from"node:fs";import{createInterface as u}from"node:readline";const p=new Set(["image/png","image/jpeg","image/gif","image/webp"]),m=10*1024*1024,g=/^data:([^;,]+);base64,(.*)$/s;function l(e){if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!i||typeof i!="object")continue;const o=i;if(o.type!=="image")continue;const n=typeof o.image_url=="string"?o.image_url:null;if(!n)continue;const r=g.exec(n);if(!r)continue;const a=r[1];if(!p.has(a))continue;const s=Buffer.from(r[2],"base64");s.length===0||s.length>m||t.push({mediaType:a,bytes:s})}return t}function y(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"&&t.type==="text"?String(t.text??""):"").join(""):""}export const CODEX_IMAGES={async sessionImages({transcriptPath:e}){if(!e)return null;const t=[],i=u({input:f(e,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const o of i){if(!o.includes('"type":"image"'))continue;const n=JSON.parse(o);if(n.type!=="event_msg")continue;const r=n.payload;if(r?.type!=="item_completed")continue;const a=r.item;if(a?.type!=="UserMessage")continue;const s=a.content,c=l(s);c.length!==0&&t.push({text:y(s),at:typeof n.timestamp=="string"?n.timestamp:null,images:c})}}catch{return null}finally{i.close()}return t}};
@@ -1 +1 @@
1
- import{CODEX_ASSETS as o}from"./assets.js";import{CODEX_CAPTURE as r}from"./capture.js";import{CODEX_CONFIG as e}from"./config.js";import{CODEX_DETECTOR as E}from"./detect.js";import{CODEX_EVENT_SOURCE as t}from"./event-source.js";import{CODEX_IMAGES as m}from"./images.js";import{CODEX_NARRATION as C}from"./narration.js";import{CODEX_MESSAGING as O}from"./messaging.js";import{CODEX_PLUGINS as i}from"./plugins.js";import{CODEX_PLUGIN_STATE as p}from"./plugin-state.js";import{CODEX_PROVISION as s}from"./provision.js";import{CODEX_QUESTIONS as _}from"./questions.js";import{CODEX_RESUME as f}from"./resume.js";import{CODEX_LOG_SOURCE as D}from"./rollout.js";import{CODEX_COMMANDS as S}from"./commands.js";import{CODEX_LIVENESS as X}from"./liveness.js";import{CODEX_TITLES as n}from"./titles.js";export{CODEX_DETECTOR}from"./detect.js";export{CODEX_PLUGIN_STATE}from"./plugin-state.js";export{CODEX_IMAGES}from"./images.js";export{CODEX_NARRATION}from"./narration.js";export{CODEX_MESSAGING}from"./messaging.js";export{CODEX_QUESTIONS}from"./questions.js";export{CODEX_RESUME}from"./resume.js";export{CODEX_EVENT_SOURCE,CodexEventSource,CodexTurnBuffer}from"./event-source.js";export{CODEX_LOG_SOURCE,CodexLogSource}from"./rollout.js";export{CODEX_CAPTURE}from"./capture.js";export{codexInterruptMarkerAt}from"./transcript.js";export{CODEX_PLUGINS,createCodexPluginSurface,CODEX_MARKETPLACE}from"./plugins.js";export{CODEX_CONFIG,ensureTrustAccepted as ensureCodexTrustAccepted}from"./config.js";export{CODEX_PROVISION,codexProvisionCheck}from"./provision.js";export*from"./mcp.js";export*from"./toml.js";export{CODEX_COMMANDS}from"./commands.js";export{CODEX_LIVENESS,codexLivenessById,codexThreadLockDir,CODEX_LOCK_GRACE_MS}from"./liveness.js";export{CODEX_TITLES,codexSessionTitleOf,codexSetSessionTitle}from"./titles.js";export const CODEX_DRIVER={id:"codex",displayName:"Codex",capabilities:["assets","detect","plugins","pluginState","messaging","resume","events","capture","logs","config","commands","provision","liveness","images","narration","questions"],assets:o,detect:E,plugins:i,pluginState:p,messaging:O,resume:f,events:t,capture:r,logs:D,config:e,commands:S,provision:s,liveness:X,images:m,narration:C,questions:_,titles:n};
1
+ import{CODEX_ASSETS as o}from"./assets.js";import{CODEX_CAPTURE as r}from"./capture.js";import{CODEX_CONFIG as e}from"./config.js";import{CODEX_DETECTOR as E}from"./detect.js";import{CODEX_EVENT_SOURCE as t}from"./event-source.js";import{CODEX_IMAGES as s}from"./images.js";import{CODEX_NARRATION as m}from"./narration.js";import{CODEX_MESSAGING as C}from"./messaging.js";import{CODEX_PLUGINS as O}from"./plugins.js";import{CODEX_PLUGIN_STATE as i}from"./plugin-state.js";import{CODEX_PROVISION as p}from"./provision.js";import{CODEX_QUESTIONS as _}from"./questions.js";import{CODEX_RESUME as a}from"./resume.js";import{CODEX_LOG_SOURCE as f}from"./rollout.js";import{CODEX_COMMANDS as D}from"./commands.js";import{CODEX_LIVENESS as S}from"./liveness.js";import{CODEX_TITLES as X}from"./titles.js";export{CODEX_DETECTOR}from"./detect.js";export{CODEX_PLUGIN_STATE}from"./plugin-state.js";export{CODEX_IMAGES}from"./images.js";export{CODEX_NARRATION}from"./narration.js";export{CODEX_MESSAGING}from"./messaging.js";export{CODEX_QUESTIONS}from"./questions.js";export{CODEX_RESUME}from"./resume.js";export{CODEX_EVENT_SOURCE,CodexEventSource,CodexTurnBuffer}from"./event-source.js";export{CODEX_LOG_SOURCE,CodexLogSource}from"./rollout.js";export{CODEX_CAPTURE}from"./capture.js";export{codexInterruptMarkerAt}from"./transcript.js";export{CODEX_PLUGINS,createCodexPluginSurface,CODEX_MARKETPLACE}from"./plugins.js";export{CODEX_CONFIG,ensureTrustAccepted as ensureCodexTrustAccepted}from"./config.js";export{CODEX_PROVISION,codexProvisionCheck}from"./provision.js";export*from"./mcp.js";export*from"./toml.js";export{CODEX_COMMANDS}from"./commands.js";export{CODEX_LIVENESS,codexLivenessById,codexThreadLockDir,CODEX_LOCK_GRACE_MS}from"./liveness.js";export{CODEX_TITLES,codexSessionTitleOf,codexSetSessionTitle}from"./titles.js";export const CODEX_DRIVER={id:"codex",displayName:"Codex",capabilities:["assets","detect","plugins","pluginState","messaging","resume","events","capture","logs","config","commands","provision","liveness","images","narration","questions"],assets:o,detect:E,plugins:O,pluginState:i,messaging:C,resume:a,events:t,capture:r,logs:f,config:e,commands:D,provision:p,liveness:S,images:s,narration:m,questions:_,titles:X};
@@ -1 +1 @@
1
- import{readdirSync as f,statSync as m}from"node:fs";import u from"node:path";import{codexHome as w}from"./home.js";export const CODEX_LOCK_GRACE_MS=9e4;const h=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.lock$/i;export function codexThreadLockDir(o){return u.join(w(o),"thread-writer-locks")}async function S(o,a){const{spawn:r}=await import("node:child_process"),i=t=>t.replace(/'/g,"''"),s=["$results = @()",...o.map(t=>{const p=u.win32.join(a,t);return`try { [void][IO.File]::Open('${i(p)}','Open','ReadWrite','None') } catch [IO.IOException] { $results += '${i(t)}' }`}),'$results -join "`n"'].join("; ");return new Promise(t=>{let p="";const c=r("powershell",["-NoProfile","-NonInteractive","-Command",s],{windowsHide:!0,stdio:["ignore","pipe","pipe"]}),e=setTimeout(()=>{c.kill("SIGKILL"),t(new Set)},5e3);c.stdout?.on("data",n=>p+=n.toString()),c.on("error",()=>{clearTimeout(e),t(new Set)}),c.on("close",()=>{clearTimeout(e),t(new Set(p.split(/\r?\n/).map(n=>n.trim()).filter(Boolean)))})})}async function y(){return new Set}const d=new Map;export async function codexLivenessById(o,a=Date.now()){const r=codexThreadLockDir(o);let i;try{i=f(r)}catch{return new Map}const s=i.filter(e=>h.test(e)),p=await(s.length===0?async()=>new Set:process.platform==="win32"?e=>S(e,r):()=>y())(s),c=new Map;for(const e of s){const n=e.replace(/\.lock$/i,"");if(p.has(e)){d.set(n,a),c.set(n,!0);continue}let l=d.get(n);if(l===void 0){try{l=m(u.join(r,e)).mtimeMs}catch{continue}d.set(n,l)}a-l>=CODEX_LOCK_GRACE_MS&&c.set(n,!1)}return c}export const CODEX_LIVENESS={harness:"codex",alive(o){return codexLivenessById().then(a=>{if(!o)return a;const r=new Map;for(const i of o){const s=a.get(i);s!==void 0&&r.set(i,s)}return r})}};
1
+ import{readdirSync as u,statSync as m}from"node:fs";import p from"node:path";import{codexHome as w}from"./home.js";export const CODEX_LOCK_GRACE_MS=9e4;const d=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.lock$/i;export function codexThreadLockDir(o){return p.join(w(o),"thread-writer-locks")}async function S(o,l){const{spawn:n}=await import("node:child_process"),r=t=>t.replace(/'/g,"''"),i=["$results = @()",...o.map(t=>{const s=p.win32.join(l,t);return`try { [void][IO.File]::Open('${r(s)}','Open','ReadWrite','None') } catch [IO.IOException] { $results += '${r(t)}' }`}),'$results -join "`n"'].join("; ");return new Promise(t=>{let s="";const e=n("powershell",["-NoProfile","-NonInteractive","-Command",i],{windowsHide:!0,stdio:["ignore","pipe","pipe"]}),c=setTimeout(()=>{e.kill("SIGKILL"),t(new Set)},5e3);e.stdout?.on("data",a=>s+=a.toString()),e.on("error",()=>{clearTimeout(c),t(new Set)}),e.on("close",()=>{clearTimeout(c),t(new Set(s.split(/\r?\n/).map(a=>a.trim()).filter(Boolean)))})})}async function h(){return new Set}const f=new Map;export async function codexLivenessById(o,l=Date.now()){const n=codexThreadLockDir(o);let r;try{r=u(n)}catch{return new Map}const i=r.filter(e=>d.test(e)),t=await(i.length===0?async()=>new Set:process.platform==="win32"?e=>S(e,n):()=>h())(i),s=new Map;for(const e of i){const c=e.replace(/\.lock$/i,"");if(t.has(e)){f.set(c,l),s.set(c,!0);continue}let a=f.get(c);if(a===void 0){try{a=m(p.join(n,e)).mtimeMs}catch{continue}f.set(c,a)}l-a>=CODEX_LOCK_GRACE_MS&&s.set(c,!1)}return s}export const CODEX_LIVENESS={harness:"codex",alive(o){return codexLivenessById().then(l=>{if(!o)return l;const n=new Map;for(const r of o){const i=l.get(r);i!==void 0&&n.set(r,i)}return n})}};
@@ -1 +1 @@
1
- import{readFile as d,writeFile as g,access as T,mkdir as k}from"node:fs/promises";import $ from"node:path";import{parse as m}from"smol-toml";import{CodexTomlCorruptError as v,parseSectionEntries as w,removeTomlSection as M,renderTomlHeader as S,renderTomlKey as x,renderTomlString as f,sameKey as y,splitTomlSections as l,upsertTomlSection as _}from"./toml.js";export function readCodexMcpFromText(r){let e;try{e=m(r)}catch{return{}}const n=e.mcp_servers;if(!n||typeof n!="object"||Array.isArray(n))return{};const t={};for(const[o,s]of Object.entries(n)){const c=E(s);c&&(t[o]=c)}return t}function j(r){if(!r||typeof r!="object"||Array.isArray(r))return;const e={};for(const[n,t]of Object.entries(r))typeof t=="string"&&(e[n]=t);return Object.keys(e).length>0?e:void 0}function E(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const e=r;if(typeof e.url=="string"){const t={url:e.url},o=j(e.http_headers);return o&&(t.headers=o),typeof e.bearer_token_env_var=="string"&&(t.bearerTokenEnvVar=e.bearer_token_env_var),t}if(typeof e.command!="string")return null;const n={command:e.command};if(Array.isArray(e.args)){const t=e.args.filter(o=>typeof o=="string");t.length>0&&(n.args=t)}if(e.env&&typeof e.env=="object"&&!Array.isArray(e.env)){const t={};for(const[o,s]of Object.entries(e.env))typeof s=="string"&&(t[o]=s);Object.keys(t).length>0&&(n.env=t)}return n}function b(r,e,n,t,o){const s=[];if("command"in e)s.push(`command = ${f(e.command)}`),e.args&&e.args.length>0&&s.push(`args = [${e.args.map(f).join(", ")}]`);else{s.push(`url = ${f(e.url)}`),e.bearerTokenEnvVar&&s.push(`bearer_token_env_var = ${f(e.bearerTokenEnvVar)}`);const a=Object.entries(e.headers??{});a.length>0&&s.push(`http_headers = { ${a.map(([i,u])=>`${x(i)} = ${f(u)}`).join(", ")} }`)}if(o&&n){const a=new Set(["command","args","env","url","http_headers","bearer_token_env_var"]);for(const[i,u]of w(n.lines.slice(1)))a.has(i)||s.push(u)}const c=Object.entries("env"in e?e.env??{}:{}),p=o&&t?w(t.lines.slice(1)).filter(([a])=>!(a in("env"in e?e.env??{}:{}))):[];if(c.length>0||p.length>0){s.push(""),s.push(S([...r,"env"]));for(const[a,i]of c)s.push(`${x(a)} = ${f(i)}`);for(const[,a]of p)s.push(a)}return s}export function upsertCodexMcpInText(r,e,n){const t=["mcp_servers",e],o=A(r);if(o)throw o;const s=l(r),c=s.find(i=>y(i.key,t)),p=s.find(i=>y(i.key,[...t,"env"])),a=_(r,t,b(t,n,c,p,!0));try{return m(a),a}catch{const i=_(r,t,b(t,n,c,p,!1));try{return m(i),i}catch(u){throw new v(`unable to produce valid TOML for [mcp_servers.${e}]: ${u instanceof Error?u.message:String(u)}`)}}}export function removeCodexMcpFromText(r,e){return M(r,["mcp_servers",e])}function A(r){return l(r)[0].lines.find(t=>/^\s*mcp_servers\s*=/.test(t))?new v('~/.codex/config.toml defines "mcp_servers" as an inline value \u2014 weave only manages the [mcp_servers.<name>] section form'):null}async function O(r){try{return await d(r,"utf-8")}catch{return""}}async function h(r){try{return await T(r),!0}catch{return!1}}export async function readCodexMcpServers(r){return await h(r)?readCodexMcpFromText(await d(r,"utf-8")):{}}export async function codexMcpExists(r,e){return await h(e)?C(await d(e,"utf-8"),["mcp_servers",r]):!1}function C(r,e){return l(r).some(n=>y(n.key,e))}export async function writeCodexMcpServer(r,e,n){const t=await O(n);if(t.trim()!=="")try{m(t)}catch(o){throw new v(`${n} is not valid TOML \u2014 refusing to write: ${o instanceof Error?o.message:String(o)}`)}await k($.dirname(n),{recursive:!0}),await g(n,upsertCodexMcpInText(t,r,e),"utf-8")}export async function removeCodexMcpServer(r,e){if(!await h(e))return!1;const n=await d(e,"utf-8");try{m(n)}catch(s){throw new v(`${e} is not valid TOML \u2014 refusing to write: ${s instanceof Error?s.message:String(s)}`)}const{text:t,removed:o}=removeCodexMcpFromText(n,r);return o&&await g(e,t,"utf-8"),o}
1
+ import{readFile as l,writeFile as g,access as T,mkdir as $}from"node:fs/promises";import j from"node:path";import{parse as m}from"smol-toml";import{CodexTomlCorruptError as v,parseSectionEntries as w,removeTomlSection as k,renderTomlHeader as S,renderTomlKey as _,renderTomlString as f,sameKey as y,splitTomlSections as d,upsertTomlSection as x}from"./toml.js";export function readCodexMcpFromText(r){let e;try{e=m(r)}catch{return{}}const n=e.mcp_servers;if(!n||typeof n!="object"||Array.isArray(n))return{};const t={};for(const[s,o]of Object.entries(n)){const c=M(o);c&&(t[s]=c)}return t}function A(r){if(!r||typeof r!="object"||Array.isArray(r))return;const e={};for(const[n,t]of Object.entries(r))typeof t=="string"&&(e[n]=t);return Object.keys(e).length>0?e:void 0}function M(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const e=r;if(typeof e.url=="string"){const t={url:e.url},s=A(e.http_headers);return s&&(t.headers=s),typeof e.bearer_token_env_var=="string"&&(t.bearerTokenEnvVar=e.bearer_token_env_var),t}if(typeof e.command!="string")return null;const n={command:e.command};if(Array.isArray(e.args)){const t=e.args.filter(s=>typeof s=="string");t.length>0&&(n.args=t)}if(e.env&&typeof e.env=="object"&&!Array.isArray(e.env)){const t={};for(const[s,o]of Object.entries(e.env))typeof o=="string"&&(t[s]=o);Object.keys(t).length>0&&(n.env=t)}return n}function b(r,e,n,t,s){const o=[];if("command"in e)o.push(`command = ${f(e.command)}`),e.args&&e.args.length>0&&o.push(`args = [${e.args.map(f).join(", ")}]`);else{o.push(`url = ${f(e.url)}`),e.bearerTokenEnvVar&&o.push(`bearer_token_env_var = ${f(e.bearerTokenEnvVar)}`);const a=Object.entries(e.headers??{});a.length>0&&o.push(`http_headers = { ${a.map(([i,u])=>`${_(i)} = ${f(u)}`).join(", ")} }`)}if(s&&n){const a=new Set(["command","args","env","url","http_headers","bearer_token_env_var"]);for(const[i,u]of w(n.lines.slice(1)))a.has(i)||o.push(u)}const c=Object.entries("env"in e?e.env??{}:{}),p=s&&t?w(t.lines.slice(1)).filter(([a])=>!(a in("env"in e?e.env??{}:{}))):[];if(c.length>0||p.length>0){o.push(""),o.push(S([...r,"env"]));for(const[a,i]of c)o.push(`${_(a)} = ${f(i)}`);for(const[,a]of p)o.push(a)}return o}export function upsertCodexMcpInText(r,e,n){const t=["mcp_servers",e],s=O(r);if(s)throw s;const o=d(r),c=o.find(i=>y(i.key,t)),p=o.find(i=>y(i.key,[...t,"env"])),a=x(r,t,b(t,n,c,p,!0));try{return m(a),a}catch{const i=x(r,t,b(t,n,c,p,!1));try{return m(i),i}catch(u){throw new v(`unable to produce valid TOML for [mcp_servers.${e}]: ${u instanceof Error?u.message:String(u)}`)}}}export function removeCodexMcpFromText(r,e){return k(r,["mcp_servers",e])}function O(r){return d(r)[0].lines.find(e=>/^\s*mcp_servers\s*=/.test(e))?new v('~/.codex/config.toml defines "mcp_servers" as an inline value \u2014 weave only manages the [mcp_servers.<name>] section form'):null}async function E(r){try{return await l(r,"utf-8")}catch{return""}}async function h(r){try{return await T(r),!0}catch{return!1}}export async function readCodexMcpServers(r){return await h(r)?readCodexMcpFromText(await l(r,"utf-8")):{}}export async function codexMcpExists(r,e){return await h(e)?C(await l(e,"utf-8"),["mcp_servers",r]):!1}function C(r,e){return d(r).some(n=>y(n.key,e))}export async function writeCodexMcpServer(r,e,n){const t=await E(n);if(t.trim()!=="")try{m(t)}catch(s){throw new v(`${n} is not valid TOML \u2014 refusing to write: ${s instanceof Error?s.message:String(s)}`)}await $(j.dirname(n),{recursive:!0}),await g(n,upsertCodexMcpInText(t,r,e),"utf-8")}export async function removeCodexMcpServer(r,e){if(!await h(e))return!1;const n=await l(e,"utf-8");try{m(n)}catch(o){throw new v(`${e} is not valid TOML \u2014 refusing to write: ${o instanceof Error?o.message:String(o)}`)}const{text:t,removed:s}=removeCodexMcpFromText(n,r);return s&&await g(e,t,"utf-8"),s}
@@ -1,4 +1,4 @@
1
- import{existsSync as d,readFileSync as l}from"node:fs";import a from"node:path";import{HARNESS_LIFECYCLE as u}from"@weavecode/core";import{CODEX_SIDE_QUESTION as f}from"./side-question.js";function m(){const n=process.env.WEAVE_CODEX_BIN;if(n&&n.trim())return{bin:n.trim(),prefix:[]};if(process.platform!=="win32")return{bin:"codex",prefix:[]};for(const t of(process.env.PATH??"").split(a.delimiter)){if(!t)continue;const s=a.join(t,"codex.exe");if(d(s))return{bin:s,prefix:[]};const e=a.join(t,"codex.cmd");if(d(e))try{const o=l(e,"utf8").split(/\r?\n/).map(c=>c.trim()).find(c=>/^".+?\.exe"/.test(c)),r=/^"(.+?\.exe)"/.exec(o??"");if(r&&d(r[1]))return{bin:r[1],prefix:[]}}catch{}const i=a.join(t,"node_modules","@openai","codex","bin","codex.js");if(d(i))return{bin:process.execPath,prefix:[i]}}return{bin:"codex",prefix:[]}}export const CODEX_QUEUED_PROMPT={command(n,t){const{bin:s,prefix:e}=m();return{bin:s,args:[...e,"queue","--thread",n,"--message",t]}},timeoutMs:3e4},CODEX_ATTACH={kinds:["file","image"],composePrompt(n,t){const s=t.filter(i=>!n.includes(i.path));if(s.length===0)return n;const e=s.map(i=>i.path).join(`
1
+ import{existsSync as a,readFileSync as l}from"node:fs";import d from"node:path";import{HARNESS_LIFECYCLE as u}from"@weavecode/core";import{CODEX_SIDE_QUESTION as f}from"./side-question.js";function h(){const n=process.env.WEAVE_CODEX_BIN;if(n&&n.trim())return{bin:n.trim(),prefix:[]};if(process.platform!=="win32")return{bin:"codex",prefix:[]};for(const t of(process.env.PATH??"").split(d.delimiter)){if(!t)continue;const s=d.join(t,"codex.exe");if(a(s))return{bin:s,prefix:[]};const e=d.join(t,"codex.cmd");if(a(e))try{const o=l(e,"utf8").split(/\r?\n/).map(c=>c.trim()).find(c=>/^".+?\.exe"/.test(c)),r=/^"(.+?\.exe)"/.exec(o??"");if(r&&a(r[1]))return{bin:r[1],prefix:[]}}catch{}const i=d.join(t,"node_modules","@openai","codex","bin","codex.js");if(a(i))return{bin:process.execPath,prefix:[i]}}return{bin:"codex",prefix:[]}}export const CODEX_QUEUED_PROMPT={command(n,t){const{bin:s,prefix:e}=h();return{bin:s,args:[...e,"queue","--thread",n,"--message",t]}},timeoutMs:3e4},CODEX_ATTACH={kinds:["file","image"],composePrompt(n,t){const s=t.filter(i=>!n.includes(i.path));if(s.length===0)return n;const e=s.map(i=>i.path).join(`
2
2
  `);return n?`${n}
3
3
 
4
- ${e}`:e}};const h={kinds:["file","dir"],lines:!1,expression:({path:n,kind:t})=>t==="dir"?`${n}/`:n,recognize:n=>{const t=[];for(const s of n.matchAll(/(?:^|\s)"([^"]*\s[^"]*)"(?=\s|$)/g)){const e=s[1],i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length+2;e.startsWith("/")||e.includes(":")||t.push({start:i,end:o,ref:n.slice(i,o),path:e,kind:"file"})}for(const s of n.matchAll(/(?:^|\s)([^\s"]+)(?=\s|$)/g)){const e=s[1];if(!/[./]/.test(e))continue;const i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length;if(e.startsWith("/")||e.includes(":")||e.includes("\\")||t.some(p=>i>=p.start&&o<=p.end))continue;const r=e.endsWith("/"),c=r?e.slice(0,-1):e;c&&t.push({start:i,end:o,ref:n.slice(i,o),path:c,kind:r?"dir":"file"})}return t.sort((s,e)=>s.start-e.start)}};export const CODEX_MESSAGING={harness:"codex",discovery:!1,prompt:null,promptInbox:null,queuedPrompt:CODEX_QUEUED_PROMPT,inject:null,headless:null,idleSignals:[...u.codex.close,"SessionEnd"],paneEnvSource:"launch",attach:CODEX_ATTACH,pathRefs:h,sideQuestion:f,unsupportedReasons:{discovery:"Codex event ingestion is pending research (BACKLOG \xA710-6); sessions are not discoverable",prompt:"Codex has no native peer-messaging channel; prompts reach it via its own queue or terminal text injection",inject:"Codex has no synchronous injection channel yet (pending research)",headless:"Codex resume is pending research",watch:"Codex error-ended turns emit no Stop; those rounds never fire idle/turnEnd"}};
4
+ ${e}`:e}};const m={kinds:["file","dir"],lines:!1,expression:({path:n,kind:t})=>t==="dir"?`${n}/`:n,recognize:n=>{const t=[];for(const s of n.matchAll(/(?:^|\s)"([^"]*\s[^"]*)"(?=\s|$)/g)){const e=s[1],i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length+2;e.startsWith("/")||e.includes(":")||t.push({start:i,end:o,ref:n.slice(i,o),path:e,kind:"file"})}for(const s of n.matchAll(/(?:^|\s)([^\s"]+)(?=\s|$)/g)){const e=s[1];if(!/[./]/.test(e))continue;const i=s.index+(s[0].startsWith(" ")?1:0),o=i+e.length;if(e.startsWith("/")||e.includes(":")||e.includes("\\")||t.some(p=>i>=p.start&&o<=p.end))continue;const r=e.endsWith("/"),c=r?e.slice(0,-1):e;c&&t.push({start:i,end:o,ref:n.slice(i,o),path:c,kind:r?"dir":"file"})}return t.sort((s,e)=>s.start-e.start)}};export const CODEX_MESSAGING={harness:"codex",discovery:!1,prompt:null,promptInbox:null,queuedPrompt:CODEX_QUEUED_PROMPT,inject:null,headless:null,idleSignals:[...u.codex.close,"SessionEnd"],paneEnvSource:"launch",attach:CODEX_ATTACH,pathRefs:m,sideQuestion:f,unsupportedReasons:{discovery:"Codex event ingestion is pending research (BACKLOG \xA710-6); sessions are not discoverable",prompt:"Codex has no native peer-messaging channel; prompts reach it via its own queue or terminal text injection",inject:"Codex has no synchronous injection channel yet (pending research)",headless:"Codex resume is pending research",watch:"Codex error-ended turns emit no Stop; those rounds never fire idle/turnEnd"}};
@@ -1 +1 @@
1
- import{createReadStream as a}from"node:fs";import{createInterface as i}from"node:readline";export const CODEX_NARRATION={async sessionNarration({transcriptPath:n}){if(!n)return null;const e=[],t=i({input:a(n,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const r of t){const s=l(r);s&&e.push(s)}}catch{return null}finally{t.close()}return e},lineParser:l};function l(n){if(!n.includes('"AgentMessage"'))return null;let e;try{e=JSON.parse(n)}catch{return null}if(e.type!=="event_msg")return null;const t=e.payload;if(t?.type!=="AgentMessage")return null;const r=typeof t.message=="string"?t.message:"";return r.trim()?{at:typeof e.timestamp=="string"?e.timestamp:null,text:r}:null}
1
+ import{createReadStream as l}from"node:fs";import{createInterface as i}from"node:readline";export const CODEX_NARRATION={async sessionNarration({transcriptPath:n}){if(!n)return null;const t=[],e=i({input:l(n,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const r of e){const s=a(r);s&&t.push(s)}}catch{return null}finally{e.close()}return t},lineParser:a};function a(n){if(!n.includes('"AgentMessage"'))return null;let t;try{t=JSON.parse(n)}catch{return null}if(t.type!=="event_msg")return null;const e=t.payload;if(e?.type!=="AgentMessage")return null;const r=typeof e.message=="string"?e.message:"";return r.trim()?{at:typeof t.timestamp=="string"?t.timestamp:null,text:r}:null}
@@ -1 +1 @@
1
- import{access as u,mkdir as p,readFile as n,writeFile as d}from"node:fs/promises";import{homedir as s}from"node:os";import m from"node:path";import{parse as f}from"smol-toml";import{CODEX_ASSETS as l}from"./assets.js";import{CodexTomlCorruptError as b,upsertCodexPluginEnabledInText as w}from"./toml.js";const c=r=>u(r).then(()=>!0,()=>!1);async function E(r){if(!await c(r))return{};try{const t=f(await n(r,"utf-8")).plugins;if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[o,a]of Object.entries(t))a&&typeof a=="object"&&typeof a.enabled=="boolean"&&(e[o]=a.enabled);return e}catch{return{}}}export const CODEX_PLUGIN_STATE={readGlobalEnabled:()=>E(l.userConfigFile(s())),async writeGlobalEnabled(r,i){const t=l.userConfigFile(s());let e="";if(await c(t)){e=await n(t,"utf-8");try{f(e)}catch(o){throw new b(`${t} is not valid TOML \u2014 refusing to write: ${o instanceof Error?o.message:String(o)}`)}}await p(m.dirname(t),{recursive:!0}),await d(t,w(e,r,i),"utf-8")}};
1
+ import{access as l,mkdir as m,readFile as i,writeFile as u}from"node:fs/promises";import{homedir as n}from"node:os";import p from"node:path";import{parse as s}from"smol-toml";import{CODEX_ASSETS as f}from"./assets.js";import{CodexTomlCorruptError as d,upsertCodexPluginEnabledInText as b}from"./toml.js";const c=e=>l(e).then(()=>!0,()=>!1);async function w(e){if(!await c(e))return{};try{const a=s(await i(e,"utf-8")).plugins;if(!a||typeof a!="object"||Array.isArray(a))return{};const r={};for(const[o,t]of Object.entries(a))t&&typeof t=="object"&&typeof t.enabled=="boolean"&&(r[o]=t.enabled);return r}catch{return{}}}export const CODEX_PLUGIN_STATE={readGlobalEnabled:()=>w(f.userConfigFile(n())),async writeGlobalEnabled(e,a){const r=f.userConfigFile(n());let o="";if(await c(r)){o=await i(r,"utf-8");try{s(o)}catch(t){throw new d(`${r} is not valid TOML \u2014 refusing to write: ${t instanceof Error?t.message:String(t)}`)}}await m(p.dirname(r),{recursive:!0}),await u(r,b(o,e,a),"utf-8")}};
@@ -1,3 +1,3 @@
1
- import{spawn as C}from"node:child_process";import{homedir as I}from"node:os";import{lstat as A,mkdir as v,readFile as $,readdir as P,writeFile as E}from"node:fs/promises";import c from"node:path";import{CODEX_ASSETS as U}from"./assets.js";import{parseSectionEntries as L,removeTomlSection as G,splitTomlSections as O,upsertCodexPluginEnabledInText as S}from"./toml.js";export const CODEX_MARKETPLACE="weave";const K=6e4,_=2e3,M=64*1024;export function codexCommandLine(a){return["codex",...a.map(g=>`"${g.replace(/"/g,'\\"')}"`)].join(" ")}function N(a){if(!(a.exitCode!==null||a.signalCode!==null)){if(process.platform==="win32"&&a.pid!==void 0){C("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref();return}a.kill("SIGKILL")}}function D(a){return a.length>_?`${a.slice(0,_)}\u2026`:a}const q=(a,g)=>new Promise((y,u)=>{const x=process.platform==="win32",l=C(x?process.env.ComSpec||"cmd.exe":"codex",x?["/d","/s","/c",codexCommandLine(a)]:a,{windowsHide:!0,windowsVerbatimArguments:x,stdio:["ignore","pipe","pipe"]}),d=`codex ${a.join(" ")}`;let p="",f="",m=!1;const b=e=>{m||(m=!0,clearTimeout(t),u(new Error(D(e))))},t=setTimeout(()=>{N(l),b(`${d}: timed out after ${g.timeoutMs}ms`)},g.timeoutMs);l.stdout?.setEncoding("utf8"),l.stdout?.on("data",e=>{p.length<M&&(p+=e)}),l.stderr?.setEncoding("utf8"),l.stderr?.on("data",e=>{f.length<M&&(f+=e)}),l.on("error",e=>b(`${d}: ${e.message}`)),l.on("close",e=>{if(m)return;if(m=!0,clearTimeout(t),e===0){y({stdout:p,stderr:f});return}const i=[f,p].filter(Boolean).join(`
2
- `).trim()||`exit ${e}`;u(new Error(D(`${d}: ${i}`)))})});export function createCodexPluginSurface(a={}){const g=a.exec??q,y=t=>g(t,{timeoutMs:K}),u=()=>U.userConfigFile(I()),x=()=>c.join(I(),".codex","plugins","cache"),l=(t,e)=>`${t}@${e??CODEX_MARKETPLACE}`,d=async()=>{try{return await $(u(),"utf8")}catch{return null}},p=t=>{if(!t)return{};const e=O(t),i={};for(const n of e)if(!(!n.key||n.key.length!==2||n.key[0]!=="plugins"))for(const[r,o]of L(n.lines.slice(1))){if(r!=="enabled")continue;const s=o.split("=")[1]?.trim();(s==="true"||s==="false")&&(i[n.key[1]]=s==="true")}return i},f=async()=>{const t=x(),e={};let i;try{i=await P(t,{withFileTypes:!0})}catch{return e}for(const n of i){if(!n.isDirectory()&&!n.isSymbolicLink())continue;const r=c.join(t,n.name);let o;try{o=await P(r,{withFileTypes:!0})}catch{continue}for(const s of o){if(!s.isDirectory()&&!s.isSymbolicLink())continue;const w=c.join(r,s.name);let h;try{h=await P(w,{withFileTypes:!0})}catch{continue}const k=h.filter(j=>j.isDirectory()||j.isSymbolicLink());if(k.length===0)continue;const T=k.map(j=>j.name).sort().pop(),F=`${s.name}@${n.name}`;e[F]=[{scope:"user",installPath:c.join(w,T),version:T}]}}return e},m=(t,e,i)=>{const n=e?.[e.length-1];return{key:t,alreadyInstalled:i,...n?.scope?{scope:n.scope}:{},...n?.installPath?{installPath:n.installPath}:{},...n?.version?{version:n.version}:{}}},b=async(t,e,i)=>{if(!t.dir)throw new Error(`marketplace dir required for ${e}@${t.name}`);if((await A(t.dir)).isSymbolicLink())return;const n=c.join(t.dir,".claude-plugin","marketplace.json");let r={};try{r=JSON.parse(await $(n,"utf8"))}catch{r={}}const o=Array.isArray(r.plugins)?[...r.plugins]:[],s=`./${c.relative(t.dir,i).split(c.sep).join("/")}`,w={name:e,source:s},h=o.findIndex(k=>k?.name===e);h>=0?o[h]=w:o.push(w),r.name=t.name,r.owner||(r.owner={name:"weave"}),r.plugins=o,await v(c.dirname(n),{recursive:!0}),await E(n,`${JSON.stringify(r,null,2)}
3
- `,"utf8")};return{projectPluginDir:t=>c.join(t,".codex","plugins"),pluginKey:l,parsePluginKey(t){const e=t.lastIndexOf("@");return e>0?{name:t.slice(0,e),market:t.slice(e+1)}:{name:t,market:CODEX_MARKETPLACE}},async globalInstall(t,e={}){let i=e.name;if(!i)try{const s=JSON.parse(await $(c.join(t,".claude-plugin","plugin.json"),"utf8"));i=typeof s.name=="string"?s.name:void 0}catch{i=void 0}if(!i)throw new Error(`plugin manifest missing name: ${t}`);const n=e.marketplace,r=l(i,n?.name),o=(await f())[r];if(o&&o.length>0)return m(r,o,!0);if(n)await b(n,i,t),await y(["plugin","marketplace","add",n.dir??""]);else throw new Error(`codex plugin install requires a marketplace (got none for ${r}); weave-managed packs must come from a market directory`);return await y(["plugin","add",r,"--json"]),m(r,(await f())[r],!1)},readInstalled:f,async isInstalled(t,e){const i=(await f())[l(t,e)];return!!i&&i.length>0},async uninstall(t,e){const i=l(t,e),n=(await f())[i];!n||n.length===0||await y(["plugin","remove",i,"--json"])},async removeMarketplace(t){const e=await d();if(!e)return;const i=c.resolve(t),n=O(e);let r;for(const o of n)if(!(!o.key||o.key.length!==2||o.key[0]!=="marketplaces")){for(const[s,w]of L(o.lines.slice(1))){if(s!=="source")continue;const k=w.split("=").slice(1).join("=").trim().replace(/^"(.*)"$/,"$1");if(c.resolve(k)===i){r=o.key[1];break}}if(r)break}r&&await y(["plugin","marketplace","remove",r])},async readProjectEnabled(t,e,i){return p(await d())[l(e,i)]??!1},async setProjectEnabled(t,e,i,n){const r=l(e,n),o=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),S(o,r,i),"utf8")},async readGlobalEnabled(){return p(await d())},async writeGlobalEnabled(t,e){const i=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),S(i,t,e),"utf8")},pluginScopes:()=>["user"],async readEnabledOverrides(t){return{user:await this.readGlobalEnabled(),project:{},local:{}}},async setEnabledOverride(t,e,i,n){if(e!=="user")throw new Error(`codex plugins only support user-scope overrides (got ${e})`);const r=await d()??"";if(n==="inherit"){const{text:o,removed:s}=G(r,["plugins",i]);if(!s)return;await v(c.dirname(u()),{recursive:!0}),await E(u(),o,"utf8");return}await v(c.dirname(u()),{recursive:!0}),await E(u(),S(r,i,n==="on"),"utf8")}}}export const CODEX_PLUGINS=createCodexPluginSurface();
1
+ import{spawn as T}from"node:child_process";import{homedir as I}from"node:os";import{lstat as M,mkdir as v,readFile as S,readdir as b,writeFile as E}from"node:fs/promises";import c from"node:path";import{CODEX_ASSETS as K}from"./assets.js";import{parseSectionEntries as L,removeTomlSection as N,splitTomlSections as O,upsertCodexPluginEnabledInText as P}from"./toml.js";export const CODEX_MARKETPLACE="weave";const J=6e4,D=2e3,A=64*1024;export function codexCommandLine(a){return["codex",...a.map(y=>`"${y.replace(/"/g,'\\"')}"`)].join(" ")}function _(a){if(!(a.exitCode!==null||a.signalCode!==null)){if(process.platform==="win32"&&a.pid!==void 0){T("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref();return}a.kill("SIGKILL")}}function F(a){return a.length>D?`${a.slice(0,D)}\u2026`:a}const q=(a,y)=>new Promise((h,u)=>{const k=process.platform==="win32",l=T(k?process.env.ComSpec||"cmd.exe":"codex",k?["/d","/s","/c",codexCommandLine(a)]:a,{windowsHide:!0,windowsVerbatimArguments:k,stdio:["ignore","pipe","pipe"]}),d=`codex ${a.join(" ")}`;let p="",m="",f=!1;const $=e=>{f||(f=!0,clearTimeout(t),u(new Error(F(e))))},t=setTimeout(()=>{_(l),$(`${d}: timed out after ${y.timeoutMs}ms`)},y.timeoutMs);l.stdout?.setEncoding("utf8"),l.stdout?.on("data",e=>{p.length<A&&(p+=e)}),l.stderr?.setEncoding("utf8"),l.stderr?.on("data",e=>{m.length<A&&(m+=e)}),l.on("error",e=>$(`${d}: ${e.message}`)),l.on("close",e=>{if(f)return;if(f=!0,clearTimeout(t),e===0){h({stdout:p,stderr:m});return}const i=[m,p].filter(Boolean).join(`
2
+ `).trim()||`exit ${e}`;u(new Error(F(`${d}: ${i}`)))})});export function createCodexPluginSurface(a={}){const y=a.exec??q,h=t=>y(t,{timeoutMs:J}),u=()=>K.userConfigFile(I()),k=()=>c.join(I(),".codex","plugins","cache"),l=(t,e)=>`${t}@${e??CODEX_MARKETPLACE}`,d=async()=>{try{return await S(u(),"utf8")}catch{return null}},p=t=>{if(!t)return{};const e=O(t),i={};for(const n of e)if(!(!n.key||n.key.length!==2||n.key[0]!=="plugins"))for(const[r,o]of L(n.lines.slice(1))){if(r!=="enabled")continue;const s=o.split("=")[1]?.trim();(s==="true"||s==="false")&&(i[n.key[1]]=s==="true")}return i},m=async()=>{const t=k(),e={};let i;try{i=await b(t,{withFileTypes:!0})}catch{return e}for(const n of i){if(!n.isDirectory()&&!n.isSymbolicLink())continue;const r=c.join(t,n.name);let o;try{o=await b(r,{withFileTypes:!0})}catch{continue}for(const s of o){if(!s.isDirectory()&&!s.isSymbolicLink())continue;const w=c.join(r,s.name);let g;try{g=await b(w,{withFileTypes:!0})}catch{continue}const x=g.filter(j=>j.isDirectory()||j.isSymbolicLink());if(x.length===0)continue;const C=x.map(j=>j.name).sort().pop(),G=`${s.name}@${n.name}`;e[G]=[{scope:"user",installPath:c.join(w,C),version:C}]}}return e},f=(t,e,i)=>{const n=e?.[e.length-1];return{key:t,alreadyInstalled:i,...n?.scope?{scope:n.scope}:{},...n?.installPath?{installPath:n.installPath}:{},...n?.version?{version:n.version}:{}}},$=async(t,e,i)=>{if(!t.dir)throw new Error(`marketplace dir required for ${e}@${t.name}`);if((await M(t.dir)).isSymbolicLink())return;const n=c.join(t.dir,".claude-plugin","marketplace.json");let r={};try{r=JSON.parse(await S(n,"utf8"))}catch{r={}}const o=Array.isArray(r.plugins)?[...r.plugins]:[],s=`./${c.relative(t.dir,i).split(c.sep).join("/")}`,w={name:e,source:s},g=o.findIndex(x=>x?.name===e);g>=0?o[g]=w:o.push(w),r.name=t.name,r.owner||(r.owner={name:"weave"}),r.plugins=o,await v(c.dirname(n),{recursive:!0}),await E(n,`${JSON.stringify(r,null,2)}
3
+ `,"utf8")};return{projectPluginDir:t=>c.join(t,".codex","plugins"),pluginKey:l,parsePluginKey(t){const e=t.lastIndexOf("@");return e>0?{name:t.slice(0,e),market:t.slice(e+1)}:{name:t,market:CODEX_MARKETPLACE}},async globalInstall(t,e={}){let i=e.name;if(!i)try{const s=JSON.parse(await S(c.join(t,".claude-plugin","plugin.json"),"utf8"));i=typeof s.name=="string"?s.name:void 0}catch{i=void 0}if(!i)throw new Error(`plugin manifest missing name: ${t}`);const n=e.marketplace,r=l(i,n?.name),o=(await m())[r];if(o&&o.length>0)return f(r,o,!0);if(n)await $(n,i,t),await h(["plugin","marketplace","add",n.dir??""]);else throw new Error(`codex plugin install requires a marketplace (got none for ${r}); weave-managed packs must come from a market directory`);return await h(["plugin","add",r,"--json"]),f(r,(await m())[r],!1)},readInstalled:m,async isInstalled(t,e){const i=(await m())[l(t,e)];return!!i&&i.length>0},async uninstall(t,e){const i=l(t,e),n=(await m())[i];!n||n.length===0||await h(["plugin","remove",i,"--json"])},async removeMarketplace(t){const e=await d();if(!e)return;const i=c.resolve(t),n=O(e);let r;for(const o of n)if(!(!o.key||o.key.length!==2||o.key[0]!=="marketplaces")){for(const[s,w]of L(o.lines.slice(1))){if(s!=="source")continue;const g=w.split("=").slice(1).join("=").trim().replace(/^"(.*)"$/,"$1");if(c.resolve(g)===i){r=o.key[1];break}}if(r)break}r&&await h(["plugin","marketplace","remove",r])},async readProjectEnabled(t,e,i){return p(await d())[l(e,i)]??!1},async setProjectEnabled(t,e,i,n){const r=l(e,n),o=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),P(o,r,i),"utf8")},async readGlobalEnabled(){return p(await d())},async writeGlobalEnabled(t,e){const i=await d()??"";await v(c.dirname(u()),{recursive:!0}),await E(u(),P(i,t,e),"utf8")},pluginScopes:()=>["user"],async readEnabledOverrides(t){return{user:await this.readGlobalEnabled(),project:{},local:{}}},async setEnabledOverride(t,e,i,n){if(e!=="user")throw new Error(`codex plugins only support user-scope overrides (got ${e})`);const r=await d()??"";if(n==="inherit"){const{text:o,removed:s}=N(r,["plugins",i]);if(!s)return;await v(c.dirname(u()),{recursive:!0}),await E(u(),o,"utf8");return}await v(c.dirname(u()),{recursive:!0}),await E(u(),P(r,i,n==="on"),"utf8")}}}export const CODEX_PLUGINS=createCodexPluginSurface();
@@ -1 +1 @@
1
- import{existsSync as d}from"node:fs";import{homedir as c}from"node:os";import p from"node:path";import{codexHome as m}from"./home.js";function l(o){return p.join(process.env.LOCALAPPDATA||p.join(o,"AppData","Local"),"OpenAI","Codex")}function u(o){return p.join(m(o),"packages","app-server-daemon")}async function f(o){const{spawn:a}=await import("node:child_process");return new Promise(n=>{let r="";const s=process.platform==="win32"?a(`${o} app-server daemon version`,{windowsHide:!0,shell:!0,stdio:["ignore","pipe","pipe"]}):a(o,["app-server","daemon","version"],{windowsHide:!0,stdio:["ignore","pipe","pipe"]}),i=setTimeout(()=>{s.kill("SIGKILL"),n(null)},8e3);s.stdout?.on("data",e=>r+=e.toString()),s.on("error",()=>{clearTimeout(i),n(null)}),s.on("close",()=>{clearTimeout(i);try{const e=JSON.parse(r);typeof e.managedCodexVersion=="string"&&typeof e.cliVersion=="string"?n({managedCodexVersion:e.managedCodexVersion,cliVersion:e.cliVersion}):n(null)}catch{n(null)}})})}export async function codexProvisionCheck(o,a=()=>f(o),n=c()){const r=[],s=[],i=d(l(n)),e=d(u(n));if(i&&!e&&(r.push("codex desktop app detected without the shared app-server daemon package \u2014 the two faces share ~/.codex, and version skew makes the older side rewrite config.toml from its stale snapshot (wiping manual provider / hooks-trust edits)"),s.push("codex app-server daemon update --from-cli --yes")),e){const t=await a();t&&t.managedCodexVersion!==t.cliVersion&&(r.push(`codex shared daemon (${t.managedCodexVersion}) differs from CLI (${t.cliVersion}) \u2014 the older side rewrites ~/.codex/config.toml from its stale snapshot on startup, wiping manual edits`),s.push("codex app-server daemon update --from-cli --yes"))}return{desktopApp:i,daemonPackage:e,warnings:r,hints:s}}export const CODEX_PROVISION={harness:"codex",check:codexProvisionCheck};
1
+ import{existsSync as d}from"node:fs";import{homedir as c}from"node:os";import p from"node:path";import{codexHome as m}from"./home.js";function l(o){return p.join(process.env.LOCALAPPDATA||p.join(o,"AppData","Local"),"OpenAI","Codex")}function u(o){return p.join(m(o),"packages","app-server-daemon")}async function f(o){const{spawn:a}=await import("node:child_process");return new Promise(n=>{let i="";const r=process.platform==="win32"?a(`${o} app-server daemon version`,{windowsHide:!0,shell:!0,stdio:["ignore","pipe","pipe"]}):a(o,["app-server","daemon","version"],{windowsHide:!0,stdio:["ignore","pipe","pipe"]}),s=setTimeout(()=>{r.kill("SIGKILL"),n(null)},8e3);r.stdout?.on("data",e=>i+=e.toString()),r.on("error",()=>{clearTimeout(s),n(null)}),r.on("close",()=>{clearTimeout(s);try{const e=JSON.parse(i);typeof e.managedCodexVersion=="string"&&typeof e.cliVersion=="string"?n({managedCodexVersion:e.managedCodexVersion,cliVersion:e.cliVersion}):n(null)}catch{n(null)}})})}export async function codexProvisionCheck(o,a=()=>f(o),n=c()){const i=[],r=[],s=d(l(n)),e=d(u(n));if(s&&!e&&(i.push("codex desktop app detected without the shared app-server daemon package \u2014 the two faces share ~/.codex, and version skew makes the older side rewrite config.toml from its stale snapshot (wiping manual provider / hooks-trust edits)"),r.push("codex app-server daemon update --from-cli --yes")),e){const t=await a();t&&t.managedCodexVersion!==t.cliVersion&&(i.push(`codex shared daemon (${t.managedCodexVersion}) differs from CLI (${t.cliVersion}) \u2014 the older side rewrites ~/.codex/config.toml from its stale snapshot on startup, wiping manual edits`),r.push("codex app-server daemon update --from-cli --yes"))}return{desktopApp:s,daemonPackage:e,warnings:i,hints:r}}export const CODEX_PROVISION={harness:"codex",check:codexProvisionCheck};
@@ -1,2 +1,2 @@
1
- const m="y",p="n",d="d",f="1",c={key:"codex:opaque",header:null,question:"The session is waiting for input (options unavailable \u2014 answer in its terminal)",multiSelect:!1,options:[]};function r(n){const e=n&&typeof n=="object"?n:{},o=Array.isArray(e.command)?e.command.filter(i=>typeof i=="string").join(" "):typeof e.command=="string"?e.command:"",s=typeof e.description=="string"?e.description:null,t=o||s||"Codex wants to run a command";return t.length>200?`${t.slice(0,200)}\u2026`:t}function a(n){const e=n&&typeof n=="object"?n:{},o=typeof e.command=="string"?e.command:"";if(!o)return"Codex wants to apply a patch";const s=[...o.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map(i=>i[1]),t=s.length>0?s.join(", "):o.split(`
2
- `)[0]??"patch";return t.length>200?`${t.slice(0,200)}\u2026`:t}function u(n,e){const o=e&&typeof e=="object"&&Object.keys(e).length>0?JSON.stringify(e):"",s=`Codex wants to call ${n}`,t=o?`${s} ${o}`:s;return t.length>200?`${t.slice(0,200)}\u2026`:t}function l(n,e){return[{keys:["y"],label:n},{keys:["n"],label:e}]}export const CODEX_QUESTIONS={plan:null,blockingTools:[],permissionNotificationType:null,silentPermissionModes:["bypassPermissions"],permissionQuestion(){return{...c,key:"codex:permission"}},parseQuestions(){return[{...c}]},eventQuestion(n,e){if(n!=="PermissionRequest")return null;const o=e.raw&&typeof e.raw=="object"?e.raw:{},s=e.toolName,t=e.toolInput;return(typeof o.permission_mode=="string"?o.permission_mode:null)==="bypassPermissions"||s==null?null:s.startsWith("mcp__")?{key:"PermissionRequest:mcp",header:"MCP tool approval",question:u(s,t),multiSelect:!1,options:[{keys:["1"],label:"Yes, run the tool and continue"}]}:s==="apply_patch"?{key:"PermissionRequest:patch",header:"Apply patch",question:a(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}:s==="request_permissions"?{key:"PermissionRequest:permissions",header:"Permissions",question:r(t),multiSelect:!1,options:[{keys:["y"],label:"Yes, grant these permissions for this turn"},{keys:["d"],label:"No, continue without permissions"}]}:s==="write_stdin"?{key:"PermissionRequest:write_stdin",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, cancel")}:{key:"PermissionRequest:exec",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}}};
1
+ const c="y",m="n",d="d",y="1",a={key:"codex:opaque",header:null,question:"The session is waiting for input (options unavailable \u2014 answer in its terminal)",multiSelect:!1,options:[]};function r(n){const e=n&&typeof n=="object"?n:{},s=Array.isArray(e.command)?e.command.filter(i=>typeof i=="string").join(" "):typeof e.command=="string"?e.command:"",o=typeof e.description=="string"?e.description:null,t=s||o||"Codex wants to run a command";return t.length>200?`${t.slice(0,200)}\u2026`:t}function p(n){const e=n&&typeof n=="object"?n:{},s=typeof e.command=="string"?e.command:"";if(!s)return"Codex wants to apply a patch";const o=[...s.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map(i=>i[1]),t=o.length>0?o.join(", "):s.split(`
2
+ `)[0]??"patch";return t.length>200?`${t.slice(0,200)}\u2026`:t}function u(n,e){const s=e&&typeof e=="object"&&Object.keys(e).length>0?JSON.stringify(e):"",o=`Codex wants to call ${n}`,t=s?`${o} ${s}`:o;return t.length>200?`${t.slice(0,200)}\u2026`:t}function l(n,e){return[{keys:["y"],label:n},{keys:["n"],label:e}]}export const CODEX_QUESTIONS={plan:null,blockingTools:[],permissionNotificationType:null,silentPermissionModes:["bypassPermissions"],permissionQuestion(){return{...a,key:"codex:permission"}},parseQuestions(){return[{...a}]},eventQuestion(n,e){if(n!=="PermissionRequest")return null;const s=e.raw&&typeof e.raw=="object"?e.raw:{},o=e.toolName,t=e.toolInput;return(typeof s.permission_mode=="string"?s.permission_mode:null)==="bypassPermissions"||o==null?null:o.startsWith("mcp__")?{key:"PermissionRequest:mcp",header:"MCP tool approval",question:u(o,t),multiSelect:!1,options:[{keys:["1"],label:"Yes, run the tool and continue"}]}:o==="apply_patch"?{key:"PermissionRequest:patch",header:"Apply patch",question:p(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}:o==="request_permissions"?{key:"PermissionRequest:permissions",header:"Permissions",question:r(t),multiSelect:!1,options:[{keys:["y"],label:"Yes, grant these permissions for this turn"},{keys:["d"],label:"No, continue without permissions"}]}:o==="write_stdin"?{key:"PermissionRequest:write_stdin",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, cancel")}:{key:"PermissionRequest:exec",header:"Command approval",question:r(t),multiSelect:!1,options:l("Yes, proceed","No, and tell Codex what to do differently")}}};
@@ -1,5 +1,5 @@
1
- import{mkdir as x,open as C,readdir as N,readFile as I,stat as L,utimes as T,writeFile as _}from"node:fs/promises";import l from"node:path";import{CodexTurnBuffer as B,metaOfLine as H}from"./event-source.js";import{readUserCapture as U}from"./capture.js";import{codexHome as O}from"./home.js";const A=512*1024,X=256*1024,W=2*6e4,J=1024*1024,K=10080*6e4,Y=400,P=4*1024*1024,E=128*1024,R="cursors.json",$=".lock",G=6e4;function q(){const n=O();return[l.join(n,"sessions"),l.join(n,"archived_sessions")]}function j(n){const t=l.resolve(n);return process.platform==="win32"?t.toLowerCase():t}function k(n){try{const t=JSON.parse(n);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}async function Q(){const n=[],t=async(e,r)=>{if(r>4)return;let i;try{i=await N(e,{withFileTypes:!0})}catch{return}for(const a of i){const f=l.join(e,a.name);if(a.isDirectory()){await t(f,r+1);continue}if(!a.isFile()||!a.name.startsWith("rollout-")||!a.name.endsWith(".jsonl"))continue;const h=await L(f).catch(()=>null);h&&n.push({path:f,size:h.size,mtimeMs:h.mtimeMs})}};for(const e of q())await t(e,0);return n}async function V(n){const t=await C(n,"r").catch(()=>null);if(!t)return null;try{const e=Buffer.alloc(E),{bytesRead:r}=await t.read(e,0,E,0),i=e.subarray(0,r).toString("utf8"),a=i.indexOf(`
2
- `);if(a<0)return r<E?"pending":null;const f=k(i.slice(0,a));return f?H(f):null}finally{await t.close()}}async function Z(n,t,e){const r=await C(n,"r").catch(()=>null);if(!r)return null;try{const i=Buffer.alloc(e),{bytesRead:a}=await r.read(i,0,e,t);return{text:i.subarray(0,a).toString("utf8"),bytes:a}}finally{await r.close()}}async function z(n){try{const t=await I(l.join(n,R),"utf8"),e=JSON.parse(t);if(e&&typeof e=="object"&&e.files&&typeof e.files=="object")return e}catch{}return{at:null,files:{}}}async function tt(n,t){t.at=new Date().toISOString(),await x(n,{recursive:!0}),await _(l.join(n,R),JSON.stringify(t))}function et(n){const t=Number(n);if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function st(n){await x(n,{recursive:!0});const t=l.join(n,$),e=`${process.pid}`;try{return await _(t,e,{flag:"wx"}),!0}catch{}const r=(await I(t,"utf8").catch(()=>"")).trim();if(r===e){const i=await L(t).catch(()=>null);if(!i||Date.now()-i.mtimeMs>G){const a=new Date;await T(t,a,a).catch(()=>{})}return!0}return r&&et(r)?!1:_(t,e).then(()=>!0,()=>!1)}const nt=1e4;export class CodexLogSource{harness="codex";buffers=new Map;lastError=null;capture=null;async captureInstalled(){const t=Date.now(),e=O();if(this.capture&&this.capture.root===e&&t-this.capture.at<nt)return this.capture.on;const r=(await U()).installed;return this.capture={root:e,at:t,on:r},r}async poll(t){const e=await this.captureInstalled();if(!await st(t.stateDir))return[];const r=(await Q()).sort((s,o)=>s.mtimeMs-o.mtimeMs),i=await z(t.stateDir);if(r.length===0&&Object.keys(i.files).length===0)return[];const a=new Map(t.cwdWhitelist.map(s=>[j(s),s])),f=t.maxRecords??Y;let h=t.maxBytes??P;const d=[];let u=!1;for(const s of r){if(d.length>=f||h<=0)break;let o=i.files[s.path],S=!1;if(!o){const c=await V(s.path);if(c==="pending")continue;if(!c){i.files[s.path]={offset:s.size,sessionId:null,cwd:null},u=!0;continue}o={offset:0,sessionId:c.sessionId,cwd:c.cwd},i.files[s.path]=o,u=!0,Date.now()-s.mtimeMs>K?o.offset=s.size:Date.now()-s.mtimeMs<W&&s.size<J?o.offset=0:(o.offset=Math.max(0,s.size-X),S=!0)}const M=o.cwd?a.get(j(o.cwd)):void 0;if(!M){o.offset!==s.size&&(o.offset=s.size,u=!0);continue}if(s.size<o.offset&&(o.offset=0,S=!1,this.buffers.delete(s.path),u=!0),s.size===o.offset)continue;const p=await Z(s.path,o.offset,Math.min(s.size-o.offset,h));if(!p){this.lastError=`read failed: ${s.path}`;continue}h-=p.bytes;let w=p.text,m=o.offset;if(S){const c=w.indexOf(`
3
- `);if(c<0){o.offset=m+p.bytes,u=!0;continue}m+=Buffer.byteLength(w.slice(0,c+1),"utf8"),w=w.slice(c+1)}const g=w.lastIndexOf(`
4
- `);if(g<0){w.length>A&&(o.offset=m+p.bytes,this.lastError=`oversized line skipped: ${l.basename(s.path)}`,u=!0);continue}let D=m;const F=this.bufferOf(s.path);for(const c of w.slice(0,g).split(`
5
- `)){if(d.length>=f)break;if(D+=Buffer.byteLength(c,"utf8")+1,!c||c.length>A)continue;const y=k(c);if(!y||e&&y.type!=="session_meta")continue;const b=F.report(y);b&&(b.sessionId=o.sessionId??void 0,b.cwd=M,d.push({report:b,at:rt(y,s.mtimeMs)}))}o.offset=D,u=!0}const v=new Set(r.map(s=>s.path));for(const s of Object.keys(i.files))v.has(s)||(delete i.files[s],this.buffers.delete(s),u=!0);return u&&await tt(t.stateDir,i).catch(()=>{}),d}async health(t){const e=await z(t.stateDir),r=O();let i=0;for(const a of Object.values(e.files))a.cwd&&i++;return{root:r,files:i,lastPollAt:e.at,lastError:this.lastError}}bufferOf(t){let e=this.buffers.get(t);return e||(e=new B,this.buffers.set(t,e)),e}}function rt(n,t){if(typeof n.timestamp=="string"&&n.timestamp){const e=Date.parse(n.timestamp);if(!Number.isNaN(e))return new Date(e).toISOString()}return new Date(t).toISOString()}export const CODEX_LOG_SOURCE=new CodexLogSource;
1
+ import{mkdir as z,open as I,readdir as _,readFile as E,stat as k,utimes as A,writeFile as O}from"node:fs/promises";import u from"node:path";import{CodexTurnBuffer as J,metaOfLine as W}from"./event-source.js";import{readUserCapture as $}from"./capture.js";import{codexHome as x}from"./home.js";const v=512*1024,P=256*1024,T=2*6e4,U=1024*1024,G=10080*6e4,H=400,X=4*1024*1024,D=128*1024,N="cursors.json",q=".lock",K=6e4;function Q(){const n=x();return[u.join(n,"sessions"),u.join(n,"archived_sessions")]}function B(n){const t=u.resolve(n);return process.platform==="win32"?t.toLowerCase():t}function C(n){try{const t=JSON.parse(n);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}async function V(){const n=[],t=async(e,i)=>{if(i>4)return;let a;try{a=await _(e,{withFileTypes:!0})}catch{return}for(const o of a){const c=u.join(e,o.name);if(o.isDirectory()){await t(c,i+1);continue}if(!o.isFile()||!o.name.startsWith("rollout-")||!o.name.endsWith(".jsonl"))continue;const h=await k(c).catch(()=>null);h&&n.push({path:c,size:h.size,mtimeMs:h.mtimeMs})}};for(const e of Q())await t(e,0);return n}async function Y(n){const t=await I(n,"r").catch(()=>null);if(!t)return null;try{const e=Buffer.alloc(D),{bytesRead:i}=await t.read(e,0,D,0),a=e.subarray(0,i).toString("utf8"),o=a.indexOf(`
2
+ `);if(o<0)return i<D?"pending":null;const c=C(a.slice(0,o));return c?W(c):null}finally{await t.close()}}async function Z(n,t,e){const i=await I(n,"r").catch(()=>null);if(!i)return null;try{const a=Buffer.alloc(e),{bytesRead:o}=await i.read(a,0,e,t);return{text:a.subarray(0,o).toString("utf8"),bytes:o}}finally{await i.close()}}async function L(n){try{const t=await E(u.join(n,N),"utf8"),e=JSON.parse(t);if(e&&typeof e=="object"&&e.files&&typeof e.files=="object")return e}catch{}return{at:null,files:{}}}async function tt(n,t){t.at=new Date().toISOString(),await z(n,{recursive:!0}),await O(u.join(n,N),JSON.stringify(t))}function et(n){const t=Number(n);if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function st(n){await z(n,{recursive:!0});const t=u.join(n,q),e=`${process.pid}`;try{return await O(t,e,{flag:"wx"}),!0}catch{}const i=(await E(t,"utf8").catch(()=>"")).trim();if(i===e){const a=await k(t).catch(()=>null);if(!a||Date.now()-a.mtimeMs>K){const o=new Date;await A(t,o,o).catch(()=>{})}return!0}return i&&et(i)?!1:O(t,e).then(()=>!0,()=>!1)}const nt=1e4;export class CodexLogSource{harness="codex";buffers=new Map;lastError=null;capture=null;async captureInstalled(){const t=Date.now(),e=x();if(this.capture&&this.capture.root===e&&t-this.capture.at<nt)return this.capture.on;const i=(await $()).installed;return this.capture={root:e,at:t,on:i},i}async poll(t){const e=await this.captureInstalled();if(!await st(t.stateDir))return[];const i=(await V()).sort((s,r)=>s.mtimeMs-r.mtimeMs),a=await L(t.stateDir);if(i.length===0&&Object.keys(a.files).length===0)return[];const o=new Map(t.cwdWhitelist.map(s=>[B(s),s])),c=t.maxRecords??H;let h=t.maxBytes??X;const m=[];let l=!1;for(const s of i){if(m.length>=c||h<=0)break;let r=a.files[s.path],g=!1;if(!r){const f=await Y(s.path);if(f==="pending")continue;if(!f){a.files[s.path]={offset:s.size,sessionId:null,cwd:null},l=!0;continue}r={offset:0,sessionId:f.sessionId,cwd:f.cwd},a.files[s.path]=r,l=!0,Date.now()-s.mtimeMs>G?r.offset=s.size:Date.now()-s.mtimeMs<T&&s.size<U?r.offset=0:(r.offset=Math.max(0,s.size-P),g=!0)}const j=r.cwd?o.get(B(r.cwd)):void 0;if(!j){r.offset!==s.size&&(r.offset=s.size,l=!0);continue}if(s.size<r.offset&&(r.offset=0,g=!1,this.buffers.delete(s.path),l=!0),s.size===r.offset)continue;const w=await Z(s.path,r.offset,Math.min(s.size-r.offset,h));if(!w){this.lastError=`read failed: ${s.path}`;continue}h-=w.bytes;let p=w.text,d=r.offset;if(g){const f=p.indexOf(`
3
+ `);if(f<0){r.offset=d+w.bytes,l=!0;continue}d+=Buffer.byteLength(p.slice(0,f+1),"utf8"),p=p.slice(f+1)}const S=p.lastIndexOf(`
4
+ `);if(S<0){p.length>v&&(r.offset=d+w.bytes,this.lastError=`oversized line skipped: ${u.basename(s.path)}`,l=!0);continue}let M=d;const F=this.bufferOf(s.path);for(const f of p.slice(0,S).split(`
5
+ `)){if(m.length>=c)break;if(M+=Buffer.byteLength(f,"utf8")+1,!f||f.length>v)continue;const y=C(f);if(!y||e&&y.type!=="session_meta")continue;const b=F.report(y);b&&(b.sessionId=r.sessionId??void 0,b.cwd=j,m.push({report:b,at:it(y,s.mtimeMs)}))}r.offset=M,l=!0}const R=new Set(i.map(s=>s.path));for(const s of Object.keys(a.files))R.has(s)||(delete a.files[s],this.buffers.delete(s),l=!0);return l&&await tt(t.stateDir,a).catch(()=>{}),m}async health(t){const e=await L(t.stateDir),i=x();let a=0;for(const o of Object.values(e.files))o.cwd&&a++;return{root:i,files:a,lastPollAt:e.at,lastError:this.lastError}}bufferOf(t){let e=this.buffers.get(t);return e||(e=new J,this.buffers.set(t,e)),e}}function it(n,t){if(typeof n.timestamp=="string"&&n.timestamp){const e=Date.parse(n.timestamp);if(!Number.isNaN(e))return new Date(e).toISOString()}return new Date(t).toISOString()}export const CODEX_LOG_SOURCE=new CodexLogSource;
@@ -1,4 +1,4 @@
1
- const I=2e3,a=/^[^\x00-\x1f\x7f]+$/,_="Side from main thread",f=/•\s+Working\s*\(/,E=/^\s*Worked for\s+/,O=/^\s*└\s+Tip:/,P="\u203A ";function R(e,t,s){const l="\u203A "+e,c=s.split(`
2
- `);let u=-1;for(let n=c.length-1;n>=0;n--){const i=c[n].trim();if(i===l&&!k(t,l)){u=n;break}if(i===l){u=n;break}}if(u<0)return null;const o=[];for(let n=u+1;n<c.length;n++){const i=c[n],r=i.trim();if(r){if(E.test(r))break;if(f.test(r))return null;if(!O.test(i)){if(r.startsWith("\u203A ".trim()))break;if(r.startsWith("\u2022")){o.push(r.replace(/^•\s*/,""));continue}o.length>0&&o.push(r)}}}return o.length>0?o.join(`
3
- `):null}function k(e,t){return e.split(`
4
- `).some(s=>s.trim()===t)}export const CODEX_SIDE_QUESTION={command(e){return e},validate(e){const t=e.trim();return t?t.length>2e3?{ok:!1,error:"\u95EE\u9898\u8FC7\u957F\uFF08\u4E0A\u9650 2000 \u5B57\u7B26\uFF09"}:a.test(t)?{ok:!0,text:t}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u542B\u6362\u884C\u6216\u63A7\u5236\u5B57\u7B26\uFF08\u4F1A\u63D0\u524D\u63D0\u4EA4\uFF09"}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u4E3A\u7A7A"}},answerOf(){return null},prerequisite:"\u4E3B\u7EBF\u7A0B\u81F3\u5C11\u53D1\u8FC7\u4E00\u6761\u6D88\u606F\u540E\u624D\u80FD\u5F00\u4FA7\u8FB9\u4F1A\u8BDD\uFF08\u5BBF\u4E3B\u9650\u5236\uFF09",screen:{openKeys:"/side",submitKey:"\r",closeKey:"",panelOpen(e){return e.includes(_)},extractAnswer(e,t,s){return f.test(s)?{answer:null,done:!1}:{answer:R(e,t,s),done:!0}}}};
1
+ const m=2e3,f=/^[^\x00-\x1f\x7f]+$/,a="Side from main thread",E=/•\s+Working\s*\(/,c=/^\s*Worked for\s+/,D=/^\s*└\s+Tip:/,k="\u203A ";function A(u,e,n){const l="\u203A "+u,o=n.split(`
2
+ `);let F=-1;for(let t=o.length-1;t>=0;t--){const i=o[t].trim();if(i===l&&!B(e,l)){F=t;break}if(i===l){F=t;break}}if(F<0)return null;const s=[];for(let t=F+1;t<o.length;t++){const i=o[t],r=i.trim();if(r){if(c.test(r))break;if(E.test(r))return null;if(!D.test(i)){if(r.startsWith("\u203A ".trim()))break;if(r.startsWith("\u2022")){s.push(r.replace(/^•\s*/,""));continue}s.length>0&&s.push(r)}}}return s.length>0?s.join(`
3
+ `):null}function B(u,e){return u.split(`
4
+ `).some(n=>n.trim()===e)}export const CODEX_SIDE_QUESTION={command(u){return u},validate(u){const e=u.trim();return e?e.length>2e3?{ok:!1,error:"\u95EE\u9898\u8FC7\u957F\uFF08\u4E0A\u9650 2000 \u5B57\u7B26\uFF09"}:f.test(e)?{ok:!0,text:e}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u542B\u6362\u884C\u6216\u63A7\u5236\u5B57\u7B26\uFF08\u4F1A\u63D0\u524D\u63D0\u4EA4\uFF09"}:{ok:!1,error:"\u95EE\u9898\u4E0D\u80FD\u4E3A\u7A7A"}},answerOf(){return null},prerequisite:"\u4E3B\u7EBF\u7A0B\u81F3\u5C11\u53D1\u8FC7\u4E00\u6761\u6D88\u606F\u540E\u624D\u80FD\u5F00\u4FA7\u8FB9\u4F1A\u8BDD\uFF08\u5BBF\u4E3B\u9650\u5236\uFF09",screen:{openKeys:"/side",submitKey:"\r",closeKey:"",panelOpen(u){return u.includes(a)},extractAnswer(u,e,n){return E.test(n)?{answer:null,done:!1}:{answer:A(u,e,n),done:!0}}}};
@@ -1,4 +1,4 @@
1
- import{spawn as h}from"node:child_process";import{readFileSync as S,statSync as g}from"node:fs";import v from"node:path";import{codexHome as y}from"./home.js";import{codexCommandLine as T}from"./plugins.js";const E=1e4,u=new Map;export function codexSessionTitleOf(c,s){const n=v.join(y(s),"session_index.jsonl");let r;try{r=g(n)}catch{return null}const d=u.get(n);if(!d||d.mtimeMs!==r.mtimeMs||d.size!==r.size){const e=new Map;try{for(const l of S(n,"utf8").split(`
2
- `)){const o=l.trim();if(o)try{const t=JSON.parse(o);typeof t.id=="string"&&typeof t.thread_name=="string"&&e.set(t.id,t.thread_name)}catch{}}}catch{return null}u.set(n,{mtimeMs:r.mtimeMs,size:r.size,names:e})}const i=u.get(n).names.get(c)??null;return i!=null&&i.trim()?i:null}export function codexSetSessionTitle(c,s){return new Promise((n,r)=>{const d=s.trim();if(!d){r(new Error("thread name must not be empty"));return}const i=process.platform==="win32",e=h(i?process.env.ComSpec||"cmd.exe":"codex",i?["/d","/s","/c",T(["app-server"])]:["app-server"],{windowsHide:!0,windowsVerbatimArguments:i,stdio:["pipe","pipe","pipe"]});let l=!1,o="";const t=a=>{l||(l=!0,clearTimeout(w),i&&e.pid!==void 0?h("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref():e.kill("SIGKILL"),a?r(a):n())},w=setTimeout(()=>t(new Error("codex app-server thread/name/set timed out")),E),p=a=>{e.stdin?.write(`${JSON.stringify(a)}
3
- `)};e.on("error",()=>t(new Error("failed to spawn codex app-server"))),e.on("exit",()=>t(new Error("codex app-server exited before thread/name/set"))),e.stdin?.on("error",()=>t(new Error("codex app-server stdin closed"))),p({jsonrpc:"2.0",id:1,method:"initialize",params:{clientInfo:{name:"weave",title:"weave",version:"1.0.0"}}}),e.stdout?.setEncoding("utf8"),e.stdout?.on("data",a=>{o+=a;let f;for(;(f=o.indexOf(`
4
- `))>=0;){const x=o.slice(0,f);o=o.slice(f+1);let m=null;try{m=JSON.parse(x)}catch{continue}if(m?.id===1){p({jsonrpc:"2.0",method:"initialized",params:{}}),p({jsonrpc:"2.0",id:2,method:"thread/name/set",params:{threadId:c,name:d}});continue}m?.id===2&&t(m.error?new Error(String(m.error.message??"thread/name/set failed")):null)}})})}export function createCodexTitleSurface(c={}){return{harness:"codex",sessionTitleOf:s=>Promise.resolve(codexSessionTitleOf(s,c.home)),setSessionTitle:(s,n)=>codexSetSessionTitle(s,n)}}export const CODEX_TITLES=createCodexTitleSurface();
1
+ import{spawn as w}from"node:child_process";import{readFileSync as S,statSync as g}from"node:fs";import v from"node:path";import{codexHome as y}from"./home.js";import{codexCommandLine as E}from"./plugins.js";const T=1e4,u=new Map;export function codexSessionTitleOf(c,s){const r=v.join(y(s),"session_index.jsonl");let n;try{n=g(r)}catch{return null}const a=u.get(r);if(!a||a.mtimeMs!==n.mtimeMs||a.size!==n.size){const e=new Map;try{for(const p of S(r,"utf8").split(`
2
+ `)){const i=p.trim();if(i)try{const t=JSON.parse(i);typeof t.id=="string"&&typeof t.thread_name=="string"&&e.set(t.id,t.thread_name)}catch{}}}catch{return null}u.set(r,{mtimeMs:n.mtimeMs,size:n.size,names:e})}const o=u.get(r).names.get(c)??null;return o!=null&&o.trim()?o:null}export function codexSetSessionTitle(c,s){return new Promise((r,n)=>{const a=s.trim();if(!a){n(new Error("thread name must not be empty"));return}const o=process.platform==="win32",e=w(o?process.env.ComSpec||"cmd.exe":"codex",o?["/d","/s","/c",E(["app-server"])]:["app-server"],{windowsHide:!0,windowsVerbatimArguments:o,stdio:["pipe","pipe","pipe"]});let p=!1,i="";const t=d=>{p||(p=!0,clearTimeout(x),o&&e.pid!==void 0?w("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref():e.kill("SIGKILL"),d?n(d):r())},x=setTimeout(()=>t(new Error("codex app-server thread/name/set timed out")),T),l=d=>{e.stdin?.write(`${JSON.stringify(d)}
3
+ `)};e.on("error",()=>t(new Error("failed to spawn codex app-server"))),e.on("exit",()=>t(new Error("codex app-server exited before thread/name/set"))),e.stdin?.on("error",()=>t(new Error("codex app-server stdin closed"))),l({jsonrpc:"2.0",id:1,method:"initialize",params:{clientInfo:{name:"weave",title:"weave",version:"1.0.0"}}}),e.stdout?.setEncoding("utf8"),e.stdout?.on("data",d=>{i+=d;let f;for(;(f=i.indexOf(`
4
+ `))>=0;){const h=i.slice(0,f);i=i.slice(f+1);let m=null;try{m=JSON.parse(h)}catch{continue}if(m?.id===1){l({jsonrpc:"2.0",method:"initialized",params:{}}),l({jsonrpc:"2.0",id:2,method:"thread/name/set",params:{threadId:c,name:a}});continue}m?.id===2&&t(m.error?new Error(String(m.error.message??"thread/name/set failed")):null)}})})}export function createCodexTitleSurface(c={}){return{harness:"codex",sessionTitleOf:s=>Promise.resolve(codexSessionTitleOf(s,c.home)),setSessionTitle:(s,r)=>codexSetSessionTitle(s,r)}}export const CODEX_TITLES=createCodexTitleSurface();
@@ -1,17 +1,17 @@
1
- import{parse as W}from"smol-toml";export class CodexTomlCorruptError extends Error{constructor(t){super(t),this.name="CodexTomlCorruptError"}}function A(n){return/[A-Za-z0-9_-]/.test(n)}function y(n){return n===" "||n===" "}const $={b:"\b",t:" ",n:`
2
- `,f:"\f",r:"\r",'"':'"',"\\":"\\"};export function parseDottedKey(n){const t=[];let e=0;for(;;){for(;e<n.length&&y(n[e]);)e++;if(e>=n.length)return null;const r=n[e];if(r==='"'||r==="'"){e++;let o="";for(;e<n.length;){const i=n[e];if(r==='"'&&i==="\\"){const s=n[e+1];if(s===void 0||!(s in $))return null;o+=$[s],e+=2;continue}if(i===r)break;o+=i,e++}if(e>=n.length)return null;e++,t.push(o)}else{const o=e;for(;e<n.length&&A(n[e]);)e++;if(e===o)return null;t.push(n.slice(o,e))}for(;e<n.length&&y(n[e]);)e++;if(e>=n.length)return t;if(n[e]!==".")return null;e++}}export function sectionHeaderKey(n){const t=n.trim();if(!t.startsWith("["))return null;const e=t.startsWith("[[");let r=e?2:1,o="",i=!1;for(;r<t.length;){const l=t[r];if(l==='"'||l==="'"){const c=l;for(o+=c,r++;r<t.length;){if(c==='"'&&t[r]==="\\"){if(r+1>=t.length)return null;o+=t[r]+t[r+1],r+=2;continue}if(t[r]===c)break;o+=t[r],r++}if(r>=t.length)return null;o+=c,r++;continue}if(l==="]"){if(e){if(t[r+1]!=="]")return null;r+=2}else r++;i=!0;break}o+=l,r++}if(!i)return null;const s=t.slice(r).trim();return s!==""&&!s.startsWith("#")?null:parseDottedKey(o)}export function renderTomlKey(n){return/^[A-Za-z0-9_-]+$/.test(n)?n:`"${x(n)}"`}export function renderTomlHeader(n){return`[${n.map(renderTomlKey).join(".")}]`}function x(n){let t="";for(const e of n)e==="\\"?t+="\\\\":e==='"'?t+='\\"':e===`
3
- `?t+="\\n":e==="\r"?t+="\\r":e===" "?t+="\\t":e<" "||e==="\x7F"?t+=`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`:t+=e;return t}export function renderTomlString(n){const t=n.includes("\\"),e=!n.includes("'")&&!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f\n]/.test(n);return t&&e?`'${n}'`:`"${x(n)}"`}export function splitTomlSections(n){const t=n.split(`
4
- `),e=[];let r={key:null,lines:[]};for(const o of t){const i=sectionHeaderKey(o);i!==null?(e.push(r),r={key:i,lines:[o]}):r.lines.push(o)}return e.push(r),e}export function sameKey(n,t){return n!==null&&n.length===t.length&&n.every((e,r)=>e===t[r])}function m(n,t){return n!==null&&n.length>t.length&&t.every((e,r)=>n[r]===e)}function C(n){let t=0;for(let e=n.length-1;e>=0&&n[e].trim()==="";e--)t++;return t}function h(n){const t=n.replace(/(?:\r?\n)+[ \t]*$/,"");return t===""?"":`${t}
5
- `}function w(n,t){const e=n.replace(/(?:\r?\n)+[ \t]*$/,"");return e.trim()===""?`${t.join(`
1
+ import{parse as W}from"smol-toml";export class CodexTomlCorruptError extends Error{constructor(n){super(n),this.name="CodexTomlCorruptError"}}function S(t){return/[A-Za-z0-9_-]/.test(t)}function x(t){return t===" "||t===" "}const $={b:"\b",t:" ",n:`
2
+ `,f:"\f",r:"\r",'"':'"',"\\":"\\"};export function parseDottedKey(t){const n=[];let e=0;for(;;){for(;e<t.length&&x(t[e]);)e++;if(e>=t.length)return null;const r=t[e];if(r==='"'||r==="'"){e++;let i="";for(;e<t.length;){const o=t[e];if(r==='"'&&o==="\\"){const s=t[e+1];if(s===void 0||!(s in $))return null;i+=$[s],e+=2;continue}if(o===r)break;i+=o,e++}if(e>=t.length)return null;e++,n.push(i)}else{const i=e;for(;e<t.length&&S(t[e]);)e++;if(e===i)return null;n.push(t.slice(i,e))}for(;e<t.length&&x(t[e]);)e++;if(e>=t.length)return n;if(t[e]!==".")return null;e++}}export function sectionHeaderKey(t){const n=t.trim();if(!n.startsWith("["))return null;const e=n.startsWith("[[");let r=e?2:1,i="",o=!1;for(;r<n.length;){const l=n[r];if(l==='"'||l==="'"){const u=l;for(i+=u,r++;r<n.length;){if(u==='"'&&n[r]==="\\"){if(r+1>=n.length)return null;i+=n[r]+n[r+1],r+=2;continue}if(n[r]===u)break;i+=n[r],r++}if(r>=n.length)return null;i+=u,r++;continue}if(l==="]"){if(e){if(n[r+1]!=="]")return null;r+=2}else r++;o=!0;break}i+=l,r++}if(!o)return null;const s=n.slice(r).trim();return s!==""&&!s.startsWith("#")?null:parseDottedKey(i)}export function renderTomlKey(t){return/^[A-Za-z0-9_-]+$/.test(t)?t:`"${y(t)}"`}export function renderTomlHeader(t){return`[${t.map(renderTomlKey).join(".")}]`}function y(t){let n="";for(const e of t)e==="\\"?n+="\\\\":e==='"'?n+='\\"':e===`
3
+ `?n+="\\n":e==="\r"?n+="\\r":e===" "?n+="\\t":e<" "||e==="\x7F"?n+=`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`:n+=e;return n}export function renderTomlString(t){const n=t.includes("\\"),e=!t.includes("'")&&!/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f\n]/.test(t);return n&&e?`'${t}'`:`"${y(t)}"`}export function splitTomlSections(t){const n=t.split(`
4
+ `),e=[];let r={key:null,lines:[]};for(const i of n){const o=sectionHeaderKey(i);o!==null?(e.push(r),r={key:o,lines:[i]}):r.lines.push(i)}return e.push(r),e}export function sameKey(t,n){return t!==null&&t.length===n.length&&t.every((e,r)=>e===n[r])}function g(t,n){return t!==null&&t.length>n.length&&n.every((e,r)=>t[r]===e)}function A(t){let n=0;for(let e=t.length-1;e>=0&&t[e].trim()==="";e--)n++;return n}function p(t){const n=t.replace(/(?:\r?\n)+[ \t]*$/,"");return n===""?"":`${n}
5
+ `}function C(t,n){const e=t.replace(/(?:\r?\n)+[ \t]*$/,"");return e.trim()===""?`${n.join(`
6
6
  `)}
7
7
  `:`${e}
8
8
 
9
- ${t.join(`
9
+ ${n.join(`
10
10
  `)}
11
- `}export function upsertTomlSection(n,t,e){const r=splitTomlSections(n);let o=-1,i=-1;const s=new Set;for(let u=0;u<r.length;u++){const d=r[u].key;sameKey(d,t)?(o<0&&(o=u),s.add(u),i=u):m(d,t)&&(s.add(u),i=u)}if(o<0)return w(n,[renderTomlHeader(t),...e]);const l=r[i].lines,c=l.slice(l.length-C(l)),f=[renderTomlHeader(t),...e,...c],a=[];for(let u=0;u<r.length;u++)u===o&&a.push(...f),!s.has(u)&&a.push(...r[u].lines);return h(a.join(`
12
- `))}export function removeTomlSection(n,t){const e=splitTomlSections(n),r=new Set;for(let i=0;i<e.length;i++){const s=e[i].key;(sameKey(s,t)||m(s,t))&&r.add(i)}if(r.size===0)return{text:n,removed:!1};const o=[];for(let i=0;i<e.length;i++)r.has(i)||o.push(...e[i].lines);return{text:h(o.join(`
13
- `)),removed:!0}}export function parseSectionEntries(n){const t=[];for(const e of n){const r=e.trim();if(r===""||r.startsWith("#")||r.startsWith("["))continue;const o=/^("[^"]*"|'[^']*'|[A-Za-z0-9_-]+)\s*=/.exec(r);if(!o)continue;const i=parseDottedKey(o[1]);i===null||i.length!==1||t.push([i[0],e])}return t}export function upsertCodexPluginEnabledInText(n,t,e){const r=["plugins",t],i=splitTomlSections(n).find(l=>sameKey(l.key,r)),s=[`enabled = ${e?"true":"false"}`];if(i)for(const[l,c]of parseSectionEntries(i.lines.slice(1)))l!=="enabled"&&s.push(c);return upsertTomlSection(n,r,s)}export function renderTomlValue(n){return n==null?'""':typeof n=="boolean"?n?"true":"false":typeof n=="number"?Number.isFinite(n)?String(n):'""':typeof n=="string"?renderTomlString(n):Array.isArray(n)?`[${n.map(renderTomlValue).join(", ")}]`:`{ ${Object.entries(n).filter(([,e])=>e!==void 0).map(([e,r])=>`${renderTomlKey(e)} = ${renderTomlValue(r)}`).join(", ")} }`}export function setTomlValueInText(n,t,e){if(t.length===0)return n;const r=`${renderTomlKey(t[t.length-1])} = ${renderTomlValue(e)}`,o=t.slice(0,-1);if(o.length===0){const d=splitTomlSections(n),p=d[0],k=t[0],g=b(p.lines,k,r);if(g===p.lines)return n;const S=d.flatMap((T,j)=>j===0?g:T.lines);return h(S.join(`
14
- `))}let i=I(n,o);const s=splitTomlSections(i),l=s.findIndex(d=>sameKey(d.key,o));if(l<0)return i;const c=s[l],f=t[t.length-1],a=b(c.lines,f,r);if(a===c.lines)return i;const u=s.flatMap((d,p)=>p===l?a:d.lines);return h(u.join(`
15
- `))}export function removeTomlValueInText(n,t){if(t.length===0)return{text:n,removed:!1};const e=splitTomlSections(n),r=t.slice(0,-1),o=t[t.length-1];for(let i=0;i<e.length;i++){const s=e[i];if(!(r.length===0?s.key===null:sameKey(s.key,r)))continue;const c=E(s.lines,o);if(c!==s.lines){const f=e.flatMap((a,u)=>u===i?c:a.lines);return{text:h(f.join(`
16
- `)),removed:!0}}}return{text:n,removed:!1}}function b(n,t,e){const r=[];let o=!1;for(let s=0;s<n.length;s++){const l=n[s],c=l.trim();if(!o&&(c.startsWith(`${t} =`)||c.startsWith(`${t}=`))){r.push(e),o=!0;continue}r.push(l)}if(o)return r;let i=-1;for(let s=n.length-1;s>=0;s--){const l=n[s].trim();if(l!==""&&!l.startsWith("#")){i=s;break}}return r.splice(i+1,0,e),r}function E(n,t){const e=[];let r=!1;for(const o of n){const i=o.trim();if(!r&&(i.startsWith(`${t} =`)||i.startsWith(`${t}=`))){r=!0;continue}e.push(o)}return r?e:n}function I(n,t){let e=n;for(let r=1;r<=t.length;r++){const o=t.slice(0,r),i=splitTomlSections(e);if(i.some(f=>sameKey(f.key,o)||f.key!==null&&m(f.key,o)))continue;const s=o.slice(0,-1),l=s.length===0?i[0]:i.find(f=>sameKey(f.key,s)),c=o[r-1];if(l){const f=K(l.lines,c);if(f){const a=i.indexOf(l);e=h([...i.flatMap((u,d)=>d===a?f.lines:u.lines),...f.sectionLines].join(`
17
- `));continue}}e=upsertTomlSection(e,[...o],[])}return e}function K(n,t){const e=n.findIndex(f=>{const a=f.trim();return a.startsWith(`${t} =`)&&a.includes("{")});if(e<0)return null;const r=n[e].trim(),o=r.slice(r.indexOf("=")+1).trim();let i;try{i=W(`v = ${o}`)}catch{return null}const s=i.v;if(!s||typeof s!="object"||Array.isArray(s))return null;const l=Object.entries(s).map(([f,a])=>`${renderTomlKey(f)} = ${renderTomlValue(a)}`),c=[...n];return c.splice(e,1),{lines:c,sectionLines:[`[${t}]`,...l]}}
11
+ `}export function upsertTomlSection(t,n,e){const r=splitTomlSections(t);let i=-1,o=-1;const s=new Set;for(let f=0;f<r.length;f++){const h=r[f].key;sameKey(h,n)?(i<0&&(i=f),s.add(f),o=f):g(h,n)&&(s.add(f),o=f)}if(i<0)return C(t,[renderTomlHeader(n),...e]);const l=r[o].lines,u=l.slice(l.length-A(l)),c=[renderTomlHeader(n),...e,...u],a=[];for(let f=0;f<r.length;f++)f===i&&a.push(...c),!s.has(f)&&a.push(...r[f].lines);return p(a.join(`
12
+ `))}export function removeTomlSection(t,n){const e=splitTomlSections(t),r=new Set;for(let o=0;o<e.length;o++){const s=e[o].key;(sameKey(s,n)||g(s,n))&&r.add(o)}if(r.size===0)return{text:t,removed:!1};const i=[];for(let o=0;o<e.length;o++)r.has(o)||i.push(...e[o].lines);return{text:p(i.join(`
13
+ `)),removed:!0}}export function parseSectionEntries(t){const n=[];for(const e of t){const r=e.trim();if(r===""||r.startsWith("#")||r.startsWith("["))continue;const i=/^("[^"]*"|'[^']*'|[A-Za-z0-9_-]+)\s*=/.exec(r);if(!i)continue;const o=parseDottedKey(i[1]);o===null||o.length!==1||n.push([o[0],e])}return n}export function upsertCodexPluginEnabledInText(t,n,e){const r=["plugins",n],i=splitTomlSections(t).find(s=>sameKey(s.key,r)),o=[`enabled = ${e?"true":"false"}`];if(i)for(const[s,l]of parseSectionEntries(i.lines.slice(1)))s!=="enabled"&&o.push(l);return upsertTomlSection(t,r,o)}export function renderTomlValue(t){return t==null?'""':typeof t=="boolean"?t?"true":"false":typeof t=="number"?Number.isFinite(t)?String(t):'""':typeof t=="string"?renderTomlString(t):Array.isArray(t)?`[${t.map(renderTomlValue).join(", ")}]`:`{ ${Object.entries(t).filter(([,n])=>n!==void 0).map(([n,e])=>`${renderTomlKey(n)} = ${renderTomlValue(e)}`).join(", ")} }`}export function setTomlValueInText(t,n,e){if(n.length===0)return t;const r=`${renderTomlKey(n[n.length-1])} = ${renderTomlValue(e)}`,i=n.slice(0,-1);if(i.length===0){const h=splitTomlSections(t),d=h[0],k=n[0],m=b(d.lines,k,r);if(m===d.lines)return t;const j=h.flatMap((T,v)=>v===0?m:T.lines);return p(j.join(`
14
+ `))}let o=I(t,i);const s=splitTomlSections(o),l=s.findIndex(h=>sameKey(h.key,i));if(l<0)return o;const u=s[l],c=n[n.length-1],a=b(u.lines,c,r);if(a===u.lines)return o;const f=s.flatMap((h,d)=>d===l?a:h.lines);return p(f.join(`
15
+ `))}export function removeTomlValueInText(t,n){if(n.length===0)return{text:t,removed:!1};const e=splitTomlSections(t),r=n.slice(0,-1),i=n[n.length-1];for(let o=0;o<e.length;o++){const s=e[o];if(!(r.length===0?s.key===null:sameKey(s.key,r)))continue;const l=E(s.lines,i);if(l!==s.lines){const u=e.flatMap((c,a)=>a===o?l:c.lines);return{text:p(u.join(`
16
+ `)),removed:!0}}}return{text:t,removed:!1}}function b(t,n,e){const r=[];let i=!1;for(let s=0;s<t.length;s++){const l=t[s],u=l.trim();if(!i&&(u.startsWith(`${n} =`)||u.startsWith(`${n}=`))){r.push(e),i=!0;continue}r.push(l)}if(i)return r;let o=-1;for(let s=t.length-1;s>=0;s--){const l=t[s].trim();if(l!==""&&!l.startsWith("#")){o=s;break}}return r.splice(o+1,0,e),r}function E(t,n){const e=[];let r=!1;for(const i of t){const o=i.trim();if(!r&&(o.startsWith(`${n} =`)||o.startsWith(`${n}=`))){r=!0;continue}e.push(i)}return r?e:t}function I(t,n){let e=t;for(let r=1;r<=n.length;r++){const i=n.slice(0,r),o=splitTomlSections(e);if(o.some(c=>sameKey(c.key,i)||c.key!==null&&g(c.key,i)))continue;const s=i.slice(0,-1),l=s.length===0?o[0]:o.find(c=>sameKey(c.key,s)),u=i[r-1];if(l){const c=K(l.lines,u);if(c){const a=o.indexOf(l);e=p([...o.flatMap((f,h)=>h===a?c.lines:f.lines),...c.sectionLines].join(`
17
+ `));continue}}e=upsertTomlSection(e,[...i],[])}return e}function K(t,n){const e=t.findIndex(c=>{const a=c.trim();return a.startsWith(`${n} =`)&&a.includes("{")});if(e<0)return null;const r=t[e].trim(),i=r.slice(r.indexOf("=")+1).trim();let o;try{o=W(`v = ${i}`)}catch{return null}const s=o.v;if(!s||typeof s!="object"||Array.isArray(s))return null;const l=Object.entries(s).map(([c,a])=>`${renderTomlKey(c)} = ${renderTomlValue(a)}`),u=[...t];return u.splice(e,1),{lines:u,sectionLines:[`[${n}]`,...l]}}
@@ -1,2 +1,2 @@
1
- export function codexInterruptMarkerAt(o){let t=null;for(const e of o.split(`
2
- `)){if(!e.includes('"turn_aborted"'))continue;let r;try{r=JSON.parse(e)}catch{continue}const i=r;if(i?.payload?.type!=="turn_aborted")continue;const n=Date.parse(String(i.timestamp??""));Number.isFinite(n)&&(t===null||n>t)&&(t=n)}return t}
1
+ export function codexInterruptMarkerAt(o){let t=null;for(const n of o.split(`
2
+ `)){if(!n.includes('"turn_aborted"'))continue;let r;try{r=JSON.parse(n)}catch{continue}const i=r;if(i?.payload?.type!=="turn_aborted")continue;const e=Date.parse(String(i.timestamp??""));Number.isFinite(e)&&(t===null||e>t)&&(t=e)}return t}
@@ -1031,6 +1031,12 @@ export interface CommandExecution {
1031
1031
  at: string;
1032
1032
  /** 宿主回显的输出原文;命令没有输出就省略。 */
1033
1033
  output?: string;
1034
+ /**
1035
+ * 触发符(缺省 `/`):web 据此拼展示原文(`${sigil}${name} ${args}`)并给气泡
1036
+ * 染色——claude 的 bash 模式(`!cmd`)转录记的是 `<bash-input>`,name = 命令行
1037
+ * 原文、sigil = `!`,气泡与输入框的 bash 形态同色(品红)。
1038
+ */
1039
+ sigil?: '/' | '!';
1034
1040
  }
1035
1041
  /**
1036
1042
  * 命令面:聊天窗口 `/` 的候选清单 + 命令执行的返显。
@@ -1 +1 @@
1
- export function commandModeAt(i,e){const t=i.trim();for(const r of e)if(t.startsWith(r.sigil)&&!(r.named&&!/^[A-Za-z][A-Za-z0-9:_-]*(\s|$)/.test(t.slice(r.sigil.length))))return r;return null}export class HarnessRegistry{drivers=new Map;register(e){if(this.drivers.has(e.id))throw new Error(`harness driver already registered: ${e.id}`);this.drivers.set(e.id,e);let t=!1;return()=>{t||(t=!0,this.drivers.get(e.id)===e&&this.drivers.delete(e.id))}}get(e){return this.drivers.get(e)}all(){return[...this.drivers.values()]}byCapability(e){return this.all().filter(t=>t.capabilities.includes(e))}initFor(e){return this.drivers.get(e)?.init}unregister(e){return this.drivers.delete(e)}}export function supports(i,e){return i.capabilities.includes(e)}
1
+ export function commandModeAt(r,e){const i=r.trim();for(const t of e)if(i.startsWith(t.sigil)&&!(t.named&&!/^[A-Za-z][A-Za-z0-9:_-]*(\s|$)/.test(i.slice(t.sigil.length))))return t;return null}export class HarnessRegistry{drivers=new Map;register(e){if(this.drivers.has(e.id))throw new Error(`harness driver already registered: ${e.id}`);this.drivers.set(e.id,e);let i=!1;return()=>{i||(i=!0,this.drivers.get(e.id)===e&&this.drivers.delete(e.id))}}get(e){return this.drivers.get(e)}all(){return[...this.drivers.values()]}byCapability(e){return this.all().filter(i=>i.capabilities.includes(e))}initFor(e){return this.drivers.get(e)?.init}unregister(e){return this.drivers.delete(e)}}export function supports(r,e){return r.capabilities.includes(e)}
@@ -1,2 +1,2 @@
1
- import i from"node:path";import{generateHookHandler as p,readUserCapture as u}from"../claude/capture.js";import{generateAutoMemoryHook as m}from"../claude/helpers-gen.js";import{generateMcpJson as c,mergeMcpJson as f}from"../claude/mcp-gen.js";import{generateSettingsJson as h,mergeSettingsJson as g}from"../claude/settings-gen.js";export const WEAVE_CONTENT_MARKER="@version weave@";const d={preToolUse:!1,postToolUse:!1,userPromptSubmit:!1,sessionStart:!1,stop:!1,stopFailure:!1,subagentStop:!1,subagentStart:!1,notification:!1,postToolUseFailure:!1,permissionRequest:!1,permissionDenied:!1,preCompact:!1,sessionEnd:!1,preModelSwitch:!1,timeout:5e3,continueOnError:!0};function a(e){try{const o=JSON.parse(e);return typeof o=="object"&&o!==null&&!Array.isArray(o)?o:null}catch{return null}}function t(e){return JSON.stringify(e,null,2)+`
2
- `}function l(e){return(o,s)=>{const n=a(o),r=a(s);return n===null||r===null?null:t(e(n,r))}}async function S(e){const o=i.join(e.projectPath,".claude","helpers"),n=(await u({home:e.platform.homeDir})).installed?d:e.hooks,r=[];return e.components.helpers&&r.push({relPath:".claude/helpers/hook-handler.cjs",weaveMarker:WEAVE_CONTENT_MARKER,content:p(e.version)},{relPath:".claude/helpers/auto-memory-hook.mjs",weaveMarker:WEAVE_CONTENT_MARKER,content:m(e.version)}),e.components.settings&&r.push({relPath:".claude/settings.json",content:t(h({components:e.components,hooks:n,platform:e.platform,helpersDir:o})),merge:l(g)}),e.components.mcp&&e.mcp.weave&&r.push({relPath:".mcp.json",content:t(c({platform:e.platform,includeWeaveServer:!0})),merge:l(f)}),r}const E={claude:S,codex:async()=>[]};export function generateInitFiles(e,o){return E[e](o)}
1
+ import l from"node:path";import{generateHookHandler as i,readUserCapture as c}from"../claude/capture.js";import{generateAutoMemoryHook as u}from"../claude/helpers-gen.js";import{generateMcpJson as m,mergeMcpJson as h}from"../claude/mcp-gen.js";import{generateSettingsJson as f,mergeSettingsJson as g}from"../claude/settings-gen.js";export const WEAVE_CONTENT_MARKER="@version weave@";const d={preToolUse:!1,postToolUse:!1,userPromptSubmit:!1,sessionStart:!1,stop:!1,stopFailure:!1,subagentStop:!1,subagentStart:!1,notification:!1,postToolUseFailure:!1,permissionRequest:!1,permissionDenied:!1,preCompact:!1,sessionEnd:!1,preModelSwitch:!1,timeout:5e3,continueOnError:!0};function a(e){try{const o=JSON.parse(e);return typeof o=="object"&&o!==null&&!Array.isArray(o)?o:null}catch{return null}}function n(e){return JSON.stringify(e,null,2)+`
2
+ `}function p(e){return(o,r)=>{const t=a(o),s=a(r);return t===null||s===null?null:n(e(t,s))}}async function S(e){const o=l.join(e.projectPath,".claude","helpers"),r=(await c({home:e.platform.homeDir})).installed?d:e.hooks,t=[];return e.components.helpers&&t.push({relPath:".claude/helpers/hook-handler.cjs",weaveMarker:WEAVE_CONTENT_MARKER,content:i(e.version)},{relPath:".claude/helpers/auto-memory-hook.mjs",weaveMarker:WEAVE_CONTENT_MARKER,content:u(e.version)}),e.components.settings&&t.push({relPath:".claude/settings.json",content:n(f({components:e.components,hooks:r,platform:e.platform,helpersDir:o})),merge:p(g)}),e.components.mcp&&e.mcp.weave&&t.push({relPath:".mcp.json",content:n(m({platform:e.platform,includeWeaveServer:!0})),merge:p(h)}),t}const v={claude:S,codex:async()=>[]};export function generateInitFiles(e,o){return v[e](o)}
@@ -1,2 +1,2 @@
1
- import{readdir as d,readFile as p,unlink as g,writeFile as S}from"node:fs/promises";import r from"node:path";import{ensureDir as h,fileExists as b,writeFileIfAbsent as A}from"@weavecode/core";export class InitPipeline{ctx;skipped=[];skipReasons=new Map;constructor(t){this.ctx=t}async runSurface(){await this.ensureDirs(),await this.writeSettings(),await this.writeMcp(),await this.copySkills(),await this.copyCommands(),await this.copyAgents(),await this.injectPluginTemplates(),await this.writeHelpers()}injectPluginTemplates(){}skip(t,e){this.skipped.push(t),this.skipReasons.set(t,e)}async writeOrMergeJson(t,e,s){if(!s&&await b(t)){const n=await x(t);return n===void 0?!1:(await k(t,m(n,e)),!0)}return await k(t,e),!0}async copyDirIfAbsent(t,e,s=!1){let n;try{n=await d(t,{withFileTypes:!0})}catch{return}await h(e);for(const a of n){const o=r.join(t,a.name),c=r.join(e,a.name);if(a.isDirectory())await this.copyDirIfAbsent(o,c,s);else{const w=await p(o,"utf-8");await A(c,w,s)}}}async sweepMarked(t,e,s){const n=new Set(e),a=[],o=async c=>{let w;try{w=await d(c,{withFileTypes:!0})}catch{return}for(const l of w){const u=r.join(c,l.name);if(l.isDirectory()){await o(u);continue}const j=r.relative(t,u).split(r.sep).join("/");if(n.has(j))continue;const y=await p(u,"utf-8").catch(()=>null);y!==null&&y.includes(s)&&(await g(u),a.push(u))}};return await o(t),a}}function m(i,t){const e={...i};for(const[s,n]of Object.entries(t)){const a=e[s];e[s]=f(a)&&f(n)?m(a,n):n}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}async function x(i){try{const t=await p(i,"utf-8"),e=JSON.parse(t);return f(e)?e:void 0}catch{return}}async function k(i,t){await h(r.dirname(i)),await S(i,JSON.stringify(t,null,2)+`
1
+ import{readdir as h,readFile as p,unlink as g,writeFile as A}from"node:fs/promises";import r from"node:path";import{ensureDir as m,fileExists as D,writeFileIfAbsent as S}from"@weavecode/core";export class InitPipeline{ctx;skipped=[];skipReasons=new Map;constructor(t){this.ctx=t}async runSurface(){await this.ensureDirs(),await this.writeSettings(),await this.writeMcp(),await this.copySkills(),await this.copyCommands(),await this.copyAgents(),await this.injectPluginTemplates(),await this.writeHelpers()}injectPluginTemplates(){}skip(t,i){this.skipped.push(t),this.skipReasons.set(t,i)}async writeOrMergeJson(t,i,n){if(!n&&await D(t)){const a=await b(t);return a===void 0?!1:(await j(t,d(a,i)),!0)}return await j(t,i),!0}async copyDirIfAbsent(t,i,n=!1){let a;try{a=await h(t,{withFileTypes:!0})}catch{return}await m(i);for(const e of a){const o=r.join(t,e.name),c=r.join(i,e.name);if(e.isDirectory())await this.copyDirIfAbsent(o,c,n);else{const u=await p(o,"utf-8");await S(c,u,n)}}}async sweepMarked(t,i,n){const a=new Set(i),e=[],o=async c=>{let u;try{u=await h(c,{withFileTypes:!0})}catch{return}for(const f of u){const w=r.join(c,f.name);if(f.isDirectory()){await o(w);continue}const k=r.relative(t,w).split(r.sep).join("/");if(a.has(k))continue;const y=await p(w,"utf-8").catch(()=>null);y!==null&&y.includes(n)&&(await g(w),e.push(w))}};return await o(t),e}}function d(s,t){const i={...s};for(const[n,a]of Object.entries(t)){const e=i[n];i[n]=l(e)&&l(a)?d(e,a):a}return i}function l(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}async function b(s){try{const t=await p(s,"utf-8"),i=JSON.parse(t);return l(i)?i:void 0}catch{return}}async function j(s,t){await m(r.dirname(s)),await A(s,JSON.stringify(t,null,2)+`
2
2
  `,"utf-8")}
@@ -1 +1 @@
1
- import{CLAUDE_DRIVER as t}from"./claude/index.js";import{CODEX_DRIVER as o}from"./codex/index.js";import{HarnessRegistry as i}from"./driver.js";export const HARNESS_DRIVERS={claude:t,codex:o};export function registerRuntimeDrivers(r){for(const e of Object.values(HARNESS_DRIVERS))r.register(e)}export function createRuntimeRegistry(){const r=new i;return registerRuntimeDrivers(r),r}
1
+ import{CLAUDE_DRIVER as t}from"./claude/index.js";import{CODEX_DRIVER as o}from"./codex/index.js";import{HarnessRegistry as s}from"./driver.js";export const HARNESS_DRIVERS={claude:t,codex:o};export function registerRuntimeDrivers(r){for(const e of Object.values(HARNESS_DRIVERS))r.register(e)}export function createRuntimeRegistry(){const r=new s;return registerRuntimeDrivers(r),r}
@@ -1 +1 @@
1
- import{cp as a,lstat as c,mkdir as s,rm as u,symlink as l,unlink as m}from"node:fs/promises";import o from"node:path";export async function linkOrCopy(r,t){const i=o.resolve(r);await s(o.dirname(t),{recursive:!0});try{return await l(i,t,process.platform==="win32"?"junction":"dir"),"link"}catch(e){const n=e.code;if(n!=="EPERM"&&n!=="EEXIST"&&n!=="ENOTSUP")throw e}return await a(i,t,{recursive:!0}),"copy"}export async function removeInstalled(r){let t;try{t=await c(r)}catch{return"absent"}return t.isSymbolicLink()?(await m(r),"link"):(await u(r,{recursive:!0,force:!0}),"removed")}export async function installForm(r){try{return(await c(r)).isSymbolicLink()?"link":"copy"}catch{return"absent"}}
1
+ import{cp as c,lstat as e,mkdir as s,rm as l,symlink as m,unlink as u}from"node:fs/promises";import o from"node:path";export async function linkOrCopy(r,t){const n=o.resolve(r);await s(o.dirname(t),{recursive:!0});try{return await m(n,t,process.platform==="win32"?"junction":"dir"),"link"}catch(a){const i=a.code;if(i!=="EPERM"&&i!=="EEXIST"&&i!=="ENOTSUP")throw a}return await c(n,t,{recursive:!0}),"copy"}export async function removeInstalled(r){let t;try{t=await e(r)}catch{return"absent"}return t.isSymbolicLink()?(await u(r),"link"):(await l(r,{recursive:!0,force:!0}),"removed")}export async function installForm(r){try{return(await e(r)).isSymbolicLink()?"link":"copy"}catch{return"absent"}}
@@ -1 +1 @@
1
- export const MAX_FIELD_CHARS=4e3,MAX_ARRAY_ITEMS=200;export function capFields(t){if(typeof t=="string")return t.length>4e3?`${t.slice(0,4e3)}\u2026`:t;if(Array.isArray(t))return t.slice(0,200).map(capFields);if(t&&typeof t=="object"){const r={};for(const[o,A]of Object.entries(t))r[o]=capFields(A);return r}return t}
1
+ export const MAX_FIELD_CHARS=4e3,MAX_ARRAY_ITEMS=200;export function capFields(t){if(typeof t=="string")return t.length>4e3?`${t.slice(0,4e3)}\u2026`:t;if(Array.isArray(t))return t.slice(0,200).map(capFields);if(t&&typeof t=="object"){const r={};for(const[n,o]of Object.entries(t))r[n]=capFields(o);return r}return t}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/harness",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Pluggable harness drivers — registry, init pipeline template method, and harness integration modules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "node": ">=22.5.0"
21
21
  },
22
22
  "dependencies": {
23
- "@weavecode/core": "^0.1.7",
23
+ "@weavecode/core": "^0.1.9",
24
24
  "smol-toml": "^1.3.0"
25
25
  }
26
26
  }
@@ -1 +1 @@
1
- function i(n){return n==="__proto__"||n==="constructor"||n==="prototype"}function f(n){const e=n.split(".");if(e.some(t=>!t||i(t)))throw new Error(`\u975E\u6CD5\u914D\u7F6E\u952E\uFF1A${n}`);return e}function c(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const u=Symbol("absent");function s(n,e){let t=n;for(const o of e){if(!c(t))return u;t=t[o]}return t===void 0?u:t}function l(n,e){let t=n;for(const o of e.slice(0,-1)){const r=t[o];if(!c(r))return;t=r}delete t[e[e.length-1]]}function p(n,e,t){let o=n;for(const r of e.slice(0,-1))c(o[r])||(o[r]={}),o=o[r];o[e[e.length-1]]=t}export function getDotted(n,e){const t=s(n,f(e));return t===u?void 0:t}export function applyUpdates(n,e){const t=structuredClone(n);for(const o of e){const r=f(o.path);o.remove?l(t,r):p(t,r,o.value)}return t}
1
+ function s(n){return n==="__proto__"||n==="constructor"||n==="prototype"}function f(n){const o=n.split(".");if(o.some(t=>!t||s(t)))throw new Error(`\u975E\u6CD5\u914D\u7F6E\u952E\uFF1A${n}`);return o}function u(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const c=Symbol("absent");function i(n,o){let t=n;for(const e of o){if(!u(t))return c;t=t[e]}return t===void 0?c:t}function l(n,o){let t=n;for(const e of o.slice(0,-1)){const r=t[e];if(!u(r))return;t=r}delete t[o[o.length-1]]}function p(n,o,t){let e=n;for(const r of o.slice(0,-1))u(e[r])||(e[r]={}),e=e[r];e[o[o.length-1]]=t}export function getDotted(n,o){const t=i(n,f(o));return t===c?void 0:t}export function applyUpdates(n,o){const t=structuredClone(n);for(const e of o){const r=f(e.path);e.remove?l(t,r):p(t,r,e.value)}return t}
@@ -1,2 +1,2 @@
1
- import s from"node:fs/promises";import p from"node:path";import{randomUUID as h}from"node:crypto";export function profileKeyOf(t,n){return(t==="project"||t==="projectLocal")&&n!==null?`${t}@p${n}`:t}const I=20;function l(t,n){return p.join(t,n)}function S(t,n){return p.join(l(t,n),"profiles.json")}function w(t,n,e,r){return p.join(l(t,n),`${e}-${r}.json`)}function m(t,n){return p.join(l(t,n),"backups")}function $(t,n,e,r){return p.join(m(t,n),`${e}-${r}.json`)}async function y(t){try{const n=JSON.parse(await s.readFile(t,"utf8"));return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}catch{return null}}async function x(t,n){await s.mkdir(p.dirname(t),{recursive:!0});const e=`${t}.${process.pid}.${Date.now()}.tmp`;await s.writeFile(e,`${JSON.stringify(n,null,2)}
2
- `,"utf8"),await s.rename(e,t)}async function j(t,n){return await y(S(t,n))??{}}function g(){return{activeId:null,profiles:[]}}function v(t,n){return t[n]??g()}export async function listProfiles(t,n,e){return v(await j(t,n),e)}async function f(t,n,e,r){const a=await j(t,n),c=v(a,e);return r(c),a[e]=c,await x(S(t,n),a),c}function d(){return new Date().toISOString()}export async function writeSnapshot(t,n,e,r,a){await x(w(t,n,e,r),a)}export async function readSnapshot(t,n,e,r){return y(w(t,n,e,r))}export async function createProfile(t,n,e,r,a){const c={id:h().slice(0,8),name:r,createdAt:d(),updatedAt:d()};return await writeSnapshot(t,n,e,c.id,a),await f(t,n,e,i=>{i.profiles.push(c)}),c}export async function saveProfile(t,n,e,r,a){await writeSnapshot(t,n,e,r,a),await f(t,n,e,c=>{const i=c.profiles.find(o=>o.id===r);i&&(i.updatedAt=d())})}export async function renameProfile(t,n,e,r,a){await f(t,n,e,c=>{const i=c.profiles.find(o=>o.id===r);i&&(i.name=a,i.updatedAt=d())})}export async function removeProfile(t,n,e,r){await f(t,n,e,a=>{a.profiles=a.profiles.filter(c=>c.id!==r),a.activeId===r&&(a.activeId=null)}),await s.rm(w(t,n,e,r),{force:!0})}export async function setActive(t,n,e,r){await f(t,n,e,a=>{a.activeId=r})}export const LASTSEEN_ID="_lastseen";export async function baselineSnapshot(t,n,e,r){if(r.activeId){const a=await readSnapshot(t,n,e,r.activeId);if(a)return a}return readSnapshot(t,n,e,LASTSEEN_ID)}export async function syncBaseline(t,n,e,r,a){r.activeId&&await saveProfile(t,n,e,r.activeId,a),await writeSnapshot(t,n,e,LASTSEEN_ID,a)}function A(t){const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`}export async function pushBackup(t,n,e,r){const a=A(new Date),c=new Set((await s.readdir(m(t,n)).catch(()=>[])).filter(u=>u.startsWith(`${e}-${a}`)));let i=a;for(let u=2;c.has(`${e}-${i}.json`);u++)i=`${a}-${u}`;await x($(t,n,e,i),r);const o=(await listBackups(t,n,e)).slice(I);for(const u of o)await s.rm($(t,n,e,u),{force:!0})}export async function listBackups(t,n,e){const r=`${e}-`,a=i=>{const o=/^(\d{4}-\d{2}-\d{2}-\d{6})(?:-(\d+))?$/.exec(i);return o?+`${o[1].replace(/-/g,"")}${o[2]??"1"}`:0};return(await s.readdir(m(t,n)).catch(()=>[])).filter(i=>i.startsWith(r)&&i.endsWith(".json")).map(i=>i.slice(r.length,-5)).sort((i,o)=>a(i)-a(o)).reverse()}export async function readBackup(t,n,e,r){return/^[A-Za-z0-9-]+$/.test(r)?y($(t,n,e,r)):null}
1
+ import c from"node:fs/promises";import u from"node:path";import{randomUUID as S}from"node:crypto";export function profileKeyOf(t,n){return(t==="project"||t==="projectLocal")&&n!==null?`${t}@p${n}`:t}const g=20;function d(t,n){return u.join(t,n)}function h(t,n){return u.join(d(t,n),"profiles.json")}function w(t,n,e,r){return u.join(d(t,n),`${e}-${r}.json`)}function $(t,n){return u.join(d(t,n),"backups")}function y(t,n,e,r){return u.join($(t,n),`${e}-${r}.json`)}async function m(t){try{const n=JSON.parse(await c.readFile(t,"utf8"));return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:null}catch{return null}}async function x(t,n){await c.mkdir(u.dirname(t),{recursive:!0});const e=`${t}.${process.pid}.${Date.now()}.tmp`;await c.writeFile(e,`${JSON.stringify(n,null,2)}
2
+ `,"utf8"),await c.rename(e,t)}async function j(t,n){return await m(h(t,n))??{}}function I(){return{activeId:null,profiles:[]}}function v(t,n){return t[n]??I()}export async function listProfiles(t,n,e){return v(await j(t,n),e)}async function l(t,n,e,r){const i=await j(t,n),a=v(i,e);return r(a),i[e]=a,await x(h(t,n),i),a}function p(){return new Date().toISOString()}export async function writeSnapshot(t,n,e,r,i){await x(w(t,n,e,r),i)}export async function readSnapshot(t,n,e,r){return m(w(t,n,e,r))}export async function createProfile(t,n,e,r,i){const a={id:S().slice(0,8),name:r,createdAt:p(),updatedAt:p()};return await writeSnapshot(t,n,e,a.id,i),await l(t,n,e,o=>{o.profiles.push(a)}),a}export async function saveProfile(t,n,e,r,i){await writeSnapshot(t,n,e,r,i),await l(t,n,e,a=>{const o=a.profiles.find(f=>f.id===r);o&&(o.updatedAt=p())})}export async function renameProfile(t,n,e,r,i){await l(t,n,e,a=>{const o=a.profiles.find(f=>f.id===r);o&&(o.name=i,o.updatedAt=p())})}export async function removeProfile(t,n,e,r){await l(t,n,e,i=>{i.profiles=i.profiles.filter(a=>a.id!==r),i.activeId===r&&(i.activeId=null)}),await c.rm(w(t,n,e,r),{force:!0})}export async function setActive(t,n,e,r){await l(t,n,e,i=>{i.activeId=r})}export const LASTSEEN_ID="_lastseen";export async function baselineSnapshot(t,n,e,r){if(r.activeId){const i=await readSnapshot(t,n,e,r.activeId);if(i)return i}return readSnapshot(t,n,e,LASTSEEN_ID)}export async function syncBaseline(t,n,e,r,i){r.activeId&&await saveProfile(t,n,e,r.activeId,i),await writeSnapshot(t,n,e,LASTSEEN_ID,i)}function A(t){const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`}export async function pushBackup(t,n,e,r){const i=A(new Date),a=new Set((await c.readdir($(t,n)).catch(()=>[])).filter(s=>s.startsWith(`${e}-${i}`)));let o=i;for(let s=2;a.has(`${e}-${o}.json`);s++)o=`${i}-${s}`;await x(y(t,n,e,o),r);const f=(await listBackups(t,n,e)).slice(g);for(const s of f)await c.rm(y(t,n,e,s),{force:!0})}export async function listBackups(t,n,e){const r=`${e}-`,i=a=>{const o=/^(\d{4}-\d{2}-\d{2}-\d{6})(?:-(\d+))?$/.exec(a);return o?+`${o[1].replace(/-/g,"")}${o[2]??"1"}`:0};return(await c.readdir($(t,n)).catch(()=>[])).filter(a=>a.startsWith(r)&&a.endsWith(".json")).map(a=>a.slice(r.length,-5)).sort((a,o)=>i(a)-i(o)).reverse()}export async function readBackup(t,n,e,r){return/^[A-Za-z0-9-]+$/.test(r)?m(y(t,n,e,r)):null}
@@ -1,2 +1,2 @@
1
- import{chmodSync as o,existsSync as c,mkdirSync as i,readFileSync as u,renameSync as y,rmSync as m,writeFileSync as p}from"node:fs";import a from"node:path";import{getAiKeyPath as n}from"../db/paths.js";export function readAiKey(t=n()){if(!c(t))return null;try{const r=JSON.parse(u(t,"utf8"));return typeof r.apiKey=="string"&&r.apiKey!==""?r.apiKey:null}catch{return null}}export function writeAiKey(t,r=n()){if(t===null||t===""){m(r,{force:!0});return}i(a.dirname(r),{recursive:!0});const e=`${r}.tmp`;p(e,`${JSON.stringify({apiKey:t},null,2)}
2
- `,{encoding:"utf8",mode:384}),y(e,r);try{o(r,384)}catch{}}export function hasAiKey(t=n()){return readAiKey(t)!==null}
1
+ import{chmodSync as n,existsSync as a,mkdirSync as c,readFileSync as o,renameSync as y,rmSync as s,writeFileSync as u}from"node:fs";import l from"node:path";import{getAiKeyPath as e}from"../db/paths.js";export function readAiKey(t=e()){if(!a(t))return null;try{const r=JSON.parse(o(t,"utf8"));return typeof r.apiKey=="string"&&r.apiKey!==""?r.apiKey:null}catch{return null}}export function writeAiKey(t,r=e()){if(t===null||t===""){s(r,{force:!0});return}c(l.dirname(r),{recursive:!0});const i=`${r}.tmp`;u(i,`${JSON.stringify({apiKey:t},null,2)}
2
+ `,{encoding:"utf8",mode:384}),y(i,r);try{n(r,384)}catch{}}export function hasAiKey(t=e()){return readAiKey(t)!==null}