@weavecode/weave 0.1.4 → 0.1.6

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 (362) hide show
  1. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/README.md +14 -0
  2. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/index.js +5 -10
  3. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/encodeurl/package.json +10 -6
  4. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/CHANGELOG.md +42 -0
  5. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/README.md +38 -10
  6. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/dist/qs.js +18 -18
  7. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/parse.js +16 -4
  8. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/lib/utils.js +13 -2
  9. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/qs/package.json +1 -1
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.cjs +6 -2
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/dist/index.mjs +6 -2
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/express-rate-limit/package.json +10 -10
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +8 -0
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  20. package/node_modules/@weavecode/cli/dist/cli.js +4 -4
  21. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  22. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  23. package/node_modules/@weavecode/cli/dist/commands/daemon.d.ts +2 -0
  24. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  25. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
  26. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  27. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  28. package/node_modules/@weavecode/cli/dist/commands/msg.js +2 -2
  29. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  30. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  31. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  32. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +4 -4
  33. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +5 -1
  34. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +5 -5
  35. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  36. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  37. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +3 -3
  38. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  39. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  40. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  41. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  42. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  43. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  44. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  45. package/node_modules/@weavecode/cli/dist/init/provision.js +1 -1
  46. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  47. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  48. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  49. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  50. package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
  51. package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
  52. package/node_modules/@weavecode/cli/package.json +5 -5
  53. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  54. package/node_modules/@weavecode/core/dist/harness.d.ts +14 -0
  55. package/node_modules/@weavecode/core/dist/harness.js +1 -1
  56. package/node_modules/@weavecode/core/dist/index.d.ts +1 -1
  57. package/node_modules/@weavecode/core/dist/index.js +1 -1
  58. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  59. package/node_modules/@weavecode/core/dist/types.js +1 -1
  60. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  61. package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
  62. package/node_modules/@weavecode/core/package.json +1 -1
  63. package/node_modules/@weavecode/harness/dist/claude/assets.js +4 -4
  64. package/node_modules/@weavecode/harness/dist/claude/capture.js +9 -9
  65. package/node_modules/@weavecode/harness/dist/claude/commands.d.ts +3 -0
  66. package/node_modules/@weavecode/harness/dist/claude/commands.js +2 -3
  67. package/node_modules/@weavecode/harness/dist/claude/config.js +2 -2
  68. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  69. package/node_modules/@weavecode/harness/dist/claude/edits.js +1 -1
  70. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  71. package/node_modules/@weavecode/harness/dist/claude/images.js +2 -2
  72. package/node_modules/@weavecode/harness/dist/claude/index.d.ts +1 -0
  73. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  74. package/node_modules/@weavecode/harness/dist/claude/liveness.js +1 -1
  75. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
  76. package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
  77. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
  78. package/node_modules/@weavecode/harness/dist/claude/narration.d.ts +0 -11
  79. package/node_modules/@weavecode/harness/dist/claude/narration.js +1 -1
  80. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  81. package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -1
  82. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  83. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  84. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  85. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
  86. package/node_modules/@weavecode/harness/dist/claude/resume.js +1 -1
  87. package/node_modules/@weavecode/harness/dist/claude/rewind.d.ts +8 -0
  88. package/node_modules/@weavecode/harness/dist/claude/rewind.js +1 -0
  89. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
  90. package/node_modules/@weavecode/harness/dist/claude/side-question.js +2 -2
  91. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +39 -18
  92. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -1
  93. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -2
  94. package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.d.ts +26 -0
  95. package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.js +2 -0
  96. package/node_modules/@weavecode/harness/dist/claude/transcript.js +7 -7
  97. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  98. package/node_modules/@weavecode/harness/dist/codex/capture.js +2 -2
  99. package/node_modules/@weavecode/harness/dist/codex/commands.js +4 -4
  100. package/node_modules/@weavecode/harness/dist/codex/config.js +2 -2
  101. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  102. package/node_modules/@weavecode/harness/dist/codex/event-source.js +2 -2
  103. package/node_modules/@weavecode/harness/dist/codex/images.js +1 -1
  104. package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
  105. package/node_modules/@weavecode/harness/dist/codex/liveness.js +1 -1
  106. package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -1
  107. package/node_modules/@weavecode/harness/dist/codex/messaging.js +2 -2
  108. package/node_modules/@weavecode/harness/dist/codex/narration.js +1 -1
  109. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  110. package/node_modules/@weavecode/harness/dist/codex/plugins.js +3 -3
  111. package/node_modules/@weavecode/harness/dist/codex/provision.js +1 -1
  112. package/node_modules/@weavecode/harness/dist/codex/questions.js +2 -2
  113. package/node_modules/@weavecode/harness/dist/codex/rollout.js +5 -5
  114. package/node_modules/@weavecode/harness/dist/codex/side-question.js +4 -4
  115. package/node_modules/@weavecode/harness/dist/codex/titles.js +4 -4
  116. package/node_modules/@weavecode/harness/dist/codex/toml.js +13 -13
  117. package/node_modules/@weavecode/harness/dist/codex/transcript.js +2 -2
  118. package/node_modules/@weavecode/harness/dist/driver.d.ts +49 -1
  119. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  120. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
  121. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  122. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  123. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  124. package/node_modules/@weavecode/harness/dist/shared/json-cap.js +1 -1
  125. package/node_modules/@weavecode/harness/package.json +2 -2
  126. package/node_modules/@weavecode/server/dist/config/dotted.js +1 -1
  127. package/node_modules/@weavecode/server/dist/config/profiles.d.ts +19 -13
  128. package/node_modules/@weavecode/server/dist/config/profiles.js +2 -2
  129. package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
  130. package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
  131. package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
  132. package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -3
  133. package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
  134. package/node_modules/@weavecode/server/dist/daemon/auto-start.js +6 -6
  135. package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
  136. package/node_modules/@weavecode/server/dist/daemon/config-routes.js +1 -1
  137. package/node_modules/@weavecode/server/dist/daemon/cron.js +1 -1
  138. package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
  139. package/node_modules/@weavecode/server/dist/daemon/dashboard-pusher.js +1 -1
  140. package/node_modules/@weavecode/server/dist/daemon/data-bus.js +1 -1
  141. package/node_modules/@weavecode/server/dist/daemon/decision-config.js +2 -2
  142. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  143. package/node_modules/@weavecode/server/dist/daemon/entry.js +7 -1
  144. package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
  145. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  146. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  147. package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
  148. package/node_modules/@weavecode/server/dist/daemon/liveness.js +1 -1
  149. package/node_modules/@weavecode/server/dist/daemon/mcp-orchestration.js +1 -1
  150. package/node_modules/@weavecode/server/dist/daemon/narration-watcher.js +2 -2
  151. package/node_modules/@weavecode/server/dist/daemon/opener/backend-ghostty.js +1 -1
  152. package/node_modules/@weavecode/server/dist/daemon/opener/backend-iterm.js +1 -1
  153. package/node_modules/@weavecode/server/dist/daemon/opener/backend-konsole.js +2 -2
  154. package/node_modules/@weavecode/server/dist/daemon/opener/backend-terminal-app.js +1 -1
  155. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wezterm.js +1 -1
  156. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wt.js +1 -1
  157. package/node_modules/@weavecode/server/dist/daemon/opener/backend.js +1 -1
  158. package/node_modules/@weavecode/server/dist/daemon/opener/launch.js +1 -1
  159. package/node_modules/@weavecode/server/dist/daemon/opener/pty-terminals.js +4 -4
  160. package/node_modules/@weavecode/server/dist/daemon/opener/shared.js +1 -1
  161. package/node_modules/@weavecode/server/dist/daemon/opener/wezterm-mux.js +1 -1
  162. package/node_modules/@weavecode/server/dist/daemon/opener/wt.js +3 -3
  163. package/node_modules/@weavecode/server/dist/daemon/opener.d.ts +2 -0
  164. package/node_modules/@weavecode/server/dist/daemon/opener.js +1 -1
  165. package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
  166. package/node_modules/@weavecode/server/dist/daemon/project-files.d.ts +12 -6
  167. package/node_modules/@weavecode/server/dist/daemon/project-files.js +2 -2
  168. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
  169. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
  170. package/node_modules/@weavecode/server/dist/daemon/prompt-images.js +1 -1
  171. package/node_modules/@weavecode/server/dist/daemon/routes/hooks-admin.js +1 -1
  172. package/node_modules/@weavecode/server/dist/daemon/routes/market.js +1 -1
  173. package/node_modules/@weavecode/server/dist/daemon/routes/orchestration.js +1 -1
  174. package/node_modules/@weavecode/server/dist/daemon/routes/path-refs.js +1 -1
  175. package/node_modules/@weavecode/server/dist/daemon/routes/project-files.js +1 -1
  176. package/node_modules/@weavecode/server/dist/daemon/routes/projects.js +1 -1
  177. package/node_modules/@weavecode/server/dist/daemon/routes/search.js +1 -1
  178. package/node_modules/@weavecode/server/dist/daemon/routes/session-control.js +1 -1
  179. package/node_modules/@weavecode/server/dist/daemon/routes/session-insights.js +1 -1
  180. package/node_modules/@weavecode/server/dist/daemon/routes/settings-statusline.js +1 -1
  181. package/node_modules/@weavecode/server/dist/daemon/routes/uploads.js +1 -1
  182. package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.d.ts +3 -0
  183. package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.js +1 -0
  184. package/node_modules/@weavecode/server/dist/daemon/routes/watches.js +1 -1
  185. package/node_modules/@weavecode/server/dist/daemon/server.js +8 -8
  186. package/node_modules/@weavecode/server/dist/daemon/session-open.js +1 -1
  187. package/node_modules/@weavecode/server/dist/daemon/session-probe.d.ts +5 -4
  188. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  189. package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
  190. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.js +1 -1
  191. package/node_modules/@weavecode/server/dist/daemon/sse-hub.js +1 -1
  192. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  193. package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
  194. package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
  195. package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.js +1 -1
  196. package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
  197. package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
  198. package/node_modules/@weavecode/server/dist/daemon/upload-sessions.js +1 -1
  199. package/node_modules/@weavecode/server/dist/db/db.js +6 -2
  200. package/node_modules/@weavecode/server/dist/db/layout.js +1 -1
  201. package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
  202. package/node_modules/@weavecode/server/dist/hooks/bus.d.ts +3 -1
  203. package/node_modules/@weavecode/server/dist/hooks/bus.js +1 -1
  204. package/node_modules/@weavecode/server/dist/hooks/dashboard-rate.js +1 -1
  205. package/node_modules/@weavecode/server/dist/hooks/decision-judge.js +1 -1
  206. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.d.ts +12 -6
  207. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.js +1 -1
  208. package/node_modules/@weavecode/server/dist/hooks/delivery/channels.d.ts +3 -3
  209. package/node_modules/@weavecode/server/dist/hooks/delivery/channels.js +1 -1
  210. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.d.ts +19 -9
  211. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.js +1 -1
  212. package/node_modules/@weavecode/server/dist/hooks/delivery/queue.js +1 -1
  213. package/node_modules/@weavecode/server/dist/hooks/delivery/relay.d.ts +2 -2
  214. package/node_modules/@weavecode/server/dist/hooks/delivery/relay.js +1 -1
  215. package/node_modules/@weavecode/server/dist/hooks/delivery/send.js +2 -2
  216. package/node_modules/@weavecode/server/dist/hooks/delivery/views.d.ts +3 -1
  217. package/node_modules/@weavecode/server/dist/hooks/delivery/views.js +1 -1
  218. package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
  219. package/node_modules/@weavecode/server/dist/hooks/edge-extract.js +1 -1
  220. package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
  221. package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
  222. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -2
  223. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  224. package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
  225. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.d.ts +45 -38
  226. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +5 -3
  227. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  228. package/node_modules/@weavecode/server/dist/hooks/orchestration-engine.js +7 -7
  229. package/node_modules/@weavecode/server/dist/hooks/orchestration-graph.js +1 -1
  230. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
  231. package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
  232. package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
  233. package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
  234. package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
  235. package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
  236. package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
  237. package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
  238. package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
  239. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  240. package/node_modules/@weavecode/server/dist/hooks/side-questions.js +1 -1
  241. package/node_modules/@weavecode/server/dist/hooks/synthetic-sessions.js +1 -1
  242. package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
  243. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  244. package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
  245. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  246. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  247. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  248. package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
  249. package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
  250. package/node_modules/@weavecode/server/dist/install/global-config.js +1 -1
  251. package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
  252. package/node_modules/@weavecode/server/dist/install/init-files.js +2 -2
  253. package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
  254. package/node_modules/@weavecode/server/dist/install/installer.js +1 -1
  255. package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
  256. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  257. package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
  258. package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
  259. package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
  260. package/node_modules/@weavecode/server/dist/install/project-config.js +1 -1
  261. package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
  262. package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
  263. package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
  264. package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
  265. package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
  266. package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
  267. package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
  268. package/node_modules/@weavecode/server/dist/market/import.js +2 -2
  269. package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
  270. package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
  271. package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
  272. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  273. package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +5 -5
  274. package/node_modules/@weavecode/server/dist/repositories/hook-events.d.ts +1 -1
  275. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +5 -5
  276. package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
  277. package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
  278. package/node_modules/@weavecode/server/dist/repositories/orchestrations.js +7 -7
  279. package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
  280. package/node_modules/@weavecode/server/dist/repositories/projects.js +2 -2
  281. package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
  282. package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
  283. package/node_modules/@weavecode/server/dist/repositories/sessions.d.ts +11 -1
  284. package/node_modules/@weavecode/server/dist/repositories/sessions.js +4 -2
  285. package/node_modules/@weavecode/server/dist/repositories/uploads.d.ts +14 -4
  286. package/node_modules/@weavecode/server/dist/repositories/uploads.js +11 -11
  287. package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
  288. package/node_modules/@weavecode/server/dist/statusline/generator.js +1 -1
  289. package/node_modules/@weavecode/server/dist/statusline/manager.js +3 -3
  290. package/node_modules/@weavecode/server/dist/surfaces.d.ts +3 -1
  291. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  292. package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
  293. package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
  294. package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
  295. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
  296. package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
  297. package/node_modules/@weavecode/server/package.json +4 -4
  298. package/node_modules/@weavecode/server/web/dist/assets/{abnfDiagram-WEYOIA3C-DA-K085F.js → abnfDiagram-WEYOIA3C-CbIFQh0R.js} +1 -1
  299. package/node_modules/@weavecode/server/web/dist/assets/{arc-BI1jnmdZ.js → arc-DH8-rYAa.js} +1 -1
  300. package/node_modules/@weavecode/server/web/dist/assets/{architectureDiagram-ZHVYKT53-DbdBgric.js → architectureDiagram-ZHVYKT53-qnv6S0sc.js} +1 -1
  301. package/node_modules/@weavecode/server/web/dist/assets/{blockDiagram-RJAE7QA3-BPRBmzb-.js → blockDiagram-RJAE7QA3-pT5eO-cB.js} +1 -1
  302. package/node_modules/@weavecode/server/web/dist/assets/{c4Diagram-XDPPPE54-C4D5sRs1.js → c4Diagram-XDPPPE54-DHDBDMb1.js} +1 -1
  303. package/node_modules/@weavecode/server/web/dist/assets/channel-BHPeeuzN.js +1 -0
  304. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2E7WHVMD-9ZSKiNU3.js → chunk-2E7WHVMD-CT951PH5.js} +1 -1
  305. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2Q5K7J3B-i0AOjw_8.js → chunk-2Q5K7J3B-E5AD7_ZY.js} +1 -1
  306. package/node_modules/@weavecode/server/web/dist/assets/{chunk-4EMNKR2T-DTpLfX1H.js → chunk-4EMNKR2T-DWz9qkcy.js} +1 -1
  307. package/node_modules/@weavecode/server/web/dist/assets/{chunk-55XCU76K-COQYRD4q.js → chunk-55XCU76K-D-SgWD8w.js} +1 -1
  308. package/node_modules/@weavecode/server/web/dist/assets/{chunk-5VM5RSS4-VsftEbvo.js → chunk-5VM5RSS4-ci6YzbO5.js} +1 -1
  309. package/node_modules/@weavecode/server/web/dist/assets/{chunk-JWPE2WC7-DonektJN.js → chunk-JWPE2WC7-CY4mr2f4.js} +1 -1
  310. package/node_modules/@weavecode/server/web/dist/assets/{chunk-VQ5W62QI-CaKUwuul.js → chunk-VQ5W62QI-CON8zyg8.js} +1 -1
  311. package/node_modules/@weavecode/server/web/dist/assets/{chunk-XXDRQBXY-DXH3D_MT.js → chunk-XXDRQBXY-DXXXZ4pW.js} +1 -1
  312. package/node_modules/@weavecode/server/web/dist/assets/{chunk-ZCHMQSOR-COwyAuGn.js → chunk-ZCHMQSOR-CukvPvkM.js} +2 -2
  313. package/node_modules/@weavecode/server/web/dist/assets/{classDiagram-v2-4MYWR3UA-DEvMZ6mX.js → classDiagram-v2-4MYWR3UA-GiWZ9xtF.js} +1 -1
  314. package/node_modules/@weavecode/server/web/dist/assets/{cose-bilkent-JH36ORCC-6JBJHfH6.js → cose-bilkent-JH36ORCC-D7aJ-akq.js} +1 -1
  315. package/node_modules/@weavecode/server/web/dist/assets/{cynefin-EF2NZ3EQ-C4GM4sjT.js → cynefin-EF2NZ3EQ-9B__MaRM.js} +1 -1
  316. package/node_modules/@weavecode/server/web/dist/assets/{cynefinDiagram-WF24UDRP-Cqgi0MBP.js → cynefinDiagram-WF24UDRP-B2ujZh2k.js} +1 -1
  317. package/node_modules/@weavecode/server/web/dist/assets/{dagre-NK4GIZVX-CljrnkCY.js → dagre-NK4GIZVX-nHaB6IWf.js} +1 -1
  318. package/node_modules/@weavecode/server/web/dist/assets/{diagram-CBK3MWTC-C3PyOj5J.js → diagram-CBK3MWTC-xKfjDvgr.js} +1 -1
  319. package/node_modules/@weavecode/server/web/dist/assets/{diagram-I5XIIV2D-I5brQlaZ.js → diagram-I5XIIV2D-BHT2-5mY.js} +1 -1
  320. package/node_modules/@weavecode/server/web/dist/assets/{diagram-ODIL2UCW-BX9uFNbU.js → diagram-ODIL2UCW-CckywF4W.js} +1 -1
  321. package/node_modules/@weavecode/server/web/dist/assets/{diagram-PFBEJUXE-y7D-VmqJ.js → diagram-PFBEJUXE-Dpjlc7Wh.js} +1 -1
  322. package/node_modules/@weavecode/server/web/dist/assets/{diagram-RJA3I4VV-DLUL8W42.js → diagram-RJA3I4VV-M6WznOaW.js} +1 -1
  323. package/node_modules/@weavecode/server/web/dist/assets/{diagram-TYUNFSNR-DLCC3ILi.js → diagram-TYUNFSNR-DgRJ3zL1.js} +1 -1
  324. package/node_modules/@weavecode/server/web/dist/assets/{ebnfDiagram-V4P3TTPT-D7vALia7.js → ebnfDiagram-V4P3TTPT-BzzVN__a.js} +1 -1
  325. package/node_modules/@weavecode/server/web/dist/assets/{elk-QONTBCTQ-Ct2_hatz.js → elk-QONTBCTQ-Ch6Gs9G9.js} +1 -1
  326. package/node_modules/@weavecode/server/web/dist/assets/{erDiagram-KYQIGQAA-DxLai58T.js → erDiagram-KYQIGQAA-COxT-Pxb.js} +1 -1
  327. package/node_modules/@weavecode/server/web/dist/assets/{flowDiagram-IUGLLWBU-AWn2IHrF.js → flowDiagram-IUGLLWBU-CJVWnTBa.js} +1 -1
  328. package/node_modules/@weavecode/server/web/dist/assets/{ganttDiagram-R7GPNTJY-DmRHd4Wz.js → ganttDiagram-R7GPNTJY-BkRpWPUl.js} +1 -1
  329. package/node_modules/@weavecode/server/web/dist/assets/{gitGraphDiagram-PDYL7XHY-Ccj-t3zg.js → gitGraphDiagram-PDYL7XHY-Ba8BJcvZ.js} +1 -1
  330. package/node_modules/@weavecode/server/web/dist/assets/index-CtifxEiF.css +11 -0
  331. package/node_modules/@weavecode/server/web/dist/assets/index-FwH9INgS.js +1090 -0
  332. package/node_modules/@weavecode/server/web/dist/assets/{infoDiagram-MVDRKAX5-BHquFlQa.js → infoDiagram-MVDRKAX5-HTQ5FUNK.js} +1 -1
  333. package/node_modules/@weavecode/server/web/dist/assets/{ishikawaDiagram-HPEHV2GE-CVogEbdm.js → ishikawaDiagram-HPEHV2GE-BNjEDIZy.js} +1 -1
  334. package/node_modules/@weavecode/server/web/dist/assets/{journeyDiagram-BOSHW7O7-DC9XG9oh.js → journeyDiagram-BOSHW7O7-Cao6h91a.js} +1 -1
  335. package/node_modules/@weavecode/server/web/dist/assets/{kanban-definition-FNSA4HC5-C_eu7DC_.js → kanban-definition-FNSA4HC5-CXIx2CHQ.js} +1 -1
  336. package/node_modules/@weavecode/server/web/dist/assets/{linear-keTbWHJ-.js → linear-65WmlvQb.js} +1 -1
  337. package/node_modules/@weavecode/server/web/dist/assets/{mermaid.core-4sbg0MnY.js → mermaid.core-D39fi_iR.js} +4 -4
  338. package/node_modules/@weavecode/server/web/dist/assets/{mindmap-definition-6OY57UG3-kMQS0S2l.js → mindmap-definition-6OY57UG3-DHqpz_AK.js} +1 -1
  339. package/node_modules/@weavecode/server/web/dist/assets/{pegDiagram-ECIUJNBX-DcUFoEwP.js → pegDiagram-ECIUJNBX-Cpy1nsER.js} +1 -1
  340. package/node_modules/@weavecode/server/web/dist/assets/{pieDiagram-GNMPY74T-BQJ7WDCx.js → pieDiagram-GNMPY74T-B1IyNqzr.js} +1 -1
  341. package/node_modules/@weavecode/server/web/dist/assets/{quadrantDiagram-D57K4MC3-C7Oi1-sq.js → quadrantDiagram-D57K4MC3-zSM6o7mB.js} +1 -1
  342. package/node_modules/@weavecode/server/web/dist/assets/{railroadDiagram-Y72NRBL7-CEF2QbOF.js → railroadDiagram-Y72NRBL7-oM4XJIwA.js} +1 -1
  343. package/node_modules/@weavecode/server/web/dist/assets/{requirementDiagram-EQYSW5RA-CTjjFS7X.js → requirementDiagram-EQYSW5RA-CbCLBjHf.js} +1 -1
  344. package/node_modules/@weavecode/server/web/dist/assets/{sankeyDiagram-SY24JHO5-j0S5kubS.js → sankeyDiagram-SY24JHO5-BucVk6EP.js} +1 -1
  345. package/node_modules/@weavecode/server/web/dist/assets/{sequenceDiagram-BLEHNHQU-B76EsZp4.js → sequenceDiagram-BLEHNHQU-Dg8CYEnT.js} +1 -1
  346. package/node_modules/@weavecode/server/web/dist/assets/{sizeCapture-INFHLROL-r0DZuqAy.js → sizeCapture-INFHLROL-C51zb7Oc.js} +1 -1
  347. package/node_modules/@weavecode/server/web/dist/assets/{stateDiagram-v2-A6IESKWZ-B4DR9LHz.js → stateDiagram-v2-A6IESKWZ-BvK2l3is.js} +1 -1
  348. package/node_modules/@weavecode/server/web/dist/assets/{swimlanes-B3ENRKFQ-Dbcl85ro.js → swimlanes-B3ENRKFQ-Ds7QOfXW.js} +1 -1
  349. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-ByBF02UJ.js +8 -0
  350. package/node_modules/@weavecode/server/web/dist/assets/{timeline-definition-JXYKGLGB-BlBXXRNf.js → timeline-definition-JXYKGLGB-CadU4Qq4.js} +1 -1
  351. package/node_modules/@weavecode/server/web/dist/assets/{usecaseDiagram-WPOLBNNX-Ck1M0dpc.js → usecaseDiagram-WPOLBNNX-BYuZwTDZ.js} +1 -1
  352. package/node_modules/@weavecode/server/web/dist/assets/{vennDiagram-Q3Y3IDCW-N8B-ohWk.js → vennDiagram-Q3Y3IDCW-C7zgxe07.js} +1 -1
  353. package/node_modules/@weavecode/server/web/dist/assets/{wardleyDiagram-IVAIDKWA-DX-AMXq_.js → wardleyDiagram-IVAIDKWA-DA4Otf4s.js} +1 -1
  354. package/node_modules/@weavecode/server/web/dist/assets/{xychartDiagram-4URNHDU4-4fgL48Yl.js → xychartDiagram-4URNHDU4-Bs5YGwMU.js} +1 -1
  355. package/node_modules/@weavecode/server/web/dist/index.html +2 -2
  356. package/node_modules/@weavecode/server/web/dist/sw.js +14 -12
  357. package/node_modules/@weavecode/templates/package.json +2 -2
  358. package/package.json +6 -6
  359. package/node_modules/@weavecode/server/web/dist/assets/channel-DcCJrvon.js +0 -1
  360. package/node_modules/@weavecode/server/web/dist/assets/index-BSxzia7U.js +0 -1031
  361. package/node_modules/@weavecode/server/web/dist/assets/index-CEpJpR7P.css +0 -11
  362. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-CZ_6SSBd.js +0 -8
@@ -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 l 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(n){return l.join(w(n),"thread-writer-locks")}async function S(n,p){const{spawn:o}=await import("node:child_process"),r=t=>t.replace(/'/g,"''"),i=["$results = @()",...n.map(t=>{const s=l.win32.join(p,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=o("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(n,p=Date.now()){const o=codexThreadLockDir(n);let r;try{r=u(o)}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,o):()=>h())(i),s=new Map;for(const e of i){const c=e.replace(/\.lock$/i,"");if(t.has(e)){f.set(c,p),s.set(c,!0);continue}let a=f.get(c);if(a===void 0){try{a=m(l.join(o,e)).mtimeMs}catch{continue}f.set(c,a)}p-a>=CODEX_LOCK_GRACE_MS&&s.set(c,!1)}return s}export const CODEX_LIVENESS={harness:"codex",alive(n){return codexLivenessById().then(p=>{if(!n)return p;const o=new Map;for(const r of n){const i=p.get(r);i!==void 0&&o.set(r,i)}return o})}};
@@ -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:r}){if(!r)return null;const t=[],e=i({input:l(r,{encoding:"utf8"}),crlfDelay:1/0});try{for await(const n of e){const s=a(n);s&&t.push(s)}}catch{return null}finally{e.close()}return t},lineParser:a};function a(r){if(!r.includes('"AgentMessage"'))return null;let t;try{t=JSON.parse(r)}catch{return null}if(t.type!=="event_msg")return null;const e=t.payload;if(e?.type!=="AgentMessage")return null;const n=typeof e.message=="string"?e.message:"";return n.trim()?{at:typeof t.timestamp=="string"?t.timestamp:null,text:n}: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 o=s(await i(e,"utf-8")).plugins;if(!o||typeof o!="object"||Array.isArray(o))return{};const r={};for(const[a,t]of Object.entries(o))t&&typeof t=="object"&&typeof t.enabled=="boolean"&&(r[a]=t.enabled);return r}catch{return{}}}export const CODEX_PLUGIN_STATE={readGlobalEnabled:()=>w(f.userConfigFile(n())),async writeGlobalEnabled(e,o){const r=f.userConfigFile(n());let a="";if(await c(r)){a=await i(r,"utf-8");try{s(a)}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(a,e,o),"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 j,writeFile as x}from"node:fs/promises";import l 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 _=6e4,D=2e3,A=64*1024;export function codexCommandLine(a){return["codex",...a.map(y=>`"${y.replace(/"/g,'\\"')}"`)].join(" ")}function q(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 J=(a,y)=>new Promise((h,u)=>{const k=process.platform==="win32",c=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=e=>{f||(f=!0,clearTimeout(t),u(new Error(F(e))))},t=setTimeout(()=>{q(c),E(`${d}: timed out after ${y.timeoutMs}ms`)},y.timeoutMs);c.stdout?.setEncoding("utf8"),c.stdout?.on("data",e=>{p.length<A&&(p+=e)}),c.stderr?.setEncoding("utf8"),c.stderr?.on("data",e=>{m.length<A&&(m+=e)}),c.on("error",e=>E(`${d}: ${e.message}`)),c.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??J,h=t=>y(t,{timeoutMs:_}),u=()=>K.userConfigFile(I()),k=()=>l.join(I(),".codex","plugins","cache"),c=(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 j(t,{withFileTypes:!0})}catch{return e}for(const n of i){if(!n.isDirectory()&&!n.isSymbolicLink())continue;const r=l.join(t,n.name);let o;try{o=await j(r,{withFileTypes:!0})}catch{continue}for(const s of o){if(!s.isDirectory()&&!s.isSymbolicLink())continue;const w=l.join(r,s.name);let g;try{g=await j(w,{withFileTypes:!0})}catch{continue}const $=g.filter(b=>b.isDirectory()||b.isSymbolicLink());if($.length===0)continue;const C=$.map(b=>b.name).sort().pop(),G=`${s.name}@${n.name}`;e[G]=[{scope:"user",installPath:l.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}:{}}},E=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=l.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=`./${l.relative(t.dir,i).split(l.sep).join("/")}`,w={name:e,source:s},g=o.findIndex($=>$?.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(l.dirname(n),{recursive:!0}),await x(n,`${JSON.stringify(r,null,2)}
3
+ `,"utf8")};return{projectPluginDir:t=>l.join(t,".codex","plugins"),pluginKey:c,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(l.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=c(i,n?.name),o=(await m())[r];if(o&&o.length>0)return f(r,o,!0);if(n)await E(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())[c(t,e)];return!!i&&i.length>0},async uninstall(t,e){const i=c(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=l.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(l.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())[c(e,i)]??!1},async setProjectEnabled(t,e,i,n){const r=c(e,n),o=await d()??"";await v(l.dirname(u()),{recursive:!0}),await x(u(),P(o,r,i),"utf8")},async readGlobalEnabled(){return p(await d())},async writeGlobalEnabled(t,e){const i=await d()??"";await v(l.dirname(u()),{recursive:!0}),await x(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(l.dirname(u()),{recursive:!0}),await x(u(),o,"utf8");return}await v(l.dirname(u()),{recursive:!0}),await x(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(s=>{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"]}),n=setTimeout(()=>{r.kill("SIGKILL"),s(null)},8e3);r.stdout?.on("data",e=>i+=e.toString()),r.on("error",()=>{clearTimeout(n),s(null)}),r.on("close",()=>{clearTimeout(n);try{const e=JSON.parse(i);typeof e.managedCodexVersion=="string"&&typeof e.cliVersion=="string"?s({managedCodexVersion:e.managedCodexVersion,cliVersion:e.cliVersion}):s(null)}catch{s(null)}})})}export async function codexProvisionCheck(o,a=()=>f(o),s=c()){const i=[],r=[],n=d(l(s)),e=d(u(s));if(n&&!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:n,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(s){const e=s&&typeof s=="object"?s:{},n=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=n||o||"Codex wants to run a command";return t.length>200?`${t.slice(0,200)}\u2026`:t}function p(s){const e=s&&typeof s=="object"?s:{},n=typeof e.command=="string"?e.command:"";if(!n)return"Codex wants to apply a patch";const o=[...n.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map(i=>i[1]),t=o.length>0?o.join(", "):n.split(`
2
+ `)[0]??"patch";return t.length>200?`${t.slice(0,200)}\u2026`:t}function u(s,e){const n=e&&typeof e=="object"&&Object.keys(e).length>0?JSON.stringify(e):"",o=`Codex wants to call ${s}`,t=n?`${o} ${n}`:o;return t.length>200?`${t.slice(0,200)}\u2026`:t}function l(s,e){return[{keys:["y"],label:s},{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(s,e){if(s!=="PermissionRequest")return null;const n=e.raw&&typeof e.raw=="object"?e.raw:{},o=e.toolName,t=e.toolInput;return(typeof n.permission_mode=="string"?n.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 k=2e3,f=/^[^\x00-\x1f\x7f]+$/,a="Side from main thread",E=/•\s+Working\s*\(/,c=/^\s*Worked for\s+/,D=/^\s*└\s+Tip:/,m="\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(m,s){const r=v.join(y(s),"session_index.jsonl");let o;try{o=g(r)}catch{return null}const a=u.get(r);if(!a||a.mtimeMs!==o.mtimeMs||a.size!==o.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:o.mtimeMs,size:o.size,names:e})}const n=u.get(r).names.get(m)??null;return n!=null&&n.trim()?n:null}export function codexSetSessionTitle(m,s){return new Promise((r,o)=>{const a=s.trim();if(!a){o(new Error("thread name must not be empty"));return}const n=process.platform==="win32",e=w(n?process.env.ComSpec||"cmd.exe":"codex",n?["/d","/s","/c",E(["app-server"])]:["app-server"],{windowsHide:!0,windowsVerbatimArguments:n,stdio:["pipe","pipe","pipe"]});let p=!1,i="";const t=d=>{p||(p=!0,clearTimeout(x),n&&e.pid!==void 0?w("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).unref():e.kill("SIGKILL"),d?o(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 c=null;try{c=JSON.parse(h)}catch{continue}if(c?.id===1){l({jsonrpc:"2.0",method:"initialized",params:{}}),l({jsonrpc:"2.0",id:2,method:"thread/name/set",params:{threadId:m,name:a}});continue}c?.id===2&&t(c.error?new Error(String(c.error.message??"thread/name/set failed")):null)}})})}export function createCodexTitleSurface(m={}){return{harness:"codex",sessionTitleOf:s=>Promise.resolve(codexSessionTitleOf(s,m.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}
@@ -7,7 +7,7 @@ import type { FileAssetCategory } from './shared/file-specs.js';
7
7
  * 依赖硬约束:本包仅依赖 @weavecode/core(永不依赖 server/cli,防 statusline/i18n 成环)。
8
8
  */
9
9
  /** 可插拔能力槽——driver 声明持有哪些,注册表按能力检索。 */
10
- export type HarnessCapability = 'init' | 'events' | 'assets' | 'resume' | 'detect' | 'plugins' | 'pluginState' | 'messaging' | 'questions' | 'capture' | 'statusline' | 'logs' | 'config' | 'edits' | 'images' | 'narration' | 'commands' | 'provision' | 'liveness';
10
+ export type HarnessCapability = 'init' | 'events' | 'assets' | 'resume' | 'detect' | 'plugins' | 'pluginState' | 'messaging' | 'questions' | 'capture' | 'statusline' | 'logs' | 'config' | 'edits' | 'images' | 'narration' | 'commands' | 'provision' | 'liveness' | 'rewind';
11
11
  /**
12
12
  * 采集集成的 user 档状态(tool-object-model §2.6 基石)。
13
13
  */
@@ -1000,6 +1000,22 @@ export interface HarnessCommand {
1000
1000
  /** 触发符:缺省 `/`;codex 的 skill 是 `$name`。前端按它展示与插胶囊。 */
1001
1001
  sigil?: '/' | '$';
1002
1002
  }
1003
+ /**
1004
+ * 输入框里的一种「命令形态」:宿主自己执行、**不当作一条 prompt 提交**的敲法。
1005
+ * 触发符归 harness(claude = `/` 斜杠命令与 `!` bash 模式,codex = `/` 命令),
1006
+ * 投递闸据此走命令的短回执窗口(这类输入多半不发 prompt 提交事件),前端据此
1007
+ * 给输入框上色(颜色是渲染层的事,这里只答形态)。
1008
+ */
1009
+ export interface CommandInputMode {
1010
+ /** 形态。`bash` = 宿主本地 shell 模式(claude 输入框在此时变品红)。 */
1011
+ readonly kind: 'slash' | 'bash';
1012
+ /** 触发符:trim 后以此开头即该形态。 */
1013
+ readonly sigil: string;
1014
+ /** 触发符后必须紧跟命令名(`/name`)才算;bash 模式是整行命令行,不要求。 */
1015
+ readonly named: boolean;
1016
+ }
1017
+ /** 这段输入命中哪种命令形态(触发符表归 harness);null = 普通 prompt。 */
1018
+ export declare function commandModeAt(text: string, modes: readonly CommandInputMode[]): CommandInputMode | null;
1003
1019
  /** 转录里的一条命令执行记录(内建命令不发 hook 事件,只有转录记着)。 */
1004
1020
  export interface CommandExecution {
1005
1021
  name: string;
@@ -1015,6 +1031,8 @@ export interface CommandExecution {
1015
1031
  */
1016
1032
  export interface CommandsSurface {
1017
1033
  readonly harness: Harness;
1034
+ /** 输入框的命令形态表(触发符 + 形态);空表 = 该 harness 没有命令形态。 */
1035
+ readonly inputModes: readonly CommandInputMode[];
1018
1036
  /** 该会话此刻可用的命令(项目级命令按项目路径现扫;`homedir` 缺省 = 本机家目录)。 */
1019
1037
  list(req: {
1020
1038
  projectPath: string;
@@ -1056,6 +1074,35 @@ export interface LivenessSurface {
1056
1074
  */
1057
1075
  alive(ids?: readonly string[]): Promise<Map<string, boolean>>;
1058
1076
  }
1077
+ /** 一次对话回退(宿主 rewind):何时发生的、退回到了哪里之前。 */
1078
+ export interface RewindMark {
1079
+ /**
1080
+ * 回退发生的时刻(ISO)。claude 的锚点行自身不带 timestamp,取锚点行之前
1081
+ * 最近一条带 timestamp 转录行的时刻——rewind 只能发生在最后活动之后。
1082
+ */
1083
+ at: string;
1084
+ /**
1085
+ * 回退边界(退回到哪条消息之前)的时刻;宿主锚点只给 uuid 不给时刻,
1086
+ * server 按事件时刻近似——这里恒 null(不猜)。
1087
+ */
1088
+ boundaryAt: string | null;
1089
+ }
1090
+ /**
1091
+ * 对话回退面:宿主的 rewind(claude = Esc Esc / `/rewind`,退回代码与/或对话)
1092
+ * 在转录里留下的痕迹归 harness 解析,server 只把「哪些气泡被回退了」交给前端
1093
+ * 置灰展示。缺这个槽 = 该 harness 的回退不可观测(前端不摆「已回退」标记)。
1094
+ */
1095
+ export interface RewindSurface {
1096
+ /**
1097
+ * 该会话的全部回退(时间序);读不到(无转录 / 路径未知 / 半路出错)→
1098
+ * null(不猜)。没有回退 = 空数组。
1099
+ */
1100
+ sessionRewinds(req: {
1101
+ sessionId: string;
1102
+ /** 转录路径(server 的探针答,宿主不自己拼目录);null = 不知道在哪。 */
1103
+ transcriptPath: string | null;
1104
+ }): Promise<RewindMark[] | null>;
1105
+ }
1059
1106
  /**
1060
1107
  * 会话标题读写面:宿主侧**用户自定义名**(codex = thread name,落 session_index
1061
1108
  * 与 sqlite threads.name)的读/写通道。读 = 宿主持久层 diff 采纳(TUI 改名反显
@@ -1093,6 +1140,7 @@ export interface HarnessDriver {
1093
1140
  commands?: CommandsSurface;
1094
1141
  provision?: ProvisionSurface;
1095
1142
  liveness?: LivenessSurface;
1143
+ rewind?: RewindSurface;
1096
1144
  /** 不入 capabilities 清单——无 web 面,消费点仅 server 两处(dispatcher diff 采纳 / PATCH rename RPC)。 */
1097
1145
  titles?: SessionTitleSurface;
1098
1146
  }
@@ -1 +1 @@
1
- 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 r=!1;return()=>{r||(r=!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(r=>r.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(i,r){const t=i.trim();for(const e of r)if(t.startsWith(e.sigil)&&!(e.named&&!/^[A-Za-z][A-Za-z0-9:_-]*(\s|$)/.test(t.slice(e.sigil.length))))return e;return null}export class HarnessRegistry{drivers=new Map;register(r){if(this.drivers.has(r.id))throw new Error(`harness driver already registered: ${r.id}`);this.drivers.set(r.id,r);let t=!1;return()=>{t||(t=!0,this.drivers.get(r.id)===r&&this.drivers.delete(r.id))}}get(r){return this.drivers.get(r)}all(){return[...this.drivers.values()]}byCapability(r){return this.all().filter(t=>t.capabilities.includes(r))}initFor(r){return this.drivers.get(r)?.init}unregister(r){return this.drivers.delete(r)}}export function supports(i,r){return i.capabilities.includes(r)}
@@ -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 S,writeFileIfAbsent as b}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 S(t)){const s=await D(t);return s===void 0?!1:(await j(t,d(s,i)),!0)}return await j(t,i),!0}async copyDirIfAbsent(t,i,n=!1){let s;try{s=await h(t,{withFileTypes:!0})}catch{return}await m(i);for(const e of s){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 b(c,u,n)}}}async sweepMarked(t,i,n){const s=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(s.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(a,t){const i={...a};for(const[n,s]of Object.entries(t)){const e=i[n];i[n]=l(e)&&l(s)?d(e,s):s}return i}function l(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}async function D(a){try{const t=await p(a,"utf-8"),i=JSON.parse(t);return l(i)?i:void 0}catch{return}}async function j(a,t){await m(r.dirname(a)),await A(a,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(e){if(typeof e=="string")return e.length>4e3?`${e.slice(0,4e3)}\u2026`:e;if(Array.isArray(e))return e.slice(0,200).map(capFields);if(e&&typeof e=="object"){const r={};for(const[n,o]of Object.entries(e))r[n]=capFields(o);return r}return e}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/harness",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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.4",
23
+ "@weavecode/core": "^0.1.6",
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(o){return o==="__proto__"||o==="constructor"||o==="prototype"}function f(o){const r=o.split(".");if(r.some(t=>!t||s(t)))throw new Error(`\u975E\u6CD5\u914D\u7F6E\u952E\uFF1A${o}`);return r}function u(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}const c=Symbol("absent");function i(o,r){let t=o;for(const n of r){if(!u(t))return c;t=t[n]}return t===void 0?c:t}function l(o,r){let t=o;for(const n of r.slice(0,-1)){const e=t[n];if(!u(e))return;t=e}delete t[r[r.length-1]]}function p(o,r,t){let n=o;for(const e of r.slice(0,-1))u(n[e])||(n[e]={}),n=n[e];n[r[r.length-1]]=t}export function getDotted(o,r){const t=i(o,f(r));return t===c?void 0:t}export function applyUpdates(o,r){const t=structuredClone(o);for(const n of r){const e=f(n.path);n.remove?l(t,e):p(t,e,n.value)}return t}
@@ -2,7 +2,13 @@ import type { ConfigFileId } from '@weavecode/harness';
2
2
  /**
3
3
  * 配置快照的落盘面。`root` = `local/harness-config`(由调用方给,测试用临时目录):
4
4
  * 快照里可能带 API key ⇒ 本机专属、不进 settings 表、不随迁移带走。
5
+ *
6
+ * `file` 实参是存储键(profileKeyOf 的输出):user/global 全机共享原样;
7
+ * project/projectLocal 带 `@p<projectId>` 后缀按项目隔离——活文件路径仍由
8
+ * 调用方按真实档位解析,这里的键只管快照/备份/基线落在谁的名下。
5
9
  */
10
+ /** project/projectLocal 档的快照按项目隔离;user/global 全机共享,不带后缀。 */
11
+ export declare function profileKeyOf(file: ConfigFileId, projectId: number | null): string;
6
12
  export interface ConfigProfileMeta {
7
13
  id: string;
8
14
  name: string;
@@ -13,27 +19,27 @@ export interface ConfigProfileState {
13
19
  activeId: string | null;
14
20
  profiles: ConfigProfileMeta[];
15
21
  }
16
- export declare function listProfiles(root: string, harness: string, file: ConfigFileId): Promise<ConfigProfileState>;
22
+ export declare function listProfiles(root: string, harness: string, file: string): Promise<ConfigProfileState>;
17
23
  /** 落一份快照(整份 JSON)。 */
18
- export declare function writeSnapshot(root: string, harness: string, file: ConfigFileId, id: string, values: Record<string, unknown>): Promise<void>;
19
- export declare function readSnapshot(root: string, harness: string, file: ConfigFileId, id: string): Promise<Record<string, unknown> | null>;
20
- export declare function createProfile(root: string, harness: string, file: ConfigFileId, name: string, values: Record<string, unknown>): Promise<ConfigProfileMeta>;
24
+ export declare function writeSnapshot(root: string, harness: string, file: string, id: string, values: Record<string, unknown>): Promise<void>;
25
+ export declare function readSnapshot(root: string, harness: string, file: string, id: string): Promise<Record<string, unknown> | null>;
26
+ export declare function createProfile(root: string, harness: string, file: string, name: string, values: Record<string, unknown>): Promise<ConfigProfileMeta>;
21
27
  /** 覆盖某份快照的内容并刷新 updatedAt。 */
22
- export declare function saveProfile(root: string, harness: string, file: ConfigFileId, id: string, values: Record<string, unknown>): Promise<void>;
23
- export declare function renameProfile(root: string, harness: string, file: ConfigFileId, id: string, name: string): Promise<void>;
24
- export declare function removeProfile(root: string, harness: string, file: ConfigFileId, id: string): Promise<void>;
25
- export declare function setActive(root: string, harness: string, file: ConfigFileId, id: string | null): Promise<void>;
28
+ export declare function saveProfile(root: string, harness: string, file: string, id: string, values: Record<string, unknown>): Promise<void>;
29
+ export declare function renameProfile(root: string, harness: string, file: string, id: string, name: string): Promise<void>;
30
+ export declare function removeProfile(root: string, harness: string, file: string, id: string): Promise<void>;
31
+ export declare function setActive(root: string, harness: string, file: string, id: string | null): Promise<void>;
26
32
  /**
27
33
  * 无活跃快照档位的自动基线(project/projectLocal 不支持快照、user/global 可能还没建):
28
34
  * 首次查看立基线、写入口同步——没有它这些档位的外部改动永远判不出漂移。
29
35
  */
30
36
  export declare const LASTSEEN_ID = "_lastseen";
31
37
  /** 漂移基线:活跃快照优先,缺省落自动基线。 */
32
- export declare function baselineSnapshot(root: string, harness: string, file: ConfigFileId, state: ConfigProfileState): Promise<Record<string, unknown> | null>;
38
+ export declare function baselineSnapshot(root: string, harness: string, file: string, state: ConfigProfileState): Promise<Record<string, unknown> | null>;
33
39
  /** 写入口同步基线:有活跃快照同步它;`_lastseen` 恒跟着写(删掉活跃快照后基线不复活旧值)。 */
34
- export declare function syncBaseline(root: string, harness: string, file: ConfigFileId, state: ConfigProfileState, values: Record<string, unknown>): Promise<void>;
40
+ export declare function syncBaseline(root: string, harness: string, file: string, state: ConfigProfileState, values: Record<string, unknown>): Promise<void>;
35
41
  /** 写盘前把当前活配置存一份(每档留最新 20 份,超出按时间删旧)。 */
36
- export declare function pushBackup(root: string, harness: string, file: ConfigFileId, values: Record<string, unknown>): Promise<void>;
42
+ export declare function pushBackup(root: string, harness: string, file: string, values: Record<string, unknown>): Promise<void>;
37
43
  /** 备份列表(新 → 旧)。同秒序号(`-2`)比无后缀的更新——按「时刻 + 序号」排,不按裸字典序。 */
38
- export declare function listBackups(root: string, harness: string, file: ConfigFileId): Promise<string[]>;
39
- export declare function readBackup(root: string, harness: string, file: ConfigFileId, id: string): Promise<Record<string, unknown> | null>;
44
+ export declare function listBackups(root: string, harness: string, file: string): Promise<string[]>;
45
+ export declare function readBackup(root: string, harness: string, file: string, id: string): Promise<Record<string, unknown> | null>;