@bolt-foundry/gambit-core 0.5.3-dev

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 (711) hide show
  1. package/esm/_dnt.polyfills.d.ts +12 -0
  2. package/esm/_dnt.polyfills.d.ts.map +1 -0
  3. package/esm/_dnt.polyfills.js +15 -0
  4. package/esm/_dnt.shims.d.ts +6 -0
  5. package/esm/_dnt.shims.d.ts.map +1 -0
  6. package/esm/_dnt.shims.js +61 -0
  7. package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts +6 -0
  8. package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts.map +1 -0
  9. package/esm/deps/jsr.io/@std/collections/1.1.3/_utils.js +18 -0
  10. package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts +322 -0
  11. package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@std/collections/1.1.3/deep_merge.js +95 -0
  13. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts +11 -0
  14. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_formats.js +28 -0
  16. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts +5 -0
  17. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/front-matter/1.0.9/_shared.js +8 -0
  19. package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts +32 -0
  20. package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/front-matter/1.0.9/any.js +48 -0
  22. package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts +30 -0
  23. package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/front-matter/1.0.9/json.js +35 -0
  25. package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts +30 -0
  26. package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/front-matter/1.0.9/toml.js +36 -0
  28. package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts +7 -0
  29. package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@std/front-matter/1.0.9/types.js +3 -0
  31. package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts +33 -0
  32. package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +39 -0
  34. package/esm/deps/jsr.io/@std/internal/1.0.12/_os.d.ts +2 -0
  35. package/esm/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/internal/1.0.12/_os.js +12 -0
  37. package/esm/deps/jsr.io/@std/internal/1.0.12/os.d.ts +3 -0
  38. package/esm/deps/jsr.io/@std/internal/1.0.12/os.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/internal/1.0.12/os.js +5 -0
  40. package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts +2 -0
  41. package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@std/path/1.1.4/_common/assert_path.js +7 -0
  43. package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts +4 -0
  44. package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@std/path/1.1.4/_common/basename.js +40 -0
  46. package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts +2 -0
  47. package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/path/1.1.4/_common/common.js +23 -0
  49. package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts +40 -0
  50. package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/path/1.1.4/_common/constants.js +46 -0
  52. package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts +2 -0
  53. package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@std/path/1.1.4/_common/dirname.js +8 -0
  55. package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts +4 -0
  56. package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@std/path/1.1.4/_common/format.js +19 -0
  58. package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts +2 -0
  59. package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.js +9 -0
  61. package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts +35 -0
  62. package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.js +235 -0
  64. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts +2 -0
  65. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize.js +8 -0
  67. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts +2 -0
  68. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts.map +1 -0
  69. package/esm/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.js +77 -0
  70. package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts +2 -0
  71. package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/path/1.1.4/_common/relative.js +9 -0
  73. package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts +2 -0
  74. package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.js +19 -0
  76. package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts +2 -0
  77. package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts.map +1 -0
  78. package/esm/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.js +15 -0
  79. package/esm/deps/jsr.io/@std/path/1.1.4/basename.d.ts +27 -0
  80. package/esm/deps/jsr.io/@std/path/1.1.4/basename.d.ts.map +1 -0
  81. package/esm/deps/jsr.io/@std/path/1.1.4/basename.js +35 -0
  82. package/esm/deps/jsr.io/@std/path/1.1.4/common.d.ts +28 -0
  83. package/esm/deps/jsr.io/@std/path/1.1.4/common.d.ts.map +1 -0
  84. package/esm/deps/jsr.io/@std/path/1.1.4/common.js +33 -0
  85. package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts +15 -0
  86. package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@std/path/1.1.4/constants.js +17 -0
  88. package/esm/deps/jsr.io/@std/path/1.1.4/dirname.d.ts +22 -0
  89. package/esm/deps/jsr.io/@std/path/1.1.4/dirname.d.ts.map +1 -0
  90. package/esm/deps/jsr.io/@std/path/1.1.4/dirname.js +28 -0
  91. package/esm/deps/jsr.io/@std/path/1.1.4/extname.d.ts +22 -0
  92. package/esm/deps/jsr.io/@std/path/1.1.4/extname.d.ts.map +1 -0
  93. package/esm/deps/jsr.io/@std/path/1.1.4/extname.js +28 -0
  94. package/esm/deps/jsr.io/@std/path/1.1.4/format.d.ts +22 -0
  95. package/esm/deps/jsr.io/@std/path/1.1.4/format.d.ts.map +1 -0
  96. package/esm/deps/jsr.io/@std/path/1.1.4/format.js +27 -0
  97. package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts +22 -0
  98. package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts.map +1 -0
  99. package/esm/deps/jsr.io/@std/path/1.1.4/from_file_url.js +28 -0
  100. package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts +77 -0
  101. package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts.map +1 -0
  102. package/esm/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.js +83 -0
  103. package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts +22 -0
  104. package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts.map +1 -0
  105. package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.js +28 -0
  106. package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts +17 -0
  107. package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts.map +1 -0
  108. package/esm/deps/jsr.io/@std/path/1.1.4/is_glob.js +42 -0
  109. package/esm/deps/jsr.io/@std/path/1.1.4/join.d.ts +23 -0
  110. package/esm/deps/jsr.io/@std/path/1.1.4/join.d.ts.map +1 -0
  111. package/esm/deps/jsr.io/@std/path/1.1.4/join.js +29 -0
  112. package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts +28 -0
  113. package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts.map +1 -0
  114. package/esm/deps/jsr.io/@std/path/1.1.4/join_globs.js +34 -0
  115. package/esm/deps/jsr.io/@std/path/1.1.4/mod.d.ts +213 -0
  116. package/esm/deps/jsr.io/@std/path/1.1.4/mod.d.ts.map +1 -0
  117. package/esm/deps/jsr.io/@std/path/1.1.4/mod.js +216 -0
  118. package/esm/deps/jsr.io/@std/path/1.1.4/normalize.d.ts +26 -0
  119. package/esm/deps/jsr.io/@std/path/1.1.4/normalize.d.ts.map +1 -0
  120. package/esm/deps/jsr.io/@std/path/1.1.4/normalize.js +32 -0
  121. package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts +29 -0
  122. package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts.map +1 -0
  123. package/esm/deps/jsr.io/@std/path/1.1.4/normalize_glob.js +35 -0
  124. package/esm/deps/jsr.io/@std/path/1.1.4/parse.d.ts +35 -0
  125. package/esm/deps/jsr.io/@std/path/1.1.4/parse.d.ts.map +1 -0
  126. package/esm/deps/jsr.io/@std/path/1.1.4/parse.js +39 -0
  127. package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts +2 -0
  128. package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts.map +1 -0
  129. package/esm/deps/jsr.io/@std/path/1.1.4/posix/_util.js +8 -0
  130. package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts +39 -0
  131. package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts.map +1 -0
  132. package/esm/deps/jsr.io/@std/path/1.1.4/posix/basename.js +52 -0
  133. package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts +13 -0
  134. package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -0
  135. package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.js +14 -0
  136. package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts +30 -0
  137. package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts.map +1 -0
  138. package/esm/deps/jsr.io/@std/path/1.1.4/posix/dirname.js +64 -0
  139. package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts +37 -0
  140. package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts.map +1 -0
  141. package/esm/deps/jsr.io/@std/path/1.1.4/posix/extname.js +93 -0
  142. package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts +24 -0
  143. package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts.map +1 -0
  144. package/esm/deps/jsr.io/@std/path/1.1.4/posix/format.js +28 -0
  145. package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts +16 -0
  146. package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts.map +1 -0
  147. package/esm/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.js +21 -0
  148. package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts +72 -0
  149. package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts.map +1 -0
  150. package/esm/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.js +82 -0
  151. package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts +17 -0
  152. package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts.map +1 -0
  153. package/esm/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.js +23 -0
  154. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts +31 -0
  155. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts.map +1 -0
  156. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join.js +45 -0
  157. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts +20 -0
  158. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts.map +1 -0
  159. package/esm/deps/jsr.io/@std/path/1.1.4/posix/join_globs.js +40 -0
  160. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts +37 -0
  161. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts.map +1 -0
  162. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize.js +58 -0
  163. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts +20 -0
  164. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts.map +1 -0
  165. package/esm/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.js +32 -0
  166. package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts +25 -0
  167. package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts.map +1 -0
  168. package/esm/deps/jsr.io/@std/path/1.1.4/posix/parse.js +115 -0
  169. package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts +20 -0
  170. package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts.map +1 -0
  171. package/esm/deps/jsr.io/@std/path/1.1.4/posix/relative.js +106 -0
  172. package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts +17 -0
  173. package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts.map +1 -0
  174. package/esm/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +59 -0
  175. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts +17 -0
  176. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts.map +1 -0
  177. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.js +27 -0
  178. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts +16 -0
  179. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts.map +1 -0
  180. package/esm/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.js +20 -0
  181. package/esm/deps/jsr.io/@std/path/1.1.4/relative.d.ts +24 -0
  182. package/esm/deps/jsr.io/@std/path/1.1.4/relative.d.ts.map +1 -0
  183. package/esm/deps/jsr.io/@std/path/1.1.4/relative.js +30 -0
  184. package/esm/deps/jsr.io/@std/path/1.1.4/resolve.d.ts +22 -0
  185. package/esm/deps/jsr.io/@std/path/1.1.4/resolve.d.ts.map +1 -0
  186. package/esm/deps/jsr.io/@std/path/1.1.4/resolve.js +30 -0
  187. package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts +22 -0
  188. package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts.map +1 -0
  189. package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.js +28 -0
  190. package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts +21 -0
  191. package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts.map +1 -0
  192. package/esm/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.js +29 -0
  193. package/esm/deps/jsr.io/@std/path/1.1.4/types.d.ts +38 -0
  194. package/esm/deps/jsr.io/@std/path/1.1.4/types.d.ts.map +1 -0
  195. package/esm/deps/jsr.io/@std/path/1.1.4/types.js +3 -0
  196. package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts +4 -0
  197. package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts.map +1 -0
  198. package/esm/deps/jsr.io/@std/path/1.1.4/windows/_util.js +15 -0
  199. package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts +22 -0
  200. package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts.map +1 -0
  201. package/esm/deps/jsr.io/@std/path/1.1.4/windows/basename.js +47 -0
  202. package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts +13 -0
  203. package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -0
  204. package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.js +14 -0
  205. package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts +17 -0
  206. package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts.map +1 -0
  207. package/esm/deps/jsr.io/@std/path/1.1.4/windows/dirname.js +113 -0
  208. package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts +17 -0
  209. package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts.map +1 -0
  210. package/esm/deps/jsr.io/@std/path/1.1.4/windows/extname.js +82 -0
  211. package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts +24 -0
  212. package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts.map +1 -0
  213. package/esm/deps/jsr.io/@std/path/1.1.4/windows/format.js +28 -0
  214. package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts +18 -0
  215. package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts.map +1 -0
  216. package/esm/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.js +30 -0
  217. package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts +71 -0
  218. package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts.map +1 -0
  219. package/esm/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.js +82 -0
  220. package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts +17 -0
  221. package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts.map +1 -0
  222. package/esm/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.js +38 -0
  223. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts +18 -0
  224. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts.map +1 -0
  225. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join.js +77 -0
  226. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts +21 -0
  227. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts.map +1 -0
  228. package/esm/deps/jsr.io/@std/path/1.1.4/windows/join_globs.js +41 -0
  229. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts +19 -0
  230. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts.map +1 -0
  231. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize.js +135 -0
  232. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts +20 -0
  233. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts.map +1 -0
  234. package/esm/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.js +32 -0
  235. package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts +25 -0
  236. package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts.map +1 -0
  237. package/esm/deps/jsr.io/@std/path/1.1.4/windows/parse.js +176 -0
  238. package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts +23 -0
  239. package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts.map +1 -0
  240. package/esm/deps/jsr.io/@std/path/1.1.4/windows/relative.js +131 -0
  241. package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts +17 -0
  242. package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts.map +1 -0
  243. package/esm/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +154 -0
  244. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts +17 -0
  245. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts.map +1 -0
  246. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.js +34 -0
  247. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts +17 -0
  248. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts.map +1 -0
  249. package/esm/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.js +49 -0
  250. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  251. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  252. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +753 -0
  253. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  254. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  255. package/esm/deps/jsr.io/@std/toml/1.0.11/parse.js +25 -0
  256. package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts +33 -0
  257. package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts.map +1 -0
  258. package/esm/deps/jsr.io/@std/yaml/1.0.10/_chars.js +48 -0
  259. package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts +66 -0
  260. package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +1 -0
  261. package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.js +1427 -0
  262. package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts +44 -0
  263. package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts.map +1 -0
  264. package/esm/deps/jsr.io/@std/yaml/1.0.10/_schema.js +117 -0
  265. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts +3 -0
  266. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts.map +1 -0
  267. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/binary.js +103 -0
  268. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts +3 -0
  269. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts.map +1 -0
  270. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/bool.js +32 -0
  271. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts +3 -0
  272. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts.map +1 -0
  273. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/float.js +96 -0
  274. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts +3 -0
  275. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts.map +1 -0
  276. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/int.js +159 -0
  277. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts +3 -0
  278. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts.map +1 -0
  279. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/map.js +14 -0
  280. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts +3 -0
  281. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts.map +1 -0
  282. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/merge.js +10 -0
  283. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts +3 -0
  284. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts.map +1 -0
  285. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/nil.js +22 -0
  286. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts +3 -0
  287. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts.map +1 -0
  288. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/omap.js +29 -0
  289. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts +3 -0
  290. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts.map +1 -0
  291. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.js +19 -0
  292. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts +3 -0
  293. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts.map +1 -0
  294. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.js +30 -0
  295. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts +3 -0
  296. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts.map +1 -0
  297. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/seq.js +10 -0
  298. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts +3 -0
  299. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts.map +1 -0
  300. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/set.js +14 -0
  301. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts +3 -0
  302. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts.map +1 -0
  303. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/str.js +9 -0
  304. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts +3 -0
  305. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts.map +1 -0
  306. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.js +81 -0
  307. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts +3 -0
  308. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts.map +1 -0
  309. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.js +20 -0
  310. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts +32 -0
  311. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts.map +1 -0
  312. package/esm/deps/jsr.io/@std/yaml/1.0.10/_type.js +6 -0
  313. package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts +4 -0
  314. package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts.map +1 -0
  315. package/esm/deps/jsr.io/@std/yaml/1.0.10/_utils.js +13 -0
  316. package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts +76 -0
  317. package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts.map +1 -0
  318. package/esm/deps/jsr.io/@std/yaml/1.0.10/parse.js +93 -0
  319. package/esm/mod.d.ts +51 -0
  320. package/esm/mod.d.ts.map +1 -0
  321. package/esm/mod.js +20 -0
  322. package/esm/package.json +3 -0
  323. package/esm/src/constants.d.ts +15 -0
  324. package/esm/src/constants.d.ts.map +1 -0
  325. package/esm/src/constants.js +20 -0
  326. package/esm/src/definitions.d.ts +11 -0
  327. package/esm/src/definitions.d.ts.map +1 -0
  328. package/esm/src/definitions.js +14 -0
  329. package/esm/src/loader.d.ts +4 -0
  330. package/esm/src/loader.d.ts.map +1 -0
  331. package/esm/src/loader.js +179 -0
  332. package/esm/src/markdown.d.ts +5 -0
  333. package/esm/src/markdown.d.ts.map +1 -0
  334. package/esm/src/markdown.js +307 -0
  335. package/esm/src/openai_compat.d.ts +63 -0
  336. package/esm/src/openai_compat.d.ts.map +1 -0
  337. package/esm/src/openai_compat.js +272 -0
  338. package/esm/src/providers/openrouter.d.ts +8 -0
  339. package/esm/src/providers/openrouter.d.ts.map +1 -0
  340. package/esm/src/providers/openrouter.js +168 -0
  341. package/esm/src/render.d.ts +51 -0
  342. package/esm/src/render.d.ts.map +1 -0
  343. package/esm/src/render.js +188 -0
  344. package/esm/src/runtime.d.ts +35 -0
  345. package/esm/src/runtime.d.ts.map +1 -0
  346. package/esm/src/runtime.js +1368 -0
  347. package/esm/src/schema.d.ts +8 -0
  348. package/esm/src/schema.d.ts.map +1 -0
  349. package/esm/src/schema.js +45 -0
  350. package/esm/src/state.d.ts +34 -0
  351. package/esm/src/state.d.ts.map +1 -0
  352. package/esm/src/state.js +22 -0
  353. package/esm/src/types.d.ts +318 -0
  354. package/esm/src/types.d.ts.map +1 -0
  355. package/esm/src/types.js +1 -0
  356. package/package.json +32 -0
  357. package/script/_dnt.polyfills.d.ts +12 -0
  358. package/script/_dnt.polyfills.d.ts.map +1 -0
  359. package/script/_dnt.polyfills.js +16 -0
  360. package/script/_dnt.shims.d.ts +6 -0
  361. package/script/_dnt.shims.d.ts.map +1 -0
  362. package/script/_dnt.shims.js +65 -0
  363. package/script/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts +6 -0
  364. package/script/deps/jsr.io/@std/collections/1.1.3/_utils.d.ts.map +1 -0
  365. package/script/deps/jsr.io/@std/collections/1.1.3/_utils.js +21 -0
  366. package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts +322 -0
  367. package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.d.ts.map +1 -0
  368. package/script/deps/jsr.io/@std/collections/1.1.3/deep_merge.js +98 -0
  369. package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts +11 -0
  370. package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.d.ts.map +1 -0
  371. package/script/deps/jsr.io/@std/front-matter/1.0.9/_formats.js +31 -0
  372. package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts +5 -0
  373. package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.d.ts.map +1 -0
  374. package/script/deps/jsr.io/@std/front-matter/1.0.9/_shared.js +11 -0
  375. package/script/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts +32 -0
  376. package/script/deps/jsr.io/@std/front-matter/1.0.9/any.d.ts.map +1 -0
  377. package/script/deps/jsr.io/@std/front-matter/1.0.9/any.js +51 -0
  378. package/script/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts +30 -0
  379. package/script/deps/jsr.io/@std/front-matter/1.0.9/json.d.ts.map +1 -0
  380. package/script/deps/jsr.io/@std/front-matter/1.0.9/json.js +38 -0
  381. package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts +30 -0
  382. package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.d.ts.map +1 -0
  383. package/script/deps/jsr.io/@std/front-matter/1.0.9/toml.js +39 -0
  384. package/script/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts +7 -0
  385. package/script/deps/jsr.io/@std/front-matter/1.0.9/types.d.ts.map +1 -0
  386. package/script/deps/jsr.io/@std/front-matter/1.0.9/types.js +4 -0
  387. package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts +33 -0
  388. package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.d.ts.map +1 -0
  389. package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +42 -0
  390. package/script/deps/jsr.io/@std/internal/1.0.12/_os.d.ts +2 -0
  391. package/script/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +1 -0
  392. package/script/deps/jsr.io/@std/internal/1.0.12/_os.js +38 -0
  393. package/script/deps/jsr.io/@std/internal/1.0.12/os.d.ts +3 -0
  394. package/script/deps/jsr.io/@std/internal/1.0.12/os.d.ts.map +1 -0
  395. package/script/deps/jsr.io/@std/internal/1.0.12/os.js +8 -0
  396. package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts +2 -0
  397. package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.d.ts.map +1 -0
  398. package/script/deps/jsr.io/@std/path/1.1.4/_common/assert_path.js +10 -0
  399. package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts +4 -0
  400. package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.d.ts.map +1 -0
  401. package/script/deps/jsr.io/@std/path/1.1.4/_common/basename.js +45 -0
  402. package/script/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts +2 -0
  403. package/script/deps/jsr.io/@std/path/1.1.4/_common/common.d.ts.map +1 -0
  404. package/script/deps/jsr.io/@std/path/1.1.4/_common/common.js +26 -0
  405. package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts +40 -0
  406. package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.d.ts.map +1 -0
  407. package/script/deps/jsr.io/@std/path/1.1.4/_common/constants.js +49 -0
  408. package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts +2 -0
  409. package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.d.ts.map +1 -0
  410. package/script/deps/jsr.io/@std/path/1.1.4/_common/dirname.js +11 -0
  411. package/script/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts +4 -0
  412. package/script/deps/jsr.io/@std/path/1.1.4/_common/format.d.ts.map +1 -0
  413. package/script/deps/jsr.io/@std/path/1.1.4/_common/format.js +23 -0
  414. package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts +2 -0
  415. package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.d.ts.map +1 -0
  416. package/script/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.js +12 -0
  417. package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts +35 -0
  418. package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.d.ts.map +1 -0
  419. package/script/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.js +238 -0
  420. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts +2 -0
  421. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.d.ts.map +1 -0
  422. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize.js +11 -0
  423. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts +2 -0
  424. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.d.ts.map +1 -0
  425. package/script/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.js +80 -0
  426. package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts +2 -0
  427. package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.d.ts.map +1 -0
  428. package/script/deps/jsr.io/@std/path/1.1.4/_common/relative.js +12 -0
  429. package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts +2 -0
  430. package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.d.ts.map +1 -0
  431. package/script/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.js +22 -0
  432. package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts +2 -0
  433. package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.d.ts.map +1 -0
  434. package/script/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.js +18 -0
  435. package/script/deps/jsr.io/@std/path/1.1.4/basename.d.ts +27 -0
  436. package/script/deps/jsr.io/@std/path/1.1.4/basename.d.ts.map +1 -0
  437. package/script/deps/jsr.io/@std/path/1.1.4/basename.js +38 -0
  438. package/script/deps/jsr.io/@std/path/1.1.4/common.d.ts +28 -0
  439. package/script/deps/jsr.io/@std/path/1.1.4/common.d.ts.map +1 -0
  440. package/script/deps/jsr.io/@std/path/1.1.4/common.js +36 -0
  441. package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts +15 -0
  442. package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts.map +1 -0
  443. package/script/deps/jsr.io/@std/path/1.1.4/constants.js +20 -0
  444. package/script/deps/jsr.io/@std/path/1.1.4/dirname.d.ts +22 -0
  445. package/script/deps/jsr.io/@std/path/1.1.4/dirname.d.ts.map +1 -0
  446. package/script/deps/jsr.io/@std/path/1.1.4/dirname.js +31 -0
  447. package/script/deps/jsr.io/@std/path/1.1.4/extname.d.ts +22 -0
  448. package/script/deps/jsr.io/@std/path/1.1.4/extname.d.ts.map +1 -0
  449. package/script/deps/jsr.io/@std/path/1.1.4/extname.js +31 -0
  450. package/script/deps/jsr.io/@std/path/1.1.4/format.d.ts +22 -0
  451. package/script/deps/jsr.io/@std/path/1.1.4/format.d.ts.map +1 -0
  452. package/script/deps/jsr.io/@std/path/1.1.4/format.js +30 -0
  453. package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts +22 -0
  454. package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.d.ts.map +1 -0
  455. package/script/deps/jsr.io/@std/path/1.1.4/from_file_url.js +31 -0
  456. package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts +77 -0
  457. package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.d.ts.map +1 -0
  458. package/script/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.js +86 -0
  459. package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts +22 -0
  460. package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.d.ts.map +1 -0
  461. package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.js +31 -0
  462. package/script/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts +17 -0
  463. package/script/deps/jsr.io/@std/path/1.1.4/is_glob.d.ts.map +1 -0
  464. package/script/deps/jsr.io/@std/path/1.1.4/is_glob.js +45 -0
  465. package/script/deps/jsr.io/@std/path/1.1.4/join.d.ts +23 -0
  466. package/script/deps/jsr.io/@std/path/1.1.4/join.d.ts.map +1 -0
  467. package/script/deps/jsr.io/@std/path/1.1.4/join.js +32 -0
  468. package/script/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts +28 -0
  469. package/script/deps/jsr.io/@std/path/1.1.4/join_globs.d.ts.map +1 -0
  470. package/script/deps/jsr.io/@std/path/1.1.4/join_globs.js +37 -0
  471. package/script/deps/jsr.io/@std/path/1.1.4/mod.d.ts +213 -0
  472. package/script/deps/jsr.io/@std/path/1.1.4/mod.d.ts.map +1 -0
  473. package/script/deps/jsr.io/@std/path/1.1.4/mod.js +232 -0
  474. package/script/deps/jsr.io/@std/path/1.1.4/normalize.d.ts +26 -0
  475. package/script/deps/jsr.io/@std/path/1.1.4/normalize.d.ts.map +1 -0
  476. package/script/deps/jsr.io/@std/path/1.1.4/normalize.js +35 -0
  477. package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts +29 -0
  478. package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.d.ts.map +1 -0
  479. package/script/deps/jsr.io/@std/path/1.1.4/normalize_glob.js +38 -0
  480. package/script/deps/jsr.io/@std/path/1.1.4/parse.d.ts +35 -0
  481. package/script/deps/jsr.io/@std/path/1.1.4/parse.d.ts.map +1 -0
  482. package/script/deps/jsr.io/@std/path/1.1.4/parse.js +42 -0
  483. package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts +2 -0
  484. package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.d.ts.map +1 -0
  485. package/script/deps/jsr.io/@std/path/1.1.4/posix/_util.js +11 -0
  486. package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts +39 -0
  487. package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.d.ts.map +1 -0
  488. package/script/deps/jsr.io/@std/path/1.1.4/posix/basename.js +55 -0
  489. package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts +13 -0
  490. package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -0
  491. package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.js +17 -0
  492. package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts +30 -0
  493. package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.d.ts.map +1 -0
  494. package/script/deps/jsr.io/@std/path/1.1.4/posix/dirname.js +67 -0
  495. package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts +37 -0
  496. package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.d.ts.map +1 -0
  497. package/script/deps/jsr.io/@std/path/1.1.4/posix/extname.js +96 -0
  498. package/script/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts +24 -0
  499. package/script/deps/jsr.io/@std/path/1.1.4/posix/format.d.ts.map +1 -0
  500. package/script/deps/jsr.io/@std/path/1.1.4/posix/format.js +31 -0
  501. package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts +16 -0
  502. package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.d.ts.map +1 -0
  503. package/script/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.js +24 -0
  504. package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts +72 -0
  505. package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.d.ts.map +1 -0
  506. package/script/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.js +85 -0
  507. package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts +17 -0
  508. package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.d.ts.map +1 -0
  509. package/script/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.js +26 -0
  510. package/script/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts +31 -0
  511. package/script/deps/jsr.io/@std/path/1.1.4/posix/join.d.ts.map +1 -0
  512. package/script/deps/jsr.io/@std/path/1.1.4/posix/join.js +48 -0
  513. package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts +20 -0
  514. package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.d.ts.map +1 -0
  515. package/script/deps/jsr.io/@std/path/1.1.4/posix/join_globs.js +43 -0
  516. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts +37 -0
  517. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.d.ts.map +1 -0
  518. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize.js +61 -0
  519. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts +20 -0
  520. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.d.ts.map +1 -0
  521. package/script/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.js +35 -0
  522. package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts +25 -0
  523. package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.d.ts.map +1 -0
  524. package/script/deps/jsr.io/@std/path/1.1.4/posix/parse.js +118 -0
  525. package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts +20 -0
  526. package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.d.ts.map +1 -0
  527. package/script/deps/jsr.io/@std/path/1.1.4/posix/relative.js +109 -0
  528. package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts +17 -0
  529. package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.d.ts.map +1 -0
  530. package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +85 -0
  531. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts +17 -0
  532. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.d.ts.map +1 -0
  533. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.js +30 -0
  534. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts +16 -0
  535. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.d.ts.map +1 -0
  536. package/script/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.js +23 -0
  537. package/script/deps/jsr.io/@std/path/1.1.4/relative.d.ts +24 -0
  538. package/script/deps/jsr.io/@std/path/1.1.4/relative.d.ts.map +1 -0
  539. package/script/deps/jsr.io/@std/path/1.1.4/relative.js +33 -0
  540. package/script/deps/jsr.io/@std/path/1.1.4/resolve.d.ts +22 -0
  541. package/script/deps/jsr.io/@std/path/1.1.4/resolve.d.ts.map +1 -0
  542. package/script/deps/jsr.io/@std/path/1.1.4/resolve.js +33 -0
  543. package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts +22 -0
  544. package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.d.ts.map +1 -0
  545. package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.js +31 -0
  546. package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts +21 -0
  547. package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.d.ts.map +1 -0
  548. package/script/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.js +32 -0
  549. package/script/deps/jsr.io/@std/path/1.1.4/types.d.ts +38 -0
  550. package/script/deps/jsr.io/@std/path/1.1.4/types.d.ts.map +1 -0
  551. package/script/deps/jsr.io/@std/path/1.1.4/types.js +4 -0
  552. package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts +4 -0
  553. package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.d.ts.map +1 -0
  554. package/script/deps/jsr.io/@std/path/1.1.4/windows/_util.js +20 -0
  555. package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts +22 -0
  556. package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.d.ts.map +1 -0
  557. package/script/deps/jsr.io/@std/path/1.1.4/windows/basename.js +50 -0
  558. package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts +13 -0
  559. package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -0
  560. package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.js +17 -0
  561. package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts +17 -0
  562. package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.d.ts.map +1 -0
  563. package/script/deps/jsr.io/@std/path/1.1.4/windows/dirname.js +116 -0
  564. package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts +17 -0
  565. package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.d.ts.map +1 -0
  566. package/script/deps/jsr.io/@std/path/1.1.4/windows/extname.js +85 -0
  567. package/script/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts +24 -0
  568. package/script/deps/jsr.io/@std/path/1.1.4/windows/format.d.ts.map +1 -0
  569. package/script/deps/jsr.io/@std/path/1.1.4/windows/format.js +31 -0
  570. package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts +18 -0
  571. package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.d.ts.map +1 -0
  572. package/script/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.js +33 -0
  573. package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts +71 -0
  574. package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.d.ts.map +1 -0
  575. package/script/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.js +85 -0
  576. package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts +17 -0
  577. package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.d.ts.map +1 -0
  578. package/script/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.js +41 -0
  579. package/script/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts +18 -0
  580. package/script/deps/jsr.io/@std/path/1.1.4/windows/join.d.ts.map +1 -0
  581. package/script/deps/jsr.io/@std/path/1.1.4/windows/join.js +80 -0
  582. package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts +21 -0
  583. package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.d.ts.map +1 -0
  584. package/script/deps/jsr.io/@std/path/1.1.4/windows/join_globs.js +44 -0
  585. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts +19 -0
  586. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.d.ts.map +1 -0
  587. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize.js +138 -0
  588. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts +20 -0
  589. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.d.ts.map +1 -0
  590. package/script/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.js +35 -0
  591. package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts +25 -0
  592. package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.d.ts.map +1 -0
  593. package/script/deps/jsr.io/@std/path/1.1.4/windows/parse.js +179 -0
  594. package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts +23 -0
  595. package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.d.ts.map +1 -0
  596. package/script/deps/jsr.io/@std/path/1.1.4/windows/relative.js +134 -0
  597. package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts +17 -0
  598. package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.d.ts.map +1 -0
  599. package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +180 -0
  600. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts +17 -0
  601. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.d.ts.map +1 -0
  602. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.js +37 -0
  603. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts +17 -0
  604. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.d.ts.map +1 -0
  605. package/script/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.js +52 -0
  606. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts +93 -0
  607. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.d.ts.map +1 -0
  608. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +781 -0
  609. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts +21 -0
  610. package/script/deps/jsr.io/@std/toml/1.0.11/parse.d.ts.map +1 -0
  611. package/script/deps/jsr.io/@std/toml/1.0.11/parse.js +28 -0
  612. package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts +33 -0
  613. package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.d.ts.map +1 -0
  614. package/script/deps/jsr.io/@std/yaml/1.0.10/_chars.js +55 -0
  615. package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts +66 -0
  616. package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +1 -0
  617. package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.js +1431 -0
  618. package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts +44 -0
  619. package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.d.ts.map +1 -0
  620. package/script/deps/jsr.io/@std/yaml/1.0.10/_schema.js +121 -0
  621. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts +3 -0
  622. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.d.ts.map +1 -0
  623. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/binary.js +106 -0
  624. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts +3 -0
  625. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.d.ts.map +1 -0
  626. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/bool.js +35 -0
  627. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts +3 -0
  628. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.d.ts.map +1 -0
  629. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/float.js +99 -0
  630. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts +3 -0
  631. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.d.ts.map +1 -0
  632. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/int.js +162 -0
  633. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts +3 -0
  634. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.d.ts.map +1 -0
  635. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/map.js +17 -0
  636. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts +3 -0
  637. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.d.ts.map +1 -0
  638. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/merge.js +13 -0
  639. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts +3 -0
  640. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.d.ts.map +1 -0
  641. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/nil.js +25 -0
  642. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts +3 -0
  643. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.d.ts.map +1 -0
  644. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/omap.js +32 -0
  645. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts +3 -0
  646. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.d.ts.map +1 -0
  647. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/pairs.js +22 -0
  648. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts +3 -0
  649. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.d.ts.map +1 -0
  650. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/regexp.js +33 -0
  651. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts +3 -0
  652. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.d.ts.map +1 -0
  653. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/seq.js +13 -0
  654. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts +3 -0
  655. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.d.ts.map +1 -0
  656. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/set.js +17 -0
  657. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts +3 -0
  658. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.d.ts.map +1 -0
  659. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/str.js +12 -0
  660. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts +3 -0
  661. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.d.ts.map +1 -0
  662. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/timestamp.js +84 -0
  663. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts +3 -0
  664. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.d.ts.map +1 -0
  665. package/script/deps/jsr.io/@std/yaml/1.0.10/_type/undefined.js +23 -0
  666. package/script/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts +32 -0
  667. package/script/deps/jsr.io/@std/yaml/1.0.10/_type.d.ts.map +1 -0
  668. package/script/deps/jsr.io/@std/yaml/1.0.10/_type.js +7 -0
  669. package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts +4 -0
  670. package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.d.ts.map +1 -0
  671. package/script/deps/jsr.io/@std/yaml/1.0.10/_utils.js +18 -0
  672. package/script/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts +76 -0
  673. package/script/deps/jsr.io/@std/yaml/1.0.10/parse.d.ts.map +1 -0
  674. package/script/deps/jsr.io/@std/yaml/1.0.10/parse.js +97 -0
  675. package/script/mod.d.ts +51 -0
  676. package/script/mod.d.ts.map +1 -0
  677. package/script/mod.js +30 -0
  678. package/script/package.json +3 -0
  679. package/script/src/constants.d.ts +15 -0
  680. package/script/src/constants.d.ts.map +1 -0
  681. package/script/src/constants.js +23 -0
  682. package/script/src/definitions.d.ts +11 -0
  683. package/script/src/definitions.d.ts.map +1 -0
  684. package/script/src/definitions.js +20 -0
  685. package/script/src/loader.d.ts +4 -0
  686. package/script/src/loader.d.ts.map +1 -0
  687. package/script/src/loader.js +206 -0
  688. package/script/src/markdown.d.ts +5 -0
  689. package/script/src/markdown.d.ts.map +1 -0
  690. package/script/src/markdown.js +335 -0
  691. package/script/src/openai_compat.d.ts +63 -0
  692. package/script/src/openai_compat.d.ts.map +1 -0
  693. package/script/src/openai_compat.js +276 -0
  694. package/script/src/providers/openrouter.d.ts +8 -0
  695. package/script/src/providers/openrouter.d.ts.map +1 -0
  696. package/script/src/providers/openrouter.js +197 -0
  697. package/script/src/render.d.ts +51 -0
  698. package/script/src/render.d.ts.map +1 -0
  699. package/script/src/render.js +192 -0
  700. package/script/src/runtime.d.ts +35 -0
  701. package/script/src/runtime.d.ts.map +1 -0
  702. package/script/src/runtime.js +1395 -0
  703. package/script/src/schema.d.ts +8 -0
  704. package/script/src/schema.d.ts.map +1 -0
  705. package/script/src/schema.js +51 -0
  706. package/script/src/state.d.ts +34 -0
  707. package/script/src/state.d.ts.map +1 -0
  708. package/script/src/state.js +49 -0
  709. package/script/src/types.d.ts +318 -0
  710. package/script/src/types.d.ts.map +1 -0
  711. package/script/src/types.js +2 -0
@@ -0,0 +1,1368 @@
1
+ import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
2
+ import { DEFAULT_GUARDRAILS, DEFAULT_STATUS_DELAY_MS, GAMBIT_TOOL_COMPLETE, GAMBIT_TOOL_END, GAMBIT_TOOL_INIT, GAMBIT_TOOL_RESPOND, } from "./constants.js";
3
+ import { loadDeck } from "./loader.js";
4
+ import { assertZodSchema, toJsonSchema, validateWithSchema } from "./schema.js";
5
+ export function isGambitEndSignal(value) {
6
+ return Boolean(value &&
7
+ typeof value === "object" &&
8
+ value.__gambitEnd === true);
9
+ }
10
+ const logger = console;
11
+ function randomId(prefix) {
12
+ const suffix = crypto.randomUUID().replace(/-/g, "").slice(0, 24);
13
+ // Keep IDs short enough for OpenAI/OpenRouter tool_call id limits (~40 chars).
14
+ return `${prefix}-${suffix}`;
15
+ }
16
+ export async function runDeck(opts) {
17
+ const guardrails = {
18
+ ...DEFAULT_GUARDRAILS,
19
+ ...opts.guardrails,
20
+ };
21
+ const depth = opts.depth ?? 0;
22
+ const inferredRoot = opts.isRoot ??
23
+ (!opts.parentActionCallId && depth === 0);
24
+ if (depth >= guardrails.maxDepth) {
25
+ throw new Error(`Max depth ${guardrails.maxDepth} exceeded`);
26
+ }
27
+ const runId = opts.runId ?? opts.state?.runId ?? randomId("run");
28
+ const deck = await loadDeck(opts.path);
29
+ const deckGuardrails = deck.guardrails ?? {};
30
+ const effectiveGuardrails = {
31
+ ...guardrails,
32
+ ...deckGuardrails,
33
+ };
34
+ const isRoot = Boolean(inferredRoot);
35
+ ensureSchemaPresence(deck, isRoot);
36
+ const resolvedInput = resolveInput({
37
+ deck,
38
+ input: opts.input,
39
+ state: opts.state,
40
+ isRoot,
41
+ initialUserMessage: opts.initialUserMessage,
42
+ });
43
+ const validatedInput = validateInput(deck, resolvedInput, isRoot, opts.allowRootStringInput ?? false);
44
+ const shouldEmitRun = opts.depth === undefined || opts.depth === 0;
45
+ if (shouldEmitRun) {
46
+ opts.trace?.({
47
+ type: "run.start",
48
+ runId,
49
+ deckPath: deck.path,
50
+ input: validatedInput,
51
+ initialUserMessage: opts
52
+ .initialUserMessage,
53
+ });
54
+ }
55
+ try {
56
+ if (deck.modelParams?.model || deck.modelParams?.temperature !== undefined) {
57
+ return await runLlmDeck({
58
+ deck,
59
+ guardrails: effectiveGuardrails,
60
+ depth,
61
+ runId,
62
+ parentActionCallId: opts.parentActionCallId,
63
+ modelProvider: opts.modelProvider,
64
+ input: validatedInput,
65
+ inputProvided: opts.inputProvided ?? true,
66
+ initialUserMessage: opts.initialUserMessage,
67
+ defaultModel: opts.defaultModel,
68
+ modelOverride: opts.modelOverride,
69
+ trace: opts.trace,
70
+ stream: opts.stream,
71
+ state: opts.state,
72
+ onStateUpdate: opts.onStateUpdate,
73
+ onStreamText: opts.onStreamText,
74
+ });
75
+ }
76
+ if (!deck.executor) {
77
+ throw new Error(`Deck ${deck.path} has no model and no executor (add run or execute to the deck definition)`);
78
+ }
79
+ return await runComputeDeck({
80
+ deck,
81
+ guardrails: effectiveGuardrails,
82
+ depth,
83
+ runId,
84
+ parentActionCallId: opts.parentActionCallId,
85
+ modelProvider: opts.modelProvider,
86
+ input: validatedInput,
87
+ defaultModel: opts.defaultModel,
88
+ modelOverride: opts.modelOverride,
89
+ trace: opts.trace,
90
+ stream: opts.stream,
91
+ onStreamText: opts.onStreamText,
92
+ });
93
+ }
94
+ finally {
95
+ if (shouldEmitRun) {
96
+ opts.trace?.({ type: "run.end", runId });
97
+ }
98
+ }
99
+ }
100
+ function toProviderParams(params) {
101
+ if (!params)
102
+ return undefined;
103
+ const { model: _model, temperature, top_p, frequency_penalty, presence_penalty, max_tokens, } = params;
104
+ const out = {};
105
+ if (temperature !== undefined)
106
+ out.temperature = temperature;
107
+ if (top_p !== undefined)
108
+ out.top_p = top_p;
109
+ if (frequency_penalty !== undefined) {
110
+ out.frequency_penalty = frequency_penalty;
111
+ }
112
+ if (presence_penalty !== undefined)
113
+ out.presence_penalty = presence_penalty;
114
+ if (max_tokens !== undefined)
115
+ out.max_tokens = max_tokens;
116
+ return Object.keys(out).length ? out : undefined;
117
+ }
118
+ function ensureSchemaPresence(deck, isRoot) {
119
+ if (!isRoot) {
120
+ if (!deck.inputSchema || !deck.outputSchema) {
121
+ throw new Error(`Deck ${deck.path} must declare inputSchema and outputSchema (non-root)`);
122
+ }
123
+ assertZodSchema(deck.inputSchema, "inputSchema");
124
+ assertZodSchema(deck.outputSchema, "outputSchema");
125
+ }
126
+ }
127
+ function resolveInput(args) {
128
+ if (args.input !== undefined)
129
+ return args.input;
130
+ if (!args.isRoot)
131
+ return args.input;
132
+ const persisted = extractInitInput(args.state);
133
+ if (persisted !== undefined)
134
+ return persisted;
135
+ if (args.initialUserMessage !== undefined) {
136
+ const schema = args.deck.inputSchema;
137
+ if (schema?.safeParse) {
138
+ const candidates = [undefined, {}, ""];
139
+ for (const candidate of candidates) {
140
+ try {
141
+ const result = schema.safeParse(candidate);
142
+ if (result?.success)
143
+ return candidate;
144
+ }
145
+ catch {
146
+ // ignore and try next candidate
147
+ }
148
+ }
149
+ }
150
+ return "";
151
+ }
152
+ return args.input;
153
+ }
154
+ function extractInitInput(state) {
155
+ if (!state?.messages)
156
+ return undefined;
157
+ for (let i = state.messages.length - 1; i >= 0; i--) {
158
+ const msg = state.messages[i];
159
+ if (msg.role === "tool" && msg.name === GAMBIT_TOOL_INIT) {
160
+ const content = msg.content;
161
+ if (typeof content !== "string")
162
+ return undefined;
163
+ try {
164
+ return JSON.parse(content);
165
+ }
166
+ catch {
167
+ return content;
168
+ }
169
+ }
170
+ }
171
+ return undefined;
172
+ }
173
+ function validateInput(deck, input, isRoot, allowRootStringInput) {
174
+ if (deck.inputSchema) {
175
+ if (isRoot && typeof input === "string" && allowRootStringInput) {
176
+ try {
177
+ return validateWithSchema(deck.inputSchema, input);
178
+ }
179
+ catch {
180
+ return input;
181
+ }
182
+ }
183
+ return validateWithSchema(deck.inputSchema, input);
184
+ }
185
+ if (isRoot) {
186
+ if (input === undefined)
187
+ return "";
188
+ if (typeof input === "string")
189
+ return input;
190
+ return input;
191
+ }
192
+ throw new Error(`Deck ${deck.path} requires inputSchema (non-root)`);
193
+ }
194
+ function validateOutput(deck, output, isRoot) {
195
+ if (deck.outputSchema) {
196
+ return validateWithSchema(deck.outputSchema, output);
197
+ }
198
+ if (isRoot) {
199
+ if (typeof output === "string")
200
+ return output;
201
+ return JSON.stringify(output);
202
+ }
203
+ throw new Error(`Deck ${deck.path} requires outputSchema (non-root)`);
204
+ }
205
+ async function runComputeDeck(ctx) {
206
+ const { deck, runId } = ctx;
207
+ const actionCallId = randomId("action");
208
+ const execContext = {
209
+ runId,
210
+ actionCallId,
211
+ parentActionCallId: ctx.parentActionCallId,
212
+ depth: ctx.depth,
213
+ input: ctx.input,
214
+ label: deck.label,
215
+ log: (entry) => {
216
+ if (!ctx.trace)
217
+ return;
218
+ const raw = typeof entry === "string" ? { message: entry } : entry;
219
+ if (!raw)
220
+ return;
221
+ const message = typeof raw.message === "string"
222
+ ? raw.message
223
+ : raw.message !== undefined
224
+ ? String(raw.message)
225
+ : typeof entry === "string"
226
+ ? entry
227
+ : "";
228
+ const title = typeof raw.title === "string" ? raw.title : undefined;
229
+ const body = raw.body ?? raw.message ?? message;
230
+ ctx.trace({
231
+ type: "log",
232
+ runId,
233
+ deckPath: deck.path,
234
+ actionCallId,
235
+ parentActionCallId: ctx.parentActionCallId,
236
+ level: raw.level ?? "info",
237
+ title: title ?? (message || undefined),
238
+ message,
239
+ body,
240
+ meta: raw.meta,
241
+ });
242
+ },
243
+ spawnAndWait: async (opts) => {
244
+ const childPath = path.isAbsolute(opts.path)
245
+ ? opts.path
246
+ : path.resolve(path.dirname(deck.path), opts.path);
247
+ return await runDeck({
248
+ path: childPath,
249
+ input: opts.input,
250
+ modelProvider: ctx.modelProvider,
251
+ isRoot: false,
252
+ guardrails: ctx.guardrails,
253
+ depth: ctx.depth + 1,
254
+ parentActionCallId: actionCallId,
255
+ runId,
256
+ defaultModel: ctx.defaultModel,
257
+ modelOverride: ctx.modelOverride,
258
+ trace: ctx.trace,
259
+ stream: ctx.stream,
260
+ state: ctx.state,
261
+ onStateUpdate: ctx.onStateUpdate,
262
+ onStreamText: ctx.onStreamText,
263
+ initialUserMessage: undefined,
264
+ inputProvided: true,
265
+ });
266
+ },
267
+ fail: (opts) => {
268
+ throw new Error(opts.message);
269
+ },
270
+ return: (payload) => Promise.resolve(payload),
271
+ };
272
+ const raw = await deck.executor(execContext);
273
+ return validateOutput(deck, raw, ctx.depth === 0);
274
+ }
275
+ async function runLlmDeck(ctx) {
276
+ const { deck, guardrails, depth, modelProvider, input, runId, inputProvided, initialUserMessage, } = ctx;
277
+ const actionCallId = randomId("action");
278
+ const start = performance.now();
279
+ const respondEnabled = Boolean(deck.respond);
280
+ const systemPrompt = buildSystemPrompt(deck);
281
+ const refToolCallId = randomId("call");
282
+ const messages = ctx.state?.messages
283
+ ? ctx.state.messages.map(sanitizeMessage)
284
+ : [];
285
+ const resumed = messages.length > 0;
286
+ const sendInit = Boolean(inputProvided) && input !== undefined && !resumed;
287
+ const idleController = createIdleController({
288
+ cfg: deck.handlers?.onIdle,
289
+ deck,
290
+ guardrails,
291
+ depth,
292
+ runId,
293
+ parentActionCallId: ctx.parentActionCallId,
294
+ modelProvider,
295
+ defaultModel: ctx.defaultModel,
296
+ modelOverride: ctx.modelOverride,
297
+ trace: ctx.trace,
298
+ stream: ctx.stream,
299
+ onStreamText: ctx.onStreamText,
300
+ pushMessages: (msgs) => messages.push(...msgs.map(sanitizeMessage)),
301
+ });
302
+ let streamingBuffer = "";
303
+ let streamingCommitted = false;
304
+ const wrappedOnStreamText = (chunk) => {
305
+ if (!chunk)
306
+ return;
307
+ idleController.touch();
308
+ streamingBuffer += chunk;
309
+ ctx.onStreamText?.(chunk);
310
+ };
311
+ if (!resumed) {
312
+ messages.push(sanitizeMessage({ role: "system", content: systemPrompt }));
313
+ if (sendInit) {
314
+ ctx.trace?.({
315
+ type: "tool.call",
316
+ runId,
317
+ actionCallId: refToolCallId,
318
+ name: GAMBIT_TOOL_INIT,
319
+ args: {},
320
+ parentActionCallId: actionCallId,
321
+ });
322
+ messages.push(sanitizeMessage({
323
+ role: "assistant",
324
+ content: null,
325
+ tool_calls: [{
326
+ id: refToolCallId,
327
+ type: "function",
328
+ function: {
329
+ name: GAMBIT_TOOL_INIT,
330
+ arguments: "{}",
331
+ },
332
+ }],
333
+ }), sanitizeMessage({
334
+ role: "tool",
335
+ name: GAMBIT_TOOL_INIT,
336
+ tool_call_id: refToolCallId,
337
+ content: JSON.stringify(input),
338
+ }));
339
+ ctx.trace?.({
340
+ type: "tool.result",
341
+ runId,
342
+ actionCallId: refToolCallId,
343
+ name: GAMBIT_TOOL_INIT,
344
+ result: input,
345
+ parentActionCallId: actionCallId,
346
+ });
347
+ }
348
+ }
349
+ if (initialUserMessage !== undefined) {
350
+ const userMessage = sanitizeMessage({
351
+ role: "user",
352
+ content: formatInputForUser(initialUserMessage),
353
+ });
354
+ messages.push(userMessage);
355
+ ctx.trace?.({
356
+ type: "message.user",
357
+ runId,
358
+ actionCallId,
359
+ deckPath: deck.path,
360
+ message: userMessage,
361
+ parentActionCallId: ctx.parentActionCallId,
362
+ });
363
+ }
364
+ idleController.touch();
365
+ const tools = await buildToolDefs(deck);
366
+ ctx.trace?.({
367
+ type: "deck.start",
368
+ runId,
369
+ deckPath: deck.path,
370
+ actionCallId,
371
+ parentActionCallId: ctx.parentActionCallId,
372
+ });
373
+ let passes = 0;
374
+ try {
375
+ while (passes < guardrails.maxPasses) {
376
+ passes++;
377
+ if (performance.now() - start > guardrails.timeoutMs) {
378
+ throw new Error("Timeout exceeded");
379
+ }
380
+ streamingBuffer = "";
381
+ streamingCommitted = false;
382
+ const model = ctx.modelOverride ??
383
+ deck.modelParams?.model ??
384
+ ctx.defaultModel ??
385
+ (() => {
386
+ throw new Error(`No model configured for deck ${deck.path} and no --model provided`);
387
+ })();
388
+ const stateMessages = ctx.state?.messages?.length;
389
+ ctx.trace?.({
390
+ type: "model.call",
391
+ runId,
392
+ actionCallId,
393
+ deckPath: deck.path,
394
+ model,
395
+ stream: ctx.stream,
396
+ messageCount: messages.length,
397
+ toolCount: tools.length,
398
+ messages: messages.map(sanitizeMessage),
399
+ tools,
400
+ stateMessages,
401
+ parentActionCallId: ctx.parentActionCallId,
402
+ });
403
+ const result = await modelProvider.chat({
404
+ model,
405
+ messages,
406
+ tools,
407
+ stream: ctx.stream,
408
+ state: ctx.state,
409
+ params: toProviderParams(deck.modelParams),
410
+ onStreamText: (ctx.onStreamText || deck.handlers?.onIdle)
411
+ ? wrappedOnStreamText
412
+ : undefined,
413
+ });
414
+ idleController.touch();
415
+ const message = result.message;
416
+ ctx.trace?.({
417
+ type: "model.result",
418
+ runId,
419
+ actionCallId,
420
+ deckPath: deck.path,
421
+ model,
422
+ finishReason: result.finishReason,
423
+ message: sanitizeMessage(message),
424
+ toolCalls: result.toolCalls,
425
+ stateMessages: result.updatedState?.messages?.length,
426
+ parentActionCallId: ctx.parentActionCallId,
427
+ });
428
+ const computeState = (updated) => {
429
+ const base = updated ??
430
+ { runId, messages: messages.map(sanitizeMessage) };
431
+ const mergedMessages = base.messages && base.messages.length > 0
432
+ ? base.messages.map(sanitizeMessage)
433
+ : messages.map(sanitizeMessage);
434
+ const priorRefs = updated?.messageRefs ?? ctx.state?.messageRefs ?? [];
435
+ const messageRefs = mergedMessages.map((m, idx) => priorRefs[idx] ?? { id: randomId("msg"), role: m.role });
436
+ const feedback = updated?.feedback ?? ctx.state?.feedback;
437
+ const traces = updated?.traces ?? ctx.state?.traces;
438
+ return {
439
+ ...base,
440
+ runId,
441
+ messages: mergedMessages,
442
+ messageRefs,
443
+ feedback,
444
+ traces,
445
+ };
446
+ };
447
+ if (result.toolCalls && result.toolCalls.length > 0) {
448
+ let responded = false;
449
+ let respondValue;
450
+ let endSignal;
451
+ const appendedMessages = [];
452
+ if (!streamingCommitted && streamingBuffer) {
453
+ messages.push(sanitizeMessage({ role: "assistant", content: streamingBuffer }));
454
+ streamingCommitted = true;
455
+ }
456
+ for (const call of result.toolCalls) {
457
+ if (respondEnabled && call.name === GAMBIT_TOOL_RESPOND) {
458
+ const status = typeof call.args?.status === "number"
459
+ ? call.args.status
460
+ : undefined;
461
+ const message = typeof call.args?.message === "string"
462
+ ? call.args.message
463
+ : undefined;
464
+ const code = typeof call.args?.code === "string"
465
+ ? call.args.code
466
+ : undefined;
467
+ const meta = (call.args?.meta &&
468
+ typeof call.args.meta === "object" &&
469
+ call.args.meta !== null)
470
+ ? call.args.meta
471
+ : undefined;
472
+ const rawPayload = call.args?.payload ?? call.args;
473
+ const validatedPayload = validateOutput(deck, rawPayload, depth === 0);
474
+ const respondEnvelope = {
475
+ payload: validatedPayload,
476
+ };
477
+ if (status !== undefined)
478
+ respondEnvelope.status = status;
479
+ if (message !== undefined)
480
+ respondEnvelope.message = message;
481
+ if (code !== undefined)
482
+ respondEnvelope.code = code;
483
+ if (meta !== undefined)
484
+ respondEnvelope.meta = meta;
485
+ ctx.trace?.({
486
+ type: "tool.call",
487
+ runId,
488
+ actionCallId: call.id,
489
+ name: call.name,
490
+ args: call.args,
491
+ parentActionCallId: actionCallId,
492
+ });
493
+ const toolContent = JSON.stringify(call.args ?? {});
494
+ appendedMessages.push({
495
+ role: "assistant",
496
+ content: null,
497
+ tool_calls: [{
498
+ id: call.id,
499
+ type: "function",
500
+ function: {
501
+ name: call.name,
502
+ arguments: JSON.stringify(call.args ?? {}),
503
+ },
504
+ }],
505
+ });
506
+ appendedMessages.push({
507
+ role: "tool",
508
+ tool_call_id: call.id,
509
+ name: call.name,
510
+ content: toolContent,
511
+ });
512
+ respondValue = respondEnvelope;
513
+ responded = true;
514
+ ctx.trace?.({
515
+ type: "tool.result",
516
+ runId,
517
+ actionCallId: call.id,
518
+ name: call.name,
519
+ result: respondEnvelope,
520
+ parentActionCallId: actionCallId,
521
+ });
522
+ continue;
523
+ }
524
+ if (deck.allowEnd && call.name === GAMBIT_TOOL_END) {
525
+ const status = typeof call.args?.status === "number"
526
+ ? call.args.status
527
+ : undefined;
528
+ const messageText = typeof call.args?.message === "string"
529
+ ? call.args.message
530
+ : undefined;
531
+ const code = typeof call.args?.code === "string"
532
+ ? call.args.code
533
+ : undefined;
534
+ const meta = (call.args?.meta &&
535
+ typeof call.args.meta === "object" &&
536
+ call.args.meta !== null)
537
+ ? call.args.meta
538
+ : undefined;
539
+ const payload = call.args?.payload;
540
+ ctx.trace?.({
541
+ type: "tool.call",
542
+ runId,
543
+ actionCallId: call.id,
544
+ name: call.name,
545
+ args: call.args,
546
+ parentActionCallId: actionCallId,
547
+ });
548
+ const toolContent = JSON.stringify(call.args ?? {});
549
+ appendedMessages.push({
550
+ role: "assistant",
551
+ content: null,
552
+ tool_calls: [{
553
+ id: call.id,
554
+ type: "function",
555
+ function: {
556
+ name: call.name,
557
+ arguments: JSON.stringify(call.args ?? {}),
558
+ },
559
+ }],
560
+ });
561
+ appendedMessages.push({
562
+ role: "tool",
563
+ tool_call_id: call.id,
564
+ name: call.name,
565
+ content: toolContent,
566
+ });
567
+ const signal = { __gambitEnd: true };
568
+ if (status !== undefined)
569
+ signal.status = status;
570
+ if (messageText !== undefined)
571
+ signal.message = messageText;
572
+ if (code !== undefined)
573
+ signal.code = code;
574
+ if (meta !== undefined)
575
+ signal.meta = meta;
576
+ if (payload !== undefined)
577
+ signal.payload = payload;
578
+ endSignal = signal;
579
+ ctx.trace?.({
580
+ type: "tool.result",
581
+ runId,
582
+ actionCallId: call.id,
583
+ name: call.name,
584
+ result: signal,
585
+ parentActionCallId: actionCallId,
586
+ });
587
+ continue;
588
+ }
589
+ ctx.trace?.({
590
+ type: "action.start",
591
+ runId,
592
+ actionCallId: call.id,
593
+ name: call.name,
594
+ path: call.name,
595
+ parentActionCallId: actionCallId,
596
+ });
597
+ ctx.trace?.({
598
+ type: "tool.call",
599
+ runId,
600
+ actionCallId: call.id,
601
+ name: call.name,
602
+ args: call.args,
603
+ parentActionCallId: actionCallId,
604
+ });
605
+ const toolResult = await handleToolCall(call, {
606
+ parentDeck: deck,
607
+ modelProvider,
608
+ guardrails,
609
+ depth,
610
+ runId,
611
+ parentActionCallId: actionCallId,
612
+ defaultModel: ctx.defaultModel,
613
+ modelOverride: ctx.modelOverride,
614
+ trace: ctx.trace,
615
+ onStreamText: (ctx.onStreamText || deck.handlers?.onIdle)
616
+ ? wrappedOnStreamText
617
+ : undefined,
618
+ runStartedAt: start,
619
+ inputProvided: true,
620
+ idle: idleController,
621
+ });
622
+ ctx.trace?.({
623
+ type: "tool.result",
624
+ runId,
625
+ actionCallId: call.id,
626
+ name: call.name,
627
+ result: toolResult.toolContent,
628
+ parentActionCallId: actionCallId,
629
+ });
630
+ appendedMessages.push({
631
+ role: "assistant",
632
+ content: null,
633
+ tool_calls: [{
634
+ id: call.id,
635
+ type: "function",
636
+ function: {
637
+ name: call.name,
638
+ arguments: JSON.stringify(call.args),
639
+ },
640
+ }],
641
+ });
642
+ appendedMessages.push({
643
+ role: "tool",
644
+ tool_call_id: call.id,
645
+ name: call.name,
646
+ content: toolResult.toolContent,
647
+ });
648
+ if (toolResult.extraMessages?.length) {
649
+ appendedMessages.push(...toolResult.extraMessages);
650
+ }
651
+ ctx.trace?.({
652
+ type: "action.end",
653
+ runId,
654
+ actionCallId: call.id,
655
+ name: call.name,
656
+ path: call.name,
657
+ parentActionCallId: actionCallId,
658
+ });
659
+ }
660
+ if (appendedMessages.length) {
661
+ messages.push(...appendedMessages.map(sanitizeMessage));
662
+ idleController.touch();
663
+ }
664
+ if (ctx.onStateUpdate) {
665
+ const state = computeState(result.updatedState);
666
+ ctx.onStateUpdate(state);
667
+ }
668
+ if (endSignal) {
669
+ ctx.trace?.({
670
+ type: "deck.end",
671
+ runId,
672
+ deckPath: deck.path,
673
+ actionCallId,
674
+ parentActionCallId: ctx.parentActionCallId,
675
+ });
676
+ return endSignal;
677
+ }
678
+ if (responded) {
679
+ ctx.trace?.({
680
+ type: "deck.end",
681
+ runId,
682
+ deckPath: deck.path,
683
+ actionCallId,
684
+ parentActionCallId: ctx.parentActionCallId,
685
+ });
686
+ return respondValue;
687
+ }
688
+ continue;
689
+ }
690
+ if (result.finishReason === "tool_calls") {
691
+ throw new Error("Model requested tool_calls but provided none");
692
+ }
693
+ if (result.finishReason === "length" &&
694
+ (message.content === null || message.content === undefined)) {
695
+ throw new Error("Model stopped early (length) with no content");
696
+ }
697
+ if (message.content !== null && message.content !== undefined) {
698
+ messages.push(sanitizeMessage(message));
699
+ if (ctx.onStateUpdate) {
700
+ const state = computeState(result.updatedState);
701
+ ctx.onStateUpdate(state);
702
+ }
703
+ if (ctx.parentActionCallId !== undefined &&
704
+ (!result.toolCalls || result.toolCalls.length === 0)) {
705
+ ctx.trace?.({
706
+ type: "monolog",
707
+ runId,
708
+ deckPath: deck.path,
709
+ actionCallId,
710
+ parentActionCallId: ctx.parentActionCallId,
711
+ content: message
712
+ .content,
713
+ });
714
+ }
715
+ if (!respondEnabled) {
716
+ const validated = validateOutput(deck, message.content, depth === 0);
717
+ ctx.trace?.({
718
+ type: "deck.end",
719
+ runId,
720
+ deckPath: deck.path,
721
+ actionCallId,
722
+ parentActionCallId: ctx.parentActionCallId,
723
+ });
724
+ return validated;
725
+ }
726
+ }
727
+ if (respondEnabled && result.finishReason === "stop") {
728
+ continue;
729
+ }
730
+ if (passes >= guardrails.maxPasses) {
731
+ throw new Error("Max passes exceeded without completing");
732
+ }
733
+ }
734
+ }
735
+ finally {
736
+ idleController.stop();
737
+ }
738
+ throw new Error("Model did not complete within guardrails");
739
+ }
740
+ async function handleToolCall(call, ctx) {
741
+ const action = ctx.parentDeck.actionDecks.find((a) => a.name === call.name);
742
+ const source = {
743
+ deckPath: ctx.parentDeck.path,
744
+ actionName: action?.name ?? call.name,
745
+ };
746
+ if (!action) {
747
+ return {
748
+ toolContent: JSON.stringify({
749
+ runId: ctx.runId,
750
+ actionCallId: call.id,
751
+ parentActionCallId: ctx.parentActionCallId,
752
+ source,
753
+ status: 404,
754
+ message: "unknown action",
755
+ }),
756
+ };
757
+ }
758
+ const baseComplete = (payload) => JSON.stringify({
759
+ runId: ctx.runId,
760
+ actionCallId: call.id,
761
+ parentActionCallId: ctx.parentActionCallId,
762
+ source,
763
+ status: payload.status,
764
+ payload: payload.payload,
765
+ message: payload.message,
766
+ code: payload.code,
767
+ meta: payload.meta,
768
+ });
769
+ const extraMessages = [];
770
+ const started = performance.now();
771
+ const busyCfg = ctx.parentDeck.handlers?.onBusy ??
772
+ ctx.parentDeck.handlers?.onInterval;
773
+ const busyDelay = busyCfg?.delayMs ?? DEFAULT_STATUS_DELAY_MS;
774
+ const busyRepeat = busyCfg?.repeatMs;
775
+ let busyTimer;
776
+ let busyFired = false;
777
+ let busyStopped = false;
778
+ let nextBusyAt = busyCfg?.path ? performance.now() + busyDelay : 0;
779
+ ctx.idle?.pause();
780
+ const childPromise = (async () => {
781
+ try {
782
+ const result = await runDeck({
783
+ path: action.path,
784
+ input: call.args,
785
+ modelProvider: ctx.modelProvider,
786
+ isRoot: false,
787
+ guardrails: ctx.guardrails,
788
+ depth: ctx.depth + 1,
789
+ parentActionCallId: call.id,
790
+ runId: ctx.runId,
791
+ defaultModel: ctx.defaultModel,
792
+ modelOverride: ctx.modelOverride,
793
+ trace: ctx.trace,
794
+ stream: ctx.stream,
795
+ onStreamText: ctx.onStreamText,
796
+ initialUserMessage: undefined,
797
+ });
798
+ return { ok: true, result };
799
+ }
800
+ catch (err) {
801
+ return { ok: false, error: err };
802
+ }
803
+ finally {
804
+ // Keep busy timers alive until the caller explicitly stops them
805
+ }
806
+ })();
807
+ const triggerBusy = async (elapsed) => {
808
+ if (busyStopped)
809
+ return;
810
+ busyFired = true;
811
+ try {
812
+ const envelope = await runBusyHandler({
813
+ parentDeck: ctx.parentDeck,
814
+ action,
815
+ call,
816
+ runId: ctx.runId,
817
+ parentActionCallId: ctx.parentActionCallId,
818
+ handlerPath: busyCfg.path,
819
+ modelProvider: ctx.modelProvider,
820
+ guardrails: ctx.guardrails,
821
+ depth: ctx.depth,
822
+ defaultModel: ctx.defaultModel,
823
+ modelOverride: ctx.modelOverride,
824
+ elapsedMs: elapsed,
825
+ trace: ctx.trace,
826
+ stream: ctx.stream,
827
+ onStreamText: ctx.onStreamText,
828
+ initialUserMessage: undefined,
829
+ });
830
+ if (envelope.length) {
831
+ extraMessages.push(...envelope.map(sanitizeMessage));
832
+ }
833
+ ctx.idle?.touch();
834
+ }
835
+ catch {
836
+ // ignore handler errors
837
+ }
838
+ };
839
+ const scheduleNextBusy = () => {
840
+ if (!busyCfg?.path || busyStopped)
841
+ return;
842
+ const now = performance.now();
843
+ const delay = Math.max(0, nextBusyAt - now);
844
+ busyTimer = setTimeout(async () => {
845
+ if (busyStopped)
846
+ return;
847
+ const elapsed = performance.now() - started;
848
+ await triggerBusy(elapsed);
849
+ if (busyRepeat && busyRepeat > 0) {
850
+ nextBusyAt += busyRepeat;
851
+ scheduleNextBusy();
852
+ }
853
+ }, delay);
854
+ };
855
+ if (busyCfg?.path) {
856
+ scheduleNextBusy();
857
+ }
858
+ const stopBusy = () => {
859
+ busyStopped = true;
860
+ if (busyTimer !== undefined) {
861
+ clearTimeout(busyTimer);
862
+ }
863
+ };
864
+ const childResult = await childPromise;
865
+ ctx.idle?.resume();
866
+ if (!childResult.ok) {
867
+ const handled = await maybeHandleError({
868
+ err: childResult.error,
869
+ call,
870
+ ctx,
871
+ action,
872
+ });
873
+ if (handled) {
874
+ if (handled.extraMessages) {
875
+ extraMessages.push(...handled.extraMessages);
876
+ }
877
+ stopBusy();
878
+ ctx.idle?.touch();
879
+ const content = handled.toolContent;
880
+ return { toolContent: content, extraMessages };
881
+ }
882
+ stopBusy();
883
+ throw childResult.error;
884
+ }
885
+ const normalized = normalizeChildResult(childResult.result);
886
+ const toolContent = baseComplete(normalized);
887
+ if (busyCfg?.path) {
888
+ const elapsedFromAction = performance.now() - started;
889
+ if (!busyFired && elapsedFromAction >= busyDelay) {
890
+ try {
891
+ const envelope = await runBusyHandler({
892
+ parentDeck: ctx.parentDeck,
893
+ action,
894
+ call,
895
+ runId: ctx.runId,
896
+ parentActionCallId: ctx.parentActionCallId,
897
+ handlerPath: busyCfg.path,
898
+ modelProvider: ctx.modelProvider,
899
+ guardrails: ctx.guardrails,
900
+ depth: ctx.depth,
901
+ defaultModel: ctx.defaultModel,
902
+ modelOverride: ctx.modelOverride,
903
+ elapsedMs: elapsedFromAction,
904
+ trace: ctx.trace,
905
+ stream: ctx.stream,
906
+ onStreamText: ctx.onStreamText,
907
+ initialUserMessage: undefined,
908
+ });
909
+ if (envelope.length) {
910
+ extraMessages.push(...envelope.map(sanitizeMessage));
911
+ }
912
+ ctx.idle?.touch();
913
+ }
914
+ catch {
915
+ // ignore handler errors
916
+ }
917
+ }
918
+ }
919
+ const completeEventId = randomId("event");
920
+ extraMessages.push({
921
+ role: "assistant",
922
+ content: null,
923
+ tool_calls: [{
924
+ id: completeEventId,
925
+ type: "function",
926
+ function: {
927
+ name: GAMBIT_TOOL_COMPLETE,
928
+ arguments: toolContent,
929
+ },
930
+ }],
931
+ }, {
932
+ role: "tool",
933
+ tool_call_id: completeEventId,
934
+ name: GAMBIT_TOOL_COMPLETE,
935
+ content: toolContent,
936
+ });
937
+ stopBusy();
938
+ ctx.idle?.touch();
939
+ return { toolContent, extraMessages };
940
+ }
941
+ function normalizeChildResult(result) {
942
+ if (result && typeof result === "object") {
943
+ const rec = result;
944
+ const status = typeof rec.status === "number" ? rec.status : undefined;
945
+ const message = typeof rec.message === "string" ? rec.message : undefined;
946
+ const code = typeof rec.code === "string" ? rec.code : undefined;
947
+ const meta = (rec.meta && typeof rec.meta === "object")
948
+ ? rec.meta
949
+ : undefined;
950
+ const payload = rec.payload ?? result;
951
+ return { status, payload, message, code, meta };
952
+ }
953
+ return { payload: result };
954
+ }
955
+ async function runBusyHandler(args) {
956
+ try {
957
+ const input = {
958
+ kind: "busy",
959
+ label: args.action.label ?? args.parentDeck.label,
960
+ source: { deckPath: args.parentDeck.path, actionName: args.action.name },
961
+ trigger: {
962
+ reason: "timeout",
963
+ elapsedMs: Math.floor(args.elapsedMs),
964
+ },
965
+ childInput: args.call.args,
966
+ };
967
+ const handlerOutput = await runDeck({
968
+ path: args.handlerPath,
969
+ input,
970
+ modelProvider: args.modelProvider,
971
+ isRoot: false,
972
+ guardrails: args.guardrails,
973
+ depth: args.depth + 1,
974
+ parentActionCallId: args.call.id,
975
+ runId: args.runId,
976
+ defaultModel: args.defaultModel,
977
+ modelOverride: args.modelOverride,
978
+ trace: args.trace,
979
+ stream: args.stream,
980
+ onStreamText: args.onStreamText,
981
+ initialUserMessage: args.initialUserMessage,
982
+ inputProvided: true,
983
+ });
984
+ const elapsedMs = Math.floor(args.elapsedMs);
985
+ let message;
986
+ if (typeof handlerOutput === "string") {
987
+ message = handlerOutput;
988
+ }
989
+ else if (handlerOutput && typeof handlerOutput === "object") {
990
+ if (typeof handlerOutput.message === "string") {
991
+ message = handlerOutput.message;
992
+ }
993
+ else {
994
+ message = JSON.stringify(handlerOutput);
995
+ }
996
+ }
997
+ if (!message)
998
+ return [];
999
+ if (args.onStreamText) {
1000
+ args.onStreamText(`${message}\n`);
1001
+ }
1002
+ else {
1003
+ logger.log(message);
1004
+ }
1005
+ return [{
1006
+ role: "assistant",
1007
+ content: `${message} (elapsed ${elapsedMs}ms)`,
1008
+ }];
1009
+ }
1010
+ catch {
1011
+ return [];
1012
+ }
1013
+ }
1014
+ function createIdleController(args) {
1015
+ if (!args.cfg?.path) {
1016
+ return {
1017
+ touch: () => { },
1018
+ pause: () => { },
1019
+ resume: () => { },
1020
+ stop: () => { },
1021
+ };
1022
+ }
1023
+ const delayMs = args.cfg.delayMs ?? DEFAULT_STATUS_DELAY_MS;
1024
+ const repeatMs = args.cfg.repeatMs;
1025
+ let timer;
1026
+ let paused = false;
1027
+ let stopped = false;
1028
+ let lastTouched = performance.now();
1029
+ const clear = () => {
1030
+ if (timer !== undefined)
1031
+ clearTimeout(timer);
1032
+ timer = undefined;
1033
+ };
1034
+ const schedule = () => {
1035
+ if (stopped || paused)
1036
+ return;
1037
+ clear();
1038
+ const now = performance.now();
1039
+ const remaining = Math.max(0, delayMs - (now - lastTouched));
1040
+ timer = setTimeout(async () => {
1041
+ if (stopped || paused)
1042
+ return;
1043
+ const elapsed = performance.now() - lastTouched;
1044
+ try {
1045
+ const envelope = await runIdleHandler({
1046
+ deck: args.deck,
1047
+ handlerPath: args.cfg.path,
1048
+ runId: args.runId,
1049
+ parentActionCallId: args.parentActionCallId,
1050
+ modelProvider: args.modelProvider,
1051
+ guardrails: args.guardrails,
1052
+ depth: args.depth,
1053
+ defaultModel: args.defaultModel,
1054
+ modelOverride: args.modelOverride,
1055
+ elapsedMs: elapsed,
1056
+ trace: args.trace,
1057
+ stream: args.stream,
1058
+ onStreamText: args.onStreamText,
1059
+ });
1060
+ if (envelope.length)
1061
+ args.pushMessages(envelope.map(sanitizeMessage));
1062
+ }
1063
+ catch {
1064
+ // ignore idle handler errors
1065
+ }
1066
+ if (repeatMs && repeatMs > 0) {
1067
+ lastTouched = performance.now();
1068
+ schedule();
1069
+ }
1070
+ }, remaining);
1071
+ };
1072
+ const touch = () => {
1073
+ if (stopped)
1074
+ return;
1075
+ lastTouched = performance.now();
1076
+ schedule();
1077
+ };
1078
+ const pause = () => {
1079
+ paused = true;
1080
+ clear();
1081
+ };
1082
+ const resume = () => {
1083
+ if (stopped)
1084
+ return;
1085
+ if (!paused)
1086
+ return;
1087
+ paused = false;
1088
+ schedule();
1089
+ };
1090
+ const stop = () => {
1091
+ stopped = true;
1092
+ clear();
1093
+ };
1094
+ return { touch, pause, resume, stop };
1095
+ }
1096
+ async function runIdleHandler(args) {
1097
+ try {
1098
+ const input = {
1099
+ kind: "idle",
1100
+ label: args.deck.label,
1101
+ source: { deckPath: args.deck.path },
1102
+ trigger: {
1103
+ reason: "idle_timeout",
1104
+ elapsedMs: Math.floor(args.elapsedMs),
1105
+ },
1106
+ };
1107
+ const handlerOutput = await runDeck({
1108
+ path: args.handlerPath,
1109
+ input,
1110
+ modelProvider: args.modelProvider,
1111
+ isRoot: false,
1112
+ guardrails: args.guardrails,
1113
+ depth: args.depth + 1,
1114
+ parentActionCallId: args.parentActionCallId,
1115
+ runId: args.runId,
1116
+ defaultModel: args.defaultModel,
1117
+ modelOverride: args.modelOverride,
1118
+ trace: args.trace,
1119
+ stream: args.stream,
1120
+ onStreamText: args.onStreamText,
1121
+ initialUserMessage: undefined,
1122
+ inputProvided: true,
1123
+ });
1124
+ const elapsedMs = Math.floor(args.elapsedMs);
1125
+ let message;
1126
+ if (typeof handlerOutput === "string") {
1127
+ message = handlerOutput;
1128
+ }
1129
+ else if (handlerOutput && typeof handlerOutput === "object") {
1130
+ if (typeof handlerOutput.message === "string") {
1131
+ message = handlerOutput.message;
1132
+ }
1133
+ else {
1134
+ message = JSON.stringify(handlerOutput);
1135
+ }
1136
+ }
1137
+ if (!message)
1138
+ return [];
1139
+ if (args.onStreamText) {
1140
+ args.onStreamText(`${message}\n`);
1141
+ }
1142
+ else {
1143
+ logger.log(message);
1144
+ }
1145
+ return [{
1146
+ role: "assistant",
1147
+ content: `${message} (idle for ${elapsedMs}ms)`,
1148
+ }];
1149
+ }
1150
+ catch {
1151
+ return [];
1152
+ }
1153
+ }
1154
+ async function maybeHandleError(args) {
1155
+ const handlerPath = args.ctx.parentDeck.handlers?.onError?.path;
1156
+ if (!handlerPath)
1157
+ return undefined;
1158
+ const message = args.err instanceof Error
1159
+ ? args.err.message
1160
+ : String(args.err);
1161
+ const envelopeInput = {
1162
+ kind: "error",
1163
+ label: args.action.label ?? args.ctx.parentDeck.label,
1164
+ source: {
1165
+ deckPath: args.ctx.parentDeck.path,
1166
+ actionName: args.action.name,
1167
+ },
1168
+ error: { message },
1169
+ childInput: args.call.args,
1170
+ };
1171
+ try {
1172
+ const handlerOutput = await runDeck({
1173
+ path: handlerPath,
1174
+ input: envelopeInput,
1175
+ modelProvider: args.ctx.modelProvider,
1176
+ isRoot: false,
1177
+ guardrails: args.ctx.guardrails,
1178
+ depth: args.ctx.depth + 1,
1179
+ parentActionCallId: args.call.id,
1180
+ runId: args.ctx.runId,
1181
+ defaultModel: args.ctx.defaultModel,
1182
+ modelOverride: args.ctx.modelOverride,
1183
+ trace: args.ctx.trace,
1184
+ stream: args.ctx.stream,
1185
+ onStreamText: args.ctx.onStreamText,
1186
+ initialUserMessage: undefined,
1187
+ inputProvided: true,
1188
+ });
1189
+ const parsed = typeof handlerOutput === "object" && handlerOutput !== null
1190
+ ? handlerOutput
1191
+ : undefined;
1192
+ const status = typeof parsed?.status === "number" ? parsed.status : 500;
1193
+ const code = typeof parsed?.code === "string" ? parsed.code : undefined;
1194
+ const messageOverride = typeof parsed?.message === "string"
1195
+ ? parsed.message
1196
+ : undefined;
1197
+ const meta = (parsed?.meta && typeof parsed.meta === "object")
1198
+ ? parsed.meta
1199
+ : undefined;
1200
+ const payload = parsed?.payload ?? handlerOutput;
1201
+ const content = JSON.stringify({
1202
+ runId: args.ctx.runId,
1203
+ actionCallId: args.call.id,
1204
+ parentActionCallId: args.ctx.parentActionCallId,
1205
+ source: {
1206
+ deckPath: args.ctx.parentDeck.path,
1207
+ actionName: args.action.name,
1208
+ },
1209
+ status,
1210
+ payload,
1211
+ message: messageOverride ?? message,
1212
+ code,
1213
+ meta,
1214
+ });
1215
+ const callId = randomId("event");
1216
+ const extraMessages = [
1217
+ {
1218
+ role: "assistant",
1219
+ content: null,
1220
+ tool_calls: [{
1221
+ id: callId,
1222
+ type: "function",
1223
+ function: {
1224
+ name: GAMBIT_TOOL_COMPLETE,
1225
+ arguments: content,
1226
+ },
1227
+ }],
1228
+ },
1229
+ {
1230
+ role: "tool",
1231
+ tool_call_id: callId,
1232
+ name: GAMBIT_TOOL_COMPLETE,
1233
+ content,
1234
+ },
1235
+ ];
1236
+ return { toolContent: content, extraMessages };
1237
+ }
1238
+ catch {
1239
+ // Fallback when the handler itself fails: still return a structured error envelope
1240
+ // so the assistant can continue gracefully.
1241
+ const status = 500;
1242
+ const messageOverride = `Handled error: ${message}`;
1243
+ const code = "HANDLER_FALLBACK";
1244
+ const content = JSON.stringify({
1245
+ runId: args.ctx.runId,
1246
+ actionCallId: args.call.id,
1247
+ parentActionCallId: args.ctx.parentActionCallId,
1248
+ source: {
1249
+ deckPath: args.ctx.parentDeck.path,
1250
+ actionName: args.action.name,
1251
+ },
1252
+ status,
1253
+ payload: envelopeInput,
1254
+ message: messageOverride,
1255
+ code,
1256
+ meta: { handlerFailed: true },
1257
+ });
1258
+ const callId = randomId("event");
1259
+ const extraMessages = [
1260
+ {
1261
+ role: "assistant",
1262
+ content: null,
1263
+ tool_calls: [{
1264
+ id: callId,
1265
+ type: "function",
1266
+ function: {
1267
+ name: GAMBIT_TOOL_COMPLETE,
1268
+ arguments: content,
1269
+ },
1270
+ }],
1271
+ },
1272
+ {
1273
+ role: "tool",
1274
+ tool_call_id: callId,
1275
+ name: GAMBIT_TOOL_COMPLETE,
1276
+ content,
1277
+ },
1278
+ ];
1279
+ return { toolContent: content, extraMessages };
1280
+ }
1281
+ }
1282
+ function buildSystemPrompt(deck) {
1283
+ const parts = [];
1284
+ const prompt = deck.body ?? deck.prompt;
1285
+ if (prompt)
1286
+ parts.push(prompt.trim());
1287
+ if (!deck.inlineEmbeds) {
1288
+ for (const card of deck.cards) {
1289
+ if (card.body)
1290
+ parts.push(card.body.trim());
1291
+ }
1292
+ }
1293
+ return parts.join("\n\n").trim();
1294
+ }
1295
+ function formatInputForUser(input) {
1296
+ if (typeof input === "string")
1297
+ return input;
1298
+ try {
1299
+ return JSON.stringify(input, null, 2);
1300
+ }
1301
+ catch {
1302
+ return String(input);
1303
+ }
1304
+ }
1305
+ function sanitizeMessage(msg) {
1306
+ const toolCalls = msg.tool_calls && msg.tool_calls.length > 0
1307
+ ? msg.tool_calls
1308
+ : undefined;
1309
+ return { ...msg, tool_calls: toolCalls };
1310
+ }
1311
+ async function buildToolDefs(deck) {
1312
+ const defs = [];
1313
+ if (deck.allowEnd) {
1314
+ defs.push({
1315
+ type: "function",
1316
+ function: {
1317
+ name: GAMBIT_TOOL_END,
1318
+ description: "End the current run once all goals are complete.",
1319
+ parameters: {
1320
+ type: "object",
1321
+ properties: {
1322
+ status: { type: "number" },
1323
+ payload: {},
1324
+ message: { type: "string" },
1325
+ code: { type: "string" },
1326
+ meta: { type: "object" },
1327
+ },
1328
+ additionalProperties: true,
1329
+ },
1330
+ },
1331
+ });
1332
+ }
1333
+ if (deck.respond) {
1334
+ defs.push({
1335
+ type: "function",
1336
+ function: {
1337
+ name: GAMBIT_TOOL_RESPOND,
1338
+ description: "Finish the current deck with a structured response.",
1339
+ parameters: {
1340
+ type: "object",
1341
+ properties: {
1342
+ status: { type: "number" },
1343
+ payload: {},
1344
+ message: { type: "string" },
1345
+ code: { type: "string" },
1346
+ meta: { type: "object" },
1347
+ },
1348
+ additionalProperties: true,
1349
+ },
1350
+ },
1351
+ });
1352
+ }
1353
+ for (const action of deck.actionDecks) {
1354
+ const child = await loadDeck(action.path, deck.path);
1355
+ ensureSchemaPresence(child, false);
1356
+ const schema = child.inputSchema;
1357
+ const params = toJsonSchema(schema);
1358
+ defs.push({
1359
+ type: "function",
1360
+ function: {
1361
+ name: action.name,
1362
+ description: action.description,
1363
+ parameters: params,
1364
+ },
1365
+ });
1366
+ }
1367
+ return defs;
1368
+ }