@warlock.js/ai 4.2.11 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/cjs/index.cjs +10151 -4625
  3. package/cjs/index.cjs.map +1 -1
  4. package/cjs/magic-string.es-BtxW4VqG.cjs +1015 -0
  5. package/cjs/magic-string.es-BtxW4VqG.cjs.map +1 -0
  6. package/cjs/matcher-logic-SBnzYohQ.cjs +217 -0
  7. package/cjs/matcher-logic-SBnzYohQ.cjs.map +1 -0
  8. package/cjs/matchers-BBh3gyB-.cjs +13739 -0
  9. package/cjs/matchers-BBh3gyB-.cjs.map +1 -0
  10. package/esm/agent/agent-config.type.d.mts +19 -6
  11. package/esm/agent/agent-config.type.d.mts.map +1 -1
  12. package/esm/agent/agent.d.mts.map +1 -1
  13. package/esm/agent/agent.mjs +17 -6
  14. package/esm/agent/agent.mjs.map +1 -1
  15. package/esm/agent/index.d.mts +2 -1
  16. package/esm/agent/index.mjs +1 -0
  17. package/esm/agent/spawn-sub-agent.d.mts +87 -0
  18. package/esm/agent/spawn-sub-agent.d.mts.map +1 -0
  19. package/esm/agent/spawn-sub-agent.mjs +68 -0
  20. package/esm/agent/spawn-sub-agent.mjs.map +1 -0
  21. package/esm/ai.d.mts +58 -3
  22. package/esm/ai.d.mts.map +1 -1
  23. package/esm/ai.mjs +58 -3
  24. package/esm/ai.mjs.map +1 -1
  25. package/esm/batch/batch.d.mts +43 -0
  26. package/esm/batch/batch.d.mts.map +1 -0
  27. package/esm/batch/batch.mjs +179 -0
  28. package/esm/batch/batch.mjs.map +1 -0
  29. package/esm/batch/batch.type.d.mts +144 -0
  30. package/esm/batch/batch.type.d.mts.map +1 -0
  31. package/esm/batch/index.mjs +3 -0
  32. package/esm/batch/run-batch-item.mjs +100 -0
  33. package/esm/batch/run-batch-item.mjs.map +1 -0
  34. package/esm/batch/run-with-concurrency.mjs +39 -0
  35. package/esm/batch/run-with-concurrency.mjs.map +1 -0
  36. package/esm/checkpoint/index.d.mts +3 -0
  37. package/esm/checkpoint/memory.d.mts +21 -0
  38. package/esm/checkpoint/memory.d.mts.map +1 -0
  39. package/esm/checkpoint/memory.mjs +0 -0
  40. package/esm/checkpoint/memory.mjs.map +1 -0
  41. package/esm/checkpoint/pg.d.mts +37 -0
  42. package/esm/checkpoint/pg.d.mts.map +1 -0
  43. package/esm/checkpoint/pg.mjs +265 -0
  44. package/esm/checkpoint/pg.mjs.map +1 -0
  45. package/esm/checkpoint/redis.d.mts +39 -0
  46. package/esm/checkpoint/redis.d.mts.map +1 -0
  47. package/esm/checkpoint/redis.mjs +200 -0
  48. package/esm/checkpoint/redis.mjs.map +1 -0
  49. package/esm/config.d.mts +61 -14
  50. package/esm/config.d.mts.map +1 -1
  51. package/esm/config.mjs +25 -6
  52. package/esm/config.mjs.map +1 -1
  53. package/esm/contracts/agent/agent.contract.d.mts +43 -0
  54. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  55. package/esm/contracts/agent/eval.type.d.mts +143 -0
  56. package/esm/contracts/agent/eval.type.d.mts.map +1 -0
  57. package/esm/contracts/agent/index.d.mts +1 -0
  58. package/esm/contracts/events/supervisor-events.type.d.mts +3 -3
  59. package/esm/contracts/fallback-model.contract.d.mts +65 -0
  60. package/esm/contracts/fallback-model.contract.d.mts.map +1 -0
  61. package/esm/contracts/index.d.mts +32 -12
  62. package/esm/contracts/memory/index.d.mts +4 -0
  63. package/esm/contracts/memory/memory-config.type.d.mts +150 -0
  64. package/esm/contracts/memory/memory-config.type.d.mts.map +1 -0
  65. package/esm/contracts/memory/memory-item.type.d.mts +64 -0
  66. package/esm/contracts/memory/memory-item.type.d.mts.map +1 -0
  67. package/esm/contracts/memory/memory.contract.d.mts +87 -0
  68. package/esm/contracts/memory/memory.contract.d.mts.map +1 -0
  69. package/esm/contracts/memory/recall-options.type.d.mts +33 -0
  70. package/esm/contracts/memory/recall-options.type.d.mts.map +1 -0
  71. package/esm/contracts/middleware/index.d.mts +2 -2
  72. package/esm/contracts/middleware/middleware-context.type.d.mts +42 -2
  73. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
  74. package/esm/contracts/middleware/middleware.contract.d.mts +46 -2
  75. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
  76. package/esm/contracts/model.contract.d.mts +63 -2
  77. package/esm/contracts/model.contract.d.mts.map +1 -1
  78. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +91 -0
  79. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -0
  80. package/esm/contracts/orchestrator/index.d.mts +8 -0
  81. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +43 -0
  82. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -0
  83. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +170 -0
  84. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -0
  85. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +118 -0
  86. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -0
  87. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +44 -0
  88. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -0
  89. package/esm/contracts/orchestrator/orchestrator.contract.d.mts +129 -0
  90. package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -0
  91. package/esm/contracts/orchestrator/session.contract.d.mts +26 -0
  92. package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -0
  93. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +89 -0
  94. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -0
  95. package/esm/contracts/planner/index.d.mts +6 -0
  96. package/esm/contracts/planner/planner-capability.type.d.mts +39 -0
  97. package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -0
  98. package/esm/contracts/planner/planner-config.type.d.mts +78 -0
  99. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -0
  100. package/esm/contracts/planner/planner-execute-options.type.d.mts +43 -0
  101. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -0
  102. package/esm/contracts/planner/planner-plan.type.d.mts +48 -0
  103. package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -0
  104. package/esm/contracts/planner/planner-result.type.d.mts +82 -0
  105. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -0
  106. package/esm/contracts/planner/planner.contract.d.mts +60 -0
  107. package/esm/contracts/planner/planner.contract.d.mts.map +1 -0
  108. package/esm/contracts/result/base-report.type.d.mts +7 -2
  109. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  110. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  111. package/esm/contracts/result/index.d.mts +2 -1
  112. package/esm/contracts/result/model-pricing.type.d.mts +10 -0
  113. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
  114. package/esm/contracts/result/orchestrator-result.type.d.mts +139 -0
  115. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -0
  116. package/esm/contracts/result/session-send-result.type.d.mts +12 -3
  117. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
  118. package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
  119. package/esm/contracts/result/usage.type.d.mts +24 -0
  120. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  121. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  122. package/esm/contracts/supervisor/dispatch-context.type.d.mts +3 -3
  123. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  124. package/esm/contracts/supervisor/index.d.mts +5 -5
  125. package/esm/contracts/supervisor/route-context.type.d.mts +2 -2
  126. package/esm/contracts/supervisor/supervisor-config.type.d.mts +55 -13
  127. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  128. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  129. package/esm/contracts/supervisor/supervisor.contract.d.mts +9 -2
  130. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  131. package/esm/contracts/workflow/index.d.mts +2 -2
  132. package/esm/contracts/workflow/workflow.contract.d.mts +28 -7
  133. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  134. package/esm/errors/error-code.type.d.mts +1 -1
  135. package/esm/errors/index.d.mts +7 -0
  136. package/esm/errors/index.mjs +7 -0
  137. package/esm/errors/orchestrator-cancelled-error.d.mts +32 -0
  138. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -0
  139. package/esm/errors/orchestrator-cancelled-error.mjs +31 -0
  140. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -0
  141. package/esm/errors/orchestrator-config-error.d.mts +26 -0
  142. package/esm/errors/orchestrator-config-error.d.mts.map +1 -0
  143. package/esm/errors/orchestrator-config-error.mjs +30 -0
  144. package/esm/errors/orchestrator-config-error.mjs.map +1 -0
  145. package/esm/errors/orchestrator-drift-error.d.mts +38 -0
  146. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -0
  147. package/esm/errors/orchestrator-drift-error.mjs +37 -0
  148. package/esm/errors/orchestrator-drift-error.mjs.map +1 -0
  149. package/esm/errors/orchestrator-failed-error.d.mts +33 -0
  150. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -0
  151. package/esm/errors/orchestrator-failed-error.mjs +36 -0
  152. package/esm/errors/orchestrator-failed-error.mjs.map +1 -0
  153. package/esm/errors/planner-cancelled-error.d.mts +33 -0
  154. package/esm/errors/planner-cancelled-error.d.mts.map +1 -0
  155. package/esm/errors/planner-cancelled-error.mjs +29 -0
  156. package/esm/errors/planner-cancelled-error.mjs.map +1 -0
  157. package/esm/errors/planner-failed-error.d.mts +40 -0
  158. package/esm/errors/planner-failed-error.d.mts.map +1 -0
  159. package/esm/errors/planner-failed-error.mjs +37 -0
  160. package/esm/errors/planner-failed-error.mjs.map +1 -0
  161. package/esm/errors/planner-plan-invalid-error.d.mts +21 -0
  162. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -0
  163. package/esm/errors/planner-plan-invalid-error.mjs +25 -0
  164. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -0
  165. package/esm/eval/eval-runner.d.mts +17 -0
  166. package/esm/eval/eval-runner.d.mts.map +1 -0
  167. package/esm/eval/eval-runner.mjs +121 -0
  168. package/esm/eval/eval-runner.mjs.map +1 -0
  169. package/esm/eval/index.d.mts +29 -0
  170. package/esm/eval/index.d.mts.map +1 -0
  171. package/esm/eval/index.mjs +30 -0
  172. package/esm/eval/index.mjs.map +1 -0
  173. package/esm/eval/judge-scorer.d.mts +21 -0
  174. package/esm/eval/judge-scorer.d.mts.map +1 -0
  175. package/esm/eval/judge-scorer.mjs +87 -0
  176. package/esm/eval/judge-scorer.mjs.map +1 -0
  177. package/esm/eval/scorers.d.mts +50 -0
  178. package/esm/eval/scorers.d.mts.map +1 -0
  179. package/esm/eval/scorers.mjs +101 -0
  180. package/esm/eval/scorers.mjs.map +1 -0
  181. package/esm/index.d.mts +95 -30
  182. package/esm/index.mjs +66 -22
  183. package/esm/memory/derive-id.mjs +24 -0
  184. package/esm/memory/derive-id.mjs.map +1 -0
  185. package/esm/memory/episodic-memory.mjs +106 -0
  186. package/esm/memory/episodic-memory.mjs.map +1 -0
  187. package/esm/memory/index.d.mts +5 -0
  188. package/esm/memory/memory.d.mts +42 -0
  189. package/esm/memory/memory.d.mts.map +1 -0
  190. package/esm/memory/memory.mjs +166 -0
  191. package/esm/memory/memory.mjs.map +1 -0
  192. package/esm/memory/procedural-memory.mjs +103 -0
  193. package/esm/memory/procedural-memory.mjs.map +1 -0
  194. package/esm/memory/semantic-memory.mjs +80 -0
  195. package/esm/memory/semantic-memory.mjs.map +1 -0
  196. package/esm/memory/working-memory.mjs +62 -0
  197. package/esm/memory/working-memory.mjs.map +1 -0
  198. package/esm/middleware/builtins/budget-contract.type.d.mts +126 -0
  199. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -0
  200. package/esm/middleware/builtins/budget.d.mts +71 -1
  201. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  202. package/esm/middleware/builtins/budget.mjs +119 -4
  203. package/esm/middleware/builtins/budget.mjs.map +1 -1
  204. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  205. package/esm/middleware/index.d.mts +2 -1
  206. package/esm/middleware/index.mjs +1 -1
  207. package/esm/middleware/pipeline.d.mts +9 -6
  208. package/esm/middleware/pipeline.d.mts.map +1 -1
  209. package/esm/middleware/pipeline.mjs.map +1 -1
  210. package/esm/mock/index.d.mts +1 -0
  211. package/esm/mock/index.mjs +1 -0
  212. package/esm/mock/mock-router.d.mts +63 -0
  213. package/esm/mock/mock-router.d.mts.map +1 -0
  214. package/esm/mock/mock-router.mjs +58 -0
  215. package/esm/mock/mock-router.mjs.map +1 -0
  216. package/esm/model/fallback-model.d.mts +45 -0
  217. package/esm/model/fallback-model.d.mts.map +1 -0
  218. package/esm/model/fallback-model.mjs +218 -0
  219. package/esm/model/fallback-model.mjs.map +1 -0
  220. package/esm/model/index.d.mts +2 -0
  221. package/esm/model/index.mjs +3 -0
  222. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  223. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  224. package/esm/node_modules/@vitest/expect/dist/index.mjs +1473 -0
  225. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  226. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +888 -0
  227. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  228. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1533 -0
  229. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -0
  230. package/esm/node_modules/@vitest/runner/dist/index.mjs +3 -0
  231. package/esm/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  232. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +922 -0
  233. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  234. package/esm/node_modules/@vitest/spy/dist/index.mjs +386 -0
  235. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  236. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +82 -0
  237. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -0
  238. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1357 -0
  239. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  240. package/esm/node_modules/@vitest/utils/dist/display.mjs +559 -0
  241. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -0
  242. package/esm/node_modules/@vitest/utils/dist/error.mjs +38 -0
  243. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  244. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +181 -0
  245. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  246. package/esm/node_modules/@vitest/utils/dist/offset.mjs +27 -0
  247. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -0
  248. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +77 -0
  249. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -0
  250. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +374 -0
  251. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  252. package/esm/node_modules/@vitest/utils/dist/timers.mjs +37 -0
  253. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -0
  254. package/esm/node_modules/chai/index.mjs +2973 -0
  255. package/esm/node_modules/chai/index.mjs.map +1 -0
  256. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  257. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  258. package/esm/node_modules/tinyrainbow/dist/index.mjs +87 -0
  259. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -0
  260. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +6 -0
  261. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -0
  262. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +52 -0
  263. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -0
  264. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +2697 -0
  265. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -0
  266. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +45 -0
  267. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -0
  268. package/esm/orchestrator/as-tool.d.mts +42 -0
  269. package/esm/orchestrator/as-tool.d.mts.map +1 -0
  270. package/esm/orchestrator/as-tool.mjs +98 -0
  271. package/esm/orchestrator/as-tool.mjs.map +1 -0
  272. package/esm/orchestrator/checkpoint.mjs +75 -0
  273. package/esm/orchestrator/checkpoint.mjs.map +1 -0
  274. package/esm/orchestrator/commands.d.mts +38 -0
  275. package/esm/orchestrator/commands.d.mts.map +1 -0
  276. package/esm/orchestrator/commands.mjs +34 -0
  277. package/esm/orchestrator/commands.mjs.map +1 -0
  278. package/esm/orchestrator/compaction.mjs +206 -0
  279. package/esm/orchestrator/compaction.mjs.map +1 -0
  280. package/esm/orchestrator/dispatch.mjs +171 -0
  281. package/esm/orchestrator/dispatch.mjs.map +1 -0
  282. package/esm/orchestrator/emitter-port.type.d.mts +31 -0
  283. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -0
  284. package/esm/orchestrator/emitter.d.mts +56 -0
  285. package/esm/orchestrator/emitter.d.mts.map +1 -0
  286. package/esm/orchestrator/emitter.mjs +85 -0
  287. package/esm/orchestrator/emitter.mjs.map +1 -0
  288. package/esm/orchestrator/engine-context.type.d.mts +56 -0
  289. package/esm/orchestrator/engine-context.type.d.mts.map +1 -0
  290. package/esm/orchestrator/execution.d.mts +116 -0
  291. package/esm/orchestrator/execution.d.mts.map +1 -0
  292. package/esm/orchestrator/execution.mjs +406 -0
  293. package/esm/orchestrator/execution.mjs.map +1 -0
  294. package/esm/orchestrator/index.d.mts +8 -0
  295. package/esm/orchestrator/index.mjs +10 -0
  296. package/esm/orchestrator/load.mjs +49 -0
  297. package/esm/orchestrator/load.mjs.map +1 -0
  298. package/esm/orchestrator/lock.mjs +75 -0
  299. package/esm/orchestrator/lock.mjs.map +1 -0
  300. package/esm/orchestrator/memory.d.mts +84 -0
  301. package/esm/orchestrator/memory.d.mts.map +1 -0
  302. package/esm/orchestrator/memory.mjs +141 -0
  303. package/esm/orchestrator/memory.mjs.map +1 -0
  304. package/esm/orchestrator/orchestrator-stream.d.mts +42 -0
  305. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -0
  306. package/esm/orchestrator/orchestrator-stream.mjs +98 -0
  307. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -0
  308. package/esm/orchestrator/orchestrator.d.mts +38 -0
  309. package/esm/orchestrator/orchestrator.d.mts.map +1 -0
  310. package/esm/orchestrator/orchestrator.mjs +173 -0
  311. package/esm/orchestrator/orchestrator.mjs.map +1 -0
  312. package/esm/orchestrator/resume.mjs +74 -0
  313. package/esm/orchestrator/resume.mjs.map +1 -0
  314. package/esm/orchestrator/signature.d.mts +40 -0
  315. package/esm/orchestrator/signature.d.mts.map +1 -0
  316. package/esm/orchestrator/signature.mjs +120 -0
  317. package/esm/orchestrator/signature.mjs.map +1 -0
  318. package/esm/orchestrator/window.mjs +56 -0
  319. package/esm/orchestrator/window.mjs.map +1 -0
  320. package/esm/planner/index.d.mts +5 -0
  321. package/esm/planner/index.mjs +6 -0
  322. package/esm/planner/plan-prompt.d.mts +17 -0
  323. package/esm/planner/plan-prompt.d.mts.map +1 -0
  324. package/esm/planner/plan-prompt.mjs +30 -0
  325. package/esm/planner/plan-prompt.mjs.map +1 -0
  326. package/esm/planner/plan-schema.d.mts +27 -0
  327. package/esm/planner/plan-schema.d.mts.map +1 -0
  328. package/esm/planner/plan-schema.mjs +117 -0
  329. package/esm/planner/plan-schema.mjs.map +1 -0
  330. package/esm/planner/planner-run.d.mts +23 -0
  331. package/esm/planner/planner-run.d.mts.map +1 -0
  332. package/esm/planner/planner-run.mjs +344 -0
  333. package/esm/planner/planner-run.mjs.map +1 -0
  334. package/esm/planner/planner.d.mts +37 -0
  335. package/esm/planner/planner.d.mts.map +1 -0
  336. package/esm/planner/planner.mjs +120 -0
  337. package/esm/planner/planner.mjs.map +1 -0
  338. package/esm/planner/signature.d.mts +18 -0
  339. package/esm/planner/signature.d.mts.map +1 -0
  340. package/esm/planner/signature.mjs +27 -0
  341. package/esm/planner/signature.mjs.map +1 -0
  342. package/esm/snapshot/index.d.mts +3 -0
  343. package/esm/snapshot/memory.d.mts +26 -0
  344. package/esm/snapshot/memory.d.mts.map +1 -0
  345. package/esm/snapshot/memory.mjs +81 -0
  346. package/esm/snapshot/memory.mjs.map +1 -0
  347. package/esm/snapshot/pg.d.mts +41 -0
  348. package/esm/snapshot/pg.d.mts.map +1 -0
  349. package/esm/snapshot/pg.mjs +146 -0
  350. package/esm/snapshot/pg.mjs.map +1 -0
  351. package/esm/snapshot/redis.d.mts +42 -0
  352. package/esm/snapshot/redis.d.mts.map +1 -0
  353. package/esm/snapshot/redis.mjs +101 -0
  354. package/esm/snapshot/redis.mjs.map +1 -0
  355. package/esm/supervisor/as-tool.d.mts +0 -6
  356. package/esm/supervisor/as-tool.d.mts.map +1 -1
  357. package/esm/supervisor/as-tool.mjs +0 -6
  358. package/esm/supervisor/as-tool.mjs.map +1 -1
  359. package/esm/supervisor/execution.d.mts +43 -8
  360. package/esm/supervisor/execution.d.mts.map +1 -1
  361. package/esm/supervisor/execution.mjs +66 -16
  362. package/esm/supervisor/execution.mjs.map +1 -1
  363. package/esm/supervisor/fan-out.d.mts +65 -0
  364. package/esm/supervisor/fan-out.d.mts.map +1 -0
  365. package/esm/supervisor/fan-out.mjs +65 -0
  366. package/esm/supervisor/fan-out.mjs.map +1 -0
  367. package/esm/supervisor/index.d.mts +5 -3
  368. package/esm/supervisor/index.mjs +3 -1
  369. package/esm/supervisor/router-factory.d.mts +110 -0
  370. package/esm/supervisor/router-factory.d.mts.map +1 -0
  371. package/esm/supervisor/router-factory.mjs +141 -0
  372. package/esm/supervisor/router-factory.mjs.map +1 -0
  373. package/esm/supervisor/router-prompt.d.mts +1 -1
  374. package/esm/supervisor/snapshot.d.mts +4 -10
  375. package/esm/supervisor/snapshot.d.mts.map +1 -1
  376. package/esm/supervisor/snapshot.mjs +8 -16
  377. package/esm/supervisor/snapshot.mjs.map +1 -1
  378. package/esm/supervisor/supervisor.mjs +1 -0
  379. package/esm/supervisor/supervisor.mjs.map +1 -1
  380. package/esm/system-prompt/index.mjs +6 -0
  381. package/esm/system-prompt/system-prompt.d.mts +51 -3
  382. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  383. package/esm/system-prompt/system-prompt.mjs +52 -6
  384. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  385. package/esm/testing/matcher-logic.d.mts +76 -0
  386. package/esm/testing/matcher-logic.d.mts.map +1 -0
  387. package/esm/testing/matcher-logic.mjs +144 -0
  388. package/esm/testing/matcher-logic.mjs.map +1 -0
  389. package/esm/testing/matchers.d.mts +48 -0
  390. package/esm/testing/matchers.d.mts.map +1 -0
  391. package/esm/testing/matchers.mjs +37 -0
  392. package/esm/testing/matchers.mjs.map +1 -0
  393. package/esm/testing/register-lazy.d.mts +20 -0
  394. package/esm/testing/register-lazy.d.mts.map +1 -0
  395. package/esm/testing/register-lazy.mjs +24 -0
  396. package/esm/testing/register-lazy.mjs.map +1 -0
  397. package/esm/tool/executable-as-tool.d.mts +87 -0
  398. package/esm/tool/executable-as-tool.d.mts.map +1 -0
  399. package/esm/tool/executable-as-tool.mjs +81 -0
  400. package/esm/tool/executable-as-tool.mjs.map +1 -0
  401. package/esm/tool/index.d.mts +2 -1
  402. package/esm/tool/index.mjs +1 -0
  403. package/esm/workflow/as-tool.mjs +0 -6
  404. package/esm/workflow/as-tool.mjs.map +1 -1
  405. package/esm/workflow/engine.mjs +2 -2
  406. package/esm/workflow/snapshot.mjs +13 -7
  407. package/esm/workflow/snapshot.mjs.map +1 -1
  408. package/esm/workflow/step-runner.mjs +1 -1
  409. package/esm/workflow/workflow.mjs +1 -0
  410. package/esm/workflow/workflow.mjs.map +1 -1
  411. package/llms-full.txt +947 -42
  412. package/llms.txt +13 -8
  413. package/package.json +3 -3
  414. package/skills/README.md +25 -5
  415. package/skills/ai-basics/SKILL.md +18 -7
  416. package/skills/ai-dx-helpers/SKILL.md +180 -0
  417. package/skills/attach-ai-middleware/SKILL.md +32 -3
  418. package/skills/handle-ai-errors/SKILL.md +20 -6
  419. package/skills/manage-ai-stores/SKILL.md +127 -0
  420. package/skills/persist-ai-data/SKILL.md +21 -10
  421. package/skills/pick-ai-provider/SKILL.md +46 -12
  422. package/skills/run-ai-agent/SKILL.md +51 -2
  423. package/skills/run-orchestrator/SKILL.md +198 -0
  424. package/skills/run-planner/SKILL.md +68 -0
  425. package/skills/run-supervisor/SKILL.md +47 -2
  426. package/skills/use-ai-memory/SKILL.md +124 -0
  427. package/skills/write-system-prompt/SKILL.md +14 -1
@@ -0,0 +1,1015 @@
1
+
2
+ //#region ../@warlock.js/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
3
+ var comma = ",".charCodeAt(0);
4
+ var semicolon = ";".charCodeAt(0);
5
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6
+ var intToChar = new Uint8Array(64);
7
+ var charToInt = new Uint8Array(128);
8
+ for (let i = 0; i < chars.length; i++) {
9
+ const c = chars.charCodeAt(i);
10
+ intToChar[i] = c;
11
+ charToInt[c] = i;
12
+ }
13
+ function encodeInteger(builder, num, relative) {
14
+ let delta = num - relative;
15
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
16
+ do {
17
+ let clamped = delta & 31;
18
+ delta >>>= 5;
19
+ if (delta > 0) clamped |= 32;
20
+ builder.write(intToChar[clamped]);
21
+ } while (delta > 0);
22
+ return num;
23
+ }
24
+ var bufLength = 1024 * 16;
25
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
26
+ return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
27
+ } } : { decode(buf) {
28
+ let out = "";
29
+ for (let i = 0; i < buf.length; i++) out += String.fromCharCode(buf[i]);
30
+ return out;
31
+ } };
32
+ var StringWriter = class {
33
+ constructor() {
34
+ this.pos = 0;
35
+ this.out = "";
36
+ this.buffer = new Uint8Array(bufLength);
37
+ }
38
+ write(v) {
39
+ const { buffer } = this;
40
+ buffer[this.pos++] = v;
41
+ if (this.pos === bufLength) {
42
+ this.out += td.decode(buffer);
43
+ this.pos = 0;
44
+ }
45
+ }
46
+ flush() {
47
+ const { buffer, out, pos } = this;
48
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
49
+ }
50
+ };
51
+ function encode(decoded) {
52
+ const writer = new StringWriter();
53
+ let sourcesIndex = 0;
54
+ let sourceLine = 0;
55
+ let sourceColumn = 0;
56
+ let namesIndex = 0;
57
+ for (let i = 0; i < decoded.length; i++) {
58
+ const line = decoded[i];
59
+ if (i > 0) writer.write(semicolon);
60
+ if (line.length === 0) continue;
61
+ let genColumn = 0;
62
+ for (let j = 0; j < line.length; j++) {
63
+ const segment = line[j];
64
+ if (j > 0) writer.write(comma);
65
+ genColumn = encodeInteger(writer, segment[0], genColumn);
66
+ if (segment.length === 1) continue;
67
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
68
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
69
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
70
+ if (segment.length === 4) continue;
71
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
72
+ }
73
+ }
74
+ return writer.flush();
75
+ }
76
+
77
+ //#endregion
78
+ //#region ../@warlock.js/node_modules/magic-string/dist/magic-string.es.mjs
79
+ var BitSet = class BitSet {
80
+ constructor(arg) {
81
+ this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
82
+ }
83
+ add(n) {
84
+ this.bits[n >> 5] |= 1 << (n & 31);
85
+ }
86
+ has(n) {
87
+ return !!(this.bits[n >> 5] & 1 << (n & 31));
88
+ }
89
+ };
90
+ var Chunk = class Chunk {
91
+ constructor(start, end, content) {
92
+ this.start = start;
93
+ this.end = end;
94
+ this.original = content;
95
+ this.intro = "";
96
+ this.outro = "";
97
+ this.content = content;
98
+ this.storeName = false;
99
+ this.edited = false;
100
+ this.previous = null;
101
+ this.next = null;
102
+ }
103
+ appendLeft(content) {
104
+ this.outro += content;
105
+ }
106
+ appendRight(content) {
107
+ this.intro = this.intro + content;
108
+ }
109
+ clone() {
110
+ const chunk = new Chunk(this.start, this.end, this.original);
111
+ chunk.intro = this.intro;
112
+ chunk.outro = this.outro;
113
+ chunk.content = this.content;
114
+ chunk.storeName = this.storeName;
115
+ chunk.edited = this.edited;
116
+ return chunk;
117
+ }
118
+ contains(index) {
119
+ return this.start < index && index < this.end;
120
+ }
121
+ eachNext(fn) {
122
+ let chunk = this;
123
+ while (chunk) {
124
+ fn(chunk);
125
+ chunk = chunk.next;
126
+ }
127
+ }
128
+ eachPrevious(fn) {
129
+ let chunk = this;
130
+ while (chunk) {
131
+ fn(chunk);
132
+ chunk = chunk.previous;
133
+ }
134
+ }
135
+ edit(content, storeName, contentOnly) {
136
+ this.content = content;
137
+ if (!contentOnly) {
138
+ this.intro = "";
139
+ this.outro = "";
140
+ }
141
+ this.storeName = storeName;
142
+ this.edited = true;
143
+ return this;
144
+ }
145
+ prependLeft(content) {
146
+ this.outro = content + this.outro;
147
+ }
148
+ prependRight(content) {
149
+ this.intro = content + this.intro;
150
+ }
151
+ reset() {
152
+ this.intro = "";
153
+ this.outro = "";
154
+ if (this.edited) {
155
+ this.content = this.original;
156
+ this.storeName = false;
157
+ this.edited = false;
158
+ }
159
+ }
160
+ split(index) {
161
+ const sliceIndex = index - this.start;
162
+ const originalBefore = this.original.slice(0, sliceIndex);
163
+ const originalAfter = this.original.slice(sliceIndex);
164
+ this.original = originalBefore;
165
+ const newChunk = new Chunk(index, this.end, originalAfter);
166
+ newChunk.outro = this.outro;
167
+ this.outro = "";
168
+ this.end = index;
169
+ if (this.edited) {
170
+ newChunk.edit("", false);
171
+ this.content = "";
172
+ } else this.content = originalBefore;
173
+ newChunk.next = this.next;
174
+ if (newChunk.next) newChunk.next.previous = newChunk;
175
+ newChunk.previous = this;
176
+ this.next = newChunk;
177
+ return newChunk;
178
+ }
179
+ toString() {
180
+ return this.intro + this.content + this.outro;
181
+ }
182
+ trimEnd(rx) {
183
+ this.outro = this.outro.replace(rx, "");
184
+ if (this.outro.length) return true;
185
+ const trimmed = this.content.replace(rx, "");
186
+ if (trimmed.length) {
187
+ if (trimmed !== this.content) {
188
+ this.split(this.start + trimmed.length).edit("", void 0, true);
189
+ if (this.edited) this.edit(trimmed, this.storeName, true);
190
+ }
191
+ return true;
192
+ } else {
193
+ this.edit("", void 0, true);
194
+ this.intro = this.intro.replace(rx, "");
195
+ if (this.intro.length) return true;
196
+ }
197
+ }
198
+ trimStart(rx) {
199
+ this.intro = this.intro.replace(rx, "");
200
+ if (this.intro.length) return true;
201
+ const trimmed = this.content.replace(rx, "");
202
+ if (trimmed.length) {
203
+ if (trimmed !== this.content) {
204
+ const newChunk = this.split(this.end - trimmed.length);
205
+ if (this.edited) newChunk.edit(trimmed, this.storeName, true);
206
+ this.edit("", void 0, true);
207
+ }
208
+ return true;
209
+ } else {
210
+ this.edit("", void 0, true);
211
+ this.outro = this.outro.replace(rx, "");
212
+ if (this.outro.length) return true;
213
+ }
214
+ }
215
+ };
216
+ function getBtoa() {
217
+ if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
218
+ else if (typeof Buffer === "function") return (str) => Buffer.from(str, "utf-8").toString("base64");
219
+ else return () => {
220
+ throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
221
+ };
222
+ }
223
+ const btoa = /*#__PURE__*/ getBtoa();
224
+ var SourceMap = class {
225
+ constructor(properties) {
226
+ this.version = 3;
227
+ this.file = properties.file;
228
+ this.sources = properties.sources;
229
+ this.sourcesContent = properties.sourcesContent;
230
+ this.names = properties.names;
231
+ this.mappings = encode(properties.mappings);
232
+ if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
233
+ if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
234
+ }
235
+ toString() {
236
+ return JSON.stringify(this);
237
+ }
238
+ toUrl() {
239
+ return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
240
+ }
241
+ };
242
+ function guessIndent(code) {
243
+ const lines = code.split("\n");
244
+ const tabbed = lines.filter((line) => /^\t+/.test(line));
245
+ const spaced = lines.filter((line) => /^ {2,}/.test(line));
246
+ if (tabbed.length === 0 && spaced.length === 0) return null;
247
+ if (tabbed.length >= spaced.length) return " ";
248
+ const min = spaced.reduce((previous, current) => {
249
+ const numSpaces = /^ +/.exec(current)[0].length;
250
+ return Math.min(numSpaces, previous);
251
+ }, Infinity);
252
+ return new Array(min + 1).join(" ");
253
+ }
254
+ function getRelativePath(from, to) {
255
+ const fromParts = from.split(/[/\\]/);
256
+ const toParts = to.split(/[/\\]/);
257
+ fromParts.pop();
258
+ while (fromParts[0] === toParts[0]) {
259
+ fromParts.shift();
260
+ toParts.shift();
261
+ }
262
+ if (fromParts.length) {
263
+ let i = fromParts.length;
264
+ while (i--) fromParts[i] = "..";
265
+ }
266
+ return fromParts.concat(toParts).join("/");
267
+ }
268
+ const toString = Object.prototype.toString;
269
+ function isObject(thing) {
270
+ return toString.call(thing) === "[object Object]";
271
+ }
272
+ function getLocator(source) {
273
+ const originalLines = source.split("\n");
274
+ const lineOffsets = [];
275
+ for (let i = 0, pos = 0; i < originalLines.length; i++) {
276
+ lineOffsets.push(pos);
277
+ pos += originalLines[i].length + 1;
278
+ }
279
+ return function locate(index) {
280
+ let i = 0;
281
+ let j = lineOffsets.length;
282
+ while (i < j) {
283
+ const m = i + j >> 1;
284
+ if (index < lineOffsets[m]) j = m;
285
+ else i = m + 1;
286
+ }
287
+ const line = i - 1;
288
+ return {
289
+ line,
290
+ column: index - lineOffsets[line]
291
+ };
292
+ };
293
+ }
294
+ const wordRegex = /\w/;
295
+ var Mappings = class {
296
+ constructor(hires) {
297
+ this.hires = hires;
298
+ this.generatedCodeLine = 0;
299
+ this.generatedCodeColumn = 0;
300
+ this.raw = [];
301
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
302
+ this.pending = null;
303
+ }
304
+ addEdit(sourceIndex, content, loc, nameIndex) {
305
+ if (content.length) {
306
+ const contentLengthMinusOne = content.length - 1;
307
+ let contentLineEnd = content.indexOf("\n", 0);
308
+ let previousContentLineEnd = -1;
309
+ while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
310
+ const segment = [
311
+ this.generatedCodeColumn,
312
+ sourceIndex,
313
+ loc.line,
314
+ loc.column
315
+ ];
316
+ if (nameIndex >= 0) segment.push(nameIndex);
317
+ this.rawSegments.push(segment);
318
+ this.generatedCodeLine += 1;
319
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
320
+ this.generatedCodeColumn = 0;
321
+ previousContentLineEnd = contentLineEnd;
322
+ contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
323
+ }
324
+ const segment = [
325
+ this.generatedCodeColumn,
326
+ sourceIndex,
327
+ loc.line,
328
+ loc.column
329
+ ];
330
+ if (nameIndex >= 0) segment.push(nameIndex);
331
+ this.rawSegments.push(segment);
332
+ this.advance(content.slice(previousContentLineEnd + 1));
333
+ } else if (this.pending) {
334
+ this.rawSegments.push(this.pending);
335
+ this.advance(content);
336
+ }
337
+ this.pending = null;
338
+ }
339
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
340
+ let originalCharIndex = chunk.start;
341
+ let first = true;
342
+ let charInHiresBoundary = false;
343
+ while (originalCharIndex < chunk.end) {
344
+ if (original[originalCharIndex] === "\n") {
345
+ loc.line += 1;
346
+ loc.column = 0;
347
+ this.generatedCodeLine += 1;
348
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
349
+ this.generatedCodeColumn = 0;
350
+ first = true;
351
+ charInHiresBoundary = false;
352
+ } else {
353
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
354
+ const segment = [
355
+ this.generatedCodeColumn,
356
+ sourceIndex,
357
+ loc.line,
358
+ loc.column
359
+ ];
360
+ if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
361
+ if (!charInHiresBoundary) {
362
+ this.rawSegments.push(segment);
363
+ charInHiresBoundary = true;
364
+ }
365
+ } else {
366
+ this.rawSegments.push(segment);
367
+ charInHiresBoundary = false;
368
+ }
369
+ else this.rawSegments.push(segment);
370
+ }
371
+ loc.column += 1;
372
+ this.generatedCodeColumn += 1;
373
+ first = false;
374
+ }
375
+ originalCharIndex += 1;
376
+ }
377
+ this.pending = null;
378
+ }
379
+ advance(str) {
380
+ if (!str) return;
381
+ const lines = str.split("\n");
382
+ if (lines.length > 1) {
383
+ for (let i = 0; i < lines.length - 1; i++) {
384
+ this.generatedCodeLine++;
385
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
386
+ }
387
+ this.generatedCodeColumn = 0;
388
+ }
389
+ this.generatedCodeColumn += lines[lines.length - 1].length;
390
+ }
391
+ };
392
+ const n = "\n";
393
+ const warned = {
394
+ insertLeft: false,
395
+ insertRight: false,
396
+ storeName: false
397
+ };
398
+ var MagicString = class MagicString {
399
+ constructor(string, options = {}) {
400
+ const chunk = new Chunk(0, string.length, string);
401
+ Object.defineProperties(this, {
402
+ original: {
403
+ writable: true,
404
+ value: string
405
+ },
406
+ outro: {
407
+ writable: true,
408
+ value: ""
409
+ },
410
+ intro: {
411
+ writable: true,
412
+ value: ""
413
+ },
414
+ firstChunk: {
415
+ writable: true,
416
+ value: chunk
417
+ },
418
+ lastChunk: {
419
+ writable: true,
420
+ value: chunk
421
+ },
422
+ lastSearchedChunk: {
423
+ writable: true,
424
+ value: chunk
425
+ },
426
+ byStart: {
427
+ writable: true,
428
+ value: {}
429
+ },
430
+ byEnd: {
431
+ writable: true,
432
+ value: {}
433
+ },
434
+ filename: {
435
+ writable: true,
436
+ value: options.filename
437
+ },
438
+ indentExclusionRanges: {
439
+ writable: true,
440
+ value: options.indentExclusionRanges
441
+ },
442
+ sourcemapLocations: {
443
+ writable: true,
444
+ value: new BitSet()
445
+ },
446
+ storedNames: {
447
+ writable: true,
448
+ value: {}
449
+ },
450
+ indentStr: {
451
+ writable: true,
452
+ value: void 0
453
+ },
454
+ ignoreList: {
455
+ writable: true,
456
+ value: options.ignoreList
457
+ },
458
+ offset: {
459
+ writable: true,
460
+ value: options.offset || 0
461
+ }
462
+ });
463
+ this.byStart[0] = chunk;
464
+ this.byEnd[string.length] = chunk;
465
+ }
466
+ addSourcemapLocation(char) {
467
+ this.sourcemapLocations.add(char);
468
+ }
469
+ append(content) {
470
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
471
+ this.outro += content;
472
+ return this;
473
+ }
474
+ appendLeft(index, content) {
475
+ index = index + this.offset;
476
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
477
+ this._split(index);
478
+ const chunk = this.byEnd[index];
479
+ if (chunk) chunk.appendLeft(content);
480
+ else this.intro += content;
481
+ return this;
482
+ }
483
+ appendRight(index, content) {
484
+ index = index + this.offset;
485
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
486
+ this._split(index);
487
+ const chunk = this.byStart[index];
488
+ if (chunk) chunk.appendRight(content);
489
+ else this.outro += content;
490
+ return this;
491
+ }
492
+ clone() {
493
+ const cloned = new MagicString(this.original, {
494
+ filename: this.filename,
495
+ offset: this.offset
496
+ });
497
+ let originalChunk = this.firstChunk;
498
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
499
+ while (originalChunk) {
500
+ cloned.byStart[clonedChunk.start] = clonedChunk;
501
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
502
+ const nextOriginalChunk = originalChunk.next;
503
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
504
+ if (nextClonedChunk) {
505
+ clonedChunk.next = nextClonedChunk;
506
+ nextClonedChunk.previous = clonedChunk;
507
+ clonedChunk = nextClonedChunk;
508
+ }
509
+ originalChunk = nextOriginalChunk;
510
+ }
511
+ cloned.lastChunk = clonedChunk;
512
+ if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
513
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
514
+ cloned.intro = this.intro;
515
+ cloned.outro = this.outro;
516
+ return cloned;
517
+ }
518
+ generateDecodedMap(options) {
519
+ options = options || {};
520
+ const sourceIndex = 0;
521
+ const names = Object.keys(this.storedNames);
522
+ const mappings = new Mappings(options.hires);
523
+ const locate = getLocator(this.original);
524
+ if (this.intro) mappings.advance(this.intro);
525
+ this.firstChunk.eachNext((chunk) => {
526
+ const loc = locate(chunk.start);
527
+ if (chunk.intro.length) mappings.advance(chunk.intro);
528
+ if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
529
+ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
530
+ if (chunk.outro.length) mappings.advance(chunk.outro);
531
+ });
532
+ if (this.outro) mappings.advance(this.outro);
533
+ return {
534
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
535
+ sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
536
+ sourcesContent: options.includeContent ? [this.original] : void 0,
537
+ names,
538
+ mappings: mappings.raw,
539
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
540
+ };
541
+ }
542
+ generateMap(options) {
543
+ return new SourceMap(this.generateDecodedMap(options));
544
+ }
545
+ _ensureindentStr() {
546
+ if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
547
+ }
548
+ _getRawIndentString() {
549
+ this._ensureindentStr();
550
+ return this.indentStr;
551
+ }
552
+ getIndentString() {
553
+ this._ensureindentStr();
554
+ return this.indentStr === null ? " " : this.indentStr;
555
+ }
556
+ indent(indentStr, options) {
557
+ const pattern = /^[^\r\n]/gm;
558
+ if (isObject(indentStr)) {
559
+ options = indentStr;
560
+ indentStr = void 0;
561
+ }
562
+ if (indentStr === void 0) {
563
+ this._ensureindentStr();
564
+ indentStr = this.indentStr || " ";
565
+ }
566
+ if (indentStr === "") return this;
567
+ options = options || {};
568
+ const isExcluded = {};
569
+ if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
570
+ for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
571
+ });
572
+ let shouldIndentNextCharacter = options.indentStart !== false;
573
+ const replacer = (match) => {
574
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
575
+ shouldIndentNextCharacter = true;
576
+ return match;
577
+ };
578
+ this.intro = this.intro.replace(pattern, replacer);
579
+ let charIndex = 0;
580
+ let chunk = this.firstChunk;
581
+ while (chunk) {
582
+ const end = chunk.end;
583
+ if (chunk.edited) {
584
+ if (!isExcluded[charIndex]) {
585
+ chunk.content = chunk.content.replace(pattern, replacer);
586
+ if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
587
+ }
588
+ } else {
589
+ charIndex = chunk.start;
590
+ while (charIndex < end) {
591
+ if (!isExcluded[charIndex]) {
592
+ const char = this.original[charIndex];
593
+ if (char === "\n") shouldIndentNextCharacter = true;
594
+ else if (char !== "\r" && shouldIndentNextCharacter) {
595
+ shouldIndentNextCharacter = false;
596
+ if (charIndex === chunk.start) chunk.prependRight(indentStr);
597
+ else {
598
+ this._splitChunk(chunk, charIndex);
599
+ chunk = chunk.next;
600
+ chunk.prependRight(indentStr);
601
+ }
602
+ }
603
+ }
604
+ charIndex += 1;
605
+ }
606
+ }
607
+ charIndex = chunk.end;
608
+ chunk = chunk.next;
609
+ }
610
+ this.outro = this.outro.replace(pattern, replacer);
611
+ return this;
612
+ }
613
+ insert() {
614
+ throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
615
+ }
616
+ insertLeft(index, content) {
617
+ if (!warned.insertLeft) {
618
+ console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
619
+ warned.insertLeft = true;
620
+ }
621
+ return this.appendLeft(index, content);
622
+ }
623
+ insertRight(index, content) {
624
+ if (!warned.insertRight) {
625
+ console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
626
+ warned.insertRight = true;
627
+ }
628
+ return this.prependRight(index, content);
629
+ }
630
+ move(start, end, index) {
631
+ start = start + this.offset;
632
+ end = end + this.offset;
633
+ index = index + this.offset;
634
+ if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
635
+ this._split(start);
636
+ this._split(end);
637
+ this._split(index);
638
+ const first = this.byStart[start];
639
+ const last = this.byEnd[end];
640
+ const oldLeft = first.previous;
641
+ const oldRight = last.next;
642
+ const newRight = this.byStart[index];
643
+ if (!newRight && last === this.lastChunk) return this;
644
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
645
+ if (oldLeft) oldLeft.next = oldRight;
646
+ if (oldRight) oldRight.previous = oldLeft;
647
+ if (newLeft) newLeft.next = first;
648
+ if (newRight) newRight.previous = last;
649
+ if (!first.previous) this.firstChunk = last.next;
650
+ if (!last.next) {
651
+ this.lastChunk = first.previous;
652
+ this.lastChunk.next = null;
653
+ }
654
+ first.previous = newLeft;
655
+ last.next = newRight || null;
656
+ if (!newLeft) this.firstChunk = first;
657
+ if (!newRight) this.lastChunk = last;
658
+ return this;
659
+ }
660
+ overwrite(start, end, content, options) {
661
+ options = options || {};
662
+ return this.update(start, end, content, {
663
+ ...options,
664
+ overwrite: !options.contentOnly
665
+ });
666
+ }
667
+ update(start, end, content, options) {
668
+ start = start + this.offset;
669
+ end = end + this.offset;
670
+ if (typeof content !== "string") throw new TypeError("replacement content must be a string");
671
+ if (this.original.length !== 0) {
672
+ while (start < 0) start += this.original.length;
673
+ while (end < 0) end += this.original.length;
674
+ }
675
+ if (end > this.original.length) throw new Error("end is out of bounds");
676
+ if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
677
+ this._split(start);
678
+ this._split(end);
679
+ if (options === true) {
680
+ if (!warned.storeName) {
681
+ console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
682
+ warned.storeName = true;
683
+ }
684
+ options = { storeName: true };
685
+ }
686
+ const storeName = options !== void 0 ? options.storeName : false;
687
+ const overwrite = options !== void 0 ? options.overwrite : false;
688
+ if (storeName) {
689
+ const original = this.original.slice(start, end);
690
+ Object.defineProperty(this.storedNames, original, {
691
+ writable: true,
692
+ value: true,
693
+ enumerable: true
694
+ });
695
+ }
696
+ const first = this.byStart[start];
697
+ const last = this.byEnd[end];
698
+ if (first) {
699
+ let chunk = first;
700
+ while (chunk !== last) {
701
+ if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
702
+ chunk = chunk.next;
703
+ chunk.edit("", false);
704
+ }
705
+ first.edit(content, storeName, !overwrite);
706
+ } else {
707
+ const newChunk = new Chunk(start, end, "").edit(content, storeName);
708
+ last.next = newChunk;
709
+ newChunk.previous = last;
710
+ }
711
+ return this;
712
+ }
713
+ prepend(content) {
714
+ if (typeof content !== "string") throw new TypeError("outro content must be a string");
715
+ this.intro = content + this.intro;
716
+ return this;
717
+ }
718
+ prependLeft(index, content) {
719
+ index = index + this.offset;
720
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
721
+ this._split(index);
722
+ const chunk = this.byEnd[index];
723
+ if (chunk) chunk.prependLeft(content);
724
+ else this.intro = content + this.intro;
725
+ return this;
726
+ }
727
+ prependRight(index, content) {
728
+ index = index + this.offset;
729
+ if (typeof content !== "string") throw new TypeError("inserted content must be a string");
730
+ this._split(index);
731
+ const chunk = this.byStart[index];
732
+ if (chunk) chunk.prependRight(content);
733
+ else this.outro = content + this.outro;
734
+ return this;
735
+ }
736
+ remove(start, end) {
737
+ start = start + this.offset;
738
+ end = end + this.offset;
739
+ if (this.original.length !== 0) {
740
+ while (start < 0) start += this.original.length;
741
+ while (end < 0) end += this.original.length;
742
+ }
743
+ if (start === end) return this;
744
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
745
+ if (start > end) throw new Error("end must be greater than start");
746
+ this._split(start);
747
+ this._split(end);
748
+ let chunk = this.byStart[start];
749
+ while (chunk) {
750
+ chunk.intro = "";
751
+ chunk.outro = "";
752
+ chunk.edit("");
753
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
754
+ }
755
+ return this;
756
+ }
757
+ reset(start, end) {
758
+ start = start + this.offset;
759
+ end = end + this.offset;
760
+ if (this.original.length !== 0) {
761
+ while (start < 0) start += this.original.length;
762
+ while (end < 0) end += this.original.length;
763
+ }
764
+ if (start === end) return this;
765
+ if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
766
+ if (start > end) throw new Error("end must be greater than start");
767
+ this._split(start);
768
+ this._split(end);
769
+ let chunk = this.byStart[start];
770
+ while (chunk) {
771
+ chunk.reset();
772
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
773
+ }
774
+ return this;
775
+ }
776
+ lastChar() {
777
+ if (this.outro.length) return this.outro[this.outro.length - 1];
778
+ let chunk = this.lastChunk;
779
+ do {
780
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
781
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
782
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
783
+ } while (chunk = chunk.previous);
784
+ if (this.intro.length) return this.intro[this.intro.length - 1];
785
+ return "";
786
+ }
787
+ lastLine() {
788
+ let lineIndex = this.outro.lastIndexOf(n);
789
+ if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
790
+ let lineStr = this.outro;
791
+ let chunk = this.lastChunk;
792
+ do {
793
+ if (chunk.outro.length > 0) {
794
+ lineIndex = chunk.outro.lastIndexOf(n);
795
+ if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
796
+ lineStr = chunk.outro + lineStr;
797
+ }
798
+ if (chunk.content.length > 0) {
799
+ lineIndex = chunk.content.lastIndexOf(n);
800
+ if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
801
+ lineStr = chunk.content + lineStr;
802
+ }
803
+ if (chunk.intro.length > 0) {
804
+ lineIndex = chunk.intro.lastIndexOf(n);
805
+ if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
806
+ lineStr = chunk.intro + lineStr;
807
+ }
808
+ } while (chunk = chunk.previous);
809
+ lineIndex = this.intro.lastIndexOf(n);
810
+ if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
811
+ return this.intro + lineStr;
812
+ }
813
+ slice(start = 0, end = this.original.length - this.offset) {
814
+ start = start + this.offset;
815
+ end = end + this.offset;
816
+ if (this.original.length !== 0) {
817
+ while (start < 0) start += this.original.length;
818
+ while (end < 0) end += this.original.length;
819
+ }
820
+ let result = "";
821
+ let chunk = this.firstChunk;
822
+ while (chunk && (chunk.start > start || chunk.end <= start)) {
823
+ if (chunk.start < end && chunk.end >= end) return result;
824
+ chunk = chunk.next;
825
+ }
826
+ if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
827
+ const startChunk = chunk;
828
+ while (chunk) {
829
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
830
+ const containsEnd = chunk.start < end && chunk.end >= end;
831
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
832
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
833
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
834
+ result += chunk.content.slice(sliceStart, sliceEnd);
835
+ if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
836
+ if (containsEnd) break;
837
+ chunk = chunk.next;
838
+ }
839
+ return result;
840
+ }
841
+ snip(start, end) {
842
+ const clone = this.clone();
843
+ clone.remove(0, start);
844
+ clone.remove(end, clone.original.length);
845
+ return clone;
846
+ }
847
+ _split(index) {
848
+ if (this.byStart[index] || this.byEnd[index]) return;
849
+ let chunk = this.lastSearchedChunk;
850
+ let previousChunk = chunk;
851
+ const searchForward = index > chunk.end;
852
+ while (chunk) {
853
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
854
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
855
+ if (chunk === previousChunk) return;
856
+ previousChunk = chunk;
857
+ }
858
+ }
859
+ _splitChunk(chunk, index) {
860
+ if (chunk.edited && chunk.content.length) {
861
+ const loc = getLocator(this.original)(index);
862
+ throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
863
+ }
864
+ const newChunk = chunk.split(index);
865
+ this.byEnd[index] = chunk;
866
+ this.byStart[index] = newChunk;
867
+ this.byEnd[newChunk.end] = newChunk;
868
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
869
+ this.lastSearchedChunk = chunk;
870
+ return true;
871
+ }
872
+ toString() {
873
+ let str = this.intro;
874
+ let chunk = this.firstChunk;
875
+ while (chunk) {
876
+ str += chunk.toString();
877
+ chunk = chunk.next;
878
+ }
879
+ return str + this.outro;
880
+ }
881
+ isEmpty() {
882
+ let chunk = this.firstChunk;
883
+ do
884
+ if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
885
+ while (chunk = chunk.next);
886
+ return true;
887
+ }
888
+ length() {
889
+ let chunk = this.firstChunk;
890
+ let length = 0;
891
+ do
892
+ length += chunk.intro.length + chunk.content.length + chunk.outro.length;
893
+ while (chunk = chunk.next);
894
+ return length;
895
+ }
896
+ trimLines() {
897
+ return this.trim("[\\r\\n]");
898
+ }
899
+ trim(charType) {
900
+ return this.trimStart(charType).trimEnd(charType);
901
+ }
902
+ trimEndAborted(charType) {
903
+ const rx = new RegExp((charType || "\\s") + "+$");
904
+ this.outro = this.outro.replace(rx, "");
905
+ if (this.outro.length) return true;
906
+ let chunk = this.lastChunk;
907
+ do {
908
+ const end = chunk.end;
909
+ const aborted = chunk.trimEnd(rx);
910
+ if (chunk.end !== end) {
911
+ if (this.lastChunk === chunk) this.lastChunk = chunk.next;
912
+ this.byEnd[chunk.end] = chunk;
913
+ this.byStart[chunk.next.start] = chunk.next;
914
+ this.byEnd[chunk.next.end] = chunk.next;
915
+ }
916
+ if (aborted) return true;
917
+ chunk = chunk.previous;
918
+ } while (chunk);
919
+ return false;
920
+ }
921
+ trimEnd(charType) {
922
+ this.trimEndAborted(charType);
923
+ return this;
924
+ }
925
+ trimStartAborted(charType) {
926
+ const rx = new RegExp("^" + (charType || "\\s") + "+");
927
+ this.intro = this.intro.replace(rx, "");
928
+ if (this.intro.length) return true;
929
+ let chunk = this.firstChunk;
930
+ do {
931
+ const end = chunk.end;
932
+ const aborted = chunk.trimStart(rx);
933
+ if (chunk.end !== end) {
934
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
935
+ this.byEnd[chunk.end] = chunk;
936
+ this.byStart[chunk.next.start] = chunk.next;
937
+ this.byEnd[chunk.next.end] = chunk.next;
938
+ }
939
+ if (aborted) return true;
940
+ chunk = chunk.next;
941
+ } while (chunk);
942
+ return false;
943
+ }
944
+ trimStart(charType) {
945
+ this.trimStartAborted(charType);
946
+ return this;
947
+ }
948
+ hasChanged() {
949
+ return this.original !== this.toString();
950
+ }
951
+ _replaceRegexp(searchValue, replacement) {
952
+ function getReplacement(match, str) {
953
+ if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
954
+ if (i === "$") return "$";
955
+ if (i === "&") return match[0];
956
+ if (+i < match.length) return match[+i];
957
+ return `$${i}`;
958
+ });
959
+ else return replacement(...match, match.index, str, match.groups);
960
+ }
961
+ function matchAll(re, str) {
962
+ let match;
963
+ const matches = [];
964
+ while (match = re.exec(str)) matches.push(match);
965
+ return matches;
966
+ }
967
+ if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
968
+ if (match.index != null) {
969
+ const replacement = getReplacement(match, this.original);
970
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
971
+ }
972
+ });
973
+ else {
974
+ const match = this.original.match(searchValue);
975
+ if (match && match.index != null) {
976
+ const replacement = getReplacement(match, this.original);
977
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
978
+ }
979
+ }
980
+ return this;
981
+ }
982
+ _replaceString(string, replacement) {
983
+ const { original } = this;
984
+ const index = original.indexOf(string);
985
+ if (index !== -1) {
986
+ if (typeof replacement === "function") replacement = replacement(string, index, original);
987
+ if (string !== replacement) this.overwrite(index, index + string.length, replacement);
988
+ }
989
+ return this;
990
+ }
991
+ replace(searchValue, replacement) {
992
+ if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
993
+ return this._replaceRegexp(searchValue, replacement);
994
+ }
995
+ _replaceAllString(string, replacement) {
996
+ const { original } = this;
997
+ const stringLength = string.length;
998
+ for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
999
+ const previous = original.slice(index, index + stringLength);
1000
+ let _replacement = replacement;
1001
+ if (typeof replacement === "function") _replacement = replacement(previous, index, original);
1002
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
1003
+ }
1004
+ return this;
1005
+ }
1006
+ replaceAll(searchValue, replacement) {
1007
+ if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
1008
+ if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
1009
+ return this._replaceRegexp(searchValue, replacement);
1010
+ }
1011
+ };
1012
+
1013
+ //#endregion
1014
+ exports.default = MagicString;
1015
+ //# sourceMappingURL=magic-string.es-BtxW4VqG.cjs.map