@nhtio/adk 0.1.0-master-e5947c71 → 0.1.0-master-74266e68

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 (355) hide show
  1. package/CHANGELOG.md +124 -1
  2. package/artifact_methods-BvoDGBnH.cjs +1 -0
  3. package/artifact_methods-q52ETLwI.mjs +1 -0
  4. package/batteries/artifacts/ecmascript.cjs +1 -1
  5. package/batteries/artifacts/ecmascript.mjs +1 -1
  6. package/batteries/artifacts/toon.cjs +1 -1
  7. package/batteries/artifacts/toon.mjs +1 -1
  8. package/batteries/artifacts/xml.cjs +1 -1
  9. package/batteries/artifacts/xml.mjs +1 -1
  10. package/batteries/artifacts/yaml.cjs +1 -1
  11. package/batteries/artifacts/yaml.mjs +1 -1
  12. package/batteries/artifacts.cjs +4 -4
  13. package/batteries/artifacts.mjs +4 -4
  14. package/batteries/dev-tools/forge.cjs +3 -3
  15. package/batteries/dev-tools/forge.mjs +3 -3
  16. package/batteries/dev-tools.cjs +2 -2
  17. package/batteries/dev-tools.mjs +2 -2
  18. package/batteries/encoding.cjs +7 -7
  19. package/batteries/encoding.mjs +7 -7
  20. package/batteries/generation/gemini/adapter.cjs +1 -1
  21. package/batteries/generation/gemini/adapter.mjs +1 -1
  22. package/batteries/generation/local_diffusion/adapter.cjs +1 -1
  23. package/batteries/generation/local_diffusion/adapter.mjs +1 -1
  24. package/batteries/generation/openai/adapter.cjs +1 -1
  25. package/batteries/generation/openai/adapter.mjs +1 -1
  26. package/batteries/llm/anthropic_messages/adapter.cjs +6 -6
  27. package/batteries/llm/anthropic_messages/adapter.mjs +6 -6
  28. package/batteries/llm/anthropic_messages/count_tokens.cjs +2 -2
  29. package/batteries/llm/anthropic_messages/count_tokens.mjs +1 -1
  30. package/batteries/llm/anthropic_messages/helpers.cjs +3 -3
  31. package/batteries/llm/anthropic_messages/helpers.mjs +3 -3
  32. package/batteries/llm/anthropic_messages/validation.cjs +2 -2
  33. package/batteries/llm/anthropic_messages/validation.mjs +2 -2
  34. package/batteries/llm/anthropic_messages.cjs +2 -2
  35. package/batteries/llm/anthropic_messages.mjs +2 -2
  36. package/batteries/llm/bedrock_converse/adapter.cjs +6 -6
  37. package/batteries/llm/bedrock_converse/adapter.mjs +6 -6
  38. package/batteries/llm/bedrock_converse/helpers.cjs +1 -1
  39. package/batteries/llm/bedrock_converse/helpers.mjs +1 -1
  40. package/batteries/llm/bedrock_converse/validation.cjs +2 -2
  41. package/batteries/llm/bedrock_converse/validation.mjs +2 -2
  42. package/batteries/llm/bedrock_converse.cjs +2 -2
  43. package/batteries/llm/bedrock_converse.mjs +2 -2
  44. package/batteries/llm/claude_code_cli/adapter.cjs +7 -7
  45. package/batteries/llm/claude_code_cli/adapter.mjs +7 -7
  46. package/batteries/llm/claude_code_cli/helpers.cjs +3 -3
  47. package/batteries/llm/claude_code_cli/helpers.mjs +3 -3
  48. package/batteries/llm/claude_code_cli/validation.cjs +2 -2
  49. package/batteries/llm/claude_code_cli/validation.mjs +2 -2
  50. package/batteries/llm/claude_code_cli.cjs +2 -2
  51. package/batteries/llm/claude_code_cli.mjs +2 -2
  52. package/batteries/llm/gemini_generate_content/adapter.cjs +7 -7
  53. package/batteries/llm/gemini_generate_content/adapter.mjs +7 -7
  54. package/batteries/llm/gemini_generate_content/helpers.cjs +1 -1
  55. package/batteries/llm/gemini_generate_content/helpers.mjs +1 -1
  56. package/batteries/llm/gemini_generate_content/validation.cjs +2 -2
  57. package/batteries/llm/gemini_generate_content/validation.mjs +2 -2
  58. package/batteries/llm/gemini_generate_content.cjs +2 -2
  59. package/batteries/llm/gemini_generate_content.mjs +2 -2
  60. package/batteries/llm/litert_lm/adapter.cjs +6 -6
  61. package/batteries/llm/litert_lm/adapter.mjs +6 -6
  62. package/batteries/llm/litert_lm/helpers.cjs +3 -3
  63. package/batteries/llm/litert_lm/helpers.mjs +3 -3
  64. package/batteries/llm/litert_lm/validation.cjs +2 -2
  65. package/batteries/llm/litert_lm/validation.mjs +2 -2
  66. package/batteries/llm/litert_lm.cjs +1 -1
  67. package/batteries/llm/litert_lm.mjs +1 -1
  68. package/batteries/llm/ollama/adapter.cjs +6 -6
  69. package/batteries/llm/ollama/adapter.mjs +6 -6
  70. package/batteries/llm/ollama/helpers.cjs +4 -4
  71. package/batteries/llm/ollama/helpers.mjs +4 -4
  72. package/batteries/llm/ollama/validation.cjs +2 -2
  73. package/batteries/llm/ollama/validation.mjs +2 -2
  74. package/batteries/llm/ollama.cjs +2 -2
  75. package/batteries/llm/ollama.mjs +2 -2
  76. package/batteries/llm/openai_chat_completions/adapter.cjs +6 -6
  77. package/batteries/llm/openai_chat_completions/adapter.mjs +6 -6
  78. package/batteries/llm/openai_chat_completions/helpers.cjs +4 -4
  79. package/batteries/llm/openai_chat_completions/helpers.mjs +4 -4
  80. package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
  81. package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
  82. package/batteries/llm/openai_chat_completions.cjs +2 -2
  83. package/batteries/llm/openai_chat_completions.mjs +2 -2
  84. package/batteries/llm/openai_responses/adapter.cjs +6 -6
  85. package/batteries/llm/openai_responses/adapter.mjs +6 -6
  86. package/batteries/llm/openai_responses/helpers.cjs +3 -3
  87. package/batteries/llm/openai_responses/helpers.mjs +3 -3
  88. package/batteries/llm/openai_responses/validation.cjs +2 -2
  89. package/batteries/llm/openai_responses/validation.mjs +2 -2
  90. package/batteries/llm/openai_responses.cjs +2 -2
  91. package/batteries/llm/openai_responses.mjs +2 -2
  92. package/batteries/llm/transformers_js/adapter.cjs +6 -6
  93. package/batteries/llm/transformers_js/adapter.mjs +6 -6
  94. package/batteries/llm/transformers_js/helpers.cjs +3 -3
  95. package/batteries/llm/transformers_js/helpers.mjs +3 -3
  96. package/batteries/llm/transformers_js/validation.cjs +2 -2
  97. package/batteries/llm/transformers_js/validation.mjs +2 -2
  98. package/batteries/llm/transformers_js.cjs +1 -1
  99. package/batteries/llm/transformers_js.mjs +1 -1
  100. package/batteries/llm/webllm_chat_completions/adapter.cjs +6 -6
  101. package/batteries/llm/webllm_chat_completions/adapter.mjs +6 -6
  102. package/batteries/llm/webllm_chat_completions/helpers.cjs +1 -1
  103. package/batteries/llm/webllm_chat_completions/helpers.mjs +1 -1
  104. package/batteries/llm/webllm_chat_completions/validation.cjs +2 -2
  105. package/batteries/llm/webllm_chat_completions/validation.mjs +2 -2
  106. package/batteries/llm/webllm_chat_completions.cjs +2 -2
  107. package/batteries/llm/webllm_chat_completions.mjs +2 -2
  108. package/batteries/llm.cjs +2 -2
  109. package/batteries/llm.mjs +2 -2
  110. package/batteries/media/contracts.cjs.map +1 -1
  111. package/batteries/media/contracts.d.ts +93 -2
  112. package/batteries/media/contracts.mjs.map +1 -1
  113. package/batteries/media/engines/execa_executor.cjs +285 -13
  114. package/batteries/media/engines/execa_executor.cjs.map +1 -1
  115. package/batteries/media/engines/execa_executor.d.ts +113 -8
  116. package/batteries/media/engines/execa_executor.mjs +285 -13
  117. package/batteries/media/engines/execa_executor.mjs.map +1 -1
  118. package/batteries/media/forge.cjs +4 -4
  119. package/batteries/media/forge.mjs +4 -4
  120. package/batteries/media/lint.cjs +1 -1
  121. package/batteries/media/lint.mjs +1 -1
  122. package/batteries/media.cjs +1 -1
  123. package/batteries/orchestration/dispatch_reasoner.cjs +4 -4
  124. package/batteries/orchestration/dispatch_reasoner.mjs +4 -4
  125. package/batteries/orchestration/executor.cjs +2 -2
  126. package/batteries/orchestration/executor.mjs +2 -2
  127. package/batteries/orchestration/forge.cjs +3 -3
  128. package/batteries/orchestration/forge.mjs +3 -3
  129. package/batteries/orchestration/validation.cjs +2 -2
  130. package/batteries/orchestration/validation.mjs +2 -2
  131. package/batteries/orchestration.cjs +3 -3
  132. package/batteries/orchestration.mjs +3 -3
  133. package/batteries/sandbox/contracts/policy_enforcer.d.ts +12 -6
  134. package/batteries/sandbox/executor.d.ts +28 -10
  135. package/batteries/sandbox/js.cjs +1 -1
  136. package/batteries/sandbox/js.mjs +1 -1
  137. package/batteries/sandbox/node/index.d.ts +1 -1
  138. package/batteries/sandbox/node/srt_enforcer.d.ts +74 -0
  139. package/batteries/sandbox/node.cjs +98 -5
  140. package/batteries/sandbox/node.cjs.map +1 -1
  141. package/batteries/sandbox/node.mjs +98 -6
  142. package/batteries/sandbox/node.mjs.map +1 -1
  143. package/batteries/sandbox/tools.cjs +1 -1
  144. package/batteries/sandbox/tools.mjs +1 -1
  145. package/batteries/sandbox.cjs +13 -13
  146. package/batteries/sandbox.cjs.map +1 -1
  147. package/batteries/sandbox.mjs +13 -13
  148. package/batteries/sandbox.mjs.map +1 -1
  149. package/batteries/skills/in_memory.cjs +1 -1
  150. package/batteries/skills.cjs +10 -10
  151. package/batteries/skills.mjs +9 -9
  152. package/batteries/tools/_shared.cjs +1 -1
  153. package/batteries/tools/_shared.mjs +1 -1
  154. package/batteries/tools/color.cjs +2 -2
  155. package/batteries/tools/color.mjs +2 -2
  156. package/batteries/tools/comparison.cjs +2 -2
  157. package/batteries/tools/comparison.mjs +2 -2
  158. package/batteries/tools/data_structure.cjs +2 -2
  159. package/batteries/tools/data_structure.mjs +2 -2
  160. package/batteries/tools/datetime_extended.cjs +3 -3
  161. package/batteries/tools/datetime_extended.mjs +3 -3
  162. package/batteries/tools/datetime_math.cjs +3 -3
  163. package/batteries/tools/datetime_math.mjs +3 -3
  164. package/batteries/tools/encoding.cjs +2 -2
  165. package/batteries/tools/encoding.mjs +2 -2
  166. package/batteries/tools/formatting.cjs +2 -2
  167. package/batteries/tools/formatting.mjs +2 -2
  168. package/batteries/tools/geo_basics.cjs +2 -2
  169. package/batteries/tools/geo_basics.mjs +2 -2
  170. package/batteries/tools/math.cjs +2 -2
  171. package/batteries/tools/math.mjs +2 -2
  172. package/batteries/tools/memory.cjs +5 -5
  173. package/batteries/tools/memory.mjs +5 -5
  174. package/batteries/tools/parsing.cjs +3 -3
  175. package/batteries/tools/parsing.mjs +3 -3
  176. package/batteries/tools/retrievables.cjs +5 -5
  177. package/batteries/tools/retrievables.mjs +5 -5
  178. package/batteries/tools/scrapper.cjs +1 -1
  179. package/batteries/tools/scrapper.mjs +1 -1
  180. package/batteries/tools/searxng.cjs +1 -1
  181. package/batteries/tools/searxng.mjs +1 -1
  182. package/batteries/tools/standing_instructions.cjs +3 -3
  183. package/batteries/tools/standing_instructions.mjs +3 -3
  184. package/batteries/tools/statistics.cjs +3 -3
  185. package/batteries/tools/statistics.mjs +3 -3
  186. package/batteries/tools/string_processing.cjs +2 -2
  187. package/batteries/tools/string_processing.mjs +2 -2
  188. package/batteries/tools/structured_data.cjs +2 -2
  189. package/batteries/tools/structured_data.mjs +2 -2
  190. package/batteries/tools/text_analysis.cjs +3 -3
  191. package/batteries/tools/text_analysis.mjs +3 -3
  192. package/batteries/tools/text_comparison.cjs +2 -2
  193. package/batteries/tools/text_comparison.mjs +2 -2
  194. package/batteries/tools/time.cjs +3 -3
  195. package/batteries/tools/time.mjs +3 -3
  196. package/batteries/tools/unit_conversion.cjs +2 -2
  197. package/batteries/tools/unit_conversion.mjs +2 -2
  198. package/batteries/tools.cjs +2 -2
  199. package/batteries/tools.mjs +2 -2
  200. package/batteries/validation.cjs +4 -4
  201. package/batteries/validation.mjs +4 -4
  202. package/batteries/vector/chroma.cjs +1 -1
  203. package/batteries/vector/chroma.mjs +1 -1
  204. package/batteries/vector/clickhouse.cjs +1 -1
  205. package/batteries/vector/clickhouse.mjs +1 -1
  206. package/batteries/vector/cloudflare.cjs +1 -1
  207. package/batteries/vector/cloudflare.mjs +1 -1
  208. package/batteries/vector/couchbase.cjs +1 -1
  209. package/batteries/vector/couchbase.mjs +1 -1
  210. package/batteries/vector/duckdb.cjs +1 -1
  211. package/batteries/vector/duckdb.mjs +1 -1
  212. package/batteries/vector/elasticsearch.cjs +1 -1
  213. package/batteries/vector/elasticsearch.mjs +1 -1
  214. package/batteries/vector/hnswlib.cjs +1 -1
  215. package/batteries/vector/hnswlib.mjs +1 -1
  216. package/batteries/vector/in_memory.cjs +1 -1
  217. package/batteries/vector/in_memory.mjs +1 -1
  218. package/batteries/vector/lancedb.cjs +1 -1
  219. package/batteries/vector/lancedb.mjs +1 -1
  220. package/batteries/vector/mariadb.cjs +1 -1
  221. package/batteries/vector/mariadb.mjs +1 -1
  222. package/batteries/vector/milvus.cjs +1 -1
  223. package/batteries/vector/milvus.mjs +1 -1
  224. package/batteries/vector/opensearch.cjs +1 -1
  225. package/batteries/vector/opensearch.mjs +1 -1
  226. package/batteries/vector/oracle23ai.cjs +1 -1
  227. package/batteries/vector/oracle23ai.mjs +1 -1
  228. package/batteries/vector/orama.cjs +1 -1
  229. package/batteries/vector/orama.mjs +1 -1
  230. package/batteries/vector/pgvector.cjs +1 -1
  231. package/batteries/vector/pgvector.mjs +1 -1
  232. package/batteries/vector/pinecone.cjs +1 -1
  233. package/batteries/vector/pinecone.mjs +1 -1
  234. package/batteries/vector/qdrant.cjs +1 -1
  235. package/batteries/vector/qdrant.mjs +1 -1
  236. package/batteries/vector/redis.cjs +1 -1
  237. package/batteries/vector/redis.mjs +1 -1
  238. package/batteries/vector/retrievable.cjs +1 -1
  239. package/batteries/vector/retrievable.mjs +1 -1
  240. package/batteries/vector/s3vectors.cjs +1 -1
  241. package/batteries/vector/s3vectors.mjs +1 -1
  242. package/batteries/vector/sqlite_vec.cjs +1 -1
  243. package/batteries/vector/sqlite_vec.mjs +1 -1
  244. package/batteries/vector/typesense.cjs +1 -1
  245. package/batteries/vector/typesense.mjs +1 -1
  246. package/batteries/vector/vespa.cjs +1 -1
  247. package/batteries/vector/vespa.mjs +1 -1
  248. package/batteries/vector/weaviate.cjs +1 -1
  249. package/batteries/vector/weaviate.mjs +1 -1
  250. package/batteries/vector.cjs +2 -2
  251. package/batteries/vector.mjs +2 -2
  252. package/batteries.cjs +9 -9
  253. package/batteries.mjs +9 -9
  254. package/{chat_common-DKw8FDol.mjs → chat_common-CeoHwSsz.mjs} +2 -2
  255. package/{chat_common-DKw8FDol.mjs.map → chat_common-CeoHwSsz.mjs.map} +1 -1
  256. package/{chat_common-vSxDBGgr.cjs → chat_common-DlIK1IAn.cjs} +2 -2
  257. package/{chat_common-vSxDBGgr.cjs.map → chat_common-DlIK1IAn.cjs.map} +1 -1
  258. package/{common-oI1niK9Z.mjs → common-B5maOoF_.mjs} +7 -7
  259. package/{common-oI1niK9Z.mjs.map → common-B5maOoF_.mjs.map} +1 -1
  260. package/{common-BcB05Isq.cjs → common-joo6vLu-.cjs} +7 -7
  261. package/{common-BcB05Isq.cjs.map → common-joo6vLu-.cjs.map} +1 -1
  262. package/common.cjs +7 -7
  263. package/common.mjs +7 -7
  264. package/{dispatch_runner-CTAI0RSs.cjs → dispatch_runner-BTaUtdtO.cjs} +5 -5
  265. package/{dispatch_runner-CTAI0RSs.cjs.map → dispatch_runner-BTaUtdtO.cjs.map} +1 -1
  266. package/{dispatch_runner-BZDXUe0G.mjs → dispatch_runner-DO7jo_gl.mjs} +5 -5
  267. package/{dispatch_runner-BZDXUe0G.mjs.map → dispatch_runner-DO7jo_gl.mjs.map} +1 -1
  268. package/dispatch_runner.cjs +1 -1
  269. package/dispatch_runner.mjs +1 -1
  270. package/{ecmascript-DOv8gVQ5.cjs → ecmascript-ChvxTCXz.cjs} +3 -3
  271. package/{ecmascript-DOv8gVQ5.cjs.map → ecmascript-ChvxTCXz.cjs.map} +1 -1
  272. package/{ecmascript-B9Z2C24U.mjs → ecmascript-bgwVyZG1.mjs} +3 -3
  273. package/{ecmascript-B9Z2C24U.mjs.map → ecmascript-bgwVyZG1.mjs.map} +1 -1
  274. package/eslint/rules.cjs +1 -1
  275. package/eslint/rules.mjs +1 -1
  276. package/eslint.cjs +2 -2
  277. package/eslint.mjs +2 -2
  278. package/exceptions.cjs +1 -1
  279. package/exceptions.mjs +1 -1
  280. package/forge.cjs +2 -2
  281. package/forge.mjs +2 -2
  282. package/guards.cjs +7 -7
  283. package/guards.mjs +7 -7
  284. package/{helpers-mbn_EsDV.mjs → helpers-C1T0DV8Q.mjs} +3 -3
  285. package/{helpers-mbn_EsDV.mjs.map → helpers-C1T0DV8Q.mjs.map} +1 -1
  286. package/{helpers-CiZnHmxC.cjs → helpers-D6ebO8Vc.cjs} +3 -3
  287. package/{helpers-CiZnHmxC.cjs.map → helpers-D6ebO8Vc.cjs.map} +1 -1
  288. package/index.cjs +10 -10
  289. package/index.mjs +10 -10
  290. package/{manifest-BPcrFRN4.cjs → manifest-DPYWN15l.cjs} +2 -2
  291. package/{manifest-BPcrFRN4.cjs.map → manifest-DPYWN15l.cjs.map} +1 -1
  292. package/mcp/adk-docs-corpus.json +2 -2
  293. package/package.json +407 -407
  294. package/{retrievable-CXTAUuuv.mjs → retrievable-CrGKx4sc.mjs} +3 -3
  295. package/{retrievable-CXTAUuuv.mjs.map → retrievable-CrGKx4sc.mjs.map} +1 -1
  296. package/{retrievable-BOuQSDHF.cjs → retrievable-DVkAglIv.cjs} +3 -3
  297. package/{retrievable-BOuQSDHF.cjs.map → retrievable-DVkAglIv.cjs.map} +1 -1
  298. package/{scrapper-lXnFGDi0.cjs → scrapper-Boc6kq2v.cjs} +4 -4
  299. package/{scrapper-lXnFGDi0.cjs.map → scrapper-Boc6kq2v.cjs.map} +1 -1
  300. package/{scrapper-BCdUm8c8.mjs → scrapper-D2Gy9Jhv.mjs} +4 -4
  301. package/{scrapper-BCdUm8c8.mjs.map → scrapper-D2Gy9Jhv.mjs.map} +1 -1
  302. package/{searxng-N7qu6dA-.cjs → searxng-DOy3eBDH.cjs} +4 -4
  303. package/{searxng-N7qu6dA-.cjs.map → searxng-DOy3eBDH.cjs.map} +1 -1
  304. package/{searxng-B-LdaVUP.mjs → searxng-cCb0lAcN.mjs} +4 -4
  305. package/{searxng-B-LdaVUP.mjs.map → searxng-cCb0lAcN.mjs.map} +1 -1
  306. package/server.json +2 -2
  307. package/skills/adk-assembly/SKILL.md +2 -2
  308. package/{spooled_artifact-Bw_7swIp.mjs → spooled_artifact-BkOe4-j-.mjs} +731 -731
  309. package/spooled_artifact-BkOe4-j-.mjs.map +1 -0
  310. package/{spooled_artifact-DZXsP4s1.cjs → spooled_artifact-BoYsldvO.cjs} +730 -730
  311. package/spooled_artifact-BoYsldvO.cjs.map +1 -0
  312. package/spooled_artifact.cjs +2 -2
  313. package/spooled_artifact.mjs +2 -2
  314. package/{spooled_markdown_artifact-vd6eNtIP.mjs → spooled_markdown_artifact-Dnl-lCGv.mjs} +3 -3
  315. package/{spooled_markdown_artifact-vd6eNtIP.mjs.map → spooled_markdown_artifact-Dnl-lCGv.mjs.map} +1 -1
  316. package/{spooled_markdown_artifact-Bo0u8cRS.cjs → spooled_markdown_artifact-DzbydBel.cjs} +3 -3
  317. package/{spooled_markdown_artifact-Bo0u8cRS.cjs.map → spooled_markdown_artifact-DzbydBel.cjs.map} +1 -1
  318. package/{thought-CxSaF6Xf.mjs → thought-BrQt6HAb.mjs} +3 -3
  319. package/{thought-CxSaF6Xf.mjs.map → thought-BrQt6HAb.mjs.map} +1 -1
  320. package/{thought-C12mqaKQ.cjs → thought-CXsVh5hS.cjs} +3 -3
  321. package/{thought-C12mqaKQ.cjs.map → thought-CXsVh5hS.cjs.map} +1 -1
  322. package/{tokenizable-BcodRtoW.cjs → tokenizable-DDIdXbJN.cjs} +29 -29
  323. package/{tokenizable-BcodRtoW.cjs.map → tokenizable-DDIdXbJN.cjs.map} +1 -1
  324. package/{tokenizable-VB4Av8GF.mjs → tokenizable-xPXj1AQX.mjs} +30 -30
  325. package/{tokenizable-VB4Av8GF.mjs.map → tokenizable-xPXj1AQX.mjs.map} +1 -1
  326. package/{tool_call-Cfaj-6zK.mjs → tool_call-8crmZsO8.mjs} +4 -4
  327. package/{tool_call-Cfaj-6zK.mjs.map → tool_call-8crmZsO8.mjs.map} +1 -1
  328. package/{tool_call-CsBOpKsg.cjs → tool_call-NvQcPf5d.cjs} +4 -4
  329. package/{tool_call-CsBOpKsg.cjs.map → tool_call-NvQcPf5d.cjs.map} +1 -1
  330. package/{tools-BjHXlDlV.cjs → tools-BHc8qB5I.cjs} +6 -6
  331. package/{tools-BjHXlDlV.cjs.map → tools-BHc8qB5I.cjs.map} +1 -1
  332. package/{tools-Vkfht7mU.mjs → tools-geIlta3C.mjs} +6 -6
  333. package/{tools-Vkfht7mU.mjs.map → tools-geIlta3C.mjs.map} +1 -1
  334. package/{toon-BSTQnHed.mjs → toon-BA9Q7NHG.mjs} +5 -5
  335. package/{toon-BSTQnHed.mjs.map → toon-BA9Q7NHG.mjs.map} +1 -1
  336. package/{toon-5c9ceKiU.cjs → toon-C8IFssRi.cjs} +5 -5
  337. package/{toon-5c9ceKiU.cjs.map → toon-C8IFssRi.cjs.map} +1 -1
  338. package/{turn_runner--tsMLLx4.cjs → turn_runner-A-vpLUvj.cjs} +5 -5
  339. package/{turn_runner--tsMLLx4.cjs.map → turn_runner-A-vpLUvj.cjs.map} +1 -1
  340. package/{turn_runner-BHHD6h77.mjs → turn_runner-BmVXcBZ2.mjs} +5 -5
  341. package/{turn_runner-BHHD6h77.mjs.map → turn_runner-BmVXcBZ2.mjs.map} +1 -1
  342. package/turn_runner.cjs +1 -1
  343. package/turn_runner.mjs +1 -1
  344. package/{xml-CYseDztH.mjs → xml-B1JIGLpU.mjs} +5 -5
  345. package/{xml-CYseDztH.mjs.map → xml-B1JIGLpU.mjs.map} +1 -1
  346. package/{xml-DTOnPN52.cjs → xml-Cu7ZvgBQ.cjs} +5 -5
  347. package/{xml-DTOnPN52.cjs.map → xml-Cu7ZvgBQ.cjs.map} +1 -1
  348. package/{yaml-BPBoiOjx.mjs → yaml-1mP4uxdf.mjs} +5 -5
  349. package/{yaml-BPBoiOjx.mjs.map → yaml-1mP4uxdf.mjs.map} +1 -1
  350. package/{yaml-CMrbNWLc.cjs → yaml-BlB29N68.cjs} +5 -5
  351. package/{yaml-CMrbNWLc.cjs.map → yaml-BlB29N68.cjs.map} +1 -1
  352. package/artifact_methods-Cg0go7Q4.mjs +0 -1
  353. package/artifact_methods-Dtf4-3C-.cjs +0 -1
  354. package/spooled_artifact-Bw_7swIp.mjs.map +0 -1
  355. package/spooled_artifact-DZXsP4s1.cjs.map +0 -1
@@ -19,6 +19,173 @@ const require_exceptions = require("../../../exceptions-Bc1s_ld5.cjs");
19
19
  * this one. The paired `ScratchWorkspace` must produce paths this executor can open; for the
20
20
  * local-process case, the bundled `fs_workspace` is the natural pair.
21
21
  */
22
+ /**
23
+ * Terminate a spawned process group: the direct child AND everything it wrapped.
24
+ *
25
+ * @remarks
26
+ * ONLY for `detached: true`. When the executor spawns `detached: false` the child is not a group
27
+ * leader, so `-pid` names no group and the group paths (this function and {@link groupAlive}) are
28
+ * never used — signalling that way would ESRCH and, worse, make the liveness probe report the
29
+ * group as dead so a `SIGKILL` escalation silently never fires.
30
+ *
31
+ * `process.kill(-pid, sig)` signals the whole GROUP the child leads (it is its own group leader
32
+ * because the child was spawned `detached`); a child that has already been reaped makes that throw
33
+ * `ESRCH`, which is fine — nothing is left to kill, so the per-process fallback still runs and
34
+ * fails equally quietly. Absent `pid` (spawn failure, or a BYO `ExecaLike` that does not expose
35
+ * one) falls back to execa's own `kill`, which is still correct for the direct child.
36
+ */
37
+ var killGroup = (pid, signal, fallback) => {
38
+ if (pid !== void 0) try {
39
+ process.kill(-pid, signal);
40
+ return;
41
+ } catch {}
42
+ fallback();
43
+ };
44
+ /**
45
+ * Whether the process group led by `pid` still has members.
46
+ *
47
+ * @remarks
48
+ * Only meaningful for a `detached: true` child (the group it leads). The `detached: false` path
49
+ * probes the direct child instead, see {@link childAlive}.
50
+ *
51
+ * Signal `0` performs the permission/existence probe without delivering anything. The deadline
52
+ * probe guards an in-flight SIGKILL escalation against an already-gone target.
53
+ */
54
+ var groupAlive = (pid) => {
55
+ try {
56
+ process.kill(-pid, 0);
57
+ return true;
58
+ } catch {
59
+ return false;
60
+ }
61
+ };
62
+ /**
63
+ * Whether the DIRECT child `pid` is still running — the `detached: false` counterpart of
64
+ * {@link groupAlive}.
65
+ *
66
+ * @remarks
67
+ * Signal `0` with a POSITIVE pid probes that one process, which is exactly the target the
68
+ * non-detached path signals; a negative pid would probe a group the child does not lead.
69
+ */
70
+ var childAlive = (pid) => {
71
+ try {
72
+ process.kill(pid, 0);
73
+ return true;
74
+ } catch {
75
+ return false;
76
+ }
77
+ };
78
+ /**
79
+ * The escalation clock: MONOTONIC milliseconds, so a wall-clock (NTP) step can neither move a
80
+ * deadline nor strand a timer that is waiting for one.
81
+ *
82
+ * @remarks
83
+ * `performance.now()` is the monotonic clock the runtime exposes in Node (>=16) and in every
84
+ * browser bundle, and it advances with the timer heap — which is exactly the property the
85
+ * deadline timer needs. `Date.now()` is deliberately NOT used anywhere in the escalation: a
86
+ * backwards wall-clock step (or a timer firing a fraction of a millisecond before the wall-clock
87
+ * deadline it was scheduled for) makes a wall comparison say "not due" at a moment when nothing
88
+ * will ever re-check it.
89
+ */
90
+ var monotonicNow = () => performance.now();
91
+ /** Probe cadence while settlement is held or post-return polling is enabled. */
92
+ var ESCALATION_POLL_MS = 100;
93
+ /**
94
+ * `unref` a timer so it cannot keep the event loop alive on its own account.
95
+ *
96
+ * @remarks
97
+ * Node's `Timeout` always has `unref`; the shape check covers exotic runtimes without holding the
98
+ * process open on them.
99
+ */
100
+ var MAX_TIMER_DELAY_MS = 2147483647;
101
+ var unrefTimer = (timer) => {
102
+ if (typeof timer?.unref === "function") timer.unref();
103
+ };
104
+ /**
105
+ * Build the `SIGKILL` escalation state machine for one invocation.
106
+ *
107
+ * @remarks
108
+ * The probe and kill are injected so the machine serves both termination stories: the process
109
+ * group and the direct child. All modes share one deadline and terminal-state latch.
110
+ */
111
+ var createEscalation = (config) => {
112
+ let state = "armed";
113
+ /**
114
+ * When the `SIGKILL` is due, in monotonic-clock milliseconds — fixed at `arm()` time, never
115
+ * re-based on settlement.
116
+ */
117
+ let deadline = 0;
118
+ let deadlineTimer;
119
+ let interval;
120
+ let resolveDone;
121
+ const done = new Promise((resolve) => {
122
+ resolveDone = resolve;
123
+ });
124
+ let waiting = false;
125
+ const stop = (next) => {
126
+ if (state !== "armed") return;
127
+ state = next;
128
+ if (deadlineTimer !== void 0) {
129
+ clearTimeout(deadlineTimer);
130
+ deadlineTimer = void 0;
131
+ }
132
+ if (interval !== void 0) {
133
+ clearInterval(interval);
134
+ interval = void 0;
135
+ }
136
+ resolveDone();
137
+ };
138
+ /**
139
+ * At the deadline, cancel if the target is already gone; otherwise send one `SIGKILL`.
140
+ *
141
+ * @remarks
142
+ * A timer can fire before the monotonic deadline (for example, due to sub-millisecond rounding).
143
+ * In that case, re-arm it for the remaining time; otherwise, cancel if the target is gone or
144
+ * send the one `SIGKILL`.
145
+ */
146
+ const check = () => {
147
+ if (state !== "armed") return;
148
+ if (!config.alive()) return stop("cancelled");
149
+ const remaining = deadline - monotonicNow();
150
+ if (remaining > 0) {
151
+ if (deadlineTimer !== void 0) clearTimeout(deadlineTimer);
152
+ deadlineTimer = setTimeout(check, Math.min(remaining, MAX_TIMER_DELAY_MS));
153
+ if (!waiting) unrefTimer(deadlineTimer);
154
+ return;
155
+ }
156
+ config.kill();
157
+ stop("fired");
158
+ };
159
+ return {
160
+ arm: () => {
161
+ if (state !== "armed") return;
162
+ deadline = monotonicNow() + config.delay;
163
+ deadlineTimer = setTimeout(check, Math.min(config.delay, MAX_TIMER_DELAY_MS));
164
+ unrefTimer(deadlineTimer);
165
+ },
166
+ wait: () => {
167
+ if (state !== "armed") return Promise.resolve();
168
+ waiting = true;
169
+ deadlineTimer?.ref?.();
170
+ const probe = () => {
171
+ if (state !== "armed") return;
172
+ if (!config.alive()) stop("cancelled");
173
+ };
174
+ probe();
175
+ if (state === "armed" && interval === void 0) interval = setInterval(probe, ESCALATION_POLL_MS);
176
+ return done;
177
+ },
178
+ poll: () => {
179
+ if (state !== "armed") return;
180
+ check();
181
+ if (state === "armed" && interval === void 0) {
182
+ interval = setInterval(check, ESCALATION_POLL_MS);
183
+ unrefTimer(interval);
184
+ }
185
+ },
186
+ cancel: () => stop("cancelled")
187
+ };
188
+ };
22
189
  var resolveExeca = async (supplied) => {
23
190
  let value = supplied ?? (() => import("execa"));
24
191
  if (typeof value === "function" && !("exec" in value)) try {
@@ -33,7 +200,31 @@ var resolveExeca = async (supplied) => {
33
200
  /**
34
201
  * Construct the bundled local-process {@link BinaryExecutor}.
35
202
  *
36
- * @param options - The execa resolver and defaults.
203
+ * @remarks
204
+ * Termination follows the `detached` flag on every abort and timeout path. With `detached: true`
205
+ * (the default) it is a PROCESS-GROUP kill: the child is spawned detached (its own group leader)
206
+ * and `killGroup` — `kill(-pid, killSignal)` — reaches everything behind a wrapper (sandbox →
207
+ * shell → command). Once termination begins, `settleEscalation` defaults to `'wait'`: settlement
208
+ * waits until the group is empty or the one SIGKILL is sent, at most the remaining escalation
209
+ * delay. `'cancel'` returns fastest but may leave survivors; `'poll'` returns fastest and watches
210
+ * survivors after return with unref'd timers. Both probing modes have a narrow PGID-reuse risk
211
+ * between probes; wait bounds it to before return. Normal exits never wait or poll.
212
+ * With `detached: false` only the DIRECT child is signalled (`subprocess.kill`) and probed
213
+ * (`process.kill(pid, 0)`); all modes cancel at settlement because that child is already reaped.
214
+ * execa's own abort machinery still runs underneath: it kills the direct child at roughly
215
+ * the same moment, so the promise settles whichever mechanism wins the race — in group mode the
216
+ * group signal is what the WRAPPER and its grandchildren die from. execa's `forceKillAfterDelay`
217
+ * is forwarded as given so its own kill escalates identically when IT is the one that fires.
218
+ * The executor owns the timeout (never forwarded to execa), so every timeout terminates the group
219
+ * or direct child through the same escalation path. Its deadline timer stays ref'd until settlement.
220
+ * `0` and `Infinity` mean no deadline. Finite timeouts above 2,147,483,647 milliseconds also
221
+ * disable the deadline rather than overflowing Node's timer into an immediate kill. Negative
222
+ * values and `NaN` reject with a `TypeError` before spawning, as execa 9 did.
223
+ * Non-zero exits are DATA: `reject: false` keeps execa from throwing and every settlement —
224
+ * spawn failure, timeout, abort, non-zero exit — lands in the returned record, never a rejection.
225
+ * `signalCode` is surfaced additively when execa reports the terminating signal.
226
+ *
227
+ * @param options - The execa resolver and defaults (timeout, kill signal/escalation, detached).
37
228
  * @returns A `BinaryExecutor` running invocations as local child processes.
38
229
  */
39
230
  var execaExecutor = (options = {}) => {
@@ -42,19 +233,100 @@ var execaExecutor = (options = {}) => {
42
233
  execaPromise ??= resolveExeca(options.execa);
43
234
  return execaPromise;
44
235
  };
236
+ const detached = options.detached ?? true;
45
237
  return { async exec(invocation) {
46
- const result = await (await getExeca())(invocation.cmd, invocation.args, {
47
- timeout: invocation.timeoutMs ?? options.defaultTimeoutMs ?? 12e4,
48
- cancelSignal: invocation.signal,
49
- reject: false,
50
- stripFinalNewline: true
51
- });
52
- return {
53
- exitCode: result.exitCode ?? -1,
54
- stdout: typeof result.stdout === "string" ? result.stdout : "",
55
- stderr: typeof result.stderr === "string" ? result.stderr : "",
56
- failed: result.failed
57
- };
238
+ const execa = await getExeca();
239
+ const pidOf = (target) => target.pid;
240
+ const signal = invocation.killSignal ?? options.defaultKillSignal ?? "SIGTERM";
241
+ const forceKillAfterDelay = invocation.forceKillAfterDelay !== void 0 ? invocation.forceKillAfterDelay : options.defaultForceKillAfterDelay ?? 5e3;
242
+ const timeout = invocation.timeoutMs ?? options.defaultTimeoutMs ?? 12e4;
243
+ const settleEscalation = invocation.settleEscalation ?? options.defaultSettleEscalation ?? "wait";
244
+ if (settleEscalation !== "wait" && settleEscalation !== "cancel" && settleEscalation !== "poll") throw new TypeError(`Expected settleEscalation to be 'wait', 'cancel', or 'poll', got ${String(settleEscalation)}`);
245
+ if (Number.isNaN(timeout) || timeout < 0) throw new TypeError(`Expected timeoutMs to be a non-negative number, got ${timeout}`);
246
+ if (forceKillAfterDelay !== false && (Number.isNaN(forceKillAfterDelay) || forceKillAfterDelay < 0)) throw new TypeError(`Expected forceKillAfterDelay to be a non-negative number, got ${forceKillAfterDelay}`);
247
+ const execaForceKillAfterDelay = forceKillAfterDelay === false || forceKillAfterDelay === Infinity || forceKillAfterDelay > MAX_TIMER_DELAY_MS ? false : forceKillAfterDelay;
248
+ let terminate;
249
+ /** The `SIGKILL` escalation for this invocation, including its settlement policy. */
250
+ let escalation;
251
+ /** The executor-owned deadline for group (or direct-child) termination. */
252
+ let deadlineTimer;
253
+ let subprocess;
254
+ let terminating = false;
255
+ let timedOut = false;
256
+ /** Set once the invocation has settled, preventing any further termination. */
257
+ let settled = false;
258
+ try {
259
+ subprocess = execa(invocation.cmd, invocation.args, {
260
+ cancelSignal: invocation.signal,
261
+ reject: false,
262
+ stripFinalNewline: true,
263
+ ...invocation.cwd === void 0 ? {} : { cwd: invocation.cwd },
264
+ ...invocation.env === void 0 ? {} : { env: invocation.env },
265
+ extendEnv: invocation.extendEnv ?? true,
266
+ killSignal: signal,
267
+ forceKillAfterDelay: execaForceKillAfterDelay,
268
+ detached
269
+ });
270
+ terminate = () => {
271
+ if (settled || terminating || !subprocess) return;
272
+ terminating = true;
273
+ const pid = pidOf(subprocess);
274
+ const child = subprocess;
275
+ if (detached && pid !== void 0) killGroup(pid, signal, () => {
276
+ try {
277
+ child?.kill(signal);
278
+ } catch {}
279
+ });
280
+ else try {
281
+ child.kill(signal);
282
+ } catch {}
283
+ if (forceKillAfterDelay !== false && Number.isFinite(forceKillAfterDelay) && pid !== void 0) {
284
+ escalation = createEscalation({
285
+ delay: forceKillAfterDelay,
286
+ alive: () => detached ? groupAlive(pid) : childAlive(pid),
287
+ kill: () => {
288
+ if (detached) try {
289
+ process.kill(-pid, "SIGKILL");
290
+ } catch {
291
+ try {
292
+ child.kill("SIGKILL");
293
+ } catch {}
294
+ }
295
+ else try {
296
+ child.kill("SIGKILL");
297
+ } catch {}
298
+ }
299
+ });
300
+ escalation.arm();
301
+ }
302
+ };
303
+ if (invocation.signal) if (invocation.signal.aborted) terminate();
304
+ else invocation.signal.addEventListener("abort", terminate, { once: true });
305
+ if (!terminating && Number.isFinite(timeout) && timeout > 0 && timeout <= MAX_TIMER_DELAY_MS) deadlineTimer = setTimeout(() => {
306
+ timedOut = true;
307
+ terminate?.();
308
+ }, timeout);
309
+ const result = await subprocess;
310
+ return {
311
+ exitCode: result.exitCode ?? -1,
312
+ stdout: typeof result.stdout === "string" ? result.stdout : "",
313
+ stderr: typeof result.stderr === "string" ? result.stderr : "",
314
+ failed: result.failed || timedOut,
315
+ ...typeof result.signal === "string" ? { signalCode: result.signal } : {}
316
+ };
317
+ } finally {
318
+ settled = true;
319
+ if (deadlineTimer !== void 0) {
320
+ clearTimeout(deadlineTimer);
321
+ deadlineTimer = void 0;
322
+ }
323
+ if (terminate && invocation.signal) invocation.signal.removeEventListener("abort", terminate);
324
+ terminate = void 0;
325
+ if (escalation !== void 0 && terminating) if (settleEscalation === "wait" && detached) await escalation.wait();
326
+ else if (settleEscalation === "poll" && detached) escalation.poll();
327
+ else escalation.cancel();
328
+ else escalation?.cancel();
329
+ }
58
330
  } };
59
331
  };
60
332
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"execa_executor.cjs","names":[],"sources":["../../../../src/batteries/media/engines/execa_executor.ts"],"sourcesContent":["/**\n * A {@link @nhtio/adk/batteries/media/contracts!BinaryExecutor} implementation that runs\n * invocations as local child processes via execa.\n *\n * @module @nhtio/adk/batteries/media/engines/execa_executor\n *\n * @remarks\n * The bundled local-process executor. `execa` is an optional peer dependency acquired through\n * an async resolver (default: a lazy dynamic import) — importing this module pulls nothing;\n * constructing the executor is what resolves the peer, and only on first `exec`.\n *\n * Process execution is a movable seam: anything implementing the `BinaryExecutor` contract —\n * a remote runner, a sandbox, a container shim — composes into binary engines exactly like\n * this one. The paired `ScratchWorkspace` must produce paths this executor can open; for the\n * local-process case, the bundled `fs_workspace` is the natural pair.\n */\n\nimport { isError, isObject } from '@nhtio/adk/guards'\nimport { E_INVALID_MEDIA_PIPELINE_CONFIG } from '../exceptions'\nimport type { BinaryExecutor, BinaryInvocation, BinaryExecResult } from '../contracts'\n\n/** The slice of execa this executor uses (kept minimal for BYO substitution in tests). */\nexport interface ExecaLike {\n (\n cmd: string,\n args: readonly string[],\n options: {\n timeout?: number\n cancelSignal?: AbortSignal\n reject: false\n stripFinalNewline?: boolean\n }\n ): Promise<{\n exitCode?: number\n stdout?: unknown\n stderr?: unknown\n failed: boolean\n }>\n}\n\n/** Resolver forms accepted for the execa module. */\nexport type ExecaResolver =\n | ExecaLike\n | (() => ExecaLike | { execa: ExecaLike } | Promise<ExecaLike | { execa: ExecaLike }>)\n\n/** Options for {@link execaExecutor}. */\nexport interface ExecaExecutorOptions {\n /**\n * The execa function or an async resolver for it. Defaults to a lazy dynamic import of the\n * `execa` package (optional peer).\n */\n execa?: ExecaResolver\n /** Default timeout applied when an invocation does not specify one. */\n defaultTimeoutMs?: number\n}\n\nconst resolveExeca = async (supplied: ExecaResolver | undefined): Promise<ExecaLike> => {\n let value: unknown = supplied ?? ((): Promise<{ execa: ExecaLike }> => import('execa'))\n if (typeof value === 'function' && !('exec' in (value as object))) {\n try {\n value = await (value as () => unknown)()\n } catch (err) {\n const detail = isError(err) ? err.message : String(err)\n throw new E_INVALID_MEDIA_PIPELINE_CONFIG([\n `execa resolver failed: ${detail} — install the optional peer dependency \"execa\" or supply your own`,\n ])\n }\n }\n if (isObject(value) && 'execa' in value) {\n value = (value as { execa: unknown }).execa\n }\n if (typeof value !== 'function') {\n throw new E_INVALID_MEDIA_PIPELINE_CONFIG(['execa resolver did not resolve to a function'])\n }\n return value as ExecaLike\n}\n\n/**\n * Construct the bundled local-process {@link BinaryExecutor}.\n *\n * @param options - The execa resolver and defaults.\n * @returns A `BinaryExecutor` running invocations as local child processes.\n */\nexport const execaExecutor = (options: ExecaExecutorOptions = {}): BinaryExecutor => {\n let execaPromise: Promise<ExecaLike> | undefined\n const getExeca = (): Promise<ExecaLike> => {\n execaPromise ??= resolveExeca(options.execa)\n return execaPromise\n }\n return {\n async exec(invocation: BinaryInvocation): Promise<BinaryExecResult> {\n const execa = await getExeca()\n const result = await execa(invocation.cmd, invocation.args, {\n timeout: invocation.timeoutMs ?? options.defaultTimeoutMs ?? 120_000,\n cancelSignal: invocation.signal,\n reject: false,\n stripFinalNewline: true,\n })\n return {\n exitCode: result.exitCode ?? -1,\n stdout: typeof result.stdout === 'string' ? result.stdout : '',\n stderr: typeof result.stderr === 'string' ? result.stderr : '',\n failed: result.failed,\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwDA,IAAM,eAAe,OAAO,aAA4D;CACtF,IAAI,QAAiB,mBAAkD,OAAO;CAC9E,IAAI,OAAO,UAAU,cAAc,EAAE,UAAW,QAC9C,IAAI;EACF,QAAQ,MAAO,MAAwB;CACzC,SAAS,KAAK;EAEZ,MAAM,IAAI,mBAAA,gCAAgC,CACxC,0BAFa,eAAA,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,EAEnB,mEACnC,CAAC;CACH;CAEF,IAAI,eAAA,SAAS,KAAK,KAAK,WAAW,OAChC,QAAS,MAA6B;CAExC,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,mBAAA,gCAAgC,CAAC,8CAA8C,CAAC;CAE5F,OAAO;AACT;;;;;;;AAQA,IAAa,iBAAiB,UAAgC,CAAC,MAAsB;CACnF,IAAI;CACJ,MAAM,iBAAqC;EACzC,iBAAiB,aAAa,QAAQ,KAAK;EAC3C,OAAO;CACT;CACA,OAAO,EACL,MAAM,KAAK,YAAyD;EAElE,MAAM,SAAS,OAAM,MADD,SAAS,GACF,WAAW,KAAK,WAAW,MAAM;GAC1D,SAAS,WAAW,aAAa,QAAQ,oBAAoB;GAC7D,cAAc,WAAW;GACzB,QAAQ;GACR,mBAAmB;EACrB,CAAC;EACD,OAAO;GACL,UAAU,OAAO,YAAY;GAC7B,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;GAC5D,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;GAC5D,QAAQ,OAAO;EACjB;CACF,EACF;AACF"}
1
+ {"version":3,"file":"execa_executor.cjs","names":[],"sources":["../../../../src/batteries/media/engines/execa_executor.ts"],"sourcesContent":["/**\n * A {@link @nhtio/adk/batteries/media/contracts!BinaryExecutor} implementation that runs\n * invocations as local child processes via execa.\n *\n * @module @nhtio/adk/batteries/media/engines/execa_executor\n *\n * @remarks\n * The bundled local-process executor. `execa` is an optional peer dependency acquired through\n * an async resolver (default: a lazy dynamic import) — importing this module pulls nothing;\n * constructing the executor is what resolves the peer, and only on first `exec`.\n *\n * Process execution is a movable seam: anything implementing the `BinaryExecutor` contract —\n * a remote runner, a sandbox, a container shim — composes into binary engines exactly like\n * this one. The paired `ScratchWorkspace` must produce paths this executor can open; for the\n * local-process case, the bundled `fs_workspace` is the natural pair.\n */\n\nimport { isError, isObject } from '@nhtio/adk/guards'\nimport { E_INVALID_MEDIA_PIPELINE_CONFIG } from '../exceptions'\nimport type { BinaryExecutor, BinaryInvocation, BinaryExecResult } from '../contracts'\n\n/**\n * The subprocess handle execa returns: promise-shaped AND carrying the live OS process.\n *\n * @remarks\n * Kept minimal for BYO substitution in tests — a consumer may supply any function of this shape\n * instead of execa. The default resolver returns execa's own subprocess, which is a promise with\n * `pid`/`kill` merged in; the group-kill path reads `pid` and only ever calls `kill`, so a\n * hand-rolled fake without them simply falls back to execa's own kill behaviour.\n */\nexport interface ExecaSubprocessLike {\n /** The spawned process id; `undefined` when the process failed to spawn. */\n readonly pid?: number\n /** Send a signal to the process. Execa's own kill honours `forceKillAfterDelay`. */\n kill: (signal?: string) => boolean\n /** The promise-style completion surface (`then`/`catch` merged onto the subprocess). */\n then: Promise<ExecaResultLike>['then']\n /** The promise-style rejection surface. */\n catch: Promise<ExecaResultLike>['catch']\n}\n\n/** The settled result slice this executor reads from execa. */\nexport interface ExecaResultLike {\n /** The process exit code; `undefined` when a signal or spawn failure ended it. */\n exitCode?: number\n /** Captured standard output (execa returns a string by default). */\n stdout?: unknown\n /** Captured standard error. */\n stderr?: unknown\n /** The signal that terminated the process, when one did (execa reports names like `'SIGKILL'`). */\n signal?: unknown\n /** `true` when the invocation failed (non-zero exit, signal kill, timeout, spawn failure). Executor-owned timeouts always report true, even if the process exits 0 after termination. */\n failed: boolean\n}\n\n/** The slice of execa this executor uses (kept minimal for BYO substitution in tests). */\nexport interface ExecaLike {\n (\n cmd: string,\n args: readonly string[],\n options: {\n timeout?: number\n cancelSignal?: AbortSignal\n reject: false\n stripFinalNewline?: boolean\n cwd?: string\n env?: Record<string, string>\n extendEnv?: boolean\n killSignal?: string\n forceKillAfterDelay?: number | false\n detached?: boolean\n }\n ): ExecaSubprocessLike & ExecaResultLike\n}\n\n/** Resolver forms accepted for the execa module. */\nexport type ExecaResolver =\n | ExecaLike\n | (() => ExecaLike | { execa: ExecaLike } | Promise<ExecaLike | { execa: ExecaLike }>)\n\n/** Options for {@link execaExecutor}. */\nexport interface ExecaExecutorOptions {\n /**\n * The execa function or an async resolver for it. Defaults to a lazy dynamic import of the\n * `execa` package (optional peer).\n */\n execa?: ExecaResolver\n /**\n * Default timeout in milliseconds when an invocation does not specify one (default: 120,000).\n * `0`, `Infinity`, and finite values above 2,147,483,647 mean no deadline; negative values and\n * `NaN` reject before spawning.\n */\n defaultTimeoutMs?: number\n /** Default {@link BinaryInvocation.killSignal} applied when an invocation does not specify one. */\n defaultKillSignal?: string\n /**\n * Default {@link BinaryInvocation.forceKillAfterDelay} (milliseconds before `SIGKILL`; `false`\n * or `Infinity` disables escalation) applied when an invocation does not specify one.\n *\n * @remarks\n * The delay is measured on the MONOTONIC clock from the moment the first kill signal is sent,\n * and settlement follows {@link ExecaExecutorOptions.defaultSettleEscalation}: wait (default),\n * cancel, or post-return polling. See {@link ExecaExecutorOptions.detached} for process targeting.\n * Because the clock is monotonic, a wall-clock (NTP) step cannot move the deadline or strand\n * the timer. `Infinity` disables escalation, like an infinite timeout disables its deadline.\n */\n defaultForceKillAfterDelay?: number | false\n /**\n * Default settlement policy when abort/timeout has begun and escalation is armed. Defaults to\n * `'wait'`: no survivors, but settlement may be delayed up to the escalation deadline. `'cancel'`\n * returns fastest but survivors may remain; `'poll'` returns fastest and kills a surviving\n * target later, with a narrow PGID-reuse risk after return. Normal exits are unaffected.\n * Wait and poll apply only with finite escalation and a known pid. Both probe numeric PGIDs:\n * empty-and-reused between probes can mis-signal an unrelated group, bounded to the wait window\n * in wait mode. With `detached: false`, settlement cancels escalation in every mode.\n */\n defaultSettleEscalation?: 'wait' | 'cancel' | 'poll'\n /**\n * Whether children are spawned as process-group leaders (`detached: true` in POSIX terms).\n * Defaults to `true`.\n *\n * @remarks\n * Group-kill is the executor's cancellation story: a binary behind a wrapper (sandbox → shell →\n * command) leaves grandchildren, and a plain `kill(pid)` kills only the direct child. Spawning\n * detached costs nothing at run time — the child keeps running like any other — and in exchange\n * every termination path can signal the group (`kill(-pid, …)`) so those grandchildren die too.\n *\n * `detached: false` selects the direct-child termination story instead, and it is not merely a\n * weaker group kill: the child is NOT a process-group leader, so `-pid` does not name its group.\n * Every path then signals the direct child alone (`subprocess.kill(sig)`), probes the direct\n * child's liveness (never the group's), and escalates `SIGKILL` to that same child.\n *\n * Settlement after termination is controlled by `defaultSettleEscalation` (default `'wait'`).\n * `wait` holds settlement until the detached group empties or SIGKILL is sent; `cancel` returns\n * immediately and may leave descendants; `poll` returns immediately and watches the group later.\n */\n detached?: boolean\n}\n\n/**\n * Terminate a spawned process group: the direct child AND everything it wrapped.\n *\n * @remarks\n * ONLY for `detached: true`. When the executor spawns `detached: false` the child is not a group\n * leader, so `-pid` names no group and the group paths (this function and {@link groupAlive}) are\n * never used — signalling that way would ESRCH and, worse, make the liveness probe report the\n * group as dead so a `SIGKILL` escalation silently never fires.\n *\n * `process.kill(-pid, sig)` signals the whole GROUP the child leads (it is its own group leader\n * because the child was spawned `detached`); a child that has already been reaped makes that throw\n * `ESRCH`, which is fine — nothing is left to kill, so the per-process fallback still runs and\n * fails equally quietly. Absent `pid` (spawn failure, or a BYO `ExecaLike` that does not expose\n * one) falls back to execa's own `kill`, which is still correct for the direct child.\n */\nconst killGroup = (pid: number | undefined, signal: string, fallback: () => void): void => {\n if (pid !== undefined) {\n try {\n process.kill(-pid, signal as never)\n return\n } catch {\n // ESRCH (already gone) or a platform without negative-pid semantics: fall through.\n }\n }\n fallback()\n}\n\n/**\n * Whether the process group led by `pid` still has members.\n *\n * @remarks\n * Only meaningful for a `detached: true` child (the group it leads). The `detached: false` path\n * probes the direct child instead, see {@link childAlive}.\n *\n * Signal `0` performs the permission/existence probe without delivering anything. The deadline\n * probe guards an in-flight SIGKILL escalation against an already-gone target.\n */\nconst groupAlive = (pid: number): boolean => {\n try {\n process.kill(-pid, 0)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Whether the DIRECT child `pid` is still running — the `detached: false` counterpart of\n * {@link groupAlive}.\n *\n * @remarks\n * Signal `0` with a POSITIVE pid probes that one process, which is exactly the target the\n * non-detached path signals; a negative pid would probe a group the child does not lead.\n */\nconst childAlive = (pid: number): boolean => {\n try {\n process.kill(pid, 0)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * The escalation clock: MONOTONIC milliseconds, so a wall-clock (NTP) step can neither move a\n * deadline nor strand a timer that is waiting for one.\n *\n * @remarks\n * `performance.now()` is the monotonic clock the runtime exposes in Node (>=16) and in every\n * browser bundle, and it advances with the timer heap — which is exactly the property the\n * deadline timer needs. `Date.now()` is deliberately NOT used anywhere in the escalation: a\n * backwards wall-clock step (or a timer firing a fraction of a millisecond before the wall-clock\n * deadline it was scheduled for) makes a wall comparison say \"not due\" at a moment when nothing\n * will ever re-check it.\n */\nconst monotonicNow = (): number => performance.now()\n\n/** Probe cadence while settlement is held or post-return polling is enabled. */\nconst ESCALATION_POLL_MS = 100\n\n/** The terminal states of an escalation: `armed` becomes `cancelled` or `fired`, never both. */\ntype EscalationState = 'armed' | 'cancelled' | 'fired'\n\n/**\n * The one-shot `SIGKILL` escalation for a single invocation.\n *\n * @remarks\n * A monotonic deadline timer drives escalation; wait and poll add liveness probes at settlement.\n * An early timer fire re-arms for the remaining time. Cancellation and firing are terminal.\n * Wait timers are ref'd; in-flight and post-return poll timers are unref'd.\n */\ninterface Escalation {\n /** Start the deadline timer, `delay` monotonic-clock milliseconds from now. */\n arm(): void\n /** Wait mode: keep probing until empty or the one SIGKILL is sent. */\n wait(): Promise<void>\n /** Poll mode: probe after return, latching off once empty. */\n poll(): void\n /** Cancel permanently; nothing is signalled after this. */\n cancel(): void\n}\n\n/**\n * `unref` a timer so it cannot keep the event loop alive on its own account.\n *\n * @remarks\n * Node's `Timeout` always has `unref`; the shape check covers exotic runtimes without holding the\n * process open on them.\n */\nconst MAX_TIMER_DELAY_MS = 2_147_483_647\n\nconst unrefTimer = (timer: { unref?: () => void } | undefined): void => {\n if (typeof timer?.unref === 'function') timer.unref()\n}\n\n/**\n * Build the `SIGKILL` escalation state machine for one invocation.\n *\n * @remarks\n * The probe and kill are injected so the machine serves both termination stories: the process\n * group and the direct child. All modes share one deadline and terminal-state latch.\n */\nconst createEscalation = (config: {\n /** Probe the escalation target: the process group, or the direct child in direct-child mode. */\n alive: () => boolean\n /** Deliver the one-shot `SIGKILL` to the target. */\n kill: () => void\n /** Milliseconds from `arm()` until the `SIGKILL` is due. */\n delay: number\n}): Escalation => {\n let state: EscalationState = 'armed'\n /**\n * When the `SIGKILL` is due, in monotonic-clock milliseconds — fixed at `arm()` time, never\n * re-based on settlement.\n */\n let deadline = 0\n let deadlineTimer: ReturnType<typeof setTimeout> | undefined\n let interval: ReturnType<typeof setInterval> | undefined\n let resolveDone!: () => void\n const done = new Promise<void>((resolve) => {\n resolveDone = resolve\n })\n let waiting = false\n\n const stop = (next: 'cancelled' | 'fired'): void => {\n if (state !== 'armed') return\n state = next\n if (deadlineTimer !== undefined) {\n clearTimeout(deadlineTimer)\n deadlineTimer = undefined\n }\n if (interval !== undefined) {\n clearInterval(interval)\n interval = undefined\n }\n resolveDone()\n }\n\n /**\n * At the deadline, cancel if the target is already gone; otherwise send one `SIGKILL`.\n *\n * @remarks\n * A timer can fire before the monotonic deadline (for example, due to sub-millisecond rounding).\n * In that case, re-arm it for the remaining time; otherwise, cancel if the target is gone or\n * send the one `SIGKILL`.\n */\n const check = (): void => {\n if (state !== 'armed') return\n // Empty is terminal: a later reappearance may be a reused PGID, not our target.\n if (!config.alive()) return stop('cancelled')\n const remaining = deadline - monotonicNow()\n if (remaining > 0) {\n // An early timer fire re-arms for the remainder of the deadline.\n //\n if (deadlineTimer !== undefined) clearTimeout(deadlineTimer)\n deadlineTimer = setTimeout(check, Math.min(remaining, MAX_TIMER_DELAY_MS))\n if (!waiting) unrefTimer(deadlineTimer)\n return\n }\n config.kill()\n stop('fired')\n }\n\n return {\n arm: (): void => {\n if (state !== 'armed') return\n deadline = monotonicNow() + config.delay\n deadlineTimer = setTimeout(check, Math.min(config.delay, MAX_TIMER_DELAY_MS))\n unrefTimer(deadlineTimer)\n },\n wait: (): Promise<void> => {\n if (state !== 'armed') return Promise.resolve()\n waiting = true\n const timer = deadlineTimer as\n | (ReturnType<typeof setTimeout> & { ref?: () => void })\n | undefined\n timer?.ref?.()\n const probe = (): void => {\n if (state !== 'armed') return\n if (!config.alive()) stop('cancelled')\n }\n probe()\n if (state === 'armed' && interval === undefined)\n interval = setInterval(probe, ESCALATION_POLL_MS)\n return done\n },\n poll: (): void => {\n if (state !== 'armed') return\n check()\n if (state === 'armed' && interval === undefined) {\n interval = setInterval(check, ESCALATION_POLL_MS)\n unrefTimer(interval)\n }\n },\n cancel: (): void => stop('cancelled'),\n }\n}\n\nconst resolveExeca = async (supplied: ExecaResolver | undefined): Promise<ExecaLike> => {\n let value: unknown =\n supplied ??\n ((): Promise<{ execa: ExecaLike }> =>\n import('execa') as unknown as Promise<{ execa: ExecaLike }>)\n if (typeof value === 'function' && !('exec' in (value as object))) {\n try {\n value = await (value as () => unknown)()\n } catch (err) {\n const detail = isError(err) ? err.message : String(err)\n throw new E_INVALID_MEDIA_PIPELINE_CONFIG([\n `execa resolver failed: ${detail} — install the optional peer dependency \"execa\" or supply your own`,\n ])\n }\n }\n if (isObject(value) && 'execa' in value) {\n value = (value as { execa: unknown }).execa\n }\n if (typeof value !== 'function') {\n throw new E_INVALID_MEDIA_PIPELINE_CONFIG(['execa resolver did not resolve to a function'])\n }\n return value as ExecaLike\n}\n\n/**\n * Construct the bundled local-process {@link BinaryExecutor}.\n *\n * @remarks\n * Termination follows the `detached` flag on every abort and timeout path. With `detached: true`\n * (the default) it is a PROCESS-GROUP kill: the child is spawned detached (its own group leader)\n * and `killGroup` — `kill(-pid, killSignal)` — reaches everything behind a wrapper (sandbox →\n * shell → command). Once termination begins, `settleEscalation` defaults to `'wait'`: settlement\n * waits until the group is empty or the one SIGKILL is sent, at most the remaining escalation\n * delay. `'cancel'` returns fastest but may leave survivors; `'poll'` returns fastest and watches\n * survivors after return with unref'd timers. Both probing modes have a narrow PGID-reuse risk\n * between probes; wait bounds it to before return. Normal exits never wait or poll.\n * With `detached: false` only the DIRECT child is signalled (`subprocess.kill`) and probed\n * (`process.kill(pid, 0)`); all modes cancel at settlement because that child is already reaped.\n * execa's own abort machinery still runs underneath: it kills the direct child at roughly\n * the same moment, so the promise settles whichever mechanism wins the race — in group mode the\n * group signal is what the WRAPPER and its grandchildren die from. execa's `forceKillAfterDelay`\n * is forwarded as given so its own kill escalates identically when IT is the one that fires.\n * The executor owns the timeout (never forwarded to execa), so every timeout terminates the group\n * or direct child through the same escalation path. Its deadline timer stays ref'd until settlement.\n * `0` and `Infinity` mean no deadline. Finite timeouts above 2,147,483,647 milliseconds also\n * disable the deadline rather than overflowing Node's timer into an immediate kill. Negative\n * values and `NaN` reject with a `TypeError` before spawning, as execa 9 did.\n * Non-zero exits are DATA: `reject: false` keeps execa from throwing and every settlement —\n * spawn failure, timeout, abort, non-zero exit — lands in the returned record, never a rejection.\n * `signalCode` is surfaced additively when execa reports the terminating signal.\n *\n * @param options - The execa resolver and defaults (timeout, kill signal/escalation, detached).\n * @returns A `BinaryExecutor` running invocations as local child processes.\n */\nexport const execaExecutor = (options: ExecaExecutorOptions = {}): BinaryExecutor => {\n let execaPromise: Promise<ExecaLike> | undefined\n const getExeca = (): Promise<ExecaLike> => {\n execaPromise ??= resolveExeca(options.execa)\n return execaPromise\n }\n const detached = options.detached ?? true\n return {\n async exec(invocation: BinaryInvocation): Promise<BinaryExecResult> {\n const execa = await getExeca()\n const pidOf = (target: { pid?: number }): number | undefined => target.pid\n const signal = invocation.killSignal ?? options.defaultKillSignal ?? 'SIGTERM'\n // `false` is a MEANINGFUL value (never escalate); only `undefined` falls back to the\n // executor default — coalescing the two would make \"no escalation\" unexpressible.\n const forceKillAfterDelay =\n invocation.forceKillAfterDelay !== undefined\n ? invocation.forceKillAfterDelay\n : (options.defaultForceKillAfterDelay ?? 5_000)\n const timeout = invocation.timeoutMs ?? options.defaultTimeoutMs ?? 120_000\n const settleEscalation =\n invocation.settleEscalation ?? options.defaultSettleEscalation ?? 'wait'\n if (\n settleEscalation !== 'wait' &&\n settleEscalation !== 'cancel' &&\n settleEscalation !== 'poll'\n )\n throw new TypeError(\n `Expected settleEscalation to be 'wait', 'cancel', or 'poll', got ${String(settleEscalation)}`\n )\n if (Number.isNaN(timeout) || timeout < 0) {\n throw new TypeError(`Expected timeoutMs to be a non-negative number, got ${timeout}`)\n }\n if (\n forceKillAfterDelay !== false &&\n (Number.isNaN(forceKillAfterDelay) || forceKillAfterDelay < 0)\n ) {\n throw new TypeError(\n `Expected forceKillAfterDelay to be a non-negative number, got ${forceKillAfterDelay}`\n )\n }\n // The executor owns escalation; don't give execa a disabled or overflowing timer. Execa\n // rejects Infinity and Node clamps delays above MAX_TIMER_DELAY_MS to an early 1ms timer.\n const execaForceKillAfterDelay =\n forceKillAfterDelay === false ||\n forceKillAfterDelay === Infinity ||\n forceKillAfterDelay > MAX_TIMER_DELAY_MS\n ? false\n : forceKillAfterDelay\n let terminate: (() => void) | undefined\n /** The `SIGKILL` escalation for this invocation, including its settlement policy. */\n let escalation: Escalation | undefined\n /** The executor-owned deadline for group (or direct-child) termination. */\n let deadlineTimer: ReturnType<typeof setTimeout> | undefined\n let subprocess: ReturnType<ExecaLike> | undefined\n let terminating = false\n let timedOut = false\n /** Set once the invocation has settled, preventing any further termination. */\n let settled = false\n try {\n subprocess = execa(invocation.cmd, invocation.args, {\n cancelSignal: invocation.signal,\n reject: false,\n stripFinalNewline: true,\n ...(invocation.cwd === undefined ? {} : { cwd: invocation.cwd }),\n ...(invocation.env === undefined ? {} : { env: invocation.env }),\n extendEnv: invocation.extendEnv ?? true,\n killSignal: signal,\n forceKillAfterDelay: execaForceKillAfterDelay,\n detached,\n })\n // Abort or timeout: terminate the group (including grandchildren) when detached, or the\n // direct child otherwise. Only abort also runs execa's own kill machinery. Fired when the\n // invocation is actually being torn down — a child that exits inside the window never\n // needs it. `terminating` guards the double path (both abort and timeout firing, or execa\n // completing in between).\n terminate = (): void => {\n if (settled || terminating || !subprocess) return\n terminating = true\n const pid = pidOf(subprocess)\n // Only the detached child leads a group `-pid` could name: with `detached: false` a\n // group signal would ESRCH and the liveness probe would wrongly report the target as\n // dead, so the child is signalled DIRECTLY on every path instead.\n const child = subprocess\n if (detached && pid !== undefined) {\n killGroup(pid, signal, () => {\n try {\n child?.kill(signal)\n } catch {\n // The child may already be gone; nothing left to do.\n }\n })\n } else {\n try {\n child.kill(signal)\n } catch {\n // The child may already be gone; nothing left to do.\n }\n }\n if (\n forceKillAfterDelay !== false &&\n Number.isFinite(forceKillAfterDelay) &&\n pid !== undefined\n ) {\n escalation = createEscalation({\n delay: forceKillAfterDelay,\n // Group mode probes the GROUP; direct-child mode probes that one pid before the\n // in-flight escalation. An empty observation cancels the escalation.\n alive: () => (detached ? groupAlive(pid) : childAlive(pid)),\n kill: () => {\n if (detached) {\n try {\n process.kill(-pid, 'SIGKILL')\n } catch {\n try {\n child.kill('SIGKILL')\n } catch {\n // Gone already.\n }\n }\n } else {\n try {\n child.kill('SIGKILL')\n } catch {\n // Gone already.\n }\n }\n },\n })\n // A single deadline timer drives escalation while the invocation is in flight.\n escalation.arm()\n }\n }\n if (invocation.signal) {\n if (invocation.signal.aborted) terminate()\n else\n invocation.signal.addEventListener('abort', terminate, {\n once: true,\n })\n }\n // The executor owns the timeout so EVERY timeout terminates the group (or direct child)\n // through `terminate`, including escalation. Keep this timer ref'd: a pending invocation\n // must hold the event loop alive, just as execa's timeout would.\n // It is skipped when the caller's signal starts out aborted (already terminating), and\n // `terminate` is then a no-op anyway.\n // Disable zero/infinite/oversized deadlines: Node clamps timer overflow to 1ms.\n if (\n !terminating &&\n Number.isFinite(timeout) &&\n timeout > 0 &&\n timeout <= MAX_TIMER_DELAY_MS\n )\n deadlineTimer = setTimeout(() => {\n timedOut = true\n terminate?.()\n }, timeout)\n const result = await subprocess\n return {\n exitCode: result.exitCode ?? -1,\n stdout: typeof result.stdout === 'string' ? result.stdout : '',\n stderr: typeof result.stderr === 'string' ? result.stderr : '',\n failed: result.failed || timedOut,\n ...(typeof result.signal === 'string' ? { signalCode: result.signal } : {}),\n }\n } finally {\n // Prevent further abort/timeout handling before settlement policy handles the one armed\n // escalation. Wait mode drives the existing state machine here; no second probe is created.\n settled = true\n // The deadline timer belongs to THIS call only; an invocation that finished on its own\n // (or was already torn down) must never arm a group kill for later.\n if (deadlineTimer !== undefined) {\n clearTimeout(deadlineTimer)\n deadlineTimer = undefined\n }\n // Detach the caller's abort listener on EVERY exit path, so a completed invocation never\n // fires a kill into an already-reaped process (group or direct child).\n if (terminate && invocation.signal)\n invocation.signal.removeEventListener('abort', terminate)\n terminate = undefined\n // Termination-only policy: normal exits always cancel; wait and poll share the same machine.\n if (escalation !== undefined && terminating) {\n if (settleEscalation === 'wait' && detached) await escalation.wait()\n else if (settleEscalation === 'poll' && detached) escalation.poll()\n else escalation.cancel()\n } else escalation?.cancel()\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0JA,IAAM,aAAa,KAAyB,QAAgB,aAA+B;CACzF,IAAI,QAAQ,KAAA,GACV,IAAI;EACF,QAAQ,KAAK,CAAC,KAAK,MAAe;EAClC;CACF,QAAQ,CAER;CAEF,SAAS;AACX;;;;;;;;;;;AAYA,IAAM,cAA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AA,KAAa,aAC9B,IAAI,qBAAqB,UAAU,UAAU,MAAM,WAAW,KAAK;QAC9D,IAAI,qBAAqB,UAAU,UAAU,WAAW,KAAK;QAC7D,WAAW,OAAO;QAClB,YAAY,OAAO;EAC5B;CACF,EACF;AACF"}
@@ -15,6 +15,38 @@
15
15
  * local-process case, the bundled `fs_workspace` is the natural pair.
16
16
  */
17
17
  import type { BinaryExecutor } from "../contracts";
18
+ /**
19
+ * The subprocess handle execa returns: promise-shaped AND carrying the live OS process.
20
+ *
21
+ * @remarks
22
+ * Kept minimal for BYO substitution in tests — a consumer may supply any function of this shape
23
+ * instead of execa. The default resolver returns execa's own subprocess, which is a promise with
24
+ * `pid`/`kill` merged in; the group-kill path reads `pid` and only ever calls `kill`, so a
25
+ * hand-rolled fake without them simply falls back to execa's own kill behaviour.
26
+ */
27
+ export interface ExecaSubprocessLike {
28
+ /** The spawned process id; `undefined` when the process failed to spawn. */
29
+ readonly pid?: number;
30
+ /** Send a signal to the process. Execa's own kill honours `forceKillAfterDelay`. */
31
+ kill: (signal?: string) => boolean;
32
+ /** The promise-style completion surface (`then`/`catch` merged onto the subprocess). */
33
+ then: Promise<ExecaResultLike>['then'];
34
+ /** The promise-style rejection surface. */
35
+ catch: Promise<ExecaResultLike>['catch'];
36
+ }
37
+ /** The settled result slice this executor reads from execa. */
38
+ export interface ExecaResultLike {
39
+ /** The process exit code; `undefined` when a signal or spawn failure ended it. */
40
+ exitCode?: number;
41
+ /** Captured standard output (execa returns a string by default). */
42
+ stdout?: unknown;
43
+ /** Captured standard error. */
44
+ stderr?: unknown;
45
+ /** The signal that terminated the process, when one did (execa reports names like `'SIGKILL'`). */
46
+ signal?: unknown;
47
+ /** `true` when the invocation failed (non-zero exit, signal kill, timeout, spawn failure). Executor-owned timeouts always report true, even if the process exits 0 after termination. */
48
+ failed: boolean;
49
+ }
18
50
  /** The slice of execa this executor uses (kept minimal for BYO substitution in tests). */
19
51
  export interface ExecaLike {
20
52
  (cmd: string, args: readonly string[], options: {
@@ -22,12 +54,13 @@ export interface ExecaLike {
22
54
  cancelSignal?: AbortSignal;
23
55
  reject: false;
24
56
  stripFinalNewline?: boolean;
25
- }): Promise<{
26
- exitCode?: number;
27
- stdout?: unknown;
28
- stderr?: unknown;
29
- failed: boolean;
30
- }>;
57
+ cwd?: string;
58
+ env?: Record<string, string>;
59
+ extendEnv?: boolean;
60
+ killSignal?: string;
61
+ forceKillAfterDelay?: number | false;
62
+ detached?: boolean;
63
+ }): ExecaSubprocessLike & ExecaResultLike;
31
64
  }
32
65
  /** Resolver forms accepted for the execa module. */
33
66
  export type ExecaResolver = ExecaLike | (() => ExecaLike | {
@@ -42,13 +75,85 @@ export interface ExecaExecutorOptions {
42
75
  * `execa` package (optional peer).
43
76
  */
44
77
  execa?: ExecaResolver;
45
- /** Default timeout applied when an invocation does not specify one. */
78
+ /**
79
+ * Default timeout in milliseconds when an invocation does not specify one (default: 120,000).
80
+ * `0`, `Infinity`, and finite values above 2,147,483,647 mean no deadline; negative values and
81
+ * `NaN` reject before spawning.
82
+ */
46
83
  defaultTimeoutMs?: number;
84
+ /** Default {@link BinaryInvocation.killSignal} applied when an invocation does not specify one. */
85
+ defaultKillSignal?: string;
86
+ /**
87
+ * Default {@link BinaryInvocation.forceKillAfterDelay} (milliseconds before `SIGKILL`; `false`
88
+ * or `Infinity` disables escalation) applied when an invocation does not specify one.
89
+ *
90
+ * @remarks
91
+ * The delay is measured on the MONOTONIC clock from the moment the first kill signal is sent,
92
+ * and settlement follows {@link ExecaExecutorOptions.defaultSettleEscalation}: wait (default),
93
+ * cancel, or post-return polling. See {@link ExecaExecutorOptions.detached} for process targeting.
94
+ * Because the clock is monotonic, a wall-clock (NTP) step cannot move the deadline or strand
95
+ * the timer. `Infinity` disables escalation, like an infinite timeout disables its deadline.
96
+ */
97
+ defaultForceKillAfterDelay?: number | false;
98
+ /**
99
+ * Default settlement policy when abort/timeout has begun and escalation is armed. Defaults to
100
+ * `'wait'`: no survivors, but settlement may be delayed up to the escalation deadline. `'cancel'`
101
+ * returns fastest but survivors may remain; `'poll'` returns fastest and kills a surviving
102
+ * target later, with a narrow PGID-reuse risk after return. Normal exits are unaffected.
103
+ * Wait and poll apply only with finite escalation and a known pid. Both probe numeric PGIDs:
104
+ * empty-and-reused between probes can mis-signal an unrelated group, bounded to the wait window
105
+ * in wait mode. With `detached: false`, settlement cancels escalation in every mode.
106
+ */
107
+ defaultSettleEscalation?: 'wait' | 'cancel' | 'poll';
108
+ /**
109
+ * Whether children are spawned as process-group leaders (`detached: true` in POSIX terms).
110
+ * Defaults to `true`.
111
+ *
112
+ * @remarks
113
+ * Group-kill is the executor's cancellation story: a binary behind a wrapper (sandbox → shell →
114
+ * command) leaves grandchildren, and a plain `kill(pid)` kills only the direct child. Spawning
115
+ * detached costs nothing at run time — the child keeps running like any other — and in exchange
116
+ * every termination path can signal the group (`kill(-pid, …)`) so those grandchildren die too.
117
+ *
118
+ * `detached: false` selects the direct-child termination story instead, and it is not merely a
119
+ * weaker group kill: the child is NOT a process-group leader, so `-pid` does not name its group.
120
+ * Every path then signals the direct child alone (`subprocess.kill(sig)`), probes the direct
121
+ * child's liveness (never the group's), and escalates `SIGKILL` to that same child.
122
+ *
123
+ * Settlement after termination is controlled by `defaultSettleEscalation` (default `'wait'`).
124
+ * `wait` holds settlement until the detached group empties or SIGKILL is sent; `cancel` returns
125
+ * immediately and may leave descendants; `poll` returns immediately and watches the group later.
126
+ */
127
+ detached?: boolean;
47
128
  }
48
129
  /**
49
130
  * Construct the bundled local-process {@link BinaryExecutor}.
50
131
  *
51
- * @param options - The execa resolver and defaults.
132
+ * @remarks
133
+ * Termination follows the `detached` flag on every abort and timeout path. With `detached: true`
134
+ * (the default) it is a PROCESS-GROUP kill: the child is spawned detached (its own group leader)
135
+ * and `killGroup` — `kill(-pid, killSignal)` — reaches everything behind a wrapper (sandbox →
136
+ * shell → command). Once termination begins, `settleEscalation` defaults to `'wait'`: settlement
137
+ * waits until the group is empty or the one SIGKILL is sent, at most the remaining escalation
138
+ * delay. `'cancel'` returns fastest but may leave survivors; `'poll'` returns fastest and watches
139
+ * survivors after return with unref'd timers. Both probing modes have a narrow PGID-reuse risk
140
+ * between probes; wait bounds it to before return. Normal exits never wait or poll.
141
+ * With `detached: false` only the DIRECT child is signalled (`subprocess.kill`) and probed
142
+ * (`process.kill(pid, 0)`); all modes cancel at settlement because that child is already reaped.
143
+ * execa's own abort machinery still runs underneath: it kills the direct child at roughly
144
+ * the same moment, so the promise settles whichever mechanism wins the race — in group mode the
145
+ * group signal is what the WRAPPER and its grandchildren die from. execa's `forceKillAfterDelay`
146
+ * is forwarded as given so its own kill escalates identically when IT is the one that fires.
147
+ * The executor owns the timeout (never forwarded to execa), so every timeout terminates the group
148
+ * or direct child through the same escalation path. Its deadline timer stays ref'd until settlement.
149
+ * `0` and `Infinity` mean no deadline. Finite timeouts above 2,147,483,647 milliseconds also
150
+ * disable the deadline rather than overflowing Node's timer into an immediate kill. Negative
151
+ * values and `NaN` reject with a `TypeError` before spawning, as execa 9 did.
152
+ * Non-zero exits are DATA: `reject: false` keeps execa from throwing and every settlement —
153
+ * spawn failure, timeout, abort, non-zero exit — lands in the returned record, never a rejection.
154
+ * `signalCode` is surfaced additively when execa reports the terminating signal.
155
+ *
156
+ * @param options - The execa resolver and defaults (timeout, kill signal/escalation, detached).
52
157
  * @returns A `BinaryExecutor` running invocations as local child processes.
53
158
  */
54
159
  export declare const execaExecutor: (options?: ExecaExecutorOptions) => BinaryExecutor;