@evalops/maestro 0.10.17 → 0.10.20

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 (930) hide show
  1. package/README.md +56 -1
  2. package/dist/agent/action-approval.d.ts +12 -2
  3. package/dist/agent/action-approval.d.ts.map +1 -1
  4. package/dist/agent/action-approval.js +19 -32
  5. package/dist/agent/action-approval.js.map +1 -1
  6. package/dist/agent/agent.d.ts +1 -0
  7. package/dist/agent/agent.d.ts.map +1 -1
  8. package/dist/agent/agent.js +26 -0
  9. package/dist/agent/agent.js.map +1 -1
  10. package/dist/agent/compaction.d.ts +2 -0
  11. package/dist/agent/compaction.d.ts.map +1 -1
  12. package/dist/agent/compaction.js +4 -2
  13. package/dist/agent/compaction.js.map +1 -1
  14. package/dist/agent/index.d.ts +1 -1
  15. package/dist/agent/index.d.ts.map +1 -1
  16. package/dist/agent/index.js +1 -1
  17. package/dist/agent/index.js.map +1 -1
  18. package/dist/agent/modes.d.ts +56 -4
  19. package/dist/agent/modes.d.ts.map +1 -1
  20. package/dist/agent/modes.js +163 -2
  21. package/dist/agent/modes.js.map +1 -1
  22. package/dist/agent/prompt-recovery.d.ts.map +1 -1
  23. package/dist/agent/prompt-recovery.js +1 -3
  24. package/dist/agent/prompt-recovery.js.map +1 -1
  25. package/dist/agent/providers/anthropic.d.ts.map +1 -1
  26. package/dist/agent/providers/anthropic.js +9 -1
  27. package/dist/agent/providers/anthropic.js.map +1 -1
  28. package/dist/agent/providers/codex-app-server.d.ts +12 -0
  29. package/dist/agent/providers/codex-app-server.d.ts.map +1 -0
  30. package/dist/agent/providers/codex-app-server.js +788 -0
  31. package/dist/agent/providers/codex-app-server.js.map +1 -0
  32. package/dist/agent/providers/google-gemini-cli.js +14 -3
  33. package/dist/agent/providers/google.js +22 -3
  34. package/dist/agent/providers/scripted.d.ts +11 -0
  35. package/dist/agent/providers/scripted.d.ts.map +1 -0
  36. package/dist/agent/providers/scripted.js +399 -0
  37. package/dist/agent/providers/scripted.js.map +1 -0
  38. package/dist/agent/providers/vertex.js +14 -3
  39. package/dist/agent/scenario-source.d.ts +19 -0
  40. package/dist/agent/scenario-source.d.ts.map +1 -0
  41. package/dist/agent/scenario-source.js +112 -0
  42. package/dist/agent/scenario-source.js.map +1 -0
  43. package/dist/agent/subagent-specs.d.ts +1 -1
  44. package/dist/agent/subagent-specs.js +1 -1
  45. package/dist/agent/subagent-specs.js.map +1 -1
  46. package/dist/agent/swarm/executor.d.ts +25 -0
  47. package/dist/agent/swarm/executor.d.ts.map +1 -1
  48. package/dist/agent/swarm/executor.js +795 -20
  49. package/dist/agent/swarm/executor.js.map +1 -1
  50. package/dist/agent/swarm/runtime-events.d.ts +11 -0
  51. package/dist/agent/swarm/runtime-events.d.ts.map +1 -0
  52. package/dist/agent/swarm/runtime-events.js +26 -0
  53. package/dist/agent/swarm/runtime-events.js.map +1 -0
  54. package/dist/agent/swarm/types.d.ts +78 -0
  55. package/dist/agent/swarm/types.d.ts.map +1 -1
  56. package/dist/agent/swarm/types.js.map +1 -1
  57. package/dist/agent/tracing.d.ts +1 -1
  58. package/dist/agent/tracing.d.ts.map +1 -1
  59. package/dist/agent/tracing.js +17 -9
  60. package/dist/agent/tracing.js.map +1 -1
  61. package/dist/agent/transport/create-provider-stream.d.ts.map +1 -1
  62. package/dist/agent/transport/create-provider-stream.js +14 -0
  63. package/dist/agent/transport/create-provider-stream.js.map +1 -1
  64. package/dist/agent/transport/stable-stringify.d.ts +2 -0
  65. package/dist/agent/transport/stable-stringify.d.ts.map +1 -0
  66. package/dist/agent/transport/stable-stringify.js +14 -0
  67. package/dist/agent/transport/stable-stringify.js.map +1 -0
  68. package/dist/agent/transport/tool-execution-bridge.d.ts.map +1 -1
  69. package/dist/agent/transport/tool-execution-bridge.js +2 -15
  70. package/dist/agent/transport/tool-execution-bridge.js.map +1 -1
  71. package/dist/agent/transport/tool-safety-pipeline.d.ts +5 -1
  72. package/dist/agent/transport/tool-safety-pipeline.d.ts.map +1 -1
  73. package/dist/agent/transport/tool-safety-pipeline.js +184 -36
  74. package/dist/agent/transport/tool-safety-pipeline.js.map +1 -1
  75. package/dist/agent/transport.d.ts +8 -0
  76. package/dist/agent/transport.d.ts.map +1 -1
  77. package/dist/agent/transport.js +1613 -68
  78. package/dist/agent/transport.js.map +1 -1
  79. package/dist/agent/types.d.ts +170 -2
  80. package/dist/agent/types.d.ts.map +1 -1
  81. package/dist/agent/types.js.map +1 -1
  82. package/dist/api/enterprise-routes.d.ts.map +1 -1
  83. package/dist/api/enterprise-routes.js +34 -3
  84. package/dist/api/enterprise-routes.js.map +1 -1
  85. package/dist/app-server/in-process-client.d.ts +32 -0
  86. package/dist/app-server/in-process-client.d.ts.map +1 -0
  87. package/dist/app-server/in-process-client.js +73 -0
  88. package/dist/app-server/in-process-client.js.map +1 -0
  89. package/dist/app-server/session-api.d.ts +36 -0
  90. package/dist/app-server/session-api.d.ts.map +1 -0
  91. package/dist/app-server/session-api.js +713 -0
  92. package/dist/app-server/session-api.js.map +1 -0
  93. package/dist/approvals/platform-action-approval.d.ts +3 -1
  94. package/dist/approvals/platform-action-approval.d.ts.map +1 -1
  95. package/dist/approvals/platform-action-approval.js +16 -9
  96. package/dist/approvals/platform-action-approval.js.map +1 -1
  97. package/dist/approvals/service-client.d.ts.map +1 -1
  98. package/dist/approvals/service-client.js +7 -7
  99. package/dist/approvals/service-client.js.map +1 -1
  100. package/dist/audit/logger.d.ts +4 -4
  101. package/dist/bootstrap/agent-creation-setup.d.ts +4 -0
  102. package/dist/bootstrap/agent-creation-setup.d.ts.map +1 -1
  103. package/dist/bootstrap/agent-creation-setup.js +3 -1
  104. package/dist/bootstrap/agent-creation-setup.js.map +1 -1
  105. package/dist/bootstrap/auth-setup.js +1 -1
  106. package/dist/bootstrap/auth-setup.js.map +1 -1
  107. package/dist/bootstrap/event-subscriptions-setup.d.ts +6 -0
  108. package/dist/bootstrap/event-subscriptions-setup.d.ts.map +1 -1
  109. package/dist/bootstrap/event-subscriptions-setup.js +26 -2
  110. package/dist/bootstrap/event-subscriptions-setup.js.map +1 -1
  111. package/dist/bootstrap/model-resolution-setup.d.ts.map +1 -1
  112. package/dist/bootstrap/model-resolution-setup.js +4 -1
  113. package/dist/bootstrap/model-resolution-setup.js.map +1 -1
  114. package/dist/bootstrap/tools-setup.d.ts +2 -1
  115. package/dist/bootstrap/tools-setup.d.ts.map +1 -1
  116. package/dist/bootstrap/tools-setup.js +5 -1
  117. package/dist/bootstrap/tools-setup.js.map +1 -1
  118. package/dist/cli/args.d.ts +9 -1
  119. package/dist/cli/args.d.ts.map +1 -1
  120. package/dist/cli/args.js +130 -5
  121. package/dist/cli/args.js.map +1 -1
  122. package/dist/cli/commands/a2a.d.ts +9 -0
  123. package/dist/cli/commands/a2a.d.ts.map +1 -0
  124. package/dist/cli/commands/a2a.js +1714 -0
  125. package/dist/cli/commands/a2a.js.map +1 -0
  126. package/dist/cli/commands/agents.d.ts +16 -2
  127. package/dist/cli/commands/agents.d.ts.map +1 -1
  128. package/dist/cli/commands/agents.js +223 -35
  129. package/dist/cli/commands/agents.js.map +1 -1
  130. package/dist/cli/commands/codex.d.ts +1 -1
  131. package/dist/cli/commands/codex.d.ts.map +1 -1
  132. package/dist/cli/commands/codex.js +145 -39
  133. package/dist/cli/commands/codex.js.map +1 -1
  134. package/dist/cli/commands/context.d.ts +10 -0
  135. package/dist/cli/commands/context.d.ts.map +1 -0
  136. package/dist/cli/commands/context.js +176 -0
  137. package/dist/cli/commands/context.js.map +1 -0
  138. package/dist/cli/commands/hosted-runner.d.ts +1 -0
  139. package/dist/cli/commands/hosted-runner.d.ts.map +1 -1
  140. package/dist/cli/commands/hosted-runner.js +9 -1
  141. package/dist/cli/commands/hosted-runner.js.map +1 -1
  142. package/dist/cli/commands/init.d.ts.map +1 -1
  143. package/dist/cli/commands/init.js +6 -0
  144. package/dist/cli/commands/init.js.map +1 -1
  145. package/dist/cli/commands/modes.d.ts +8 -0
  146. package/dist/cli/commands/modes.d.ts.map +1 -0
  147. package/dist/cli/commands/modes.js +151 -0
  148. package/dist/cli/commands/modes.js.map +1 -0
  149. package/dist/cli/commands/operating-plane.d.ts +14 -0
  150. package/dist/cli/commands/operating-plane.d.ts.map +1 -0
  151. package/dist/cli/commands/operating-plane.js +160 -0
  152. package/dist/cli/commands/operating-plane.js.map +1 -0
  153. package/dist/cli/commands/run.d.ts +87 -0
  154. package/dist/cli/commands/run.d.ts.map +1 -0
  155. package/dist/cli/commands/run.js +356 -0
  156. package/dist/cli/commands/run.js.map +1 -0
  157. package/dist/cli/commands/scenario.d.ts +7 -0
  158. package/dist/cli/commands/scenario.d.ts.map +1 -0
  159. package/dist/cli/commands/scenario.js +195 -0
  160. package/dist/cli/commands/scenario.js.map +1 -0
  161. package/dist/cli/commands/skill.d.ts +7 -0
  162. package/dist/cli/commands/skill.d.ts.map +1 -0
  163. package/dist/cli/commands/skill.js +286 -0
  164. package/dist/cli/commands/skill.js.map +1 -0
  165. package/dist/cli/headless-protocol.d.ts +55 -1
  166. package/dist/cli/headless-protocol.d.ts.map +1 -1
  167. package/dist/cli/headless-protocol.js +446 -7
  168. package/dist/cli/headless-protocol.js.map +1 -1
  169. package/dist/cli/headless-runtime-selection.d.ts +38 -0
  170. package/dist/cli/headless-runtime-selection.d.ts.map +1 -0
  171. package/dist/cli/headless-runtime-selection.js +48 -0
  172. package/dist/cli/headless-runtime-selection.js.map +1 -0
  173. package/dist/cli/headless.d.ts +5 -1
  174. package/dist/cli/headless.d.ts.map +1 -1
  175. package/dist/cli/headless.js +11 -1
  176. package/dist/cli/headless.js.map +1 -1
  177. package/dist/cli/help.d.ts +3 -1
  178. package/dist/cli/help.d.ts.map +1 -1
  179. package/dist/cli/help.js +136 -30
  180. package/dist/cli/help.js.map +1 -1
  181. package/dist/cli/system-prompt.d.ts +22 -4
  182. package/dist/cli/system-prompt.d.ts.map +1 -1
  183. package/dist/cli/system-prompt.js +224 -127
  184. package/dist/cli/system-prompt.js.map +1 -1
  185. package/dist/cli-tui/commands/a2a-handlers.d.ts +7 -0
  186. package/dist/cli-tui/commands/a2a-handlers.d.ts.map +1 -0
  187. package/dist/cli-tui/commands/a2a-handlers.js +160 -0
  188. package/dist/cli-tui/commands/a2a-handlers.js.map +1 -0
  189. package/dist/cli-tui/commands/command-catalog.d.ts.map +1 -1
  190. package/dist/cli-tui/commands/command-catalog.js +15 -0
  191. package/dist/cli-tui/commands/command-catalog.js.map +1 -1
  192. package/dist/cli-tui/commands/command-registry-adapter.js +10 -1
  193. package/dist/cli-tui/commands/command-registry-adapter.js.map +1 -1
  194. package/dist/cli-tui/commands/handlers/mode-handler.d.ts.map +1 -1
  195. package/dist/cli-tui/commands/handlers/mode-handler.js +22 -10
  196. package/dist/cli-tui/commands/handlers/mode-handler.js.map +1 -1
  197. package/dist/cli-tui/commands/mcp-handlers.d.ts.map +1 -1
  198. package/dist/cli-tui/commands/mcp-handlers.js +6 -5
  199. package/dist/cli-tui/commands/mcp-handlers.js.map +1 -1
  200. package/dist/cli-tui/commands/types.d.ts +1 -0
  201. package/dist/cli-tui/commands/types.d.ts.map +1 -1
  202. package/dist/cli-tui/commands/types.js.map +1 -1
  203. package/dist/cli-tui/commands/utility-handlers.d.ts +4 -0
  204. package/dist/cli-tui/commands/utility-handlers.d.ts.map +1 -1
  205. package/dist/cli-tui/commands/utility-handlers.js +45 -6
  206. package/dist/cli-tui/commands/utility-handlers.js.map +1 -1
  207. package/dist/cli-tui/run/run-shell-command.d.ts.map +1 -1
  208. package/dist/cli-tui/run/run-shell-command.js +14 -5
  209. package/dist/cli-tui/run/run-shell-command.js.map +1 -1
  210. package/dist/cli-tui/run/streaming-shell-command.d.ts.map +1 -1
  211. package/dist/cli-tui/run/streaming-shell-command.js +14 -5
  212. package/dist/cli-tui/run/streaming-shell-command.js.map +1 -1
  213. package/dist/cli-tui/selectors/model-selector.d.ts +1 -0
  214. package/dist/cli-tui/selectors/model-selector.d.ts.map +1 -1
  215. package/dist/cli-tui/selectors/model-selector.js +6 -2
  216. package/dist/cli-tui/selectors/model-selector.js.map +1 -1
  217. package/dist/cli-tui/tui-renderer/command-registry-options.d.ts.map +1 -1
  218. package/dist/cli-tui/tui-renderer/command-registry-options.js +5 -0
  219. package/dist/cli-tui/tui-renderer/command-registry-options.js.map +1 -1
  220. package/dist/cli-tui/utils/commands/review-prompt.d.ts +1 -1
  221. package/dist/cli-tui/utils/commands/review-prompt.d.ts.map +1 -1
  222. package/dist/cli-tui/utils/commands/review-prompt.js +8 -3
  223. package/dist/cli-tui/utils/commands/review-prompt.js.map +1 -1
  224. package/dist/cli-tui/utils/runtime-badges.d.ts +1 -0
  225. package/dist/cli-tui/utils/runtime-badges.d.ts.map +1 -1
  226. package/dist/cli-tui/utils/runtime-badges.js +7 -0
  227. package/dist/cli-tui/utils/runtime-badges.js.map +1 -1
  228. package/dist/cli-tui/utils/text-formatting.d.ts +1 -0
  229. package/dist/cli-tui/utils/text-formatting.d.ts.map +1 -1
  230. package/dist/cli-tui/utils/text-formatting.js +5 -0
  231. package/dist/cli-tui/utils/text-formatting.js.map +1 -1
  232. package/dist/cli.js +49209 -26165
  233. package/dist/cli.js.map +1 -1
  234. package/dist/codex/app-server-client.d.ts +139 -0
  235. package/dist/codex/app-server-client.d.ts.map +1 -0
  236. package/dist/codex/app-server-client.js +352 -0
  237. package/dist/codex/app-server-client.js.map +1 -0
  238. package/dist/codex/compatibility.d.ts +48 -0
  239. package/dist/codex/compatibility.d.ts.map +1 -0
  240. package/dist/codex/compatibility.js +344 -0
  241. package/dist/codex/compatibility.js.map +1 -0
  242. package/dist/codex/subagent-dispatch-table.d.ts +66 -0
  243. package/dist/codex/subagent-dispatch-table.d.ts.map +1 -0
  244. package/dist/codex/subagent-dispatch-table.js +127 -0
  245. package/dist/codex/subagent-dispatch-table.js.map +1 -0
  246. package/dist/codex/subagent-workgraph.d.ts +56 -0
  247. package/dist/codex/subagent-workgraph.d.ts.map +1 -0
  248. package/dist/codex/subagent-workgraph.js +89 -0
  249. package/dist/codex/subagent-workgraph.js.map +1 -0
  250. package/dist/config/constants.d.ts +3 -1
  251. package/dist/config/constants.d.ts.map +1 -1
  252. package/dist/config/constants.js +9 -0
  253. package/dist/config/constants.js.map +1 -1
  254. package/dist/config/feature-flags.d.ts +10 -1
  255. package/dist/config/feature-flags.d.ts.map +1 -1
  256. package/dist/config/feature-flags.js +17 -6
  257. package/dist/config/feature-flags.js.map +1 -1
  258. package/dist/config/index.d.ts +1 -1
  259. package/dist/config/index.d.ts.map +1 -1
  260. package/dist/config/index.js +1 -1
  261. package/dist/config/index.js.map +1 -1
  262. package/dist/config/toml-config.d.ts +32 -0
  263. package/dist/config/toml-config.d.ts.map +1 -1
  264. package/dist/config/toml-config.js +152 -43
  265. package/dist/config/toml-config.js.map +1 -1
  266. package/dist/connectors/service-client.d.ts.map +1 -1
  267. package/dist/connectors/service-client.js +4 -7
  268. package/dist/connectors/service-client.js.map +1 -1
  269. package/dist/context/manifest-types.d.ts +59 -0
  270. package/dist/context/manifest-types.d.ts.map +1 -0
  271. package/dist/context/manifest-types.js +2 -0
  272. package/dist/context/manifest-types.js.map +1 -0
  273. package/dist/context/manifest.d.ts +16 -0
  274. package/dist/context/manifest.d.ts.map +1 -0
  275. package/dist/context/manifest.js +503 -0
  276. package/dist/context/manifest.js.map +1 -0
  277. package/dist/db/schema.d.ts +10 -1
  278. package/dist/db/schema.d.ts.map +1 -1
  279. package/dist/db/schema.js.map +1 -1
  280. package/dist/evalops/agent-bootstrap.d.ts +1 -0
  281. package/dist/evalops/agent-bootstrap.d.ts.map +1 -1
  282. package/dist/evalops/agent-bootstrap.js +41 -1
  283. package/dist/evalops/agent-bootstrap.js.map +1 -1
  284. package/dist/evalops/env-aliases.d.ts +13 -0
  285. package/dist/evalops/env-aliases.d.ts.map +1 -0
  286. package/dist/evalops/env-aliases.js +60 -0
  287. package/dist/evalops/env-aliases.js.map +1 -0
  288. package/dist/evalops/managed-context.d.ts.map +1 -1
  289. package/dist/evalops/managed-context.js +28 -62
  290. package/dist/evalops/managed-context.js.map +1 -1
  291. package/dist/guardian/config.d.ts.map +1 -1
  292. package/dist/guardian/config.js +1 -0
  293. package/dist/guardian/config.js.map +1 -1
  294. package/dist/guardian/runner.d.ts +2 -0
  295. package/dist/guardian/runner.d.ts.map +1 -1
  296. package/dist/guardian/runner.js +105 -2
  297. package/dist/guardian/runner.js.map +1 -1
  298. package/dist/guardian/types.d.ts +1 -0
  299. package/dist/guardian/types.d.ts.map +1 -1
  300. package/dist/guardian/types.js.map +1 -1
  301. package/dist/index.d.ts +6 -1
  302. package/dist/index.d.ts.map +1 -1
  303. package/dist/index.js +6 -1
  304. package/dist/index.js.map +1 -1
  305. package/dist/main.d.ts.map +1 -1
  306. package/dist/main.js +267 -55
  307. package/dist/main.js.map +1 -1
  308. package/dist/mcp/config.d.ts.map +1 -1
  309. package/dist/mcp/config.js +89 -7
  310. package/dist/mcp/config.js.map +1 -1
  311. package/dist/mcp/manager.d.ts +5 -1
  312. package/dist/mcp/manager.d.ts.map +1 -1
  313. package/dist/mcp/manager.js +159 -4
  314. package/dist/mcp/manager.js.map +1 -1
  315. package/dist/mcp/platform-plugin.d.ts.map +1 -1
  316. package/dist/mcp/platform-plugin.js +9 -26
  317. package/dist/mcp/platform-plugin.js.map +1 -1
  318. package/dist/mcp/schema.d.ts +15 -0
  319. package/dist/mcp/schema.d.ts.map +1 -1
  320. package/dist/mcp/schema.js +24 -0
  321. package/dist/mcp/schema.js.map +1 -1
  322. package/dist/mcp/tool-bridge.d.ts +39 -10
  323. package/dist/mcp/tool-bridge.d.ts.map +1 -1
  324. package/dist/mcp/tool-bridge.js +101 -24
  325. package/dist/mcp/tool-bridge.js.map +1 -1
  326. package/dist/mcp/types.d.ts +27 -0
  327. package/dist/mcp/types.d.ts.map +1 -1
  328. package/dist/mcp/types.js.map +1 -1
  329. package/dist/mcp/workspace-trust.d.ts +10 -0
  330. package/dist/mcp/workspace-trust.d.ts.map +1 -0
  331. package/dist/mcp/workspace-trust.js +295 -0
  332. package/dist/mcp/workspace-trust.js.map +1 -0
  333. package/dist/memory/service-client.d.ts +1 -0
  334. package/dist/memory/service-client.d.ts.map +1 -1
  335. package/dist/memory/service-client.js +194 -9
  336. package/dist/memory/service-client.js.map +1 -1
  337. package/dist/models/builtin.d.ts.map +1 -1
  338. package/dist/models/builtin.js +66 -25
  339. package/dist/models/builtin.js.map +1 -1
  340. package/dist/models/config-loader.d.ts +10 -10
  341. package/dist/models/config-loader.d.ts.map +1 -1
  342. package/dist/models/config-loader.js +2 -0
  343. package/dist/models/config-loader.js.map +1 -1
  344. package/dist/models/registry.d.ts +1 -0
  345. package/dist/models/registry.d.ts.map +1 -1
  346. package/dist/models/registry.js +1 -0
  347. package/dist/models/registry.js.map +1 -1
  348. package/dist/oauth/device-identity.d.ts.map +1 -1
  349. package/dist/oauth/device-identity.js +1 -3
  350. package/dist/oauth/device-identity.js.map +1 -1
  351. package/dist/oauth/evalops.d.ts.map +1 -1
  352. package/dist/oauth/evalops.js +2 -5
  353. package/dist/oauth/evalops.js.map +1 -1
  354. package/dist/opentelemetry.d.ts.map +1 -1
  355. package/dist/opentelemetry.js +12 -12
  356. package/dist/opentelemetry.js.map +1 -1
  357. package/dist/package-version.d.ts +2 -0
  358. package/dist/package-version.d.ts.map +1 -0
  359. package/dist/package-version.js +11 -0
  360. package/dist/package-version.js.map +1 -0
  361. package/dist/packages/constants.d.ts +3 -0
  362. package/dist/packages/constants.d.ts.map +1 -0
  363. package/dist/packages/constants.js +3 -0
  364. package/dist/packages/constants.js.map +1 -0
  365. package/dist/packages/inspection.d.ts.map +1 -1
  366. package/dist/packages/inspection.js +2 -1
  367. package/dist/packages/inspection.js.map +1 -1
  368. package/dist/packages/search.d.ts.map +1 -1
  369. package/dist/packages/search.js +1 -1
  370. package/dist/packages/search.js.map +1 -1
  371. package/dist/platform/a2a-capability-market.d.ts +21 -0
  372. package/dist/platform/a2a-capability-market.d.ts.map +1 -0
  373. package/dist/platform/a2a-capability-market.js +176 -0
  374. package/dist/platform/a2a-capability-market.js.map +1 -0
  375. package/dist/platform/a2a-client.d.ts +217 -0
  376. package/dist/platform/a2a-client.d.ts.map +1 -0
  377. package/dist/platform/a2a-client.js +589 -0
  378. package/dist/platform/a2a-client.js.map +1 -0
  379. package/dist/platform/a2a-fleet.d.ts +41 -0
  380. package/dist/platform/a2a-fleet.d.ts.map +1 -0
  381. package/dist/platform/a2a-fleet.js +109 -0
  382. package/dist/platform/a2a-fleet.js.map +1 -0
  383. package/dist/platform/a2a-maestro-peer.d.ts +20 -0
  384. package/dist/platform/a2a-maestro-peer.d.ts.map +1 -0
  385. package/dist/platform/a2a-maestro-peer.js +176 -0
  386. package/dist/platform/a2a-maestro-peer.js.map +1 -0
  387. package/dist/platform/a2a-peer-pairing.d.ts +107 -0
  388. package/dist/platform/a2a-peer-pairing.d.ts.map +1 -0
  389. package/dist/platform/a2a-peer-pairing.js +489 -0
  390. package/dist/platform/a2a-peer-pairing.js.map +1 -0
  391. package/dist/platform/a2a-peer-registry.d.ts +68 -0
  392. package/dist/platform/a2a-peer-registry.d.ts.map +1 -0
  393. package/dist/platform/a2a-peer-registry.js +320 -0
  394. package/dist/platform/a2a-peer-registry.js.map +1 -0
  395. package/dist/platform/a2a-task-ledger.d.ts +86 -0
  396. package/dist/platform/a2a-task-ledger.d.ts.map +1 -0
  397. package/dist/platform/a2a-task-ledger.js +546 -0
  398. package/dist/platform/a2a-task-ledger.js.map +1 -0
  399. package/dist/platform/a2a-work-graph.d.ts +43 -0
  400. package/dist/platform/a2a-work-graph.d.ts.map +1 -0
  401. package/dist/platform/a2a-work-graph.js +267 -0
  402. package/dist/platform/a2a-work-graph.js.map +1 -0
  403. package/dist/platform/agent-registry-client.d.ts +327 -0
  404. package/dist/platform/agent-registry-client.d.ts.map +1 -0
  405. package/dist/platform/agent-registry-client.js +803 -0
  406. package/dist/platform/agent-registry-client.js.map +1 -0
  407. package/dist/platform/agent-runtime-client.d.ts +135 -1
  408. package/dist/platform/agent-runtime-client.d.ts.map +1 -1
  409. package/dist/platform/agent-runtime-client.js +467 -10
  410. package/dist/platform/agent-runtime-client.js.map +1 -1
  411. package/dist/platform/cerebro-facts-client.d.ts.map +1 -1
  412. package/dist/platform/cerebro-facts-client.js +4 -7
  413. package/dist/platform/cerebro-facts-client.js.map +1 -1
  414. package/dist/platform/client.d.ts +2 -0
  415. package/dist/platform/client.d.ts.map +1 -1
  416. package/dist/platform/client.js +7 -14
  417. package/dist/platform/client.js.map +1 -1
  418. package/dist/platform/core-services.d.ts +68 -0
  419. package/dist/platform/core-services.d.ts.map +1 -1
  420. package/dist/platform/core-services.js +68 -0
  421. package/dist/platform/core-services.js.map +1 -1
  422. package/dist/platform/fermata-eval-client.d.ts +195 -0
  423. package/dist/platform/fermata-eval-client.d.ts.map +1 -0
  424. package/dist/platform/fermata-eval-client.js +146 -0
  425. package/dist/platform/fermata-eval-client.js.map +1 -0
  426. package/dist/platform/fermata-scenario-suite.d.ts +99 -0
  427. package/dist/platform/fermata-scenario-suite.d.ts.map +1 -0
  428. package/dist/platform/fermata-scenario-suite.js +459 -0
  429. package/dist/platform/fermata-scenario-suite.js.map +1 -0
  430. package/dist/platform/maestro-timeline-client.d.ts.map +1 -1
  431. package/dist/platform/maestro-timeline-client.js +5 -11
  432. package/dist/platform/maestro-timeline-client.js.map +1 -1
  433. package/dist/platform/operating-plane-client.d.ts +156 -0
  434. package/dist/platform/operating-plane-client.d.ts.map +1 -0
  435. package/dist/platform/operating-plane-client.js +131 -0
  436. package/dist/platform/operating-plane-client.js.map +1 -0
  437. package/dist/platform/operating-plane-summary.d.ts +47 -0
  438. package/dist/platform/operating-plane-summary.d.ts.map +1 -0
  439. package/dist/platform/operating-plane-summary.js +209 -0
  440. package/dist/platform/operating-plane-summary.js.map +1 -0
  441. package/dist/platform/tool-execution-client.d.ts.map +1 -1
  442. package/dist/platform/tool-execution-client.js +4 -11
  443. package/dist/platform/tool-execution-client.js.map +1 -1
  444. package/dist/prompts/service-client.d.ts.map +1 -1
  445. package/dist/prompts/service-client.js +3 -5
  446. package/dist/prompts/service-client.js.map +1 -1
  447. package/dist/prompts/system-prompt.d.ts +3 -0
  448. package/dist/prompts/system-prompt.d.ts.map +1 -1
  449. package/dist/prompts/system-prompt.js +13 -3
  450. package/dist/prompts/system-prompt.js.map +1 -1
  451. package/dist/prompts/types.d.ts +2 -0
  452. package/dist/prompts/types.d.ts.map +1 -1
  453. package/dist/prompts/types.js.map +1 -1
  454. package/dist/providers/api-keys.d.ts +1 -1
  455. package/dist/providers/api-keys.d.ts.map +1 -1
  456. package/dist/providers/api-keys.js +2 -1
  457. package/dist/providers/api-keys.js.map +1 -1
  458. package/dist/providers/auth.d.ts.map +1 -1
  459. package/dist/providers/auth.js +48 -25
  460. package/dist/providers/auth.js.map +1 -1
  461. package/dist/remote-runner/attach-client.d.ts.map +1 -1
  462. package/dist/remote-runner/attach-client.js +1 -0
  463. package/dist/remote-runner/attach-client.js.map +1 -1
  464. package/dist/remote-runner/client.d.ts.map +1 -1
  465. package/dist/remote-runner/client.js +4 -7
  466. package/dist/remote-runner/client.js.map +1 -1
  467. package/dist/rpc/rpc-types.d.ts.map +1 -1
  468. package/dist/rpc/rpc-types.js +1 -0
  469. package/dist/rpc/rpc-types.js.map +1 -1
  470. package/dist/safety/action-firewall.d.ts.map +1 -1
  471. package/dist/safety/action-firewall.js +69 -6
  472. package/dist/safety/action-firewall.js.map +1 -1
  473. package/dist/safety/attack-patterns.d.ts.map +1 -1
  474. package/dist/safety/attack-patterns.js +31 -14
  475. package/dist/safety/attack-patterns.js.map +1 -1
  476. package/dist/safety/bash-parser.d.ts.map +1 -1
  477. package/dist/safety/bash-parser.js +4 -3
  478. package/dist/safety/bash-parser.js.map +1 -1
  479. package/dist/safety/execpolicy.d.ts +15 -3
  480. package/dist/safety/execpolicy.d.ts.map +1 -1
  481. package/dist/safety/execpolicy.js +248 -37
  482. package/dist/safety/execpolicy.js.map +1 -1
  483. package/dist/safety/governance-service-client.d.ts.map +1 -1
  484. package/dist/safety/governance-service-client.js +4 -7
  485. package/dist/safety/governance-service-client.js.map +1 -1
  486. package/dist/safety/guarded-files.d.ts +34 -0
  487. package/dist/safety/guarded-files.d.ts.map +1 -0
  488. package/dist/safety/guarded-files.js +372 -0
  489. package/dist/safety/guarded-files.js.map +1 -0
  490. package/dist/safety/loop-detector.d.ts.map +1 -1
  491. package/dist/safety/loop-detector.js +6 -1
  492. package/dist/safety/loop-detector.js.map +1 -1
  493. package/dist/safety/permission-profile.d.ts +47 -0
  494. package/dist/safety/permission-profile.d.ts.map +1 -0
  495. package/dist/safety/permission-profile.js +349 -0
  496. package/dist/safety/permission-profile.js.map +1 -0
  497. package/dist/safety/safety-middleware.d.ts +5 -1
  498. package/dist/safety/safety-middleware.d.ts.map +1 -1
  499. package/dist/safety/safety-middleware.js +3 -2
  500. package/dist/safety/safety-middleware.js.map +1 -1
  501. package/dist/safety/suspicious-patterns.d.ts.map +1 -1
  502. package/dist/safety/suspicious-patterns.js +12 -7
  503. package/dist/safety/suspicious-patterns.js.map +1 -1
  504. package/dist/safety/tool-categorization.js +1 -1
  505. package/dist/safety/tool-categorization.js.map +1 -1
  506. package/dist/safety/validators/path-policy-validator.d.ts.map +1 -1
  507. package/dist/safety/validators/path-policy-validator.js +7 -0
  508. package/dist/safety/validators/path-policy-validator.js.map +1 -1
  509. package/dist/sandbox/index.d.ts +6 -1
  510. package/dist/sandbox/index.d.ts.map +1 -1
  511. package/dist/sandbox/index.js +30 -4
  512. package/dist/sandbox/index.js.map +1 -1
  513. package/dist/sandbox/native-sandbox.d.ts +3 -0
  514. package/dist/sandbox/native-sandbox.d.ts.map +1 -1
  515. package/dist/sandbox/native-sandbox.js +139 -18
  516. package/dist/sandbox/native-sandbox.js.map +1 -1
  517. package/dist/sentry.d.ts +17 -0
  518. package/dist/sentry.d.ts.map +1 -0
  519. package/dist/sentry.js +91 -0
  520. package/dist/sentry.js.map +1 -0
  521. package/dist/server/agent-runtime-ledger.d.ts +141 -0
  522. package/dist/server/agent-runtime-ledger.d.ts.map +1 -0
  523. package/dist/server/agent-runtime-ledger.js +334 -0
  524. package/dist/server/agent-runtime-ledger.js.map +1 -0
  525. package/dist/server/agent-trajectory-inspection.d.ts +104 -0
  526. package/dist/server/agent-trajectory-inspection.d.ts.map +1 -0
  527. package/dist/server/agent-trajectory-inspection.js +168 -0
  528. package/dist/server/agent-trajectory-inspection.js.map +1 -0
  529. package/dist/server/agent-trajectory-replay.d.ts +56 -0
  530. package/dist/server/agent-trajectory-replay.d.ts.map +1 -0
  531. package/dist/server/agent-trajectory-replay.js +214 -0
  532. package/dist/server/agent-trajectory-replay.js.map +1 -0
  533. package/dist/server/agent-trajectory-scenarios.d.ts +109 -0
  534. package/dist/server/agent-trajectory-scenarios.d.ts.map +1 -0
  535. package/dist/server/agent-trajectory-scenarios.js +822 -0
  536. package/dist/server/agent-trajectory-scenarios.js.map +1 -0
  537. package/dist/server/agent-trajectory-scorers.d.ts +61 -0
  538. package/dist/server/agent-trajectory-scorers.d.ts.map +1 -0
  539. package/dist/server/agent-trajectory-scorers.js +162 -0
  540. package/dist/server/agent-trajectory-scorers.js.map +1 -0
  541. package/dist/server/agent-trajectory-validation.d.ts +7 -0
  542. package/dist/server/agent-trajectory-validation.d.ts.map +1 -0
  543. package/dist/server/agent-trajectory-validation.js +101 -0
  544. package/dist/server/agent-trajectory-validation.js.map +1 -0
  545. package/dist/server/agent-trajectory.d.ts +50 -0
  546. package/dist/server/agent-trajectory.d.ts.map +1 -0
  547. package/dist/server/agent-trajectory.js +159 -0
  548. package/dist/server/agent-trajectory.js.map +1 -0
  549. package/dist/server/app-context.d.ts +18 -0
  550. package/dist/server/app-context.d.ts.map +1 -1
  551. package/dist/server/app-context.js.map +1 -1
  552. package/dist/server/handlers/headless-sessions.d.ts.map +1 -1
  553. package/dist/server/handlers/headless-sessions.js +64 -27
  554. package/dist/server/handlers/headless-sessions.js.map +1 -1
  555. package/dist/server/handlers/health.d.ts +6 -0
  556. package/dist/server/handlers/health.d.ts.map +1 -1
  557. package/dist/server/handlers/health.js +6 -0
  558. package/dist/server/handlers/health.js.map +1 -1
  559. package/dist/server/handlers/hosted-runner-drain.d.ts +69 -1
  560. package/dist/server/handlers/hosted-runner-drain.d.ts.map +1 -1
  561. package/dist/server/handlers/hosted-runner-drain.js +309 -18
  562. package/dist/server/handlers/hosted-runner-drain.js.map +1 -1
  563. package/dist/server/handlers/hosted-runner-identity.d.ts +16 -0
  564. package/dist/server/handlers/hosted-runner-identity.d.ts.map +1 -1
  565. package/dist/server/handlers/hosted-runner-identity.js +43 -0
  566. package/dist/server/handlers/hosted-runner-identity.js.map +1 -1
  567. package/dist/server/handlers/mode.d.ts.map +1 -1
  568. package/dist/server/handlers/mode.js +3 -1
  569. package/dist/server/handlers/mode.js.map +1 -1
  570. package/dist/server/handlers/pending-requests.d.ts.map +1 -1
  571. package/dist/server/handlers/pending-requests.js +336 -51
  572. package/dist/server/handlers/pending-requests.js.map +1 -1
  573. package/dist/server/handlers/platform-a2a-push.d.ts +6 -0
  574. package/dist/server/handlers/platform-a2a-push.d.ts.map +1 -0
  575. package/dist/server/handlers/platform-a2a-push.js +136 -0
  576. package/dist/server/handlers/platform-a2a-push.js.map +1 -0
  577. package/dist/server/handlers/sessions.d.ts.map +1 -1
  578. package/dist/server/handlers/sessions.js +21 -1
  579. package/dist/server/handlers/sessions.js.map +1 -1
  580. package/dist/server/headless-runtime-service.d.ts +9 -2
  581. package/dist/server/headless-runtime-service.d.ts.map +1 -1
  582. package/dist/server/headless-runtime-service.js +39 -0
  583. package/dist/server/headless-runtime-service.js.map +1 -1
  584. package/dist/server/hosted-agent-runtime-progress.d.ts +144 -0
  585. package/dist/server/hosted-agent-runtime-progress.d.ts.map +1 -0
  586. package/dist/server/hosted-agent-runtime-progress.js +1650 -0
  587. package/dist/server/hosted-agent-runtime-progress.js.map +1 -0
  588. package/dist/server/hosted-runner-lease.d.ts +41 -0
  589. package/dist/server/hosted-runner-lease.d.ts.map +1 -0
  590. package/dist/server/hosted-runner-lease.js +140 -0
  591. package/dist/server/hosted-runner-lease.js.map +1 -0
  592. package/dist/server/hosted-session-manager.d.ts +16 -8
  593. package/dist/server/hosted-session-manager.d.ts.map +1 -1
  594. package/dist/server/hosted-session-manager.js +98 -76
  595. package/dist/server/hosted-session-manager.js.map +1 -1
  596. package/dist/server/junit-xml.d.ts +2 -0
  597. package/dist/server/junit-xml.d.ts.map +1 -0
  598. package/dist/server/junit-xml.js +9 -0
  599. package/dist/server/junit-xml.js.map +1 -0
  600. package/dist/server/routes.d.ts.map +1 -1
  601. package/dist/server/routes.js +6 -0
  602. package/dist/server/routes.js.map +1 -1
  603. package/dist/server/scenario-recorder.d.ts +56 -0
  604. package/dist/server/scenario-recorder.d.ts.map +1 -0
  605. package/dist/server/scenario-recorder.js +109 -0
  606. package/dist/server/scenario-recorder.js.map +1 -0
  607. package/dist/server/scripted-scenario-runner.d.ts +46 -0
  608. package/dist/server/scripted-scenario-runner.d.ts.map +1 -0
  609. package/dist/server/scripted-scenario-runner.js +190 -0
  610. package/dist/server/scripted-scenario-runner.js.map +1 -0
  611. package/dist/server/server-middlewares.d.ts +6 -2
  612. package/dist/server/server-middlewares.d.ts.map +1 -1
  613. package/dist/server/server-middlewares.js +8 -2
  614. package/dist/server/server-middlewares.js.map +1 -1
  615. package/dist/server/server-request-manager.d.ts +9 -1
  616. package/dist/server/server-request-manager.d.ts.map +1 -1
  617. package/dist/server/server-request-manager.js +49 -4
  618. package/dist/server/server-request-manager.js.map +1 -1
  619. package/dist/services/intelligent-router/service.d.ts +2 -0
  620. package/dist/services/intelligent-router/service.d.ts.map +1 -1
  621. package/dist/services/intelligent-router/service.js +4 -0
  622. package/dist/services/intelligent-router/service.js.map +1 -1
  623. package/dist/services/service-authority.d.ts +25 -0
  624. package/dist/services/service-authority.d.ts.map +1 -0
  625. package/dist/services/service-authority.js +143 -0
  626. package/dist/services/service-authority.js.map +1 -0
  627. package/dist/services/workspace-config/service.d.ts +2 -0
  628. package/dist/services/workspace-config/service.d.ts.map +1 -1
  629. package/dist/services/workspace-config/service.js +4 -0
  630. package/dist/services/workspace-config/service.js.map +1 -1
  631. package/dist/session/manager.d.ts +8 -2
  632. package/dist/session/manager.d.ts.map +1 -1
  633. package/dist/session/manager.js +19 -4
  634. package/dist/session/manager.js.map +1 -1
  635. package/dist/session/session-branch.d.ts.map +1 -1
  636. package/dist/session/session-branch.js +5 -1
  637. package/dist/session/session-branch.js.map +1 -1
  638. package/dist/session/session-catalog.d.ts +7 -2
  639. package/dist/session/session-catalog.d.ts.map +1 -1
  640. package/dist/session/session-catalog.js +13 -2
  641. package/dist/session/session-catalog.js.map +1 -1
  642. package/dist/session/session-context.d.ts +6 -2
  643. package/dist/session/session-context.d.ts.map +1 -1
  644. package/dist/session/session-context.js +44 -4
  645. package/dist/session/session-context.js.map +1 -1
  646. package/dist/session/session-graph-projection.d.ts +32 -0
  647. package/dist/session/session-graph-projection.d.ts.map +1 -0
  648. package/dist/session/session-graph-projection.js +133 -0
  649. package/dist/session/session-graph-projection.js.map +1 -0
  650. package/dist/session/types.d.ts +18 -0
  651. package/dist/session/types.d.ts.map +1 -1
  652. package/dist/session/types.js +8 -0
  653. package/dist/session/types.js.map +1 -1
  654. package/dist/session/wire-format.generated.d.ts +3 -0
  655. package/dist/session/wire-format.generated.d.ts.map +1 -1
  656. package/dist/session/wire-format.generated.js +20 -0
  657. package/dist/session/wire-format.generated.js.map +1 -1
  658. package/dist/skills/eval-harness.d.ts +38 -0
  659. package/dist/skills/eval-harness.d.ts.map +1 -0
  660. package/dist/skills/eval-harness.js +112 -0
  661. package/dist/skills/eval-harness.js.map +1 -0
  662. package/dist/skills/index.d.ts +5 -1
  663. package/dist/skills/index.d.ts.map +1 -1
  664. package/dist/skills/index.js +5 -1
  665. package/dist/skills/index.js.map +1 -1
  666. package/dist/skills/linter.d.ts +36 -0
  667. package/dist/skills/linter.d.ts.map +1 -0
  668. package/dist/skills/linter.js +398 -0
  669. package/dist/skills/linter.js.map +1 -0
  670. package/dist/skills/loader.d.ts +36 -6
  671. package/dist/skills/loader.d.ts.map +1 -1
  672. package/dist/skills/loader.js +169 -86
  673. package/dist/skills/loader.js.map +1 -1
  674. package/dist/skills/package-contract.d.ts +45 -0
  675. package/dist/skills/package-contract.d.ts.map +1 -0
  676. package/dist/skills/package-contract.js +153 -0
  677. package/dist/skills/package-contract.js.map +1 -0
  678. package/dist/skills/runtime-activation.d.ts +68 -0
  679. package/dist/skills/runtime-activation.d.ts.map +1 -0
  680. package/dist/skills/runtime-activation.js +228 -0
  681. package/dist/skills/runtime-activation.js.map +1 -0
  682. package/dist/skills/service-client.d.ts.map +1 -1
  683. package/dist/skills/service-client.js +3 -4
  684. package/dist/skills/service-client.js.map +1 -1
  685. package/dist/skills/tool.d.ts.map +1 -1
  686. package/dist/skills/tool.js +2 -0
  687. package/dist/skills/tool.js.map +1 -1
  688. package/dist/skills/types.d.ts +14 -0
  689. package/dist/skills/types.d.ts.map +1 -1
  690. package/dist/skills/types.js.map +1 -1
  691. package/dist/telemetry/agent-operating-plane-context.d.ts +24 -0
  692. package/dist/telemetry/agent-operating-plane-context.d.ts.map +1 -0
  693. package/dist/telemetry/agent-operating-plane-context.js +54 -0
  694. package/dist/telemetry/agent-operating-plane-context.js.map +1 -0
  695. package/dist/telemetry/beacon.d.ts +24 -0
  696. package/dist/telemetry/beacon.d.ts.map +1 -0
  697. package/dist/telemetry/beacon.js +115 -0
  698. package/dist/telemetry/beacon.js.map +1 -0
  699. package/dist/telemetry/cli-command-aggregator.d.ts +36 -0
  700. package/dist/telemetry/cli-command-aggregator.d.ts.map +1 -0
  701. package/dist/telemetry/cli-command-aggregator.js +251 -0
  702. package/dist/telemetry/cli-command-aggregator.js.map +1 -0
  703. package/dist/telemetry/cli-startup.d.ts +21 -0
  704. package/dist/telemetry/cli-startup.d.ts.map +1 -0
  705. package/dist/telemetry/cli-startup.js +83 -0
  706. package/dist/telemetry/cli-startup.js.map +1 -0
  707. package/dist/telemetry/disablement.d.ts +13 -0
  708. package/dist/telemetry/disablement.d.ts.map +1 -0
  709. package/dist/telemetry/disablement.js +19 -0
  710. package/dist/telemetry/disablement.js.map +1 -0
  711. package/dist/telemetry/index.d.ts +6 -2
  712. package/dist/telemetry/index.d.ts.map +1 -1
  713. package/dist/telemetry/index.js +6 -2
  714. package/dist/telemetry/index.js.map +1 -1
  715. package/dist/telemetry/maestro-event-bus.d.ts +52 -0
  716. package/dist/telemetry/maestro-event-bus.d.ts.map +1 -1
  717. package/dist/telemetry/maestro-event-bus.js +179 -3
  718. package/dist/telemetry/maestro-event-bus.js.map +1 -1
  719. package/dist/telemetry/maestro-event-catalog.d.ts +3 -1
  720. package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -1
  721. package/dist/telemetry/maestro-event-catalog.js +2 -0
  722. package/dist/telemetry/maestro-event-catalog.js.map +1 -1
  723. package/dist/telemetry/maestro-platform-replay-fixture.d.ts.map +1 -1
  724. package/dist/telemetry/maestro-platform-replay-fixture.js +74 -9
  725. package/dist/telemetry/maestro-platform-replay-fixture.js.map +1 -1
  726. package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts +1 -1
  727. package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts.map +1 -1
  728. package/dist/telemetry/maestro-publisher-conformance-fixture.js +46 -11
  729. package/dist/telemetry/maestro-publisher-conformance-fixture.js.map +1 -1
  730. package/dist/telemetry/mcp-beacon.d.ts +20 -0
  731. package/dist/telemetry/mcp-beacon.d.ts.map +1 -0
  732. package/dist/telemetry/mcp-beacon.js +54 -0
  733. package/dist/telemetry/mcp-beacon.js.map +1 -0
  734. package/dist/telemetry/metadata-normalization.d.ts +7 -0
  735. package/dist/telemetry/metadata-normalization.d.ts.map +1 -0
  736. package/dist/telemetry/metadata-normalization.js +189 -0
  737. package/dist/telemetry/metadata-normalization.js.map +1 -0
  738. package/dist/telemetry/meter-service-client.d.ts.map +1 -1
  739. package/dist/telemetry/meter-service-client.js +5 -10
  740. package/dist/telemetry/meter-service-client.js.map +1 -1
  741. package/dist/telemetry/metrics.d.ts +123 -0
  742. package/dist/telemetry/metrics.d.ts.map +1 -0
  743. package/dist/telemetry/metrics.js +184 -0
  744. package/dist/telemetry/metrics.js.map +1 -0
  745. package/dist/telemetry/turn-tracker.d.ts +1 -0
  746. package/dist/telemetry/turn-tracker.d.ts.map +1 -1
  747. package/dist/telemetry/turn-tracker.js +22 -1
  748. package/dist/telemetry/turn-tracker.js.map +1 -1
  749. package/dist/telemetry/wide-events.d.ts +31 -1
  750. package/dist/telemetry/wide-events.d.ts.map +1 -1
  751. package/dist/telemetry/wide-events.js +229 -1
  752. package/dist/telemetry/wide-events.js.map +1 -1
  753. package/dist/telemetry.d.ts +39 -3
  754. package/dist/telemetry.d.ts.map +1 -1
  755. package/dist/telemetry.js +160 -3
  756. package/dist/telemetry.js.map +1 -1
  757. package/dist/testing/test-verification-hook.d.ts.map +1 -1
  758. package/dist/testing/test-verification-hook.js +34 -21
  759. package/dist/testing/test-verification-hook.js.map +1 -1
  760. package/dist/tools/apply-patch-parser.d.ts +26 -0
  761. package/dist/tools/apply-patch-parser.d.ts.map +1 -0
  762. package/dist/tools/apply-patch-parser.js +146 -0
  763. package/dist/tools/apply-patch-parser.js.map +1 -0
  764. package/dist/tools/apply-patch.d.ts +42 -0
  765. package/dist/tools/apply-patch.d.ts.map +1 -0
  766. package/dist/tools/apply-patch.js +648 -0
  767. package/dist/tools/apply-patch.js.map +1 -0
  768. package/dist/tools/ask-user.d.ts +1 -0
  769. package/dist/tools/ask-user.d.ts.map +1 -1
  770. package/dist/tools/background/tool-handler.d.ts +1 -0
  771. package/dist/tools/background/tool-handler.d.ts.map +1 -1
  772. package/dist/tools/bash.d.ts +1 -0
  773. package/dist/tools/bash.d.ts.map +1 -1
  774. package/dist/tools/codesearch.d.ts +1 -0
  775. package/dist/tools/codesearch.d.ts.map +1 -1
  776. package/dist/tools/conductor-client.d.ts +1 -0
  777. package/dist/tools/conductor-client.d.ts.map +1 -1
  778. package/dist/tools/conductor-client.js +63 -0
  779. package/dist/tools/conductor-client.js.map +1 -1
  780. package/dist/tools/diff.d.ts +1 -0
  781. package/dist/tools/diff.d.ts.map +1 -1
  782. package/dist/tools/edit.d.ts +1 -0
  783. package/dist/tools/edit.d.ts.map +1 -1
  784. package/dist/tools/extract-document.d.ts +1 -0
  785. package/dist/tools/extract-document.d.ts.map +1 -1
  786. package/dist/tools/find.d.ts +10 -0
  787. package/dist/tools/find.d.ts.map +1 -1
  788. package/dist/tools/find.js +236 -27
  789. package/dist/tools/find.js.map +1 -1
  790. package/dist/tools/gh.d.ts +3 -0
  791. package/dist/tools/gh.d.ts.map +1 -1
  792. package/dist/tools/index.d.ts +50 -0
  793. package/dist/tools/index.d.ts.map +1 -1
  794. package/dist/tools/index.js +4 -0
  795. package/dist/tools/index.js.map +1 -1
  796. package/dist/tools/list.d.ts +1 -0
  797. package/dist/tools/list.d.ts.map +1 -1
  798. package/dist/tools/notebook.d.ts +1 -0
  799. package/dist/tools/notebook.d.ts.map +1 -1
  800. package/dist/tools/oracle.d.ts +1 -0
  801. package/dist/tools/oracle.d.ts.map +1 -1
  802. package/dist/tools/oracle.js +17 -32
  803. package/dist/tools/oracle.js.map +1 -1
  804. package/dist/tools/parallel-execution.d.ts +13 -2
  805. package/dist/tools/parallel-execution.d.ts.map +1 -1
  806. package/dist/tools/parallel-execution.js +178 -7
  807. package/dist/tools/parallel-execution.js.map +1 -1
  808. package/dist/tools/parallel-ripgrep.d.ts +1 -0
  809. package/dist/tools/parallel-ripgrep.d.ts.map +1 -1
  810. package/dist/tools/pipeline.d.ts +4 -0
  811. package/dist/tools/pipeline.d.ts.map +1 -1
  812. package/dist/tools/read.d.ts +1 -0
  813. package/dist/tools/read.d.ts.map +1 -1
  814. package/dist/tools/search.d.ts +1 -0
  815. package/dist/tools/search.d.ts.map +1 -1
  816. package/dist/tools/status.d.ts +1 -0
  817. package/dist/tools/status.d.ts.map +1 -1
  818. package/dist/tools/todo.d.ts +1 -0
  819. package/dist/tools/todo.d.ts.map +1 -1
  820. package/dist/tools/tool-dsl.d.ts +5 -1
  821. package/dist/tools/tool-dsl.d.ts.map +1 -1
  822. package/dist/tools/tool-dsl.js +1 -0
  823. package/dist/tools/tool-dsl.js.map +1 -1
  824. package/dist/tools/tool-result-cache.d.ts.map +1 -1
  825. package/dist/tools/tool-result-cache.js +1 -0
  826. package/dist/tools/tool-result-cache.js.map +1 -1
  827. package/dist/tools/typebox-tool.d.ts.map +1 -1
  828. package/dist/tools/typebox-tool.js +3 -0
  829. package/dist/tools/typebox-tool.js.map +1 -1
  830. package/dist/tools/webfetch.d.ts +1 -0
  831. package/dist/tools/webfetch.d.ts.map +1 -1
  832. package/dist/tools/websearch.d.ts +1 -0
  833. package/dist/tools/websearch.d.ts.map +1 -1
  834. package/dist/tools/write.d.ts +1 -0
  835. package/dist/tools/write.d.ts.map +1 -1
  836. package/dist/utils/abort-error.d.ts +2 -0
  837. package/dist/utils/abort-error.d.ts.map +1 -0
  838. package/dist/utils/abort-error.js +7 -0
  839. package/dist/utils/abort-error.js.map +1 -0
  840. package/dist/utils/downstream.d.ts.map +1 -1
  841. package/dist/utils/downstream.js +4 -0
  842. package/dist/utils/downstream.js.map +1 -1
  843. package/dist/utils/logger.d.ts +3 -0
  844. package/dist/utils/logger.d.ts.map +1 -1
  845. package/dist/utils/logger.js +14 -3
  846. package/dist/utils/logger.js.map +1 -1
  847. package/dist/utils/path-containment.d.ts +2 -0
  848. package/dist/utils/path-containment.d.ts.map +1 -0
  849. package/dist/utils/path-containment.js +14 -0
  850. package/dist/utils/path-containment.js.map +1 -0
  851. package/dist/utils/prompt-safe-text.d.ts +7 -0
  852. package/dist/utils/prompt-safe-text.d.ts.map +1 -0
  853. package/dist/utils/prompt-safe-text.js +44 -0
  854. package/dist/utils/prompt-safe-text.js.map +1 -0
  855. package/dist/version.json +2 -2
  856. package/dist/web-server.d.ts.map +1 -1
  857. package/dist/web-server.js +32 -7
  858. package/dist/web-server.js.map +1 -1
  859. package/dist/workspace/root-resolver.d.ts +4 -1
  860. package/dist/workspace/root-resolver.d.ts.map +1 -1
  861. package/dist/workspace/root-resolver.js +16 -6
  862. package/dist/workspace/root-resolver.js.map +1 -1
  863. package/node_modules/@evalops/contracts/dist/advisor-effort.d.ts +8 -0
  864. package/node_modules/@evalops/contracts/dist/advisor-effort.d.ts.map +1 -0
  865. package/node_modules/@evalops/contracts/dist/advisor-effort.js +35 -0
  866. package/node_modules/@evalops/contracts/dist/advisor-effort.js.map +1 -0
  867. package/node_modules/@evalops/contracts/dist/delegation-prompt.d.ts +10 -0
  868. package/node_modules/@evalops/contracts/dist/delegation-prompt.d.ts.map +1 -0
  869. package/node_modules/@evalops/contracts/dist/delegation-prompt.js +48 -0
  870. package/node_modules/@evalops/contracts/dist/delegation-prompt.js.map +1 -0
  871. package/node_modules/@evalops/contracts/dist/guarded-files-settings.d.ts +20 -0
  872. package/node_modules/@evalops/contracts/dist/guarded-files-settings.d.ts.map +1 -0
  873. package/node_modules/@evalops/contracts/dist/guarded-files-settings.js +147 -0
  874. package/node_modules/@evalops/contracts/dist/guarded-files-settings.js.map +1 -0
  875. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.d.ts +2 -0
  876. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.d.ts.map +1 -1
  877. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.js +1 -0
  878. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.js.map +1 -1
  879. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts +280 -5
  880. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts.map +1 -1
  881. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js +36 -1
  882. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js.map +1 -1
  883. package/node_modules/@evalops/contracts/dist/index.d.ts +15 -1
  884. package/node_modules/@evalops/contracts/dist/index.d.ts.map +1 -1
  885. package/node_modules/@evalops/contracts/dist/index.js +6 -0
  886. package/node_modules/@evalops/contracts/dist/index.js.map +1 -1
  887. package/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts +593 -0
  888. package/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts.map +1 -0
  889. package/node_modules/@evalops/contracts/dist/maestro-app-server.js +218 -0
  890. package/node_modules/@evalops/contracts/dist/maestro-app-server.js.map +1 -0
  891. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts +91 -0
  892. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts.map +1 -1
  893. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js +92 -61
  894. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js.map +1 -1
  895. package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts +3 -0
  896. package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts.map +1 -1
  897. package/node_modules/@evalops/contracts/dist/runtime-constraints.d.ts +28 -0
  898. package/node_modules/@evalops/contracts/dist/runtime-constraints.d.ts.map +1 -0
  899. package/node_modules/@evalops/contracts/dist/runtime-constraints.js +71 -0
  900. package/node_modules/@evalops/contracts/dist/runtime-constraints.js.map +1 -0
  901. package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts +7 -0
  902. package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts.map +1 -1
  903. package/node_modules/@evalops/contracts/dist/runtime-server-request.js +2 -0
  904. package/node_modules/@evalops/contracts/dist/runtime-server-request.js.map +1 -1
  905. package/node_modules/@evalops/contracts/dist/scenario.d.ts +191 -0
  906. package/node_modules/@evalops/contracts/dist/scenario.d.ts.map +1 -0
  907. package/node_modules/@evalops/contracts/dist/scenario.js +4 -0
  908. package/node_modules/@evalops/contracts/dist/scenario.js.map +1 -0
  909. package/node_modules/@evalops/contracts/dist/schemas.d.ts +17 -3
  910. package/node_modules/@evalops/contracts/dist/schemas.d.ts.map +1 -1
  911. package/node_modules/@evalops/contracts/dist/schemas.js +16 -0
  912. package/node_modules/@evalops/contracts/dist/schemas.js.map +1 -1
  913. package/node_modules/@evalops/contracts/package.json +1 -1
  914. package/node_modules/@evalops/tui/package.json +1 -1
  915. package/package.json +41 -7
  916. package/skills/incident-triage/SKILL.md +40 -0
  917. package/skills/incident-triage/mcp.json +14 -0
  918. package/skills/incident-triage/reference/triage.md +20 -0
  919. package/skills/incident-triage/toolbox/incident-timeline +22 -0
  920. package/skills/incident-triage/toolbox/incident-timeline.cmd +16 -0
  921. package/skills/pr-review/SKILL.md +40 -0
  922. package/skills/pr-review/mcp.json +14 -0
  923. package/skills/pr-review/reference/rubric.md +20 -0
  924. package/skills/pr-review/toolbox/review-summary +20 -0
  925. package/skills/pr-review/toolbox/review-summary.cmd +14 -0
  926. package/skills/release-verification/SKILL.md +40 -0
  927. package/skills/release-verification/mcp.json +15 -0
  928. package/skills/release-verification/reference/checklist.md +21 -0
  929. package/skills/release-verification/toolbox/release-readiness +18 -0
  930. package/skills/release-verification/toolbox/release-readiness.cmd +12 -0
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-types.d.ts","sourceRoot":"","sources":["../../src/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,GAAG,EAEH,OAAO,EACP,KAAK,EACL,MAAM,mBAAmB,CAAC;AAM3B;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACvD,IAAI,EAAE,QAAQ,CAAC;IACf,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,KAAK,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,OAAO,GAAG,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U,CAgB1E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,WAAW,GACnB,QAAQ,IAAI,gBAAgB,CAE9B"}
@@ -19,6 +19,7 @@ export function isAgentEvent(response) {
19
19
  "tool_execution_update",
20
20
  "tool_execution_end",
21
21
  "tool_batch_summary",
22
+ "tool_phase_summary",
22
23
  "tool_retry_required",
23
24
  "tool_retry_resolved",
24
25
  "error",
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../src/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwKH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAqB;IACjD,OAAO;QACN,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,aAAa;QACb,WAAW;QACX,sBAAsB;QACtB,uBAAuB;QACvB,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,qBAAqB;QACrB,OAAO;KACP,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC9B,QAAqB;IAErB,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC;AAClC,CAAC","sourcesContent":["/**\n * RPC Types for Composer Agent\n *\n * Defines the typed protocol for JSON-over-stdio RPC communication.\n *\n * @module rpc/rpc-types\n */\n\nimport type {\n\tAgentEvent,\n\tApi,\n\tAppMessage,\n\tMessage,\n\tModel,\n} from \"../agent/types.js\";\n\n// ============================================================================\n// RPC Commands (Client -> Server)\n// ============================================================================\n\n/**\n * Base interface for all RPC commands.\n */\nexport interface RpcCommandBase {\n\ttype: string;\n\t/** Optional request ID for response correlation */\n\tid?: string;\n}\n\n/**\n * Send a prompt to the agent.\n */\nexport interface RpcPromptCommand extends RpcCommandBase {\n\ttype: \"prompt\";\n\t/** The message to send */\n\tmessage: string;\n\t/** Optional attachments */\n\tattachments?: Array<{\n\t\tid: string;\n\t\ttype: \"image\" | \"document\";\n\t\tfileName: string;\n\t\tmimeType: string;\n\t\tsize: number;\n\t\tcontent: string;\n\t}>;\n}\n\n/**\n * Abort the current agent operation.\n */\nexport interface RpcAbortCommand extends RpcCommandBase {\n\ttype: \"abort\";\n}\n\n/**\n * Get the current conversation messages.\n */\nexport interface RpcGetMessagesCommand extends RpcCommandBase {\n\ttype: \"get_messages\";\n}\n\n/**\n * Get the full agent state.\n */\nexport interface RpcGetStateCommand extends RpcCommandBase {\n\ttype: \"get_state\";\n}\n\n/**\n * Continue the conversation without a new user message.\n */\nexport interface RpcContinueCommand extends RpcCommandBase {\n\ttype: \"continue\";\n\toptions?: {\n\t\tsystemPromptOverride?: string;\n\t};\n}\n\n/**\n * Trigger context compaction.\n */\nexport interface RpcCompactCommand extends RpcCommandBase {\n\ttype: \"compact\";\n\tcustomInstructions?: string;\n}\n\n/**\n * Union of all RPC commands.\n */\nexport type RpcCommand =\n\t| RpcPromptCommand\n\t| RpcAbortCommand\n\t| RpcGetMessagesCommand\n\t| RpcGetStateCommand\n\t| RpcContinueCommand\n\t| RpcCompactCommand;\n\n// ============================================================================\n// RPC Responses (Server -> Client)\n// ============================================================================\n\n/**\n * Base interface for all RPC responses.\n */\nexport interface RpcResponseBase {\n\ttype: string;\n\t/** Request ID if provided in command */\n\tid?: string;\n}\n\n/**\n * Response containing conversation messages.\n */\nexport interface RpcMessagesResponse extends RpcResponseBase {\n\ttype: \"messages\";\n\tmessages: Message[];\n}\n\n/**\n * Response containing agent state.\n */\nexport interface RpcStateResponse extends RpcResponseBase {\n\ttype: \"state\";\n\tstate: {\n\t\tmodel: Model<Api>;\n\t\tmessages: Message[];\n\t\tisStreaming: boolean;\n\t\terror: string | null;\n\t\tthinkingLevel: number;\n\t\tsession?: { id: string };\n\t\tqueuedMessageCount: number;\n\t};\n}\n\n/**\n * Error response.\n */\nexport interface RpcErrorResponse extends RpcResponseBase {\n\ttype: \"error\";\n\terror: string;\n}\n\n/**\n * Compaction event response.\n */\nexport interface RpcCompactionResponse extends RpcResponseBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tfirstKeptEntryIndex: number;\n\ttokensBefore: number;\n\tauto: boolean;\n\tcustomInstructions?: string;\n\ttimestamp: string;\n}\n\n/**\n * Union of all RPC responses.\n */\nexport type RpcResponse =\n\t| RpcMessagesResponse\n\t| RpcStateResponse\n\t| RpcErrorResponse\n\t| RpcCompactionResponse\n\t| AgentEvent;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\n/**\n * Agent event types that can be received over RPC.\n */\nexport type RpcAgentEventType = AgentEvent[\"type\"];\n\n/**\n * Check if an RPC response is an agent event.\n */\nexport function isAgentEvent(response: RpcResponse): response is AgentEvent {\n\treturn [\n\t\t\"message_start\",\n\t\t\"message_update\",\n\t\t\"message_end\",\n\t\t\"agent_start\",\n\t\t\"agent_end\",\n\t\t\"tool_execution_start\",\n\t\t\"tool_execution_update\",\n\t\t\"tool_execution_end\",\n\t\t\"tool_batch_summary\",\n\t\t\"tool_retry_required\",\n\t\t\"tool_retry_resolved\",\n\t\t\"error\",\n\t].includes(response.type);\n}\n\n/**\n * Check if an RPC response is an error.\n */\nexport function isErrorResponse(\n\tresponse: RpcResponse,\n): response is RpcErrorResponse {\n\treturn response.type === \"error\";\n}\n"]}
1
+ {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../src/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwKH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAqB;IACjD,OAAO;QACN,eAAe;QACf,gBAAgB;QAChB,aAAa;QACb,aAAa;QACb,WAAW;QACX,sBAAsB;QACtB,uBAAuB;QACvB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,qBAAqB;QACrB,OAAO;KACP,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC9B,QAAqB;IAErB,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC;AAClC,CAAC","sourcesContent":["/**\n * RPC Types for Composer Agent\n *\n * Defines the typed protocol for JSON-over-stdio RPC communication.\n *\n * @module rpc/rpc-types\n */\n\nimport type {\n\tAgentEvent,\n\tApi,\n\tAppMessage,\n\tMessage,\n\tModel,\n} from \"../agent/types.js\";\n\n// ============================================================================\n// RPC Commands (Client -> Server)\n// ============================================================================\n\n/**\n * Base interface for all RPC commands.\n */\nexport interface RpcCommandBase {\n\ttype: string;\n\t/** Optional request ID for response correlation */\n\tid?: string;\n}\n\n/**\n * Send a prompt to the agent.\n */\nexport interface RpcPromptCommand extends RpcCommandBase {\n\ttype: \"prompt\";\n\t/** The message to send */\n\tmessage: string;\n\t/** Optional attachments */\n\tattachments?: Array<{\n\t\tid: string;\n\t\ttype: \"image\" | \"document\";\n\t\tfileName: string;\n\t\tmimeType: string;\n\t\tsize: number;\n\t\tcontent: string;\n\t}>;\n}\n\n/**\n * Abort the current agent operation.\n */\nexport interface RpcAbortCommand extends RpcCommandBase {\n\ttype: \"abort\";\n}\n\n/**\n * Get the current conversation messages.\n */\nexport interface RpcGetMessagesCommand extends RpcCommandBase {\n\ttype: \"get_messages\";\n}\n\n/**\n * Get the full agent state.\n */\nexport interface RpcGetStateCommand extends RpcCommandBase {\n\ttype: \"get_state\";\n}\n\n/**\n * Continue the conversation without a new user message.\n */\nexport interface RpcContinueCommand extends RpcCommandBase {\n\ttype: \"continue\";\n\toptions?: {\n\t\tsystemPromptOverride?: string;\n\t};\n}\n\n/**\n * Trigger context compaction.\n */\nexport interface RpcCompactCommand extends RpcCommandBase {\n\ttype: \"compact\";\n\tcustomInstructions?: string;\n}\n\n/**\n * Union of all RPC commands.\n */\nexport type RpcCommand =\n\t| RpcPromptCommand\n\t| RpcAbortCommand\n\t| RpcGetMessagesCommand\n\t| RpcGetStateCommand\n\t| RpcContinueCommand\n\t| RpcCompactCommand;\n\n// ============================================================================\n// RPC Responses (Server -> Client)\n// ============================================================================\n\n/**\n * Base interface for all RPC responses.\n */\nexport interface RpcResponseBase {\n\ttype: string;\n\t/** Request ID if provided in command */\n\tid?: string;\n}\n\n/**\n * Response containing conversation messages.\n */\nexport interface RpcMessagesResponse extends RpcResponseBase {\n\ttype: \"messages\";\n\tmessages: Message[];\n}\n\n/**\n * Response containing agent state.\n */\nexport interface RpcStateResponse extends RpcResponseBase {\n\ttype: \"state\";\n\tstate: {\n\t\tmodel: Model<Api>;\n\t\tmessages: Message[];\n\t\tisStreaming: boolean;\n\t\terror: string | null;\n\t\tthinkingLevel: number;\n\t\tsession?: { id: string };\n\t\tqueuedMessageCount: number;\n\t};\n}\n\n/**\n * Error response.\n */\nexport interface RpcErrorResponse extends RpcResponseBase {\n\ttype: \"error\";\n\terror: string;\n}\n\n/**\n * Compaction event response.\n */\nexport interface RpcCompactionResponse extends RpcResponseBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\tfirstKeptEntryIndex: number;\n\ttokensBefore: number;\n\tauto: boolean;\n\tcustomInstructions?: string;\n\ttimestamp: string;\n}\n\n/**\n * Union of all RPC responses.\n */\nexport type RpcResponse =\n\t| RpcMessagesResponse\n\t| RpcStateResponse\n\t| RpcErrorResponse\n\t| RpcCompactionResponse\n\t| AgentEvent;\n\n// ============================================================================\n// Utility Types\n// ============================================================================\n\n/**\n * Agent event types that can be received over RPC.\n */\nexport type RpcAgentEventType = AgentEvent[\"type\"];\n\n/**\n * Check if an RPC response is an agent event.\n */\nexport function isAgentEvent(response: RpcResponse): response is AgentEvent {\n\treturn [\n\t\t\"message_start\",\n\t\t\"message_update\",\n\t\t\"message_end\",\n\t\t\"agent_start\",\n\t\t\"agent_end\",\n\t\t\"tool_execution_start\",\n\t\t\"tool_execution_update\",\n\t\t\"tool_execution_end\",\n\t\t\"tool_batch_summary\",\n\t\t\"tool_phase_summary\",\n\t\t\"tool_retry_required\",\n\t\t\"tool_retry_resolved\",\n\t\t\"error\",\n\t].includes(response.type);\n}\n\n/**\n * Check if an RPC response is an error.\n */\nexport function isErrorResponse(\n\tresponse: RpcResponse,\n): response is RpcErrorResponse {\n\treturn response.type === \"error\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"action-firewall.d.ts","sourceRoot":"","sources":["../../src/safety/action-firewall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EACX,qBAAqB,EACrB,qBAAqB,EAErB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAczE,OAAO,EACN,KAAK,qCAAqC,EAG1C,MAAM,gCAAgC,CAAC;AAMxC,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,qBAAqB,CAAC;AA+C/E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,MAAM,CAAC,EAAE,OAAO,GAAG,kBAAkB,GAAG,OAAO,CAAC;IAChD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,CACV,OAAO,EAAE,qBAAqB,KAC1B,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,kCAAkC;IAClC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3E,gEAAgE;IAChE,KAAK,CAAC,EAAE,CAAC,OAA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AE,aAAa;IAI/B,QAAQ,CACb,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAqFnB,6BAA6B;CAoC3C;AAED,eAAO,MAAM,qBAAqB,gBAAuB,CAAC"}
@@ -46,10 +46,12 @@
46
46
  *
47
47
  * @module safety/action-firewall
48
48
  */
49
+ import { parseApplyPatchPaths } from "../tools/apply-patch-parser.js";
49
50
  import { createLogger } from "../utils/logger.js";
50
51
  import { isCommandAllowlisted } from "./bash-allowlist.js";
51
52
  import { analyzeCommandSafety, dangerousPatternDescriptions, dangerousPatterns, hasEgressPrimitives, isDestructiveSimpleCommand, isParserAvailable, isSimpleBenignBash, tokenizeSimple, unwrapShellCommand, } from "./bash-safety-analyzer.js";
52
53
  import { evaluateActionWithActionFirewallGovernanceService, resolveActionFirewallGovernanceServiceConfig, } from "./governance-service-client.js";
54
+ import { DEFAULT_GUARDED_FILE_RULE_ID, describeDefaultGuardedFileMatch, findGuardedToolCallMatch, } from "./guarded-files.js";
53
55
  import { isContainedInWorkspace, isSystemPath } from "./path-containment.js";
54
56
  import { checkPolicy } from "./policy.js";
55
57
  import { RuleCache } from "./rule-cache.js";
@@ -279,21 +281,28 @@ function extractFilePaths(context) {
279
281
  if (!args)
280
282
  return [];
281
283
  const paths = [];
284
+ const toolName = context.toolName.toLowerCase();
282
285
  // Simple extraction for standard file tools
283
286
  // Note: deeper extraction is done in policy.ts, this is for quick system protection
284
- if (context.toolName === "write" || context.toolName === "edit") {
287
+ if (toolName === "write" || toolName === "edit") {
285
288
  const p = getStringArg(context, "file_path") || getStringArg(context, "path");
286
289
  if (p)
287
290
  paths.push(p);
288
291
  }
289
- if (context.toolName === "delete_file") {
292
+ if (toolName === "apply_patch") {
293
+ const patch = getStringArg(context, "patch");
294
+ if (patch) {
295
+ paths.push(...parseApplyPatchPaths(patch));
296
+ }
297
+ }
298
+ if (toolName === "delete_file") {
290
299
  const p = getStringArg(context, "file_path") ||
291
300
  getStringArg(context, "target_file");
292
301
  if (p)
293
302
  paths.push(p);
294
303
  }
295
304
  // Handle move_file and copy_file - extract both source and destination
296
- if (context.toolName === "move_file" || context.toolName === "copy_file") {
305
+ if (toolName === "move_file" || toolName === "copy_file") {
297
306
  const source = getStringArg(context, "source") ||
298
307
  getStringArg(context, "source_path") ||
299
308
  getStringArg(context, "from");
@@ -371,7 +380,14 @@ export const defaultFirewallRules = [
371
380
  action: "block", // HARD BLOCK for system paths
372
381
  evaluate: (ctx) => {
373
382
  // Only check file mutation tools
374
- if (!["write", "edit", "delete_file", "move_file", "copy_file"].includes(ctx.toolName)) {
383
+ if (![
384
+ "write",
385
+ "edit",
386
+ "apply_patch",
387
+ "delete_file",
388
+ "move_file",
389
+ "copy_file",
390
+ ].includes(ctx.toolName)) {
375
391
  return { allowed: true };
376
392
  }
377
393
  const paths = extractFilePaths(ctx);
@@ -390,13 +406,55 @@ export const defaultFirewallRules = [
390
406
  },
391
407
  remediation: () => "Do not modify critical system paths. If you need to write a file, use the current workspace directory or a temporary folder.",
392
408
  },
409
+ {
410
+ id: DEFAULT_GUARDED_FILE_RULE_ID,
411
+ description: "Block guarded user and editor configuration files when policy requires a hard block",
412
+ action: "block",
413
+ evaluate: (ctx) => {
414
+ const match = findGuardedToolCallMatch(ctx.toolName, ctx.args, {
415
+ policy: ctx.metadata?.guardedFiles,
416
+ });
417
+ if (match?.defaultBehavior === "block") {
418
+ return {
419
+ allowed: false,
420
+ reason: describeDefaultGuardedFileMatch(match),
421
+ remediation: "Remove the matching custom guard or change its defaultBehavior to ask if this access should be approval-gated instead of blocked.",
422
+ };
423
+ }
424
+ return { allowed: true };
425
+ },
426
+ },
427
+ {
428
+ id: DEFAULT_GUARDED_FILE_RULE_ID,
429
+ description: "Require explicit approval before reading or mutating guarded user and editor configuration files",
430
+ action: "require_approval",
431
+ evaluate: (ctx) => {
432
+ const match = findGuardedToolCallMatch(ctx.toolName, ctx.args, {
433
+ policy: ctx.metadata?.guardedFiles,
434
+ });
435
+ if (match) {
436
+ return {
437
+ allowed: false,
438
+ reason: describeDefaultGuardedFileMatch(match),
439
+ };
440
+ }
441
+ return { allowed: true };
442
+ },
443
+ },
393
444
  {
394
445
  name: "workspace-containment",
395
446
  description: "Require approval for file modifications outside the workspace",
396
447
  action: "require_approval",
397
448
  evaluate: (ctx) => {
398
449
  // Only check file mutation tools
399
- if (!["write", "edit", "delete_file", "move_file", "copy_file"].includes(ctx.toolName)) {
450
+ if (![
451
+ "write",
452
+ "edit",
453
+ "apply_patch",
454
+ "delete_file",
455
+ "move_file",
456
+ "copy_file",
457
+ ].includes(ctx.toolName)) {
400
458
  return { allowed: true };
401
459
  }
402
460
  const paths = extractFilePaths(ctx);
@@ -455,8 +513,12 @@ export const defaultFirewallRules = [
455
513
  if (process.env.MAESTRO_PLAN_MODE !== "1")
456
514
  return false;
457
515
  const name = ctx.toolName;
458
- if (name === "write" || name === "edit" || name === "bash")
516
+ if (name === "write" ||
517
+ name === "edit" ||
518
+ name === "apply_patch" ||
519
+ name === "bash") {
459
520
  return true;
521
+ }
460
522
  if (name === "todo")
461
523
  return true;
462
524
  if (name === "gh_pr") {
@@ -589,6 +651,7 @@ export class ActionFirewall {
589
651
  "bash",
590
652
  "write",
591
653
  "edit",
654
+ "apply_patch",
592
655
  "delete_file",
593
656
  "background_tasks",
594
657
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"action-firewall.js","sourceRoot":"","sources":["../../src/safety/action-firewall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GAClB,MAAM,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,EACzF;gBACC,KAAK,EAAE,OAAO;gBACd,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC1B,CACD,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["/**\n * Action Firewall - Rule-based safety enforcement for tool execution\n *\n * The action firewall is the central decision point for tool safety. Before\n * any tool executes, it passes through the firewall which evaluates a series\n * of rules and returns a verdict: allow, require_approval, or block.\n *\n * ## Architecture\n *\n * ```\n * Tool Call → ActionFirewall.evaluate() → Rules (sequential) → Verdict\n * ↓ ↓\n * Context Object Match + Reason + Remediation\n * ```\n *\n * ## Verdict Types\n *\n * - **allow**: Tool executes immediately without user interaction\n * - **require_approval**: User must explicitly approve before execution\n * - **block**: Tool is prevented from executing entirely (hard block)\n *\n * ## Rule Evaluation Order\n *\n * Rules are evaluated sequentially in priority order. The first matching\n * rule determines the verdict. This means:\n *\n * 1. Enterprise policy rules (hard blocks) come first\n * 2. System path protection (hard blocks) second\n * 3. Workspace containment (soft approval) third\n * 4. Dangerous command patterns (soft approval) later\n *\n * ## Caching Strategy\n *\n * Policy checks and tree-sitter analysis can be expensive. We use WeakMaps\n * keyed by the context object to cache results within a single evaluation.\n * The WeakMap ensures entries are garbage collected when the context is\n * no longer referenced.\n *\n * ## Integration Points\n *\n * The firewall integrates with:\n * - **Enterprise Policy**: Organizational restrictions on tools/paths\n * - **Workflow State**: PII tracking for egress prevention\n * - **Bash Parser**: Structured command analysis\n * - **Semantic Judge**: LLM-based intent analysis (optional, slow path)\n *\n * @module safety/action-firewall\n */\n\nimport type {\n\tActionApprovalContext,\n\tActionFirewallVerdict,\n\tWorkflowStateSnapshot,\n} from \"../agent/action-approval.js\";\nexport type { ActionApprovalContext } from \"../agent/action-approval.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport { isCommandAllowlisted } from \"./bash-allowlist.js\";\nimport {\n\tanalyzeCommandSafety,\n\tdangerousPatternDescriptions,\n\tdangerousPatterns,\n\thasEgressPrimitives,\n\tisDestructiveSimpleCommand,\n\tisParserAvailable,\n\tisSimpleBenignBash,\n\ttokenizeSimple,\n\tunwrapShellCommand,\n} from \"./bash-safety-analyzer.js\";\nimport {\n\ttype ActionFirewallGovernanceServiceConfig,\n\tevaluateActionWithActionFirewallGovernanceService,\n\tresolveActionFirewallGovernanceServiceConfig,\n} from \"./governance-service-client.js\";\nimport { isContainedInWorkspace, isSystemPath } from \"./path-containment.js\";\nimport { checkPolicy } from \"./policy.js\";\nimport { RuleCache } from \"./rule-cache.js\";\nimport { TOOL_TAGS, looksLikeEgress } from \"./workflow-state.js\";\n\nimport type { SemanticJudge, SemanticJudgeContext } from \"./semantic-judge.js\";\n\nconst logger = createLogger(\"safety:action-firewall\");\n// Evaluate env flags lazily to honor profile overrides set after initial import.\nconst isStrictUntaggedEgress = () =>\n\tprocess.env.MAESTRO_FAIL_UNTAGGED_EGRESS === \"1\";\nconst isBackgroundShellBlocked = () =>\n\tprocess.env.MAESTRO_BACKGROUND_SHELL_DISABLE === \"1\";\nconst isSafeModeEnabled = () => process.env.MAESTRO_SAFE_MODE === \"1\";\nconst isProdProfile = () =>\n\tprocess.env.MAESTRO_PROFILE === \"prod\" ||\n\tprocess.env.MAESTRO_WEB_PROFILE === \"prod\";\nconst isNoEgressShellEnabled = () =>\n\t[\"1\", \"true\", \"on\"].includes(\n\t\t(process.env.MAESTRO_NO_EGRESS_SHELL ?? \"\").toLowerCase(),\n\t);\nconst isEgressOverrideAllowed = () =>\n\t[\"1\", \"true\", \"on\"].includes(\n\t\t(process.env.MAESTRO_ALLOW_EGRESS_SHELL ?? \"\").toLowerCase(),\n\t);\n\n/**\n * Policy Check Result - Cached result of enterprise policy evaluation\n */\ninterface PolicyCheckResult {\n\tallowed: boolean;\n\treason?: string;\n}\n\n/**\n * Policy Check Cache - Avoids redundant policy evaluations\n *\n * The firewall evaluation flow calls match() to check if a rule applies,\n * then reason() to get the human-readable explanation. For policy checks,\n * both need the same expensive async evaluation.\n *\n * We cache the result on match() and reuse it in reason(). The WeakMap\n * key is the context object itself, ensuring:\n * 1. Each context gets its own cached result\n * 2. Cache entries are automatically garbage collected when context is freed\n * 3. No memory leaks from long-running processes\n */\nconst policyCheckCache = new RuleCache<\n\tActionApprovalContext,\n\tPolicyCheckResult\n>();\n\n/**\n * Action Firewall Rule Interface\n *\n * Defines the structure of a firewall rule. Rules are the building blocks\n * of the firewall; each rule checks for a specific condition and returns\n * a verdict if matched.\n *\n * ## Rule Anatomy\n *\n * - **id**: Unique identifier for logging and debugging\n * - **description**: Human-readable explanation of what the rule checks\n * - **action**: What happens if rule matches (default: require_approval)\n * - **match()**: Predicate that returns true if rule applies\n * - **reason()**: Optional function returning why rule matched\n * - **remediation()**: Optional function suggesting how to fix the issue\n *\n * ## Match Evaluation\n *\n * The match function receives the full tool context including:\n * - toolName: Name of the tool being called\n * - args: Arguments passed to the tool\n * - metadata: Additional context (workflow state, annotations)\n * - user/session: Authentication context\n *\n * Rules can be sync or async. Async rules are awaited during evaluation.\n */\ntype RuleOutcome = { allowed: boolean; reason?: string; remediation?: string };\n\nexport interface ActionFirewallRule {\n\t/** Optional legacy identifier used in existing logs/tests */\n\tid?: string;\n\t/** Optional name for logging */\n\tname?: string;\n\t/** Human-readable description */\n\tdescription: string;\n\t/** Verdict override */\n\taction?: \"allow\" | \"require_approval\" | \"block\";\n\t/** Modern evaluation hook (preferred) */\n\tevaluate?: (\n\t\tcontext: ActionApprovalContext,\n\t) => RuleOutcome | Promise<RuleOutcome>;\n\t/** Optional remediation helper */\n\tremediation?: (context: ActionApprovalContext) => string | Promise<string>;\n\t/** Legacy match/reason hooks kept for backward compatibility */\n\tmatch?: (context: ActionApprovalContext) => boolean | Promise<boolean>;\n\treason?: (context: ActionApprovalContext) => string | Promise<string>;\n}\n\nconst untaggedEgressWarnings = new Set<string>();\nexport const HUMAN_EGRESS_PII_RULE_ID = \"pii-redaction-before-human-egress\";\n\nfunction getArgsObject(\n\tcontext: ActionApprovalContext,\n): Record<string, unknown> | null {\n\treturn context.args && typeof context.args === \"object\"\n\t\t? (context.args as Record<string, unknown>)\n\t\t: null;\n}\n\nfunction getStringArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): string | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"string\" ? value : null;\n}\n\nfunction getBooleanArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): boolean | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"boolean\" ? value : null;\n}\n\nfunction getCommandArg(context: ActionApprovalContext): string | null {\n\treturn getStringArg(context, \"command\");\n}\n\nfunction isBackgroundTaskShellStart(context: ActionApprovalContext): boolean {\n\tif (context.toolName !== \"background_tasks\") {\n\t\treturn false;\n\t}\n\tconst action = getStringArg(context, \"action\");\n\tif (action !== \"start\") {\n\t\treturn false;\n\t}\n\treturn getBooleanArg(context, \"shell\") === true;\n}\n\nfunction getWorkflowState(\n\tcontext: ActionApprovalContext,\n): WorkflowStateSnapshot | null {\n\treturn context.metadata?.workflowState ?? null;\n}\n\nfunction getPendingUnredactedPii(\n\tcontext: ActionApprovalContext,\n): WorkflowStateSnapshot[\"pendingPii\"] {\n\tconst snapshot = getWorkflowState(context);\n\tif (!snapshot) {\n\t\treturn [];\n\t}\n\treturn snapshot.pendingPii.filter((artifact) => artifact.redacted !== true);\n}\n\nfunction warnUntaggedEgress(toolName: string): void {\n\tif (untaggedEgressWarnings.has(toolName)) {\n\t\treturn;\n\t}\n\tuntaggedEgressWarnings.add(toolName);\n\tlogger.warn(\n\t\t\"Untagged egress-like tool encountered; treating as human-facing until TOOL_TAGS is updated\",\n\t\t{ toolName },\n\t);\n}\n\nfunction isHumanFacingTool(toolName: string): boolean {\n\tconst toolTags = TOOL_TAGS[toolName];\n\tif (toolTags?.egress === \"human\") {\n\t\treturn true;\n\t}\n\tif (!toolTags && looksLikeEgress(toolName)) {\n\t\twarnUntaggedEgress(toolName);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getAnnotations(context: ActionApprovalContext) {\n\treturn context.metadata?.annotations;\n}\n\nfunction isMcpTool(toolName: string): boolean {\n\treturn toolName.startsWith(\"mcp_\");\n}\n\n/**\n * Generate rules from dangerous patterns (regex-based)\n */\nconst dangerousCommandRules: ActionFirewallRule[] = Object.entries(\n\tdangerousPatterns,\n).map(([key, pattern]) => ({\n\tname: `command-${key}`,\n\tdescription:\n\t\tdangerousPatternDescriptions[\n\t\t\tkey as keyof typeof dangerousPatternDescriptions\n\t\t],\n\taction: \"require_approval\",\n\tevaluate: (ctx) => {\n\t\tif (!isBashGuardEnabled()) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tconst command = getCommandArg(ctx);\n\t\tif (!command) return { allowed: true };\n\t\tconst unwrapped = unwrapShellCommand(command) ?? command;\n\t\tif (isCommandAllowlisted(unwrapped)) return { allowed: true };\n\t\tif (!pattern.test(unwrapped)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: `Detected ${dangerousPatternDescriptions[key as keyof typeof dangerousPatternDescriptions]}: ${unwrapped.trim()}`,\n\t\t};\n\t},\n}));\n\nconst isBashStrict = () => process.env.MAESTRO_BASH_STRICT === \"1\";\nconst isBashGuardEnabled = () => {\n\tconst flag = process.env.MAESTRO_BASH_GUARD?.toLowerCase?.();\n\tif (flag) {\n\t\treturn ![\"0\", \"off\", \"false\", \"disabled\", \"no\"].includes(flag);\n\t}\n\t// Default: guard ON (previous behavior). Explicitly set MAESTRO_BASH_GUARD=0 to YOLO.\n\tif (isSafeModeEnabled() || isProdProfile()) {\n\t\treturn true;\n\t}\n\treturn true;\n};\n\n/**\n * Tree-sitter based command safety rule.\n * Provides more accurate analysis than regex patterns.\n */\nconst treeSitterCommandRule: ActionFirewallRule = {\n\tname: \"command-treesitter-analysis\",\n\tdescription: \"Tree-sitter based command safety analysis\",\n\taction: \"require_approval\",\n\tevaluate: (ctx) => {\n\t\tif (!isBashGuardEnabled()) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tif (ctx.toolName !== \"bash\" && !isBackgroundTaskShellStart(ctx)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tlet command = getCommandArg(ctx);\n\t\tif (!command) return { allowed: true };\n\n\t\t// Try to unwrap bash -c \"...\" style commands\n\t\tconst unwrapped = unwrapShellCommand(command);\n\t\tif (unwrapped) {\n\t\t\tcommand = unwrapped;\n\t\t}\n\n\t\tif (isCommandAllowlisted(command)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\tconst simpleTokens = tokenizeSimple(command);\n\t\tif (isDestructiveSimpleCommand(simpleTokens)) {\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Command requires approval (destructive or mutating operation detected)\",\n\t\t\t};\n\t\t}\n\n\t\tif (!isBashStrict() && isSimpleBenignBash(command)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\t// Only run tree-sitter if the parser is available; otherwise fall back to approval\n\t\tif (!isParserAvailable()) {\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Command requires approval (bash parser unavailable; unable to fully analyze)\",\n\t\t\t};\n\t\t}\n\n\t\tconst analysis = analyzeCommandSafety(command);\n\t\tif (analysis.safe) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: analysis.reason ?? \"Command failed tree-sitter safety analysis\",\n\t\t};\n\t},\n};\n\n/**\n * Critical System Paths - Directories that should never be modified\n *\n * These paths are protected with a HARD BLOCK (not just approval required).\n * Modifying files in these directories can:\n * - Break the operating system\n * - Compromise system security\n * - Affect other users on the system\n *\n * ## Linux Paths\n *\n * - /etc: System configuration\n * - /usr: System programs and libraries\n * - /var: Variable data (logs, databases)\n * - /boot: Bootloader and kernel\n * - /sys, /proc: Kernel virtual filesystems\n * - /dev: Device files\n * - /bin, /sbin: Essential system binaries\n * - /lib, /lib64: Shared libraries\n * - /opt: Optional/third-party software\n *\n * ## macOS Paths\n *\n * - /System: System files\n * - /Library: System libraries\n * - /private/etc, /private/var: Private system configuration/data\n * - /dev: Device files\n *\n * ## Windows Paths\n *\n * - C:\\Windows: Operating system\n * - C:\\Program Files: Installed applications\n *\n * Note: /var/folders (macOS temp) and /tmp are explicitly allowed\n * through the isContainedInWorkspace check before system path blocking.\n */\nfunction extractFilePaths(context: ActionApprovalContext): string[] {\n\tconst args = getArgsObject(context);\n\tif (!args) return [];\n\tconst paths: string[] = [];\n\n\t// Simple extraction for standard file tools\n\t// Note: deeper extraction is done in policy.ts, this is for quick system protection\n\tif (context.toolName === \"write\" || context.toolName === \"edit\") {\n\t\tconst p =\n\t\t\tgetStringArg(context, \"file_path\") || getStringArg(context, \"path\");\n\t\tif (p) paths.push(p);\n\t}\n\tif (context.toolName === \"delete_file\") {\n\t\tconst p =\n\t\t\tgetStringArg(context, \"file_path\") ||\n\t\t\tgetStringArg(context, \"target_file\");\n\t\tif (p) paths.push(p);\n\t}\n\t// Handle move_file and copy_file - extract both source and destination\n\tif (context.toolName === \"move_file\" || context.toolName === \"copy_file\") {\n\t\tconst source =\n\t\t\tgetStringArg(context, \"source\") ||\n\t\t\tgetStringArg(context, \"source_path\") ||\n\t\t\tgetStringArg(context, \"from\");\n\t\tconst dest =\n\t\t\tgetStringArg(context, \"destination\") ||\n\t\t\tgetStringArg(context, \"destination_path\") ||\n\t\t\tgetStringArg(context, \"dest\") ||\n\t\t\tgetStringArg(context, \"to\");\n\t\tif (source) paths.push(source);\n\t\tif (dest) paths.push(dest);\n\t}\n\treturn paths;\n}\n\n/**\n * Workspace Containment Check - Determines if a path is in a \"safe zone\"\n *\n * The firewall uses containment to prevent accidental writes outside the\n * project directory. This function checks if a file path is within one of\n * the allowed zones.\n *\n * ## Safe Zones (in order of check)\n *\n * 1. **Workspace root**: Current working directory and subdirectories\n * 2. **System temp directory**: /tmp, /var/folders, etc.\n * 3. **Trusted paths**: User-configured paths in firewall.json\n *\n * ## Path Resolution Complexity\n *\n * We must handle several path edge cases:\n *\n * - **Symlinks**: macOS /tmp → /private/tmp, so we resolve real paths\n * - **Non-existent files**: Can't realpath a file being created, use logical path\n * - **Relative paths**: Convert to absolute before comparison\n * - **Path traversal**: Detect ../ escapes using relative() output\n *\n * ## Detection Method\n *\n * For each safe zone, we compute relative(zone, targetPath). If the result:\n * - Starts with \"..\" → path escapes the zone (unsafe)\n * - Is an absolute path → completely outside (unsafe)\n * - Otherwise → contained within zone (safe)\n *\n * @param filePath - The path to check (may be relative or absolute)\n * @returns true if path is contained in a safe zone, false otherwise\n */\n\nexport const defaultFirewallRules: ActionFirewallRule[] = [\n\t{\n\t\tname: \"enterprise-policy\",\n\t\tdescription: \"Enforce enterprise policies on tools and dependencies\",\n\t\taction: \"block\", // HARD BLOCK for policy violations\n\t\tevaluate: async (ctx) => {\n\t\t\tconst cached = policyCheckCache.get(ctx);\n\t\t\tif (cached) {\n\t\t\t\treturn cached.allowed\n\t\t\t\t\t? { allowed: true }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\t\treason: cached.reason ?? \"Action blocked by enterprise policy\",\n\t\t\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await checkPolicy(ctx);\n\t\t\tpolicyCheckCache.set(ctx, result);\n\t\t\tif (result.allowed) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason: result.reason ?? \"Action blocked by enterprise policy\",\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\tname: \"system-path-protection\",\n\t\tdescription: \"Prevent modification of critical system directories\",\n\t\taction: \"block\", // HARD BLOCK for system paths\n\t\tevaluate: (ctx) => {\n\t\t\t// Only check file mutation tools\n\t\t\tif (\n\t\t\t\t![\"write\", \"edit\", \"delete_file\", \"move_file\", \"copy_file\"].includes(\n\t\t\t\t\tctx.toolName,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst paths = extractFilePaths(ctx);\n\t\t\t// We check system paths first, but if it's in workspace, temp, or a trusted path (safe), we should allow it.\n\t\t\t// System paths like /var include /var/folders (temp on mac), so we need to exclude safe temp paths from system path blocking.\n\n\t\t\t// Filter out paths that are inside the workspace, temp, or trusted paths (which are safe)\n\t\t\tconst unsafePaths = paths.filter((p) => !isContainedInWorkspace(p));\n\n\t\t\t// Only check remaining paths against system blocklist\n\t\t\tif (unsafePaths.some(isSystemPath)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason:\n\t\t\t\t\t\t\"Modification of critical system directories is blocked for safety.\",\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allowed: true };\n\t\t},\n\t\tremediation: () =>\n\t\t\t\"Do not modify critical system paths. If you need to write a file, use the current workspace directory or a temporary folder.\",\n\t},\n\t{\n\t\tname: \"workspace-containment\",\n\t\tdescription:\n\t\t\t\"Require approval for file modifications outside the workspace\",\n\t\taction: \"require_approval\",\n\t\tevaluate: (ctx) => {\n\t\t\t// Only check file mutation tools\n\t\t\tif (\n\t\t\t\t![\"write\", \"edit\", \"delete_file\", \"move_file\", \"copy_file\"].includes(\n\t\t\t\t\tctx.toolName,\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst paths = extractFilePaths(ctx);\n\t\t\t// Return true (match rule) if ANY path is NOT contained\n\t\t\tconst outsidePaths = paths.filter((p) => !isContainedInWorkspace(p));\n\t\t\tif (outsidePaths.length === 0) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason: `File modification outside workspace detected: ${outsidePaths.join(\", \")}. This requires explicit approval.`,\n\t\t\t};\n\t\t},\n\t\tremediation: () =>\n\t\t\t\"The file path is outside the allowed workspace. Please use a path within the current project or a temporary directory, or ask the user to add this path to 'containment.trustedPaths' in ~/.maestro/firewall.json.\",\n\t},\n\t{\n\t\tid: \"untagged-human-egress\",\n\t\tdescription:\n\t\t\t\"Block human-facing tool calls without explicit TOOL_TAGS annotations when strict mode is enabled\",\n\t\taction: \"block\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isStrictUntaggedEgress()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!isHumanFacingTool(ctx.toolName)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn TOOL_TAGS[ctx.toolName] === undefined;\n\t\t},\n\t\treason: () =>\n\t\t\t\"Human-facing tool is missing TOOL_TAGS; annotate the tool or disable strict mode via MAESTRO_FAIL_UNTAGGED_EGRESS=0.\",\n\t\tremediation: () =>\n\t\t\t\"Add TOOL_TAGS entry marking egress intent (human/http) before invoking the tool.\",\n\t},\n\t{\n\t\tid: \"background-shell-block\",\n\t\tdescription: \"Block shell-based background tasks when disabled by policy\",\n\t\taction: \"block\",\n\t\tmatch: (ctx) =>\n\t\t\tisBackgroundShellBlocked() && isBackgroundTaskShellStart(ctx) === true,\n\t\treason: () =>\n\t\t\t\"Starting background_tasks with shell=true is disabled by policy. Set MAESTRO_BACKGROUND_SHELL_DISABLE=0 to allow.\",\n\t},\n\t{\n\t\tid: \"mcp-destructive-tool\",\n\t\tdescription: \"MCP tools marked as destructive require approval\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isMcpTool(ctx.toolName)) return false;\n\t\t\tconst annotations = getAnnotations(ctx);\n\t\t\t// Require approval if destructiveHint is true and readOnlyHint is not true\n\t\t\treturn (\n\t\t\t\tannotations?.destructiveHint === true && !annotations?.readOnlyHint\n\t\t\t);\n\t\t},\n\t\treason: (ctx) =>\n\t\t\t`MCP tool \"${ctx.toolName}\" is marked as destructive and requires approval`,\n\t},\n\t{\n\t\tid: \"plan-mode-confirm\",\n\t\tdescription:\n\t\t\t\"When plan mode is enabled, require approval before mutating commands\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (process.env.MAESTRO_PLAN_MODE !== \"1\") return false;\n\t\t\tconst name = ctx.toolName;\n\t\t\tif (name === \"write\" || name === \"edit\" || name === \"bash\") return true;\n\t\t\tif (name === \"todo\") return true;\n\t\t\tif (name === \"gh_pr\") {\n\t\t\t\tconst action = getStringArg(ctx, \"action\");\n\t\t\t\treturn !action || ![\"list\", \"view\", \"checks\", \"diff\"].includes(action);\n\t\t\t}\n\t\t\tif (name === \"gh_issue\") {\n\t\t\t\tconst action = getStringArg(ctx, \"action\");\n\t\t\t\treturn !action || ![\"list\", \"view\"].includes(action);\n\t\t\t}\n\t\t\tif (name === \"background_tasks\") {\n\t\t\t\tconst args = getArgsObject(ctx);\n\t\t\t\tconst action = args?.action;\n\t\t\t\tconst shell = args?.shell === true;\n\t\t\t\treturn action === \"start\" && shell;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\treason: (ctx) =>\n\t\t\t`Plan mode requires confirmation before executing ${ctx.toolName}. Toggle with /plan-mode or MAESTRO_PLAN_MODE=0.`,\n\t},\n\t{\n\t\tid: \"no-egress-shell\",\n\t\tdescription:\n\t\t\t\"Require approval when shell egress is disabled via MAESTRO_NO_EGRESS_SHELL\",\n\t\taction: \"require_approval\",\n\t\tevaluate: (ctx) => {\n\t\t\tif (!isNoEgressShellEnabled() || isEgressOverrideAllowed()) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tif (ctx.toolName !== \"bash\" && !isBackgroundTaskShellStart(ctx)) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst raw = getCommandArg(ctx);\n\t\t\tif (!raw) return { allowed: true };\n\t\t\tconst unwrapped = unwrapShellCommand(raw) ?? raw;\n\t\t\tif (isCommandAllowlisted(unwrapped)) return { allowed: true };\n\t\t\tif (!hasEgressPrimitives(unwrapped)) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Shell egress (curl/wget/ssh/nc/dev/tcp) requires approval because MAESTRO_NO_EGRESS_SHELL=1. Allow temporarily with MAESTRO_ALLOW_EGRESS_SHELL=1 or add a bash allowlist entry.\",\n\t\t\t};\n\t\t},\n\t},\n\t...dangerousCommandRules,\n\ttreeSitterCommandRule,\n\t{\n\t\tid: \"background-shell-mode\",\n\t\tdescription: \"Shell mode background tasks\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => isBackgroundTaskShellStart(ctx),\n\t\treason: () =>\n\t\t\t\"Background task shell mode requires manual approval (pipes, redirects, and globbing are high risk)\",\n\t},\n\t{\n\t\tid: HUMAN_EGRESS_PII_RULE_ID,\n\t\tdescription: \"PII must be redacted before human-facing tools execute\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isHumanFacingTool(ctx.toolName)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst pending = getPendingUnredactedPii(ctx);\n\t\t\treturn pending.length > 0;\n\t\t},\n\t\treason: (ctx) => {\n\t\t\tconst pending = getPendingUnredactedPii(ctx);\n\t\t\tconst offenders =\n\t\t\t\tpending\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\t`${artifact.label} (artifact: ${artifact.id}, source: ${artifact.sourceToolCallId})`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"; \") || \"unredacted artifacts\";\n\t\t\treturn `Unredacted PII (${offenders}) detected before executing human-facing tool \"${ctx.toolName}\". Run your redaction tool on the listed artifacts, then retry.`;\n\t\t},\n\t},\n];\n\nexport class ActionFirewall {\n\tprivate semanticJudge?: SemanticJudge;\n\tprivate readonly governanceService:\n\t\t| ActionFirewallGovernanceServiceConfig\n\t\t| false\n\t\t| undefined;\n\n\tconstructor(\n\t\tprivate readonly rules: ActionFirewallRule[] = defaultFirewallRules,\n\t\toptions?: {\n\t\t\tgovernanceService?: ActionFirewallGovernanceServiceConfig | false;\n\t\t},\n\t) {\n\t\tthis.governanceService = options?.governanceService;\n\t}\n\n\tsetSemanticJudge(judge: SemanticJudge) {\n\t\tthis.semanticJudge = judge;\n\t}\n\n\tasync evaluate(\n\t\tcontext: ActionApprovalContext,\n\t): Promise<ActionFirewallVerdict> {\n\t\tconst governanceServiceVerdict =\n\t\t\tawait this.evaluateWithGovernanceService(context);\n\t\tif (governanceServiceVerdict?.action === \"block\") {\n\t\t\treturn governanceServiceVerdict;\n\t\t}\n\t\tif (governanceServiceVerdict?.action === \"require_approval\") {\n\t\t\treturn governanceServiceVerdict;\n\t\t}\n\n\t\tif (!governanceServiceVerdict) {\n\t\t\tfor (const rule of this.rules) {\n\t\t\t\tconst evaluation: RuleOutcome = rule.evaluate\n\t\t\t\t\t? await rule.evaluate(context)\n\t\t\t\t\t: (await rule.match?.(context))\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\t\t\treason:\n\t\t\t\t\t\t\t\t\t(await rule.reason?.(context)) ??\n\t\t\t\t\t\t\t\t\t`Action matched rule: ${rule.description}`,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: { allowed: true };\n\n\t\t\t\tif (!evaluation.allowed) {\n\t\t\t\t\tconst action = rule.action ?? \"require_approval\";\n\t\t\t\t\tconst reason =\n\t\t\t\t\t\tevaluation.reason ??\n\t\t\t\t\t\t`Action matched rule: ${rule.description ?? rule.name}`;\n\t\t\t\t\tconst remediation =\n\t\t\t\t\t\tevaluation.remediation ?? (await rule.remediation?.(context));\n\t\t\t\t\tconst ruleId =\n\t\t\t\t\t\t(rule as { id?: string }).id ?? rule.name ?? \"unknown-rule\";\n\n\t\t\t\t\tif (action === \"allow\") {\n\t\t\t\t\t\treturn { action: \"allow\" };\n\t\t\t\t\t}\n\n\t\t\t\t\tif (action === \"block\") {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\truleId,\n\t\t\t\t\t\t\treason,\n\t\t\t\t\t\t\tremediation,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction,\n\t\t\t\t\t\truleId,\n\t\t\t\t\t\treason,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 2. Run semantic judge if available (slow path)\n\t\tif (this.semanticJudge && context.userIntent) {\n\t\t\tconst SENSITIVE_TOOLS = [\n\t\t\t\t\"bash\",\n\t\t\t\t\"write\",\n\t\t\t\t\"edit\",\n\t\t\t\t\"delete_file\",\n\t\t\t\t\"background_tasks\",\n\t\t\t];\n\t\t\tif (SENSITIVE_TOOLS.includes(context.toolName)) {\n\t\t\t\tconst judgment = await this.semanticJudge.evaluate({\n\t\t\t\t\tuserIntent: context.userIntent,\n\t\t\t\t\ttoolName: context.toolName,\n\t\t\t\t\ttoolArgs: context.args,\n\t\t\t\t});\n\n\t\t\t\tif (!judgment.safe) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: \"require_approval\",\n\t\t\t\t\t\truleId: \"semantic-judge\",\n\t\t\t\t\t\treason: judgment.reason,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { action: \"allow\" };\n\t}\n\n\tprivate async evaluateWithGovernanceService(\n\t\tcontext: ActionApprovalContext,\n\t): Promise<ActionFirewallVerdict | null> {\n\t\tconst config = resolveActionFirewallGovernanceServiceConfig(\n\t\t\tthis.governanceService,\n\t\t\tcontext,\n\t\t);\n\t\tif (!config) {\n\t\t\treturn null;\n\t\t}\n\n\t\ttry {\n\t\t\tconst verdict = await evaluateActionWithActionFirewallGovernanceService(\n\t\t\t\tconfig,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t\treturn verdict;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tif (config.failureMode === \"required\") {\n\t\t\t\treturn {\n\t\t\t\t\taction: \"block\",\n\t\t\t\t\truleId: \"governance-service-unavailable\",\n\t\t\t\t\treason: `Governance service unavailable: ${message}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tlogger.warn(\n\t\t\t\t\"Failed to evaluate action with governance service; falling back to local firewall rules\",\n\t\t\t\t{\n\t\t\t\t\terror: message,\n\t\t\t\t\ttoolName: context.toolName,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n}\n\nexport const defaultActionFirewall = new ActionFirewall();\n"]}
1
+ {"version":3,"file":"action-firewall.js","sourceRoot":"","sources":["../../src/safety/action-firewall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAQH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,iDAAiD,EACjD,4CAA4C,GAC5C,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,4BAA4B,EAC5B,+BAA+B,EAC/B,wBAAwB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAIjE,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CA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iBACtB,CAAC,CAAC;gBAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACpB,OAAO;wBACN,MAAM,EAAE,kBAAkB;wBAC1B,MAAM,EAAE,gBAAgB;wBACxB,MAAM,EAAE,QAAQ,CAAC,MAAM;qBACvB,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5B,CAAC;IAEO,KAAK,CAAC,6BAA6B,CAC1C,OAA8B;QAE9B,MAAM,MAAM,GAAG,4CAA4C,CAC1D,IAAI,CAAC,iBAAiB,EACtB,OAAO,CACP,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,iDAAiD,CACtE,MAAM,EACN,OAAO,CACP,CAAC;YACF,OAAO,OAAO,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,IAAI,MAAM,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;gBACvC,OAAO;oBACN,MAAM,EAAE,OAAO;oBACf,MAAM,EAAE,gCAAgC;oBACxC,MAAM,EAAE,mCAAmC,OAAO,EAAE;iBACpD,CAAC;YACH,CAAC;YACD,MAAM,CAAC,IAAI,CACV,yFAAyF,EACzF;gBACC,KAAK,EAAE,OAAO;gBACd,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC1B,CACD,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;CACD;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["/**\n * Action Firewall - Rule-based safety enforcement for tool execution\n *\n * The action firewall is the central decision point for tool safety. Before\n * any tool executes, it passes through the firewall which evaluates a series\n * of rules and returns a verdict: allow, require_approval, or block.\n *\n * ## Architecture\n *\n * ```\n * Tool Call → ActionFirewall.evaluate() → Rules (sequential) → Verdict\n * ↓ ↓\n * Context Object Match + Reason + Remediation\n * ```\n *\n * ## Verdict Types\n *\n * - **allow**: Tool executes immediately without user interaction\n * - **require_approval**: User must explicitly approve before execution\n * - **block**: Tool is prevented from executing entirely (hard block)\n *\n * ## Rule Evaluation Order\n *\n * Rules are evaluated sequentially in priority order. The first matching\n * rule determines the verdict. This means:\n *\n * 1. Enterprise policy rules (hard blocks) come first\n * 2. System path protection (hard blocks) second\n * 3. Workspace containment (soft approval) third\n * 4. Dangerous command patterns (soft approval) later\n *\n * ## Caching Strategy\n *\n * Policy checks and tree-sitter analysis can be expensive. We use WeakMaps\n * keyed by the context object to cache results within a single evaluation.\n * The WeakMap ensures entries are garbage collected when the context is\n * no longer referenced.\n *\n * ## Integration Points\n *\n * The firewall integrates with:\n * - **Enterprise Policy**: Organizational restrictions on tools/paths\n * - **Workflow State**: PII tracking for egress prevention\n * - **Bash Parser**: Structured command analysis\n * - **Semantic Judge**: LLM-based intent analysis (optional, slow path)\n *\n * @module safety/action-firewall\n */\n\nimport type {\n\tActionApprovalContext,\n\tActionFirewallVerdict,\n\tWorkflowStateSnapshot,\n} from \"../agent/action-approval.js\";\nexport type { ActionApprovalContext } from \"../agent/action-approval.js\";\nimport { parseApplyPatchPaths } from \"../tools/apply-patch-parser.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport { isCommandAllowlisted } from \"./bash-allowlist.js\";\nimport {\n\tanalyzeCommandSafety,\n\tdangerousPatternDescriptions,\n\tdangerousPatterns,\n\thasEgressPrimitives,\n\tisDestructiveSimpleCommand,\n\tisParserAvailable,\n\tisSimpleBenignBash,\n\ttokenizeSimple,\n\tunwrapShellCommand,\n} from \"./bash-safety-analyzer.js\";\nimport {\n\ttype ActionFirewallGovernanceServiceConfig,\n\tevaluateActionWithActionFirewallGovernanceService,\n\tresolveActionFirewallGovernanceServiceConfig,\n} from \"./governance-service-client.js\";\nimport {\n\tDEFAULT_GUARDED_FILE_RULE_ID,\n\tdescribeDefaultGuardedFileMatch,\n\tfindGuardedToolCallMatch,\n} from \"./guarded-files.js\";\nimport { isContainedInWorkspace, isSystemPath } from \"./path-containment.js\";\nimport { checkPolicy } from \"./policy.js\";\nimport { RuleCache } from \"./rule-cache.js\";\nimport { TOOL_TAGS, looksLikeEgress } from \"./workflow-state.js\";\n\nimport type { SemanticJudge, SemanticJudgeContext } from \"./semantic-judge.js\";\n\nconst logger = createLogger(\"safety:action-firewall\");\n// Evaluate env flags lazily to honor profile overrides set after initial import.\nconst isStrictUntaggedEgress = () =>\n\tprocess.env.MAESTRO_FAIL_UNTAGGED_EGRESS === \"1\";\nconst isBackgroundShellBlocked = () =>\n\tprocess.env.MAESTRO_BACKGROUND_SHELL_DISABLE === \"1\";\nconst isSafeModeEnabled = () => process.env.MAESTRO_SAFE_MODE === \"1\";\nconst isProdProfile = () =>\n\tprocess.env.MAESTRO_PROFILE === \"prod\" ||\n\tprocess.env.MAESTRO_WEB_PROFILE === \"prod\";\nconst isNoEgressShellEnabled = () =>\n\t[\"1\", \"true\", \"on\"].includes(\n\t\t(process.env.MAESTRO_NO_EGRESS_SHELL ?? \"\").toLowerCase(),\n\t);\nconst isEgressOverrideAllowed = () =>\n\t[\"1\", \"true\", \"on\"].includes(\n\t\t(process.env.MAESTRO_ALLOW_EGRESS_SHELL ?? \"\").toLowerCase(),\n\t);\n\n/**\n * Policy Check Result - Cached result of enterprise policy evaluation\n */\ninterface PolicyCheckResult {\n\tallowed: boolean;\n\treason?: string;\n}\n\n/**\n * Policy Check Cache - Avoids redundant policy evaluations\n *\n * The firewall evaluation flow calls match() to check if a rule applies,\n * then reason() to get the human-readable explanation. For policy checks,\n * both need the same expensive async evaluation.\n *\n * We cache the result on match() and reuse it in reason(). The WeakMap\n * key is the context object itself, ensuring:\n * 1. Each context gets its own cached result\n * 2. Cache entries are automatically garbage collected when context is freed\n * 3. No memory leaks from long-running processes\n */\nconst policyCheckCache = new RuleCache<\n\tActionApprovalContext,\n\tPolicyCheckResult\n>();\n\n/**\n * Action Firewall Rule Interface\n *\n * Defines the structure of a firewall rule. Rules are the building blocks\n * of the firewall; each rule checks for a specific condition and returns\n * a verdict if matched.\n *\n * ## Rule Anatomy\n *\n * - **id**: Unique identifier for logging and debugging\n * - **description**: Human-readable explanation of what the rule checks\n * - **action**: What happens if rule matches (default: require_approval)\n * - **match()**: Predicate that returns true if rule applies\n * - **reason()**: Optional function returning why rule matched\n * - **remediation()**: Optional function suggesting how to fix the issue\n *\n * ## Match Evaluation\n *\n * The match function receives the full tool context including:\n * - toolName: Name of the tool being called\n * - args: Arguments passed to the tool\n * - metadata: Additional context (workflow state, annotations)\n * - user/session: Authentication context\n *\n * Rules can be sync or async. Async rules are awaited during evaluation.\n */\ntype RuleOutcome = { allowed: boolean; reason?: string; remediation?: string };\n\nexport interface ActionFirewallRule {\n\t/** Optional legacy identifier used in existing logs/tests */\n\tid?: string;\n\t/** Optional name for logging */\n\tname?: string;\n\t/** Human-readable description */\n\tdescription: string;\n\t/** Verdict override */\n\taction?: \"allow\" | \"require_approval\" | \"block\";\n\t/** Modern evaluation hook (preferred) */\n\tevaluate?: (\n\t\tcontext: ActionApprovalContext,\n\t) => RuleOutcome | Promise<RuleOutcome>;\n\t/** Optional remediation helper */\n\tremediation?: (context: ActionApprovalContext) => string | Promise<string>;\n\t/** Legacy match/reason hooks kept for backward compatibility */\n\tmatch?: (context: ActionApprovalContext) => boolean | Promise<boolean>;\n\treason?: (context: ActionApprovalContext) => string | Promise<string>;\n}\n\nconst untaggedEgressWarnings = new Set<string>();\nexport const HUMAN_EGRESS_PII_RULE_ID = \"pii-redaction-before-human-egress\";\n\nfunction getArgsObject(\n\tcontext: ActionApprovalContext,\n): Record<string, unknown> | null {\n\treturn context.args && typeof context.args === \"object\"\n\t\t? (context.args as Record<string, unknown>)\n\t\t: null;\n}\n\nfunction getStringArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): string | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"string\" ? value : null;\n}\n\nfunction getBooleanArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): boolean | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"boolean\" ? value : null;\n}\n\nfunction getCommandArg(context: ActionApprovalContext): string | null {\n\treturn getStringArg(context, \"command\");\n}\n\nfunction isBackgroundTaskShellStart(context: ActionApprovalContext): boolean {\n\tif (context.toolName !== \"background_tasks\") {\n\t\treturn false;\n\t}\n\tconst action = getStringArg(context, \"action\");\n\tif (action !== \"start\") {\n\t\treturn false;\n\t}\n\treturn getBooleanArg(context, \"shell\") === true;\n}\n\nfunction getWorkflowState(\n\tcontext: ActionApprovalContext,\n): WorkflowStateSnapshot | null {\n\treturn context.metadata?.workflowState ?? null;\n}\n\nfunction getPendingUnredactedPii(\n\tcontext: ActionApprovalContext,\n): WorkflowStateSnapshot[\"pendingPii\"] {\n\tconst snapshot = getWorkflowState(context);\n\tif (!snapshot) {\n\t\treturn [];\n\t}\n\treturn snapshot.pendingPii.filter((artifact) => artifact.redacted !== true);\n}\n\nfunction warnUntaggedEgress(toolName: string): void {\n\tif (untaggedEgressWarnings.has(toolName)) {\n\t\treturn;\n\t}\n\tuntaggedEgressWarnings.add(toolName);\n\tlogger.warn(\n\t\t\"Untagged egress-like tool encountered; treating as human-facing until TOOL_TAGS is updated\",\n\t\t{ toolName },\n\t);\n}\n\nfunction isHumanFacingTool(toolName: string): boolean {\n\tconst toolTags = TOOL_TAGS[toolName];\n\tif (toolTags?.egress === \"human\") {\n\t\treturn true;\n\t}\n\tif (!toolTags && looksLikeEgress(toolName)) {\n\t\twarnUntaggedEgress(toolName);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getAnnotations(context: ActionApprovalContext) {\n\treturn context.metadata?.annotations;\n}\n\nfunction isMcpTool(toolName: string): boolean {\n\treturn toolName.startsWith(\"mcp_\");\n}\n\n/**\n * Generate rules from dangerous patterns (regex-based)\n */\nconst dangerousCommandRules: ActionFirewallRule[] = Object.entries(\n\tdangerousPatterns,\n).map(([key, pattern]) => ({\n\tname: `command-${key}`,\n\tdescription:\n\t\tdangerousPatternDescriptions[\n\t\t\tkey as keyof typeof dangerousPatternDescriptions\n\t\t],\n\taction: \"require_approval\",\n\tevaluate: (ctx) => {\n\t\tif (!isBashGuardEnabled()) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tconst command = getCommandArg(ctx);\n\t\tif (!command) return { allowed: true };\n\t\tconst unwrapped = unwrapShellCommand(command) ?? command;\n\t\tif (isCommandAllowlisted(unwrapped)) return { allowed: true };\n\t\tif (!pattern.test(unwrapped)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: `Detected ${dangerousPatternDescriptions[key as keyof typeof dangerousPatternDescriptions]}: ${unwrapped.trim()}`,\n\t\t};\n\t},\n}));\n\nconst isBashStrict = () => process.env.MAESTRO_BASH_STRICT === \"1\";\nconst isBashGuardEnabled = () => {\n\tconst flag = process.env.MAESTRO_BASH_GUARD?.toLowerCase?.();\n\tif (flag) {\n\t\treturn ![\"0\", \"off\", \"false\", \"disabled\", \"no\"].includes(flag);\n\t}\n\t// Default: guard ON (previous behavior). Explicitly set MAESTRO_BASH_GUARD=0 to YOLO.\n\tif (isSafeModeEnabled() || isProdProfile()) {\n\t\treturn true;\n\t}\n\treturn true;\n};\n\n/**\n * Tree-sitter based command safety rule.\n * Provides more accurate analysis than regex patterns.\n */\nconst treeSitterCommandRule: ActionFirewallRule = {\n\tname: \"command-treesitter-analysis\",\n\tdescription: \"Tree-sitter based command safety analysis\",\n\taction: \"require_approval\",\n\tevaluate: (ctx) => {\n\t\tif (!isBashGuardEnabled()) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tif (ctx.toolName !== \"bash\" && !isBackgroundTaskShellStart(ctx)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\tlet command = getCommandArg(ctx);\n\t\tif (!command) return { allowed: true };\n\n\t\t// Try to unwrap bash -c \"...\" style commands\n\t\tconst unwrapped = unwrapShellCommand(command);\n\t\tif (unwrapped) {\n\t\t\tcommand = unwrapped;\n\t\t}\n\n\t\tif (isCommandAllowlisted(command)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\tconst simpleTokens = tokenizeSimple(command);\n\t\tif (isDestructiveSimpleCommand(simpleTokens)) {\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Command requires approval (destructive or mutating operation detected)\",\n\t\t\t};\n\t\t}\n\n\t\tif (!isBashStrict() && isSimpleBenignBash(command)) {\n\t\t\treturn { allowed: true };\n\t\t}\n\n\t\t// Only run tree-sitter if the parser is available; otherwise fall back to approval\n\t\tif (!isParserAvailable()) {\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Command requires approval (bash parser unavailable; unable to fully analyze)\",\n\t\t\t};\n\t\t}\n\n\t\tconst analysis = analyzeCommandSafety(command);\n\t\tif (analysis.safe) {\n\t\t\treturn { allowed: true };\n\t\t}\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: analysis.reason ?? \"Command failed tree-sitter safety analysis\",\n\t\t};\n\t},\n};\n\n/**\n * Critical System Paths - Directories that should never be modified\n *\n * These paths are protected with a HARD BLOCK (not just approval required).\n * Modifying files in these directories can:\n * - Break the operating system\n * - Compromise system security\n * - Affect other users on the system\n *\n * ## Linux Paths\n *\n * - /etc: System configuration\n * - /usr: System programs and libraries\n * - /var: Variable data (logs, databases)\n * - /boot: Bootloader and kernel\n * - /sys, /proc: Kernel virtual filesystems\n * - /dev: Device files\n * - /bin, /sbin: Essential system binaries\n * - /lib, /lib64: Shared libraries\n * - /opt: Optional/third-party software\n *\n * ## macOS Paths\n *\n * - /System: System files\n * - /Library: System libraries\n * - /private/etc, /private/var: Private system configuration/data\n * - /dev: Device files\n *\n * ## Windows Paths\n *\n * - C:\\Windows: Operating system\n * - C:\\Program Files: Installed applications\n *\n * Note: /var/folders (macOS temp) and /tmp are explicitly allowed\n * through the isContainedInWorkspace check before system path blocking.\n */\nfunction extractFilePaths(context: ActionApprovalContext): string[] {\n\tconst args = getArgsObject(context);\n\tif (!args) return [];\n\tconst paths: string[] = [];\n\tconst toolName = context.toolName.toLowerCase();\n\n\t// Simple extraction for standard file tools\n\t// Note: deeper extraction is done in policy.ts, this is for quick system protection\n\tif (toolName === \"write\" || toolName === \"edit\") {\n\t\tconst p =\n\t\t\tgetStringArg(context, \"file_path\") || getStringArg(context, \"path\");\n\t\tif (p) paths.push(p);\n\t}\n\tif (toolName === \"apply_patch\") {\n\t\tconst patch = getStringArg(context, \"patch\");\n\t\tif (patch) {\n\t\t\tpaths.push(...parseApplyPatchPaths(patch));\n\t\t}\n\t}\n\tif (toolName === \"delete_file\") {\n\t\tconst p =\n\t\t\tgetStringArg(context, \"file_path\") ||\n\t\t\tgetStringArg(context, \"target_file\");\n\t\tif (p) paths.push(p);\n\t}\n\t// Handle move_file and copy_file - extract both source and destination\n\tif (toolName === \"move_file\" || toolName === \"copy_file\") {\n\t\tconst source =\n\t\t\tgetStringArg(context, \"source\") ||\n\t\t\tgetStringArg(context, \"source_path\") ||\n\t\t\tgetStringArg(context, \"from\");\n\t\tconst dest =\n\t\t\tgetStringArg(context, \"destination\") ||\n\t\t\tgetStringArg(context, \"destination_path\") ||\n\t\t\tgetStringArg(context, \"dest\") ||\n\t\t\tgetStringArg(context, \"to\");\n\t\tif (source) paths.push(source);\n\t\tif (dest) paths.push(dest);\n\t}\n\treturn paths;\n}\n\n/**\n * Workspace Containment Check - Determines if a path is in a \"safe zone\"\n *\n * The firewall uses containment to prevent accidental writes outside the\n * project directory. This function checks if a file path is within one of\n * the allowed zones.\n *\n * ## Safe Zones (in order of check)\n *\n * 1. **Workspace root**: Current working directory and subdirectories\n * 2. **System temp directory**: /tmp, /var/folders, etc.\n * 3. **Trusted paths**: User-configured paths in firewall.json\n *\n * ## Path Resolution Complexity\n *\n * We must handle several path edge cases:\n *\n * - **Symlinks**: macOS /tmp → /private/tmp, so we resolve real paths\n * - **Non-existent files**: Can't realpath a file being created, use logical path\n * - **Relative paths**: Convert to absolute before comparison\n * - **Path traversal**: Detect ../ escapes using relative() output\n *\n * ## Detection Method\n *\n * For each safe zone, we compute relative(zone, targetPath). If the result:\n * - Starts with \"..\" → path escapes the zone (unsafe)\n * - Is an absolute path → completely outside (unsafe)\n * - Otherwise → contained within zone (safe)\n *\n * @param filePath - The path to check (may be relative or absolute)\n * @returns true if path is contained in a safe zone, false otherwise\n */\n\nexport const defaultFirewallRules: ActionFirewallRule[] = [\n\t{\n\t\tname: \"enterprise-policy\",\n\t\tdescription: \"Enforce enterprise policies on tools and dependencies\",\n\t\taction: \"block\", // HARD BLOCK for policy violations\n\t\tevaluate: async (ctx) => {\n\t\t\tconst cached = policyCheckCache.get(ctx);\n\t\t\tif (cached) {\n\t\t\t\treturn cached.allowed\n\t\t\t\t\t? { allowed: true }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\t\treason: cached.reason ?? \"Action blocked by enterprise policy\",\n\t\t\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await checkPolicy(ctx);\n\t\t\tpolicyCheckCache.set(ctx, result);\n\t\t\tif (result.allowed) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason: result.reason ?? \"Action blocked by enterprise policy\",\n\t\t\t};\n\t\t},\n\t},\n\t{\n\t\tname: \"system-path-protection\",\n\t\tdescription: \"Prevent modification of critical system directories\",\n\t\taction: \"block\", // HARD BLOCK for system paths\n\t\tevaluate: (ctx) => {\n\t\t\t// Only check file mutation tools\n\t\t\tif (\n\t\t\t\t![\n\t\t\t\t\t\"write\",\n\t\t\t\t\t\"edit\",\n\t\t\t\t\t\"apply_patch\",\n\t\t\t\t\t\"delete_file\",\n\t\t\t\t\t\"move_file\",\n\t\t\t\t\t\"copy_file\",\n\t\t\t\t].includes(ctx.toolName)\n\t\t\t) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst paths = extractFilePaths(ctx);\n\t\t\t// We check system paths first, but if it's in workspace, temp, or a trusted path (safe), we should allow it.\n\t\t\t// System paths like /var include /var/folders (temp on mac), so we need to exclude safe temp paths from system path blocking.\n\n\t\t\t// Filter out paths that are inside the workspace, temp, or trusted paths (which are safe)\n\t\t\tconst unsafePaths = paths.filter((p) => !isContainedInWorkspace(p));\n\n\t\t\t// Only check remaining paths against system blocklist\n\t\t\tif (unsafePaths.some(isSystemPath)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason:\n\t\t\t\t\t\t\"Modification of critical system directories is blocked for safety.\",\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allowed: true };\n\t\t},\n\t\tremediation: () =>\n\t\t\t\"Do not modify critical system paths. If you need to write a file, use the current workspace directory or a temporary folder.\",\n\t},\n\t{\n\t\tid: DEFAULT_GUARDED_FILE_RULE_ID,\n\t\tdescription:\n\t\t\t\"Block guarded user and editor configuration files when policy requires a hard block\",\n\t\taction: \"block\",\n\t\tevaluate: (ctx) => {\n\t\t\tconst match = findGuardedToolCallMatch(ctx.toolName, ctx.args, {\n\t\t\t\tpolicy: ctx.metadata?.guardedFiles,\n\t\t\t});\n\t\t\tif (match?.defaultBehavior === \"block\") {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: describeDefaultGuardedFileMatch(match),\n\t\t\t\t\tremediation:\n\t\t\t\t\t\t\"Remove the matching custom guard or change its defaultBehavior to ask if this access should be approval-gated instead of blocked.\",\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allowed: true };\n\t\t},\n\t},\n\t{\n\t\tid: DEFAULT_GUARDED_FILE_RULE_ID,\n\t\tdescription:\n\t\t\t\"Require explicit approval before reading or mutating guarded user and editor configuration files\",\n\t\taction: \"require_approval\",\n\t\tevaluate: (ctx) => {\n\t\t\tconst match = findGuardedToolCallMatch(ctx.toolName, ctx.args, {\n\t\t\t\tpolicy: ctx.metadata?.guardedFiles,\n\t\t\t});\n\t\t\tif (match) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: describeDefaultGuardedFileMatch(match),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allowed: true };\n\t\t},\n\t},\n\t{\n\t\tname: \"workspace-containment\",\n\t\tdescription:\n\t\t\t\"Require approval for file modifications outside the workspace\",\n\t\taction: \"require_approval\",\n\t\tevaluate: (ctx) => {\n\t\t\t// Only check file mutation tools\n\t\t\tif (\n\t\t\t\t![\n\t\t\t\t\t\"write\",\n\t\t\t\t\t\"edit\",\n\t\t\t\t\t\"apply_patch\",\n\t\t\t\t\t\"delete_file\",\n\t\t\t\t\t\"move_file\",\n\t\t\t\t\t\"copy_file\",\n\t\t\t\t].includes(ctx.toolName)\n\t\t\t) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst paths = extractFilePaths(ctx);\n\t\t\t// Return true (match rule) if ANY path is NOT contained\n\t\t\tconst outsidePaths = paths.filter((p) => !isContainedInWorkspace(p));\n\t\t\tif (outsidePaths.length === 0) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason: `File modification outside workspace detected: ${outsidePaths.join(\", \")}. This requires explicit approval.`,\n\t\t\t};\n\t\t},\n\t\tremediation: () =>\n\t\t\t\"The file path is outside the allowed workspace. Please use a path within the current project or a temporary directory, or ask the user to add this path to 'containment.trustedPaths' in ~/.maestro/firewall.json.\",\n\t},\n\t{\n\t\tid: \"untagged-human-egress\",\n\t\tdescription:\n\t\t\t\"Block human-facing tool calls without explicit TOOL_TAGS annotations when strict mode is enabled\",\n\t\taction: \"block\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isStrictUntaggedEgress()) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!isHumanFacingTool(ctx.toolName)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn TOOL_TAGS[ctx.toolName] === undefined;\n\t\t},\n\t\treason: () =>\n\t\t\t\"Human-facing tool is missing TOOL_TAGS; annotate the tool or disable strict mode via MAESTRO_FAIL_UNTAGGED_EGRESS=0.\",\n\t\tremediation: () =>\n\t\t\t\"Add TOOL_TAGS entry marking egress intent (human/http) before invoking the tool.\",\n\t},\n\t{\n\t\tid: \"background-shell-block\",\n\t\tdescription: \"Block shell-based background tasks when disabled by policy\",\n\t\taction: \"block\",\n\t\tmatch: (ctx) =>\n\t\t\tisBackgroundShellBlocked() && isBackgroundTaskShellStart(ctx) === true,\n\t\treason: () =>\n\t\t\t\"Starting background_tasks with shell=true is disabled by policy. Set MAESTRO_BACKGROUND_SHELL_DISABLE=0 to allow.\",\n\t},\n\t{\n\t\tid: \"mcp-destructive-tool\",\n\t\tdescription: \"MCP tools marked as destructive require approval\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isMcpTool(ctx.toolName)) return false;\n\t\t\tconst annotations = getAnnotations(ctx);\n\t\t\t// Require approval if destructiveHint is true and readOnlyHint is not true\n\t\t\treturn (\n\t\t\t\tannotations?.destructiveHint === true && !annotations?.readOnlyHint\n\t\t\t);\n\t\t},\n\t\treason: (ctx) =>\n\t\t\t`MCP tool \"${ctx.toolName}\" is marked as destructive and requires approval`,\n\t},\n\t{\n\t\tid: \"plan-mode-confirm\",\n\t\tdescription:\n\t\t\t\"When plan mode is enabled, require approval before mutating commands\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (process.env.MAESTRO_PLAN_MODE !== \"1\") return false;\n\t\t\tconst name = ctx.toolName;\n\t\t\tif (\n\t\t\t\tname === \"write\" ||\n\t\t\t\tname === \"edit\" ||\n\t\t\t\tname === \"apply_patch\" ||\n\t\t\t\tname === \"bash\"\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (name === \"todo\") return true;\n\t\t\tif (name === \"gh_pr\") {\n\t\t\t\tconst action = getStringArg(ctx, \"action\");\n\t\t\t\treturn !action || ![\"list\", \"view\", \"checks\", \"diff\"].includes(action);\n\t\t\t}\n\t\t\tif (name === \"gh_issue\") {\n\t\t\t\tconst action = getStringArg(ctx, \"action\");\n\t\t\t\treturn !action || ![\"list\", \"view\"].includes(action);\n\t\t\t}\n\t\t\tif (name === \"background_tasks\") {\n\t\t\t\tconst args = getArgsObject(ctx);\n\t\t\t\tconst action = args?.action;\n\t\t\t\tconst shell = args?.shell === true;\n\t\t\t\treturn action === \"start\" && shell;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\treason: (ctx) =>\n\t\t\t`Plan mode requires confirmation before executing ${ctx.toolName}. Toggle with /plan-mode or MAESTRO_PLAN_MODE=0.`,\n\t},\n\t{\n\t\tid: \"no-egress-shell\",\n\t\tdescription:\n\t\t\t\"Require approval when shell egress is disabled via MAESTRO_NO_EGRESS_SHELL\",\n\t\taction: \"require_approval\",\n\t\tevaluate: (ctx) => {\n\t\t\tif (!isNoEgressShellEnabled() || isEgressOverrideAllowed()) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tif (ctx.toolName !== \"bash\" && !isBackgroundTaskShellStart(ctx)) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\tconst raw = getCommandArg(ctx);\n\t\t\tif (!raw) return { allowed: true };\n\t\t\tconst unwrapped = unwrapShellCommand(raw) ?? raw;\n\t\t\tif (isCommandAllowlisted(unwrapped)) return { allowed: true };\n\t\t\tif (!hasEgressPrimitives(unwrapped)) return { allowed: true };\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason:\n\t\t\t\t\t\"Shell egress (curl/wget/ssh/nc/dev/tcp) requires approval because MAESTRO_NO_EGRESS_SHELL=1. Allow temporarily with MAESTRO_ALLOW_EGRESS_SHELL=1 or add a bash allowlist entry.\",\n\t\t\t};\n\t\t},\n\t},\n\t...dangerousCommandRules,\n\ttreeSitterCommandRule,\n\t{\n\t\tid: \"background-shell-mode\",\n\t\tdescription: \"Shell mode background tasks\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => isBackgroundTaskShellStart(ctx),\n\t\treason: () =>\n\t\t\t\"Background task shell mode requires manual approval (pipes, redirects, and globbing are high risk)\",\n\t},\n\t{\n\t\tid: HUMAN_EGRESS_PII_RULE_ID,\n\t\tdescription: \"PII must be redacted before human-facing tools execute\",\n\t\taction: \"require_approval\",\n\t\tmatch: (ctx) => {\n\t\t\tif (!isHumanFacingTool(ctx.toolName)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst pending = getPendingUnredactedPii(ctx);\n\t\t\treturn pending.length > 0;\n\t\t},\n\t\treason: (ctx) => {\n\t\t\tconst pending = getPendingUnredactedPii(ctx);\n\t\t\tconst offenders =\n\t\t\t\tpending\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(artifact) =>\n\t\t\t\t\t\t\t`${artifact.label} (artifact: ${artifact.id}, source: ${artifact.sourceToolCallId})`,\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"; \") || \"unredacted artifacts\";\n\t\t\treturn `Unredacted PII (${offenders}) detected before executing human-facing tool \"${ctx.toolName}\". Run your redaction tool on the listed artifacts, then retry.`;\n\t\t},\n\t},\n];\n\nexport class ActionFirewall {\n\tprivate semanticJudge?: SemanticJudge;\n\tprivate readonly governanceService:\n\t\t| ActionFirewallGovernanceServiceConfig\n\t\t| false\n\t\t| undefined;\n\n\tconstructor(\n\t\tprivate readonly rules: ActionFirewallRule[] = defaultFirewallRules,\n\t\toptions?: {\n\t\t\tgovernanceService?: ActionFirewallGovernanceServiceConfig | false;\n\t\t},\n\t) {\n\t\tthis.governanceService = options?.governanceService;\n\t}\n\n\tsetSemanticJudge(judge: SemanticJudge) {\n\t\tthis.semanticJudge = judge;\n\t}\n\n\tasync evaluate(\n\t\tcontext: ActionApprovalContext,\n\t): Promise<ActionFirewallVerdict> {\n\t\tconst governanceServiceVerdict =\n\t\t\tawait this.evaluateWithGovernanceService(context);\n\t\tif (governanceServiceVerdict?.action === \"block\") {\n\t\t\treturn governanceServiceVerdict;\n\t\t}\n\t\tif (governanceServiceVerdict?.action === \"require_approval\") {\n\t\t\treturn governanceServiceVerdict;\n\t\t}\n\n\t\tif (!governanceServiceVerdict) {\n\t\t\tfor (const rule of this.rules) {\n\t\t\t\tconst evaluation: RuleOutcome = rule.evaluate\n\t\t\t\t\t? await rule.evaluate(context)\n\t\t\t\t\t: (await rule.match?.(context))\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\t\t\treason:\n\t\t\t\t\t\t\t\t\t(await rule.reason?.(context)) ??\n\t\t\t\t\t\t\t\t\t`Action matched rule: ${rule.description}`,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: { allowed: true };\n\n\t\t\t\tif (!evaluation.allowed) {\n\t\t\t\t\tconst action = rule.action ?? \"require_approval\";\n\t\t\t\t\tconst reason =\n\t\t\t\t\t\tevaluation.reason ??\n\t\t\t\t\t\t`Action matched rule: ${rule.description ?? rule.name}`;\n\t\t\t\t\tconst remediation =\n\t\t\t\t\t\tevaluation.remediation ?? (await rule.remediation?.(context));\n\t\t\t\t\tconst ruleId =\n\t\t\t\t\t\t(rule as { id?: string }).id ?? rule.name ?? \"unknown-rule\";\n\n\t\t\t\t\tif (action === \"allow\") {\n\t\t\t\t\t\treturn { action: \"allow\" };\n\t\t\t\t\t}\n\n\t\t\t\t\tif (action === \"block\") {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\truleId,\n\t\t\t\t\t\t\treason,\n\t\t\t\t\t\t\tremediation,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction,\n\t\t\t\t\t\truleId,\n\t\t\t\t\t\treason,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 2. Run semantic judge if available (slow path)\n\t\tif (this.semanticJudge && context.userIntent) {\n\t\t\tconst SENSITIVE_TOOLS = [\n\t\t\t\t\"bash\",\n\t\t\t\t\"write\",\n\t\t\t\t\"edit\",\n\t\t\t\t\"apply_patch\",\n\t\t\t\t\"delete_file\",\n\t\t\t\t\"background_tasks\",\n\t\t\t];\n\t\t\tif (SENSITIVE_TOOLS.includes(context.toolName)) {\n\t\t\t\tconst judgment = await this.semanticJudge.evaluate({\n\t\t\t\t\tuserIntent: context.userIntent,\n\t\t\t\t\ttoolName: context.toolName,\n\t\t\t\t\ttoolArgs: context.args,\n\t\t\t\t});\n\n\t\t\t\tif (!judgment.safe) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: \"require_approval\",\n\t\t\t\t\t\truleId: \"semantic-judge\",\n\t\t\t\t\t\treason: judgment.reason,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { action: \"allow\" };\n\t}\n\n\tprivate async evaluateWithGovernanceService(\n\t\tcontext: ActionApprovalContext,\n\t): Promise<ActionFirewallVerdict | null> {\n\t\tconst config = resolveActionFirewallGovernanceServiceConfig(\n\t\t\tthis.governanceService,\n\t\t\tcontext,\n\t\t);\n\t\tif (!config) {\n\t\t\treturn null;\n\t\t}\n\n\t\ttry {\n\t\t\tconst verdict = await evaluateActionWithActionFirewallGovernanceService(\n\t\t\t\tconfig,\n\t\t\t\tcontext,\n\t\t\t);\n\t\t\treturn verdict;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tif (config.failureMode === \"required\") {\n\t\t\t\treturn {\n\t\t\t\t\taction: \"block\",\n\t\t\t\t\truleId: \"governance-service-unavailable\",\n\t\t\t\t\treason: `Governance service unavailable: ${message}`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tlogger.warn(\n\t\t\t\t\"Failed to evaluate action with governance service; falling back to local firewall rules\",\n\t\t\t\t{\n\t\t\t\t\terror: message,\n\t\t\t\t\ttoolName: context.toolName,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\t}\n}\n\nexport const defaultActionFirewall = new ActionFirewall();\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"attack-patterns.d.ts","sourceRoot":"","sources":["../../src/safety/attack-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,cAAc,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,sBAAsB,GACtB,gBAAgB,GAChB,aAAa,GACb,iBAAiB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,sBAAsB;IACtB,QAAQ,EAAE,cAAc,CAAC;IACzB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAwJzE,CAAC;AAwBF;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,eAAe,EAwL3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAAe,EAuGvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAE,eAAe,EAkF1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAAe,EA2DpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAAe,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AAE,eAAe,EA+E1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAAe,EA2DpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAAe,EAgJjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAAe,EAwBrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAAe,EAOhD,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,GACf,qBAAqB,GAAG,SAAS,CAEnC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,cAAc,GACtB,eAAe,EAAE,CAKnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAC9C,eAAe,EAAE,CAEnB"}
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * @module safety/attack-patterns
11
11
  */
12
+ import { parseApplyPatchPaths } from "../tools/apply-patch-parser.js";
12
13
  /**
13
14
  * Registry mapping pattern IDs to their metadata
14
15
  */
@@ -158,7 +159,28 @@ function pathMatches(args, pattern) {
158
159
  const path = args.path ||
159
160
  args.file_path ||
160
161
  args.target;
161
- return path ? pattern.test(path) : false;
162
+ if (path && pattern.test(path)) {
163
+ return true;
164
+ }
165
+ const patch = args.patch;
166
+ if (typeof patch === "string") {
167
+ return parseApplyPatchPaths(patch).some((patchPath) => pattern.test(patchPath));
168
+ }
169
+ return false;
170
+ }
171
+ function toolMutatesFiles(currentTool) {
172
+ const normalizedTool = currentTool.toLowerCase();
173
+ return (normalizedTool === "write" ||
174
+ normalizedTool === "edit" ||
175
+ normalizedTool === "apply_patch");
176
+ }
177
+ function mutationContent(args) {
178
+ const content = args.content;
179
+ if (typeof content === "string") {
180
+ return content;
181
+ }
182
+ const patch = args.patch;
183
+ return typeof patch === "string" ? patch : "";
162
184
  }
163
185
  /**
164
186
  * Credential Harvesting Patterns
@@ -454,8 +476,7 @@ export const PRIVILEGE_ESCALATION_PATTERNS = [
454
476
  windowMs: 60_000,
455
477
  detect: (_records, currentTool, currentArgs) => {
456
478
  const cronPattern = /\/etc\/cron|crontab|\/var\/spool\/cron/i;
457
- if (currentTool.toLowerCase() === "write" ||
458
- currentTool.toLowerCase() === "edit") {
479
+ if (toolMutatesFiles(currentTool)) {
459
480
  if (pathMatches(currentArgs, cronPattern)) {
460
481
  return {
461
482
  matched: true,
@@ -567,8 +588,7 @@ export const PERSISTENCE_PATTERNS = [
567
588
  windowMs: 60_000,
568
589
  detect: (_records, currentTool, currentArgs) => {
569
590
  const sshPattern = /\.ssh\/authorized_keys|\.ssh\/id_/i;
570
- if (currentTool.toLowerCase() === "write" ||
571
- currentTool.toLowerCase() === "edit") {
591
+ if (toolMutatesFiles(currentTool)) {
572
592
  if (pathMatches(currentArgs, sshPattern)) {
573
593
  return {
574
594
  matched: true,
@@ -587,8 +607,7 @@ export const PERSISTENCE_PATTERNS = [
587
607
  windowMs: 60_000,
588
608
  detect: (_records, currentTool, currentArgs) => {
589
609
  const profilePattern = /\.bashrc|\.bash_profile|\.zshrc|\.profile|\.bash_login/i;
590
- if (currentTool.toLowerCase() === "write" ||
591
- currentTool.toLowerCase() === "edit") {
610
+ if (toolMutatesFiles(currentTool)) {
592
611
  if (pathMatches(currentArgs, profilePattern)) {
593
612
  return {
594
613
  matched: true,
@@ -607,8 +626,7 @@ export const PERSISTENCE_PATTERNS = [
607
626
  windowMs: 60_000,
608
627
  detect: (_records, currentTool, currentArgs) => {
609
628
  const systemdPattern = /\/etc\/systemd|\.config\/systemd|\.service$/i;
610
- if (currentTool.toLowerCase() === "write" ||
611
- currentTool.toLowerCase() === "edit") {
629
+ if (toolMutatesFiles(currentTool)) {
612
630
  if (pathMatches(currentArgs, systemdPattern)) {
613
631
  return {
614
632
  matched: true,
@@ -629,6 +647,7 @@ export const PERSISTENCE_PATTERNS = [
629
647
  // Check for LD_PRELOAD being written to profile files
630
648
  if (currentTool.toLowerCase() === "write" ||
631
649
  currentTool.toLowerCase() === "edit" ||
650
+ currentTool.toLowerCase() === "apply_patch" ||
632
651
  currentTool.toLowerCase() === "bash") {
633
652
  // Check for LD_PRELOAD in command or file content
634
653
  const ldPreloadPattern = /LD_PRELOAD/i;
@@ -643,7 +662,7 @@ export const PERSISTENCE_PATTERNS = [
643
662
  }
644
663
  else if (pathMatches(currentArgs, profilePattern)) {
645
664
  // If writing to profile files, check for LD_PRELOAD in content
646
- const content = currentArgs.content;
665
+ const content = mutationContent(currentArgs);
647
666
  if (content && ldPreloadPattern.test(content)) {
648
667
  return {
649
668
  matched: true,
@@ -663,8 +682,7 @@ export const PERSISTENCE_PATTERNS = [
663
682
  windowMs: 60_000,
664
683
  detect: (_records, currentTool, currentArgs) => {
665
684
  const gitHooksPattern = /\.git\/hooks\//i;
666
- if (currentTool.toLowerCase() === "write" ||
667
- currentTool.toLowerCase() === "edit") {
685
+ if (toolMutatesFiles(currentTool)) {
668
686
  if (pathMatches(currentArgs, gitHooksPattern)) {
669
687
  return {
670
688
  matched: true,
@@ -683,8 +701,7 @@ export const PERSISTENCE_PATTERNS = [
683
701
  windowMs: 60_000,
684
702
  detect: (_records, currentTool, currentArgs) => {
685
703
  const pamPattern = /\/etc\/pam\.d\/|\/etc\/pam\.conf|pam_.*\.so/i;
686
- if (currentTool.toLowerCase() === "write" ||
687
- currentTool.toLowerCase() === "edit") {
704
+ if (toolMutatesFiles(currentTool)) {
688
705
  if (pathMatches(currentArgs, pamPattern)) {
689
706
  return {
690
707
  matched: true,