@oxygen-agent/cli 1.1014.1997 → 1.1014.2100

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 (242) hide show
  1. package/README.md +1 -1
  2. package/dist/cli-output.js +12 -0
  3. package/dist/column-decision-options.js +1 -1
  4. package/dist/command-families/tables/bundle-format.d.ts +1 -1
  5. package/dist/command-families/tables/bundle-format.js +1 -1
  6. package/dist/command-families/tables/import-columns.js +1 -1
  7. package/dist/command-families/tables/import-upload.d.ts +1 -1
  8. package/dist/command-families/tables/import-values.js +1 -1
  9. package/dist/command-families/tables/imports.d.ts +1 -1
  10. package/dist/command-families/tables/imports.js +1 -1
  11. package/dist/command-families/tables/options.d.ts +1 -0
  12. package/dist/command-families/tables/register-automation.js +3 -1
  13. package/dist/command-families/tables/register-relations.js +1 -1
  14. package/dist/command-families/tables/row-selection.js +1 -1
  15. package/dist/command-support.d.ts +7 -0
  16. package/dist/command-support.js +25 -0
  17. package/dist/commands/billing.js +2 -2
  18. package/dist/commands/columns.js +1 -1
  19. package/dist/commands/enrich-column.js +1 -1
  20. package/dist/commands/mailboxes.js +1 -1
  21. package/dist/commands/observability.js +4 -4
  22. package/dist/commands/table-runs.js +11 -1
  23. package/dist/commands/tags.js +2 -2
  24. package/dist/commands/workflows.js +31 -10
  25. package/dist/deliverability-evidence-commands.js +1 -1
  26. package/dist/http-client.d.ts +1 -1
  27. package/dist/http-client.js +1 -1
  28. package/dist/streamed-file-import.d.ts +1 -1
  29. package/dist/streamed-file-import.js +1 -1
  30. package/node_modules/@oxygen/formula/dist/cross-row-function.d.ts +13 -0
  31. package/node_modules/@oxygen/formula/dist/cross-row-function.js +1 -0
  32. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.d.ts +2 -0
  33. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.js +1 -0
  34. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.d.ts +3 -0
  35. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.js +3 -0
  36. package/node_modules/@oxygen/formula/dist/evaluate.d.ts +12 -1
  37. package/node_modules/@oxygen/formula/dist/evaluate.js +28 -3
  38. package/node_modules/@oxygen/recipe-sdk/dist/index.d.ts +2 -0
  39. package/node_modules/@oxygen/shared/dist/agent-sessions.d.ts +1 -1
  40. package/node_modules/@oxygen/shared/dist/agent-sessions.js +1 -1
  41. package/node_modules/@oxygen/shared/dist/capability-discovery.d.ts +1 -1
  42. package/node_modules/@oxygen/shared/dist/capability-discovery.js +2 -2
  43. package/node_modules/@oxygen/shared/dist/cell-format.js +2 -2
  44. package/node_modules/@oxygen/shared/dist/collab.d.ts +1 -1
  45. package/node_modules/@oxygen/shared/dist/contracts/geo.js +1 -1
  46. package/node_modules/@oxygen/shared/dist/contracts/guided-activation.js +1 -1
  47. package/node_modules/@oxygen/shared/dist/copilot-access.js +1 -1
  48. package/node_modules/@oxygen/shared/dist/dnc-identities.js +1 -1
  49. package/node_modules/@oxygen/shared/dist/error-redaction.d.ts +1 -1
  50. package/node_modules/@oxygen/shared/dist/error-redaction.js +2 -2
  51. package/node_modules/@oxygen/shared/dist/esp-contract.d.ts +133 -0
  52. package/node_modules/@oxygen/shared/dist/esp-contract.js +121 -0
  53. package/node_modules/@oxygen/shared/dist/freemail-domains.d.ts +1 -1
  54. package/node_modules/@oxygen/shared/dist/freemail-domains.js +1 -1
  55. package/node_modules/@oxygen/shared/dist/{geo.js → geo/geo.js} +2 -2
  56. package/node_modules/@oxygen/shared/dist/index.d.ts +17 -16
  57. package/node_modules/@oxygen/shared/dist/index.js +18 -16
  58. package/node_modules/@oxygen/shared/dist/knowledge-bootstrap.js +1 -1
  59. package/node_modules/@oxygen/shared/dist/langfuse.d.ts +5 -1
  60. package/node_modules/@oxygen/shared/dist/langfuse.js +25 -3
  61. package/node_modules/@oxygen/shared/dist/linkedin-connection-identity.js +1 -1
  62. package/node_modules/@oxygen/shared/dist/{email-deliverability-policy.d.ts → mailboxes/email-deliverability-policy.d.ts} +1 -1
  63. package/node_modules/@oxygen/shared/dist/{emailguard-placement-probe.js → mailboxes/emailguard-placement-probe.js} +1 -1
  64. package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.js → mailboxes/sending-domain-rollout.js} +1 -1
  65. package/node_modules/@oxygen/shared/dist/{mailbox-standby-rollout.d.ts → mailboxes/standby-rollout.d.ts} +1 -1
  66. package/node_modules/@oxygen/shared/dist/{mailbox-standby-rollout.js → mailboxes/standby-rollout.js} +2 -2
  67. package/node_modules/@oxygen/shared/dist/{warmup-metrics.js → mailboxes/warmup-metrics.js} +1 -1
  68. package/node_modules/@oxygen/shared/dist/mcp-event-contract.js +1 -1
  69. package/node_modules/@oxygen/shared/dist/object-storage.js +1 -1
  70. package/node_modules/@oxygen/shared/dist/{guided-activation.d.ts → onboarding/guided-activation.d.ts} +1 -1
  71. package/node_modules/@oxygen/shared/dist/{guided-activation.js → onboarding/guided-activation.js} +2 -2
  72. package/node_modules/@oxygen/shared/dist/{guided-onboarding-company-context.d.ts → onboarding/guided-onboarding-company-context.d.ts} +6 -6
  73. package/node_modules/@oxygen/shared/dist/{guided-onboarding-company-context.js → onboarding/guided-onboarding-company-context.js} +2 -2
  74. package/node_modules/@oxygen/shared/dist/{signup-lead-payload.js → onboarding/signup-lead-payload.js} +2 -2
  75. package/node_modules/@oxygen/shared/dist/{signup-lead-webhook.js → onboarding/signup-lead-webhook.js} +2 -2
  76. package/node_modules/@oxygen/shared/dist/onboarding-leads.d.ts +4 -0
  77. package/node_modules/@oxygen/shared/dist/plan-band.d.ts +1 -1
  78. package/node_modules/@oxygen/shared/dist/plan-band.js +1 -1
  79. package/node_modules/@oxygen/shared/dist/plan-limits.d.ts +1 -1
  80. package/node_modules/@oxygen/shared/dist/plan-limits.js +3 -3
  81. package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.d.ts → posts/metrics-core.d.ts} +1 -1
  82. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.d.ts → posts/metrics-linkedin.d.ts} +1 -1
  83. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.js → posts/metrics-linkedin.js} +2 -2
  84. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.d.ts → posts/metrics-series.d.ts} +1 -1
  85. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.js → posts/metrics-series.js} +1 -1
  86. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.d.ts → posts/metrics-x.d.ts} +1 -1
  87. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.js → posts/metrics-x.js} +2 -2
  88. package/node_modules/@oxygen/shared/dist/{social-post-metrics.d.ts → posts/metrics.d.ts} +3 -3
  89. package/node_modules/@oxygen/shared/dist/{social-post-metrics.js → posts/metrics.js} +3 -3
  90. package/node_modules/@oxygen/shared/dist/recipient-provider.d.ts +2 -10
  91. package/node_modules/@oxygen/shared/dist/recipient-provider.js +1 -9
  92. package/node_modules/@oxygen/shared/dist/redis-endpoint-map.d.ts +10 -0
  93. package/node_modules/@oxygen/shared/dist/redis-endpoint-map.js +63 -0
  94. package/node_modules/@oxygen/shared/dist/repricing.js +1 -1
  95. package/node_modules/@oxygen/shared/dist/sending-limits.js +1 -1
  96. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.d.ts +2 -118
  97. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.js +2 -107
  98. package/node_modules/@oxygen/shared/dist/sequences.d.ts +0 -1
  99. package/node_modules/@oxygen/shared/dist/sequences.js +0 -2
  100. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.d.ts → support/native-chat-discovery.d.ts} +1 -1
  101. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.js → support/native-chat-discovery.js} +1 -1
  102. package/node_modules/@oxygen/shared/dist/suppression-entries.js +1 -1
  103. package/node_modules/@oxygen/shared/dist/table-field-types.d.ts +1 -1
  104. package/node_modules/@oxygen/shared/dist/table-field-types.js +2 -2
  105. package/node_modules/@oxygen/shared/dist/table-run-summary.js +1 -1
  106. package/node_modules/@oxygen/shared/dist/{table-capacity.d.ts → tables/capacity.d.ts} +2 -2
  107. package/node_modules/@oxygen/shared/dist/{table-capacity.js → tables/capacity.js} +1 -1
  108. package/node_modules/@oxygen/shared/dist/{column-decision.js → tables/column-decision.js} +1 -1
  109. package/node_modules/@oxygen/shared/dist/{column-output-fields.js → tables/column-output-fields.js} +4 -4
  110. package/node_modules/@oxygen/shared/dist/{enrichment-intents.d.ts → tables/enrichment-intents.d.ts} +1 -1
  111. package/node_modules/@oxygen/shared/dist/{file-import.js → tables/file-import.js} +2 -2
  112. package/node_modules/@oxygen/shared/dist/{tags.d.ts → tags/tags.d.ts} +1 -1
  113. package/node_modules/@oxygen/shared/dist/{tags.js → tags/tags.js} +1 -1
  114. package/node_modules/@oxygen/shared/dist/teammates.js +1 -1
  115. package/node_modules/@oxygen/shared/dist/{ugc-amplification-identity.js → ugc/amplification-identity.js} +1 -1
  116. package/node_modules/@oxygen/shared/dist/version.d.ts +1 -1
  117. package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
  118. package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
  119. package/node_modules/@oxygen/shared/dist/version.js +1 -1
  120. package/node_modules/@oxygen/shared/dist/workspace-event-catalog.js +1 -1
  121. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.d.ts +6 -0
  122. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.js +9 -2
  123. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.d.ts +44 -0
  124. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.js +90 -0
  125. package/node_modules/@oxygen/shared/dist/workspace-placement-view.d.ts +24 -0
  126. package/node_modules/@oxygen/shared/dist/workspace-placement-view.js +5 -4
  127. package/node_modules/@oxygen/shared/dist/workspace-placement.d.ts +4 -0
  128. package/node_modules/@oxygen/shared/dist/workspace-placement.js +8 -2
  129. package/node_modules/@oxygen/shared/package.json +0 -60
  130. package/node_modules/@oxygen/workflows/dist/cron.d.ts +42 -0
  131. package/node_modules/@oxygen/workflows/dist/cron.js +271 -0
  132. package/node_modules/@oxygen/workflows/dist/event-dispatch.d.ts +2 -1
  133. package/node_modules/@oxygen/workflows/dist/graph/condition.d.ts +3 -0
  134. package/node_modules/@oxygen/workflows/dist/graph/condition.js +19 -0
  135. package/node_modules/@oxygen/workflows/dist/graph/expression.d.ts +1 -2
  136. package/node_modules/@oxygen/workflows/dist/graph/expression.js +2 -19
  137. package/node_modules/@oxygen/workflows/dist/graph/types.d.ts +4 -3
  138. package/node_modules/@oxygen/workflows/dist/index.d.ts +8 -985
  139. package/node_modules/@oxygen/workflows/dist/index.js +8 -1221
  140. package/node_modules/@oxygen/workflows/dist/manifest-builders.d.ts +73 -0
  141. package/node_modules/@oxygen/workflows/dist/manifest-builders.js +102 -0
  142. package/node_modules/@oxygen/workflows/dist/manifest-guards.d.ts +16 -0
  143. package/node_modules/@oxygen/workflows/dist/manifest-guards.js +34 -0
  144. package/node_modules/@oxygen/workflows/dist/manifest-hash.d.ts +47 -0
  145. package/node_modules/@oxygen/workflows/dist/manifest-hash.js +102 -0
  146. package/node_modules/@oxygen/workflows/dist/manifest-lint.d.ts +17 -0
  147. package/node_modules/@oxygen/workflows/dist/manifest-lint.js +474 -0
  148. package/node_modules/@oxygen/workflows/dist/manifest-types.d.ts +256 -0
  149. package/node_modules/@oxygen/workflows/dist/manifest-types.js +9 -0
  150. package/node_modules/@oxygen/workflows/dist/pure-function.d.ts +17 -0
  151. package/node_modules/@oxygen/workflows/dist/pure-function.js +130 -0
  152. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.d.ts +1 -17
  153. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.js +1 -93
  154. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.d.ts +16 -0
  155. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.js +92 -0
  156. package/node_modules/@oxygen/workflows/dist/workflow-schemas.d.ts +545 -0
  157. package/node_modules/@oxygen/workflows/dist/workflow-schemas.js +135 -0
  158. package/node_modules/@oxygen/workflows/package.json +4 -0
  159. package/package.json +1 -1
  160. /package/node_modules/@oxygen/shared/dist/{geo.d.ts → geo/geo.d.ts} +0 -0
  161. /package/node_modules/@oxygen/shared/dist/{deliverability-blacklist.d.ts → mailboxes/deliverability-blacklist.d.ts} +0 -0
  162. /package/node_modules/@oxygen/shared/dist/{deliverability-blacklist.js → mailboxes/deliverability-blacklist.js} +0 -0
  163. /package/node_modules/@oxygen/shared/dist/{deliverability-checks.d.ts → mailboxes/deliverability-checks.d.ts} +0 -0
  164. /package/node_modules/@oxygen/shared/dist/{deliverability-checks.js → mailboxes/deliverability-checks.js} +0 -0
  165. /package/node_modules/@oxygen/shared/dist/{deliverability-evidence.d.ts → mailboxes/deliverability-evidence.d.ts} +0 -0
  166. /package/node_modules/@oxygen/shared/dist/{deliverability-evidence.js → mailboxes/deliverability-evidence.js} +0 -0
  167. /package/node_modules/@oxygen/shared/dist/{deliverability-loop.d.ts → mailboxes/deliverability-loop.d.ts} +0 -0
  168. /package/node_modules/@oxygen/shared/dist/{deliverability-loop.js → mailboxes/deliverability-loop.js} +0 -0
  169. /package/node_modules/@oxygen/shared/dist/{deliverability-surface.d.ts → mailboxes/deliverability-surface.d.ts} +0 -0
  170. /package/node_modules/@oxygen/shared/dist/{deliverability-surface.js → mailboxes/deliverability-surface.js} +0 -0
  171. /package/node_modules/@oxygen/shared/dist/{domain-authentication.d.ts → mailboxes/domain-authentication.d.ts} +0 -0
  172. /package/node_modules/@oxygen/shared/dist/{domain-authentication.js → mailboxes/domain-authentication.js} +0 -0
  173. /package/node_modules/@oxygen/shared/dist/{email-deliverability-policy.js → mailboxes/email-deliverability-policy.js} +0 -0
  174. /package/node_modules/@oxygen/shared/dist/{email-health-status.d.ts → mailboxes/email-health-status.d.ts} +0 -0
  175. /package/node_modules/@oxygen/shared/dist/{email-health-status.js → mailboxes/email-health-status.js} +0 -0
  176. /package/node_modules/@oxygen/shared/dist/{email-health-summary.d.ts → mailboxes/email-health-summary.d.ts} +0 -0
  177. /package/node_modules/@oxygen/shared/dist/{email-health-summary.js → mailboxes/email-health-summary.js} +0 -0
  178. /package/node_modules/@oxygen/shared/dist/{emailguard-placement-probe.d.ts → mailboxes/emailguard-placement-probe.d.ts} +0 -0
  179. /package/node_modules/@oxygen/shared/dist/{microsoft-consent-url.d.ts → mailboxes/microsoft-consent-url.d.ts} +0 -0
  180. /package/node_modules/@oxygen/shared/dist/{microsoft-consent-url.js → mailboxes/microsoft-consent-url.js} +0 -0
  181. /package/node_modules/@oxygen/shared/dist/{placement-copy.d.ts → mailboxes/placement-copy.d.ts} +0 -0
  182. /package/node_modules/@oxygen/shared/dist/{placement-copy.js → mailboxes/placement-copy.js} +0 -0
  183. /package/node_modules/@oxygen/shared/dist/{placement-history.d.ts → mailboxes/placement-history.d.ts} +0 -0
  184. /package/node_modules/@oxygen/shared/dist/{placement-history.js → mailboxes/placement-history.js} +0 -0
  185. /package/node_modules/@oxygen/shared/dist/{placement-report.d.ts → mailboxes/placement-report.d.ts} +0 -0
  186. /package/node_modules/@oxygen/shared/dist/{placement-report.js → mailboxes/placement-report.js} +0 -0
  187. /package/node_modules/@oxygen/shared/dist/{received-authentication.d.ts → mailboxes/received-authentication.d.ts} +0 -0
  188. /package/node_modules/@oxygen/shared/dist/{received-authentication.js → mailboxes/received-authentication.js} +0 -0
  189. /package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.d.ts → mailboxes/sending-domain-rollout.d.ts} +0 -0
  190. /package/node_modules/@oxygen/shared/dist/{ses-identity-policy.d.ts → mailboxes/ses-identity-policy.d.ts} +0 -0
  191. /package/node_modules/@oxygen/shared/dist/{ses-identity-policy.js → mailboxes/ses-identity-policy.js} +0 -0
  192. /package/node_modules/@oxygen/shared/dist/{mailbox-standby.d.ts → mailboxes/standby.d.ts} +0 -0
  193. /package/node_modules/@oxygen/shared/dist/{mailbox-standby.js → mailboxes/standby.js} +0 -0
  194. /package/node_modules/@oxygen/shared/dist/{warmup-metrics.d.ts → mailboxes/warmup-metrics.d.ts} +0 -0
  195. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.d.ts → observability/attempt-provenance.d.ts} +0 -0
  196. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.js → observability/attempt-provenance.js} +0 -0
  197. /package/node_modules/@oxygen/shared/dist/{onboarding-first-leads.d.ts → onboarding/first-leads.d.ts} +0 -0
  198. /package/node_modules/@oxygen/shared/dist/{onboarding-first-leads.js → onboarding/first-leads.js} +0 -0
  199. /package/node_modules/@oxygen/shared/dist/{future-signup-events.d.ts → onboarding/future-signup-events.d.ts} +0 -0
  200. /package/node_modules/@oxygen/shared/dist/{future-signup-events.js → onboarding/future-signup-events.js} +0 -0
  201. /package/node_modules/@oxygen/shared/dist/{future-signup-lifecycle-projection.d.ts → onboarding/future-signup-lifecycle-projection.d.ts} +0 -0
  202. /package/node_modules/@oxygen/shared/dist/{future-signup-lifecycle-projection.js → onboarding/future-signup-lifecycle-projection.js} +0 -0
  203. /package/node_modules/@oxygen/shared/dist/{guided-activation.fixture.d.ts → onboarding/guided-activation.fixture.d.ts} +0 -0
  204. /package/node_modules/@oxygen/shared/dist/{guided-activation.fixture.js → onboarding/guided-activation.fixture.js} +0 -0
  205. /package/node_modules/@oxygen/shared/dist/{onboarding-plays.d.ts → onboarding/plays.d.ts} +0 -0
  206. /package/node_modules/@oxygen/shared/dist/{onboarding-plays.js → onboarding/plays.js} +0 -0
  207. /package/node_modules/@oxygen/shared/dist/{onboarding-research.d.ts → onboarding/research.d.ts} +0 -0
  208. /package/node_modules/@oxygen/shared/dist/{onboarding-research.js → onboarding/research.js} +0 -0
  209. /package/node_modules/@oxygen/shared/dist/{signup-lead-deliveries.d.ts → onboarding/signup-lead-deliveries.d.ts} +0 -0
  210. /package/node_modules/@oxygen/shared/dist/{signup-lead-deliveries.js → onboarding/signup-lead-deliveries.js} +0 -0
  211. /package/node_modules/@oxygen/shared/dist/{signup-lead-payload.d.ts → onboarding/signup-lead-payload.d.ts} +0 -0
  212. /package/node_modules/@oxygen/shared/dist/{signup-lead-webhook.d.ts → onboarding/signup-lead-webhook.d.ts} +0 -0
  213. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.d.ts → posts/linkedin-mentions.d.ts} +0 -0
  214. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.js → posts/linkedin-mentions.js} +0 -0
  215. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.d.ts → posts/linkedin-post-keywords.d.ts} +0 -0
  216. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.js → posts/linkedin-post-keywords.js} +0 -0
  217. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.d.ts → posts/linkedin-post-url.d.ts} +0 -0
  218. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.js → posts/linkedin-post-url.js} +0 -0
  219. /package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.js → posts/metrics-core.js} +0 -0
  220. /package/node_modules/@oxygen/shared/dist/{native-chat.d.ts → support/native-chat.d.ts} +0 -0
  221. /package/node_modules/@oxygen/shared/dist/{native-chat.js → support/native-chat.js} +0 -0
  222. /package/node_modules/@oxygen/shared/dist/{plain-support-events.d.ts → support/plain-support-events.d.ts} +0 -0
  223. /package/node_modules/@oxygen/shared/dist/{plain-support-events.js → support/plain-support-events.js} +0 -0
  224. /package/node_modules/@oxygen/shared/dist/{column-decision.d.ts → tables/column-decision.d.ts} +0 -0
  225. /package/node_modules/@oxygen/shared/dist/{column-output-fields.d.ts → tables/column-output-fields.d.ts} +0 -0
  226. /package/node_modules/@oxygen/shared/dist/{column-types.d.ts → tables/column-types.d.ts} +0 -0
  227. /package/node_modules/@oxygen/shared/dist/{column-types.js → tables/column-types.js} +0 -0
  228. /package/node_modules/@oxygen/shared/dist/{company-enrichment-fields.d.ts → tables/company-enrichment-fields.d.ts} +0 -0
  229. /package/node_modules/@oxygen/shared/dist/{company-enrichment-fields.js → tables/company-enrichment-fields.js} +0 -0
  230. /package/node_modules/@oxygen/shared/dist/{enrichment-intents.js → tables/enrichment-intents.js} +0 -0
  231. /package/node_modules/@oxygen/shared/dist/{file-import.d.ts → tables/file-import.d.ts} +0 -0
  232. /package/node_modules/@oxygen/shared/dist/{import-limits.d.ts → tables/import-limits.d.ts} +0 -0
  233. /package/node_modules/@oxygen/shared/dist/{import-limits.js → tables/import-limits.js} +0 -0
  234. /package/node_modules/@oxygen/shared/dist/{table-limits.d.ts → tables/limits.d.ts} +0 -0
  235. /package/node_modules/@oxygen/shared/dist/{table-limits.js → tables/limits.js} +0 -0
  236. /package/node_modules/@oxygen/shared/dist/{linkedin-url.d.ts → tables/linkedin-url.d.ts} +0 -0
  237. /package/node_modules/@oxygen/shared/dist/{linkedin-url.js → tables/linkedin-url.js} +0 -0
  238. /package/node_modules/@oxygen/shared/dist/{select-options.d.ts → tables/select-options.d.ts} +0 -0
  239. /package/node_modules/@oxygen/shared/dist/{select-options.js → tables/select-options.js} +0 -0
  240. /package/node_modules/@oxygen/shared/dist/{ugc-amplification-identity.d.ts → ugc/amplification-identity.d.ts} +0 -0
  241. /package/node_modules/@oxygen/shared/dist/{ugc.d.ts → ugc/ugc.d.ts} +0 -0
  242. /package/node_modules/@oxygen/shared/dist/{ugc.js → ugc/ugc.js} +0 -0
@@ -1,8 +1,3 @@
1
- import { createHash } from "node:crypto";
2
- import * as vm from "node:vm"; // skipcq: JS-C1003
3
- import { isWorkflowGraphManifest, WORKFLOW_CODE_V1_DEFAULT_OUTPUT_BYTES, WORKFLOW_CODE_V1_DEFAULT_TIMEOUT_MS, WORKFLOW_CODE_V1_MAX_OUTPUT_BYTES, WORKFLOW_CODE_V1_MIN_OUTPUT_BYTES, WORKFLOW_CODE_V1_MIN_TIMEOUT_MS, } from "./graph/types.js";
4
- import { lintWorkflowGraphManifest } from "./graph/lint.js";
5
- import { DURABLE_RECIPE_COMPILER_VERSION, isNonEmptyString, isRecord, isValidWorkflowStatus, isWorkflowToolRejected, lintRecipeManifest, parseCronSchedule, validateBranchTarget, validateOptionalMaxCredits, validatePureFunctionSource, validateRecipeBundleSafety, validateTrigger, WORKFLOW_MANIFEST_VERSION, } from "./manifest-validation.js";
6
1
  export * from "./usage-estimate.js";
7
2
  // Pure event-dispatch semantics, shared by the apps/web and apps/worker event
8
3
  // dispatchers so the filter gate, idempotency rule, and delivery verdict cannot
@@ -18,1219 +13,11 @@ export { RECIPE_TIMESTAMP_MILLIS_SOURCE } from "./recipe-timestamp.js";
18
13
  export * from "./refactor-internals/execution-policy.js";
19
14
  // The v1 manifest validators the v2 graph linter reuses; see manifest-validation.ts.
20
15
  export { DURABLE_RECIPE_COMPILER_VERSION, isWorkflowToolRejected, lintRecipeManifest, lintWorkflowCodeSourceSafety, MAX_RECIPE_BUNDLE_BYTES, validateJsonSchemaValue, validateOptionalMaxCredits, validatePureFunctionSource, validateTrigger, WORKFLOW_MANIFEST_VERSION, } from "./manifest-validation.js";
21
- export const WORKFLOW_COMPILER_VERSION = "oxygen-workflows-v1";
22
- export const BLUEPRINT_VERSION = 1;
23
- export const BLUEPRINT_COMPILER_VERSION = "oxygen-blueprints-v1";
24
- export const MAX_BLUEPRINT_BYTES = 4_000_000;
25
- export const DEFAULT_WORKFLOW_CRON_TIMEZONE = "UTC";
26
- // Step ids that must not be used: they collide with JavaScript object internals
27
- // when the runtime assembles ctx.steps, so their outputs would be silently lost.
28
- const RESERVED_STEP_IDS = new Set(["__proto__", "constructor", "prototype"]);
29
- export function defineWorkflow(input) {
30
- return {
31
- __oxygen_workflow_definition: true,
32
- id: input.id,
33
- name: input.name,
34
- ...(input.status ? { status: input.status } : {}),
35
- ...(input.specification ? { specification: input.specification } : {}),
36
- ...(input.trigger ? { trigger: input.trigger } : {}),
37
- ...(input.inputSchema ? { inputSchema: input.inputSchema } : {}),
38
- ...(input.maxCredits != null ? { maxCredits: input.maxCredits } : {}),
39
- steps: input.steps,
40
- };
41
- }
42
- export function apiTrigger(input = {}) {
43
- return {
44
- type: "api",
45
- ...(input.status ? { status: input.status } : {}),
46
- };
47
- }
48
- export function webhookTrigger(input) {
49
- return {
50
- type: "webhook",
51
- trigger_id: input.id,
52
- ...(input.name !== undefined ? { trigger_name: input.name } : {}),
53
- secret_required: input.secret ?? true,
54
- ...(input.idempotencyKeyPath !== undefined
55
- ? { idempotency_key_path: input.idempotencyKeyPath }
56
- : {}),
57
- ...(input.status ? { status: input.status } : {}),
58
- };
59
- }
60
- export function cronTrigger(input) {
61
- return {
62
- type: "cron",
63
- cron: input.cron,
64
- ...(input.timezone !== undefined ? { timezone: input.timezone } : {}),
65
- ...(input.status ? { status: input.status } : {}),
66
- };
67
- }
68
- export function eventTrigger(input) {
69
- return {
70
- type: "event",
71
- source: input.source,
72
- event: input.event,
73
- ...(input.filters ? { filters: input.filters } : {}),
74
- ...(input.idempotencyKeyPath !== undefined
75
- ? { idempotency_key_path: input.idempotencyKeyPath }
76
- : {}),
77
- ...(input.status ? { status: input.status } : {}),
78
- };
79
- }
80
- // Lookahead window for the next cron run. Must exceed the largest gap a *valid*
81
- // schedule can have, or legitimate sparse crons get falsely rejected: the worst
82
- // case is "Feb 29" across a century boundary (e.g. 2096 → 2104, an ~8-year gap,
83
- // since 2100 is not a leap year). The day-skipping scan below keeps even this
84
- // wide window cheap (~one zonedDateParts call per non-matching day).
85
- const MAX_CRON_LOOKAHEAD_DAYS = 366 * 8 + 2;
86
- export function nextCronRunAfter(input) {
87
- const schedule = parseCronSchedule(input.cron);
88
- const timezone = input.timezone?.trim() || DEFAULT_WORKFLOW_CRON_TIMEZONE;
89
- let candidate = roundUpToNextMinute(input.after ?? new Date());
90
- const deadline = candidate.getTime() + MAX_CRON_LOOKAHEAD_DAYS * 24 * 60 * 60 * 1000;
91
- while (candidate.getTime() <= deadline) {
92
- const parts = zonedDateParts(candidate, timezone);
93
- if (matchesCronSchedule(schedule, parts)) {
94
- return candidate;
95
- }
96
- // If the calendar date itself can't match, no minute that day matches —
97
- // jump to the next day instead of scanning all 1440 minutes. This keeps
98
- // sparse schedules (e.g. "0 9 29 2 *") and unsatisfiable ones fast over the
99
- // multi-year window. The jump targets ~00:00 of the next day, so a
100
- // subsequently matching date is scanned from its start (no missed minutes).
101
- if (!matchesCronDate(schedule, parts)) {
102
- const minutesToNextDay = Math.max(1, 24 * 60 - (parts.hour * 60 + parts.minute));
103
- let next = new Date(candidate.getTime() + minutesToNextDay * 60_000);
104
- // minutesToNextDay is a LOCAL-clock count added to a UTC instant. On a
105
- // spring-forward day the local day is < 24h, so the jump overshoots the
106
- // next local midnight and lands at ~01:00 — skipping an early-of-day match
107
- // (e.g. "0 0 …"), which can push the next run a full year out. If the jump
108
- // crossed into the next local day but past midnight, pull it back to that
109
- // midnight. (A fall-back day is > 24h: the jump undershoots and stays on
110
- // the same date, which the next iteration advances — left as-is.)
111
- const landed = zonedDateParts(next, timezone);
112
- const intoNextLocalDay = landed.hour * 60 + landed.minute;
113
- if (landed.dayOfMonth !== parts.dayOfMonth && intoNextLocalDay > 0) {
114
- next = new Date(next.getTime() - intoNextLocalDay * 60_000);
115
- }
116
- candidate = next;
117
- }
118
- else {
119
- candidate = new Date(candidate.getTime() + 60_000);
120
- }
121
- }
122
- throw new Error(`Cron expression has no matching run time in the next ${MAX_CRON_LOOKAHEAD_DAYS} days.`);
123
- }
124
- /**
125
- * The first slot of `cron` strictly after `after` that is also at least
126
- * `minIntervalMinutes` after `lastFireAt`. This is how a plan's minimum cron
127
- * interval (repricing 2026-09, decision L4.2) is enforced at fire time: a
128
- * schedule that fires closer together than the plan allows keeps running, only
129
- * slower, and is never deleted (proposal P-47). With no last fire or a minimum
130
- * of one minute or less it is exactly `nextCronRunAfter`.
131
- */
132
- export function nextCronRunAfterMinInterval(input) {
133
- const minIntervalMs = Math.max(0, input.minIntervalMinutes ?? 0) * 60_000;
134
- let after = input.after;
135
- if (input.lastFireAt && minIntervalMs > 60_000) {
136
- // One millisecond before the earliest allowed instant: nextCronRunAfter
137
- // returns the first whole-minute slot strictly after it, so a slot exactly
138
- // `minIntervalMinutes` after the last fire is allowed.
139
- const earliestAllowed = input.lastFireAt.getTime() + minIntervalMs - 1;
140
- if (earliestAllowed > after.getTime())
141
- after = new Date(earliestAllowed);
142
- }
143
- return nextCronRunAfter({ cron: input.cron, timezone: input.timezone ?? null, after });
144
- }
145
- // How many calendar days minCronGapMinutes scans for two matching days in a
146
- // row: two leap cycles, so a Feb 29 or a day-of-month/weekday coincidence is
147
- // always seen.
148
- const CRON_GAP_DAY_SCAN = 366 * 8 + 2;
149
- // Real-time simulation around a daylight-saving change covers the day it falls
150
- // in plus this many whole days either side (so the fire before a long gap that
151
- // straddles the change is inside the window), and stops after this many fires.
152
- const CRON_GAP_DST_WINDOW_DAYS = 1;
153
- const CRON_GAP_DST_MAX_FIRES = 5_000;
154
- /**
155
- * The smallest gap in minutes between two consecutive fires of `cron`, which is
156
- * what a plan's minimum cron interval is checked against (repricing 2026-09,
157
- * decision L4.2). It is the smallest gap, never the average: `0,5 9 * * *`
158
- * fires once a day on average but twice five minutes apart, so its gap is 5.
159
- *
160
- * Gaps are measured in real time in `timezone`. A daylight-saving change can
161
- * bring two fires closer than their wall-clock times suggest (01:55 and 03:05
162
- * are ten minutes apart on the night the clock skips from 02:00 to 03:00, and
163
- * a repeated hour can fire 01:45 and then 01:00 again), so the fires around
164
- * each change in the coming year are simulated as well.
165
- *
166
- * Returns null when the schedule never fires twice within the scan (for
167
- * example `0 9 29 2 *` fires once every few years and has no meaningful gap
168
- * for a minimum to bind). Throws on an unparseable expression, like
169
- * `nextCronRunAfter`.
170
- */
171
- export function minCronGapMinutes(input) {
172
- const schedule = parseCronSchedule(input.cron);
173
- const timezone = input.timezone?.trim() || DEFAULT_WORKFLOW_CRON_TIMEZONE;
174
- const fireMinutes = [...schedule.hours]
175
- .flatMap((hour) => [...schedule.minutes].map((minute) => hour * 60 + minute))
176
- .sort((a, b) => a - b);
177
- let gap = Number.POSITIVE_INFINITY;
178
- for (let index = 1; index < fireMinutes.length; index += 1) {
179
- gap = Math.min(gap, (fireMinutes[index] ?? 0) - (fireMinutes[index - 1] ?? 0));
180
- }
181
- const dayGap = smallestMatchingDayGap(schedule);
182
- const firstFire = fireMinutes[0];
183
- const lastFire = fireMinutes[fireMinutes.length - 1];
184
- if (dayGap !== null && firstFire !== undefined && lastFire !== undefined) {
185
- gap = Math.min(gap, dayGap * 24 * 60 + firstFire - lastFire);
186
- }
187
- // A one-minute gap is the floor of the cron grammar; daylight saving cannot
188
- // bring two fires closer than that.
189
- if (gap > 1) {
190
- const dstGap = smallestGapAroundDaylightSavingChanges(input.cron, timezone, input.now ?? new Date());
191
- if (dstGap !== null)
192
- gap = Math.min(gap, dstGap);
193
- }
194
- return Number.isFinite(gap) ? gap : null;
195
- }
196
- /** Fewest days between two calendar days the schedule's date fields both match. */
197
- function smallestMatchingDayGap(schedule) {
198
- // Calendar arithmetic only (no timezone): day-of-month, month and weekday
199
- // matching is the same on every clock. A fixed leap-year start covers every
200
- // weekday/day-of-month combination within the scan.
201
- const start = Date.UTC(2024, 0, 1);
202
- let previousMatch = null;
203
- let smallest = null;
204
- for (let day = 0; day < CRON_GAP_DAY_SCAN; day += 1) {
205
- const date = new Date(start + day * 24 * 60 * 60 * 1000);
206
- const matches = matchesCronDate(schedule, {
207
- minute: 0,
208
- hour: 0,
209
- dayOfMonth: date.getUTCDate(),
210
- month: date.getUTCMonth() + 1,
211
- dayOfWeek: date.getUTCDay(),
212
- });
213
- if (!matches)
214
- continue;
215
- if (previousMatch !== null) {
216
- const gap = day - previousMatch;
217
- smallest = smallest === null ? gap : Math.min(smallest, gap);
218
- if (smallest === 1)
219
- return 1;
220
- }
221
- previousMatch = day;
222
- }
223
- return smallest;
224
- }
225
- /**
226
- * The smallest real-time gap between fires in the days around each
227
- * daylight-saving change in the year after `now`; null when the zone has no
228
- * change in that year or no two fires fall in any window.
229
- */
230
- function smallestGapAroundDaylightSavingChanges(cron, timezone, now) {
231
- const dayMs = 24 * 60 * 60 * 1000;
232
- const start = Math.floor(now.getTime() / dayMs) * dayMs;
233
- let smallest = null;
234
- let previousOffset = zonedOffsetMinutes(new Date(start), timezone);
235
- for (let day = 1; day <= 367; day += 1) {
236
- const offset = zonedOffsetMinutes(new Date(start + day * dayMs), timezone);
237
- if (offset === previousOffset)
238
- continue;
239
- previousOffset = offset;
240
- const windowStart = new Date(start + (day - 1 - CRON_GAP_DST_WINDOW_DAYS) * dayMs);
241
- const windowEnd = start + (day + CRON_GAP_DST_WINDOW_DAYS) * dayMs;
242
- let fire = nextCronRunAfter({ cron, timezone, after: windowStart });
243
- for (let fires = 0; fires < CRON_GAP_DST_MAX_FIRES && fire.getTime() <= windowEnd; fires += 1) {
244
- const next = nextCronRunAfter({ cron, timezone, after: fire });
245
- if (next.getTime() > windowEnd)
246
- break;
247
- const gap = Math.round((next.getTime() - fire.getTime()) / 60_000);
248
- smallest = smallest === null ? gap : Math.min(smallest, gap);
249
- fire = next;
250
- }
251
- }
252
- return smallest;
253
- }
254
- /** Minutes the zone's wall clock is ahead of UTC at `date`. */
255
- function zonedOffsetMinutes(date, timezone) {
256
- const formatter = getZonedFormatter(timezone);
257
- const parts = new Map();
258
- for (const part of formatter.formatToParts(date)) {
259
- if (part.type !== "literal")
260
- parts.set(part.type, part.value);
261
- }
262
- const wallClock = Date.UTC(Number(parts.get("year")), Number(parts.get("month")) - 1, Number(parts.get("day")), Number(parts.get("hour")), Number(parts.get("minute")));
263
- const instant = Math.floor(date.getTime() / 60_000) * 60_000;
264
- return Math.round((wallClock - instant) / 60_000);
265
- }
266
- export function transformStep(input) {
267
- return {
268
- __oxygen_workflow_step: true,
269
- kind: "transform",
270
- id: input.id,
271
- ...(input.description ? { description: input.description } : {}),
272
- run: input.run,
273
- };
274
- }
275
- export function toolStep(input) {
276
- return {
277
- __oxygen_workflow_step: true,
278
- kind: "tool",
279
- id: input.id,
280
- ...(input.description ? { description: input.description } : {}),
281
- tool: input.tool,
282
- ...(input.effect ? { effect: input.effect } : {}),
283
- ...(input.mode ? { mode: input.mode } : {}),
284
- ...(input.connectionId !== undefined ? { connectionId: input.connectionId } : {}),
285
- ...(input.maxCredits != null ? { maxCredits: input.maxCredits } : {}),
286
- payload: input.payload,
287
- };
288
- }
289
- /**
290
- * Conditional step. `condition` is evaluated; control then flows by mode:
291
- *
292
- * - then only (no `else`, no `join`) — GUARD: truthy continues to `then` (steps
293
- * between the branch and `then` are skipped); falsy skips straight to the end
294
- * of the workflow (no step after the branch runs) and the run completes.
295
- * - then + else (no `join`) — skip-until-target jump to `then`/`else`; from the
296
- * chosen target, the remaining steps run sequentially through the end.
297
- * - then + else + join — real if/else: the non-chosen arm is skipped and `join`
298
- * is the convergence point where shared downstream work resumes.
299
- *
300
- * All targets must be ids of later steps (branches are forward-only).
301
- */
302
- export function branchStep(input) {
303
- return {
304
- __oxygen_workflow_step: true,
305
- kind: "branch",
306
- id: input.id,
307
- ...(input.description ? { description: input.description } : {}),
308
- condition: input.condition,
309
- then: input.then,
310
- ...(input.else !== undefined ? { else: input.else } : {}),
311
- ...(input.join !== undefined ? { join: input.join } : {}),
312
- };
313
- }
314
- export function isWorkflowDefinition(value) {
315
- return isRecord(value) && value.__oxygen_workflow_definition === true;
316
- }
317
- export function isWorkflowManifest(value) {
318
- return isRecord(value)
319
- && value.manifest_version === WORKFLOW_MANIFEST_VERSION
320
- && Array.isArray(value.steps);
321
- }
322
- export function isRecipeManifest(value) {
323
- return isRecord(value)
324
- && value.manifest_version === WORKFLOW_MANIFEST_VERSION
325
- && value.compiler_version === DURABLE_RECIPE_COMPILER_VERSION;
326
- }
327
- /**
328
- * Every manifest shape the platform can store and run: v1 hosted steps, durable
329
- * recipes, and oxygen-workflows-v2 graphs. This is the gate `workflows apply`
330
- * and the CLI loader route through, so a shape listed here must already have a
331
- * linter and a worker execution path — accepting a manifest we cannot run would
332
- * cut a revision that fails at run time instead of at authoring time.
333
- */
334
- export function isAnyWorkflowManifest(value) {
335
- return isWorkflowManifest(value) || isRecipeManifest(value) || isWorkflowGraphManifest(value);
336
- }
337
- export function compileWorkflowDefinition(// skipcq: JS-R1005 -- compiler validates workflow metadata, trigger, steps, branch targets, and defaults together.
338
- definition, options = {}) {
339
- const sourceHash = options.sourceHash
340
- ?? hashWorkflowSource(options.source ?? JSON.stringify(definition, workflowJsonReplacer));
341
- const manifest = {
342
- manifest_version: WORKFLOW_MANIFEST_VERSION,
343
- workflow: {
344
- id: definition.id,
345
- name: definition.name,
346
- ...(definition.status ? { status: definition.status } : {}),
347
- },
348
- ...(definition.specification ? { specification: definition.specification } : {}),
349
- ...(definition.trigger ? { trigger: definition.trigger } : {}),
350
- ...(definition.inputSchema ? { input_schema: definition.inputSchema } : {}),
351
- ...(definition.maxCredits != null ? { max_credits: definition.maxCredits } : {}),
352
- steps: definition.steps.map((step) => {
353
- if (step.kind === "transform") {
354
- return {
355
- kind: "transform",
356
- id: step.id,
357
- ...(step.description ? { description: step.description } : {}),
358
- run_source: serializeWorkflowFunction(step.run, `steps.${step.id}.run`),
359
- };
360
- }
361
- if (step.kind === "branch") {
362
- return {
363
- kind: "branch",
364
- id: step.id,
365
- ...(step.description ? { description: step.description } : {}),
366
- condition_source: serializeWorkflowFunction(step.condition, `steps.${step.id}.condition`),
367
- then_id: step.then,
368
- ...(step.else !== undefined ? { else_id: step.else } : {}),
369
- ...(step.join !== undefined ? { join_id: step.join } : {}),
370
- };
371
- }
372
- return {
373
- kind: "tool",
374
- id: step.id,
375
- ...(step.description ? { description: step.description } : {}),
376
- tool: step.tool,
377
- effect: step.effect ?? "external_read",
378
- ...(step.mode ? { mode: step.mode } : {}),
379
- ...(step.connectionId !== undefined ? { connection_id: step.connectionId } : {}),
380
- ...(step.maxCredits != null ? { max_credits: step.maxCredits } : {}),
381
- payload_source: serializeWorkflowFunction(step.payload, `steps.${step.id}.payload`),
382
- };
383
- }),
384
- source_hash: sourceHash,
385
- compiler_version: WORKFLOW_COMPILER_VERSION,
386
- created_at: (options.createdAt ?? new Date()).toISOString(),
387
- };
388
- assertWorkflowManifest(manifest);
389
- return manifest;
390
- }
391
- export function buildRecipeManifest(input) {
392
- const bundle = input.bundle;
393
- if (typeof bundle !== "string" || bundle.length === 0) {
394
- throw new Error("Recipe bundle source is required.");
395
- }
396
- const sourceHash = input.sourceHash ?? hashRecipeSource({
397
- bundle,
398
- ...(input.configurationSchema !== undefined
399
- ? { configurationSchema: input.configurationSchema }
400
- : {}),
401
- ...(input.configuration !== undefined ? { configuration: input.configuration } : {}),
402
- });
403
- const manifest = {
404
- manifest_version: WORKFLOW_MANIFEST_VERSION,
405
- workflow: {
406
- id: input.workflowId,
407
- name: input.workflowName,
408
- ...(input.status ? { status: input.status } : {}),
409
- },
410
- ...(input.trigger ? { trigger: input.trigger } : {}),
411
- ...(input.inputSchema ? { input_schema: input.inputSchema } : {}),
412
- ...(input.configurationSchema ? { configuration_schema: input.configurationSchema } : {}),
413
- ...(input.configuration ? { configuration: input.configuration } : {}),
414
- runtime: "durable",
415
- bundle,
416
- bundle_format: "esm",
417
- tools_used: Array.from(new Set((input.toolsUsed ?? []).filter(Boolean))).sort(),
418
- ...(input.visualPlan ? { visual_plan: input.visualPlan } : {}),
419
- ...(input.maxCredits != null ? { max_credits: input.maxCredits } : {}),
420
- source_hash: sourceHash,
421
- compiler_version: DURABLE_RECIPE_COMPILER_VERSION,
422
- created_at: (input.createdAt ?? new Date()).toISOString(),
423
- };
424
- return manifest;
425
- }
426
- /** Canonical executable identity shared by recipe compilers and repair paths. */
427
- export function hashRecipeSource(input) {
428
- // Preserve the historical bundle-only identity for recipes that have no
429
- // editable configuration. Configuration-bearing revisions include schema +
430
- // values because either can change the behavior of the same bundle source.
431
- if (input.configurationSchema === undefined && input.configuration === undefined) {
432
- return hashWorkflowSource(input.bundle);
433
- }
434
- return hashWorkflowSource(JSON.stringify({
435
- bundle: input.bundle,
436
- configuration_schema: input.configurationSchema ?? null,
437
- configuration: input.configuration ?? null,
438
- }, workflowJsonReplacer));
439
- }
440
- export function lintWorkflowManifest(// skipcq: JS-R1005
441
- value, options = {}) {
442
- if (isWorkflowGraphManifest(value)) {
443
- return lintWorkflowGraphManifest(value, options);
444
- }
445
- if (isRecord(value)
446
- && typeof value.compiler_version === "string"
447
- && value.compiler_version.startsWith("oxygen-recipes-")) {
448
- return lintRecipeManifest(value, options);
449
- }
450
- const issues = [];
451
- const add = (path, code, message) => issues.push({ path, code, message });
452
- if (!isRecord(value)) {
453
- add("$", "invalid_manifest", "Workflow manifest must be an object.");
454
- return { ok: false, issues };
455
- }
456
- if (value.manifest_version !== WORKFLOW_MANIFEST_VERSION) {
457
- add("$.manifest_version", "invalid_manifest_version", "Workflow manifest version must be 1.");
458
- }
459
- const workflow = value.workflow;
460
- if (!isRecord(workflow)) {
461
- add("$.workflow", "missing_workflow", "Workflow metadata is required.");
462
- }
463
- else {
464
- if (!isNonEmptyString(workflow.id))
465
- add("$.workflow.id", "invalid_workflow_id", "Workflow id is required.");
466
- if (!isNonEmptyString(workflow.name))
467
- add("$.workflow.name", "invalid_workflow_name", "Workflow name is required.");
468
- if (workflow.status !== undefined && !isValidWorkflowStatus(workflow.status)) {
469
- add("$.workflow.status", "invalid_workflow_status", "Workflow status must be active or disabled.");
470
- }
471
- }
472
- if (value.trigger !== undefined)
473
- validateTrigger(value.trigger, "$.trigger", add);
474
- validateOptionalMaxCredits(value.max_credits, "$.max_credits", add);
475
- if (!Array.isArray(value.steps) || value.steps.length === 0) {
476
- add("$.steps", "missing_steps", "At least one workflow step is required.");
477
- }
478
- else {
479
- // Pre-pass: collect id → declared-index so branch targets can be
480
- // validated for existence + forward-only direction in the main pass.
481
- const idToIndex = new Map();
482
- value.steps.forEach((step, index) => {
483
- if (isRecord(step) && isNonEmptyString(step.id)) {
484
- if (!idToIndex.has(step.id))
485
- idToIndex.set(step.id, index);
486
- }
487
- });
488
- const ids = new Set();
489
- value.steps.forEach((step, index) => {
490
- const path = `$.steps.${index}`;
491
- if (!isRecord(step)) {
492
- add(path, "invalid_step", "Workflow step must be an object.");
493
- return;
494
- }
495
- if (!isNonEmptyString(step.id)) {
496
- add(`${path}.id`, "invalid_step_id", "Step id is required.");
497
- }
498
- else if (RESERVED_STEP_IDS.has(step.id)) {
499
- // Step ids become keys on the ctx.steps object the runtime assembles.
500
- // "__proto__" / "constructor" / "prototype" collide with JavaScript
501
- // object internals: assigning ctx.steps["__proto__"] = output hits the
502
- // prototype setter, so the output is silently dropped from step outputs
503
- // and unreadable downstream while the run still reports success. Reject
504
- // at authoring time instead of letting that data loss happen at runtime.
505
- add(`${path}.id`, "reserved_step_id", `Step id '${step.id}' is reserved (it collides with a JavaScript object key and would be dropped from step outputs). Choose another id.`);
506
- }
507
- else if (ids.has(step.id)) {
508
- add(`${path}.id`, "duplicate_step_id", `Step id '${step.id}' is duplicated.`);
509
- }
510
- else {
511
- ids.add(step.id);
512
- }
513
- if (step.kind === "transform") {
514
- if (!isNonEmptyString(step.run_source)) {
515
- add(`${path}.run_source`, "missing_step_code", "Transform step run_source is required.");
516
- }
517
- else {
518
- validatePureFunctionSource(step.run_source, `${path}.run_source`, add);
519
- }
520
- return;
521
- }
522
- if (step.kind === "tool") {
523
- if (!isNonEmptyString(step.tool)) {
524
- add(`${path}.tool`, "missing_tool", "Tool step tool id is required.");
525
- }
526
- else if (isWorkflowToolRejected(step.tool)) {
527
- add(`${path}.tool`, "unsupported_workflow_tool", `Tool '${step.tool}' is not allowed in workflow automations.`);
528
- }
529
- else if (options.isToolAllowed && !options.isToolAllowed(step.tool)) {
530
- add(`${path}.tool`, "tool_not_allowed", `Tool '${step.tool}' is not available for workflow automations.`);
531
- }
532
- if (!isNonEmptyString(step.payload_source)) {
533
- add(`${path}.payload_source`, "missing_step_code", "Tool step payload_source is required.");
534
- }
535
- else {
536
- validatePureFunctionSource(step.payload_source, `${path}.payload_source`, add);
537
- }
538
- if (step.effect !== "none"
539
- && step.effect !== "external_read"
540
- && step.effect !== "external_write") {
541
- add(`${path}.effect`, "invalid_step_effect", "Step effect is invalid.");
542
- }
543
- else if (isNonEmptyString(step.tool)) {
544
- // No resolver: skip the canonical cross-check rather than refuse.
545
- //
546
- // This function is reached by compileWorkflowDefinition, which the CLI
547
- // calls locally — and the CLI deliberately cannot classify effects,
548
- // because that is exactly the dependency removed from this package.
549
- // Refusing here would make `oxygen workflows` unable to compile any
550
- // manifest containing a tool step.
551
- //
552
- // Skipping is safe because this check is a CONVENIENCE, not the gate:
553
- // apply and the worker runtime both resolve the effect canonically and
554
- // both REFUSE what they cannot classify. The divergence v1.513.2 fixed
555
- // was lint disagreeing with apply, and that is addressed by the server
556
- // lint path always injecting resolveWorkflowToolEffect (see
557
- // apps/web/src/lib/workflows.ts lintHostedWorkflowManifest) — not by a
558
- // default inside this package.
559
- const resolveEffect = options.resolveToolEffect;
560
- if (resolveEffect) {
561
- const canonicalEffect = resolveEffect(step.tool);
562
- if (canonicalEffect !== null && step.effect !== canonicalEffect) {
563
- add(`${path}.effect`, "tool_effect_mismatch", `Tool '${step.tool}' has canonical effect '${canonicalEffect}', not '${String(step.effect)}'. Set step.effect to '${canonicalEffect}'.`);
564
- }
565
- }
566
- }
567
- if (step.mode !== undefined
568
- && step.mode !== "dry_run"
569
- && step.mode !== "live"
570
- && step.mode !== "smoke_test") {
571
- add(`${path}.mode`, "invalid_step_mode", "Step mode is invalid.");
572
- }
573
- if (step.connection_id !== undefined && !isNonEmptyString(step.connection_id)) {
574
- add(`${path}.connection_id`, "invalid_connection_id", "Tool step connection_id must be a non-empty string.");
575
- }
576
- validateOptionalMaxCredits(step.max_credits, `${path}.max_credits`, add);
577
- return;
578
- }
579
- if (step.kind === "branch") {
580
- if (!isNonEmptyString(step.condition_source)) {
581
- add(`${path}.condition_source`, "missing_step_code", "Branch step condition_source is required.");
582
- }
583
- else {
584
- validatePureFunctionSource(step.condition_source, `${path}.condition_source`, add);
585
- }
586
- validateBranchTarget(step.then_id, `${path}.then_id`, "then_id", index, idToIndex, add);
587
- if (step.else_id !== undefined) {
588
- validateBranchTarget(step.else_id, `${path}.else_id`, "else_id", index, idToIndex, add);
589
- }
590
- if (step.join_id !== undefined) {
591
- validateBranchTarget(step.join_id, `${path}.join_id`, "join_id", index, idToIndex, add);
592
- }
593
- return;
594
- }
595
- add(`${path}.kind`, "invalid_step_kind", "Step kind must be transform, tool, or branch.");
596
- });
597
- }
598
- if (!isNonEmptyString(value.source_hash)) {
599
- add("$.source_hash", "missing_source_hash", "Manifest source_hash is required.");
600
- }
601
- if (!isNonEmptyString(value.compiler_version)) {
602
- add("$.compiler_version", "missing_compiler_version", "Manifest compiler_version is required.");
603
- }
604
- return { ok: issues.length === 0, issues };
605
- }
606
- export function assertRecipeManifest(value, options = {}) {
607
- const result = lintRecipeManifest(value, options);
608
- if (result.ok)
609
- return;
610
- const first = result.issues[0];
611
- throw new Error(first ? `${first.code}: ${first.message}` : "Invalid recipe manifest.");
612
- }
613
- export function assertWorkflowManifest(value, options = {}) {
614
- const result = lintWorkflowManifest(value, options);
615
- if (result.ok)
616
- return;
617
- const first = result.issues[0];
618
- throw new Error(first ? `${first.code}: ${first.message}` : "Invalid workflow manifest.");
619
- }
620
- export function isBlueprint(value) {
621
- return isRecord(value)
622
- && value.blueprint_version === BLUEPRINT_VERSION
623
- && value.compiler_version === BLUEPRINT_COMPILER_VERSION;
624
- }
625
- const BLUEPRINT_REF_PATTERN = /^[a-z][a-z0-9_-]{0,79}$/;
626
- const BLUEPRINT_PROMPT_SLUG_PATTERN = /^[a-z][a-z0-9_-]{0,119}$/;
627
- export function lintBlueprint(// skipcq: JS-R1005
628
- value, options = {}) {
629
- const issues = [];
630
- const add = (path, code, message) => issues.push({ path, code, message });
631
- if (!isRecord(value)) {
632
- add("$", "invalid_blueprint", "Blueprint must be an object.");
633
- return { ok: false, issues };
634
- }
635
- if (value.blueprint_version !== BLUEPRINT_VERSION) {
636
- add("$.blueprint_version", "invalid_blueprint_version", "Blueprint version must be 1.");
637
- }
638
- if (value.compiler_version !== BLUEPRINT_COMPILER_VERSION) {
639
- add("$.compiler_version", "invalid_compiler_version", `Blueprint compiler_version must be '${BLUEPRINT_COMPILER_VERSION}'.`);
640
- }
641
- if (!isNonEmptyString(value.id))
642
- add("$.id", "invalid_blueprint_id", "Blueprint id is required.");
643
- if (!isNonEmptyString(value.name))
644
- add("$.name", "invalid_blueprint_name", "Blueprint name is required.");
645
- if (typeof value.summary !== "string")
646
- add("$.summary", "invalid_summary", "Blueprint summary must be a string.");
647
- if (!Array.isArray(value.tags)) {
648
- add("$.tags", "invalid_tags", "Blueprint tags must be an array of strings.");
649
- }
650
- if (!isNonEmptyString(value.exported_at)) {
651
- add("$.exported_at", "invalid_exported_at", "Blueprint exported_at must be an ISO timestamp.");
652
- }
653
- if (!isNonEmptyString(value.source_hash)) {
654
- add("$.source_hash", "missing_source_hash", "Blueprint source_hash is required.");
655
- }
656
- const tableRefs = new Set();
657
- if (!Array.isArray(value.tables)) {
658
- add("$.tables", "invalid_tables", "Blueprint tables must be an array.");
659
- }
660
- else {
661
- value.tables.forEach((table, index) => {
662
- const path = `$.tables.${index}`;
663
- if (!isRecord(table)) {
664
- add(path, "invalid_table", "Blueprint table must be an object.");
665
- return;
666
- }
667
- if (!isNonEmptyString(table.ref) || !BLUEPRINT_REF_PATTERN.test(table.ref)) {
668
- add(`${path}.ref`, "invalid_table_ref", "Blueprint table ref must be lowercase kebab/snake_case (a-z0-9_-).");
669
- }
670
- else {
671
- if (tableRefs.has(table.ref)) {
672
- add(`${path}.ref`, "duplicate_table_ref", `Blueprint table ref '${table.ref}' is duplicated.`);
673
- }
674
- tableRefs.add(table.ref);
675
- }
676
- if (!isNonEmptyString(table.name))
677
- add(`${path}.name`, "invalid_table_name", "Blueprint table name is required.");
678
- if (!Array.isArray(table.columns) || table.columns.length === 0) {
679
- add(`${path}.columns`, "invalid_table_columns", "Blueprint table must declare at least one column.");
680
- }
681
- else {
682
- table.columns.forEach((column, columnIndex) => {
683
- const columnPath = `${path}.columns.${columnIndex}`;
684
- if (!isRecord(column)) {
685
- add(columnPath, "invalid_column", "Blueprint column must be an object.");
686
- return;
687
- }
688
- if (!isNonEmptyString(column.label)) {
689
- add(`${columnPath}.label`, "invalid_column_label", "Blueprint column label is required.");
690
- }
691
- });
692
- }
693
- });
694
- }
695
- if (value.column_grafts !== undefined) {
696
- if (!Array.isArray(value.column_grafts)) {
697
- add("$.column_grafts", "invalid_column_grafts", "Blueprint column_grafts must be an array.");
698
- }
699
- else {
700
- value.column_grafts.forEach((graft, index) => {
701
- const path = `$.column_grafts.${index}`;
702
- if (!isRecord(graft)) {
703
- add(path, "invalid_column_graft", "Column graft must be an object.");
704
- return;
705
- }
706
- if (!isNonEmptyString(graft.table_ref) || !tableRefs.has(graft.table_ref)) {
707
- add(`${path}.table_ref`, "invalid_graft_ref", "Column graft table_ref must match a declared blueprint table ref.");
708
- }
709
- if (!isRecord(graft.column) || !isNonEmptyString(graft.column.label)) {
710
- add(`${path}.column`, "invalid_graft_column", "Column graft column must be an object with a label.");
711
- }
712
- });
713
- }
714
- }
715
- const promptSlugs = new Set();
716
- if (!Array.isArray(value.prompt_templates)) {
717
- add("$.prompt_templates", "invalid_prompt_templates", "Blueprint prompt_templates must be an array.");
718
- }
719
- else {
720
- value.prompt_templates.forEach((prompt, index) => {
721
- const path = `$.prompt_templates.${index}`;
722
- if (!isRecord(prompt)) {
723
- add(path, "invalid_prompt", "Blueprint prompt must be an object.");
724
- return;
725
- }
726
- if (!isNonEmptyString(prompt.slug) || !BLUEPRINT_PROMPT_SLUG_PATTERN.test(prompt.slug)) {
727
- add(`${path}.slug`, "invalid_prompt_slug", "Prompt slug must be lowercase kebab/snake_case (a-z0-9_-).");
728
- }
729
- else {
730
- if (promptSlugs.has(prompt.slug)) {
731
- add(`${path}.slug`, "duplicate_prompt_slug", `Prompt slug '${prompt.slug}' is duplicated.`);
732
- }
733
- promptSlugs.add(prompt.slug);
734
- }
735
- if (!isNonEmptyString(prompt.name))
736
- add(`${path}.name`, "invalid_prompt_name", "Prompt name is required.");
737
- if (!isNonEmptyString(prompt.body))
738
- add(`${path}.body`, "invalid_prompt_body", "Prompt body is required.");
739
- if (prompt.kind !== "ai_column_system" && prompt.kind !== "scoring_rubric" && prompt.kind !== "other") {
740
- add(`${path}.kind`, "invalid_prompt_kind", "Prompt kind must be ai_column_system, scoring_rubric, or other.");
741
- }
742
- });
743
- }
744
- if (!Array.isArray(value.workflows)) {
745
- add("$.workflows", "invalid_workflows", "Blueprint workflows must be an array.");
746
- }
747
- else if (value.workflows.length === 0) {
748
- add("$.workflows", "missing_workflows", "Blueprint must include at least one workflow.");
749
- }
750
- else {
751
- value.workflows.forEach((entry, index) => {
752
- const path = `$.workflows.${index}`;
753
- if (!isRecord(entry)) {
754
- add(path, "invalid_workflow_entry", "Workflow entry must be an object.");
755
- return;
756
- }
757
- const manifest = entry.manifest;
758
- const manifestResult = lintWorkflowManifest(manifest, options);
759
- if (!manifestResult.ok) {
760
- manifestResult.issues.forEach((issue) => {
761
- add(`${path}.manifest${issue.path.replace(/^\$/, "")}`, issue.code, issue.message);
762
- });
763
- }
764
- if (entry.table_refs !== undefined && !isRecord(entry.table_refs)) {
765
- add(`${path}.table_refs`, "invalid_workflow_table_refs", "Workflow table_refs must be an object map.");
766
- }
767
- else if (isRecord(entry.table_refs)) {
768
- for (const refName of Object.keys(entry.table_refs)) {
769
- if (!tableRefs.has(refName)) {
770
- add(`${path}.table_refs.${refName}`, "unknown_workflow_table_ref", `Workflow references table ref '${refName}' which is not declared on this blueprint.`);
771
- }
772
- }
773
- }
774
- if (entry.prompt_template_slugs !== undefined) {
775
- if (!Array.isArray(entry.prompt_template_slugs)) {
776
- add(`${path}.prompt_template_slugs`, "invalid_prompt_slug_list", "Workflow prompt_template_slugs must be an array of strings.");
777
- }
778
- else {
779
- entry.prompt_template_slugs.forEach((slug, slugIndex) => {
780
- if (!isNonEmptyString(slug)) {
781
- add(`${path}.prompt_template_slugs.${slugIndex}`, "invalid_prompt_slug", "Workflow prompt slug references must be non-empty strings.");
782
- }
783
- else if (!promptSlugs.has(slug)) {
784
- add(`${path}.prompt_template_slugs.${slugIndex}`, "unknown_prompt_slug", `Workflow references prompt slug '${slug}' which is not declared on this blueprint.`);
785
- }
786
- });
787
- }
788
- }
789
- });
790
- }
791
- const requires = value.requires;
792
- if (!isRecord(requires)) {
793
- add("$.requires", "invalid_requires", "Blueprint requires must be an object.");
794
- }
795
- else {
796
- if (requires.integrations !== undefined) {
797
- if (!Array.isArray(requires.integrations)) {
798
- add("$.requires.integrations", "invalid_requires_integrations", "Blueprint requires.integrations must be an array.");
799
- }
800
- else {
801
- requires.integrations.forEach((entry, index) => {
802
- const path = `$.requires.integrations.${index}`;
803
- if (!isRecord(entry)) {
804
- add(path, "invalid_integration", "Integration requirement must be an object.");
805
- return;
806
- }
807
- if (!isNonEmptyString(entry.kind)) {
808
- add(`${path}.kind`, "invalid_integration_kind", "Integration requirement kind is required (e.g. 'instantly', 'apollo').");
809
- }
810
- });
811
- }
812
- }
813
- if (requires.context_keys !== undefined && !Array.isArray(requires.context_keys)) {
814
- add("$.requires.context_keys", "invalid_context_keys", "Blueprint requires.context_keys must be an array of strings.");
815
- }
816
- }
817
- return { ok: issues.length === 0, issues };
818
- }
819
- export function assertBlueprint(value, options = {}) {
820
- const result = lintBlueprint(value, options);
821
- if (result.ok)
822
- return;
823
- const first = result.issues[0];
824
- throw new Error(first ? `${first.code}: ${first.message}` : "Invalid blueprint.");
825
- }
826
- export function buildBlueprint(input) {
827
- const draft = {
828
- blueprint_version: BLUEPRINT_VERSION,
829
- id: input.id,
830
- name: input.name,
831
- summary: input.summary ?? "",
832
- tags: Array.isArray(input.tags) ? Array.from(new Set(input.tags.filter(Boolean))) : [],
833
- ...(input.audience ? { audience: input.audience } : {}),
834
- requires: input.requires ?? {},
835
- ...(input.inputSchema ? { input_schema: input.inputSchema } : {}),
836
- tables: input.tables,
837
- ...(input.columnGrafts && input.columnGrafts.length > 0 ? { column_grafts: input.columnGrafts } : {}),
838
- prompt_templates: input.promptTemplates ?? [],
839
- workflows: input.workflows,
840
- exported_at: (input.exportedAt ?? new Date()).toISOString(),
841
- ...(input.exportedFrom ? { exported_from: input.exportedFrom } : {}),
842
- compiler_version: BLUEPRINT_COMPILER_VERSION,
843
- };
844
- const sourceHash = input.sourceHash
845
- ?? hashWorkflowSource(JSON.stringify(draft, workflowJsonReplacer));
846
- return { ...draft, source_hash: sourceHash };
847
- }
848
- export function assertRecipeBundleSafe(bundle) {
849
- const issues = lintRecipeBundleSafety(bundle, "$.bundle");
850
- const first = issues[0];
851
- if (first)
852
- throw new Error(`${first.code}: ${first.message}`);
853
- }
854
- export function lintRecipeBundleSafety(bundle, path = "$.bundle") {
855
- const issues = [];
856
- validateRecipeBundleSafety(bundle, path, (issuePath, code, message) => {
857
- issues.push({ path: issuePath, code, message });
858
- });
859
- return issues;
860
- }
861
- /**
862
- * The ceiling of the legacy synchronous `node:vm` path below. It stays at 10 s
863
- * (and its callers pass 1 s) when the typed Code node rose to 30 s (repricing
864
- * 2026-09, decision L4.3; proposal P-49): this path runs on the worker's own
865
- * event loop, so a long synchronous script would stall every other job and its
866
- * queue lock renewal. The typed Code node runs in a separate microVM instead.
867
- */
868
- export const PURE_WORKFLOW_FUNCTION_MAX_TIMEOUT_MS = 10_000;
869
- export async function runPureWorkflowFunction(input) {
870
- const timeoutMs = Math.max(WORKFLOW_CODE_V1_MIN_TIMEOUT_MS, Math.min(input.timeoutMs ?? WORKFLOW_CODE_V1_DEFAULT_TIMEOUT_MS, PURE_WORKFLOW_FUNCTION_MAX_TIMEOUT_MS));
871
- const maxOutputBytes = Math.max(WORKFLOW_CODE_V1_MIN_OUTPUT_BYTES, Math.min(input.maxOutputBytes ?? WORKFLOW_CODE_V1_DEFAULT_OUTPUT_BYTES, WORKFLOW_CODE_V1_MAX_OUTPUT_BYTES));
872
- const issues = [];
873
- validatePureFunctionSource(input.source, "$.source", (path, code, message) => {
874
- issues.push({ path, code, message });
875
- });
876
- if (issues.length > 0) {
877
- const first = issues[0];
878
- throw new Error(first ? `${first.code}: ${first.message}` : "Invalid workflow function source.");
879
- }
880
- // Cross the host/sandbox boundary as a JSON string, then parse INSIDE the
881
- // vm context. If we passed the host object directly its prototype chain
882
- // would point at the host's Object/Function, and the regex token blacklist
883
- // is trivially bypassed (e.g. "con"+"structor") to reach
884
- // __oxygen_context.constructor.constructor === host Function — which is
885
- // not affected by the new context's codeGeneration setting and yields
886
- // worker-process RCE. Parsing inside the context rebinds the prototype to
887
- // the sandboxed Object, so the same walk reaches the sandboxed Function,
888
- // which then trips contextCodeGeneration.strings=false below.
889
- const context = toJsonValue(input.context, "context");
890
- const contextJson = JSON.stringify(context);
891
- const sandbox = Object.create(null);
892
- sandbox.__oxygen_context_json = contextJson;
893
- // Shadow dangerous globals on the sandbox surface. Defense-in-depth: the
894
- // load-bearing block is contextCodeGeneration; this just removes the
895
- // obvious top-level handles.
896
- sandbox.Function = undefined;
897
- sandbox.eval = undefined;
898
- sandbox.setTimeout = undefined;
899
- sandbox.setInterval = undefined;
900
- sandbox.setImmediate = undefined;
901
- sandbox.queueMicrotask = undefined;
902
- sandbox.WebAssembly = undefined;
903
- const script = new vm.Script('"use strict";\n'
904
- + 'const __oxygen_context = JSON.parse(__oxygen_context_json);\n'
905
- + `const __oxygen_fn = (${input.source});\n`
906
- + '__oxygen_fn(__oxygen_context);');
907
- // Disable dynamic code generation in the sandboxed context. Combined with
908
- // the JSON re-parse above, this means every prototype-walk path to
909
- // Function — direct, via context.constructor.constructor, or any other
910
- // reachable Function instance — throws EvalError when called with source.
911
- try {
912
- const result = script.runInNewContext(sandbox, {
913
- timeout: timeoutMs,
914
- contextCodeGeneration: {
915
- strings: false,
916
- wasm: false,
917
- },
918
- });
919
- const resolved = isPromiseLike(result)
920
- ? await withTimeout(result, timeoutMs)
921
- : result;
922
- return enforceJsonOutput(resolved, maxOutputBytes);
923
- }
924
- catch (error) {
925
- throw normalizeSandboxThrow(error);
926
- }
927
- }
928
- // A throw from inside the vm sandbox is constructed with the sandbox realm's
929
- // Error, so `error instanceof Error` is false in the host worker — and
930
- // serializeOxygenError then drops the message and reports a generic
931
- // "Workflow run failed.", leaving a failing transform/branch undebuggable.
932
- // Reconstruct a host-realm Error preserving the user's message/name. Host-realm
933
- // throws (vm timeout, enforceJsonOutput's workflow_output_too_large) already
934
- // pass instanceof and are returned unchanged.
935
- function normalizeSandboxThrow(error) {
936
- if (error instanceof Error)
937
- return error;
938
- if (error && typeof error === "object") {
939
- const record = error;
940
- const message = typeof record.message === "string" && record.message
941
- ? record.message
942
- : "Workflow function threw.";
943
- const normalized = new Error(message);
944
- if (typeof record.name === "string" && record.name)
945
- normalized.name = record.name;
946
- return normalized;
947
- }
948
- return new Error(typeof error === "string" && error ? error : "Workflow function threw a non-error value.");
949
- }
950
- export const workflowApplySchema = {
951
- $schema: "https://json-schema.org/draft/2020-12/schema",
952
- title: "OXYGEN Workflow Apply Input",
953
- type: "object",
954
- additionalProperties: false,
955
- properties: {
956
- manifest: { $ref: "#/$defs/manifest" },
957
- approved: {
958
- type: "boolean",
959
- description: "Standing tool authorization for this exact autonomous revision.",
960
- },
961
- max_credits: {
962
- type: "number",
963
- exclusiveMinimum: 0,
964
- description: "Hard credit ceiling for each autonomous delivery.",
965
- },
966
- publish: {
967
- type: "boolean",
968
- description: "False saves an editable draft revision without publishing it. Defaults to true.",
969
- },
970
- },
971
- required: ["manifest"],
972
- $defs: {
973
- manifest: { type: "object", additionalProperties: true },
974
- },
975
- };
976
- export const workflowCallSchema = {
977
- $schema: "https://json-schema.org/draft/2020-12/schema",
978
- title: "OXYGEN Workflow Call Input",
979
- type: "object",
980
- additionalProperties: false,
981
- properties: {
982
- workflow: { type: "string" },
983
- workflow_id: { type: "string" },
984
- workflow_name: { type: "string" },
985
- input: { type: "object", additionalProperties: true },
986
- mode: { enum: ["dry_run", "live", "smoke_test"] },
987
- idempotency_key: { type: "string" },
988
- revision_version: {
989
- type: "integer",
990
- minimum: 1,
991
- description: "Exact saved revision to run. Historical revisions are non-live only.",
992
- },
993
- approved: {
994
- type: "boolean",
995
- description: "Explicit approval required for live calls.",
996
- },
997
- max_credits: {
998
- type: "number",
999
- exclusiveMinimum: 0,
1000
- description: "Positive credit ceiling required for live calls.",
1001
- },
1002
- },
1003
- required: ["mode"],
1004
- };
1005
- export const workflowEventEmitSchema = {
1006
- $schema: "https://json-schema.org/draft/2020-12/schema",
1007
- title: "OXYGEN Workflow Event Emit Input",
1008
- type: "object",
1009
- additionalProperties: false,
1010
- properties: {
1011
- source: { type: "string" },
1012
- event: { type: "string" },
1013
- payload: { type: "object", additionalProperties: true },
1014
- raw_payload: { type: "object", additionalProperties: true },
1015
- headers: { type: "object", additionalProperties: true },
1016
- external_event_id: { type: "string" },
1017
- idempotency_key: { type: "string" },
1018
- mode: { enum: ["dry_run", "live", "smoke_test"] },
1019
- approved: {
1020
- type: "boolean",
1021
- description: "Explicit approval required when event deliveries run live.",
1022
- },
1023
- max_credits: {
1024
- type: "number",
1025
- exclusiveMinimum: 0,
1026
- description: "Positive per-delivery credit ceiling required for live event emission.",
1027
- },
1028
- },
1029
- required: ["source", "event", "payload", "mode"],
1030
- };
1031
- export const workflowTriggerSchema = {
1032
- $schema: "https://json-schema.org/draft/2020-12/schema",
1033
- title: "OXYGEN Workflow Trigger",
1034
- type: "object",
1035
- additionalProperties: false,
1036
- properties: {
1037
- type: { enum: ["api", "webhook", "cron", "event"] },
1038
- trigger_id: { type: "string" },
1039
- trigger_name: { type: ["string", "null"] },
1040
- secret_required: { type: "boolean" },
1041
- idempotency_key_path: { type: ["string", "null"] },
1042
- cron: { type: "string" },
1043
- timezone: { type: ["string", "null"] },
1044
- source: { type: "string" },
1045
- event: { type: "string" },
1046
- filters: {
1047
- type: "array",
1048
- items: {
1049
- type: "object",
1050
- additionalProperties: false,
1051
- properties: {
1052
- path: { type: "string" },
1053
- op: { enum: ["eq", "neq", "exists", "not_exists"] },
1054
- value: {},
1055
- },
1056
- required: ["path", "op"],
1057
- },
1058
- },
1059
- status: { enum: ["active", "disabled"] },
1060
- },
1061
- required: ["type"],
1062
- };
1063
- export const workflowManifestSchema = {
1064
- $schema: "https://json-schema.org/draft/2020-12/schema",
1065
- title: "OXYGEN Workflow Manifest",
1066
- type: "object",
1067
- additionalProperties: true,
1068
- required: ["manifest_version", "workflow", "steps", "source_hash", "compiler_version"],
1069
- };
1070
- export function getWorkflowSchema(subject = "apply") {
1071
- const schemas = {
1072
- apply: workflowApplySchema,
1073
- call: workflowCallSchema,
1074
- event: workflowEventEmitSchema,
1075
- trigger: workflowTriggerSchema,
1076
- manifest: workflowManifestSchema,
1077
- };
1078
- if (subject === "all")
1079
- return { schemas };
1080
- return schemas[subject];
1081
- }
1082
- function serializeWorkflowFunction(fn, path) {
1083
- if (typeof fn !== "function") {
1084
- throw new Error(`${path} must be a function.`);
1085
- }
1086
- const source = Function.prototype.toString.call(fn);
1087
- const issues = [];
1088
- validatePureFunctionSource(source, path, (issuePath, code, message) => {
1089
- issues.push({ path: issuePath, code, message });
1090
- });
1091
- if (issues.length > 0) {
1092
- const first = issues[0];
1093
- throw new Error(first ? `${first.code}: ${first.message}` : `${path} is invalid.`);
1094
- }
1095
- return source;
1096
- }
1097
- const zonedFormatters = new Map();
1098
- // Date-only match (month + day-of-month/day-of-week), excluding hour/minute.
1099
- // Lets nextCronRunAfter skip whole non-matching days in one jump.
1100
- function matchesCronDate(schedule, parts) {
1101
- if (!schedule.months.has(parts.month))
1102
- return false;
1103
- const dayOfMonthMatches = schedule.daysOfMonth.has(parts.dayOfMonth);
1104
- const dayOfWeekMatches = schedule.daysOfWeek.has(parts.dayOfWeek);
1105
- if (schedule.dayOfMonthRestricted && schedule.dayOfWeekRestricted) {
1106
- return dayOfMonthMatches || dayOfWeekMatches;
1107
- }
1108
- return dayOfMonthMatches && dayOfWeekMatches;
1109
- }
1110
- function matchesCronSchedule(schedule, parts) {
1111
- if (!schedule.minutes.has(parts.minute))
1112
- return false;
1113
- if (!schedule.hours.has(parts.hour))
1114
- return false;
1115
- return matchesCronDate(schedule, parts);
1116
- }
1117
- function roundUpToNextMinute(value) {
1118
- const result = new Date(value.getTime());
1119
- result.setUTCSeconds(0, 0);
1120
- if (result.getTime() <= value.getTime()) {
1121
- result.setUTCMinutes(result.getUTCMinutes() + 1);
1122
- }
1123
- return result;
1124
- }
1125
- function zonedDateParts(date, timezone) {
1126
- const formatter = getZonedFormatter(timezone);
1127
- const parts = new Map();
1128
- for (const part of formatter.formatToParts(date)) {
1129
- if (part.type !== "literal")
1130
- parts.set(part.type, part.value);
1131
- }
1132
- return {
1133
- minute: Number(parts.get("minute")),
1134
- hour: Number(parts.get("hour")),
1135
- dayOfMonth: Number(parts.get("day")),
1136
- month: Number(parts.get("month")),
1137
- dayOfWeek: weekdayToNumber(parts.get("weekday") ?? ""),
1138
- };
1139
- }
1140
- function getZonedFormatter(timezone) {
1141
- const cached = zonedFormatters.get(timezone);
1142
- if (cached)
1143
- return cached;
1144
- const formatter = new Intl.DateTimeFormat("en-US", {
1145
- timeZone: timezone,
1146
- weekday: "short",
1147
- year: "numeric",
1148
- month: "numeric",
1149
- day: "numeric",
1150
- hour: "numeric",
1151
- minute: "numeric",
1152
- hourCycle: "h23",
1153
- });
1154
- zonedFormatters.set(timezone, formatter);
1155
- return formatter;
1156
- }
1157
- function weekdayToNumber(value) {
1158
- switch (value.toLowerCase()) {
1159
- case "sun":
1160
- return 0;
1161
- case "mon":
1162
- return 1;
1163
- case "tue":
1164
- return 2;
1165
- case "wed":
1166
- return 3;
1167
- case "thu":
1168
- return 4;
1169
- case "fri":
1170
- return 5;
1171
- case "sat":
1172
- return 6;
1173
- default:
1174
- throw new Error(`Unsupported weekday '${value}'.`);
1175
- }
1176
- }
1177
- function hashWorkflowSource(source) {
1178
- return createHash("sha256").update(source).digest("hex");
1179
- }
1180
- // Deterministic plan hash (Gap 4): binds an approval decision to the exact
1181
- // reviewed plan + cost so it cannot be replayed against a changed plan. The
1182
- // durable mid-run approval gate (recipe-context) hashes its relevant fields
1183
- // through this; binding the imperative `workflows call` admission path the same
1184
- // way is a flagged follow-up. Canonical (sorted-key) JSON keeps the hash stable
1185
- // regardless of key order or undefined fields.
1186
- export function computeWorkflowPlanHash(input) {
1187
- return hashWorkflowSource(canonicalJsonStringify(input));
1188
- }
1189
- function canonicalJsonStringify(value) {
1190
- if (value === null || typeof value !== "object")
1191
- return JSON.stringify(value) ?? "null";
1192
- if (Array.isArray(value))
1193
- return `[${value.map(canonicalJsonStringify).join(",")}]`;
1194
- const entries = Object.entries(value)
1195
- .filter(([, entryValue]) => entryValue !== undefined)
1196
- .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
1197
- return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJsonStringify(entryValue)}`).join(",")}}`;
1198
- }
1199
- function workflowJsonReplacer(_key, value) {
1200
- return typeof value === "function" ? Function.prototype.toString.call(value) : value;
1201
- }
1202
- function enforceJsonOutput(value, maxOutputBytes) {
1203
- const json = JSON.stringify(value);
1204
- if (json === undefined)
1205
- return null;
1206
- if (Buffer.byteLength(json) > maxOutputBytes) {
1207
- throw new Error("workflow_output_too_large: Workflow function output is too large.");
1208
- }
1209
- return JSON.parse(json);
1210
- }
1211
- function toJsonValue(value, label) {
1212
- const json = JSON.stringify(value);
1213
- if (json === undefined) {
1214
- throw new Error(`${label} must be JSON serializable.`);
1215
- }
1216
- return JSON.parse(json);
1217
- }
1218
- function isPromiseLike(value) {
1219
- return value !== null && typeof value === "object" && "then" in value
1220
- && typeof value.then === "function";
1221
- }
1222
- async function withTimeout(promise, timeoutMs) {
1223
- let timer = null;
1224
- try {
1225
- return await Promise.race([
1226
- promise,
1227
- new Promise((_, reject) => {
1228
- timer = setTimeout(() => reject(new Error("workflow_function_timeout: Workflow function timed out.")), timeoutMs);
1229
- }),
1230
- ]);
1231
- }
1232
- finally {
1233
- if (timer)
1234
- clearTimeout(timer);
1235
- }
1236
- }
16
+ export { WORKFLOW_COMPILER_VERSION, BLUEPRINT_VERSION, BLUEPRINT_COMPILER_VERSION, MAX_BLUEPRINT_BYTES, DEFAULT_WORKFLOW_CRON_TIMEZONE, } from "./manifest-types.js";
17
+ export { defineWorkflow, apiTrigger, webhookTrigger, cronTrigger, eventTrigger, transformStep, toolStep, branchStep, } from "./manifest-builders.js";
18
+ export { nextCronRunAfter, nextCronRunAfterMinInterval, minCronGapMinutes, } from "./cron.js";
19
+ export { isWorkflowDefinition, isWorkflowManifest, isRecipeManifest, isAnyWorkflowManifest, isBlueprint, } from "./manifest-guards.js";
20
+ export { buildRecipeManifest, hashRecipeSource, buildBlueprint, computeWorkflowPlanHash, } from "./manifest-hash.js";
21
+ export { compileWorkflowDefinition, lintWorkflowManifest, assertRecipeManifest, assertWorkflowManifest, lintBlueprint, assertBlueprint, assertRecipeBundleSafe, lintRecipeBundleSafety, } from "./manifest-lint.js";
22
+ export { PURE_WORKFLOW_FUNCTION_MAX_TIMEOUT_MS, runPureWorkflowFunction, } from "./pure-function.js";
23
+ export { workflowApplySchema, workflowCallSchema, workflowEventEmitSchema, workflowTriggerSchema, workflowManifestSchema, getWorkflowSchema, } from "./workflow-schemas.js";