@bastani/atomic 0.9.74 → 0.9.75-alpha.1

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 (383) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +8 -0
  5. package/dist/builtin/subagents/package.json +3 -3
  6. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +8 -10
  7. package/dist/builtin/subagents/skills/agent-desktop/SKILL.md +9 -5
  8. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -1
  9. package/dist/builtin/web-access/package.json +2 -2
  10. package/dist/builtin/workflows/CHANGELOG.md +32 -0
  11. package/dist/builtin/workflows/README.md +5 -2
  12. package/dist/builtin/workflows/builtin/{chunk-m8eg152f.js → chunk-89we7r4p.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-a4fdm2cw.js → chunk-8yfssw01.js} +1 -1
  14. package/dist/builtin/workflows/builtin/{chunk-774myqzs.js → chunk-v8mb0005.js} +366 -45
  15. package/dist/builtin/workflows/builtin/{chunk-d5cxskkp.js → chunk-wh2p4qjg.js} +2 -2
  16. package/dist/builtin/workflows/builtin/goal.js +2 -2
  17. package/dist/builtin/workflows/builtin/index.d.ts +10 -0
  18. package/dist/builtin/workflows/builtin/index.js +4 -4
  19. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +12 -0
  20. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  21. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  22. package/dist/builtin/workflows/package.json +2 -2
  23. package/dist/builtin/workflows/skills/impeccable/SKILL.md +4 -4
  24. package/dist/builtin/workflows/skills/impeccable/reference/android.md +1 -1
  25. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -2
  26. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
  27. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +1 -1
  28. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +4 -4
  29. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
  30. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +3 -2
  31. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
  32. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +1 -1
  33. package/dist/builtin/workflows/skills/impeccable/reference/document.md +3 -3
  34. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +19 -0
  35. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +15 -8
  36. package/dist/builtin/workflows/skills/impeccable/reference/init.md +2 -0
  37. package/dist/builtin/workflows/skills/impeccable/reference/live.md +8 -6
  38. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +4 -4
  39. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +0 -1
  40. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
  41. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
  42. package/dist/builtin/workflows/skills/impeccable/scripts/command-metadata.json +2 -2
  43. package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +9 -0
  44. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +98 -44
  45. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +101 -34
  46. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +6 -2
  47. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +4 -1
  48. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +444 -144
  49. package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +3 -1
  50. package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +2 -2
  51. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +13 -11
  52. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +10 -8
  53. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +143 -0
  54. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +11 -7
  55. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +3 -3
  56. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +6 -2
  57. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +7 -7
  58. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +2 -2
  59. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5_5.md +3 -3
  60. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +2 -2
  61. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +2 -2
  62. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +6 -5
  63. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +4 -4
  64. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +2 -2
  65. package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +4 -3
  66. package/dist/builtin/workflows/skills/skill-creator/scripts/aggregate_benchmark.py +0 -0
  67. package/dist/builtin/workflows/skills/skill-creator/scripts/generate_report.py +0 -0
  68. package/dist/builtin/workflows/skills/skill-creator/scripts/improve_description.py +0 -0
  69. package/dist/builtin/workflows/skills/skill-creator/scripts/package_skill.py +0 -0
  70. package/dist/builtin/workflows/skills/skill-creator/scripts/quick_validate.py +0 -0
  71. package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +0 -0
  72. package/dist/builtin/workflows/skills/skill-creator/scripts/run_loop.py +0 -0
  73. package/dist/builtin/workflows/skills/unslop/SKILL.md +15 -34
  74. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +1 -0
  75. package/dist/builtin/workflows/src/durable/journal/values.d.ts +2 -0
  76. package/dist/builtin/workflows/src/extension/index.bundle.mjs +809 -410
  77. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +695 -305
  78. package/dist/builtin/workflows/src/index.js +685 -295
  79. package/dist/builtin/workflows/src/local-worker-entry.mjs +695 -305
  80. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -6
  81. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +2 -2
  82. package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +2 -0
  83. package/dist/bun/app-host-modules.d.ts +1 -1
  84. package/dist/bun/app-host-modules.d.ts.map +1 -1
  85. package/dist/bun/app-host-modules.js.map +1 -1
  86. package/dist/bun/internal-workflow-worker.d.ts +2 -0
  87. package/dist/bun/internal-workflow-worker.d.ts.map +1 -1
  88. package/dist/bun/internal-workflow-worker.js +2 -1
  89. package/dist/bun/internal-workflow-worker.js.map +1 -1
  90. package/dist/codemode-worker.js +2 -0
  91. package/dist/config.d.ts +8 -0
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +14 -0
  94. package/dist/config.js.map +1 -1
  95. package/dist/core/agent-session-bash.d.ts.map +1 -1
  96. package/dist/core/agent-session-bash.js +2 -1
  97. package/dist/core/agent-session-bash.js.map +1 -1
  98. package/dist/core/agent-session-blueprint-environment.d.ts +10 -0
  99. package/dist/core/agent-session-blueprint-environment.d.ts.map +1 -0
  100. package/dist/core/agent-session-blueprint-environment.js +28 -0
  101. package/dist/core/agent-session-blueprint-environment.js.map +1 -0
  102. package/dist/core/agent-session-events.d.ts.map +1 -1
  103. package/dist/core/agent-session-events.js +2 -0
  104. package/dist/core/agent-session-events.js.map +1 -1
  105. package/dist/core/agent-session-methods.d.ts +1 -0
  106. package/dist/core/agent-session-methods.d.ts.map +1 -1
  107. package/dist/core/agent-session-methods.js.map +1 -1
  108. package/dist/core/agent-session-retry.d.ts.map +1 -1
  109. package/dist/core/agent-session-retry.js +14 -4
  110. package/dist/core/agent-session-retry.js.map +1 -1
  111. package/dist/core/agent-session-runtime.d.ts +20 -0
  112. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  113. package/dist/core/agent-session-runtime.js +55 -6
  114. package/dist/core/agent-session-runtime.js.map +1 -1
  115. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  116. package/dist/core/agent-session-tool-registry.js +2 -1
  117. package/dist/core/agent-session-tool-registry.js.map +1 -1
  118. package/dist/core/agent-session.d.ts +2 -0
  119. package/dist/core/agent-session.d.ts.map +1 -1
  120. package/dist/core/agent-session.js +2 -0
  121. package/dist/core/agent-session.js.map +1 -1
  122. package/dist/core/async-scope.d.ts +13 -0
  123. package/dist/core/async-scope.d.ts.map +1 -0
  124. package/dist/core/async-scope.js +20 -0
  125. package/dist/core/async-scope.js.map +1 -0
  126. package/dist/core/cache-warmer.d.ts +3 -14
  127. package/dist/core/cache-warmer.d.ts.map +1 -1
  128. package/dist/core/cache-warmer.js +8 -60
  129. package/dist/core/cache-warmer.js.map +1 -1
  130. package/dist/core/extensions/extension-work.js +2 -2
  131. package/dist/core/extensions/extension-work.js.map +1 -1
  132. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  133. package/dist/core/extensions/loader-host-modules.js +3 -1
  134. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  135. package/dist/core/extensions/ui-types.d.ts +2 -1
  136. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  137. package/dist/core/extensions/ui-types.js.map +1 -1
  138. package/dist/core/extensions/workflow-events.d.ts +1 -1
  139. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  140. package/dist/core/extensions/workflow-events.js.map +1 -1
  141. package/dist/core/extensions/workflow-run-control.d.ts +4 -2
  142. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  143. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  144. package/dist/core/model-fallback-failures.d.ts +6 -0
  145. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  146. package/dist/core/model-fallback-failures.js +10 -1
  147. package/dist/core/model-fallback-failures.js.map +1 -1
  148. package/dist/core/preferred-providers.d.ts +19 -0
  149. package/dist/core/preferred-providers.d.ts.map +1 -0
  150. package/dist/core/preferred-providers.js +25 -0
  151. package/dist/core/preferred-providers.js.map +1 -0
  152. package/dist/core/provider-alias.d.ts.map +1 -1
  153. package/dist/core/provider-alias.js +4 -0
  154. package/dist/core/provider-alias.js.map +1 -1
  155. package/dist/core/provider-composer.d.ts.map +1 -1
  156. package/dist/core/provider-composer.js +1 -0
  157. package/dist/core/provider-composer.js.map +1 -1
  158. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  159. package/dist/core/remote-catalog-provider.js +3 -0
  160. package/dist/core/remote-catalog-provider.js.map +1 -1
  161. package/dist/core/resume/blueprint/action-expressions.d.ts +32 -0
  162. package/dist/core/resume/blueprint/action-expressions.d.ts.map +1 -0
  163. package/dist/core/resume/blueprint/action-expressions.js +389 -0
  164. package/dist/core/resume/blueprint/action-expressions.js.map +1 -0
  165. package/dist/core/resume/blueprint/actions.d.ts +90 -0
  166. package/dist/core/resume/blueprint/actions.d.ts.map +1 -0
  167. package/dist/core/resume/blueprint/actions.js +818 -0
  168. package/dist/core/resume/blueprint/actions.js.map +1 -0
  169. package/dist/core/resume/blueprint/build.d.ts +102 -0
  170. package/dist/core/resume/blueprint/build.d.ts.map +1 -0
  171. package/dist/core/resume/blueprint/build.js +535 -0
  172. package/dist/core/resume/blueprint/build.js.map +1 -0
  173. package/dist/core/resume/blueprint/context.d.ts +11 -0
  174. package/dist/core/resume/blueprint/context.d.ts.map +1 -0
  175. package/dist/core/resume/blueprint/context.js +106 -0
  176. package/dist/core/resume/blueprint/context.js.map +1 -0
  177. package/dist/core/resume/blueprint/envrc.d.ts +19 -0
  178. package/dist/core/resume/blueprint/envrc.d.ts.map +1 -0
  179. package/dist/core/resume/blueprint/envrc.js +77 -0
  180. package/dist/core/resume/blueprint/envrc.js.map +1 -0
  181. package/dist/core/resume/blueprint/errors.d.ts +179 -0
  182. package/dist/core/resume/blueprint/errors.d.ts.map +1 -0
  183. package/dist/core/resume/blueprint/errors.js +169 -0
  184. package/dist/core/resume/blueprint/errors.js.map +1 -0
  185. package/dist/core/resume/blueprint/ledger.d.ts +51 -0
  186. package/dist/core/resume/blueprint/ledger.d.ts.map +1 -0
  187. package/dist/core/resume/blueprint/ledger.js +119 -0
  188. package/dist/core/resume/blueprint/ledger.js.map +1 -0
  189. package/dist/core/resume/blueprint/notices.d.ts +14 -0
  190. package/dist/core/resume/blueprint/notices.d.ts.map +1 -0
  191. package/dist/core/resume/blueprint/notices.js +44 -0
  192. package/dist/core/resume/blueprint/notices.js.map +1 -0
  193. package/dist/core/resume/blueprint/process.d.ts +44 -0
  194. package/dist/core/resume/blueprint/process.d.ts.map +1 -0
  195. package/dist/core/resume/blueprint/process.js +142 -0
  196. package/dist/core/resume/blueprint/process.js.map +1 -0
  197. package/dist/core/resume/blueprint/resume.d.ts +73 -0
  198. package/dist/core/resume/blueprint/resume.d.ts.map +1 -0
  199. package/dist/core/resume/blueprint/resume.js +206 -0
  200. package/dist/core/resume/blueprint/resume.js.map +1 -0
  201. package/dist/core/resume/blueprint/schema.d.ts +26 -0
  202. package/dist/core/resume/blueprint/schema.d.ts.map +1 -0
  203. package/dist/core/resume/blueprint/schema.js +243 -0
  204. package/dist/core/resume/blueprint/schema.js.map +1 -0
  205. package/dist/core/resume/blueprint/steps.d.ts +54 -0
  206. package/dist/core/resume/blueprint/steps.d.ts.map +1 -0
  207. package/dist/core/resume/blueprint/steps.js +155 -0
  208. package/dist/core/resume/blueprint/steps.js.map +1 -0
  209. package/dist/core/resume/blueprint/types.d.ts +63 -0
  210. package/dist/core/resume/blueprint/types.d.ts.map +1 -0
  211. package/dist/core/resume/blueprint/types.js +2 -0
  212. package/dist/core/resume/blueprint/types.js.map +1 -0
  213. package/dist/core/resume/errors.d.ts +7 -35
  214. package/dist/core/resume/errors.d.ts.map +1 -1
  215. package/dist/core/resume/errors.js +1 -21
  216. package/dist/core/resume/errors.js.map +1 -1
  217. package/dist/core/resume/index.d.ts +12 -4
  218. package/dist/core/resume/index.d.ts.map +1 -1
  219. package/dist/core/resume/index.js +11 -4
  220. package/dist/core/resume/index.js.map +1 -1
  221. package/dist/core/resume/run-setup.d.ts +36 -15
  222. package/dist/core/resume/run-setup.d.ts.map +1 -1
  223. package/dist/core/resume/run-setup.js +70 -54
  224. package/dist/core/resume/run-setup.js.map +1 -1
  225. package/dist/core/resume/session-resume.d.ts +34 -20
  226. package/dist/core/resume/session-resume.d.ts.map +1 -1
  227. package/dist/core/resume/session-resume.js +244 -106
  228. package/dist/core/resume/session-resume.js.map +1 -1
  229. package/dist/core/retry-policy.d.ts +19 -1
  230. package/dist/core/retry-policy.d.ts.map +1 -1
  231. package/dist/core/retry-policy.js +26 -1
  232. package/dist/core/retry-policy.js.map +1 -1
  233. package/dist/core/sdk.js +1 -1
  234. package/dist/core/sdk.js.map +1 -1
  235. package/dist/core/session-cwd.d.ts +56 -1
  236. package/dist/core/session-cwd.d.ts.map +1 -1
  237. package/dist/core/session-cwd.js +94 -4
  238. package/dist/core/session-cwd.js.map +1 -1
  239. package/dist/core/session-manager-core.d.ts +1 -1
  240. package/dist/core/session-manager-core.d.ts.map +1 -1
  241. package/dist/core/session-manager-core.js +10 -5
  242. package/dist/core/session-manager-core.js.map +1 -1
  243. package/dist/core/session-worktree-snapshots.d.ts +11 -0
  244. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  245. package/dist/core/session-worktree-snapshots.js +10 -4
  246. package/dist/core/session-worktree-snapshots.js.map +1 -1
  247. package/dist/core/settings-defaults.d.ts +1 -1
  248. package/dist/core/settings-defaults.d.ts.map +1 -1
  249. package/dist/core/settings-defaults.js +1 -1
  250. package/dist/core/settings-defaults.js.map +1 -1
  251. package/dist/core/settings-manager-basic-accessors.d.ts +3 -2
  252. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  253. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  254. package/dist/core/settings-schema.d.ts.map +1 -1
  255. package/dist/core/settings-schema.js +2 -1
  256. package/dist/core/settings-schema.js.map +1 -1
  257. package/dist/core/slash-commands.d.ts.map +1 -1
  258. package/dist/core/slash-commands.js +4 -0
  259. package/dist/core/slash-commands.js.map +1 -1
  260. package/dist/core/storage/write-ahead-log.d.ts +2 -1
  261. package/dist/core/storage/write-ahead-log.d.ts.map +1 -1
  262. package/dist/core/storage/write-ahead-log.js +27 -6
  263. package/dist/core/storage/write-ahead-log.js.map +1 -1
  264. package/dist/core/system-prompt.d.ts.map +1 -1
  265. package/dist/core/system-prompt.js +10 -0
  266. package/dist/core/system-prompt.js.map +1 -1
  267. package/dist/core/tools/file-tool-errors.d.ts +1 -1
  268. package/dist/core/tools/file-tool-errors.js +1 -1
  269. package/dist/core/tools/file-tool-errors.js.map +1 -1
  270. package/dist/core/tools/find.d.ts.map +1 -1
  271. package/dist/core/tools/find.js +52 -26
  272. package/dist/core/tools/find.js.map +1 -1
  273. package/dist/core/tools/grep.d.ts +2 -0
  274. package/dist/core/tools/grep.d.ts.map +1 -1
  275. package/dist/core/tools/grep.js.map +1 -1
  276. package/dist/core/tools/powershell.d.ts.map +1 -1
  277. package/dist/core/tools/powershell.js +10 -2
  278. package/dist/core/tools/powershell.js.map +1 -1
  279. package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
  280. package/dist/core/tools/tool-concurrency.js +2 -2
  281. package/dist/core/tools/tool-concurrency.js.map +1 -1
  282. package/dist/index.d.ts +3 -2
  283. package/dist/index.d.ts.map +1 -1
  284. package/dist/index.js +2 -1
  285. package/dist/index.js.map +1 -1
  286. package/dist/main-session.d.ts +12 -4
  287. package/dist/main-session.d.ts.map +1 -1
  288. package/dist/main-session.js +28 -4
  289. package/dist/main-session.js.map +1 -1
  290. package/dist/main.d.ts.map +1 -1
  291. package/dist/main.js +6 -8
  292. package/dist/main.js.map +1 -1
  293. package/dist/modes/interactive/components/chat-session-host.d.ts +5 -1
  294. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  295. package/dist/modes/interactive/components/chat-session-host.js +6 -1
  296. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  297. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  298. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  299. package/dist/modes/interactive/components/oauth-selector.js +34 -13
  300. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  301. package/dist/modes/interactive/components/provider-brand.d.ts +16 -0
  302. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  303. package/dist/modes/interactive/components/provider-brand.js +67 -0
  304. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  305. package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
  306. package/dist/modes/interactive/interactive-auth-routing.js +8 -6
  307. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  308. package/dist/modes/interactive/interactive-extension-dialogs.js +4 -3
  309. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  310. package/dist/modes/interactive/interactive-extension-runtime.js +8 -3
  311. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  312. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  313. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  314. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  315. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  316. package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -2
  317. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  318. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  319. package/dist/modes/interactive/interactive-session-routing.js +59 -21
  320. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  321. package/dist/modes/interactive/interactive-slash-commands.js +23 -12
  322. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  323. package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
  324. package/dist/modes/interactive/login-provider-options.js +2 -1
  325. package/dist/modes/interactive/login-provider-options.js.map +1 -1
  326. package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -0
  327. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  328. package/dist/modes/interactive-engine/isolated-runtime.js +8 -3
  329. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  330. package/dist/modes/rpc/rpc-client-api.d.ts +2 -1
  331. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  332. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  333. package/dist/modes/rpc/rpc-client.d.ts +0 -1
  334. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  335. package/dist/modes/rpc/rpc-client.js +2 -18
  336. package/dist/modes/rpc/rpc-client.js.map +1 -1
  337. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  338. package/dist/modes/rpc/rpc-command-handler.js +8 -2
  339. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  340. package/dist/modes/rpc/rpc-error-decoding.d.ts +7 -0
  341. package/dist/modes/rpc/rpc-error-decoding.d.ts.map +1 -0
  342. package/dist/modes/rpc/rpc-error-decoding.js +25 -0
  343. package/dist/modes/rpc/rpc-error-decoding.js.map +1 -0
  344. package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
  345. package/dist/modes/rpc/rpc-responses.js +12 -0
  346. package/dist/modes/rpc/rpc-responses.js.map +1 -1
  347. package/dist/modes/rpc/rpc-types.d.ts +11 -0
  348. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  349. package/dist/modes/rpc/rpc-types.js.map +1 -1
  350. package/dist/package-manager-cli.d.ts.map +1 -1
  351. package/dist/package-manager-cli.js +12 -3
  352. package/dist/package-manager-cli.js.map +1 -1
  353. package/docs/background-tasks.md +1 -1
  354. package/docs/codemode.md +22 -0
  355. package/docs/extensions/api-reference.md +27 -1
  356. package/docs/extensions/authoring.md +1 -1
  357. package/docs/extensions/ui.md +1 -1
  358. package/docs/getting-started/first-session.md +1 -1
  359. package/docs/guides/resume-on-any-machine.md +72 -19
  360. package/docs/models/evals.md +85 -17
  361. package/docs/models/reference.md +1 -1
  362. package/docs/providers.md +38 -5
  363. package/docs/reference/cli.md +2 -0
  364. package/docs/rpc/protocol.md +11 -1
  365. package/docs/sdk/reference.md +36 -4
  366. package/docs/sdk.md +2 -2
  367. package/docs/sessions.md +11 -1
  368. package/docs/settings.md +7 -2
  369. package/docs/skills.md +3 -3
  370. package/docs/storage.md +1 -1
  371. package/docs/tools.md +3 -1
  372. package/docs/workflows/api-reference.md +14 -12
  373. package/docs/workflows/authoring.md +29 -1
  374. package/docs/workflows/builtins.md +9 -1
  375. package/docs/workflows/operations.md +8 -8
  376. package/docs/worktree-snapshots.md +3 -2
  377. package/npm-shrinkwrap.json +83 -67
  378. package/package.json +7 -7
  379. package/schemas/settings.schema.json +3 -2
  380. package/dist/core/resume/setup-hook.d.ts +0 -69
  381. package/dist/core/resume/setup-hook.d.ts.map +0 -1
  382. package/dist/core/resume/setup-hook.js +0 -261
  383. package/dist/core/resume/setup-hook.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"remote-catalog-provider.js","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,WAAW,GAKX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAClD,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AA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AAY;oBACpB,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE;wBACxB,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS;4BAAE,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;wBAC3E,YAAY,GAAG,WAAW,CAAC,OAAO,IAAI,SAAS,CAAC;wBAChD,OAAO,OAAO,CAAC,OAAO,CAAC;4BACtB,GAAG,WAAW;4BACd,OAAO,EAAE,eAAe,CAAC,WAAW,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;yBACtE,CAAC,CAAC;oBACJ,CAAC;iBACD,CAAC,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACV,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;oBACvD,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACtC,MAAM,OAAO,CAAC,OAAO,CAAC;4BACrB,OAAO,EAAE,eAAe,CAAC,YAAY,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;4BAC/D,MAAM,EAAE,GAAG,EAAE;gCACZ,UAAU,GAAG,KAAK,CAAC;4BACpB,CAAC;yBACD,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\tgetModelType,\n\tisModelType,\n\ttype ModelsStoreEntry,\n\ttype ModelType,\n\ttype Provider,\n\ttype RefreshModelsContext,\n} from \"@bastani/pi-ai\";\nimport { VERSION } from \"../config.js\";\nimport { fetchWithRetry } from \"../utils/management-http.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\n\nconst DEFAULT_CATALOG_BASE_URL = \"https://pi.dev\";\nconst REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS = 4_000;\nexport const REMOTE_CATALOG_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;\n/**\n * Model types this client can consume. Sent as `?types=` so the catalog server\n * returns the full-type shard instead of the chat-only one served to clients\n * that predate model types. A server that ignores the parameter still returns\n * the chat-only shard, which this client handles unchanged.\n */\nexport const REMOTE_CATALOG_MODEL_TYPES: readonly ModelType[] = [\"chat\", \"image\", \"classifier\"];\n\nfunction isSupportedModelType(model: { type?: unknown }): boolean {\n\treturn (\n\t\tmodel.type === undefined ||\n\t\t(typeof model.type === \"string\" && REMOTE_CATALOG_MODEL_TYPES.includes(model.type as ModelType))\n\t);\n}\n\nfunction hasOperationShape(model: unknown): boolean {\n\tif (typeof model !== \"object\" || model === null) return false;\n\tif (!(\"type\" in model) || (model.type !== \"image\" && model.type !== \"classifier\")) return true;\n\tif (!(\"cost\" in model)) return false;\n\tconst cost = model.cost;\n\treturn (\n\t\t\"id\" in model &&\n\t\ttypeof model.id === \"string\" &&\n\t\tmodel.id.length > 0 &&\n\t\t\"name\" in model &&\n\t\ttypeof model.name === \"string\" &&\n\t\t\"api\" in model &&\n\t\ttypeof model.api === \"string\" &&\n\t\t\"baseUrl\" in model &&\n\t\ttypeof model.baseUrl === \"string\" &&\n\t\t\"input\" in model &&\n\t\tArray.isArray(model.input) &&\n\t\tcost !== null &&\n\t\ttypeof cost === \"object\" &&\n\t\t[\"input\", \"output\", \"cacheRead\", \"cacheWrite\"].every(\n\t\t\t(key) => key in cost && typeof (cost as Record<string, unknown>)[key] === \"number\",\n\t\t) &&\n\t\t(model.type === \"image\"\n\t\t\t? \"output\" in model && Array.isArray(model.output) && model.output.includes(\"image\")\n\t\t\t: \"contextWindow\" in model && typeof model.contextWindow === \"number\" && model.contextWindow > 0)\n\t);\n}\n\nfunction mergeModels<TModel extends AnyModel>(baseline: readonly TModel[], dynamic: readonly TModel[]): TModel[] {\n\tconst merged = new Map<string, TModel>();\n\tfor (const model of baseline) merged.set(`${getModelType(model)}\\0${model.id}`, model);\n\tfor (const model of dynamic) {\n\t\tconst key = `${getModelType(model)}\\0${model.id}`;\n\t\tconst bundled = merged.get(key);\n\t\tif (\n\t\t\tbundled &&\n\t\t\tisModelType(bundled, \"chat\") &&\n\t\t\tisModelType(model, \"chat\") &&\n\t\t\tmodel.serviceTiers === undefined &&\n\t\t\tbundled.serviceTiers !== undefined\n\t\t) {\n\t\t\tmerged.set(key, { ...model, serviceTiers: bundled.serviceTiers });\n\t\t} else {\n\t\t\tmerged.set(key, model);\n\t\t}\n\t}\n\treturn [...merged.values()];\n}\n\nfunction parseCatalog(providerId: string, value: unknown): AnyModel[] {\n\tconst entries = Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"object\" && value !== null && \"models\" in value && Array.isArray(value.models)\n\t\t\t? value.models\n\t\t\t: typeof value === \"object\" && value !== null\n\t\t\t\t? Object.values(value)\n\t\t\t\t: undefined;\n\tif (!entries) throw new Error(`Invalid model catalog for provider \"${providerId}\"`);\n\treturn entries\n\t\t.filter((entry): entry is Record<string, unknown> => typeof entry === \"object\" && entry !== null && \"id\" in entry)\n\t\t.filter(isSupportedModelType)\n\t\t.filter(hasOperationShape)\n\t\t.map((model) => ({ ...model, provider: providerId }) as AnyModel);\n}\n\n/** Read a successful pi.dev catalog response. A missing or invalid Last-Modified header is 0. */\nasync function readCatalog(\n\tproviderId: string,\n\tresponse: Response,\n): Promise<{ models: AnyModel[]; lastModified: number; etag: string | undefined }> {\n\tconst lastModified = Date.parse(response.headers.get(\"last-modified\") ?? \"\");\n\treturn {\n\t\tmodels: parseCatalog(providerId, await response.json()),\n\t\tlastModified: Number.isNaN(lastModified) ? 0 : lastModified,\n\t\tetag: response.headers.get(\"etag\") ?? undefined,\n\t};\n}\n\n/** Whether a pi.dev catalog is newer than the model data shipped with Atomic. */\nfunction isNewer(lastModified: number | undefined, localGeneratedAt: number | undefined): boolean {\n\treturn localGeneratedAt === undefined || (lastModified !== undefined && lastModified > localGeneratedAt);\n}\n\nfunction remoteModels(entry: ModelsStoreEntry | undefined, localGeneratedAt: number | undefined): readonly AnyModel[] {\n\treturn entry && isNewer(entry.lastModified, localGeneratedAt) ? entry.models : [];\n}\n\nfunction requestCatalog(\n\tproviderId: string,\n\tcatalogBaseUrl: string,\n\tsignal: AbortSignal,\n\tvalidator?: string,\n): Promise<Response> {\n\tconst url = new URL(`/api/models/providers/${encodeURIComponent(providerId)}`, catalogBaseUrl);\n\turl.searchParams.set(\"types\", REMOTE_CATALOG_MODEL_TYPES.join(\",\"));\n\treturn fetchWithRetry(\n\t\turl,\n\t\t{\n\t\t\theaders: {\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\t...(validator ? { \"if-none-match\": validator } : {}),\n\t\t\t},\n\t\t\tsignal,\n\t\t},\n\t\t{ attemptTimeoutMs: REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS },\n\t);\n}\n\n/** Replaces the catalog with a credential-specific model list. */\nexport type PersonalizeCatalog = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[]>;\n\n/** Add a persisted pi.dev catalog overlay to a static built-in provider. */\nexport function withRemoteCatalog(\n\tprovider: Provider,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tconst models = provider.getAllModels?.() ?? provider.getModels();\n\tif (models.length > 0 && !models.some(isSupportedModelType)) return provider;\n\n\tlet dynamicModels: readonly AnyModel[] = [];\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () =>\n\t\t\tmergeModels(\n\t\t\t\tprovider.getModels(),\n\t\t\t\tdynamicModels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t),\n\t\tgetAllModels: () => mergeModels(provider.getAllModels?.() ?? provider.getModels(), dynamicModels),\n\t\trefreshModels: async (context) => {\n\t\t\t// 0.84.1 hands the snapshot in directly and coalesces concurrent refreshes\n\t\t\t// itself, so the old inflight-promise dedup is gone. Every mutation of\n\t\t\t// dynamicModels now runs inside a generation-checked publish; a false return\n\t\t\t// means a newer refresh already superseded this pass, so it must not continue.\n\t\t\tconst stored = context.stored;\n\t\t\tconst restored = remoteModels(stored, localGeneratedAt).filter(\n\t\t\t\t(model) => model.provider === provider.id && hasOperationShape(model),\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t// Skip the request if pi.dev was checked less than REMOTE_CATALOG_REFRESH_INTERVAL_MS ago.\n\t\t\t// An entry without lastModified (saved by an older version, or after a failed first request) is\n\t\t\t// always refetched: remoteModels() ignores it, so waiting would leave the overlay empty.\n\t\t\tif (\n\t\t\t\t!context.force &&\n\t\t\t\tstored?.checkedAt !== undefined &&\n\t\t\t\tstored.lastModified !== undefined &&\n\t\t\t\tDate.now() - stored.checkedAt < REMOTE_CATALOG_REFRESH_INTERVAL_MS\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only revalidate when a cached body backs the validator, so a 304 can never\n\t\t\t// leave the overlay empty.\n\t\t\tconst validator = stored && stored.models.length > 0 ? stored.etag : undefined;\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, validator);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst checkedAt = Date.now();\n\t\t\t// Unchanged: dynamicModels already holds the stored overlay, so only the\n\t\t\t// freshness window moves.\n\t\t\tif (response.status === 304 && stored) {\n\t\t\t\tawait context.publish({ persist: { ...stored, checkedAt } });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (response.status === 404 || response.status === 501) {\n\t\t\t\tawait context.publish({\n\t\t\t\t\tpersist: {\n\t\t\t\t\t\t...(stored ?? { models: [] }),\n\t\t\t\t\t\tcheckedAt,\n\t\t\t\t\t\tlastModified: 0,\n\t\t\t\t\t\tetag: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok) {\n\t\t\t\t// Transient failure: the cached body and its validator stay valid, so keep the\n\t\t\t\t// etag and let the next refresh revalidate instead of downloading the catalog.\n\t\t\t\tawait context.publish({ persist: { ...(stored ?? { models: [] }), checkedAt } });\n\t\t\t\tthrow new Error(`Model catalog request failed for ${provider.id}: ${response.status}`);\n\t\t\t}\n\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst entry: ModelsStoreEntry = { ...catalog, checkedAt };\n\t\t\tconst published = remoteModels(entry, localGeneratedAt);\n\t\t\tawait context.publish({\n\t\t\t\tpersist: entry,\n\t\t\t\tupdate: () => {\n\t\t\t\t\tdynamicModels = published;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Like `withRemoteCatalog`, but on each network refresh the catalog (built-in models plus a newer\n * pi.dev catalog) is passed through `personalize` and the result is saved. The saved entry holds\n * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.\n * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an\n * empty catalog saved by an older version after a failed or missing pi.dev catalog) falls back to\n * the built-in models.\n */\nexport function withPersonalizedCatalog(\n\tprovider: Provider,\n\tpersonalize: PersonalizeCatalog,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tlet personalModels: readonly AnyModel[] = [];\n\tconst builtinModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst getAllModels = (): readonly AnyModel[] => (personalModels.length > 0 ? personalModels : builtinModels());\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModels: async (context) => {\n\t\t\tconst restored = (context.stored?.models ?? []).filter(\n\t\t\t\t(model) => model.provider === provider.id && hasOperationShape(model),\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tpersonalModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\n\t\t\tlet remote: readonly AnyModel[] = [];\n\t\t\ttry {\n\t\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal);\n\t\t\t\tif (response.ok) {\n\t\t\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\t\t\tif (isNewer(catalog.lastModified, localGeneratedAt)) remote = catalog.models;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tremote = [];\n\t\t\t}\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst personalized = await personalize(mergeModels(builtinModels(), remote), context);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tawait context.publish({\n\t\t\t\tpersist: { models: personalized, checkedAt: Date.now() },\n\t\t\t\tupdate: () => {\n\t\t\t\t\tpersonalModels = personalized;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Lists the models an account offers that `catalog` lacks, or undefined when the account's list\n * could not be read, which keeps the models saved before.\n */\nexport type DiscoverModels = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[] | undefined>;\n\nfunction isDiscoveredModel(model: AnyModel): boolean {\n\treturn isModelType(model, \"chat\") && model.discovered === true;\n}\n\nfunction modelKey(model: AnyModel): string {\n\treturn `${getModelType(model)}\\0${model.id}`;\n}\n\nfunction withSavedModels(entry: ModelsStoreEntry, saved: readonly AnyModel[]): ModelsStoreEntry {\n\treturn { ...entry, models: [...entry.models, ...saved] };\n}\n\n/**\n * Add the models an account offers beyond the provider's catalog. Each network refresh runs the\n * wrapped provider's own refresh first, then `discover`. Discovered models are saved in the\n * provider's stored entry beside the wrapped provider's data, so a later start restores them without\n * the network. They are replaced only by a list `discover` read; when it could not read one, the saved\n * models stay. The catalog always wins: a discovered ID the catalog also lists is dropped, so a\n * curated entry is never replaced.\n */\nexport function withDiscoveredModels(provider: Provider, discover: DiscoverModels): Provider {\n\tlet discovered: readonly AnyModel[] = [];\n\tconst catalogModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst withDiscovered = (catalog: readonly AnyModel[]): AnyModel[] => {\n\t\tconst owned = new Set(catalog.map(modelKey));\n\t\treturn [...catalog, ...discovered.filter((model) => !owned.has(modelKey(model)))];\n\t};\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => withDiscovered(provider.getModels()).filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels: () => withDiscovered(catalogModels()),\n\t\trefreshModels: async (context) => {\n\t\t\tconst stored = context.stored;\n\t\t\tconst saved = (stored?.models ?? []).filter(\n\t\t\t\t(model) => model.provider === provider.id && isDiscoveredModel(model),\n\t\t\t);\n\t\t\tlet catalogEntry: ModelsStoreEntry | undefined = stored && {\n\t\t\t\t...stored,\n\t\t\t\tmodels: stored.models.filter((model) => !isDiscoveredModel(model)),\n\t\t\t};\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdiscovered = saved;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait provider.refreshModels?.({\n\t\t\t\t\t...context,\n\t\t\t\t\tstored: catalogEntry,\n\t\t\t\t\tpublish: (publication) => {\n\t\t\t\t\t\tif (publication.persist === undefined) return context.publish(publication);\n\t\t\t\t\t\tcatalogEntry = publication.persist ?? undefined;\n\t\t\t\t\t\treturn context.publish({\n\t\t\t\t\t\t\t...publication,\n\t\t\t\t\t\t\tpersist: withSavedModels(publication.persist ?? { models: [] }, saved),\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tif (context.allowNetwork && !context.signal.aborted) {\n\t\t\t\t\tconst found = await discover(catalogModels(), context);\n\t\t\t\t\tif (found && !context.signal.aborted) {\n\t\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\t\tpersist: withSavedModels(catalogEntry ?? { models: [] }, found),\n\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\tdiscovered = found;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"remote-catalog-provider.js","sourceRoot":"","sources":["../../src/core/remote-catalog-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,WAAW,GAKX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAClD,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAEhG,SAAS,oBAAoB,CAAC,KAAyB;IACtD,OAAO,CACN,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,0BAA0B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAiB,CAAC,CAAC,C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AAC,OAAO,CAAC,WAAW,CAAC,CAAC;wBAC3E,YAAY,GAAG,WAAW,CAAC,OAAO,IAAI,SAAS,CAAC;wBAChD,OAAO,OAAO,CAAC,OAAO,CAAC;4BACtB,GAAG,WAAW;4BACd,OAAO,EAAE,eAAe,CAAC,WAAW,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;yBACtE,CAAC,CAAC;oBACJ,CAAC;iBACD,CAAC,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACV,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,EAAE,OAAO,CAAC,CAAC;oBACvD,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACtC,MAAM,OAAO,CAAC,OAAO,CAAC;4BACrB,OAAO,EAAE,eAAe,CAAC,YAAY,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC;4BAC/D,MAAM,EAAE,GAAG,EAAE;gCACZ,UAAU,GAAG,KAAK,CAAC;4BACpB,CAAC;yBACD,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype AnyModel,\n\tgetModelType,\n\tisModelType,\n\ttype ModelsStoreEntry,\n\ttype ModelType,\n\ttype Provider,\n\ttype RefreshModelsContext,\n} from \"@bastani/pi-ai\";\nimport { VERSION } from \"../config.js\";\nimport { fetchWithRetry } from \"../utils/management-http.ts\";\nimport { getPiUserAgent } from \"../utils/pi-user-agent.ts\";\n\nconst DEFAULT_CATALOG_BASE_URL = \"https://pi.dev\";\nconst REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS = 4_000;\nexport const REMOTE_CATALOG_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;\n/**\n * Model types this client can consume. Sent as `?types=` so the catalog server\n * returns the full-type shard instead of the chat-only one served to clients\n * that predate model types. A server that ignores the parameter still returns\n * the chat-only shard, which this client handles unchanged.\n */\nexport const REMOTE_CATALOG_MODEL_TYPES: readonly ModelType[] = [\"chat\", \"image\", \"classifier\"];\n\nfunction isSupportedModelType(model: { type?: unknown }): boolean {\n\treturn (\n\t\tmodel.type === undefined ||\n\t\t(typeof model.type === \"string\" && REMOTE_CATALOG_MODEL_TYPES.includes(model.type as ModelType))\n\t);\n}\n\nfunction hasOperationShape(model: unknown): boolean {\n\tif (typeof model !== \"object\" || model === null) return false;\n\tif (!(\"type\" in model) || (model.type !== \"image\" && model.type !== \"classifier\")) return true;\n\tif (!(\"cost\" in model)) return false;\n\tconst cost = model.cost;\n\treturn (\n\t\t\"id\" in model &&\n\t\ttypeof model.id === \"string\" &&\n\t\tmodel.id.length > 0 &&\n\t\t\"name\" in model &&\n\t\ttypeof model.name === \"string\" &&\n\t\t\"api\" in model &&\n\t\ttypeof model.api === \"string\" &&\n\t\t\"baseUrl\" in model &&\n\t\ttypeof model.baseUrl === \"string\" &&\n\t\t\"input\" in model &&\n\t\tArray.isArray(model.input) &&\n\t\tcost !== null &&\n\t\ttypeof cost === \"object\" &&\n\t\t[\"input\", \"output\", \"cacheRead\", \"cacheWrite\"].every(\n\t\t\t(key) => key in cost && typeof (cost as Record<string, unknown>)[key] === \"number\",\n\t\t) &&\n\t\t(model.type === \"image\"\n\t\t\t? \"output\" in model && Array.isArray(model.output) && model.output.includes(\"image\")\n\t\t\t: \"contextWindow\" in model && typeof model.contextWindow === \"number\" && model.contextWindow > 0)\n\t);\n}\n\nfunction mergeModels<TModel extends AnyModel>(baseline: readonly TModel[], dynamic: readonly TModel[]): TModel[] {\n\tconst merged = new Map<string, TModel>();\n\tfor (const model of baseline) merged.set(`${getModelType(model)}\\0${model.id}`, model);\n\tfor (const model of dynamic) {\n\t\tconst key = `${getModelType(model)}\\0${model.id}`;\n\t\tconst bundled = merged.get(key);\n\t\tif (\n\t\t\tbundled &&\n\t\t\tisModelType(bundled, \"chat\") &&\n\t\t\tisModelType(model, \"chat\") &&\n\t\t\tmodel.serviceTiers === undefined &&\n\t\t\tbundled.serviceTiers !== undefined\n\t\t) {\n\t\t\tmerged.set(key, { ...model, serviceTiers: bundled.serviceTiers });\n\t\t} else {\n\t\t\tmerged.set(key, model);\n\t\t}\n\t}\n\treturn [...merged.values()];\n}\n\nfunction parseCatalog(providerId: string, value: unknown): AnyModel[] {\n\tconst entries = Array.isArray(value)\n\t\t? value\n\t\t: typeof value === \"object\" && value !== null && \"models\" in value && Array.isArray(value.models)\n\t\t\t? value.models\n\t\t\t: typeof value === \"object\" && value !== null\n\t\t\t\t? Object.values(value)\n\t\t\t\t: undefined;\n\tif (!entries) throw new Error(`Invalid model catalog for provider \"${providerId}\"`);\n\treturn entries\n\t\t.filter((entry): entry is Record<string, unknown> => typeof entry === \"object\" && entry !== null && \"id\" in entry)\n\t\t.filter(isSupportedModelType)\n\t\t.filter(hasOperationShape)\n\t\t.map((model) => ({ ...model, provider: providerId }) as AnyModel);\n}\n\n/** Read a successful pi.dev catalog response. A missing or invalid Last-Modified header is 0. */\nasync function readCatalog(\n\tproviderId: string,\n\tresponse: Response,\n): Promise<{ models: AnyModel[]; lastModified: number; etag: string | undefined }> {\n\tconst lastModified = Date.parse(response.headers.get(\"last-modified\") ?? \"\");\n\treturn {\n\t\tmodels: parseCatalog(providerId, await response.json()),\n\t\tlastModified: Number.isNaN(lastModified) ? 0 : lastModified,\n\t\tetag: response.headers.get(\"etag\") ?? undefined,\n\t};\n}\n\n/** Whether a pi.dev catalog is newer than the model data shipped with Atomic. */\nfunction isNewer(lastModified: number | undefined, localGeneratedAt: number | undefined): boolean {\n\treturn localGeneratedAt === undefined || (lastModified !== undefined && lastModified > localGeneratedAt);\n}\n\nfunction remoteModels(entry: ModelsStoreEntry | undefined, localGeneratedAt: number | undefined): readonly AnyModel[] {\n\treturn entry && isNewer(entry.lastModified, localGeneratedAt) ? entry.models : [];\n}\n\nfunction requestCatalog(\n\tproviderId: string,\n\tcatalogBaseUrl: string,\n\tsignal: AbortSignal,\n\tvalidator?: string,\n): Promise<Response> {\n\tconst url = new URL(`/api/models/providers/${encodeURIComponent(providerId)}`, catalogBaseUrl);\n\turl.searchParams.set(\"types\", REMOTE_CATALOG_MODEL_TYPES.join(\",\"));\n\treturn fetchWithRetry(\n\t\turl,\n\t\t{\n\t\t\theaders: {\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"User-Agent\": getPiUserAgent(VERSION),\n\t\t\t\t...(validator ? { \"if-none-match\": validator } : {}),\n\t\t\t},\n\t\t\tsignal,\n\t\t},\n\t\t{ attemptTimeoutMs: REMOTE_CATALOG_ATTEMPT_TIMEOUT_MS },\n\t);\n}\n\n/** Replaces the catalog with a credential-specific model list. */\nexport type PersonalizeCatalog = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[]>;\n\n/** Add a persisted pi.dev catalog overlay to a static built-in provider. */\nexport function withRemoteCatalog(\n\tprovider: Provider,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tconst models = provider.getAllModels?.() ?? provider.getModels();\n\tif (models.length > 0 && !models.some(isSupportedModelType)) return provider;\n\n\tlet dynamicModels: readonly AnyModel[] = [];\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () =>\n\t\t\tmergeModels(\n\t\t\t\tprovider.getModels(),\n\t\t\t\tdynamicModels.filter((model) => isModelType(model, \"chat\")),\n\t\t\t),\n\t\tgetAllModels: () => mergeModels(provider.getAllModels?.() ?? provider.getModels(), dynamicModels),\n\t\trefreshModelsAuth: \"configured\",\n\t\trefreshModels: async (context) => {\n\t\t\t// 0.84.1 hands the snapshot in directly and coalesces concurrent refreshes\n\t\t\t// itself, so the old inflight-promise dedup is gone. Every mutation of\n\t\t\t// dynamicModels now runs inside a generation-checked publish; a false return\n\t\t\t// means a newer refresh already superseded this pass, so it must not continue.\n\t\t\tconst stored = context.stored;\n\t\t\tconst restored = remoteModels(stored, localGeneratedAt).filter(\n\t\t\t\t(model) => model.provider === provider.id && hasOperationShape(model),\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdynamicModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\t\t\t// Skip the request if pi.dev was checked less than REMOTE_CATALOG_REFRESH_INTERVAL_MS ago.\n\t\t\t// An entry without lastModified (saved by an older version, or after a failed first request) is\n\t\t\t// always refetched: remoteModels() ignores it, so waiting would leave the overlay empty.\n\t\t\tif (\n\t\t\t\t!context.force &&\n\t\t\t\tstored?.checkedAt !== undefined &&\n\t\t\t\tstored.lastModified !== undefined &&\n\t\t\t\tDate.now() - stored.checkedAt < REMOTE_CATALOG_REFRESH_INTERVAL_MS\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only revalidate when a cached body backs the validator, so a 304 can never\n\t\t\t// leave the overlay empty.\n\t\t\tconst validator = stored && stored.models.length > 0 ? stored.etag : undefined;\n\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal, validator);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst checkedAt = Date.now();\n\t\t\t// Unchanged: dynamicModels already holds the stored overlay, so only the\n\t\t\t// freshness window moves.\n\t\t\tif (response.status === 304 && stored) {\n\t\t\t\tawait context.publish({ persist: { ...stored, checkedAt } });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (response.status === 404 || response.status === 501) {\n\t\t\t\tawait context.publish({\n\t\t\t\t\tpersist: {\n\t\t\t\t\t\t...(stored ?? { models: [] }),\n\t\t\t\t\t\tcheckedAt,\n\t\t\t\t\t\tlastModified: 0,\n\t\t\t\t\t\tetag: undefined,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!response.ok) {\n\t\t\t\t// Transient failure: the cached body and its validator stay valid, so keep the\n\t\t\t\t// etag and let the next refresh revalidate instead of downloading the catalog.\n\t\t\t\tawait context.publish({ persist: { ...(stored ?? { models: [] }), checkedAt } });\n\t\t\t\tthrow new Error(`Model catalog request failed for ${provider.id}: ${response.status}`);\n\t\t\t}\n\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst entry: ModelsStoreEntry = { ...catalog, checkedAt };\n\t\t\tconst published = remoteModels(entry, localGeneratedAt);\n\t\t\tawait context.publish({\n\t\t\t\tpersist: entry,\n\t\t\t\tupdate: () => {\n\t\t\t\t\tdynamicModels = published;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Like `withRemoteCatalog`, but on each network refresh the catalog (built-in models plus a newer\n * pi.dev catalog) is passed through `personalize` and the result is saved. The saved entry holds\n * the personalized list, not the pi.dev catalog, and replaces the catalog, including offline.\n * The refresh interval and etag revalidation are skipped. An empty list (nothing saved yet, or an\n * empty catalog saved by an older version after a failed or missing pi.dev catalog) falls back to\n * the built-in models.\n */\nexport function withPersonalizedCatalog(\n\tprovider: Provider,\n\tpersonalize: PersonalizeCatalog,\n\tcatalogBaseUrl: string = DEFAULT_CATALOG_BASE_URL,\n\tlocalGeneratedAt?: number,\n): Provider {\n\tlet personalModels: readonly AnyModel[] = [];\n\tconst builtinModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst getAllModels = (): readonly AnyModel[] => (personalModels.length > 0 ? personalModels : builtinModels());\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => getAllModels().filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels,\n\t\trefreshModelsAuth: \"credential\",\n\t\trefreshModels: async (context) => {\n\t\t\tconst restored = (context.stored?.models ?? []).filter(\n\t\t\t\t(model) => model.provider === provider.id && hasOperationShape(model),\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tpersonalModels = restored;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!context.allowNetwork || context.signal.aborted) return;\n\n\t\t\tlet remote: readonly AnyModel[] = [];\n\t\t\ttry {\n\t\t\t\tconst response = await requestCatalog(provider.id, catalogBaseUrl, context.signal);\n\t\t\t\tif (response.ok) {\n\t\t\t\t\tconst catalog = await readCatalog(provider.id, response);\n\t\t\t\t\tif (isNewer(catalog.lastModified, localGeneratedAt)) remote = catalog.models;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tremote = [];\n\t\t\t}\n\t\t\tif (context.signal.aborted) return;\n\t\t\tconst personalized = await personalize(mergeModels(builtinModels(), remote), context);\n\t\t\tif (context.signal.aborted) return;\n\t\t\tawait context.publish({\n\t\t\t\tpersist: { models: personalized, checkedAt: Date.now() },\n\t\t\t\tupdate: () => {\n\t\t\t\t\tpersonalModels = personalized;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n}\n\n/**\n * Lists the models an account offers that `catalog` lacks, or undefined when the account's list\n * could not be read, which keeps the models saved before.\n */\nexport type DiscoverModels = (\n\tcatalog: readonly AnyModel[],\n\tcontext: RefreshModelsContext,\n) => Promise<readonly AnyModel[] | undefined>;\n\nfunction isDiscoveredModel(model: AnyModel): boolean {\n\treturn isModelType(model, \"chat\") && model.discovered === true;\n}\n\nfunction modelKey(model: AnyModel): string {\n\treturn `${getModelType(model)}\\0${model.id}`;\n}\n\nfunction withSavedModels(entry: ModelsStoreEntry, saved: readonly AnyModel[]): ModelsStoreEntry {\n\treturn { ...entry, models: [...entry.models, ...saved] };\n}\n\n/**\n * Add the models an account offers beyond the provider's catalog. Each network refresh runs the\n * wrapped provider's own refresh first, then `discover`. Discovered models are saved in the\n * provider's stored entry beside the wrapped provider's data, so a later start restores them without\n * the network. They are replaced only by a list `discover` read; when it could not read one, the saved\n * models stay. The catalog always wins: a discovered ID the catalog also lists is dropped, so a\n * curated entry is never replaced.\n */\nexport function withDiscoveredModels(provider: Provider, discover: DiscoverModels): Provider {\n\tlet discovered: readonly AnyModel[] = [];\n\tconst catalogModels = (): readonly AnyModel[] => provider.getAllModels?.() ?? provider.getModels();\n\tconst withDiscovered = (catalog: readonly AnyModel[]): AnyModel[] => {\n\t\tconst owned = new Set(catalog.map(modelKey));\n\t\treturn [...catalog, ...discovered.filter((model) => !owned.has(modelKey(model)))];\n\t};\n\n\treturn {\n\t\t...provider,\n\t\tgetModels: () => withDiscovered(provider.getModels()).filter((model) => isModelType(model, \"chat\")),\n\t\tgetAllModels: () => withDiscovered(catalogModels()),\n\t\trefreshModelsAuth: \"credential\",\n\t\trefreshModels: async (context) => {\n\t\t\tconst stored = context.stored;\n\t\t\tconst saved = (stored?.models ?? []).filter(\n\t\t\t\t(model) => model.provider === provider.id && isDiscoveredModel(model),\n\t\t\t);\n\t\t\tlet catalogEntry: ModelsStoreEntry | undefined = stored && {\n\t\t\t\t...stored,\n\t\t\t\tmodels: stored.models.filter((model) => !isDiscoveredModel(model)),\n\t\t\t};\n\t\t\tif (\n\t\t\t\t!(await context.publish({\n\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\tdiscovered = saved;\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait provider.refreshModels?.({\n\t\t\t\t\t...context,\n\t\t\t\t\tstored: catalogEntry,\n\t\t\t\t\tpublish: (publication) => {\n\t\t\t\t\t\tif (publication.persist === undefined) return context.publish(publication);\n\t\t\t\t\t\tcatalogEntry = publication.persist ?? undefined;\n\t\t\t\t\t\treturn context.publish({\n\t\t\t\t\t\t\t...publication,\n\t\t\t\t\t\t\tpersist: withSavedModels(publication.persist ?? { models: [] }, saved),\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} finally {\n\t\t\t\tif (context.allowNetwork && !context.signal.aborted) {\n\t\t\t\t\tconst found = await discover(catalogModels(), context);\n\t\t\t\t\tif (found && !context.signal.aborted) {\n\t\t\t\t\t\tawait context.publish({\n\t\t\t\t\t\t\tpersist: withSavedModels(catalogEntry ?? { models: [] }, found),\n\t\t\t\t\t\t\tupdate: () => {\n\t\t\t\t\t\t\t\tdiscovered = found;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,32 @@
1
+ export type ExpressionObject = {
2
+ [key: string]: ExpressionValue;
3
+ };
4
+ export type ExpressionValue = null | boolean | number | string | ExpressionValue[] | ExpressionObject;
5
+ /** What an expression can read. A context name that is not in `roots` is unsupported, never empty. */
6
+ export interface ExpressionContext {
7
+ readonly roots: {
8
+ readonly [name: string]: ExpressionValue;
9
+ };
10
+ /** Whether an earlier step failed, which decides `success()` and `failure()`. */
11
+ readonly failed: boolean;
12
+ }
13
+ /** An expression uses syntax, a context, a property or a function this evaluator does not implement, or is malformed. */
14
+ export declare class ExpressionError extends Error {
15
+ readonly name: "ExpressionError";
16
+ readonly problem: string;
17
+ constructor(source: string, problem: string, options?: ErrorOptions);
18
+ }
19
+ /** An object whose properties are all known: reading another one is an unsupported property, not null. */
20
+ export declare function closedObject(label: string, properties: ExpressionObject): ExpressionObject;
21
+ /** GitHub's conversion of a value to text: objects and arrays are not rendered. */
22
+ export declare function toText(value: ExpressionValue | undefined): string;
23
+ /** The value of one expression, the text between `${{` and `}}`. */
24
+ export declare function evaluateExpression(source: string, context: ExpressionContext): ExpressionValue;
25
+ /** `template` with every `${{ expression }}` replaced by the text of its value. */
26
+ export declare function interpolate(template: string, context: ExpressionContext): string;
27
+ /**
28
+ * Whether an `if` condition holds, with or without the `${{ }}` around it. A condition without a status function also
29
+ * requires that no earlier step failed, as in GitHub.
30
+ */
31
+ export declare function evaluateCondition(condition: string, context: ExpressionContext): boolean;
32
+ //# sourceMappingURL=action-expressions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-expressions.d.ts","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/action-expressions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EAAE,GAAG,gBAAgB,CAAC;AAEtG,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IAC7D,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAED,yHAAyH;AACzH,qBAAa,eAAgB,SAAQ,KAAK;IACzC,SAAkB,IAAI,EAAG,iBAAiB,CAAU;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlE;CACD;AAID,0GAA0G;AAC1G,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CAG1F;AAqOD,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAWjE;AAqGD,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,eAAe,CAE9F;AAYD,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAWhF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAOxF"}
@@ -0,0 +1,389 @@
1
+ /** An expression uses syntax, a context, a property or a function this evaluator does not implement, or is malformed. */
2
+ export class ExpressionError extends Error {
3
+ name = "ExpressionError";
4
+ problem;
5
+ constructor(source, problem, options) {
6
+ super(`${problem} in "${source.trim().slice(0, 80)}"`, options);
7
+ this.problem = problem;
8
+ }
9
+ }
10
+ const closedObjects = new WeakMap();
11
+ /** An object whose properties are all known: reading another one is an unsupported property, not null. */
12
+ export function closedObject(label, properties) {
13
+ closedObjects.set(properties, label);
14
+ return properties;
15
+ }
16
+ const TOKEN_PATTERN = /(?<number>-?(?:0x[0-9a-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?))|(?<string>'(?:[^']|'')*')|(?<name>[a-z_][a-z0-9_-]*)|(?<symbol>==|!=|&&|\|\||[()[\].,!])/iy;
17
+ function tokenize(source) {
18
+ const tokens = [];
19
+ const pattern = new RegExp(TOKEN_PATTERN);
20
+ let position = 0;
21
+ for (;;) {
22
+ while (/\s/.test(source.charAt(position)))
23
+ position++;
24
+ if (position >= source.length)
25
+ return tokens;
26
+ pattern.lastIndex = position;
27
+ const groups = pattern.exec(source)?.groups;
28
+ if (groups === undefined) {
29
+ throw new ExpressionError(source, `unsupported syntax near "${source.slice(position, position + 12)}"`);
30
+ }
31
+ position = pattern.lastIndex;
32
+ if (groups.number !== undefined)
33
+ tokens.push({ kind: "number", value: Number(groups.number) });
34
+ else if (groups.string !== undefined) {
35
+ tokens.push({ kind: "string", value: groups.string.slice(1, -1).replaceAll("''", "'") });
36
+ }
37
+ else if (groups.name !== undefined)
38
+ tokens.push({ kind: "name", value: groups.name });
39
+ else
40
+ tokens.push({ kind: "symbol", value: groups.symbol });
41
+ }
42
+ }
43
+ const STATUS_FUNCTIONS = new Set(["always", "success", "failure", "cancelled"]);
44
+ const FUNCTIONS = {
45
+ contains: {
46
+ min: 2,
47
+ max: 2,
48
+ call: ([search, item]) => Array.isArray(search)
49
+ ? search.some((element) => looselyEqual(element, item))
50
+ : toText(search).toLowerCase().includes(toText(item).toLowerCase()),
51
+ },
52
+ startswith: {
53
+ min: 2,
54
+ max: 2,
55
+ call: ([text, prefix]) => toText(text).toLowerCase().startsWith(toText(prefix).toLowerCase()),
56
+ },
57
+ endswith: {
58
+ min: 2,
59
+ max: 2,
60
+ call: ([text, suffix]) => toText(text).toLowerCase().endsWith(toText(suffix).toLowerCase()),
61
+ },
62
+ format: {
63
+ min: 1,
64
+ max: Number.POSITIVE_INFINITY,
65
+ call: ([template, ...values], _context, source) => formatText(source, toText(template), values),
66
+ },
67
+ join: {
68
+ min: 1,
69
+ max: 2,
70
+ call: ([values, separator]) => Array.isArray(values)
71
+ ? values.map(toText).join(separator === undefined ? "," : toText(separator))
72
+ : toText(values),
73
+ },
74
+ tojson: { min: 1, max: 1, call: ([value]) => JSON.stringify(value, null, 2) },
75
+ fromjson: {
76
+ min: 1,
77
+ max: 1,
78
+ call: ([text], _context, source) => {
79
+ try {
80
+ return JSON.parse(toText(text));
81
+ }
82
+ catch (error) {
83
+ throw new ExpressionError(source, "fromJSON was given text that is not JSON", { cause: error });
84
+ }
85
+ },
86
+ },
87
+ always: { min: 0, max: 0, call: () => true },
88
+ success: { min: 0, max: 0, call: (_args, context) => !context.failed },
89
+ failure: { min: 0, max: 0, call: (_args, context) => context.failed },
90
+ cancelled: { min: 0, max: 0, call: () => false },
91
+ };
92
+ function formatText(source, template, values) {
93
+ let result = "";
94
+ for (let position = 0; position < template.length; position++) {
95
+ const character = template.charAt(position);
96
+ const next = template.charAt(position + 1);
97
+ if (character === "{" && next === "{") {
98
+ result += "{";
99
+ position++;
100
+ }
101
+ else if (character === "}" && next === "}") {
102
+ result += "}";
103
+ position++;
104
+ }
105
+ else if (character === "{") {
106
+ const close = template.indexOf("}", position);
107
+ const index = close === -1 ? "" : template.slice(position + 1, close);
108
+ if (!/^\d+$/.test(index) || Number(index) >= values.length) {
109
+ throw new ExpressionError(source, "format was given a placeholder it cannot fill");
110
+ }
111
+ result += toText(values[Number(index)] ?? null);
112
+ position = close;
113
+ }
114
+ else if (character === "}") {
115
+ throw new ExpressionError(source, "format was given an unmatched }");
116
+ }
117
+ else
118
+ result += character;
119
+ }
120
+ return result;
121
+ }
122
+ function parse(source) {
123
+ const tokens = tokenize(source);
124
+ let position = 0;
125
+ function fail(problem) {
126
+ throw new ExpressionError(source, problem);
127
+ }
128
+ function takeSymbol(...symbols) {
129
+ const token = tokens[position];
130
+ if (token?.kind !== "symbol" || !symbols.includes(token.value))
131
+ return undefined;
132
+ position++;
133
+ return token.value;
134
+ }
135
+ function expectSymbol(symbol) {
136
+ if (takeSymbol(symbol) === undefined)
137
+ fail(`expected "${symbol}"`);
138
+ }
139
+ function parseCall(name) {
140
+ const key = name.toLowerCase();
141
+ const definition = Object.hasOwn(FUNCTIONS, key) ? FUNCTIONS[key] : undefined;
142
+ if (definition === undefined)
143
+ return fail(`unsupported function ${name}`);
144
+ const args = [];
145
+ if (takeSymbol(")") === undefined) {
146
+ args.push(parseOr());
147
+ while (takeSymbol(",") !== undefined)
148
+ args.push(parseOr());
149
+ expectSymbol(")");
150
+ }
151
+ if (args.length < definition.min || args.length > definition.max) {
152
+ fail(`${name} was given ${args.length} arguments`);
153
+ }
154
+ return { kind: "call", name: key, args };
155
+ }
156
+ function parsePrimary() {
157
+ const token = tokens[position++];
158
+ if (token === undefined)
159
+ return fail("expected a value");
160
+ if (token.kind === "number" || token.kind === "string")
161
+ return { kind: "literal", value: token.value };
162
+ if (token.kind === "name") {
163
+ const keyword = token.value.toLowerCase();
164
+ if (keyword === "true")
165
+ return { kind: "literal", value: true };
166
+ if (keyword === "false")
167
+ return { kind: "literal", value: false };
168
+ if (keyword === "null")
169
+ return { kind: "literal", value: null };
170
+ return takeSymbol("(") === undefined ? { kind: "context", name: token.value } : parseCall(token.value);
171
+ }
172
+ if (token.value !== "(")
173
+ return fail(`unexpected "${token.value}"`);
174
+ const inner = parseOr();
175
+ expectSymbol(")");
176
+ return inner;
177
+ }
178
+ function parsePostfix() {
179
+ let node = parsePrimary();
180
+ for (;;) {
181
+ if (takeSymbol(".") !== undefined) {
182
+ const property = tokens[position++];
183
+ if (property?.kind !== "name")
184
+ return fail('expected a property name after "."');
185
+ node = { kind: "member", object: node, property: property.value };
186
+ }
187
+ else if (takeSymbol("[") !== undefined) {
188
+ const index = parseOr();
189
+ expectSymbol("]");
190
+ node = { kind: "index", object: node, index };
191
+ }
192
+ else
193
+ return node;
194
+ }
195
+ }
196
+ function parseUnary() {
197
+ return takeSymbol("!") === undefined ? parsePostfix() : { kind: "not", operand: parseUnary() };
198
+ }
199
+ function parseEquality() {
200
+ let left = parseUnary();
201
+ for (let operator = takeSymbol("==", "!="); operator !== undefined; operator = takeSymbol("==", "!=")) {
202
+ left = { kind: "equality", negated: operator === "!=", left, right: parseUnary() };
203
+ }
204
+ return left;
205
+ }
206
+ function parseAnd() {
207
+ let left = parseEquality();
208
+ while (takeSymbol("&&") !== undefined)
209
+ left = { kind: "logical", operator: "&&", left, right: parseEquality() };
210
+ return left;
211
+ }
212
+ function parseOr() {
213
+ let left = parseAnd();
214
+ while (takeSymbol("||") !== undefined)
215
+ left = { kind: "logical", operator: "||", left, right: parseAnd() };
216
+ return left;
217
+ }
218
+ const tree = parseOr();
219
+ if (position < tokens.length)
220
+ fail("unexpected input after the expression");
221
+ return tree;
222
+ }
223
+ function typeOf(value) {
224
+ if (value === null)
225
+ return "null";
226
+ if (Array.isArray(value))
227
+ return "array";
228
+ return typeof value;
229
+ }
230
+ /** GitHub's conversion of a value to text: objects and arrays are not rendered. */
231
+ export function toText(value) {
232
+ switch (typeOf(value ?? null)) {
233
+ case "null":
234
+ return "";
235
+ case "array":
236
+ return "Array";
237
+ case "object":
238
+ return "Object";
239
+ default:
240
+ return String(value);
241
+ }
242
+ }
243
+ function toNumber(value) {
244
+ switch (typeOf(value)) {
245
+ case "null":
246
+ return 0;
247
+ case "boolean":
248
+ return value === true ? 1 : 0;
249
+ case "number":
250
+ return value;
251
+ case "string":
252
+ return value.trim() === "" ? 0 : Number(value);
253
+ default:
254
+ return Number.NaN;
255
+ }
256
+ }
257
+ function isTruthy(value) {
258
+ return !(value === null || value === false || value === 0 || value === "" || Number.isNaN(value));
259
+ }
260
+ function looselyEqual(left, right) {
261
+ const other = right ?? null;
262
+ if (typeof left === "string" && typeof other === "string")
263
+ return left.toLowerCase() === other.toLowerCase();
264
+ if (typeOf(left) === typeOf(other))
265
+ return left === other;
266
+ const leftType = typeOf(left);
267
+ const otherType = typeOf(other);
268
+ if (leftType === "object" || leftType === "array" || otherType === "object" || otherType === "array")
269
+ return false;
270
+ return toNumber(left) === toNumber(other);
271
+ }
272
+ function lookup(object, name) {
273
+ if (Object.hasOwn(object, name))
274
+ return object[name];
275
+ const lowered = name.toLowerCase();
276
+ for (const [key, value] of Object.entries(object))
277
+ if (key.toLowerCase() === lowered)
278
+ return value;
279
+ return undefined;
280
+ }
281
+ function readProperty(source, value, name) {
282
+ if (typeOf(value) !== "object")
283
+ return null;
284
+ const object = value;
285
+ const found = lookup(object, name);
286
+ if (found !== undefined)
287
+ return found;
288
+ const label = closedObjects.get(object);
289
+ if (label !== undefined)
290
+ throw new ExpressionError(source, `unsupported property ${label}.${name}`);
291
+ return null;
292
+ }
293
+ function evaluate(node, context, source) {
294
+ switch (node.kind) {
295
+ case "literal":
296
+ return node.value;
297
+ case "context": {
298
+ const root = lookup(context.roots, node.name);
299
+ if (root === undefined)
300
+ throw new ExpressionError(source, `unsupported context ${node.name}`);
301
+ return root;
302
+ }
303
+ case "member":
304
+ return readProperty(source, evaluate(node.object, context, source), node.property);
305
+ case "index": {
306
+ const object = evaluate(node.object, context, source);
307
+ const index = evaluate(node.index, context, source);
308
+ if (Array.isArray(object))
309
+ return typeof index === "number" ? (object[index] ?? null) : null;
310
+ return typeof index === "string" ? readProperty(source, object, index) : null;
311
+ }
312
+ case "call": {
313
+ const args = node.args.map((arg) => evaluate(arg, context, source));
314
+ return FUNCTIONS[node.name].call(args, context, source);
315
+ }
316
+ case "not":
317
+ return !isTruthy(evaluate(node.operand, context, source));
318
+ case "equality": {
319
+ const equal = looselyEqual(evaluate(node.left, context, source), evaluate(node.right, context, source));
320
+ return node.negated ? !equal : equal;
321
+ }
322
+ case "logical": {
323
+ const left = evaluate(node.left, context, source);
324
+ if (isTruthy(left) === (node.operator === "||"))
325
+ return left;
326
+ return evaluate(node.right, context, source);
327
+ }
328
+ }
329
+ }
330
+ function usesStatusFunction(node) {
331
+ switch (node.kind) {
332
+ case "call":
333
+ return STATUS_FUNCTIONS.has(node.name) || node.args.some(usesStatusFunction);
334
+ case "member":
335
+ return usesStatusFunction(node.object);
336
+ case "index":
337
+ return usesStatusFunction(node.object) || usesStatusFunction(node.index);
338
+ case "not":
339
+ return usesStatusFunction(node.operand);
340
+ case "equality":
341
+ case "logical":
342
+ return usesStatusFunction(node.left) || usesStatusFunction(node.right);
343
+ default:
344
+ return false;
345
+ }
346
+ }
347
+ /** The value of one expression, the text between `${{` and `}}`. */
348
+ export function evaluateExpression(source, context) {
349
+ return evaluate(parse(source), context, source);
350
+ }
351
+ function findClose(text, from) {
352
+ let quoted = false;
353
+ for (let position = from; position < text.length; position++) {
354
+ const character = text.charAt(position);
355
+ if (character === "'")
356
+ quoted = !quoted;
357
+ else if (!quoted && character === "}" && text.charAt(position + 1) === "}")
358
+ return position;
359
+ }
360
+ return -1;
361
+ }
362
+ /** `template` with every `${{ expression }}` replaced by the text of its value. */
363
+ export function interpolate(template, context) {
364
+ let result = "";
365
+ let position = 0;
366
+ for (;;) {
367
+ const start = template.indexOf("${{", position);
368
+ if (start === -1)
369
+ return result + template.slice(position);
370
+ const end = findClose(template, start + 3);
371
+ if (end === -1)
372
+ throw new ExpressionError(template.slice(start), 'unterminated "${{"');
373
+ result += template.slice(position, start) + toText(evaluateExpression(template.slice(start + 3, end), context));
374
+ position = end + 2;
375
+ }
376
+ }
377
+ /**
378
+ * Whether an `if` condition holds, with or without the `${{ }}` around it. A condition without a status function also
379
+ * requires that no earlier step failed, as in GitHub.
380
+ */
381
+ export function evaluateCondition(condition, context) {
382
+ const trimmed = condition.trim();
383
+ const wrapped = trimmed.startsWith("${{") && findClose(trimmed, 3) === trimmed.length - 2;
384
+ const source = wrapped ? trimmed.slice(3, -2) : trimmed;
385
+ const tree = parse(source);
386
+ const holds = isTruthy(evaluate(tree, context, source));
387
+ return usesStatusFunction(tree) ? holds : !context.failed && holds;
388
+ }
389
+ //# sourceMappingURL=action-expressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-expressions.js","sourceRoot":"","sources":["../../../../src/core/resume/blueprint/action-expressions.ts"],"names":[],"mappings":"AAUA,yHAAyH;AACzH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACvB,IAAI,GAAG,iBAA0B,CAAC;IAC3C,OAAO,CAAS;IAEzB,YAAY,MAAc,EAAE,OAAe,EAAE,OAAsB;QAClE,KAAK,CAAC,GAAG,OAAO,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD;AAED,MAAM,aAAa,GAAG,IAAI,OAAO,EAA4B,CAAC;AAE9D,0GAA0G;AAC1G,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,UAA4B;IACvE,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC;AAmBD,MAAM,aAAa,GAClB,qJAAqJ,CAAC;AAEvJ,SAAS,QAAQ,CAAC,MAAc;IAC/B,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,MAAM,OAAO,G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C;QACvF,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QAChH,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC;IACpB,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,OAA0B;IAC9E,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1F,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACxD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC;AACpE,CAAC","sourcesContent":["export type ExpressionObject = { [key: string]: ExpressionValue };\nexport type ExpressionValue = null | boolean | number | string | ExpressionValue[] | ExpressionObject;\n\n/** What an expression can read. A context name that is not in `roots` is unsupported, never empty. */\nexport interface ExpressionContext {\n\treadonly roots: { readonly [name: string]: ExpressionValue };\n\t/** Whether an earlier step failed, which decides `success()` and `failure()`. */\n\treadonly failed: boolean;\n}\n\n/** An expression uses syntax, a context, a property or a function this evaluator does not implement, or is malformed. */\nexport class ExpressionError extends Error {\n\toverride readonly name = \"ExpressionError\" as const;\n\treadonly problem: string;\n\n\tconstructor(source: string, problem: string, options?: ErrorOptions) {\n\t\tsuper(`${problem} in \"${source.trim().slice(0, 80)}\"`, options);\n\t\tthis.problem = problem;\n\t}\n}\n\nconst closedObjects = new WeakMap<ExpressionObject, string>();\n\n/** An object whose properties are all known: reading another one is an unsupported property, not null. */\nexport function closedObject(label: string, properties: ExpressionObject): ExpressionObject {\n\tclosedObjects.set(properties, label);\n\treturn properties;\n}\n\ntype Punctuation = \"(\" | \")\" | \"[\" | \"]\" | \".\" | \",\" | \"!\" | \"==\" | \"!=\" | \"&&\" | \"||\";\ntype Token =\n\t| { readonly kind: \"number\"; readonly value: number }\n\t| { readonly kind: \"string\"; readonly value: string }\n\t| { readonly kind: \"name\"; readonly value: string }\n\t| { readonly kind: \"symbol\"; readonly value: Punctuation };\n\ntype Node =\n\t| { readonly kind: \"literal\"; readonly value: ExpressionValue }\n\t| { readonly kind: \"context\"; readonly name: string }\n\t| { readonly kind: \"member\"; readonly object: Node; readonly property: string }\n\t| { readonly kind: \"index\"; readonly object: Node; readonly index: Node }\n\t| { readonly kind: \"call\"; readonly name: string; readonly args: readonly Node[] }\n\t| { readonly kind: \"not\"; readonly operand: Node }\n\t| { readonly kind: \"equality\"; readonly negated: boolean; readonly left: Node; readonly right: Node }\n\t| { readonly kind: \"logical\"; readonly operator: \"&&\" | \"||\"; readonly left: Node; readonly right: Node };\n\nconst TOKEN_PATTERN =\n\t/(?<number>-?(?:0x[0-9a-f]+|\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?))|(?<string>'(?:[^']|'')*')|(?<name>[a-z_][a-z0-9_-]*)|(?<symbol>==|!=|&&|\\|\\||[()[\\].,!])/iy;\n\nfunction tokenize(source: string): Token[] {\n\tconst tokens: Token[] = [];\n\tconst pattern = new RegExp(TOKEN_PATTERN);\n\tlet position = 0;\n\tfor (;;) {\n\t\twhile (/\\s/.test(source.charAt(position))) position++;\n\t\tif (position >= source.length) return tokens;\n\t\tpattern.lastIndex = position;\n\t\tconst groups = pattern.exec(source)?.groups;\n\t\tif (groups === undefined) {\n\t\t\tthrow new ExpressionError(source, `unsupported syntax near \"${source.slice(position, position + 12)}\"`);\n\t\t}\n\t\tposition = pattern.lastIndex;\n\t\tif (groups.number !== undefined) tokens.push({ kind: \"number\", value: Number(groups.number) });\n\t\telse if (groups.string !== undefined) {\n\t\t\ttokens.push({ kind: \"string\", value: groups.string.slice(1, -1).replaceAll(\"''\", \"'\") });\n\t\t} else if (groups.name !== undefined) tokens.push({ kind: \"name\", value: groups.name });\n\t\telse tokens.push({ kind: \"symbol\", value: groups.symbol as Punctuation });\n\t}\n}\n\ninterface FunctionDefinition {\n\treadonly min: number;\n\treadonly max: number;\n\treadonly call: (args: ExpressionValue[], context: ExpressionContext, source: string) => ExpressionValue;\n}\n\nconst STATUS_FUNCTIONS: ReadonlySet<string> = new Set([\"always\", \"success\", \"failure\", \"cancelled\"]);\n\nconst FUNCTIONS: Readonly<Record<string, FunctionDefinition>> = {\n\tcontains: {\n\t\tmin: 2,\n\t\tmax: 2,\n\t\tcall: ([search, item]) =>\n\t\t\tArray.isArray(search)\n\t\t\t\t? search.some((element) => looselyEqual(element, item))\n\t\t\t\t: toText(search).toLowerCase().includes(toText(item).toLowerCase()),\n\t},\n\tstartswith: {\n\t\tmin: 2,\n\t\tmax: 2,\n\t\tcall: ([text, prefix]) => toText(text).toLowerCase().startsWith(toText(prefix).toLowerCase()),\n\t},\n\tendswith: {\n\t\tmin: 2,\n\t\tmax: 2,\n\t\tcall: ([text, suffix]) => toText(text).toLowerCase().endsWith(toText(suffix).toLowerCase()),\n\t},\n\tformat: {\n\t\tmin: 1,\n\t\tmax: Number.POSITIVE_INFINITY,\n\t\tcall: ([template, ...values], _context, source) => formatText(source, toText(template), values),\n\t},\n\tjoin: {\n\t\tmin: 1,\n\t\tmax: 2,\n\t\tcall: ([values, separator]) =>\n\t\t\tArray.isArray(values)\n\t\t\t\t? values.map(toText).join(separator === undefined ? \",\" : toText(separator))\n\t\t\t\t: toText(values),\n\t},\n\ttojson: { min: 1, max: 1, call: ([value]) => JSON.stringify(value, null, 2) },\n\tfromjson: {\n\t\tmin: 1,\n\t\tmax: 1,\n\t\tcall: ([text], _context, source) => {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(toText(text)) as ExpressionValue;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new ExpressionError(source, \"fromJSON was given text that is not JSON\", { cause: error });\n\t\t\t}\n\t\t},\n\t},\n\talways: { min: 0, max: 0, call: () => true },\n\tsuccess: { min: 0, max: 0, call: (_args, context) => !context.failed },\n\tfailure: { min: 0, max: 0, call: (_args, context) => context.failed },\n\tcancelled: { min: 0, max: 0, call: () => false },\n};\n\nfunction formatText(source: string, template: string, values: readonly ExpressionValue[]): string {\n\tlet result = \"\";\n\tfor (let position = 0; position < template.length; position++) {\n\t\tconst character = template.charAt(position);\n\t\tconst next = template.charAt(position + 1);\n\t\tif (character === \"{\" && next === \"{\") {\n\t\t\tresult += \"{\";\n\t\t\tposition++;\n\t\t} else if (character === \"}\" && next === \"}\") {\n\t\t\tresult += \"}\";\n\t\t\tposition++;\n\t\t} else if (character === \"{\") {\n\t\t\tconst close = template.indexOf(\"}\", position);\n\t\t\tconst index = close === -1 ? \"\" : template.slice(position + 1, close);\n\t\t\tif (!/^\\d+$/.test(index) || Number(index) >= values.length) {\n\t\t\t\tthrow new ExpressionError(source, \"format was given a placeholder it cannot fill\");\n\t\t\t}\n\t\t\tresult += toText(values[Number(index)] ?? null);\n\t\t\tposition = close;\n\t\t} else if (character === \"}\") {\n\t\t\tthrow new ExpressionError(source, \"format was given an unmatched }\");\n\t\t} else result += character;\n\t}\n\treturn result;\n}\n\nfunction parse(source: string): Node {\n\tconst tokens = tokenize(source);\n\tlet position = 0;\n\n\tfunction fail(problem: string): never {\n\t\tthrow new ExpressionError(source, problem);\n\t}\n\n\tfunction takeSymbol(...symbols: Punctuation[]): Punctuation | undefined {\n\t\tconst token = tokens[position];\n\t\tif (token?.kind !== \"symbol\" || !symbols.includes(token.value)) return undefined;\n\t\tposition++;\n\t\treturn token.value;\n\t}\n\n\tfunction expectSymbol(symbol: Punctuation): void {\n\t\tif (takeSymbol(symbol) === undefined) fail(`expected \"${symbol}\"`);\n\t}\n\n\tfunction parseCall(name: string): Node {\n\t\tconst key = name.toLowerCase();\n\t\tconst definition = Object.hasOwn(FUNCTIONS, key) ? FUNCTIONS[key] : undefined;\n\t\tif (definition === undefined) return fail(`unsupported function ${name}`);\n\t\tconst args: Node[] = [];\n\t\tif (takeSymbol(\")\") === undefined) {\n\t\t\targs.push(parseOr());\n\t\t\twhile (takeSymbol(\",\") !== undefined) args.push(parseOr());\n\t\t\texpectSymbol(\")\");\n\t\t}\n\t\tif (args.length < definition.min || args.length > definition.max) {\n\t\t\tfail(`${name} was given ${args.length} arguments`);\n\t\t}\n\t\treturn { kind: \"call\", name: key, args };\n\t}\n\n\tfunction parsePrimary(): Node {\n\t\tconst token = tokens[position++];\n\t\tif (token === undefined) return fail(\"expected a value\");\n\t\tif (token.kind === \"number\" || token.kind === \"string\") return { kind: \"literal\", value: token.value };\n\t\tif (token.kind === \"name\") {\n\t\t\tconst keyword = token.value.toLowerCase();\n\t\t\tif (keyword === \"true\") return { kind: \"literal\", value: true };\n\t\t\tif (keyword === \"false\") return { kind: \"literal\", value: false };\n\t\t\tif (keyword === \"null\") return { kind: \"literal\", value: null };\n\t\t\treturn takeSymbol(\"(\") === undefined ? { kind: \"context\", name: token.value } : parseCall(token.value);\n\t\t}\n\t\tif (token.value !== \"(\") return fail(`unexpected \"${token.value}\"`);\n\t\tconst inner = parseOr();\n\t\texpectSymbol(\")\");\n\t\treturn inner;\n\t}\n\n\tfunction parsePostfix(): Node {\n\t\tlet node = parsePrimary();\n\t\tfor (;;) {\n\t\t\tif (takeSymbol(\".\") !== undefined) {\n\t\t\t\tconst property = tokens[position++];\n\t\t\t\tif (property?.kind !== \"name\") return fail('expected a property name after \".\"');\n\t\t\t\tnode = { kind: \"member\", object: node, property: property.value };\n\t\t\t} else if (takeSymbol(\"[\") !== undefined) {\n\t\t\t\tconst index = parseOr();\n\t\t\t\texpectSymbol(\"]\");\n\t\t\t\tnode = { kind: \"index\", object: node, index };\n\t\t\t} else return node;\n\t\t}\n\t}\n\n\tfunction parseUnary(): Node {\n\t\treturn takeSymbol(\"!\") === undefined ? parsePostfix() : { kind: \"not\", operand: parseUnary() };\n\t}\n\n\tfunction parseEquality(): Node {\n\t\tlet left = parseUnary();\n\t\tfor (let operator = takeSymbol(\"==\", \"!=\"); operator !== undefined; operator = takeSymbol(\"==\", \"!=\")) {\n\t\t\tleft = { kind: \"equality\", negated: operator === \"!=\", left, right: parseUnary() };\n\t\t}\n\t\treturn left;\n\t}\n\n\tfunction parseAnd(): Node {\n\t\tlet left = parseEquality();\n\t\twhile (takeSymbol(\"&&\") !== undefined) left = { kind: \"logical\", operator: \"&&\", left, right: parseEquality() };\n\t\treturn left;\n\t}\n\n\tfunction parseOr(): Node {\n\t\tlet left = parseAnd();\n\t\twhile (takeSymbol(\"||\") !== undefined) left = { kind: \"logical\", operator: \"||\", left, right: parseAnd() };\n\t\treturn left;\n\t}\n\n\tconst tree = parseOr();\n\tif (position < tokens.length) fail(\"unexpected input after the expression\");\n\treturn tree;\n}\n\nfunction typeOf(value: ExpressionValue): \"null\" | \"array\" | \"boolean\" | \"number\" | \"string\" | \"object\" {\n\tif (value === null) return \"null\";\n\tif (Array.isArray(value)) return \"array\";\n\treturn typeof value as \"boolean\" | \"number\" | \"string\" | \"object\";\n}\n\n/** GitHub's conversion of a value to text: objects and arrays are not rendered. */\nexport function toText(value: ExpressionValue | undefined): string {\n\tswitch (typeOf(value ?? null)) {\n\t\tcase \"null\":\n\t\t\treturn \"\";\n\t\tcase \"array\":\n\t\t\treturn \"Array\";\n\t\tcase \"object\":\n\t\t\treturn \"Object\";\n\t\tdefault:\n\t\t\treturn String(value);\n\t}\n}\n\nfunction toNumber(value: ExpressionValue): number {\n\tswitch (typeOf(value)) {\n\t\tcase \"null\":\n\t\t\treturn 0;\n\t\tcase \"boolean\":\n\t\t\treturn value === true ? 1 : 0;\n\t\tcase \"number\":\n\t\t\treturn value as number;\n\t\tcase \"string\":\n\t\t\treturn (value as string).trim() === \"\" ? 0 : Number(value);\n\t\tdefault:\n\t\t\treturn Number.NaN;\n\t}\n}\n\nfunction isTruthy(value: ExpressionValue): boolean {\n\treturn !(value === null || value === false || value === 0 || value === \"\" || Number.isNaN(value));\n}\n\nfunction looselyEqual(left: ExpressionValue, right: ExpressionValue | undefined): boolean {\n\tconst other = right ?? null;\n\tif (typeof left === \"string\" && typeof other === \"string\") return left.toLowerCase() === other.toLowerCase();\n\tif (typeOf(left) === typeOf(other)) return left === other;\n\tconst leftType = typeOf(left);\n\tconst otherType = typeOf(other);\n\tif (leftType === \"object\" || leftType === \"array\" || otherType === \"object\" || otherType === \"array\") return false;\n\treturn toNumber(left) === toNumber(other);\n}\n\nfunction lookup(object: ExpressionObject, name: string): ExpressionValue | undefined {\n\tif (Object.hasOwn(object, name)) return object[name];\n\tconst lowered = name.toLowerCase();\n\tfor (const [key, value] of Object.entries(object)) if (key.toLowerCase() === lowered) return value;\n\treturn undefined;\n}\n\nfunction readProperty(source: string, value: ExpressionValue, name: string): ExpressionValue {\n\tif (typeOf(value) !== \"object\") return null;\n\tconst object = value as ExpressionObject;\n\tconst found = lookup(object, name);\n\tif (found !== undefined) return found;\n\tconst label = closedObjects.get(object);\n\tif (label !== undefined) throw new ExpressionError(source, `unsupported property ${label}.${name}`);\n\treturn null;\n}\n\nfunction evaluate(node: Node, context: ExpressionContext, source: string): ExpressionValue {\n\tswitch (node.kind) {\n\t\tcase \"literal\":\n\t\t\treturn node.value;\n\t\tcase \"context\": {\n\t\t\tconst root = lookup(context.roots, node.name);\n\t\t\tif (root === undefined) throw new ExpressionError(source, `unsupported context ${node.name}`);\n\t\t\treturn root;\n\t\t}\n\t\tcase \"member\":\n\t\t\treturn readProperty(source, evaluate(node.object, context, source), node.property);\n\t\tcase \"index\": {\n\t\t\tconst object = evaluate(node.object, context, source);\n\t\t\tconst index = evaluate(node.index, context, source);\n\t\t\tif (Array.isArray(object)) return typeof index === \"number\" ? (object[index] ?? null) : null;\n\t\t\treturn typeof index === \"string\" ? readProperty(source, object, index) : null;\n\t\t}\n\t\tcase \"call\": {\n\t\t\tconst args = node.args.map((arg) => evaluate(arg, context, source));\n\t\t\treturn (FUNCTIONS[node.name] as FunctionDefinition).call(args, context, source);\n\t\t}\n\t\tcase \"not\":\n\t\t\treturn !isTruthy(evaluate(node.operand, context, source));\n\t\tcase \"equality\": {\n\t\t\tconst equal = looselyEqual(evaluate(node.left, context, source), evaluate(node.right, context, source));\n\t\t\treturn node.negated ? !equal : equal;\n\t\t}\n\t\tcase \"logical\": {\n\t\t\tconst left = evaluate(node.left, context, source);\n\t\t\tif (isTruthy(left) === (node.operator === \"||\")) return left;\n\t\t\treturn evaluate(node.right, context, source);\n\t\t}\n\t}\n}\n\nfunction usesStatusFunction(node: Node): boolean {\n\tswitch (node.kind) {\n\t\tcase \"call\":\n\t\t\treturn STATUS_FUNCTIONS.has(node.name) || node.args.some(usesStatusFunction);\n\t\tcase \"member\":\n\t\t\treturn usesStatusFunction(node.object);\n\t\tcase \"index\":\n\t\t\treturn usesStatusFunction(node.object) || usesStatusFunction(node.index);\n\t\tcase \"not\":\n\t\t\treturn usesStatusFunction(node.operand);\n\t\tcase \"equality\":\n\t\tcase \"logical\":\n\t\t\treturn usesStatusFunction(node.left) || usesStatusFunction(node.right);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/** The value of one expression, the text between `${{` and `}}`. */\nexport function evaluateExpression(source: string, context: ExpressionContext): ExpressionValue {\n\treturn evaluate(parse(source), context, source);\n}\n\nfunction findClose(text: string, from: number): number {\n\tlet quoted = false;\n\tfor (let position = from; position < text.length; position++) {\n\t\tconst character = text.charAt(position);\n\t\tif (character === \"'\") quoted = !quoted;\n\t\telse if (!quoted && character === \"}\" && text.charAt(position + 1) === \"}\") return position;\n\t}\n\treturn -1;\n}\n\n/** `template` with every `${{ expression }}` replaced by the text of its value. */\nexport function interpolate(template: string, context: ExpressionContext): string {\n\tlet result = \"\";\n\tlet position = 0;\n\tfor (;;) {\n\t\tconst start = template.indexOf(\"${{\", position);\n\t\tif (start === -1) return result + template.slice(position);\n\t\tconst end = findClose(template, start + 3);\n\t\tif (end === -1) throw new ExpressionError(template.slice(start), 'unterminated \"${{\"');\n\t\tresult += template.slice(position, start) + toText(evaluateExpression(template.slice(start + 3, end), context));\n\t\tposition = end + 2;\n\t}\n}\n\n/**\n * Whether an `if` condition holds, with or without the `${{ }}` around it. A condition without a status function also\n * requires that no earlier step failed, as in GitHub.\n */\nexport function evaluateCondition(condition: string, context: ExpressionContext): boolean {\n\tconst trimmed = condition.trim();\n\tconst wrapped = trimmed.startsWith(\"${{\") && findClose(trimmed, 3) === trimmed.length - 2;\n\tconst source = wrapped ? trimmed.slice(3, -2) : trimmed;\n\tconst tree = parse(source);\n\tconst holds = isTruthy(evaluate(tree, context, source));\n\treturn usesStatusFunction(tree) ? holds : !context.failed && holds;\n}\n"]}