@workflow/world-vercel 4.0.1-beta.8 → 4.1.0-beta.29
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.
- package/dist/events.d.ts +2 -2
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +49 -12
- package/dist/events.js.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +8 -13
- package/dist/hooks.js.map +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +105 -30
- package/dist/queue.js.map +1 -1
- package/dist/runs.d.ts +23 -8
- package/dist/runs.d.ts.map +1 -1
- package/dist/runs.js +22 -95
- package/dist/runs.js.map +1 -1
- package/dist/steps.d.ts +53 -3
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +83 -31
- package/dist/steps.js.map +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +7 -16
- package/dist/storage.js.map +1 -1
- package/dist/streamer.d.ts.map +1 -1
- package/dist/streamer.js +22 -7
- package/dist/streamer.js.map +1 -1
- package/dist/utils.d.ts +16 -13
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +139 -51
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +8 -6
- package/dist/backend.d.ts +0 -4
- package/dist/backend.d.ts.map +0 -1
- package/dist/backend.js +0 -18
- package/dist/backend.js.map +0 -1
package/dist/runs.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { WorkflowAPIError, WorkflowRunNotFoundError } from '@workflow/errors';
|
|
2
|
-
import { PaginatedResponseSchema, WorkflowRunBaseSchema, } from '@workflow/world';
|
|
2
|
+
import { PaginatedResponseSchema, StructuredErrorSchema, WorkflowRunBaseSchema, } from '@workflow/world';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { DEFAULT_RESOLVE_DATA_OPTION,
|
|
4
|
+
import { DEFAULT_RESOLVE_DATA_OPTION, deserializeError, makeRequest, } from './utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Wire format schema for workflow runs coming from the backend.
|
|
7
|
-
* The backend
|
|
8
|
-
*
|
|
7
|
+
* The backend may return error either as:
|
|
8
|
+
* - A JSON string (legacy format) that needs deserialization
|
|
9
|
+
* - An already structured object (new format) with { message, stack?, code? }
|
|
9
10
|
*
|
|
10
11
|
* This is used for validation in makeRequest(), then deserializeError()
|
|
11
|
-
*
|
|
12
|
+
* normalizes both formats into the expected StructuredError object.
|
|
12
13
|
*/
|
|
13
14
|
const WorkflowRunWireBaseSchema = WorkflowRunBaseSchema.omit({
|
|
14
15
|
error: true,
|
|
15
16
|
}).extend({
|
|
16
|
-
// Backend returns error as a JSON string
|
|
17
|
-
error: z.string().optional(),
|
|
17
|
+
// Backend returns error as either a JSON string or structured object
|
|
18
|
+
error: z.union([z.string(), StructuredErrorSchema]).optional(),
|
|
18
19
|
});
|
|
19
20
|
// Wire schema for resolved data (full input/output)
|
|
20
21
|
const WorkflowRunWireSchema = WorkflowRunWireBaseSchema;
|
|
21
22
|
// Wire schema for lazy mode with refs instead of data
|
|
23
|
+
// input/output can be Uint8Array (v2) or any JSON (legacy v1)
|
|
22
24
|
const WorkflowRunWireWithRefsSchema = WorkflowRunWireBaseSchema.omit({
|
|
23
25
|
input: true,
|
|
24
26
|
output: true,
|
|
@@ -26,27 +28,25 @@ const WorkflowRunWireWithRefsSchema = WorkflowRunWireBaseSchema.omit({
|
|
|
26
28
|
// We discard the results of the refs, so we don't care about the type here
|
|
27
29
|
inputRef: z.any().optional(),
|
|
28
30
|
outputRef: z.any().optional(),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
// Accept both Uint8Array (v2 format) and any (legacy v1 JSON format)
|
|
32
|
+
input: z.union([z.instanceof(Uint8Array), z.any()]).optional(),
|
|
33
|
+
output: z.union([z.instanceof(Uint8Array), z.any()]).optional(),
|
|
34
|
+
blobStorageBytes: z.number().optional(),
|
|
35
|
+
streamStorageBytes: z.number().optional(),
|
|
31
36
|
});
|
|
32
|
-
//
|
|
37
|
+
// Implementation
|
|
33
38
|
function filterRunData(run, resolveData) {
|
|
34
39
|
if (resolveData === 'none') {
|
|
35
40
|
const { inputRef: _inputRef, outputRef: _outputRef, ...rest } = run;
|
|
36
41
|
const deserialized = deserializeError(rest);
|
|
37
42
|
return {
|
|
38
43
|
...deserialized,
|
|
39
|
-
input:
|
|
44
|
+
input: undefined,
|
|
40
45
|
output: undefined,
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
return deserializeError(run);
|
|
44
49
|
}
|
|
45
|
-
// Functions
|
|
46
|
-
/**
|
|
47
|
-
* This query technically works but should be used sparingly till the backend
|
|
48
|
-
* uses CH to resolve this instead of scanning a dynamo table.
|
|
49
|
-
*/
|
|
50
50
|
export async function listWorkflowRuns(params = {}, config) {
|
|
51
51
|
const { workflowName, status, pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION, } = params;
|
|
52
52
|
const searchParams = new URLSearchParams();
|
|
@@ -64,7 +64,7 @@ export async function listWorkflowRuns(params = {}, config) {
|
|
|
64
64
|
const remoteRefBehavior = resolveData === 'none' ? 'lazy' : 'resolve';
|
|
65
65
|
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
66
66
|
const queryString = searchParams.toString();
|
|
67
|
-
const endpoint = `/
|
|
67
|
+
const endpoint = `/v2/runs${queryString ? `?${queryString}` : ''}`;
|
|
68
68
|
const response = (await makeRequest({
|
|
69
69
|
endpoint,
|
|
70
70
|
options: { method: 'GET' },
|
|
@@ -78,13 +78,11 @@ export async function listWorkflowRuns(params = {}, config) {
|
|
|
78
78
|
data: response.data.map((run) => filterRunData(run, resolveData)),
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
export async function
|
|
81
|
+
export async function createWorkflowRunV1(data, config) {
|
|
82
82
|
const run = await makeRequest({
|
|
83
83
|
endpoint: '/v1/runs/create',
|
|
84
|
-
options: {
|
|
85
|
-
|
|
86
|
-
body: JSON.stringify(data, dateToStringReplacer),
|
|
87
|
-
},
|
|
84
|
+
options: { method: 'POST' },
|
|
85
|
+
data,
|
|
88
86
|
config,
|
|
89
87
|
schema: WorkflowRunWireSchema,
|
|
90
88
|
});
|
|
@@ -96,7 +94,7 @@ export async function getWorkflowRun(id, params, config) {
|
|
|
96
94
|
const searchParams = new URLSearchParams();
|
|
97
95
|
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
98
96
|
const queryString = searchParams.toString();
|
|
99
|
-
const endpoint = `/
|
|
97
|
+
const endpoint = `/v2/runs/${id}${queryString ? `?${queryString}` : ''}`;
|
|
100
98
|
try {
|
|
101
99
|
const run = await makeRequest({
|
|
102
100
|
endpoint,
|
|
@@ -115,28 +113,7 @@ export async function getWorkflowRun(id, params, config) {
|
|
|
115
113
|
throw error;
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
|
-
export async function
|
|
119
|
-
try {
|
|
120
|
-
const serialized = serializeError(data);
|
|
121
|
-
const run = await makeRequest({
|
|
122
|
-
endpoint: `/v1/runs/${id}`,
|
|
123
|
-
options: {
|
|
124
|
-
method: 'PUT',
|
|
125
|
-
body: JSON.stringify(serialized, dateToStringReplacer),
|
|
126
|
-
},
|
|
127
|
-
config,
|
|
128
|
-
schema: WorkflowRunWireSchema,
|
|
129
|
-
});
|
|
130
|
-
return deserializeError(run);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
if (error instanceof WorkflowAPIError && error.status === 404) {
|
|
134
|
-
throw new WorkflowRunNotFoundError(id);
|
|
135
|
-
}
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
export async function cancelWorkflowRun(id, params, config) {
|
|
116
|
+
export async function cancelWorkflowRunV1(id, params, config) {
|
|
140
117
|
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
141
118
|
const remoteRefBehavior = resolveData === 'none' ? 'lazy' : 'resolve';
|
|
142
119
|
const searchParams = new URLSearchParams();
|
|
@@ -161,54 +138,4 @@ export async function cancelWorkflowRun(id, params, config) {
|
|
|
161
138
|
throw error;
|
|
162
139
|
}
|
|
163
140
|
}
|
|
164
|
-
export async function pauseWorkflowRun(id, params, config) {
|
|
165
|
-
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
166
|
-
const remoteRefBehavior = resolveData === 'none' ? 'lazy' : 'resolve';
|
|
167
|
-
const searchParams = new URLSearchParams();
|
|
168
|
-
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
169
|
-
const queryString = searchParams.toString();
|
|
170
|
-
const endpoint = `/v1/runs/${id}/pause${queryString ? `?${queryString}` : ''}`;
|
|
171
|
-
try {
|
|
172
|
-
const run = await makeRequest({
|
|
173
|
-
endpoint,
|
|
174
|
-
options: { method: 'PUT' },
|
|
175
|
-
config,
|
|
176
|
-
schema: (remoteRefBehavior === 'lazy'
|
|
177
|
-
? WorkflowRunWireWithRefsSchema
|
|
178
|
-
: WorkflowRunWireSchema),
|
|
179
|
-
});
|
|
180
|
-
return filterRunData(run, resolveData);
|
|
181
|
-
}
|
|
182
|
-
catch (error) {
|
|
183
|
-
if (error instanceof WorkflowAPIError && error.status === 404) {
|
|
184
|
-
throw new WorkflowRunNotFoundError(id);
|
|
185
|
-
}
|
|
186
|
-
throw error;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
export async function resumeWorkflowRun(id, params, config) {
|
|
190
|
-
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
191
|
-
const remoteRefBehavior = resolveData === 'none' ? 'lazy' : 'resolve';
|
|
192
|
-
const searchParams = new URLSearchParams();
|
|
193
|
-
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
194
|
-
const queryString = searchParams.toString();
|
|
195
|
-
const endpoint = `/v1/runs/${id}/resume${queryString ? `?${queryString}` : ''}`;
|
|
196
|
-
try {
|
|
197
|
-
const run = await makeRequest({
|
|
198
|
-
endpoint,
|
|
199
|
-
options: { method: 'PUT' },
|
|
200
|
-
config,
|
|
201
|
-
schema: (remoteRefBehavior === 'lazy'
|
|
202
|
-
? WorkflowRunWireWithRefsSchema
|
|
203
|
-
: WorkflowRunWireSchema),
|
|
204
|
-
});
|
|
205
|
-
return filterRunData(run, resolveData);
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
if (error instanceof WorkflowAPIError && error.status === 404) {
|
|
209
|
-
throw new WorkflowRunNotFoundError(id);
|
|
210
|
-
}
|
|
211
|
-
throw error;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
141
|
//# sourceMappingURL=runs.js.map
|
package/dist/runs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAML,uBAAuB,
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAML,uBAAuB,EACvB,qBAAqB,EAErB,qBAAqB,GAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;GAQG;AACH,MAAM,yBAAyB,GAAG,qBAAqB,CAAC,IAAI,CAAC;IAC3D,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC,MAAM,CAAC;IACR,qEAAqE;IACrE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,q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AAC,qBAAqB,CAAQ;SAClC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC9D,MAAM,IAAI,wBAAwB,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/steps.d.ts
CHANGED
|
@@ -1,7 +1,57 @@
|
|
|
1
|
-
import { type CreateStepRequest, type GetStepParams, type ListWorkflowRunStepsParams, type PaginatedResponse, type Step, type UpdateStepRequest } from '@workflow/world';
|
|
1
|
+
import { type CreateStepRequest, type GetStepParams, type ListWorkflowRunStepsParams, type PaginatedResponse, type Step, type StepWithoutData, type UpdateStepRequest } from '@workflow/world';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import type { APIConfig } from './utils.js';
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Wire format schema for steps coming from the backend.
|
|
6
|
+
* Handles error deserialization from wire format.
|
|
7
|
+
*/
|
|
8
|
+
export declare const StepWireSchema: z.ZodObject<{
|
|
9
|
+
output: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>>;
|
|
10
|
+
input: z.ZodUnion<readonly [z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>]>;
|
|
11
|
+
status: z.ZodEnum<{
|
|
12
|
+
pending: "pending";
|
|
13
|
+
running: "running";
|
|
14
|
+
completed: "completed";
|
|
15
|
+
failed: "failed";
|
|
16
|
+
cancelled: "cancelled";
|
|
17
|
+
}>;
|
|
18
|
+
runId: z.ZodString;
|
|
19
|
+
specVersion: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
startedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
21
|
+
completedAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
22
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
23
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
24
|
+
stepId: z.ZodString;
|
|
25
|
+
stepName: z.ZodString;
|
|
26
|
+
attempt: z.ZodNumber;
|
|
27
|
+
retryAfter: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
28
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
29
|
+
message: z.ZodString;
|
|
30
|
+
stack: z.ZodOptional<z.ZodString>;
|
|
31
|
+
code: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>]>>;
|
|
33
|
+
errorRef: z.ZodOptional<z.ZodAny>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/**
|
|
36
|
+
* Transform step from wire format to Step interface format.
|
|
37
|
+
* Maps:
|
|
38
|
+
* - error/errorRef → error (deserializing JSON string to StructuredError)
|
|
39
|
+
*/
|
|
40
|
+
export declare function deserializeStep(wireStep: any): Step;
|
|
41
|
+
export declare function listWorkflowRunSteps(params: ListWorkflowRunStepsParams & {
|
|
42
|
+
resolveData: 'none';
|
|
43
|
+
}, config?: APIConfig): Promise<PaginatedResponse<StepWithoutData>>;
|
|
44
|
+
export declare function listWorkflowRunSteps(params: ListWorkflowRunStepsParams & {
|
|
45
|
+
resolveData?: 'all';
|
|
46
|
+
}, config?: APIConfig): Promise<PaginatedResponse<Step>>;
|
|
47
|
+
export declare function listWorkflowRunSteps(params: ListWorkflowRunStepsParams, config?: APIConfig): Promise<PaginatedResponse<Step | StepWithoutData>>;
|
|
4
48
|
export declare function createStep(runId: string, data: CreateStepRequest, config?: APIConfig): Promise<Step>;
|
|
5
49
|
export declare function updateStep(runId: string, stepId: string, data: UpdateStepRequest, config?: APIConfig): Promise<Step>;
|
|
6
|
-
export declare function getStep(runId: string | undefined, stepId: string, params
|
|
50
|
+
export declare function getStep(runId: string | undefined, stepId: string, params: GetStepParams & {
|
|
51
|
+
resolveData: 'none';
|
|
52
|
+
}, config?: APIConfig): Promise<StepWithoutData>;
|
|
53
|
+
export declare function getStep(runId: string | undefined, stepId: string, params?: GetStepParams & {
|
|
54
|
+
resolveData?: 'all';
|
|
55
|
+
}, config?: APIConfig): Promise<Step>;
|
|
56
|
+
export declare function getStep(runId: string | undefined, stepId: string, params?: GetStepParams, config?: APIConfig): Promise<Step | StepWithoutData>;
|
|
7
57
|
//# sourceMappingURL=steps.d.ts.map
|
package/dist/steps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAET,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EAET,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBzB,CAAC;AAcH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAy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CAAC,IAAI,CAAC,CAAC;AACjB,wBAAsB,OAAO,CAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC"}
|
package/dist/steps.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { PaginatedResponseSchema, StepSchema, } from '@workflow/world';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { DEFAULT_RESOLVE_DATA_OPTION,
|
|
3
|
+
import { DEFAULT_RESOLVE_DATA_OPTION, makeRequest, serializeError, } from './utils.js';
|
|
4
4
|
/**
|
|
5
5
|
* Wire format schema for steps coming from the backend.
|
|
6
|
-
*
|
|
7
|
-
* a schema that accepts the wire format before deserialization.
|
|
8
|
-
*
|
|
9
|
-
* This is used for validation in makeRequest(), then deserializeStepError()
|
|
10
|
-
* transforms the string into the expected StructuredError object.
|
|
6
|
+
* Handles error deserialization from wire format.
|
|
11
7
|
*/
|
|
12
|
-
const StepWireSchema = StepSchema.omit({
|
|
8
|
+
export const StepWireSchema = StepSchema.omit({
|
|
13
9
|
error: true,
|
|
14
10
|
}).extend({
|
|
15
|
-
// Backend returns error as
|
|
16
|
-
|
|
11
|
+
// Backend returns error either as:
|
|
12
|
+
// - A JSON string (legacy/lazy mode)
|
|
13
|
+
// - An object {message, stack} (when errorRef is resolved)
|
|
14
|
+
// This will be deserialized and mapped to error
|
|
15
|
+
error: z
|
|
16
|
+
.union([
|
|
17
|
+
z.string(),
|
|
18
|
+
z.object({
|
|
19
|
+
message: z.string(),
|
|
20
|
+
stack: z.string().optional(),
|
|
21
|
+
code: z.string().optional(),
|
|
22
|
+
}),
|
|
23
|
+
])
|
|
24
|
+
.optional(),
|
|
25
|
+
errorRef: z.any().optional(),
|
|
17
26
|
});
|
|
18
27
|
// Wire schema for lazy mode with refs instead of data
|
|
19
28
|
const StepWireWithRefsSchema = StepWireSchema.omit({
|
|
@@ -23,23 +32,70 @@ const StepWireWithRefsSchema = StepWireSchema.omit({
|
|
|
23
32
|
// We discard the results of the refs, so we don't care about the type here
|
|
24
33
|
inputRef: z.any().optional(),
|
|
25
34
|
outputRef: z.any().optional(),
|
|
26
|
-
input: z.
|
|
27
|
-
output: z.
|
|
35
|
+
input: z.instanceof(Uint8Array).optional(),
|
|
36
|
+
output: z.instanceof(Uint8Array).optional(),
|
|
28
37
|
});
|
|
29
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Transform step from wire format to Step interface format.
|
|
40
|
+
* Maps:
|
|
41
|
+
* - error/errorRef → error (deserializing JSON string to StructuredError)
|
|
42
|
+
*/
|
|
43
|
+
export function deserializeStep(wireStep) {
|
|
44
|
+
const { error, errorRef, ...rest } = wireStep;
|
|
45
|
+
const result = {
|
|
46
|
+
...rest,
|
|
47
|
+
};
|
|
48
|
+
// Deserialize error to StructuredError
|
|
49
|
+
// The backend returns error as:
|
|
50
|
+
// - error: JSON string (legacy) or object (when resolved)
|
|
51
|
+
// - errorRef: resolved object {message, stack} when remoteRefBehavior=resolve
|
|
52
|
+
const errorSource = error ?? errorRef;
|
|
53
|
+
if (errorSource) {
|
|
54
|
+
if (typeof errorSource === 'string') {
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(errorSource);
|
|
57
|
+
if (typeof parsed === 'object' && parsed.message !== undefined) {
|
|
58
|
+
result.error = {
|
|
59
|
+
message: parsed.message,
|
|
60
|
+
stack: parsed.stack,
|
|
61
|
+
code: parsed.code,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Parsed but not an object with message
|
|
66
|
+
result.error = { message: String(parsed) };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Not JSON, treat as plain string
|
|
71
|
+
result.error = { message: errorSource };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (typeof errorSource === 'object' && errorSource !== null) {
|
|
75
|
+
// Already an object (from resolved ref)
|
|
76
|
+
result.error = {
|
|
77
|
+
message: errorSource.message ?? 'Unknown error',
|
|
78
|
+
stack: errorSource.stack,
|
|
79
|
+
code: errorSource.code,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
// Implementation - when resolveData='none', returns Step with input/output set to undefined
|
|
86
|
+
// to match other World implementations (world-local, world-postgres)
|
|
30
87
|
function filterStepData(step, resolveData) {
|
|
31
88
|
if (resolveData === 'none') {
|
|
32
89
|
const { inputRef: _inputRef, outputRef: _outputRef, ...rest } = step;
|
|
33
|
-
const deserialized =
|
|
90
|
+
const deserialized = deserializeStep(rest);
|
|
34
91
|
return {
|
|
35
92
|
...deserialized,
|
|
36
|
-
input:
|
|
93
|
+
input: undefined,
|
|
37
94
|
output: undefined,
|
|
38
95
|
};
|
|
39
96
|
}
|
|
40
|
-
return
|
|
97
|
+
return deserializeStep(step);
|
|
41
98
|
}
|
|
42
|
-
// Functions
|
|
43
99
|
export async function listWorkflowRunSteps(params, config) {
|
|
44
100
|
const { runId, pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION, } = params;
|
|
45
101
|
const searchParams = new URLSearchParams();
|
|
@@ -53,7 +109,7 @@ export async function listWorkflowRunSteps(params, config) {
|
|
|
53
109
|
const remoteRefBehavior = resolveData === 'none' ? 'lazy' : 'resolve';
|
|
54
110
|
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
55
111
|
const queryString = searchParams.toString();
|
|
56
|
-
const endpoint = `/
|
|
112
|
+
const endpoint = `/v2/runs/${runId}/steps${queryString ? `?${queryString}` : ''}`;
|
|
57
113
|
const response = (await makeRequest({
|
|
58
114
|
endpoint,
|
|
59
115
|
options: { method: 'GET' },
|
|
@@ -67,28 +123,24 @@ export async function listWorkflowRunSteps(params, config) {
|
|
|
67
123
|
}
|
|
68
124
|
export async function createStep(runId, data, config) {
|
|
69
125
|
const step = await makeRequest({
|
|
70
|
-
endpoint: `/
|
|
71
|
-
options: {
|
|
72
|
-
|
|
73
|
-
body: JSON.stringify(data, dateToStringReplacer),
|
|
74
|
-
},
|
|
126
|
+
endpoint: `/v2/runs/${runId}/steps`,
|
|
127
|
+
options: { method: 'POST' },
|
|
128
|
+
data,
|
|
75
129
|
config,
|
|
76
130
|
schema: StepWireSchema,
|
|
77
131
|
});
|
|
78
|
-
return
|
|
132
|
+
return deserializeStep(step);
|
|
79
133
|
}
|
|
80
134
|
export async function updateStep(runId, stepId, data, config) {
|
|
81
135
|
const serialized = serializeError(data);
|
|
82
136
|
const step = await makeRequest({
|
|
83
|
-
endpoint: `/
|
|
84
|
-
options: {
|
|
85
|
-
|
|
86
|
-
body: JSON.stringify(serialized, dateToStringReplacer),
|
|
87
|
-
},
|
|
137
|
+
endpoint: `/v2/runs/${runId}/steps/${stepId}`,
|
|
138
|
+
options: { method: 'PUT' },
|
|
139
|
+
data: serialized,
|
|
88
140
|
config,
|
|
89
141
|
schema: StepWireSchema,
|
|
90
142
|
});
|
|
91
|
-
return
|
|
143
|
+
return deserializeStep(step);
|
|
92
144
|
}
|
|
93
145
|
export async function getStep(runId, stepId, params, config) {
|
|
94
146
|
const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
@@ -97,8 +149,8 @@ export async function getStep(runId, stepId, params, config) {
|
|
|
97
149
|
searchParams.set('remoteRefBehavior', remoteRefBehavior);
|
|
98
150
|
const queryString = searchParams.toString();
|
|
99
151
|
const endpoint = runId
|
|
100
|
-
? `/
|
|
101
|
-
: `/
|
|
152
|
+
? `/v2/runs/${runId}/steps/${stepId}${queryString ? `?${queryString}` : ''}`
|
|
153
|
+
: `/v2/steps/${stepId}${queryString ? `?${queryString}` : ''}`;
|
|
102
154
|
const step = await makeRequest({
|
|
103
155
|
endpoint,
|
|
104
156
|
options: { method: 'GET' },
|
package/dist/steps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,uBAAuB,EAEvB,UAAU,
|
|
1
|
+
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../src/steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,uBAAuB,EAEvB,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,2BAA2B,EAC3B,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IAC5C,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC,MAAM,CAAC;IACR,mCAAmC;IACnC,qCAAqC;IACrC,2DAA2D;IAC3D,gDAAgD;IAChD,KAAK,EAAE,CAAC;SACL,KAAK,CAAC;QACL,CAAC,CAAC,MAAM,EAAE;QACV,CAAC,CAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;YACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC5B,CAAC;KACH,CAAC;SACD,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAEH,sDAAsD;AACtD,MAAM,sBAAsB,GAAG,cAAc,CAAC,IAAI,CAAC;IACjD,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;CACb,CAAC,CAAC,MAAM,CAAC;IACR,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC5B,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,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AAC,CAAC;AAC3C,CAAC"}
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CA2BzD"}
|
package/dist/storage.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import { createWorkflowRunEvent, getWorkflowRunEvents } from './events.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { getHook, getHookByToken, listHooks } from './hooks.js';
|
|
3
|
+
import { getWorkflowRun, listWorkflowRuns } from './runs.js';
|
|
4
|
+
import { getStep, listWorkflowRunSteps } from './steps.js';
|
|
5
5
|
export function createStorage(config) {
|
|
6
6
|
return {
|
|
7
7
|
// Storage interface with namespaced methods
|
|
8
8
|
runs: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
update: (id, data) => updateWorkflowRun(id, data, config),
|
|
12
|
-
list: (params) => listWorkflowRuns(params, config),
|
|
13
|
-
cancel: (id, params) => cancelWorkflowRun(id, params, config),
|
|
14
|
-
pause: (id, params) => pauseWorkflowRun(id, params, config),
|
|
15
|
-
resume: (id, params) => resumeWorkflowRun(id, params, config),
|
|
9
|
+
get: ((id, params) => getWorkflowRun(id, params, config)),
|
|
10
|
+
list: ((params) => listWorkflowRuns(params, config)),
|
|
16
11
|
},
|
|
17
12
|
steps: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
update: (runId, stepId, data) => updateStep(runId, stepId, data, config),
|
|
21
|
-
list: (params) => listWorkflowRunSteps(params, config),
|
|
13
|
+
get: ((runId, stepId, params) => getStep(runId, stepId, params, config)),
|
|
14
|
+
list: ((params) => listWorkflowRunSteps(params, config)),
|
|
22
15
|
},
|
|
23
16
|
events: {
|
|
24
17
|
create: (runId, data, params) => createWorkflowRunEvent(runId, data, params, config),
|
|
@@ -26,11 +19,9 @@ export function createStorage(config) {
|
|
|
26
19
|
listByCorrelationId: (params) => getWorkflowRunEvents(params, config),
|
|
27
20
|
},
|
|
28
21
|
hooks: {
|
|
29
|
-
create: (runId, data) => createHook(runId, data, config),
|
|
30
22
|
get: (hookId, params) => getHook(hookId, params, config),
|
|
31
23
|
getByToken: (token) => getHookByToken(token, config),
|
|
32
24
|
list: (params) => listHooks(params, config),
|
|
33
|
-
dispose: (hookId) => disposeHook(hookId, config),
|
|
34
25
|
},
|
|
35
26
|
};
|
|
36
27
|
}
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAG3D,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,OAAO;QACL,4CAA4C;QAC5C,IAAI,EAAE;YACJ,GAAG,EAAE,CAAC,CAAC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er.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAkC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"streamer.d.ts","sourceRoot":"","sources":["../src/streamer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAkC,MAAM,YAAY,CAAC;AAe5E,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAkD3D"}
|
package/dist/streamer.js
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
import { getHttpConfig } from './utils.js';
|
|
2
|
-
function getStreamUrl(name, httpConfig) {
|
|
3
|
-
|
|
2
|
+
function getStreamUrl(name, runId, httpConfig) {
|
|
3
|
+
if (runId) {
|
|
4
|
+
return new URL(`${httpConfig.baseUrl}/v2/runs/${runId}/stream/${encodeURIComponent(name)}`);
|
|
5
|
+
}
|
|
6
|
+
return new URL(`${httpConfig.baseUrl}/v2/stream/${encodeURIComponent(name)}`);
|
|
4
7
|
}
|
|
5
8
|
export function createStreamer(config) {
|
|
6
9
|
return {
|
|
7
|
-
async writeToStream(name, chunk) {
|
|
10
|
+
async writeToStream(name, runId, chunk) {
|
|
11
|
+
// Await runId if it's a promise to ensure proper flushing
|
|
12
|
+
const resolvedRunId = await runId;
|
|
8
13
|
const httpConfig = await getHttpConfig(config);
|
|
9
|
-
await fetch(getStreamUrl(name, httpConfig), {
|
|
14
|
+
await fetch(getStreamUrl(name, resolvedRunId, httpConfig), {
|
|
10
15
|
method: 'PUT',
|
|
11
16
|
body: chunk,
|
|
12
17
|
headers: httpConfig.headers,
|
|
13
18
|
duplex: 'half',
|
|
14
19
|
});
|
|
15
20
|
},
|
|
16
|
-
async closeStream(name) {
|
|
21
|
+
async closeStream(name, runId) {
|
|
22
|
+
// Await runId if it's a promise to ensure proper flushing
|
|
23
|
+
const resolvedRunId = await runId;
|
|
17
24
|
const httpConfig = await getHttpConfig(config);
|
|
18
25
|
httpConfig.headers.set('X-Stream-Done', 'true');
|
|
19
|
-
await fetch(getStreamUrl(name, httpConfig), {
|
|
26
|
+
await fetch(getStreamUrl(name, resolvedRunId, httpConfig), {
|
|
20
27
|
method: 'PUT',
|
|
21
28
|
headers: httpConfig.headers,
|
|
22
29
|
});
|
|
23
30
|
},
|
|
24
31
|
async readFromStream(name, startIndex) {
|
|
25
32
|
const httpConfig = await getHttpConfig(config);
|
|
26
|
-
const url = getStreamUrl(name, httpConfig);
|
|
33
|
+
const url = getStreamUrl(name, undefined, httpConfig);
|
|
27
34
|
if (typeof startIndex === 'number') {
|
|
28
35
|
url.searchParams.set('startIndex', String(startIndex));
|
|
29
36
|
}
|
|
@@ -32,6 +39,14 @@ export function createStreamer(config) {
|
|
|
32
39
|
throw new Error(`Failed to fetch stream: ${res.status}`);
|
|
33
40
|
return res.body;
|
|
34
41
|
},
|
|
42
|
+
async listStreamsByRunId(runId) {
|
|
43
|
+
const httpConfig = await getHttpConfig(config);
|
|
44
|
+
const url = new URL(`${httpConfig.baseUrl}/v2/runs/${runId}/streams`);
|
|
45
|
+
const res = await fetch(url, { headers: httpConfig.headers });
|
|
46
|
+
if (!res.ok)
|
|
47
|
+
throw new Error(`Failed to list streams: ${res.status}`);
|
|
48
|
+
return (await res.json());
|
|
49
|
+
},
|
|
35
50
|
};
|
|
36
51
|
}
|
|
37
52
|
//# sourceMappingURL=streamer.js.map
|
package/dist/streamer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamer.js","sourceRoot":"","sources":["../src/streamer.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,aAAa,EAAmB,MAAM,YAAY,CAAC;AAE5E,SAAS,YAAY,
|
|
1
|
+
{"version":3,"file":"streamer.js","sourceRoot":"","sources":["../src/streamer.ts"],"names":[],"mapp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