@xyne/workflow-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/README.md +36 -0
  2. package/dist/agents/agent-step.d.ts +152 -0
  3. package/dist/agents/agent-step.d.ts.map +1 -0
  4. package/dist/agents/agent-step.js +403 -0
  5. package/dist/agents/agent-step.js.map +1 -0
  6. package/dist/agents/base-runtime.d.ts +38 -0
  7. package/dist/agents/base-runtime.d.ts.map +1 -0
  8. package/dist/agents/base-runtime.js +21 -0
  9. package/dist/agents/base-runtime.js.map +1 -0
  10. package/dist/agents/index.d.ts +12 -0
  11. package/dist/agents/index.d.ts.map +1 -0
  12. package/dist/agents/index.js +17 -0
  13. package/dist/agents/index.js.map +1 -0
  14. package/dist/agents/interceptor.d.ts +19 -0
  15. package/dist/agents/interceptor.d.ts.map +1 -0
  16. package/dist/agents/interceptor.js +21 -0
  17. package/dist/agents/interceptor.js.map +1 -0
  18. package/dist/agents/interceptors/approval-gate.d.ts +14 -0
  19. package/dist/agents/interceptors/approval-gate.d.ts.map +1 -0
  20. package/dist/agents/interceptors/approval-gate.js +19 -0
  21. package/dist/agents/interceptors/approval-gate.js.map +1 -0
  22. package/dist/agents/interceptors/tool-logger.d.ts +15 -0
  23. package/dist/agents/interceptors/tool-logger.d.ts.map +1 -0
  24. package/dist/agents/interceptors/tool-logger.js +23 -0
  25. package/dist/agents/interceptors/tool-logger.js.map +1 -0
  26. package/dist/agents/pi-mono-runtime.d.ts +88 -0
  27. package/dist/agents/pi-mono-runtime.d.ts.map +1 -0
  28. package/dist/agents/pi-mono-runtime.js +129 -0
  29. package/dist/agents/pi-mono-runtime.js.map +1 -0
  30. package/dist/agents/tool-registry.d.ts +25 -0
  31. package/dist/agents/tool-registry.d.ts.map +1 -0
  32. package/dist/agents/tool-registry.js +47 -0
  33. package/dist/agents/tool-registry.js.map +1 -0
  34. package/dist/agents/tool-types.d.ts +25 -0
  35. package/dist/agents/tool-types.d.ts.map +1 -0
  36. package/dist/agents/tool-types.js +9 -0
  37. package/dist/agents/tool-types.js.map +1 -0
  38. package/dist/agents/types.d.ts +91 -0
  39. package/dist/agents/types.d.ts.map +1 -0
  40. package/dist/agents/types.js +12 -0
  41. package/dist/agents/types.js.map +1 -0
  42. package/dist/builder/index.d.ts +30 -0
  43. package/dist/builder/index.d.ts.map +1 -0
  44. package/dist/builder/index.js +32 -0
  45. package/dist/builder/index.js.map +1 -0
  46. package/dist/client/index.d.ts +19 -0
  47. package/dist/client/index.d.ts.map +1 -0
  48. package/dist/client/index.js +18 -0
  49. package/dist/client/index.js.map +1 -0
  50. package/dist/client/types.d.ts +128 -0
  51. package/dist/client/types.d.ts.map +1 -0
  52. package/dist/client/types.js +10 -0
  53. package/dist/client/types.js.map +1 -0
  54. package/dist/client/workflow-client.d.ts +15 -0
  55. package/dist/client/workflow-client.d.ts.map +1 -0
  56. package/dist/client/workflow-client.js +293 -0
  57. package/dist/client/workflow-client.js.map +1 -0
  58. package/dist/common/attachment.d.ts +31 -0
  59. package/dist/common/attachment.d.ts.map +1 -0
  60. package/dist/common/attachment.js +21 -0
  61. package/dist/common/attachment.js.map +1 -0
  62. package/dist/common/executable-check.d.ts +42 -0
  63. package/dist/common/executable-check.d.ts.map +1 -0
  64. package/dist/common/executable-check.js +115 -0
  65. package/dist/common/executable-check.js.map +1 -0
  66. package/dist/common/index.d.ts +21 -0
  67. package/dist/common/index.d.ts.map +1 -0
  68. package/dist/common/index.js +19 -0
  69. package/dist/common/index.js.map +1 -0
  70. package/dist/common/resume-payload.d.ts +34 -0
  71. package/dist/common/resume-payload.d.ts.map +1 -0
  72. package/dist/common/resume-payload.js +12 -0
  73. package/dist/common/resume-payload.js.map +1 -0
  74. package/dist/engine/available-context.d.ts +29 -0
  75. package/dist/engine/available-context.d.ts.map +1 -0
  76. package/dist/engine/available-context.js +66 -0
  77. package/dist/engine/available-context.js.map +1 -0
  78. package/dist/engine/condition-evaluator.d.ts +13 -0
  79. package/dist/engine/condition-evaluator.d.ts.map +1 -0
  80. package/dist/engine/condition-evaluator.js +92 -0
  81. package/dist/engine/condition-evaluator.js.map +1 -0
  82. package/dist/engine/config-validator.d.ts +25 -0
  83. package/dist/engine/config-validator.d.ts.map +1 -0
  84. package/dist/engine/config-validator.js +316 -0
  85. package/dist/engine/config-validator.js.map +1 -0
  86. package/dist/engine/pause-step.d.ts +20 -0
  87. package/dist/engine/pause-step.d.ts.map +1 -0
  88. package/dist/engine/pause-step.js +24 -0
  89. package/dist/engine/pause-step.js.map +1 -0
  90. package/dist/engine/service-registry.d.ts +49 -0
  91. package/dist/engine/service-registry.d.ts.map +1 -0
  92. package/dist/engine/service-registry.js +76 -0
  93. package/dist/engine/service-registry.js.map +1 -0
  94. package/dist/engine/variable-resolver.d.ts +29 -0
  95. package/dist/engine/variable-resolver.d.ts.map +1 -0
  96. package/dist/engine/variable-resolver.js +130 -0
  97. package/dist/engine/variable-resolver.js.map +1 -0
  98. package/dist/engine/workflow-executor.d.ts +96 -0
  99. package/dist/engine/workflow-executor.d.ts.map +1 -0
  100. package/dist/engine/workflow-executor.js +837 -0
  101. package/dist/engine/workflow-executor.js.map +1 -0
  102. package/dist/index.d.ts +57 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +56 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/persistence/in-memory-adapter.d.ts +138 -0
  107. package/dist/persistence/in-memory-adapter.d.ts.map +1 -0
  108. package/dist/persistence/in-memory-adapter.js +315 -0
  109. package/dist/persistence/in-memory-adapter.js.map +1 -0
  110. package/dist/persistence/types.d.ts +214 -0
  111. package/dist/persistence/types.d.ts.map +1 -0
  112. package/dist/persistence/types.js +8 -0
  113. package/dist/persistence/types.js.map +1 -0
  114. package/dist/router/types.d.ts +57 -0
  115. package/dist/router/types.d.ts.map +1 -0
  116. package/dist/router/types.js +8 -0
  117. package/dist/router/types.js.map +1 -0
  118. package/dist/router/workflow-router.d.ts +26 -0
  119. package/dist/router/workflow-router.d.ts.map +1 -0
  120. package/dist/router/workflow-router.js +611 -0
  121. package/dist/router/workflow-router.js.map +1 -0
  122. package/dist/runtime/execution-event-bus.d.ts +38 -0
  123. package/dist/runtime/execution-event-bus.d.ts.map +1 -0
  124. package/dist/runtime/execution-event-bus.js +87 -0
  125. package/dist/runtime/execution-event-bus.js.map +1 -0
  126. package/dist/runtime/types.d.ts +129 -0
  127. package/dist/runtime/types.d.ts.map +1 -0
  128. package/dist/runtime/types.js +5 -0
  129. package/dist/runtime/types.js.map +1 -0
  130. package/dist/runtime/workflow-runtime.d.ts +256 -0
  131. package/dist/runtime/workflow-runtime.d.ts.map +1 -0
  132. package/dist/runtime/workflow-runtime.js +699 -0
  133. package/dist/runtime/workflow-runtime.js.map +1 -0
  134. package/dist/steps/base-step.d.ts +204 -0
  135. package/dist/steps/base-step.d.ts.map +1 -0
  136. package/dist/steps/base-step.js +69 -0
  137. package/dist/steps/base-step.js.map +1 -0
  138. package/dist/steps/builtin/code.step.d.ts +95 -0
  139. package/dist/steps/builtin/code.step.d.ts.map +1 -0
  140. package/dist/steps/builtin/code.step.js +122 -0
  141. package/dist/steps/builtin/code.step.js.map +1 -0
  142. package/dist/steps/builtin/conditional.step.d.ts +146 -0
  143. package/dist/steps/builtin/conditional.step.d.ts.map +1 -0
  144. package/dist/steps/builtin/conditional.step.js +71 -0
  145. package/dist/steps/builtin/conditional.step.js.map +1 -0
  146. package/dist/steps/builtin/dedup.step.d.ts +65 -0
  147. package/dist/steps/builtin/dedup.step.d.ts.map +1 -0
  148. package/dist/steps/builtin/dedup.step.js +61 -0
  149. package/dist/steps/builtin/dedup.step.js.map +1 -0
  150. package/dist/steps/builtin/http-request.step.d.ts +928 -0
  151. package/dist/steps/builtin/http-request.step.d.ts.map +1 -0
  152. package/dist/steps/builtin/http-request.step.js +570 -0
  153. package/dist/steps/builtin/http-request.step.js.map +1 -0
  154. package/dist/steps/builtin/loop.step.d.ts +100 -0
  155. package/dist/steps/builtin/loop.step.d.ts.map +1 -0
  156. package/dist/steps/builtin/loop.step.js +79 -0
  157. package/dist/steps/builtin/loop.step.js.map +1 -0
  158. package/dist/steps/builtin/parallel.step.d.ts +208 -0
  159. package/dist/steps/builtin/parallel.step.d.ts.map +1 -0
  160. package/dist/steps/builtin/parallel.step.js +249 -0
  161. package/dist/steps/builtin/parallel.step.js.map +1 -0
  162. package/dist/steps/builtin/switch.step.d.ts +200 -0
  163. package/dist/steps/builtin/switch.step.d.ts.map +1 -0
  164. package/dist/steps/builtin/switch.step.js +92 -0
  165. package/dist/steps/builtin/switch.step.js.map +1 -0
  166. package/dist/steps/builtin/transform.step.d.ts +247 -0
  167. package/dist/steps/builtin/transform.step.d.ts.map +1 -0
  168. package/dist/steps/builtin/transform.step.js +135 -0
  169. package/dist/steps/builtin/transform.step.js.map +1 -0
  170. package/dist/steps/builtin/wait.step.d.ts +921 -0
  171. package/dist/steps/builtin/wait.step.d.ts.map +1 -0
  172. package/dist/steps/builtin/wait.step.js +211 -0
  173. package/dist/steps/builtin/wait.step.js.map +1 -0
  174. package/dist/steps/step-registry.d.ts +64 -0
  175. package/dist/steps/step-registry.d.ts.map +1 -0
  176. package/dist/steps/step-registry.js +102 -0
  177. package/dist/steps/step-registry.js.map +1 -0
  178. package/dist/storage/in-memory-adapter.d.ts +25 -0
  179. package/dist/storage/in-memory-adapter.d.ts.map +1 -0
  180. package/dist/storage/in-memory-adapter.js +41 -0
  181. package/dist/storage/in-memory-adapter.js.map +1 -0
  182. package/dist/storage/types.d.ts +53 -0
  183. package/dist/storage/types.d.ts.map +1 -0
  184. package/dist/storage/types.js +13 -0
  185. package/dist/storage/types.js.map +1 -0
  186. package/dist/testing/index.d.ts +10 -0
  187. package/dist/testing/index.d.ts.map +1 -0
  188. package/dist/testing/index.js +10 -0
  189. package/dist/testing/index.js.map +1 -0
  190. package/dist/testing/mock-context.d.ts +13 -0
  191. package/dist/testing/mock-context.d.ts.map +1 -0
  192. package/dist/testing/mock-context.js +21 -0
  193. package/dist/testing/mock-context.js.map +1 -0
  194. package/dist/testing/mock-step-context.d.ts +47 -0
  195. package/dist/testing/mock-step-context.d.ts.map +1 -0
  196. package/dist/testing/mock-step-context.js +59 -0
  197. package/dist/testing/mock-step-context.js.map +1 -0
  198. package/dist/triggers/base-trigger.d.ts +58 -0
  199. package/dist/triggers/base-trigger.d.ts.map +1 -0
  200. package/dist/triggers/base-trigger.js +37 -0
  201. package/dist/triggers/base-trigger.js.map +1 -0
  202. package/dist/triggers/builtin/default-cron-trigger.d.ts +44 -0
  203. package/dist/triggers/builtin/default-cron-trigger.d.ts.map +1 -0
  204. package/dist/triggers/builtin/default-cron-trigger.js +31 -0
  205. package/dist/triggers/builtin/default-cron-trigger.js.map +1 -0
  206. package/dist/triggers/builtin/default-event-trigger.d.ts +32 -0
  207. package/dist/triggers/builtin/default-event-trigger.d.ts.map +1 -0
  208. package/dist/triggers/builtin/default-event-trigger.js +21 -0
  209. package/dist/triggers/builtin/default-event-trigger.js.map +1 -0
  210. package/dist/triggers/builtin/default-manual-trigger.d.ts +119 -0
  211. package/dist/triggers/builtin/default-manual-trigger.d.ts.map +1 -0
  212. package/dist/triggers/builtin/default-manual-trigger.js +64 -0
  213. package/dist/triggers/builtin/default-manual-trigger.js.map +1 -0
  214. package/dist/triggers/builtin/default-webhook-trigger.d.ts +72 -0
  215. package/dist/triggers/builtin/default-webhook-trigger.d.ts.map +1 -0
  216. package/dist/triggers/builtin/default-webhook-trigger.js +91 -0
  217. package/dist/triggers/builtin/default-webhook-trigger.js.map +1 -0
  218. package/dist/triggers/cron-trigger.d.ts +52 -0
  219. package/dist/triggers/cron-trigger.d.ts.map +1 -0
  220. package/dist/triggers/cron-trigger.js +15 -0
  221. package/dist/triggers/cron-trigger.js.map +1 -0
  222. package/dist/triggers/event-trigger.d.ts +14 -0
  223. package/dist/triggers/event-trigger.d.ts.map +1 -0
  224. package/dist/triggers/event-trigger.js +13 -0
  225. package/dist/triggers/event-trigger.js.map +1 -0
  226. package/dist/triggers/manual-trigger.d.ts +11 -0
  227. package/dist/triggers/manual-trigger.d.ts.map +1 -0
  228. package/dist/triggers/manual-trigger.js +10 -0
  229. package/dist/triggers/manual-trigger.js.map +1 -0
  230. package/dist/triggers/trigger-registry.d.ts +48 -0
  231. package/dist/triggers/trigger-registry.d.ts.map +1 -0
  232. package/dist/triggers/trigger-registry.js +81 -0
  233. package/dist/triggers/trigger-registry.js.map +1 -0
  234. package/dist/triggers/webhook-trigger.d.ts +54 -0
  235. package/dist/triggers/webhook-trigger.d.ts.map +1 -0
  236. package/dist/triggers/webhook-trigger.js +13 -0
  237. package/dist/triggers/webhook-trigger.js.map +1 -0
  238. package/dist/types/attachment.d.ts +23 -0
  239. package/dist/types/attachment.d.ts.map +1 -0
  240. package/dist/types/attachment.js +2 -0
  241. package/dist/types/attachment.js.map +1 -0
  242. package/dist/types/categories.d.ts +14 -0
  243. package/dist/types/categories.d.ts.map +1 -0
  244. package/dist/types/categories.js +10 -0
  245. package/dist/types/categories.js.map +1 -0
  246. package/dist/types/context.d.ts +61 -0
  247. package/dist/types/context.d.ts.map +1 -0
  248. package/dist/types/context.js +2 -0
  249. package/dist/types/context.js.map +1 -0
  250. package/dist/types/index.d.ts +18 -0
  251. package/dist/types/index.d.ts.map +1 -0
  252. package/dist/types/index.js +12 -0
  253. package/dist/types/index.js.map +1 -0
  254. package/dist/types/known-types.d.ts +34 -0
  255. package/dist/types/known-types.d.ts.map +1 -0
  256. package/dist/types/known-types.js +49 -0
  257. package/dist/types/known-types.js.map +1 -0
  258. package/dist/types/operators.d.ts +20 -0
  259. package/dist/types/operators.d.ts.map +1 -0
  260. package/dist/types/operators.js +27 -0
  261. package/dist/types/operators.js.map +1 -0
  262. package/dist/types/pause-path.d.ts +23 -0
  263. package/dist/types/pause-path.d.ts.map +1 -0
  264. package/dist/types/pause-path.js +2 -0
  265. package/dist/types/pause-path.js.map +1 -0
  266. package/dist/types/pause-state.d.ts +100 -0
  267. package/dist/types/pause-state.d.ts.map +1 -0
  268. package/dist/types/pause-state.js +15 -0
  269. package/dist/types/pause-state.js.map +1 -0
  270. package/dist/types/resume-payload.d.ts +34 -0
  271. package/dist/types/resume-payload.d.ts.map +1 -0
  272. package/dist/types/resume-payload.js +12 -0
  273. package/dist/types/resume-payload.js.map +1 -0
  274. package/dist/types/status.d.ts +27 -0
  275. package/dist/types/status.d.ts.map +1 -0
  276. package/dist/types/status.js +41 -0
  277. package/dist/types/status.js.map +1 -0
  278. package/dist/types/step-events.d.ts +22 -0
  279. package/dist/types/step-events.d.ts.map +1 -0
  280. package/dist/types/step-events.js +8 -0
  281. package/dist/types/step-events.js.map +1 -0
  282. package/dist/types/step-types.d.ts +12 -0
  283. package/dist/types/step-types.d.ts.map +1 -0
  284. package/dist/types/step-types.js +2 -0
  285. package/dist/types/step-types.js.map +1 -0
  286. package/dist/types/trigger-types.d.ts +12 -0
  287. package/dist/types/trigger-types.d.ts.map +1 -0
  288. package/dist/types/trigger-types.js +2 -0
  289. package/dist/types/trigger-types.js.map +1 -0
  290. package/dist/types/validation.d.ts +19 -0
  291. package/dist/types/validation.d.ts.map +1 -0
  292. package/dist/types/validation.js +11 -0
  293. package/dist/types/validation.js.map +1 -0
  294. package/dist/types/workflow-config.d.ts +122 -0
  295. package/dist/types/workflow-config.d.ts.map +1 -0
  296. package/dist/types/workflow-config.js +71 -0
  297. package/dist/types/workflow-config.js.map +1 -0
  298. package/dist/util/executable-check.d.ts +42 -0
  299. package/dist/util/executable-check.d.ts.map +1 -0
  300. package/dist/util/executable-check.js +115 -0
  301. package/dist/util/executable-check.js.map +1 -0
  302. package/dist/util/schema-convert.d.ts +14 -0
  303. package/dist/util/schema-convert.d.ts.map +1 -0
  304. package/dist/util/schema-convert.js +16 -0
  305. package/dist/util/schema-convert.js.map +1 -0
  306. package/dist/util/variable-ref.d.ts +52 -0
  307. package/dist/util/variable-ref.d.ts.map +1 -0
  308. package/dist/util/variable-ref.js +89 -0
  309. package/dist/util/variable-ref.js.map +1 -0
  310. package/package.json +97 -0
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ import type { TriggerType } from './trigger-types.js';
3
+ import type { StepType } from './step-types.js';
4
+ import { BuiltinStepType } from './known-types.js';
5
+ import type { ControlFlowStepType } from './known-types.js';
6
+ import type { ConditionOperator } from './operators.js';
7
+ /**
8
+ * Wraps a Zod schema to also accept a `{{...}}` variable reference string.
9
+ * Used in step config schemas — e.g. `variableRef(z.string())` accepts
10
+ * either a literal string or a `{{trigger.someField}}` reference.
11
+ */
12
+ export declare function variableRef<T extends z.ZodTypeAny>(inner: T): z.ZodUnion<[T, z.ZodString]>;
13
+ /**
14
+ * Given a schema that may be a variableRef union, extract the inner (non-ref) schema.
15
+ * Returns null if the schema is not a variableRef union.
16
+ */
17
+ export declare function getVariableRefInnerSchema(schema: z.ZodTypeAny): z.ZodTypeAny | null;
18
+ export interface LeafCondition {
19
+ variable: string;
20
+ operator: ConditionOperator;
21
+ value?: unknown;
22
+ }
23
+ export type Condition = LeafCondition | {
24
+ all: Condition[];
25
+ } | {
26
+ any: Condition[];
27
+ };
28
+ export declare const LeafConditionSchema: z.ZodType<LeafCondition>;
29
+ export declare const ConditionSchema: z.ZodType<Condition>;
30
+ /**
31
+ * What happens after a step completes successfully.
32
+ * - `continue` (default): move to the next step
33
+ * - `review`: pause the execution and wait for a human to approve, retry with feedback, or abort
34
+ */
35
+ export type StepCompletionGate = 'continue' | 'review';
36
+ export interface ActionStepConfig {
37
+ id: string;
38
+ type: Exclude<StepType, ControlFlowStepType>;
39
+ config: Record<string, unknown>;
40
+ /** Defaults to 'continue' when omitted. */
41
+ onComplete?: StepCompletionGate;
42
+ }
43
+ export interface ConditionalStepConfig {
44
+ id: string;
45
+ type: BuiltinStepType.CONDITIONAL;
46
+ config: {
47
+ condition: Condition;
48
+ if_true: WorkflowStepConfig[];
49
+ if_false?: WorkflowStepConfig[];
50
+ };
51
+ onComplete?: StepCompletionGate;
52
+ }
53
+ export interface SwitchCaseEntry {
54
+ condition: Condition;
55
+ label?: string;
56
+ steps: WorkflowStepConfig[];
57
+ }
58
+ export interface SwitchStepConfig {
59
+ id: string;
60
+ type: BuiltinStepType.SWITCH;
61
+ config: {
62
+ /**
63
+ * Cases evaluated top-to-bottom; the first whose condition is true wins.
64
+ * May be empty when the step is first created — `default` always runs in that case.
65
+ */
66
+ cases: SwitchCaseEntry[];
67
+ /**
68
+ * Fallback branch — always present, executed when no case matches.
69
+ * May be empty (`[]`) to no-op the fallback.
70
+ */
71
+ default: WorkflowStepConfig[];
72
+ };
73
+ onComplete?: StepCompletionGate;
74
+ }
75
+ export type WorkflowStepConfig = ActionStepConfig | ConditionalStepConfig | SwitchStepConfig;
76
+ export declare const WorkflowSettingsSchema: z.ZodObject<{
77
+ onError: z.ZodDefault<z.ZodEnum<["stop", "continue"]>>;
78
+ retry: z.ZodOptional<z.ZodObject<{
79
+ maxAttempts: z.ZodNumber;
80
+ intervalMs: z.ZodNumber;
81
+ }, "strip", z.ZodTypeAny, {
82
+ maxAttempts: number;
83
+ intervalMs: number;
84
+ }, {
85
+ maxAttempts: number;
86
+ intervalMs: number;
87
+ }>>;
88
+ }, "strip", z.ZodTypeAny, {
89
+ onError: "continue" | "stop";
90
+ retry?: {
91
+ maxAttempts: number;
92
+ intervalMs: number;
93
+ } | undefined;
94
+ }, {
95
+ onError?: "continue" | "stop" | undefined;
96
+ retry?: {
97
+ maxAttempts: number;
98
+ intervalMs: number;
99
+ } | undefined;
100
+ }>;
101
+ export type WorkflowSettings = z.infer<typeof WorkflowSettingsSchema>;
102
+ /**
103
+ * The complete configuration for a workflow.
104
+ *
105
+ * - `trigger` — what starts the workflow (host-defined type + config)
106
+ * - `steps` — the tree of steps to execute
107
+ * - `settings` — error handling, retry, timeout (optional — defaults to stop-on-error)
108
+ */
109
+ export interface WorkflowConfig {
110
+ trigger: {
111
+ type: TriggerType;
112
+ config: Record<string, unknown>;
113
+ };
114
+ steps: WorkflowStepConfig[];
115
+ settings?: WorkflowSettings;
116
+ }
117
+ /**
118
+ * Read a dotted path from a nested object.
119
+ * `readDottedPath({ a: { b: 1 } }, 'a.b')` → `1`
120
+ */
121
+ export declare function readDottedPath(payload: Record<string, unknown>, path: string): unknown;
122
+ //# sourceMappingURL=workflow-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-config.d.ts","sourceRoot":"","sources":["../../src/types/workflow-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYxD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAChD,KAAK,EAAE,CAAC,GACP,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAM9B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,CAAC,CAAC,UAAU,GACnB,CAAC,CAAC,UAAU,GAAG,IAAI,CAWrB;AAID,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GACjB,aAAa,GACb;IAAE,GAAG,EAAE,SAAS,EAAE,CAAA;CAAE,GACpB;IAAE,GAAG,EAAE,SAAS,EAAE,CAAA;CAAE,CAAC;AAEzB,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,a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QjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAItE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QACP,IAAI,EAAE,WAAW,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACjC,CAAC;IACF,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,IAAI,EAAE,MAAM,GACX,OAAO,CAcT"}
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+ import { BuiltinStepType } from './known-types.js';
3
+ import { ConditionOperatorSchema } from './operators.js';
4
+ import { VARIABLE_REF_REGEX, VARIABLE_REF_DESCRIPTION_PREFIX, } from '../util/variable-ref.js';
5
+ // ─── Variable Reference Helpers ───
6
+ const variableRefStringSchema = z
7
+ .string()
8
+ .regex(VARIABLE_REF_REGEX, 'Must be a {{context.<path>}} reference');
9
+ /**
10
+ * Wraps a Zod schema to also accept a `{{...}}` variable reference string.
11
+ * Used in step config schemas — e.g. `variableRef(z.string())` accepts
12
+ * either a literal string or a `{{trigger.someField}}` reference.
13
+ */
14
+ export function variableRef(inner) {
15
+ return z
16
+ .union([inner, variableRefStringSchema])
17
+ .describe(`${VARIABLE_REF_DESCRIPTION_PREFIX}${inner.description ?? inner._def.typeName}`);
18
+ }
19
+ /**
20
+ * Given a schema that may be a variableRef union, extract the inner (non-ref) schema.
21
+ * Returns null if the schema is not a variableRef union.
22
+ */
23
+ export function getVariableRefInnerSchema(schema) {
24
+ if (schema instanceof z.ZodUnion &&
25
+ typeof schema.description === 'string' &&
26
+ schema.description.startsWith(VARIABLE_REF_DESCRIPTION_PREFIX)) {
27
+ const options = schema._def
28
+ .options;
29
+ return options[0] ?? null;
30
+ }
31
+ return null;
32
+ }
33
+ export const LeafConditionSchema = z.object({
34
+ variable: variableRefStringSchema,
35
+ operator: ConditionOperatorSchema,
36
+ value: z.unknown().optional(),
37
+ });
38
+ export const ConditionSchema = z.lazy(() => z.union([
39
+ LeafConditionSchema,
40
+ z.object({ all: z.array(ConditionSchema) }),
41
+ z.object({ any: z.array(ConditionSchema) }),
42
+ ]));
43
+ // ─── Workflow Settings ───
44
+ export const WorkflowSettingsSchema = z.object({
45
+ onError: z.enum(['stop', 'continue']).default('stop'),
46
+ retry: z
47
+ .object({
48
+ maxAttempts: z.number().int().min(1).max(10),
49
+ intervalMs: z.number().int().min(1000),
50
+ })
51
+ .optional(),
52
+ });
53
+ // ─── Utility ───
54
+ /**
55
+ * Read a dotted path from a nested object.
56
+ * `readDottedPath({ a: { b: 1 } }, 'a.b')` → `1`
57
+ */
58
+ export function readDottedPath(payload, path) {
59
+ const parts = path.split('.');
60
+ let current = payload;
61
+ for (const part of parts) {
62
+ if (current === null ||
63
+ current === undefined ||
64
+ typeof current !== 'object') {
65
+ return undefined;
66
+ }
67
+ current = current[part];
68
+ }
69
+ return current;
70
+ }
71
+ //# sourceMappingURL=workflow-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-config.js","sourceRoot":"","sources":["../../src/types/workflow-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAChC,MAAM,yBAAyB,CAAC;AAEjC,qCAAqC;AAErC,MAAM,uBAAuB,GAAG,CAAC;KAC9B,MAAM,EAAE;KACR,KAAK,CAAC,kBAAkB,EAAE,wCAAwC,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,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AAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,CAAC;SACL,MAAM,CAAC;QACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;KACvC,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAsBH,kBAAkB;AAElB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgC,EAChC,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAY,OAAO,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IACE,OAAO,KAAK,IAAI;YAChB,OAAO,KAAK,SAAS;YACrB,OAAO,OAAO,KAAK,QAAQ,EAC3B,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Executable upload safety check.
3
+ *
4
+ * Allow-by-default with a deny-list of known dangerous types — covers the
5
+ * common attack surface (native binaries, scripts that auto-run, installers,
6
+ * macro-enabled Office docs) without forcing workflow authors to enumerate
7
+ * every safe MIME type.
8
+ *
9
+ * Two checks run in parallel so spoofed MIME types alone can't bypass:
10
+ * 1. MIME type matches the deny-list
11
+ * 2. Filename extension matches the deny-list
12
+ *
13
+ * Either match blocks the upload. To accept executables (e.g. a security-
14
+ * analysis workflow that intentionally examines binaries), the host opts
15
+ * in via `RuntimeOptions.allowExecutableUploads = true`.
16
+ */
17
+ /**
18
+ * MIME types treated as executable / unsafe (lowercase — input is also
19
+ * lowercased before comparison).
20
+ */
21
+ export declare const BLOCKED_EXECUTABLE_MIME_TYPES: ReadonlySet<string>;
22
+ /**
23
+ * File extensions treated as executable / unsafe (case-insensitive, no dot).
24
+ * The check uses the LAST extension so `report.exe.txt` is treated as text
25
+ * (Windows shows the trailing extension, which is what the user actually sees).
26
+ */
27
+ export declare const BLOCKED_EXECUTABLE_EXTENSIONS: ReadonlySet<string>;
28
+ /**
29
+ * Extract the lowercase extension (no dot) from a filename, or '' if none.
30
+ * A leading dot doesn't count — `.bashrc` has no extension, not "bashrc".
31
+ */
32
+ export declare function extensionOf(name: string): string;
33
+ /**
34
+ * Returns a human-readable reason if the file should be blocked as
35
+ * executable, or `null` if it's safe.
36
+ *
37
+ * Always check both the MIME type and the filename — clients can spoof one
38
+ * but rarely both. This is defense-in-depth, not authoritative malware
39
+ * detection (run real AV at the storage layer for that).
40
+ */
41
+ export declare function isExecutable(mimeType: string, name: string): string | null;
42
+ //# sourceMappingURL=executable-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-check.d.ts","sourceRoot":"","sources":["../../src/util/executable-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAwC5D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAmB5D,CAAC;AAEH;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS1E"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Executable upload safety check.
3
+ *
4
+ * Allow-by-default with a deny-list of known dangerous types — covers the
5
+ * common attack surface (native binaries, scripts that auto-run, installers,
6
+ * macro-enabled Office docs) without forcing workflow authors to enumerate
7
+ * every safe MIME type.
8
+ *
9
+ * Two checks run in parallel so spoofed MIME types alone can't bypass:
10
+ * 1. MIME type matches the deny-list
11
+ * 2. Filename extension matches the deny-list
12
+ *
13
+ * Either match blocks the upload. To accept executables (e.g. a security-
14
+ * analysis workflow that intentionally examines binaries), the host opts
15
+ * in via `RuntimeOptions.allowExecutableUploads = true`.
16
+ */
17
+ /**
18
+ * MIME types treated as executable / unsafe (lowercase — input is also
19
+ * lowercased before comparison).
20
+ */
21
+ export const BLOCKED_EXECUTABLE_MIME_TYPES = new Set([
22
+ // Native binaries
23
+ 'application/x-msdownload',
24
+ 'application/x-msdos-program',
25
+ 'application/x-executable',
26
+ 'application/x-mach-binary',
27
+ 'application/vnd.microsoft.portable-executable',
28
+ 'application/x-msi',
29
+ 'application/x-ms-installer',
30
+ // Shell + Windows scripts
31
+ 'application/x-sh',
32
+ 'application/x-shellscript',
33
+ 'application/x-bat',
34
+ 'application/x-csh',
35
+ 'application/x-cmd',
36
+ 'application/x-msmetafile',
37
+ // JavaScript / ECMAScript
38
+ 'text/javascript',
39
+ 'application/javascript',
40
+ 'application/ecmascript',
41
+ 'application/x-javascript',
42
+ // Java / Flash
43
+ 'application/java-archive',
44
+ 'application/x-java-archive',
45
+ 'application/x-java-jnlp-file',
46
+ 'application/x-shockwave-flash',
47
+ // Installer / package formats that bundle executables
48
+ 'application/vnd.android.package-archive',
49
+ 'application/x-debian-package',
50
+ 'application/x-rpm',
51
+ // Macro-enabled Office documents (lowercased — IANA tokens are case-insensitive)
52
+ 'application/vnd.ms-word.document.macroenabled.12',
53
+ 'application/vnd.ms-word.template.macroenabled.12',
54
+ 'application/vnd.ms-excel.sheet.macroenabled.12',
55
+ 'application/vnd.ms-excel.template.macroenabled.12',
56
+ 'application/vnd.ms-excel.addin.macroenabled.12',
57
+ 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
58
+ 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
59
+ 'application/vnd.ms-powerpoint.template.macroenabled.12',
60
+ 'application/vnd.ms-powerpoint.addin.macroenabled.12',
61
+ ]);
62
+ /**
63
+ * File extensions treated as executable / unsafe (case-insensitive, no dot).
64
+ * The check uses the LAST extension so `report.exe.txt` is treated as text
65
+ * (Windows shows the trailing extension, which is what the user actually sees).
66
+ */
67
+ export const BLOCKED_EXECUTABLE_EXTENSIONS = new Set([
68
+ // Windows
69
+ 'exe', 'msi', 'com', 'scr', 'cmd', 'bat', 'ps1', 'psm1',
70
+ 'vbs', 'vbe', 'wsf', 'wsh', 'hta', 'cpl', 'lnk',
71
+ 'dll', 'sys', 'drv', 'ocx',
72
+ // macOS / Unix
73
+ 'app', 'dmg', 'pkg',
74
+ 'sh', 'bash', 'zsh', 'fish', 'csh', 'ksh', 'command', 'tool',
75
+ // Java / Flash
76
+ 'jar', 'war', 'jnlp', 'swf',
77
+ // Mobile installers
78
+ 'apk', 'ipa', 'xap',
79
+ // Linux installers
80
+ 'deb', 'rpm', 'run', 'bin',
81
+ // JavaScript (auto-executes in browser / Node contexts)
82
+ 'js', 'mjs', 'cjs',
83
+ // Macro-enabled Office
84
+ 'docm', 'dotm', 'xlsm', 'xltm', 'xlam', 'xlsb',
85
+ 'pptm', 'potm', 'ppam', 'ppsm', 'sldm',
86
+ ]);
87
+ /**
88
+ * Extract the lowercase extension (no dot) from a filename, or '' if none.
89
+ * A leading dot doesn't count — `.bashrc` has no extension, not "bashrc".
90
+ */
91
+ export function extensionOf(name) {
92
+ const dot = name.lastIndexOf('.');
93
+ if (dot <= 0 || dot === name.length - 1)
94
+ return '';
95
+ return name.slice(dot + 1).toLowerCase();
96
+ }
97
+ /**
98
+ * Returns a human-readable reason if the file should be blocked as
99
+ * executable, or `null` if it's safe.
100
+ *
101
+ * Always check both the MIME type and the filename — clients can spoof one
102
+ * but rarely both. This is defense-in-depth, not authoritative malware
103
+ * detection (run real AV at the storage layer for that).
104
+ */
105
+ export function isExecutable(mimeType, name) {
106
+ if (BLOCKED_EXECUTABLE_MIME_TYPES.has(mimeType.toLowerCase())) {
107
+ return `Executable MIME type "${mimeType}" is not allowed.`;
108
+ }
109
+ const ext = extensionOf(name);
110
+ if (ext && BLOCKED_EXECUTABLE_EXTENSIONS.has(ext)) {
111
+ return `Files with .${ext} extension are not allowed.`;
112
+ }
113
+ return null;
114
+ }
115
+ //# sourceMappingURL=executable-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-check.js","sourceRoot":"","sources":["../../src/util/executable-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACxE,kBAAkB;IAClB,0BAA0B;IAC1B,6BAA6B;IAC7B,0BAA0B;IAC1B,2BAA2B;IAC3B,+CAA+C;IAC/C,mBAAmB;IACnB,4BAA4B;IAC5B,0BAA0B;IAC1B,kBAAkB;IAClB,2BAA2B;IAC3B,mBAAmB;IACnB,mBAAmB;IACnB,mBAAmB;IACnB,0BAA0B;IAC1B,0BAA0B;IAC1B,iBAAiB;IACjB,wBAAwB;IACxB,wBAAwB;IACxB,0BAA0B;IAC1B,eAAe;IACf,0BAA0B;IAC1B,4BAA4B;IAC5B,8BAA8B;IAC9B,+BAA+B;IAC/B,sDAAsD;IACtD,yCAAyC;IACzC,8BAA8B;IAC9B,mBAAmB;IACnB,iFAAiF;IACjF,kDAAkD;IAClD,kDAAkD;IAClD,gDAAgD;IAChD,mDAAmD;IACnD,gDAAgD;IAChD,uDAAuD;IACvD,4DAA4D;IAC5D,wDAAwD;IACxD,qDAAqD;CACtD,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACxE,UAAU;IACV,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAA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,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,GAAG,IAAI,6BAA6B,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,eAAe,GAAG,6BAA6B,CAAC;IACzD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Thin wrapper around `zod-to-json-schema` for registry descriptors.
3
+ *
4
+ * Centralised so the conversion options stay consistent across the SDK.
5
+ */
6
+ import type { z } from 'zod';
7
+ /**
8
+ * Convert a Zod schema to a plain JSON Schema object.
9
+ *
10
+ * Returns `Record<string, unknown>` so callers don't need to
11
+ * depend on the `zod-to-json-schema` package directly.
12
+ */
13
+ export declare function zodToJsonSchemaRecord(schema: z.ZodTypeAny): Record<string, unknown>;
14
+ //# sourceMappingURL=schema-convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-convert.d.ts","sourceRoot":"","sources":["../../src/util/schema-convert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,CAAC,CAAC,UAAU,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Thin wrapper around `zod-to-json-schema` for registry descriptors.
3
+ *
4
+ * Centralised so the conversion options stay consistent across the SDK.
5
+ */
6
+ import { zodToJsonSchema } from 'zod-to-json-schema';
7
+ /**
8
+ * Convert a Zod schema to a plain JSON Schema object.
9
+ *
10
+ * Returns `Record<string, unknown>` so callers don't need to
11
+ * depend on the `zod-to-json-schema` package directly.
12
+ */
13
+ export function zodToJsonSchemaRecord(schema) {
14
+ return zodToJsonSchema(schema);
15
+ }
16
+ //# sourceMappingURL=schema-convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-convert.js","sourceRoot":"","sources":["../../src/util/schema-convert.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAoB;IAEpB,OAAO,eAAe,CAAC,MAAM,CAA4B,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Single source of truth for the `{{...}}` variable reference wire format.
3
+ *
4
+ * Both the engine (runtime resolver) and UI (picker/autocomplete) consume this.
5
+ * The `context.` prefix is optional for backward compatibility — both
6
+ * `{{context.trigger.x}}` and `{{trigger.x}}` are recognized.
7
+ */
8
+ /**
9
+ * Matches a *pure* single reference (the entire string is a ref).
10
+ * The `context.` prefix is optional.
11
+ */
12
+ export declare const VARIABLE_REF_REGEX: RegExp;
13
+ /**
14
+ * Sentinel prefix for Zod `.describe()` — lets JSON Schema consumers detect
15
+ * "this is a variableRef-wrapped field" without inspecting the Zod tree.
16
+ */
17
+ export declare const VARIABLE_REF_DESCRIPTION_PREFIX = "__variableRef__";
18
+ export type VariableRefToken = {
19
+ kind: 'literal';
20
+ text: string;
21
+ } | {
22
+ kind: 'ref';
23
+ path: string;
24
+ raw: string;
25
+ };
26
+ /**
27
+ * Tokenize a string into literal segments and variable references.
28
+ *
29
+ * "hello" → [literal('hello')]
30
+ * "{{trigger.x}}" → [ref('trigger.x')]
31
+ * "Hi {{trigger.user.name}}!" → [literal('Hi '), ref('trigger.user.name'), literal('!')]
32
+ */
33
+ export declare function tokenize(input: string): VariableRefToken[];
34
+ /** True iff `value` is exactly one reference with no surrounding text. */
35
+ export declare function isPureRef(value: string): boolean;
36
+ /**
37
+ * Extract the dotted path from a pure reference: `{{trigger.x}}` → `trigger.x`.
38
+ * Returns null if `value` isn't a pure reference.
39
+ */
40
+ export declare function extractRefPath(value: string): string | null;
41
+ export interface FoundRef {
42
+ /** The dotted path inside the ref, e.g. `trigger.ticket.id`. */
43
+ refPath: string;
44
+ /** JSON-pointer-style location in the config object where the ref string lives. */
45
+ location: string;
46
+ }
47
+ /**
48
+ * Collect every `{{...}}` reference found anywhere in a nested config object
49
+ * (strings, arrays, objects). Used by the config validator to flag unresolvable refs.
50
+ */
51
+ export declare function collectRefs(value: unknown, prefix: string): FoundRef[];
52
+ //# sourceMappingURL=variable-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-ref.d.ts","sourceRoot":"","sources":["../../src/util/variable-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAkC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,+BAA+B,oBAAoB,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAK/C;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAoB1D;AAED,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG3D;AAED,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAItE"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Single source of truth for the `{{...}}` variable reference wire format.
3
+ *
4
+ * Both the engine (runtime resolver) and UI (picker/autocomplete) consume this.
5
+ * The `context.` prefix is optional for backward compatibility — both
6
+ * `{{context.trigger.x}}` and `{{trigger.x}}` are recognized.
7
+ */
8
+ /**
9
+ * Matches a *pure* single reference (the entire string is a ref).
10
+ * The `context.` prefix is optional.
11
+ */
12
+ export const VARIABLE_REF_REGEX = /^\{\{(?:context\.)?[^}]+\}\}$/;
13
+ /**
14
+ * Sentinel prefix for Zod `.describe()` — lets JSON Schema consumers detect
15
+ * "this is a variableRef-wrapped field" without inspecting the Zod tree.
16
+ */
17
+ export const VARIABLE_REF_DESCRIPTION_PREFIX = '__variableRef__';
18
+ /** Global regex — captures the dotted path inside `{{...}}`. */
19
+ const TOKEN_REGEX = /\{\{(?:context\.)?([^}]+)\}\}/g;
20
+ /**
21
+ * Tokenize a string into literal segments and variable references.
22
+ *
23
+ * "hello" → [literal('hello')]
24
+ * "{{trigger.x}}" → [ref('trigger.x')]
25
+ * "Hi {{trigger.user.name}}!" → [literal('Hi '), ref('trigger.user.name'), literal('!')]
26
+ */
27
+ export function tokenize(input) {
28
+ const tokens = [];
29
+ let lastIndex = 0;
30
+ TOKEN_REGEX.lastIndex = 0;
31
+ let match;
32
+ while ((match = TOKEN_REGEX.exec(input)) !== null) {
33
+ if (match.index > lastIndex) {
34
+ tokens.push({
35
+ kind: 'literal',
36
+ text: input.slice(lastIndex, match.index),
37
+ });
38
+ }
39
+ tokens.push({ kind: 'ref', path: match[1], raw: match[0] });
40
+ lastIndex = TOKEN_REGEX.lastIndex;
41
+ }
42
+ if (lastIndex < input.length) {
43
+ tokens.push({ kind: 'literal', text: input.slice(lastIndex) });
44
+ }
45
+ return tokens;
46
+ }
47
+ /** True iff `value` is exactly one reference with no surrounding text. */
48
+ export function isPureRef(value) {
49
+ return VARIABLE_REF_REGEX.test(value);
50
+ }
51
+ /**
52
+ * Extract the dotted path from a pure reference: `{{trigger.x}}` → `trigger.x`.
53
+ * Returns null if `value` isn't a pure reference.
54
+ */
55
+ export function extractRefPath(value) {
56
+ const m = /^\{\{(?:context\.)?([^}]+)\}\}$/.exec(value);
57
+ return m?.[1] ?? null;
58
+ }
59
+ /**
60
+ * Collect every `{{...}}` reference found anywhere in a nested config object
61
+ * (strings, arrays, objects). Used by the config validator to flag unresolvable refs.
62
+ */
63
+ export function collectRefs(value, prefix) {
64
+ const out = [];
65
+ walk(value, prefix, out);
66
+ return out;
67
+ }
68
+ function walk(value, prefix, out) {
69
+ if (typeof value === 'string') {
70
+ TOKEN_REGEX.lastIndex = 0;
71
+ let match;
72
+ while ((match = TOKEN_REGEX.exec(value)) !== null) {
73
+ out.push({ refPath: match[1], location: prefix });
74
+ }
75
+ return;
76
+ }
77
+ if (Array.isArray(value)) {
78
+ for (let i = 0; i < value.length; i++) {
79
+ walk(value[i], `${prefix}[${i}]`, out);
80
+ }
81
+ return;
82
+ }
83
+ if (value !== null && typeof value === 'object') {
84
+ for (const [k, v] of Object.entries(value)) {
85
+ walk(v, prefix ? `${prefix}.${k}` : k, out);
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=variable-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-ref.js","sourceRoot":"","sources":["../../src/util/variable-ref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,iBAAiB,CAAC;AAMjE,gEAAgE;AAChE,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,MAAM,GAAuB,EAAE,CAAC;IACtC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC;IAE1B,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC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AE,GAAe;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,WAAW,CAAC,SAAS,GAAG,CAAC,CAAC;QAC1B,IAAI,KAA6B,CAAC;QAClC,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAClD,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YACtE,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@xyne/workflow-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Workflow engine SDK — steps, triggers, executor, agents, and a framework-agnostic HTTP router.",
5
+ "license": "UNLICENSED",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+ssh://git@ssh.bitbucket.juspay.net/xyne/xyne-spaces.git",
9
+ "directory": "packages/workflow-sdk"
10
+ },
11
+ "type": "module",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./types": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "import": "./dist/types/index.js"
26
+ },
27
+ "./common": {
28
+ "types": "./dist/common/index.d.ts",
29
+ "import": "./dist/common/index.js"
30
+ },
31
+ "./testing": {
32
+ "types": "./dist/testing/index.d.ts",
33
+ "import": "./dist/testing/index.js"
34
+ },
35
+ "./agents": {
36
+ "types": "./dist/agents/index.d.ts",
37
+ "import": "./dist/agents/index.js"
38
+ },
39
+ "./runtime": {
40
+ "types": "./dist/runtime/types.d.ts",
41
+ "import": "./dist/runtime/types.js"
42
+ },
43
+ "./router": {
44
+ "types": "./dist/router/types.d.ts",
45
+ "import": "./dist/router/types.js"
46
+ },
47
+ "./client": {
48
+ "types": "./dist/client/index.d.ts",
49
+ "import": "./dist/client/index.js"
50
+ },
51
+ "./builder": {
52
+ "types": "./dist/builder/index.d.ts",
53
+ "import": "./dist/builder/index.js"
54
+ }
55
+ },
56
+ "peerDependencies": {
57
+ "@earendil-works/pi-agent-core": ">=0.79.0",
58
+ "@earendil-works/pi-ai": ">=0.79.0",
59
+ "typebox": ">=1.1.0"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "@earendil-works/pi-agent-core": {
63
+ "optional": true
64
+ },
65
+ "@earendil-works/pi-ai": {
66
+ "optional": true
67
+ },
68
+ "typebox": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "scripts": {
73
+ "build": "tsc",
74
+ "watch": "tsc --watch",
75
+ "typecheck": "tsc --noEmit",
76
+ "test": "vitest run",
77
+ "test:watch": "vitest",
78
+ "test:coverage": "vitest run --coverage",
79
+ "prepublishOnly": "npm run build && npm test"
80
+ },
81
+ "dependencies": {
82
+ "zod": "^3.25.76",
83
+ "zod-to-json-schema": "^3.25.2"
84
+ },
85
+ "devDependencies": {
86
+ "@earendil-works/pi-agent-core": "^0.79.0",
87
+ "@earendil-works/pi-ai": "^0.79.0",
88
+ "@types/node": "^22.0.0",
89
+ "@vitest/coverage-v8": "^3.2.1",
90
+ "typebox": "^1.1.38",
91
+ "typescript": "^5.8.0",
92
+ "vitest": "^3.2.1"
93
+ },
94
+ "engines": {
95
+ "node": ">=20.0.0"
96
+ }
97
+ }