@namzu/sdk 71.0.1 → 72.0.0

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 (268) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +1 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/authorization/readonly-commands.d.ts +9 -1
  6. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  7. package/dist/authorization/readonly-commands.js +70 -4
  8. package/dist/authorization/readonly-commands.js.map +1 -1
  9. package/dist/authorization/shell-paths.d.ts.map +1 -1
  10. package/dist/authorization/shell-paths.js +68 -16
  11. package/dist/authorization/shell-paths.js.map +1 -1
  12. package/dist/compaction/index.d.ts +1 -1
  13. package/dist/compaction/index.d.ts.map +1 -1
  14. package/dist/compaction/index.js +1 -1
  15. package/dist/compaction/index.js.map +1 -1
  16. package/dist/compaction/manual.d.ts +8 -0
  17. package/dist/compaction/manual.d.ts.map +1 -1
  18. package/dist/compaction/manual.js +18 -14
  19. package/dist/compaction/manual.js.map +1 -1
  20. package/dist/compaction/model-summary.d.ts +24 -6
  21. package/dist/compaction/model-summary.d.ts.map +1 -1
  22. package/dist/compaction/model-summary.js +152 -28
  23. package/dist/compaction/model-summary.js.map +1 -1
  24. package/dist/compaction/restore.d.ts +23 -0
  25. package/dist/compaction/restore.d.ts.map +1 -1
  26. package/dist/compaction/restore.js +59 -1
  27. package/dist/compaction/restore.js.map +1 -1
  28. package/dist/compaction/summary.d.ts +37 -2
  29. package/dist/compaction/summary.d.ts.map +1 -1
  30. package/dist/compaction/summary.js +46 -6
  31. package/dist/compaction/summary.js.map +1 -1
  32. package/dist/config/registry.d.ts +2 -0
  33. package/dist/config/registry.d.ts.map +1 -1
  34. package/dist/config/registry.js +76 -5
  35. package/dist/config/registry.js.map +1 -1
  36. package/dist/config/runtime.js +3 -3
  37. package/dist/config/runtime.js.map +1 -1
  38. package/dist/connector/index.d.ts +2 -2
  39. package/dist/connector/index.d.ts.map +1 -1
  40. package/dist/connector/index.js +1 -1
  41. package/dist/connector/index.js.map +1 -1
  42. package/dist/connector/mcp/adapter.d.ts +8 -0
  43. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  44. package/dist/connector/mcp/adapter.js +131 -1
  45. package/dist/connector/mcp/adapter.js.map +1 -1
  46. package/dist/connector/mcp/client.d.ts +26 -6
  47. package/dist/connector/mcp/client.d.ts.map +1 -1
  48. package/dist/connector/mcp/client.js +49 -7
  49. package/dist/connector/mcp/client.js.map +1 -1
  50. package/dist/connector/mcp/index.d.ts +2 -0
  51. package/dist/connector/mcp/index.d.ts.map +1 -1
  52. package/dist/connector/mcp/index.js +1 -0
  53. package/dist/connector/mcp/index.js.map +1 -1
  54. package/dist/connector/mcp/sandbox-stdio.d.ts +67 -0
  55. package/dist/connector/mcp/sandbox-stdio.d.ts.map +1 -0
  56. package/dist/connector/mcp/sandbox-stdio.js +178 -0
  57. package/dist/connector/mcp/sandbox-stdio.js.map +1 -0
  58. package/dist/connector/mcp/stdio-program.d.ts +34 -0
  59. package/dist/connector/mcp/stdio-program.d.ts.map +1 -0
  60. package/dist/connector/mcp/stdio-program.js +47 -0
  61. package/dist/connector/mcp/stdio-program.js.map +1 -0
  62. package/dist/connector/mcp/stdio.d.ts +12 -0
  63. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  64. package/dist/connector/mcp/stdio.js +54 -7
  65. package/dist/connector/mcp/stdio.js.map +1 -1
  66. package/dist/connector/web/guarded-fetch.d.ts +51 -2
  67. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  68. package/dist/connector/web/guarded-fetch.js +140 -19
  69. package/dist/connector/web/guarded-fetch.js.map +1 -1
  70. package/dist/connector/web/index.d.ts +2 -2
  71. package/dist/connector/web/index.d.ts.map +1 -1
  72. package/dist/connector/web/index.js +1 -1
  73. package/dist/connector/web/index.js.map +1 -1
  74. package/dist/constants/mcp/index.d.ts +29 -0
  75. package/dist/constants/mcp/index.d.ts.map +1 -1
  76. package/dist/constants/mcp/index.js +29 -0
  77. package/dist/constants/mcp/index.js.map +1 -1
  78. package/dist/manager/agent/lifecycle.d.ts +18 -1
  79. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  80. package/dist/manager/agent/lifecycle.js +53 -8
  81. package/dist/manager/agent/lifecycle.js.map +1 -1
  82. package/dist/plugin/hook-module/capabilities.d.ts.map +1 -1
  83. package/dist/plugin/hook-module/capabilities.js +24 -13
  84. package/dist/plugin/hook-module/capabilities.js.map +1 -1
  85. package/dist/plugin/hook-module/host.d.ts +31 -0
  86. package/dist/plugin/hook-module/host.d.ts.map +1 -1
  87. package/dist/plugin/hook-module/host.js +56 -13
  88. package/dist/plugin/hook-module/host.js.map +1 -1
  89. package/dist/plugin/hook-module/index.d.ts +3 -2
  90. package/dist/plugin/hook-module/index.d.ts.map +1 -1
  91. package/dist/plugin/hook-module/index.js +2 -1
  92. package/dist/plugin/hook-module/index.js.map +1 -1
  93. package/dist/plugin/index.d.ts +2 -1
  94. package/dist/plugin/index.d.ts.map +1 -1
  95. package/dist/plugin/index.js +1 -0
  96. package/dist/plugin/index.js.map +1 -1
  97. package/dist/plugin/shell-hook-execute.d.ts +55 -0
  98. package/dist/plugin/shell-hook-execute.d.ts.map +1 -0
  99. package/dist/plugin/shell-hook-execute.js +73 -0
  100. package/dist/plugin/shell-hook-execute.js.map +1 -0
  101. package/dist/plugin/shell-hook-restrict.d.ts +31 -0
  102. package/dist/plugin/shell-hook-restrict.d.ts.map +1 -0
  103. package/dist/plugin/shell-hook-restrict.js +69 -0
  104. package/dist/plugin/shell-hook-restrict.js.map +1 -0
  105. package/dist/plugin/shell-hook.d.ts +73 -4
  106. package/dist/plugin/shell-hook.d.ts.map +1 -1
  107. package/dist/plugin/shell-hook.js +118 -17
  108. package/dist/plugin/shell-hook.js.map +1 -1
  109. package/dist/public-runtime.d.ts +9 -7
  110. package/dist/public-runtime.d.ts.map +1 -1
  111. package/dist/public-runtime.js +6 -5
  112. package/dist/public-runtime.js.map +1 -1
  113. package/dist/public-types.d.ts +4 -2
  114. package/dist/public-types.d.ts.map +1 -1
  115. package/dist/runtime/jobs/websocket-source.d.ts +2 -22
  116. package/dist/runtime/jobs/websocket-source.d.ts.map +1 -1
  117. package/dist/runtime/jobs/websocket-source.js +2 -33
  118. package/dist/runtime/jobs/websocket-source.js.map +1 -1
  119. package/dist/runtime/query/compact-session.d.ts.map +1 -1
  120. package/dist/runtime/query/compact-session.js +5 -0
  121. package/dist/runtime/query/compact-session.js.map +1 -1
  122. package/dist/runtime/query/events.d.ts +7 -0
  123. package/dist/runtime/query/events.d.ts.map +1 -1
  124. package/dist/runtime/query/events.js +29 -11
  125. package/dist/runtime/query/events.js.map +1 -1
  126. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  127. package/dist/runtime/query/executor/tool-call-admission.js +51 -10
  128. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  129. package/dist/runtime/query/index.d.ts +6 -0
  130. package/dist/runtime/query/index.d.ts.map +1 -1
  131. package/dist/runtime/query/index.js +3 -0
  132. package/dist/runtime/query/index.js.map +1 -1
  133. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  134. package/dist/runtime/query/iteration/phases/compaction.js +21 -3
  135. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  136. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  137. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  138. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  139. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  140. package/dist/runtime/query/path-escalation.js +90 -17
  141. package/dist/runtime/query/path-escalation.js.map +1 -1
  142. package/dist/runtime/query/steering.d.ts +15 -0
  143. package/dist/runtime/query/steering.d.ts.map +1 -1
  144. package/dist/runtime/query/steering.js +27 -3
  145. package/dist/runtime/query/steering.js.map +1 -1
  146. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  147. package/dist/scheduler/completion-inbox.js +15 -0
  148. package/dist/scheduler/completion-inbox.js.map +1 -1
  149. package/dist/session/workspace/driver.d.ts +12 -0
  150. package/dist/session/workspace/driver.d.ts.map +1 -1
  151. package/dist/session/workspace/git-worktree.d.ts +16 -0
  152. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  153. package/dist/session/workspace/git-worktree.js +35 -0
  154. package/dist/session/workspace/git-worktree.js.map +1 -1
  155. package/dist/session/workspace/holds.d.ts +78 -0
  156. package/dist/session/workspace/holds.d.ts.map +1 -0
  157. package/dist/session/workspace/holds.js +150 -0
  158. package/dist/session/workspace/holds.js.map +1 -0
  159. package/dist/session/workspace/index.d.ts +3 -1
  160. package/dist/session/workspace/index.d.ts.map +1 -1
  161. package/dist/session/workspace/index.js +2 -1
  162. package/dist/session/workspace/index.js.map +1 -1
  163. package/dist/store/config/index.d.ts +3 -0
  164. package/dist/store/config/index.d.ts.map +1 -1
  165. package/dist/store/config/index.js +3 -0
  166. package/dist/store/config/index.js.map +1 -1
  167. package/dist/store/session-index/index.d.ts +13 -0
  168. package/dist/store/session-index/index.d.ts.map +1 -1
  169. package/dist/store/session-index/index.js +1 -0
  170. package/dist/store/session-index/index.js.map +1 -1
  171. package/dist/store/session-index/rebuild.d.ts +12 -0
  172. package/dist/store/session-index/rebuild.d.ts.map +1 -1
  173. package/dist/store/session-index/rebuild.js +20 -4
  174. package/dist/store/session-index/rebuild.js.map +1 -1
  175. package/dist/store/session-index/sqlite.d.ts +20 -0
  176. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  177. package/dist/store/session-index/sqlite.js +50 -12
  178. package/dist/store/session-index/sqlite.js.map +1 -1
  179. package/dist/tools/admit-facts.d.ts.map +1 -1
  180. package/dist/tools/admit-facts.js +59 -0
  181. package/dist/tools/admit-facts.js.map +1 -1
  182. package/dist/tools/builtins/grep.d.ts.map +1 -1
  183. package/dist/tools/builtins/grep.js +57 -0
  184. package/dist/tools/builtins/grep.js.map +1 -1
  185. package/dist/tools/builtins/lsp.d.ts.map +1 -1
  186. package/dist/tools/builtins/lsp.js +41 -4
  187. package/dist/tools/builtins/lsp.js.map +1 -1
  188. package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
  189. package/dist/tools/coordinator/ask-user-question.js +67 -3
  190. package/dist/tools/coordinator/ask-user-question.js.map +1 -1
  191. package/dist/turn/memory-promoter.d.ts.map +1 -1
  192. package/dist/turn/memory-promoter.js +20 -4
  193. package/dist/turn/memory-promoter.js.map +1 -1
  194. package/dist/types/agent/base.d.ts +6 -0
  195. package/dist/types/agent/base.d.ts.map +1 -1
  196. package/dist/types/agent/task.d.ts +5 -0
  197. package/dist/types/agent/task.d.ts.map +1 -1
  198. package/dist/types/agent/task.js.map +1 -1
  199. package/dist/types/code-navigation/index.d.ts +34 -4
  200. package/dist/types/code-navigation/index.d.ts.map +1 -1
  201. package/dist/types/hitl/index.d.ts +8 -0
  202. package/dist/types/hitl/index.d.ts.map +1 -1
  203. package/dist/types/hitl/index.js.map +1 -1
  204. package/dist/types/message/index.d.ts +7 -0
  205. package/dist/types/message/index.d.ts.map +1 -1
  206. package/dist/types/message/index.js.map +1 -1
  207. package/dist/types/tool/presentation.d.ts +21 -0
  208. package/dist/types/tool/presentation.d.ts.map +1 -1
  209. package/package.json +6 -6
  210. package/src/agents/QueryAgent.ts +1 -0
  211. package/src/authorization/readonly-commands.ts +72 -4
  212. package/src/authorization/shell-paths.ts +75 -18
  213. package/src/compaction/index.ts +1 -0
  214. package/src/compaction/manual.ts +48 -12
  215. package/src/compaction/model-summary.ts +163 -28
  216. package/src/compaction/restore.ts +74 -1
  217. package/src/compaction/summary.ts +69 -3
  218. package/src/config/registry.ts +87 -5
  219. package/src/config/runtime.ts +3 -3
  220. package/src/connector/index.ts +3 -0
  221. package/src/connector/mcp/adapter.ts +137 -1
  222. package/src/connector/mcp/client.ts +49 -7
  223. package/src/connector/mcp/index.ts +5 -0
  224. package/src/connector/mcp/sandbox-stdio.ts +214 -0
  225. package/src/connector/mcp/stdio-program.ts +68 -0
  226. package/src/connector/mcp/stdio.ts +61 -7
  227. package/src/connector/web/guarded-fetch.ts +197 -30
  228. package/src/connector/web/index.ts +4 -1
  229. package/src/constants/mcp/index.ts +31 -0
  230. package/src/manager/agent/lifecycle.ts +58 -13
  231. package/src/plugin/hook-module/capabilities.ts +36 -14
  232. package/src/plugin/hook-module/host.ts +86 -13
  233. package/src/plugin/hook-module/index.ts +3 -0
  234. package/src/plugin/index.ts +4 -0
  235. package/src/plugin/shell-hook-execute.ts +126 -0
  236. package/src/plugin/shell-hook-restrict.ts +66 -0
  237. package/src/plugin/shell-hook.ts +209 -16
  238. package/src/public-runtime.ts +19 -0
  239. package/src/public-types.ts +20 -0
  240. package/src/runtime/jobs/websocket-source.ts +2 -46
  241. package/src/runtime/query/compact-session.ts +5 -0
  242. package/src/runtime/query/events.ts +29 -11
  243. package/src/runtime/query/executor/tool-call-admission.ts +62 -17
  244. package/src/runtime/query/index.ts +10 -0
  245. package/src/runtime/query/iteration/phases/compaction.ts +26 -2
  246. package/src/runtime/query/iteration/phases/context.ts +6 -0
  247. package/src/runtime/query/path-escalation.ts +102 -16
  248. package/src/runtime/query/steering.ts +38 -3
  249. package/src/scheduler/completion-inbox.ts +14 -0
  250. package/src/session/workspace/driver.ts +12 -0
  251. package/src/session/workspace/git-worktree.ts +49 -0
  252. package/src/session/workspace/holds.ts +201 -0
  253. package/src/session/workspace/index.ts +13 -1
  254. package/src/store/config/index.ts +6 -0
  255. package/src/store/session-index/index.ts +14 -0
  256. package/src/store/session-index/rebuild.ts +22 -4
  257. package/src/store/session-index/sqlite.ts +63 -14
  258. package/src/tools/admit-facts.ts +64 -0
  259. package/src/tools/builtins/grep.ts +52 -0
  260. package/src/tools/builtins/lsp.ts +47 -4
  261. package/src/tools/coordinator/ask-user-question.ts +88 -4
  262. package/src/turn/memory-promoter.ts +24 -3
  263. package/src/types/agent/base.ts +7 -0
  264. package/src/types/agent/task.ts +5 -0
  265. package/src/types/code-navigation/index.ts +48 -4
  266. package/src/types/hitl/index.ts +8 -0
  267. package/src/types/message/index.ts +7 -0
  268. package/src/types/tool/presentation.ts +22 -0
@@ -157,7 +157,9 @@ import {
157
157
  shellPathOutsideEnv,
158
158
  substituteMovedFolders,
159
159
  } from './shell-hook-env.js'
160
+ import { type ShellHookExecutor, runThroughExecutor } from './shell-hook-execute.js'
160
161
  import { postHookJson } from './shell-hook-http.js'
162
+ import { restrictHookVerdict } from './shell-hook-restrict.js'
161
163
  import { type ShellHookToolNames, shellHookToolName } from './shell-hook-tool-names.js'
162
164
  import { worktreeHookVerdict } from './worktree-hook-answer.js'
163
165
 
@@ -351,8 +353,22 @@ export interface PromptHookEntry extends ShellHookEntryBase {
351
353
  readonly prompt: string
352
354
  }
353
355
 
356
+ /** One call to a tool on a connected tool server, at one event. */
357
+ export interface McpToolHookEntry extends ShellHookEntryBase {
358
+ readonly type: 'mcp_tool'
359
+ /** The server to call, by its name in the tool-server config. */
360
+ readonly server: string
361
+ /** The tool to call, by the name the server itself reports (no `mcp__` prefix). */
362
+ readonly tool: string
363
+ /**
364
+ * The arguments the tool is called with, as one JSON object. Absent, the
365
+ * tool is called with none.
366
+ */
367
+ readonly arguments?: Readonly<Record<string, unknown>>
368
+ }
369
+
354
370
  /** Any hook entry a config may carry. */
355
- export type ShellHookHandler = ShellHookEntry | HttpHookEntry | PromptHookEntry
371
+ export type ShellHookHandler = ShellHookEntry | HttpHookEntry | PromptHookEntry | McpToolHookEntry
356
372
 
357
373
  /** Event → entries, the shape a host's config file carries. */
358
374
  export type ShellHooksConfig = {
@@ -990,11 +1006,18 @@ function isExecutableFile(path: string): boolean {
990
1006
  }
991
1007
  }
992
1008
 
993
- /** Run one hook command to completion, bounded by its deadline and capture. */
1009
+ /**
1010
+ * Run one hook command to completion, bounded by its deadline and capture.
1011
+ *
1012
+ * With `execute` the command goes to that executor and nothing is started in
1013
+ * this process: no fallback exists, and the host's own environment is not
1014
+ * handed over (the command gets the hook's variables and `extraEnv` only).
1015
+ */
994
1016
  export function runShellHook(
995
1017
  entry: ShellHookEntry,
996
1018
  input: ShellHookInput,
997
1019
  signal?: AbortSignal,
1020
+ execute?: ShellHookExecutor,
998
1021
  ): Promise<ShellHookOutcome> {
999
1022
  const timeoutMs = Math.min(
1000
1023
  MAX_SHELL_HOOK_TIMEOUT_MS,
@@ -1009,7 +1032,7 @@ export function runShellHook(
1009
1032
  NAMZU_TURN_ID: _inheritedTurnId,
1010
1033
  NAMZU_ENV_FILE: _inheritedEnvFile,
1011
1034
  ...inherited
1012
- } = process.env
1035
+ } = execute !== undefined ? ({} as NodeJS.ProcessEnv) : process.env
1013
1036
  const projectDir = input.projectDir ?? input.cwd
1014
1037
  const kernel = {
1015
1038
  NAMZU_HOOK_EVENT: input.event,
@@ -1060,6 +1083,27 @@ export function runShellHook(
1060
1083
  args: entry.args.map((arg) => substituteMovedFolders(arg, env)),
1061
1084
  }
1062
1085
  const unsetVariables = unset.length > 0 ? { unsetVariables: unset } : {}
1086
+ if (execute !== undefined) {
1087
+ // Nothing below this block runs: no host folder is made, no host process is started.
1088
+ const sent: Record<string, string> = {}
1089
+ for (const [name, value] of Object.entries(withSessionChildMarker(withSafeGitConfig(env)))) {
1090
+ if (typeof value === 'string') sent[name] = value
1091
+ }
1092
+ return runThroughExecutor(
1093
+ execute,
1094
+ {
1095
+ command: placed.command,
1096
+ ...(placed.args !== undefined ? { args: placed.args } : {}),
1097
+ stdin: payload,
1098
+ env: sent,
1099
+ cwd: input.cwd,
1100
+ timeoutMs,
1101
+ },
1102
+ MAX_CAPTURE_BYTES,
1103
+ signal,
1104
+ unsetVariables,
1105
+ )
1106
+ }
1063
1107
  if (pluginFolders !== undefined) {
1064
1108
  try {
1065
1109
  // Created when first needed; never inside the plugin's own folder.
@@ -2027,10 +2071,11 @@ export function shellHookVerdict(
2027
2071
  }
2028
2072
  }
2029
2073
 
2030
- /** A short name for a hook in logs: its command, its url, or the start of its prompt. */
2074
+ /** A short name for a hook in logs: its command, its url, the tool it calls, or the start of its prompt. */
2031
2075
  export function describeShellHook(entry: ShellHookHandler): string {
2032
2076
  if (entry.type === 'http') return entry.url
2033
2077
  if (entry.type === 'prompt') return `prompt: ${entry.prompt.slice(0, 80)}`
2078
+ if (entry.type === 'mcp_tool') return `mcp: ${entry.server}/${entry.tool}`
2034
2079
  return entry.command
2035
2080
  }
2036
2081
 
@@ -2052,9 +2097,40 @@ export type ShellHookJudge = (request: {
2052
2097
  readonly signal: AbortSignal
2053
2098
  }) => Promise<string | undefined>
2054
2099
 
2100
+ /**
2101
+ * What one `mcp_tool` call came back with. `ok` false is a call the server
2102
+ * refused or that failed; `output` is the text of a successful one, read
2103
+ * exactly as a command hook's stdout is (its JSON answer included).
2104
+ */
2105
+ export interface ShellHookMcpToolAnswer {
2106
+ readonly ok: boolean
2107
+ readonly output: string
2108
+ readonly error?: string
2109
+ }
2110
+
2111
+ /**
2112
+ * Calls one tool on one connected tool server and returns its answer, or
2113
+ * `undefined` when no connected server has that tool. The host supplies it:
2114
+ * the kernel does not own the servers a session is connected to. It should
2115
+ * honour `signal`.
2116
+ */
2117
+ export type ShellHookMcpToolCaller = (request: {
2118
+ readonly server: string
2119
+ readonly tool: string
2120
+ readonly arguments: Readonly<Record<string, unknown>>
2121
+ readonly sessionId: string
2122
+ readonly turnId?: string
2123
+ readonly signal: AbortSignal
2124
+ }) => Promise<ShellHookMcpToolAnswer | undefined>
2125
+
2055
2126
  export interface ShellHookOptions {
2056
2127
  /** Answers `prompt` hooks. Without it a `prompt` hook is logged and lets the action go ahead. */
2057
2128
  readonly judge?: ShellHookJudge
2129
+ /**
2130
+ * Calls the tool an `mcp_tool` hook names. Without it such a hook is
2131
+ * reported as a failure, which `onFailure: block` counts as a refusal.
2132
+ */
2133
+ readonly mcpToolCall?: ShellHookMcpToolCaller
2058
2134
  /** Where the command runs and what `cwd` says on stdin. */
2059
2135
  readonly cwd: string
2060
2136
  readonly log?: Logger
@@ -2113,6 +2189,26 @@ export interface ShellHookOptions {
2113
2189
  * Without it no hook gets the variable and nothing is carried.
2114
2190
  */
2115
2191
  readonly hookEnv?: SessionHookEnv
2192
+ /**
2193
+ * Runs every command hook of this adapter somewhere other than this process
2194
+ * (a sandbox the host keeps its tools in). With it set, no hook command is
2195
+ * ever started as a child of the host, whatever the event: a request the
2196
+ * executor cannot serve fails the hook, it does not run on the host. The
2197
+ * command gets the hook's own variables and `extraEnv`, not the host's
2198
+ * environment, and the plugin's data folder is not made here. A hook that
2199
+ * writes variables for later commands (`NAMZU_ENV_FILE`) is not given the
2200
+ * file, which is a host path. `http`, `prompt` and `mcp_tool` hooks start no
2201
+ * process and are not routed through it.
2202
+ */
2203
+ readonly execute?: ShellHookExecutor
2204
+ /**
2205
+ * Accept only the answers that narrow: `deny`, `block`, `skip`, errors,
2206
+ * `additionalContext`, notices and `halt`. An `allow`, `permissionDecision:
2207
+ * allow`, `updatedInput`, `retry` and the other answers that widen what the
2208
+ * session may do are dropped, whichever hook gave them. Absent, every answer
2209
+ * is read as before.
2210
+ */
2211
+ readonly restrictVerdicts?: boolean
2116
2212
  /**
2117
2213
  * Called when a hook of this adapter ran out its deadline and was ended.
2118
2214
  * `hook` is the command, URL or prompt text the entry names.
@@ -2220,11 +2316,79 @@ function readJudgement(reply: string): { ok: boolean; reason: string } | undefin
2220
2316
  }
2221
2317
  }
2222
2318
 
2319
+ /**
2320
+ * An `mcp_tool` hook: the host calls the named tool on the named server, and
2321
+ * its answer is read exactly as a command hook's stdout is. A call that
2322
+ * cannot be made — no caller, no such server or tool, a refused or failed
2323
+ * call, the deadline — is the hook's own failure, which `onFailure: block`
2324
+ * counts as a refusal.
2325
+ */
2326
+ async function runMcpToolHook(
2327
+ entry: McpToolHookEntry,
2328
+ input: ShellHookInput,
2329
+ call: ShellHookMcpToolCaller | undefined,
2330
+ signal: AbortSignal | undefined,
2331
+ log: Logger,
2332
+ ): Promise<ShellHookOutcome> {
2333
+ const where = describeShellHook(entry)
2334
+ if (call === undefined) {
2335
+ return {
2336
+ exitCode: null,
2337
+ timedOut: false,
2338
+ stdout: '',
2339
+ stderr: '',
2340
+ spawnError: `no connected tool server is reachable, so ${where} was not called`,
2341
+ }
2342
+ }
2343
+ const deadline = AbortSignal.timeout(hookTimeout(entry))
2344
+ const combined = signal ? AbortSignal.any([signal, deadline]) : deadline
2345
+ let answer: ShellHookMcpToolAnswer | undefined
2346
+ try {
2347
+ answer = await call({
2348
+ server: entry.server,
2349
+ tool: entry.tool,
2350
+ arguments: entry.arguments ?? {},
2351
+ sessionId: input.sessionId,
2352
+ ...(input.turnId !== undefined ? { turnId: input.turnId } : {}),
2353
+ signal: combined,
2354
+ })
2355
+ } catch (error) {
2356
+ log.warn('mcp tool hook failed', {
2357
+ 'namzu.hook.event': input.event,
2358
+ 'namzu.hook.command': where,
2359
+ 'namzu.hook.error': error instanceof Error ? error.message : String(error),
2360
+ })
2361
+ return {
2362
+ exitCode: 1,
2363
+ timedOut: deadline.aborted,
2364
+ stdout: '',
2365
+ stderr: error instanceof Error ? error.message : String(error),
2366
+ }
2367
+ }
2368
+ if (answer === undefined) {
2369
+ return {
2370
+ exitCode: 1,
2371
+ timedOut: deadline.aborted,
2372
+ stdout: '',
2373
+ stderr: `no connected server named ${entry.server} offers a tool named ${entry.tool}`,
2374
+ }
2375
+ }
2376
+ if (!answer.ok) {
2377
+ return {
2378
+ exitCode: 1,
2379
+ timedOut: deadline.aborted,
2380
+ stdout: '',
2381
+ stderr: answer.error ?? 'the tool call failed',
2382
+ }
2383
+ }
2384
+ return { exitCode: 0, timedOut: false, stdout: answer.output, stderr: '' }
2385
+ }
2386
+
2223
2387
  /**
2224
2388
  * One run of a `worktree_create` or `worktree_remove` hook, to its answer. It
2225
2389
  * is always awaited (an `async` flag cannot make a hook that does the work run
2226
- * out of sight), and a `prompt` hook cannot do it at all, which is said as a
2227
- * failure rather than skipped.
2390
+ * out of sight), and a `prompt` or `mcp_tool` hook cannot do it at all, which
2391
+ * is said as a failure rather than skipped.
2228
2392
  */
2229
2393
  async function runWorktreeHook(
2230
2394
  event: 'worktree_create' | 'worktree_remove',
@@ -2232,12 +2396,13 @@ async function runWorktreeHook(
2232
2396
  input: ShellHookInput,
2233
2397
  signal: AbortSignal | undefined,
2234
2398
  reportTimeout: (timedOut: boolean) => void,
2399
+ execute: ShellHookExecutor | undefined,
2235
2400
  ): Promise<PluginHookResult> {
2236
2401
  const label = describeShellHook(entry)
2237
- if (entry.type === 'prompt') {
2402
+ if (entry.type === 'prompt' || entry.type === 'mcp_tool') {
2238
2403
  return {
2239
2404
  action: 'error',
2240
- message: `The ${event} hook \`${label}\` is a prompt, and a prompt cannot make or remove a worktree. Use a command or an http hook.`,
2405
+ message: `The ${event} hook \`${label}\` is a ${entry.type} hook, and it cannot make or remove a worktree. Use a command or an http hook.`,
2241
2406
  }
2242
2407
  }
2243
2408
  if (entry.type === 'http') {
@@ -2259,7 +2424,7 @@ async function runWorktreeHook(
2259
2424
  ...(response.error !== undefined ? { spawnError: response.error } : {}),
2260
2425
  })
2261
2426
  }
2262
- const outcome = await runShellHook(entry, input, signal)
2427
+ const outcome = await runShellHook(entry, input, signal, execute)
2263
2428
  reportTimeout(outcome.timedOut)
2264
2429
  return worktreeHookVerdict(event, label, outcome)
2265
2430
  }
@@ -2369,7 +2534,7 @@ export function createShellHook(
2369
2534
  let spent = false
2370
2535
  // The shell verdict branches on `event`, but TypeScript cannot retain that
2371
2536
  // correlation across the async handler closure and the union of events.
2372
- return {
2537
+ const definition = {
2373
2538
  event,
2374
2539
  ...(entry.statusMessage !== undefined ? { statusMessage: entry.statusMessage } : {}),
2375
2540
  // A file named by the matcher is watched for as long as the hook is attached.
@@ -2456,8 +2621,9 @@ export function createShellHook(
2456
2621
  ? event
2457
2622
  : undefined
2458
2623
  const runsACommand = entry.type === undefined || entry.type === 'command'
2624
+ // The variables file is a host path; a command run elsewhere is not given it.
2459
2625
  const envFile =
2460
- envEvent !== undefined && runsACommand
2626
+ envEvent !== undefined && runsACommand && options.execute === undefined
2461
2627
  ? options.hookEnv?.fileFor(envEvent, envSlot)
2462
2628
  : undefined
2463
2629
  const hookInput = shellHookInputFor(event, context, options, {
@@ -2469,7 +2635,14 @@ export function createShellHook(
2469
2635
  ...(context.toolInput !== undefined ? { toolInput: context.toolInput } : {}),
2470
2636
  }
2471
2637
  if (event === 'worktree_create' || event === 'worktree_remove') {
2472
- return runWorktreeHook(event, entry, hookInput, context.signal, reportTimeout)
2638
+ return runWorktreeHook(
2639
+ event,
2640
+ entry,
2641
+ hookInput,
2642
+ context.signal,
2643
+ reportTimeout,
2644
+ options.execute,
2645
+ )
2473
2646
  }
2474
2647
  if (entry.type === 'http') {
2475
2648
  const response = await postHookJson({
@@ -2499,12 +2672,24 @@ export function createShellHook(
2499
2672
  if (entry.type === 'prompt') {
2500
2673
  return judgePromptHook(event, entry, hookInput, options.judge, context.signal, log)
2501
2674
  }
2675
+ if (entry.type === 'mcp_tool') {
2676
+ const outcome = await runMcpToolHook(
2677
+ entry,
2678
+ hookInput,
2679
+ options.mcpToolCall,
2680
+ context.signal,
2681
+ log,
2682
+ )
2683
+ reportTimeout(outcome.timedOut)
2684
+ return shellHookVerdict(event, entry, outcome, log, verdictCall)
2685
+ }
2502
2686
  if (entry.async === true) {
2503
2687
  // Started and left running: it decides nothing, so nothing waits
2504
2688
  // for it and its own failure is only written down.
2505
- void runShellHook(entry, hookInput)
2689
+ void runShellHook(entry, hookInput, undefined, options.execute)
2506
2690
  .then((outcome) => {
2507
- if (envEvent !== undefined) options.hookEnv?.absorb(envEvent, envSlot)
2691
+ if (envEvent !== undefined && options.execute === undefined)
2692
+ options.hookEnv?.absorb(envEvent, envSlot)
2508
2693
  const verdict = shellHookVerdict(event, entry, outcome, log, verdictCall)
2509
2694
  if (verdict.action !== 'continue') {
2510
2695
  log.warn('an async hook answered, and its answer is not applied', {
@@ -2517,14 +2702,22 @@ export function createShellHook(
2517
2702
  .catch(() => undefined)
2518
2703
  return { action: 'continue' }
2519
2704
  }
2520
- const outcome = await runShellHook(entry, hookInput, context.signal)
2705
+ const outcome = await runShellHook(entry, hookInput, context.signal, options.execute)
2521
2706
  // What the hook appended counts even when it was ended or failed after
2522
2707
  // writing it: the lines are data it already gave.
2523
- if (envEvent !== undefined) options.hookEnv?.absorb(envEvent, envSlot)
2708
+ if (envEvent !== undefined && options.execute === undefined)
2709
+ options.hookEnv?.absorb(envEvent, envSlot)
2524
2710
  reportTimeout(outcome.timedOut)
2525
2711
  return shellHookVerdict(event, entry, outcome, log, verdictCall)
2526
2712
  },
2527
2713
  } as PluginHookDefinition
2714
+ if (options.restrictVerdicts !== true) return definition
2715
+ const where = { event, command: describeShellHook(entry) }
2716
+ return {
2717
+ ...definition,
2718
+ handler: async (context: PluginHookContext) =>
2719
+ restrictHookVerdict(await definition.handler(context as never), log, where),
2720
+ } as PluginHookDefinition
2528
2721
  }
2529
2722
 
2530
2723
  /**
@@ -96,6 +96,7 @@ export type {
96
96
 
97
97
  export type {
98
98
  CodeNavigationProvider,
99
+ CodeNavigationRequestOptions,
99
100
  CodeNavigationResult,
100
101
  HoverResult,
101
102
  SourceLocation,
@@ -343,6 +344,7 @@ export {
343
344
  withFileLock,
344
345
  withFileLockSync,
345
346
  } from './utils/file-lock.js'
347
+ export { temporaryPathFor } from './utils/atomic-write.js'
346
348
  export {
347
349
  STATE_BACKUPS_DIR,
348
350
  STATE_BACKUP_KEEP,
@@ -874,6 +876,11 @@ export {
874
876
  scanHookModule,
875
877
  startHookModule,
876
878
  summarizeHookModule,
879
+ HOOK_WORKER_SOURCE,
880
+ HOST_REACHING_CAPABILITIES,
881
+ createCapabilityBridge,
882
+ workerTransport,
883
+ restrictHookVerdict,
877
884
  } from './plugin/index.js'
878
885
  export type {
879
886
  CommonLayoutOptions,
@@ -1141,6 +1148,7 @@ export {
1141
1148
  // The only transport in the tree that can RUN an `MCPServer`. It reached
1142
1149
  // `connector/mcp/index.ts` and stopped there, so the server was public
1143
1150
  // with no public way to serve it.
1151
+ SandboxStdioTransport,
1144
1152
  ServerStdioTransport,
1145
1153
  StdioTransport,
1146
1154
  StreamableHttpTransport,
@@ -1166,6 +1174,8 @@ export type {
1166
1174
  McpSkillsClient,
1167
1175
  McpSkillsRefresh,
1168
1176
  McpSkillsRefreshStatus,
1177
+ SandboxStdioReplyVerdict,
1178
+ SandboxStdioTransportOptions,
1169
1179
  McpEnvelope,
1170
1180
  McpEnvelopeInput,
1171
1181
  McpEraProbe,
@@ -1398,6 +1408,10 @@ export type { VaultInstrumentationOptions } from './vault/instrumentation.js'
1398
1408
 
1399
1409
  export {
1400
1410
  GitWorktreeDriver,
1411
+ DiskWorkspaceHoldStore,
1412
+ WorkspaceInUseError,
1413
+ defaultWorkspaceHoldsDir,
1414
+ defaultWorktreesDir,
1401
1415
  HookedWorkspaceDriver,
1402
1416
  WorktreeHookError,
1403
1417
  worktreeHookHost,
@@ -1575,6 +1589,7 @@ export {
1575
1589
  COMPACTION_HEADER,
1576
1590
  COMPACTION_RECOVERY_NOTE,
1577
1591
  COMPACTION_RESUME_NOTE,
1592
+ COMPACTION_RESUME_NOTE_MAY_ASK,
1578
1593
  isCompactionMessage,
1579
1594
  } from './compaction/summary.js'
1580
1595
  export {
@@ -1891,10 +1906,14 @@ export {
1891
1906
  export {
1892
1907
  GuardedFetchProvider,
1893
1908
  WebFetchRefusedError,
1909
+ checkedAddresses,
1894
1910
  isPrivateAddress,
1911
+ pinnedFetch,
1912
+ pinnedLookup,
1895
1913
  privateAddressProblem,
1896
1914
  proxyConfigured,
1897
1915
  } from './connector/web/index.js'
1916
+ export type { AddressCheckOptions, PinnedRequest } from './connector/web/index.js'
1898
1917
 
1899
1918
  // Where an attachment's bytes live when the message does not carry them.
1900
1919
  // Inline base64 lands in the transcript, in every checkpoint, and on the
@@ -243,11 +243,14 @@ export type {
243
243
  } from './agents/file-definitions.js'
244
244
  export type {
245
245
  HttpHookEntry,
246
+ McpToolHookEntry,
246
247
  PromptHookEntry,
247
248
  ShellHookEntry,
248
249
  ShellHookEvent,
249
250
  ShellHookHandler,
250
251
  ShellHookJudge,
252
+ ShellHookMcpToolAnswer,
253
+ ShellHookMcpToolCaller,
251
254
  ShellHookOnFailure,
252
255
  ShellHookCall,
253
256
  ShellHookInput,
@@ -257,6 +260,19 @@ export type {
257
260
  ShellHooksConfig,
258
261
  } from './plugin/shell-hook.js'
259
262
  export type { ShellHookToolNames } from './plugin/shell-hook-tool-names.js'
263
+ export type {
264
+ ShellHookExecRequest,
265
+ ShellHookExecResult,
266
+ ShellHookExecutor,
267
+ } from './plugin/shell-hook-execute.js'
268
+ export type {
269
+ CapabilityBridge,
270
+ CapabilityBridgeOptions,
271
+ HookModuleCapability,
272
+ HookModuleClock,
273
+ HookModuleTransport,
274
+ HookModuleTransportFactory,
275
+ } from './plugin/hook-module/index.js'
260
276
  export type { HookEnvEvent, SessionHookEnvOptions } from './plugin/session-hook-env.js'
261
277
  export type {
262
278
  FileChange,
@@ -284,6 +300,10 @@ export type {
284
300
  export type {
285
301
  RegisterSharedSessionPlanInput,
286
302
  SharedSessionWorkspaceConfig,
303
+ DiskWorkspaceHoldStoreOptions,
304
+ WorkspaceHold,
305
+ WorkspaceHoldRequest,
306
+ WorkspaceHoldStore,
287
307
  } from './session/workspace/index.js'
288
308
 
289
309
  export type {
@@ -4,7 +4,7 @@ import { isIP } from 'node:net'
4
4
 
5
5
  import type { WebSocket as WebSocketClient } from 'ws'
6
6
 
7
- import { isPrivateAddress } from '../../connector/web/guarded-fetch.js'
7
+ import { isPrivateAddress, pinnedLookup } from '../../connector/web/guarded-fetch.js'
8
8
  import { isolationOf } from '../../sandbox/isolation.js'
9
9
  import type { Sandbox } from '../../types/sandbox/index.js'
10
10
  import type { MonitorWebSocketTarget } from '../../types/tool/index.js'
@@ -170,51 +170,7 @@ export async function vetWebSocketTarget(
170
170
  return addresses.map((address) => ({ address, family: isIP(address) === 6 ? 6 : 4 }))
171
171
  }
172
172
 
173
- /**
174
- * A `lookup` for the socket that answers with the addresses that were checked
175
- * and nothing else.
176
- *
177
- * This is what closes the gap `web_fetch` documents: there the address is
178
- * checked, then the platform `fetch` resolves the name AGAIN, so a name that
179
- * answers publicly the first time and privately the second (DNS rebinding)
180
- * gets through. Here the connection never asks DNS: it is handed the checked
181
- * addresses, so there is no second answer to differ. The URL still names the
182
- * host, so TLS keeps its SNI and its certificate check on the hostname and not
183
- * on an address.
184
- */
185
- export function pinnedLookup(
186
- addresses: readonly { readonly address: string; readonly family: 4 | 6 }[],
187
- ) {
188
- return (
189
- _hostname: string,
190
- options: { all?: boolean; family?: number | string } | undefined,
191
- callback: (
192
- error: NodeJS.ErrnoException | null,
193
- address: string | { address: string; family: number }[],
194
- family?: number,
195
- ) => void,
196
- ): void => {
197
- // A caller that wants one family gets that family's addresses; asking for
198
- // one we hold none of is an error rather than a fall back to DNS.
199
- const wanted = options?.family === 4 || options?.family === 6 ? options.family : undefined
200
- const usable = wanted === undefined ? addresses : addresses.filter((a) => a.family === wanted)
201
- const first = usable[0]
202
- if (first === undefined) {
203
- const error: NodeJS.ErrnoException = new Error('no vetted address of that family')
204
- error.code = 'ENOTFOUND'
205
- callback(error, '', 0)
206
- return
207
- }
208
- if (options?.all === true) {
209
- callback(
210
- null,
211
- usable.map((a) => ({ address: a.address, family: a.family })),
212
- )
213
- return
214
- }
215
- callback(null, first.address, first.family)
216
- }
217
- }
173
+ export { pinnedLookup }
218
174
 
219
175
  /** `api.example.com` is that host; `.example.com` is the domain and its subdomains. */
220
176
  export function hostMatchesPolicy(hostname: string, allowedHosts: readonly string[]): boolean {
@@ -6,6 +6,7 @@ import {
6
6
  compactRegion,
7
7
  } from '../../compaction/manual.js'
8
8
  import { readFoldedHistory } from '../../manager/session/turn-recorder.js'
9
+ import { DiskSessionLog } from '../../store/session-log/index.js'
9
10
  import { NamzuError } from '../../types/errors/index.js'
10
11
  import type { MessageId, SessionId } from '../../types/ids/index.js'
11
12
  import type { Message } from '../../types/message/index.js'
@@ -55,6 +56,8 @@ export async function compactSession(
55
56
  const ids = new Map<Message, MessageId>()
56
57
  for (const entry of history) if (entry.messageId) ids.set(entry.message, entry.messageId)
57
58
  const result = await compactNow({
59
+ // The session's own file, so the summary says where exact text is stored.
60
+ ...(log instanceof DiskSessionLog ? { sessionFile: log.file } : {}),
58
61
  ...input,
59
62
  messages: history.map((entry) => entry.message),
60
63
  ...(hooks ? { hooks: { ...hooks, sessionId, trigger } } : {}),
@@ -141,6 +144,8 @@ export async function compactSessionRange(
141
144
  const ids = new Map<Message, MessageId>()
142
145
  for (const entry of history) if (entry.messageId) ids.set(entry.message, entry.messageId)
143
146
  const result = await compactRegion({
147
+ // The session's own file, so the summary says where exact text is stored.
148
+ ...(log instanceof DiskSessionLog ? { sessionFile: log.file } : {}),
144
149
  ...input,
145
150
  messages: history.map((entry) => entry.message),
146
151
  start,
@@ -13,6 +13,7 @@ import { type SessionEvent, isEphemeralEvent } from '../../types/session/events.
13
13
  import type { SessionRecord } from '../../types/session/records.js'
14
14
  import type { TaskEvent, TaskStore } from '../../types/task/index.js'
15
15
  import { awaitWithAbort } from '../../utils/await-with-abort.js'
16
+ import { toErrorMessage } from '../../utils/error.js'
16
17
  import { SCOPE_ATTRIBUTE } from '../../utils/log/types.js'
17
18
  import { type Logger, resolveLogger } from '../../utils/logger.js'
18
19
 
@@ -82,7 +83,7 @@ export class EventTranslator {
82
83
  recorder.onLogWriteHealth((change) => {
83
84
  // Live only: the log is what cannot be written. The listener runs inside
84
85
  // a log write, so it must not wait on one.
85
- void this.emitEvent(
86
+ void this.emitFromStore(
86
87
  change.state === 'degraded'
87
88
  ? {
88
89
  type: 'session_log_degraded',
@@ -262,18 +263,35 @@ export class EventTranslator {
262
263
  }
263
264
  }
264
265
 
266
+ /**
267
+ * Emit an event a store's listener raised. The stores call their listeners
268
+ * and do not wait on them, so a rejection here would reach no one and stop
269
+ * the process as an unhandled rejection. A failed log write has already been
270
+ * delivered live (see `emitEvent`); the failure itself is reported on the log.
271
+ */
272
+ private async emitFromStore(draft: SessionEventDraft): Promise<void> {
273
+ try {
274
+ await this.emitEvent(draft)
275
+ } catch (error) {
276
+ this.log.warn('Could not record a session event raised by a store', {
277
+ 'namzu.event.type': draft.type,
278
+ 'exception.message': toErrorMessage(error),
279
+ })
280
+ }
281
+ }
282
+
265
283
  wireActivityStore(activityStore: ActivityStore): void {
266
284
  activityStore.on(async (event: ActivityEvent) => {
267
285
  const activity = event.activity
268
286
  if (event.type === 'activity.created') {
269
- await this.emitEvent({
287
+ await this.emitFromStore({
270
288
  type: 'activity_created',
271
289
  activityId: activity.id,
272
290
  activityType: activity.type,
273
291
  description: activity.description,
274
292
  })
275
293
  } else {
276
- await this.emitEvent({
294
+ await this.emitFromStore({
277
295
  type: 'activity_updated',
278
296
  activityId: activity.id,
279
297
  status: activity.status,
@@ -296,7 +314,7 @@ export class EventTranslator {
296
314
  if (task.sessionId !== sessionId) return
297
315
  switch (event.type) {
298
316
  case 'task.created':
299
- await this.emitEvent({
317
+ await this.emitFromStore({
300
318
  type: 'task_created',
301
319
  taskId: task.id,
302
320
  subject: task.subject,
@@ -311,7 +329,7 @@ export class EventTranslator {
311
329
  case 'task.updated':
312
330
  case 'task.claimed':
313
331
  case 'task.deleted':
314
- await this.emitEvent({
332
+ await this.emitFromStore({
315
333
  type: 'task_updated',
316
334
  taskId: task.id,
317
335
  subject: task.subject,
@@ -336,7 +354,7 @@ export class EventTranslator {
336
354
  const plan = event.plan
337
355
  switch (event.type) {
338
356
  case 'plan.ready':
339
- await this.emitEvent({
357
+ await this.emitFromStore({
340
358
  type: 'plan_ready',
341
359
  planId: plan.id,
342
360
  title: plan.title,
@@ -345,10 +363,10 @@ export class EventTranslator {
345
363
  })
346
364
  break
347
365
  case 'plan.approved':
348
- await this.emitEvent({ type: 'plan_approved', planId: plan.id })
366
+ await this.emitFromStore({ type: 'plan_approved', planId: plan.id })
349
367
  break
350
368
  case 'plan.rejected':
351
- await this.emitEvent({
369
+ await this.emitFromStore({
352
370
  type: 'plan_rejected',
353
371
  planId: plan.id,
354
372
  reason: plan.rejectionReason,
@@ -356,7 +374,7 @@ export class EventTranslator {
356
374
  break
357
375
  case 'plan.step_updated':
358
376
  if (event.step) {
359
- await this.emitEvent({
377
+ await this.emitFromStore({
360
378
  type: 'plan_step_updated',
361
379
  planId: plan.id,
362
380
  stepId: event.step.id,
@@ -365,10 +383,10 @@ export class EventTranslator {
365
383
  }
366
384
  break
367
385
  case 'plan.completed':
368
- await this.emitEvent({ type: 'plan_completed', planId: plan.id })
386
+ await this.emitFromStore({ type: 'plan_completed', planId: plan.id })
369
387
  break
370
388
  case 'plan.failed':
371
- await this.emitEvent({
389
+ await this.emitFromStore({
372
390
  type: 'plan_failed',
373
391
  planId: plan.id,
374
392
  ...(plan.failureReason ? { reason: plan.failureReason } : {}),