@agentsmarket/pipeline-runtime 0.5.0 → 0.5.2
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/README.md +86 -1
- package/dist/adapters/minimax.d.ts +16 -8
- package/dist/adapters/minimax.js +105 -26
- package/dist/adapters/multimodal-convert.d.ts +54 -0
- package/dist/adapters/multimodal-convert.js +105 -0
- package/dist/adapters/openrouter.d.ts +5 -0
- package/dist/adapters/openrouter.js +53 -6
- package/dist/index.d.ts +20 -4
- package/dist/index.js +15 -3
- package/dist/loop.d.ts +90 -0
- package/dist/loop.js +200 -0
- package/dist/memory.d.ts +73 -0
- package/dist/memory.js +119 -0
- package/dist/model-resolver.d.ts +52 -1
- package/dist/multimodal.d.ts +43 -0
- package/dist/multimodal.js +23 -0
- package/dist/output-errors.d.ts +93 -0
- package/dist/output-errors.js +128 -0
- package/dist/output-schema-validate.d.ts +10 -0
- package/dist/output-schema-validate.js +149 -0
- package/dist/output-schema.d.ts +66 -0
- package/dist/output-schema.js +141 -0
- package/dist/pipeline-refs.d.ts +15 -0
- package/dist/pipeline-refs.js +155 -0
- package/dist/provider-registry.d.ts +22 -1
- package/dist/provider-registry.js +62 -2
- package/dist/providers/anthropic.d.ts +28 -0
- package/dist/providers/anthropic.js +118 -0
- package/dist/providers/openai-chat.d.ts +28 -0
- package/dist/providers/openai-chat.js +106 -0
- package/dist/providers/openai-dalle.d.ts +19 -0
- package/dist/providers/openai-dalle.js +41 -0
- package/dist/providers/openai-tts.d.ts +19 -0
- package/dist/providers/openai-tts.js +46 -0
- package/dist/providers/openai-vision.d.ts +15 -0
- package/dist/providers/openai-vision.js +43 -0
- package/dist/providers/openai-whisper.d.ts +16 -0
- package/dist/providers/openai-whisper.js +43 -0
- package/dist/providers/replicate.d.ts +19 -0
- package/dist/providers/replicate.js +61 -0
- package/dist/providers/types.d.ts +23 -0
- package/dist/providers/types.js +31 -0
- package/dist/runtime-constraints.d.ts +2 -1
- package/dist/stages.d.ts +14 -2
- package/dist/stages.js +339 -34
- package/dist/streaming-events.d.ts +17 -2
- package/dist/streaming-events.js +12 -0
- package/dist/testing/assertions.d.ts +17 -0
- package/dist/testing/assertions.js +149 -0
- package/dist/testing/conformance.d.ts +3 -0
- package/dist/testing/conformance.js +28 -0
- package/dist/testing/coverage.d.ts +11 -0
- package/dist/testing/coverage.js +35 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/reporters/json.d.ts +5 -0
- package/dist/testing/reporters/json.js +23 -0
- package/dist/testing/reporters/junit.d.ts +5 -0
- package/dist/testing/reporters/junit.js +31 -0
- package/dist/testing/reporters/text.d.ts +5 -0
- package/dist/testing/reporters/text.js +36 -0
- package/dist/testing/runner.d.ts +25 -0
- package/dist/testing/runner.js +222 -0
- package/dist/testing/spec-parser.d.ts +366 -0
- package/dist/testing/spec-parser.js +60 -0
- package/dist/testing/stage-extractor.d.ts +16 -0
- package/dist/testing/stage-extractor.js +25 -0
- package/dist/tools/audio-transcribe.d.ts +11 -0
- package/dist/tools/audio-transcribe.js +45 -0
- package/dist/tools/image-describe.d.ts +12 -0
- package/dist/tools/image-describe.js +47 -0
- package/dist/tools/image-generate.d.ts +12 -0
- package/dist/tools/image-generate.js +47 -0
- package/dist/tools/memory-recall.d.ts +13 -0
- package/dist/tools/memory-recall.js +63 -0
- package/dist/tools/memory-shared.d.ts +8 -0
- package/dist/tools/memory-shared.js +8 -0
- package/dist/tools/memory-store.d.ts +14 -0
- package/dist/tools/memory-store.js +68 -0
- package/dist/tools/tool-skills.js +14 -0
- package/dist/tools/tts-synthesize.d.ts +12 -0
- package/dist/tools/tts-synthesize.js +50 -0
- package/dist/tools/video-generate.d.ts +12 -0
- package/dist/tools/video-generate.js +47 -0
- package/dist/types.d.ts +8 -0
- package/dist/validate-inputs.d.ts +115 -0
- package/dist/validate-inputs.js +273 -0
- package/package.json +3 -3
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const AssertionSchema: z.ZodUnion<[z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"equality">;
|
|
4
|
+
path: z.ZodString;
|
|
5
|
+
value: z.ZodUnknown;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
path: string;
|
|
8
|
+
type: "equality";
|
|
9
|
+
value?: unknown;
|
|
10
|
+
}, {
|
|
11
|
+
path: string;
|
|
12
|
+
type: "equality";
|
|
13
|
+
value?: unknown;
|
|
14
|
+
}>, z.ZodObject<{
|
|
15
|
+
type: z.ZodLiteral<"contains">;
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
value: string | number | boolean;
|
|
20
|
+
path: string;
|
|
21
|
+
type: "contains";
|
|
22
|
+
}, {
|
|
23
|
+
value: string | number | boolean;
|
|
24
|
+
path: string;
|
|
25
|
+
type: "contains";
|
|
26
|
+
}>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<"regex">;
|
|
28
|
+
path: z.ZodString;
|
|
29
|
+
pattern: z.ZodString;
|
|
30
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
path: string;
|
|
33
|
+
type: "regex";
|
|
34
|
+
pattern: string;
|
|
35
|
+
flags?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
path: string;
|
|
38
|
+
type: "regex";
|
|
39
|
+
pattern: string;
|
|
40
|
+
flags?: string | undefined;
|
|
41
|
+
}>, z.ZodObject<{
|
|
42
|
+
type: z.ZodEnum<["gte", "lte", "gt", "lt"]>;
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
value: z.ZodNumber;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
value: number;
|
|
47
|
+
path: string;
|
|
48
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
49
|
+
}, {
|
|
50
|
+
value: number;
|
|
51
|
+
path: string;
|
|
52
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
53
|
+
}>, z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"exists">;
|
|
55
|
+
path: z.ZodString;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
path: string;
|
|
58
|
+
type: "exists";
|
|
59
|
+
}, {
|
|
60
|
+
path: string;
|
|
61
|
+
type: "exists";
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"absent">;
|
|
64
|
+
path: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
path: string;
|
|
67
|
+
type: "absent";
|
|
68
|
+
}, {
|
|
69
|
+
path: string;
|
|
70
|
+
type: "absent";
|
|
71
|
+
}>, z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"jsonpath">;
|
|
73
|
+
path: z.ZodString;
|
|
74
|
+
value: z.ZodUnknown;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
path: string;
|
|
77
|
+
type: "jsonpath";
|
|
78
|
+
value?: unknown;
|
|
79
|
+
}, {
|
|
80
|
+
path: string;
|
|
81
|
+
type: "jsonpath";
|
|
82
|
+
value?: unknown;
|
|
83
|
+
}>, z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"schema">;
|
|
85
|
+
path: z.ZodString;
|
|
86
|
+
schema_file: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
path: string;
|
|
89
|
+
type: "schema";
|
|
90
|
+
schema_file: string;
|
|
91
|
+
}, {
|
|
92
|
+
path: string;
|
|
93
|
+
type: "schema";
|
|
94
|
+
schema_file: string;
|
|
95
|
+
}>]>;
|
|
96
|
+
export type Assertion = z.infer<typeof AssertionSchema>;
|
|
97
|
+
declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
98
|
+
name: z.ZodString;
|
|
99
|
+
description: z.ZodOptional<z.ZodString>;
|
|
100
|
+
pipeline: z.ZodOptional<z.ZodString>;
|
|
101
|
+
stage: z.ZodOptional<z.ZodString>;
|
|
102
|
+
inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
103
|
+
mock: z.ZodDefault<z.ZodBoolean>;
|
|
104
|
+
expect_error: z.ZodOptional<z.ZodString>;
|
|
105
|
+
assertions: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
106
|
+
type: z.ZodLiteral<"equality">;
|
|
107
|
+
path: z.ZodString;
|
|
108
|
+
value: z.ZodUnknown;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
path: string;
|
|
111
|
+
type: "equality";
|
|
112
|
+
value?: unknown;
|
|
113
|
+
}, {
|
|
114
|
+
path: string;
|
|
115
|
+
type: "equality";
|
|
116
|
+
value?: unknown;
|
|
117
|
+
}>, z.ZodObject<{
|
|
118
|
+
type: z.ZodLiteral<"contains">;
|
|
119
|
+
path: z.ZodString;
|
|
120
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
value: string | number | boolean;
|
|
123
|
+
path: string;
|
|
124
|
+
type: "contains";
|
|
125
|
+
}, {
|
|
126
|
+
value: string | number | boolean;
|
|
127
|
+
path: string;
|
|
128
|
+
type: "contains";
|
|
129
|
+
}>, z.ZodObject<{
|
|
130
|
+
type: z.ZodLiteral<"regex">;
|
|
131
|
+
path: z.ZodString;
|
|
132
|
+
pattern: z.ZodString;
|
|
133
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
path: string;
|
|
136
|
+
type: "regex";
|
|
137
|
+
pattern: string;
|
|
138
|
+
flags?: string | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
path: string;
|
|
141
|
+
type: "regex";
|
|
142
|
+
pattern: string;
|
|
143
|
+
flags?: string | undefined;
|
|
144
|
+
}>, z.ZodObject<{
|
|
145
|
+
type: z.ZodEnum<["gte", "lte", "gt", "lt"]>;
|
|
146
|
+
path: z.ZodString;
|
|
147
|
+
value: z.ZodNumber;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
value: number;
|
|
150
|
+
path: string;
|
|
151
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
152
|
+
}, {
|
|
153
|
+
value: number;
|
|
154
|
+
path: string;
|
|
155
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
156
|
+
}>, z.ZodObject<{
|
|
157
|
+
type: z.ZodLiteral<"exists">;
|
|
158
|
+
path: z.ZodString;
|
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
|
160
|
+
path: string;
|
|
161
|
+
type: "exists";
|
|
162
|
+
}, {
|
|
163
|
+
path: string;
|
|
164
|
+
type: "exists";
|
|
165
|
+
}>, z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"absent">;
|
|
167
|
+
path: z.ZodString;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
path: string;
|
|
170
|
+
type: "absent";
|
|
171
|
+
}, {
|
|
172
|
+
path: string;
|
|
173
|
+
type: "absent";
|
|
174
|
+
}>, z.ZodObject<{
|
|
175
|
+
type: z.ZodLiteral<"jsonpath">;
|
|
176
|
+
path: z.ZodString;
|
|
177
|
+
value: z.ZodUnknown;
|
|
178
|
+
}, "strip", z.ZodTypeAny, {
|
|
179
|
+
path: string;
|
|
180
|
+
type: "jsonpath";
|
|
181
|
+
value?: unknown;
|
|
182
|
+
}, {
|
|
183
|
+
path: string;
|
|
184
|
+
type: "jsonpath";
|
|
185
|
+
value?: unknown;
|
|
186
|
+
}>, z.ZodObject<{
|
|
187
|
+
type: z.ZodLiteral<"schema">;
|
|
188
|
+
path: z.ZodString;
|
|
189
|
+
schema_file: z.ZodString;
|
|
190
|
+
}, "strip", z.ZodTypeAny, {
|
|
191
|
+
path: string;
|
|
192
|
+
type: "schema";
|
|
193
|
+
schema_file: string;
|
|
194
|
+
}, {
|
|
195
|
+
path: string;
|
|
196
|
+
type: "schema";
|
|
197
|
+
schema_file: string;
|
|
198
|
+
}>]>, "many">>;
|
|
199
|
+
}, "strip", z.ZodTypeAny, {
|
|
200
|
+
inputs: Record<string, unknown>;
|
|
201
|
+
name: string;
|
|
202
|
+
mock: boolean;
|
|
203
|
+
assertions: ({
|
|
204
|
+
path: string;
|
|
205
|
+
type: "equality";
|
|
206
|
+
value?: unknown;
|
|
207
|
+
} | {
|
|
208
|
+
value: string | number | boolean;
|
|
209
|
+
path: string;
|
|
210
|
+
type: "contains";
|
|
211
|
+
} | {
|
|
212
|
+
path: string;
|
|
213
|
+
type: "regex";
|
|
214
|
+
pattern: string;
|
|
215
|
+
flags?: string | undefined;
|
|
216
|
+
} | {
|
|
217
|
+
value: number;
|
|
218
|
+
path: string;
|
|
219
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
220
|
+
} | {
|
|
221
|
+
path: string;
|
|
222
|
+
type: "exists";
|
|
223
|
+
} | {
|
|
224
|
+
path: string;
|
|
225
|
+
type: "absent";
|
|
226
|
+
} | {
|
|
227
|
+
path: string;
|
|
228
|
+
type: "jsonpath";
|
|
229
|
+
value?: unknown;
|
|
230
|
+
} | {
|
|
231
|
+
path: string;
|
|
232
|
+
type: "schema";
|
|
233
|
+
schema_file: string;
|
|
234
|
+
})[];
|
|
235
|
+
pipeline?: string | undefined;
|
|
236
|
+
description?: string | undefined;
|
|
237
|
+
stage?: string | undefined;
|
|
238
|
+
expect_error?: string | undefined;
|
|
239
|
+
}, {
|
|
240
|
+
name: string;
|
|
241
|
+
inputs?: Record<string, unknown> | undefined;
|
|
242
|
+
pipeline?: string | undefined;
|
|
243
|
+
description?: string | undefined;
|
|
244
|
+
mock?: boolean | undefined;
|
|
245
|
+
stage?: string | undefined;
|
|
246
|
+
expect_error?: string | undefined;
|
|
247
|
+
assertions?: ({
|
|
248
|
+
path: string;
|
|
249
|
+
type: "equality";
|
|
250
|
+
value?: unknown;
|
|
251
|
+
} | {
|
|
252
|
+
value: string | number | boolean;
|
|
253
|
+
path: string;
|
|
254
|
+
type: "contains";
|
|
255
|
+
} | {
|
|
256
|
+
path: string;
|
|
257
|
+
type: "regex";
|
|
258
|
+
pattern: string;
|
|
259
|
+
flags?: string | undefined;
|
|
260
|
+
} | {
|
|
261
|
+
value: number;
|
|
262
|
+
path: string;
|
|
263
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
264
|
+
} | {
|
|
265
|
+
path: string;
|
|
266
|
+
type: "exists";
|
|
267
|
+
} | {
|
|
268
|
+
path: string;
|
|
269
|
+
type: "absent";
|
|
270
|
+
} | {
|
|
271
|
+
path: string;
|
|
272
|
+
type: "jsonpath";
|
|
273
|
+
value?: unknown;
|
|
274
|
+
} | {
|
|
275
|
+
path: string;
|
|
276
|
+
type: "schema";
|
|
277
|
+
schema_file: string;
|
|
278
|
+
})[] | undefined;
|
|
279
|
+
}>, {
|
|
280
|
+
inputs: Record<string, unknown>;
|
|
281
|
+
name: string;
|
|
282
|
+
mock: boolean;
|
|
283
|
+
assertions: ({
|
|
284
|
+
path: string;
|
|
285
|
+
type: "equality";
|
|
286
|
+
value?: unknown;
|
|
287
|
+
} | {
|
|
288
|
+
value: string | number | boolean;
|
|
289
|
+
path: string;
|
|
290
|
+
type: "contains";
|
|
291
|
+
} | {
|
|
292
|
+
path: string;
|
|
293
|
+
type: "regex";
|
|
294
|
+
pattern: string;
|
|
295
|
+
flags?: string | undefined;
|
|
296
|
+
} | {
|
|
297
|
+
value: number;
|
|
298
|
+
path: string;
|
|
299
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
300
|
+
} | {
|
|
301
|
+
path: string;
|
|
302
|
+
type: "exists";
|
|
303
|
+
} | {
|
|
304
|
+
path: string;
|
|
305
|
+
type: "absent";
|
|
306
|
+
} | {
|
|
307
|
+
path: string;
|
|
308
|
+
type: "jsonpath";
|
|
309
|
+
value?: unknown;
|
|
310
|
+
} | {
|
|
311
|
+
path: string;
|
|
312
|
+
type: "schema";
|
|
313
|
+
schema_file: string;
|
|
314
|
+
})[];
|
|
315
|
+
pipeline?: string | undefined;
|
|
316
|
+
description?: string | undefined;
|
|
317
|
+
stage?: string | undefined;
|
|
318
|
+
expect_error?: string | undefined;
|
|
319
|
+
}, {
|
|
320
|
+
name: string;
|
|
321
|
+
inputs?: Record<string, unknown> | undefined;
|
|
322
|
+
pipeline?: string | undefined;
|
|
323
|
+
description?: string | undefined;
|
|
324
|
+
mock?: boolean | undefined;
|
|
325
|
+
stage?: string | undefined;
|
|
326
|
+
expect_error?: string | undefined;
|
|
327
|
+
assertions?: ({
|
|
328
|
+
path: string;
|
|
329
|
+
type: "equality";
|
|
330
|
+
value?: unknown;
|
|
331
|
+
} | {
|
|
332
|
+
value: string | number | boolean;
|
|
333
|
+
path: string;
|
|
334
|
+
type: "contains";
|
|
335
|
+
} | {
|
|
336
|
+
path: string;
|
|
337
|
+
type: "regex";
|
|
338
|
+
pattern: string;
|
|
339
|
+
flags?: string | undefined;
|
|
340
|
+
} | {
|
|
341
|
+
value: number;
|
|
342
|
+
path: string;
|
|
343
|
+
type: "gte" | "lte" | "gt" | "lt";
|
|
344
|
+
} | {
|
|
345
|
+
path: string;
|
|
346
|
+
type: "exists";
|
|
347
|
+
} | {
|
|
348
|
+
path: string;
|
|
349
|
+
type: "absent";
|
|
350
|
+
} | {
|
|
351
|
+
path: string;
|
|
352
|
+
type: "jsonpath";
|
|
353
|
+
value?: unknown;
|
|
354
|
+
} | {
|
|
355
|
+
path: string;
|
|
356
|
+
type: "schema";
|
|
357
|
+
schema_file: string;
|
|
358
|
+
})[] | undefined;
|
|
359
|
+
}>;
|
|
360
|
+
export type TestSpec = z.infer<typeof TestSpecSchema>;
|
|
361
|
+
export declare class TestSpecParseError extends Error {
|
|
362
|
+
constructor(message: string);
|
|
363
|
+
}
|
|
364
|
+
export declare function parseTestSpec(yamlText: string): TestSpec;
|
|
365
|
+
export declare function loadTestSpecFile(content: string, sourcePath?: string): TestSpec;
|
|
366
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M9 — YAML test spec parser (TestSpec + Assertion DSL types).
|
|
3
|
+
*
|
|
4
|
+
* Format mirrors pipeline YAML: human-authored, zod-validated.
|
|
5
|
+
*/
|
|
6
|
+
import yaml from 'js-yaml';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
const EqualityAssertion = z.object({ type: z.literal('equality'), path: z.string(), value: z.unknown() });
|
|
9
|
+
const ContainsAssertion = z.object({ type: z.literal('contains'), path: z.string(), value: z.union([z.string(), z.number(), z.boolean()]) });
|
|
10
|
+
const RegexAssertion = z.object({ type: z.literal('regex'), path: z.string(), pattern: z.string(), flags: z.string().optional() });
|
|
11
|
+
const NumericAssertion = z.object({ type: z.enum(['gte', 'lte', 'gt', 'lt']), path: z.string(), value: z.number() });
|
|
12
|
+
const ExistsAssertion = z.object({ type: z.literal('exists'), path: z.string() });
|
|
13
|
+
const AbsentAssertion = z.object({ type: z.literal('absent'), path: z.string() });
|
|
14
|
+
const JsonpathAssertion = z.object({ type: z.literal('jsonpath'), path: z.string(), value: z.unknown() });
|
|
15
|
+
const SchemaAssertion = z.object({ type: z.literal('schema'), path: z.string(), schema_file: z.string() });
|
|
16
|
+
const AssertionSchema = z.union([
|
|
17
|
+
EqualityAssertion, ContainsAssertion, RegexAssertion, NumericAssertion,
|
|
18
|
+
ExistsAssertion, AbsentAssertion, JsonpathAssertion, SchemaAssertion,
|
|
19
|
+
]);
|
|
20
|
+
const TestSpecSchema = z.object({
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
pipeline: z.string().optional(),
|
|
24
|
+
stage: z.string().optional(),
|
|
25
|
+
inputs: z.record(z.unknown()).default({}),
|
|
26
|
+
mock: z.boolean().default(true),
|
|
27
|
+
expect_error: z.string().optional(),
|
|
28
|
+
assertions: z.array(AssertionSchema).default([]),
|
|
29
|
+
}).refine((s) => s.pipeline !== undefined || s.stage !== undefined || s.expect_error !== undefined, {
|
|
30
|
+
message: 'test spec requires one of: pipeline, stage, or expect_error',
|
|
31
|
+
});
|
|
32
|
+
export class TestSpecParseError extends Error {
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'TEST_SPEC_PARSE_ERROR';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function parseTestSpec(yamlText) {
|
|
39
|
+
let raw;
|
|
40
|
+
try {
|
|
41
|
+
raw = yaml.load(yamlText);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
throw new TestSpecParseError(`invalid YAML: ${e.message}`);
|
|
45
|
+
}
|
|
46
|
+
const parsed = TestSpecSchema.safeParse(raw);
|
|
47
|
+
if (!parsed.success) {
|
|
48
|
+
throw new TestSpecParseError(`invalid test spec: ${parsed.error.message}`);
|
|
49
|
+
}
|
|
50
|
+
return parsed.data;
|
|
51
|
+
}
|
|
52
|
+
export function loadTestSpecFile(content, sourcePath) {
|
|
53
|
+
try {
|
|
54
|
+
return parseTestSpec(content);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
const where = sourcePath ? ` (${sourcePath})` : '';
|
|
58
|
+
throw new TestSpecParseError(`${e.message}${where}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ExtractedStage {
|
|
2
|
+
name: string;
|
|
3
|
+
stage: Record<string, unknown>;
|
|
4
|
+
spec: {
|
|
5
|
+
name: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
stages: Record<string, unknown>[];
|
|
8
|
+
defaults?: {
|
|
9
|
+
model?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class StageNotFoundInSpecError extends Error {
|
|
14
|
+
constructor(stageId: string, available: string[]);
|
|
15
|
+
}
|
|
16
|
+
export declare function extractStage(pipelineYamlText: string, stageId: string): ExtractedStage;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M9 — extract a single stage from a pipeline YAML for stage tests.
|
|
3
|
+
*/
|
|
4
|
+
import { loadPipelineYaml } from '../resolve-vars.js';
|
|
5
|
+
export class StageNotFoundInSpecError extends Error {
|
|
6
|
+
constructor(stageId, available) {
|
|
7
|
+
super(`stage "${stageId}" not found (available: ${available.join(', ') || 'none'})`);
|
|
8
|
+
this.name = 'STAGE_NOT_FOUND';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function extractStage(pipelineYamlText, stageId) {
|
|
12
|
+
const spec = loadPipelineYaml(pipelineYamlText);
|
|
13
|
+
const stages = spec.stages ?? [];
|
|
14
|
+
const ids = stages.map((s) => String(s.id ?? ''));
|
|
15
|
+
const found = stages.find((s) => String(s.id) === stageId);
|
|
16
|
+
if (!found)
|
|
17
|
+
throw new StageNotFoundInSpecError(stageId, ids);
|
|
18
|
+
const clone = JSON.parse(JSON.stringify(found));
|
|
19
|
+
delete clone.depends_on;
|
|
20
|
+
return {
|
|
21
|
+
name: spec.name ?? 'stage-test',
|
|
22
|
+
stage: clone,
|
|
23
|
+
spec: { name: `${spec.name ?? 'pipeline'}::${stageId}`, version: spec.version, stages: [clone], defaults: spec.defaults },
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* audio_transcribe — tool skill (M2).
|
|
3
|
+
* Speech-to-text via Whisper API. Mock-mode default unless
|
|
4
|
+
* TOOL_SKILL_AUDIO_TRANSCRIBE_ENABLED=true (requires OPENAI_API_KEY).
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolSkillContext, ToolSkillResult } from './tool-skills.js';
|
|
7
|
+
export interface AudioTranscribeInput {
|
|
8
|
+
audio_url: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function audioTranscribeHandler(input: unknown, ctx: ToolSkillContext): Promise<ToolSkillResult>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { openaiWhisperTranscribe } from '../providers/openai-whisper.js';
|
|
2
|
+
const MAX_AUDIO_BYTES = 25 * 1024 * 1024;
|
|
3
|
+
export async function audioTranscribeHandler(input, ctx) {
|
|
4
|
+
const parsed = parseInput(input);
|
|
5
|
+
const enabled = globalThis
|
|
6
|
+
.process?.env?.TOOL_SKILL_AUDIO_TRANSCRIBE_ENABLED === 'true';
|
|
7
|
+
if (!enabled) {
|
|
8
|
+
return mockResult(parsed);
|
|
9
|
+
}
|
|
10
|
+
return realProviderCall(parsed, ctx);
|
|
11
|
+
}
|
|
12
|
+
function parseInput(input) {
|
|
13
|
+
if (typeof input !== 'object' || input === null) {
|
|
14
|
+
throw new Error('audio_transcribe requires object input with audio_url');
|
|
15
|
+
}
|
|
16
|
+
const obj = input;
|
|
17
|
+
const url = obj.audio_url ?? obj.url;
|
|
18
|
+
if (typeof url !== 'string' || url.length === 0) {
|
|
19
|
+
throw new Error('audio_transcribe: audio_url is required');
|
|
20
|
+
}
|
|
21
|
+
if (!url.startsWith('https://') && !url.startsWith('data:')) {
|
|
22
|
+
throw new Error(`audio_transcribe: only HTTPS or data: URLs supported (got ${url.slice(0, 24)})`);
|
|
23
|
+
}
|
|
24
|
+
const language = typeof obj.language === 'string' ? obj.language : undefined;
|
|
25
|
+
return { audio_url: url, language };
|
|
26
|
+
}
|
|
27
|
+
function mockResult(parsed) {
|
|
28
|
+
return {
|
|
29
|
+
text: JSON.stringify({
|
|
30
|
+
ok: true,
|
|
31
|
+
mock: true,
|
|
32
|
+
transcript: '[mock transcript of audio content]',
|
|
33
|
+
language: parsed.language ?? 'auto',
|
|
34
|
+
duration_seconds: 30,
|
|
35
|
+
}),
|
|
36
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
37
|
+
meta: { tool: 'audio_transcribe', mode: 'mock', max_bytes: MAX_AUDIO_BYTES },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async function realProviderCall(parsed, _ctx) {
|
|
41
|
+
return openaiWhisperTranscribe({
|
|
42
|
+
audio_url: parsed.audio_url,
|
|
43
|
+
language: parsed.language,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* image_describe — tool skill (M2).
|
|
3
|
+
* Multimodal LLM call to describe an image. Mock-mode default unless
|
|
4
|
+
* TOOL_SKILL_IMAGE_DESCRIBE_ENABLED=true (requires provider API key).
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolSkillContext, ToolSkillResult } from './tool-skills.js';
|
|
7
|
+
export interface ImageDescribeInput {
|
|
8
|
+
image_url: string;
|
|
9
|
+
prompt?: string;
|
|
10
|
+
max_words?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function imageDescribeHandler(input: unknown, ctx: ToolSkillContext): Promise<ToolSkillResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { openaiVisionDescribe } from '../providers/openai-vision.js';
|
|
2
|
+
export async function imageDescribeHandler(input, ctx) {
|
|
3
|
+
const parsed = parseInput(input);
|
|
4
|
+
const enabled = globalThis
|
|
5
|
+
.process?.env?.TOOL_SKILL_IMAGE_DESCRIBE_ENABLED === 'true';
|
|
6
|
+
if (!enabled) {
|
|
7
|
+
return mockResult(parsed);
|
|
8
|
+
}
|
|
9
|
+
return realProviderCall(parsed, ctx);
|
|
10
|
+
}
|
|
11
|
+
function parseInput(input) {
|
|
12
|
+
if (typeof input !== 'object' || input === null) {
|
|
13
|
+
throw new Error('image_describe requires object input with image_url');
|
|
14
|
+
}
|
|
15
|
+
const obj = input;
|
|
16
|
+
const url = obj.image_url ?? obj.url;
|
|
17
|
+
if (typeof url !== 'string' || url.length === 0) {
|
|
18
|
+
throw new Error('image_describe: image_url is required');
|
|
19
|
+
}
|
|
20
|
+
if (!url.startsWith('https://') && !url.startsWith('data:')) {
|
|
21
|
+
throw new Error(`image_describe: only HTTPS or data: URLs supported (got ${url.slice(0, 24)})`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
image_url: url,
|
|
25
|
+
prompt: typeof obj.prompt === 'string' ? obj.prompt : 'Describe this image.',
|
|
26
|
+
max_words: typeof obj.max_words === 'number' && obj.max_words > 0 ? obj.max_words : 200,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function mockResult(parsed) {
|
|
30
|
+
return {
|
|
31
|
+
text: JSON.stringify({
|
|
32
|
+
ok: true,
|
|
33
|
+
mock: true,
|
|
34
|
+
description: `[mock image description for ${parsed.image_url.slice(0, 60)}]`,
|
|
35
|
+
prompt: parsed.prompt,
|
|
36
|
+
}),
|
|
37
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
38
|
+
meta: { tool: 'image_describe', mode: 'mock' },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function realProviderCall(parsed, _ctx) {
|
|
42
|
+
return openaiVisionDescribe({
|
|
43
|
+
image_url: parsed.image_url,
|
|
44
|
+
prompt: parsed.prompt ?? 'Describe this image.',
|
|
45
|
+
max_tokens: (parsed.max_words ?? 200) * 2,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* image_generate — tool skill (M2).
|
|
3
|
+
* Text-to-image via DALL-E / Flux. Mock-mode default unless
|
|
4
|
+
* TOOL_SKILL_IMAGE_GENERATE_ENABLED=true (requires provider API key).
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolSkillContext, ToolSkillResult } from './tool-skills.js';
|
|
7
|
+
export interface ImageGenerateInput {
|
|
8
|
+
prompt: string;
|
|
9
|
+
size?: '1024x1024' | '1792x1024' | '1024x1792';
|
|
10
|
+
n?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function imageGenerateHandler(input: unknown, ctx: ToolSkillContext): Promise<ToolSkillResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { openaiDallEGenerate } from '../providers/openai-dalle.js';
|
|
2
|
+
export async function imageGenerateHandler(input, ctx) {
|
|
3
|
+
const parsed = parseInput(input);
|
|
4
|
+
const enabled = globalThis
|
|
5
|
+
.process?.env?.TOOL_SKILL_IMAGE_GENERATE_ENABLED === 'true';
|
|
6
|
+
if (!enabled) {
|
|
7
|
+
return mockResult(parsed);
|
|
8
|
+
}
|
|
9
|
+
return realProviderCall(parsed, ctx);
|
|
10
|
+
}
|
|
11
|
+
function parseInput(input) {
|
|
12
|
+
if (typeof input !== 'object' || input === null) {
|
|
13
|
+
throw new Error('image_generate requires object input with prompt');
|
|
14
|
+
}
|
|
15
|
+
const obj = input;
|
|
16
|
+
const prompt = obj.prompt;
|
|
17
|
+
if (typeof prompt !== 'string' || prompt.length === 0) {
|
|
18
|
+
throw new Error('image_generate: prompt is required and non-empty');
|
|
19
|
+
}
|
|
20
|
+
const size = obj.size;
|
|
21
|
+
const validSize = size === '1024x1024' || size === '1792x1024' || size === '1024x1792'
|
|
22
|
+
? size
|
|
23
|
+
: '1024x1024';
|
|
24
|
+
const n = typeof obj.n === 'number' && obj.n > 0 && obj.n <= 4 ? obj.n : 1;
|
|
25
|
+
return { prompt, size: validSize, n };
|
|
26
|
+
}
|
|
27
|
+
function mockResult(parsed) {
|
|
28
|
+
return {
|
|
29
|
+
text: JSON.stringify({
|
|
30
|
+
ok: true,
|
|
31
|
+
mock: true,
|
|
32
|
+
images: Array.from({ length: parsed.n ?? 1 }, (_, i) => ({
|
|
33
|
+
url: `mock://image-gen/${Date.now()}-${i}.png`,
|
|
34
|
+
size: parsed.size,
|
|
35
|
+
})),
|
|
36
|
+
}),
|
|
37
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
38
|
+
meta: { tool: 'image_generate', mode: 'mock' },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function realProviderCall(parsed, _ctx) {
|
|
42
|
+
return openaiDallEGenerate({
|
|
43
|
+
prompt: parsed.prompt,
|
|
44
|
+
size: parsed.size,
|
|
45
|
+
n: parsed.n,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory_recall — tool skill (M6.1).
|
|
3
|
+
* Read a value (or list keys with prefix) from pipeline memory partition.
|
|
4
|
+
* Mock-mode default unless MEMORY_ENABLED=true (requires R2 binding).
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolSkillContext, ToolSkillResult } from './tool-skills.js';
|
|
7
|
+
export interface MemoryRecallInput {
|
|
8
|
+
pipeline_id: string;
|
|
9
|
+
partition: string;
|
|
10
|
+
key?: string;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function memoryRecallHandler(input: unknown, ctx: ToolSkillContext): Promise<ToolSkillResult>;
|