@workflow/core 4.0.1-beta.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 (143) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +3 -0
  3. package/dist/builtins.d.ts +4 -0
  4. package/dist/builtins.d.ts.map +1 -0
  5. package/dist/builtins.js +13 -0
  6. package/dist/builtins.js.map +1 -0
  7. package/dist/create-hook.d.ts +123 -0
  8. package/dist/create-hook.d.ts.map +1 -0
  9. package/dist/create-hook.js +32 -0
  10. package/dist/create-hook.js.map +1 -0
  11. package/dist/define-hook.d.ts +53 -0
  12. package/dist/define-hook.d.ts.map +1 -0
  13. package/dist/define-hook.js +59 -0
  14. package/dist/define-hook.js.map +1 -0
  15. package/dist/events-consumer.d.ts +35 -0
  16. package/dist/events-consumer.d.ts.map +1 -0
  17. package/dist/events-consumer.js +72 -0
  18. package/dist/events-consumer.js.map +1 -0
  19. package/dist/global.d.ts +29 -0
  20. package/dist/global.d.ts.map +1 -0
  21. package/dist/global.js +50 -0
  22. package/dist/global.js.map +1 -0
  23. package/dist/index.d.ts +18 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +18 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/logger.d.ts +31 -0
  28. package/dist/logger.d.ts.map +1 -0
  29. package/dist/logger.js +32 -0
  30. package/dist/logger.js.map +1 -0
  31. package/dist/observability.d.ts +24 -0
  32. package/dist/observability.d.ts.map +1 -0
  33. package/dist/observability.js +126 -0
  34. package/dist/observability.js.map +1 -0
  35. package/dist/parse-name.d.ts +25 -0
  36. package/dist/parse-name.d.ts.map +1 -0
  37. package/dist/parse-name.js +40 -0
  38. package/dist/parse-name.js.map +1 -0
  39. package/dist/private.d.ts +26 -0
  40. package/dist/private.d.ts.map +1 -0
  41. package/dist/private.js +17 -0
  42. package/dist/private.js.map +1 -0
  43. package/dist/runtime/resume-hook.d.ts +71 -0
  44. package/dist/runtime/resume-hook.d.ts.map +1 -0
  45. package/dist/runtime/resume-hook.js +180 -0
  46. package/dist/runtime/resume-hook.js.map +1 -0
  47. package/dist/runtime/start.d.ts +28 -0
  48. package/dist/runtime/start.d.ts.map +1 -0
  49. package/dist/runtime/start.js +57 -0
  50. package/dist/runtime/start.js.map +1 -0
  51. package/dist/runtime/world.d.ts +24 -0
  52. package/dist/runtime/world.d.ts.map +1 -0
  53. package/dist/runtime/world.js +84 -0
  54. package/dist/runtime/world.js.map +1 -0
  55. package/dist/runtime.d.ts +121 -0
  56. package/dist/runtime.d.ts.map +1 -0
  57. package/dist/runtime.js +554 -0
  58. package/dist/runtime.js.map +1 -0
  59. package/dist/schemas.d.ts +29 -0
  60. package/dist/schemas.d.ts.map +1 -0
  61. package/dist/schemas.js +15 -0
  62. package/dist/schemas.js.map +1 -0
  63. package/dist/serialization.d.ts +188 -0
  64. package/dist/serialization.d.ts.map +1 -0
  65. package/dist/serialization.js +725 -0
  66. package/dist/serialization.js.map +1 -0
  67. package/dist/step/context-storage.d.ts +8 -0
  68. package/dist/step/context-storage.d.ts.map +1 -0
  69. package/dist/step/context-storage.js +3 -0
  70. package/dist/step/context-storage.js.map +1 -0
  71. package/dist/step/get-step-metadata.d.ts +38 -0
  72. package/dist/step/get-step-metadata.d.ts.map +1 -0
  73. package/dist/step/get-step-metadata.js +14 -0
  74. package/dist/step/get-step-metadata.js.map +1 -0
  75. package/dist/step/get-workflow-metadata.d.ts +7 -0
  76. package/dist/step/get-workflow-metadata.d.ts.map +1 -0
  77. package/dist/step/get-workflow-metadata.js +12 -0
  78. package/dist/step/get-workflow-metadata.js.map +1 -0
  79. package/dist/step.d.ts +4 -0
  80. package/dist/step.d.ts.map +1 -0
  81. package/dist/step.js +92 -0
  82. package/dist/step.js.map +1 -0
  83. package/dist/symbols.d.ts +9 -0
  84. package/dist/symbols.d.ts.map +1 -0
  85. package/dist/symbols.js +9 -0
  86. package/dist/symbols.js.map +1 -0
  87. package/dist/telemetry/semantic-conventions.d.ts +175 -0
  88. package/dist/telemetry/semantic-conventions.d.ts.map +1 -0
  89. package/dist/telemetry/semantic-conventions.js +121 -0
  90. package/dist/telemetry/semantic-conventions.js.map +1 -0
  91. package/dist/telemetry.d.ts +24 -0
  92. package/dist/telemetry.d.ts.map +1 -0
  93. package/dist/telemetry.js +121 -0
  94. package/dist/telemetry.js.map +1 -0
  95. package/dist/types.d.ts +10 -0
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +39 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/util.d.ts +43 -0
  100. package/dist/util.d.ts.map +1 -0
  101. package/dist/util.js +76 -0
  102. package/dist/util.js.map +1 -0
  103. package/dist/vm/index.d.ts +17 -0
  104. package/dist/vm/index.d.ts.map +1 -0
  105. package/dist/vm/index.js +93 -0
  106. package/dist/vm/index.js.map +1 -0
  107. package/dist/vm/uuid.d.ts +10 -0
  108. package/dist/vm/uuid.d.ts.map +1 -0
  109. package/dist/vm/uuid.js +30 -0
  110. package/dist/vm/uuid.js.map +1 -0
  111. package/dist/workflow/create-hook.d.ts +7 -0
  112. package/dist/workflow/create-hook.d.ts.map +1 -0
  113. package/dist/workflow/create-hook.js +22 -0
  114. package/dist/workflow/create-hook.js.map +1 -0
  115. package/dist/workflow/define-hook.d.ts +10 -0
  116. package/dist/workflow/define-hook.d.ts.map +1 -0
  117. package/dist/workflow/define-hook.js +15 -0
  118. package/dist/workflow/define-hook.js.map +1 -0
  119. package/dist/workflow/get-workflow-metadata.d.ts +17 -0
  120. package/dist/workflow/get-workflow-metadata.d.ts.map +1 -0
  121. package/dist/workflow/get-workflow-metadata.js +11 -0
  122. package/dist/workflow/get-workflow-metadata.js.map +1 -0
  123. package/dist/workflow/hook.d.ts +4 -0
  124. package/dist/workflow/hook.d.ts.map +1 -0
  125. package/dist/workflow/hook.js +101 -0
  126. package/dist/workflow/hook.js.map +1 -0
  127. package/dist/workflow/index.d.ts +10 -0
  128. package/dist/workflow/index.d.ts.map +1 -0
  129. package/dist/workflow/index.js +14 -0
  130. package/dist/workflow/index.js.map +1 -0
  131. package/dist/workflow/writable-stream.d.ts +3 -0
  132. package/dist/workflow/writable-stream.d.ts.map +1 -0
  133. package/dist/workflow/writable-stream.js +12 -0
  134. package/dist/workflow/writable-stream.js.map +1 -0
  135. package/dist/workflow.d.ts +3 -0
  136. package/dist/workflow.d.ts.map +1 -0
  137. package/dist/workflow.js +454 -0
  138. package/dist/workflow.js.map +1 -0
  139. package/dist/writable-stream.d.ts +22 -0
  140. package/dist/writable-stream.d.ts.map +1 -0
  141. package/dist/writable-stream.js +16 -0
  142. package/dist/writable-stream.js.map +1 -0
  143. package/package.json +73 -0
package/dist/logger.js ADDED
@@ -0,0 +1,32 @@
1
+ import debug from 'debug';
2
+ import { getActiveSpan } from './telemetry.js';
3
+ function createLogger(namespace) {
4
+ const baseDebug = debug(`workflow:${namespace}`);
5
+ const logger = (level) => {
6
+ const levelDebug = baseDebug.extend(level);
7
+ return (message, metadata) => {
8
+ levelDebug(message, metadata);
9
+ if (levelDebug.enabled) {
10
+ getActiveSpan()
11
+ .then((span) => {
12
+ span?.addEvent(`${level}.${namespace}`, { message, ...metadata });
13
+ })
14
+ .catch(() => {
15
+ // Silently ignore telemetry errors
16
+ });
17
+ }
18
+ };
19
+ };
20
+ return {
21
+ debug: logger('debug'),
22
+ info: logger('info'),
23
+ warn: logger('warn'),
24
+ error: logger('error'),
25
+ };
26
+ }
27
+ export const stepLogger = createLogger('step');
28
+ export const runtimeLogger = createLogger('runtime');
29
+ export const webhookLogger = createLogger('webhook');
30
+ export const eventsLogger = createLogger('events');
31
+ export const adapterLogger = createLogger('adapter');
32
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,SAAS,YAAY,C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workflow inspection.
3
+ * Shared between CLI and Web UI for consistent behavior.
4
+ */
5
+ export declare const isStreamId: (value: unknown) => boolean;
6
+ export declare const hydrateResourceIO: <T extends {
7
+ stepId?: string;
8
+ hookId?: string;
9
+ eventId?: string;
10
+ input?: any;
11
+ output?: any;
12
+ metadata?: any;
13
+ eventData?: any;
14
+ executionContext?: any;
15
+ }>(resource: T) => T;
16
+ /**
17
+ * Extract all stream IDs from a value (recursively traverses objects/arrays)
18
+ */
19
+ export declare function extractStreamIds(obj: unknown): string[];
20
+ /**
21
+ * Truncate a string to a maximum length, adding ellipsis if needed
22
+ */
23
+ export declare function truncateId(id: string, maxLength?: number): string;
24
+ //# sourceMappingURL=observability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../src/observability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,OAE3C,CAAC;AA0FF,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,gBAAgB,CAAC,EAAE,GAAG,CAAC;CACxB,EAED,UAAU,CAAC,KACV,CAmBF,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAmBvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,MAAM,CAG7D"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Observability utilities for workflow inspection.
3
+ * Shared between CLI and Web UI for consistent behavior.
4
+ */
5
+ import { hydrateStepArguments, hydrateStepReturnValue, hydrateWorkflowArguments, hydrateWorkflowReturnValue, } from './serialization.js';
6
+ const STREAM_ID_PREFIX = 'strm_';
7
+ /*
8
+ * Check if a value is a stream ID
9
+ */
10
+ export const isStreamId = (value) => {
11
+ return typeof value === 'string' && value.startsWith(STREAM_ID_PREFIX);
12
+ };
13
+ const streamToStreamId = (value) => {
14
+ if ('name' in value) {
15
+ if (!value.name.startsWith(STREAM_ID_PREFIX)) {
16
+ return `${STREAM_ID_PREFIX}${value.name}`;
17
+ }
18
+ return value.name;
19
+ }
20
+ return `${STREAM_ID_PREFIX}null`;
21
+ };
22
+ /**
23
+ * This is an extra reviver for devalue that takes any streams that would be converted,
24
+ * into actual streams, and instead formats them as string links for printing in CLI output.
25
+ *
26
+ * This is mainly because we don't want to open any streams that we aren't going to read from,
27
+ * and so we can get the string ID/name, which the serializer stream doesn't provide.
28
+ */
29
+ const streamPrintRevivers = {
30
+ ReadableStream: streamToStreamId,
31
+ WritableStream: streamToStreamId,
32
+ TransformStream: streamToStreamId,
33
+ };
34
+ const hydrateStepIO = (step) => {
35
+ return {
36
+ ...step,
37
+ input: step.input && Array.isArray(step.input) && step.input.length
38
+ ? hydrateStepArguments(step.input, [], globalThis, streamPrintRevivers)
39
+ : step.input,
40
+ output: step.output
41
+ ? hydrateStepReturnValue(step.output, globalThis, streamPrintRevivers)
42
+ : step.output,
43
+ };
44
+ };
45
+ const hydrateWorkflowIO = (workflow) => {
46
+ return {
47
+ ...workflow,
48
+ input: workflow.input && Array.isArray(workflow.input) && workflow.input.length
49
+ ? hydrateWorkflowArguments(workflow.input, globalThis, streamPrintRevivers)
50
+ : workflow.input,
51
+ output: workflow.output
52
+ ? hydrateWorkflowReturnValue(workflow.output, [], globalThis, streamPrintRevivers)
53
+ : workflow.output,
54
+ };
55
+ };
56
+ const hydrateEventData = (event) => {
57
+ return {
58
+ ...event,
59
+ eventData: event.eventData
60
+ ? hydrateStepArguments(event.eventData, [], globalThis)
61
+ : event.eventData,
62
+ };
63
+ };
64
+ const hydrateHookMetadata = (hook) => {
65
+ return {
66
+ ...hook,
67
+ metadata: hook.metadata
68
+ ? hydrateStepArguments(hook.metadata, [], globalThis)
69
+ : hook.metadata,
70
+ };
71
+ };
72
+ export const hydrateResourceIO = (resource) => {
73
+ if (!resource) {
74
+ return resource;
75
+ }
76
+ let hydrated;
77
+ if ('stepId' in resource) {
78
+ hydrated = hydrateStepIO(resource);
79
+ }
80
+ else if ('hookId' in resource) {
81
+ hydrated = hydrateHookMetadata(resource);
82
+ }
83
+ else if ('eventId' in resource) {
84
+ hydrated = hydrateEventData(resource);
85
+ }
86
+ else {
87
+ hydrated = hydrateWorkflowIO(resource);
88
+ }
89
+ if ('executionContext' in hydrated) {
90
+ const { executionContext: _, ...rest } = hydrated;
91
+ return rest;
92
+ }
93
+ return hydrated;
94
+ };
95
+ /**
96
+ * Extract all stream IDs from a value (recursively traverses objects/arrays)
97
+ */
98
+ export function extractStreamIds(obj) {
99
+ const streamIds = [];
100
+ function traverse(value) {
101
+ if (isStreamId(value)) {
102
+ streamIds.push(value);
103
+ }
104
+ else if (Array.isArray(value)) {
105
+ for (const item of value) {
106
+ traverse(item);
107
+ }
108
+ }
109
+ else if (value && typeof value === 'object') {
110
+ for (const val of Object.values(value)) {
111
+ traverse(val);
112
+ }
113
+ }
114
+ }
115
+ traverse(obj);
116
+ return Array.from(new Set(streamIds)); // Remove duplicates
117
+ }
118
+ /**
119
+ * Truncate a string to a maximum length, adding ellipsis if needed
120
+ */
121
+ export function truncateId(id, maxLength = 12) {
122
+ if (id.length <= maxLength)
123
+ return id;
124
+ return `${id.slice(0, maxLength)}...`;
125
+ }
126
+ //# sourceMappingURL=observability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability.js","sourceRoot":"","sources":["../src/observability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,wBA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;IAED,QAAQ,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,oBAAoB;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,SAAS,GAAG,EAAE;IACnD,IAAI,EAAE,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC;AACxC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Parse a workflow name into its components.
3
+ *
4
+ * @param name - The workflow name to parse.
5
+ * @returns An object with `shortName`, `path`, and `functionName` properties.
6
+ * When the name is invalid, returns `null`.
7
+ */
8
+ export declare function parseWorkflowName(name: string): {
9
+ shortName: string;
10
+ path: string;
11
+ functionName: string;
12
+ } | null;
13
+ /**
14
+ * Parse a step name into its components.
15
+ *
16
+ * @param name - The step name to parse.
17
+ * @returns An object with `shortName`, `path`, and `functionName` properties.
18
+ * When the name is invalid, returns `null`.
19
+ */
20
+ export declare function parseStepName(name: string): {
21
+ shortName: string;
22
+ path: string;
23
+ functionName: string;
24
+ } | null;
25
+ //# sourceMappingURL=parse-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-name.d.ts","sourceRoot":"","sources":["../src/parse-name.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM;eAvB9B,MAAM;UAAQ,MAAM;kBAAgB,MAAM;SAyBzD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM;eAlC1B,MAAM;UAAQ,MAAM;kBAAgB,MAAM;SAoCzD"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Parse a machine readable name.
3
+ *
4
+ * @see {@link ../../swc-plugin-workflow/transform/src/naming.rs} for the naming scheme.
5
+ */
6
+ function parseName(tag, name) {
7
+ if (typeof name !== 'string') {
8
+ return null;
9
+ }
10
+ const [prefix, path, ...functionNameParts] = name.split('//');
11
+ if (prefix !== tag || !path || functionNameParts.length === 0) {
12
+ return null;
13
+ }
14
+ return {
15
+ shortName: functionNameParts.at(-1) ?? '',
16
+ path,
17
+ functionName: functionNameParts.join('//'),
18
+ };
19
+ }
20
+ /**
21
+ * Parse a workflow name into its components.
22
+ *
23
+ * @param name - The workflow name to parse.
24
+ * @returns An object with `shortName`, `path`, and `functionName` properties.
25
+ * When the name is invalid, returns `null`.
26
+ */
27
+ export function parseWorkflowName(name) {
28
+ return parseName('workflow', name);
29
+ }
30
+ /**
31
+ * Parse a step name into its components.
32
+ *
33
+ * @param name - The step name to parse.
34
+ * @returns An object with `shortName`, `path`, and `functionName` properties.
35
+ * When the name is invalid, returns `null`.
36
+ */
37
+ export function parseStepName(name) {
38
+ return parseName('step', name);
39
+ }
40
+ //# sourceMappingURL=parse-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-name.js","sourceRoot":"","sources":["../src/parse-name.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,SAAS,SAAS,CAChB,GAAW,EACX,IAAY;IAEZ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,SAAS,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;QACzC,IAAI;QACJ,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Utils used by the bundler when transforming code
3
+ */
4
+ import type { EventsConsumer } from './events-consumer.js';
5
+ import type { QueueItem } from './global.js';
6
+ import type { Serializable } from './schemas.js';
7
+ export type StepFunction<Args extends Serializable[] = any[], Result extends Serializable | unknown = unknown> = ((...args: Args) => Promise<Result>) & {
8
+ maxRetries?: number;
9
+ };
10
+ /**
11
+ * Register a step function to be served in the server bundle
12
+ */
13
+ export declare function registerStepFunction(stepId: string, stepFn: StepFunction): void;
14
+ /**
15
+ * Find a registered step function by name
16
+ */
17
+ export declare function getStepFunction(stepId: string): StepFunction | undefined;
18
+ export interface WorkflowOrchestratorContext {
19
+ globalThis: typeof globalThis;
20
+ eventsConsumer: EventsConsumer;
21
+ invocationsQueue: QueueItem[];
22
+ onWorkflowError: (error: Error) => void;
23
+ generateUlid: () => string;
24
+ generateNanoid: () => string;
25
+ }
26
+ //# sourceMappingURL=private.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.d.ts","sourceRoot":"","sources":["../src/private.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,YAAY,CACtB,IAAI,SAAS,YAAY,EAAE,GAAG,GAAG,EAAE,EACnC,MAAM,SAAS,YAAY,GAAG,OAAO,GAAG,OAAO,IAC7C,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,QAExE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAExE;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,SAAS,EAAE,CAAC;IAC9B,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Utils used by the bundler when transforming code
3
+ */
4
+ const registeredSteps = new Map();
5
+ /**
6
+ * Register a step function to be served in the server bundle
7
+ */
8
+ export function registerStepFunction(stepId, stepFn) {
9
+ registeredSteps.set(stepId, stepFn);
10
+ }
11
+ /**
12
+ * Find a registered step function by name
13
+ */
14
+ export function getStepFunction(stepId) {
15
+ return registeredSteps.get(stepId);
16
+ }
17
+ //# sourceMappingURL=private.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private.js","sourceRoot":"","sources":["../src/private.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,MAAM,eAAe,GAAG,IAAI,GAAG,EAAwB,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAoB;IACvE,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { Hook } from '@workflow/world';
2
+ /**
3
+ * Get the hook by token to find the associated workflow run,
4
+ * and hydrate the `metadata` property if it was set from within
5
+ * the workflow run.
6
+ *
7
+ * @param token - The unique token identifying the hook
8
+ */
9
+ export declare function getHookByToken(token: string): Promise<Hook>;
10
+ /**
11
+ * Resumes a workflow run by sending a payload to a hook identified by its token.
12
+ *
13
+ * This function is called externally (e.g., from an API route or server action)
14
+ * to send data to a hook and resume the associated workflow run.
15
+ *
16
+ * @param token - The unique token identifying the hook
17
+ * @param payload - The data payload to send to the hook
18
+ * @returns Promise resolving to an object with the runId, or null if the hook doesn't exist
19
+ *
20
+ * @example
21
+ *
22
+ * ```ts
23
+ * // In an API route
24
+ * import { resumeHook } from '@workflow/core/runtime';
25
+ *
26
+ * export async function POST(request: Request) {
27
+ * const { token, data } = await request.json();
28
+ * const result = await resumeHook(token, data);
29
+ *
30
+ * if (!result) {
31
+ * return new Response('Hook not found', { status: 404 });
32
+ * }
33
+ *
34
+ * return Response.json({ runId: result.runId });
35
+ * }
36
+ * ```
37
+ */
38
+ export declare function resumeHook<T = any>(token: string, payload: T): Promise<Hook | null>;
39
+ /**
40
+ * Resumes a webhook by sending a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}
41
+ * object to a hook identified by its token.
42
+ *
43
+ * This function is called externally (e.g., from an API route or server action)
44
+ * to send a request to a webhook and resume the associated workflow run.
45
+ *
46
+ * @param token - The unique token identifying the hook
47
+ * @param request - The request to send to the hook
48
+ * @returns Promise resolving to the response, or null if the hook doesn't exist
49
+ *
50
+ * @example
51
+ *
52
+ * ```ts
53
+ * // In an API route
54
+ * import { resumeWebhook } from '@workflow/core/runtime';
55
+ *
56
+ * export async function POST(request: Request) {
57
+ * const url = new URL(request.url);
58
+ * const token = url.searchParams.get('token');
59
+ *
60
+ * if (!token) {
61
+ * return new Response('Missing token', { status: 400 });
62
+ * }
63
+ *
64
+ * const response = await resumeWebhook(token, request);
65
+ *
66
+ * return response ?? new Response('Webhook not found', { status: 404 });
67
+ * }
68
+ * ```
69
+ */
70
+ export declare function resumeWebhook(token: string, request: Request): Promise<Response>;
71
+ //# sourceMappingURL=resume-hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume-hook.d.ts","sourceRoot":"","sources":["../../src/runtime/resume-hook.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAW5C;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,EACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,GACT,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAuEtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAkDnB"}
@@ -0,0 +1,180 @@
1
+ import { waitUntil } from '@vercel/functions';
2
+ import { ERROR_SLUGS, WorkflowRuntimeError } from '@workflow/errors';
3
+ import { dehydrateStepReturnValue, hydrateStepArguments, } from '../serialization.js';
4
+ import { WEBHOOK_RESPONSE_WRITABLE } from '../symbols.js';
5
+ import * as Attribute from '../telemetry/semantic-conventions.js';
6
+ import { getSpanContextForTraceCarrier, trace } from '../telemetry.js';
7
+ import { getWorld } from './world.js';
8
+ /**
9
+ * Get the hook by token to find the associated workflow run,
10
+ * and hydrate the `metadata` property if it was set from within
11
+ * the workflow run.
12
+ *
13
+ * @param token - The unique token identifying the hook
14
+ */
15
+ export async function getHookByToken(token) {
16
+ const world = getWorld();
17
+ const hook = await world.hooks.getByToken(token);
18
+ if (typeof hook.metadata !== 'undefined') {
19
+ hook.metadata = hydrateStepArguments(hook.metadata, [], globalThis);
20
+ }
21
+ return hook;
22
+ }
23
+ /**
24
+ * Resumes a workflow run by sending a payload to a hook identified by its token.
25
+ *
26
+ * This function is called externally (e.g., from an API route or server action)
27
+ * to send data to a hook and resume the associated workflow run.
28
+ *
29
+ * @param token - The unique token identifying the hook
30
+ * @param payload - The data payload to send to the hook
31
+ * @returns Promise resolving to an object with the runId, or null if the hook doesn't exist
32
+ *
33
+ * @example
34
+ *
35
+ * ```ts
36
+ * // In an API route
37
+ * import { resumeHook } from '@workflow/core/runtime';
38
+ *
39
+ * export async function POST(request: Request) {
40
+ * const { token, data } = await request.json();
41
+ * const result = await resumeHook(token, data);
42
+ *
43
+ * if (!result) {
44
+ * return new Response('Hook not found', { status: 404 });
45
+ * }
46
+ *
47
+ * return Response.json({ runId: result.runId });
48
+ * }
49
+ * ```
50
+ */
51
+ export async function resumeHook(token, payload) {
52
+ return trace('HOOK.resume', async (span) => {
53
+ const world = getWorld();
54
+ try {
55
+ const hook = await getHookByToken(token);
56
+ span?.setAttributes({
57
+ ...Attribute.HookToken(token),
58
+ ...Attribute.HookId(hook.hookId),
59
+ ...Attribute.WorkflowRunId(hook.runId),
60
+ });
61
+ // Dehydrate the payload for storage
62
+ const ops = [];
63
+ const dehydratedPayload = dehydrateStepReturnValue(payload, ops, globalThis);
64
+ waitUntil(Promise.all(ops));
65
+ // Create a hook_received event with the payload
66
+ await world.events.create(hook.runId, {
67
+ eventType: 'hook_received',
68
+ correlationId: hook.hookId,
69
+ eventData: {
70
+ payload: dehydratedPayload,
71
+ },
72
+ });
73
+ const workflowRun = await world.runs.get(hook.runId);
74
+ span?.setAttributes({
75
+ ...Attribute.WorkflowName(workflowRun.workflowName),
76
+ });
77
+ const traceCarrier = workflowRun.executionContext?.traceCarrier;
78
+ if (traceCarrier) {
79
+ const context = await getSpanContextForTraceCarrier(traceCarrier);
80
+ if (context) {
81
+ span?.addLink?.({ context });
82
+ }
83
+ }
84
+ // Re-trigger the workflow against the deployment ID associated
85
+ // with the workflow run that the hook belongs to
86
+ await world.queue(`__wkf_workflow_${workflowRun.workflowName}`, {
87
+ runId: hook.runId,
88
+ // attach the trace carrier from the workflow run
89
+ traceCarrier: workflowRun.executionContext?.traceCarrier ?? undefined,
90
+ }, {
91
+ deploymentId: workflowRun.deploymentId,
92
+ });
93
+ return hook;
94
+ }
95
+ catch (_err) {
96
+ // If hook not found, return null
97
+ span?.setAttributes({
98
+ ...Attribute.HookToken(token),
99
+ ...Attribute.HookFound(false),
100
+ });
101
+ // TODO: Check for specific error types
102
+ return null;
103
+ }
104
+ });
105
+ }
106
+ /**
107
+ * Resumes a webhook by sending a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}
108
+ * object to a hook identified by its token.
109
+ *
110
+ * This function is called externally (e.g., from an API route or server action)
111
+ * to send a request to a webhook and resume the associated workflow run.
112
+ *
113
+ * @param token - The unique token identifying the hook
114
+ * @param request - The request to send to the hook
115
+ * @returns Promise resolving to the response, or null if the hook doesn't exist
116
+ *
117
+ * @example
118
+ *
119
+ * ```ts
120
+ * // In an API route
121
+ * import { resumeWebhook } from '@workflow/core/runtime';
122
+ *
123
+ * export async function POST(request: Request) {
124
+ * const url = new URL(request.url);
125
+ * const token = url.searchParams.get('token');
126
+ *
127
+ * if (!token) {
128
+ * return new Response('Missing token', { status: 400 });
129
+ * }
130
+ *
131
+ * const response = await resumeWebhook(token, request);
132
+ *
133
+ * return response ?? new Response('Webhook not found', { status: 404 });
134
+ * }
135
+ * ```
136
+ */
137
+ export async function resumeWebhook(token, request) {
138
+ const hook = await getHookByToken(token);
139
+ let response;
140
+ let responseReadable;
141
+ if (hook.metadata &&
142
+ typeof hook.metadata === 'object' &&
143
+ 'respondWith' in hook.metadata) {
144
+ if (hook.metadata.respondWith === 'manual') {
145
+ const { readable, writable } = new TransformStream();
146
+ responseReadable = readable;
147
+ // The request instance includes the writable stream which will be used
148
+ // to write the response to the client from within the workflow run
149
+ request[WEBHOOK_RESPONSE_WRITABLE] = writable;
150
+ }
151
+ else if (hook.metadata.respondWith instanceof Response) {
152
+ response = hook.metadata.respondWith;
153
+ }
154
+ else {
155
+ throw new WorkflowRuntimeError(`Invalid \`respondWith\` value: ${hook.metadata.respondWith}`, { slug: ERROR_SLUGS.WEBHOOK_INVALID_RESPOND_WITH_VALUE });
156
+ }
157
+ }
158
+ else {
159
+ // No `respondWith` value implies the default behavior of returning a 202
160
+ response = new Response(null, { status: 202 });
161
+ }
162
+ await resumeHook(hook.token, request);
163
+ if (responseReadable) {
164
+ // Wait for the readable stream to emit one chunk,
165
+ // which is the `Response` object
166
+ const reader = responseReadable.getReader();
167
+ const chunk = await reader.read();
168
+ if (chunk.value) {
169
+ response = chunk.value;
170
+ }
171
+ reader.cancel();
172
+ }
173
+ if (!response) {
174
+ throw new WorkflowRuntimeError('Workflow run did not send a response', {
175
+ slug: ERROR_SLUGS.WEBHOOK_RESPONSE_NOT_SENT,
176
+ });
177
+ }
178
+ return response;
179
+ }
180
+ //# sourceMappingURL=resume-hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume-hook.js","sourceRoot":"","sources":["../../src/runtime/resume-hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,SAAS,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEt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AC,IAAI,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,oBAAoB,CAAC,sCAAsC,EAAE;YACrE,IAAI,EAAE,WAAW,CAAC,yBAAyB;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Run } from '../runtime.js';
2
+ export interface StartOptions {
3
+ /**
4
+ * The deployment ID to use for the workflow run.
5
+ */
6
+ deploymentId?: string;
7
+ }
8
+ /**
9
+ * Represents an imported workflow function.
10
+ */
11
+ export type WorkflowFunction<TArgs extends unknown[], TResult> = (...args: TArgs) => Promise<TResult>;
12
+ /**
13
+ * Represents the generated metadata of a workflow function.
14
+ */
15
+ export type WorkflowMetadata = {
16
+ workflowId: string;
17
+ };
18
+ /**
19
+ * Starts a workflow run.
20
+ *
21
+ * @param workflow - The imported workflow function to start.
22
+ * @param args - The arguments to pass to the workflow (optional).
23
+ * @param options - The options for the workflow run (optional).
24
+ * @returns The unique run ID for the newly started workflow invocation.
25
+ */
26
+ export declare function start<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, args: TArgs, options?: StartOptions): Promise<Run<TResult>>;
27
+ export declare function start<TArgs extends unknown[], TResult>(workflow: WorkflowFunction<TArgs, TResult> | WorkflowMetadata, options?: StartOptions): Promise<Run<TResult>>;
28
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/runtime/start.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAOpC,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,IAAI,CAC/D,GAAG,IAAI,EAAE,KAAK,KACX,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACpD,QAAQ,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,gBAAgB,EAC7D,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAEzB,wBAAgB,KAAK,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EACpD,QAAQ,EAAE,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,gBAAgB,EAC7D,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC"}