ai-props 2.3.0 → 2.4.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.
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +9 -0
- package/dist/ai.d.ts +125 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +199 -0
- package/dist/ai.js.map +1 -0
- package/dist/cache.d.ts +66 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +183 -0
- package/dist/cache.js.map +1 -0
- package/dist/cascade.d.ts +329 -0
- package/dist/cascade.d.ts.map +1 -0
- package/dist/cascade.js +522 -0
- package/dist/cascade.js.map +1 -0
- package/dist/client.d.ts +233 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +191 -0
- package/dist/client.js.map +1 -0
- package/dist/durable-cascade.d.ts +280 -0
- package/dist/durable-cascade.d.ts.map +1 -0
- package/dist/durable-cascade.js +469 -0
- package/dist/durable-cascade.js.map +1 -0
- package/dist/event-bridge.d.ts +257 -0
- package/dist/event-bridge.d.ts.map +1 -0
- package/dist/event-bridge.js +317 -0
- package/dist/event-bridge.js.map +1 -0
- package/dist/generate.d.ts +69 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +227 -0
- package/dist/generate.js.map +1 -0
- package/dist/hoc.d.ts +164 -0
- package/dist/hoc.d.ts.map +1 -0
- package/dist/hoc.js +236 -0
- package/dist/hoc.js.map +1 -0
- package/dist/hono-jsx.d.ts +208 -0
- package/dist/hono-jsx.d.ts.map +1 -0
- package/dist/hono-jsx.js +459 -0
- package/dist/hono-jsx.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/mdx-types.d.ts +152 -0
- package/dist/mdx-types.d.ts.map +1 -0
- package/dist/mdx-types.js +9 -0
- package/dist/mdx-types.js.map +1 -0
- package/dist/mdx-utils.d.ts +106 -0
- package/dist/mdx-utils.d.ts.map +1 -0
- package/dist/mdx-utils.js +384 -0
- package/dist/mdx-utils.js.map +1 -0
- package/dist/mdx.d.ts +230 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +820 -0
- package/dist/mdx.js.map +1 -0
- package/dist/rpc.d.ts +313 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +359 -0
- package/dist/rpc.js.map +1 -0
- package/dist/streaming.d.ts +199 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +402 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +58 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +251 -0
- package/dist/validate.js.map +1 -0
- package/dist/worker.d.ts +270 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +405 -0
- package/dist/worker.js.map +1 -0
- package/package.json +4 -4
package/dist/cascade.js
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cascade Executor - Code -> Generative -> Agentic -> Human escalation pattern for AI Props
|
|
3
|
+
*
|
|
4
|
+
* Implements a tiered execution strategy that tries deterministic code first,
|
|
5
|
+
* then escalates to AI-powered prop generation, and finally to human-in-the-loop
|
|
6
|
+
* if all automated approaches fail.
|
|
7
|
+
*
|
|
8
|
+
* ## Features
|
|
9
|
+
*
|
|
10
|
+
* - **Tier Escalation**: Code -> Generative -> Agentic -> Human pattern
|
|
11
|
+
* - **Per-tier Timeouts**: Configurable timeouts for each tier
|
|
12
|
+
* - **5W+H Audit Events**: Who, What, When, Where, Why, How event emission
|
|
13
|
+
* - **Context Propagation**: Share context across tiers
|
|
14
|
+
* - **Retry Support**: Configurable retries per tier with backoff
|
|
15
|
+
* - **AI Gateway Support**: Configuration helpers for Cloudflare AI Gateway
|
|
16
|
+
*
|
|
17
|
+
* ## Basic Usage
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { CascadeExecutor, createCascadeStep } from 'ai-props/worker'
|
|
22
|
+
*
|
|
23
|
+
* const generateTitleCascade = new CascadeExecutor({
|
|
24
|
+
* tiers: {
|
|
25
|
+
* code: {
|
|
26
|
+
* name: 'template-title',
|
|
27
|
+
* execute: async (input) => {
|
|
28
|
+
* if (input.template) return { title: input.template }
|
|
29
|
+
* throw new Error('No template')
|
|
30
|
+
* }
|
|
31
|
+
* },
|
|
32
|
+
* generative: {
|
|
33
|
+
* name: 'ai-title',
|
|
34
|
+
* execute: async (input) => {
|
|
35
|
+
* const result = await generateProps({
|
|
36
|
+
* schema: { title: 'A compelling title' },
|
|
37
|
+
* context: input
|
|
38
|
+
* })
|
|
39
|
+
* return result.props
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* })
|
|
44
|
+
*
|
|
45
|
+
* const result = await generateTitleCascade.execute({ topic: 'AI' })
|
|
46
|
+
* console.log(result.value) // { title: '...' }
|
|
47
|
+
* console.log(result.tier) // 'code' or 'generative'
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @packageDocumentation
|
|
51
|
+
*/
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Constants
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Ordered list of capability tiers
|
|
57
|
+
*/
|
|
58
|
+
export const TIER_ORDER = ['code', 'generative', 'agentic', 'human'];
|
|
59
|
+
/**
|
|
60
|
+
* Default timeouts per tier (in milliseconds)
|
|
61
|
+
*/
|
|
62
|
+
export const DEFAULT_TIER_TIMEOUTS = {
|
|
63
|
+
code: 5000, // 5 seconds
|
|
64
|
+
generative: 30000, // 30 seconds
|
|
65
|
+
agentic: 300000, // 5 minutes
|
|
66
|
+
human: 86400000, // 24 hours
|
|
67
|
+
};
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Errors
|
|
70
|
+
// ============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* Error thrown when cascade times out
|
|
73
|
+
*/
|
|
74
|
+
export class CascadeTimeoutError extends Error {
|
|
75
|
+
timeout;
|
|
76
|
+
elapsed;
|
|
77
|
+
constructor(timeout, elapsed) {
|
|
78
|
+
super(`Cascade timed out after ${elapsed}ms (limit: ${timeout}ms)`);
|
|
79
|
+
this.name = 'CascadeTimeoutError';
|
|
80
|
+
this.timeout = timeout;
|
|
81
|
+
this.elapsed = elapsed;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error thrown when a tier is skipped
|
|
86
|
+
*/
|
|
87
|
+
export class TierSkippedError extends Error {
|
|
88
|
+
tier;
|
|
89
|
+
reason;
|
|
90
|
+
constructor(tier, reason) {
|
|
91
|
+
super(`Tier '${tier}' was skipped: ${reason}`);
|
|
92
|
+
this.name = 'TierSkippedError';
|
|
93
|
+
this.tier = tier;
|
|
94
|
+
this.reason = reason;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Error thrown when all tiers fail
|
|
99
|
+
*/
|
|
100
|
+
export class AllTiersFailedError extends Error {
|
|
101
|
+
history;
|
|
102
|
+
constructor(history) {
|
|
103
|
+
super('All cascade tiers failed');
|
|
104
|
+
this.name = 'AllTiersFailedError';
|
|
105
|
+
this.history = history;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Helper Functions
|
|
110
|
+
// ============================================================================
|
|
111
|
+
/**
|
|
112
|
+
* Create a cascade context for tracing
|
|
113
|
+
*/
|
|
114
|
+
export function createCascadeContext(options) {
|
|
115
|
+
return {
|
|
116
|
+
correlationId: `cascade-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
117
|
+
name: options.name,
|
|
118
|
+
steps: [],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Record a step in the cascade context
|
|
123
|
+
*/
|
|
124
|
+
export function recordStep(context, tier, meta) {
|
|
125
|
+
const step = {
|
|
126
|
+
id: `${tier}-${Date.now()}`,
|
|
127
|
+
tier,
|
|
128
|
+
status: 'running',
|
|
129
|
+
startTime: Date.now(),
|
|
130
|
+
};
|
|
131
|
+
context.steps.push(step);
|
|
132
|
+
return {
|
|
133
|
+
complete: () => {
|
|
134
|
+
step.status = 'completed';
|
|
135
|
+
step.endTime = Date.now();
|
|
136
|
+
},
|
|
137
|
+
fail: (error) => {
|
|
138
|
+
step.status = 'failed';
|
|
139
|
+
step.endTime = Date.now();
|
|
140
|
+
step.error = error.message;
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// CascadeExecutor
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* CascadeExecutor implements the code -> generative -> agentic -> human pattern
|
|
149
|
+
*
|
|
150
|
+
* This is the base executor for cascade patterns, suitable for both
|
|
151
|
+
* synchronous and worker contexts.
|
|
152
|
+
*/
|
|
153
|
+
export class CascadeExecutor {
|
|
154
|
+
config;
|
|
155
|
+
actor;
|
|
156
|
+
cascadeName;
|
|
157
|
+
constructor(config) {
|
|
158
|
+
this.config = config;
|
|
159
|
+
this.actor = config.actor || 'system';
|
|
160
|
+
this.cascadeName = config.cascadeName || 'cascade';
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Execute the cascade
|
|
164
|
+
*/
|
|
165
|
+
async execute(input) {
|
|
166
|
+
const startTime = Date.now();
|
|
167
|
+
const context = createCascadeContext({ name: this.cascadeName });
|
|
168
|
+
const history = [];
|
|
169
|
+
const skippedTiers = [];
|
|
170
|
+
const tierDurations = {};
|
|
171
|
+
const previousErrors = [];
|
|
172
|
+
// Emit cascade start event
|
|
173
|
+
this.emitEvent({
|
|
174
|
+
who: this.actor,
|
|
175
|
+
what: 'cascade-start',
|
|
176
|
+
when: startTime,
|
|
177
|
+
where: this.cascadeName,
|
|
178
|
+
how: {
|
|
179
|
+
status: 'running',
|
|
180
|
+
metadata: { input },
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
// Set up total timeout if configured
|
|
184
|
+
let totalTimeoutId;
|
|
185
|
+
let totalTimedOut = false;
|
|
186
|
+
const totalTimeoutPromise = new Promise((_, reject) => {
|
|
187
|
+
if (this.config.totalTimeout) {
|
|
188
|
+
totalTimeoutId = setTimeout(() => {
|
|
189
|
+
totalTimedOut = true;
|
|
190
|
+
reject(new CascadeTimeoutError(this.config.totalTimeout, Date.now() - startTime));
|
|
191
|
+
}, this.config.totalTimeout);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
try {
|
|
195
|
+
// Execute tiers in order
|
|
196
|
+
for (const tier of TIER_ORDER) {
|
|
197
|
+
if (totalTimedOut)
|
|
198
|
+
break;
|
|
199
|
+
const handler = this.config.tiers[tier];
|
|
200
|
+
// Check if tier should be skipped
|
|
201
|
+
if (!handler) {
|
|
202
|
+
skippedTiers.push(tier);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// Check skip condition
|
|
206
|
+
const skipCondition = this.config.skipConditions?.[tier];
|
|
207
|
+
if (skipCondition && skipCondition(input)) {
|
|
208
|
+
skippedTiers.push(tier);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
// Execute tier
|
|
212
|
+
const tierResult = await this.executeTier(tier, handler, input, context, previousErrors, startTime, totalTimeoutPromise);
|
|
213
|
+
history.push(tierResult);
|
|
214
|
+
tierDurations[tier] = tierResult.duration;
|
|
215
|
+
// If tier succeeded, we're done
|
|
216
|
+
if (tierResult.success && tierResult.value !== undefined) {
|
|
217
|
+
if (totalTimeoutId)
|
|
218
|
+
clearTimeout(totalTimeoutId);
|
|
219
|
+
const endTime = Date.now();
|
|
220
|
+
this.emitEvent({
|
|
221
|
+
who: this.actor,
|
|
222
|
+
what: 'cascade-complete',
|
|
223
|
+
when: endTime,
|
|
224
|
+
where: this.cascadeName,
|
|
225
|
+
how: {
|
|
226
|
+
status: 'completed',
|
|
227
|
+
duration: endTime - startTime,
|
|
228
|
+
metadata: { tier, value: tierResult.value },
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
value: tierResult.value,
|
|
233
|
+
tier,
|
|
234
|
+
history,
|
|
235
|
+
skippedTiers,
|
|
236
|
+
context,
|
|
237
|
+
metrics: {
|
|
238
|
+
totalDuration: endTime - startTime,
|
|
239
|
+
tierDurations,
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
// Record error for next tier
|
|
244
|
+
if (tierResult.error) {
|
|
245
|
+
previousErrors.push({
|
|
246
|
+
tier,
|
|
247
|
+
error: tierResult.error.message,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Check if we timed out
|
|
252
|
+
if (totalTimedOut) {
|
|
253
|
+
if (totalTimeoutId)
|
|
254
|
+
clearTimeout(totalTimeoutId);
|
|
255
|
+
throw new CascadeTimeoutError(this.config.totalTimeout, Date.now() - startTime);
|
|
256
|
+
}
|
|
257
|
+
// All tiers failed
|
|
258
|
+
if (totalTimeoutId)
|
|
259
|
+
clearTimeout(totalTimeoutId);
|
|
260
|
+
throw new AllTiersFailedError(history);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
if (totalTimeoutId)
|
|
264
|
+
clearTimeout(totalTimeoutId);
|
|
265
|
+
const endTime = Date.now();
|
|
266
|
+
this.emitEvent({
|
|
267
|
+
who: this.actor,
|
|
268
|
+
what: 'cascade-failed',
|
|
269
|
+
when: endTime,
|
|
270
|
+
where: this.cascadeName,
|
|
271
|
+
why: error instanceof Error ? error.message : String(error),
|
|
272
|
+
how: {
|
|
273
|
+
status: 'failed',
|
|
274
|
+
duration: endTime - startTime,
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Execute a single tier with timeout and retry support
|
|
282
|
+
*/
|
|
283
|
+
async executeTier(tier, handler, input, cascadeContext, previousErrors, cascadeStartTime, totalTimeoutPromise) {
|
|
284
|
+
const tierStartTime = Date.now();
|
|
285
|
+
// Record step start
|
|
286
|
+
const step = recordStep(cascadeContext, tier, {
|
|
287
|
+
actor: this.actor,
|
|
288
|
+
action: `execute-${tier}`,
|
|
289
|
+
});
|
|
290
|
+
// Emit tier start event
|
|
291
|
+
this.emitEvent({
|
|
292
|
+
who: this.actor,
|
|
293
|
+
what: `tier-${tier}-execute`,
|
|
294
|
+
when: tierStartTime,
|
|
295
|
+
where: this.cascadeName,
|
|
296
|
+
how: {
|
|
297
|
+
status: 'running',
|
|
298
|
+
metadata: { tier },
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
// Determine timeout
|
|
302
|
+
const timeout = this.getTierTimeout(tier);
|
|
303
|
+
// Create tier context
|
|
304
|
+
const tierContext = {
|
|
305
|
+
correlationId: cascadeContext.correlationId,
|
|
306
|
+
tier,
|
|
307
|
+
input,
|
|
308
|
+
cascadeContext,
|
|
309
|
+
previousErrors: [...previousErrors],
|
|
310
|
+
};
|
|
311
|
+
// Get retry config
|
|
312
|
+
const retryConfig = this.config.retryConfig?.[tier];
|
|
313
|
+
const maxRetries = retryConfig?.maxRetries ?? 0;
|
|
314
|
+
let lastError;
|
|
315
|
+
let attempts = 0;
|
|
316
|
+
while (attempts <= maxRetries) {
|
|
317
|
+
attempts++;
|
|
318
|
+
try {
|
|
319
|
+
// Execute with timeout
|
|
320
|
+
const result = await this.executeWithTimeout(() => handler.execute(input, tierContext), timeout, totalTimeoutPromise);
|
|
321
|
+
const duration = Date.now() - tierStartTime;
|
|
322
|
+
// Mark step complete
|
|
323
|
+
step.complete();
|
|
324
|
+
// Emit tier success event
|
|
325
|
+
this.emitEvent({
|
|
326
|
+
who: this.actor,
|
|
327
|
+
what: `tier-${tier}-execute`,
|
|
328
|
+
when: Date.now(),
|
|
329
|
+
where: this.cascadeName,
|
|
330
|
+
how: {
|
|
331
|
+
status: 'completed',
|
|
332
|
+
duration,
|
|
333
|
+
metadata: { tier, result, attempts },
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
return {
|
|
337
|
+
tier,
|
|
338
|
+
success: true,
|
|
339
|
+
value: result,
|
|
340
|
+
duration,
|
|
341
|
+
attempts,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
346
|
+
// Check if it's a timeout error
|
|
347
|
+
const isTimeout = lastError.message.includes('timed out') || lastError.name === 'TimeoutError';
|
|
348
|
+
// If we've exhausted retries or it's a total timeout, stop
|
|
349
|
+
if (attempts > maxRetries || lastError instanceof CascadeTimeoutError) {
|
|
350
|
+
const duration = Date.now() - tierStartTime;
|
|
351
|
+
// Mark step failed
|
|
352
|
+
step.fail(lastError);
|
|
353
|
+
// Emit tier failure event
|
|
354
|
+
this.emitEvent({
|
|
355
|
+
who: this.actor,
|
|
356
|
+
what: `tier-${tier}-execute`,
|
|
357
|
+
when: Date.now(),
|
|
358
|
+
where: this.cascadeName,
|
|
359
|
+
why: lastError.message,
|
|
360
|
+
how: {
|
|
361
|
+
status: 'failed',
|
|
362
|
+
duration,
|
|
363
|
+
metadata: { tier, error: lastError.message, attempts },
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
// Emit escalation event if not last tier
|
|
367
|
+
const nextTier = this.getNextConfiguredTier(tier);
|
|
368
|
+
if (nextTier) {
|
|
369
|
+
this.emitEvent({
|
|
370
|
+
who: this.actor,
|
|
371
|
+
what: `escalate-to-${nextTier}`,
|
|
372
|
+
when: Date.now(),
|
|
373
|
+
where: this.cascadeName,
|
|
374
|
+
why: lastError.message,
|
|
375
|
+
how: {
|
|
376
|
+
status: 'running',
|
|
377
|
+
metadata: { fromTier: tier, toTier: nextTier },
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
tier,
|
|
383
|
+
success: false,
|
|
384
|
+
error: lastError,
|
|
385
|
+
timedOut: isTimeout,
|
|
386
|
+
duration,
|
|
387
|
+
attempts,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
// Wait before retry with exponential backoff
|
|
391
|
+
if (retryConfig) {
|
|
392
|
+
const delay = retryConfig.baseDelay * Math.pow(retryConfig.multiplier ?? 2, attempts - 1);
|
|
393
|
+
await this.sleep(delay);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// Should not reach here, but handle edge case
|
|
398
|
+
const duration = Date.now() - tierStartTime;
|
|
399
|
+
return {
|
|
400
|
+
tier,
|
|
401
|
+
success: false,
|
|
402
|
+
...(lastError !== undefined && { error: lastError }),
|
|
403
|
+
duration,
|
|
404
|
+
attempts,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Execute a function with a timeout
|
|
409
|
+
*/
|
|
410
|
+
async executeWithTimeout(fn, timeout, totalTimeoutPromise) {
|
|
411
|
+
const promises = [fn()];
|
|
412
|
+
// Add total timeout race
|
|
413
|
+
if (this.config.totalTimeout) {
|
|
414
|
+
promises.push(totalTimeoutPromise);
|
|
415
|
+
}
|
|
416
|
+
// Add tier timeout
|
|
417
|
+
if (timeout) {
|
|
418
|
+
promises.push(new Promise((_, reject) => {
|
|
419
|
+
setTimeout(() => {
|
|
420
|
+
const error = new Error(`Tier timed out after ${timeout}ms`);
|
|
421
|
+
error.name = 'TimeoutError';
|
|
422
|
+
reject(error);
|
|
423
|
+
}, timeout);
|
|
424
|
+
}));
|
|
425
|
+
}
|
|
426
|
+
return Promise.race(promises);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get timeout for a tier
|
|
430
|
+
*/
|
|
431
|
+
getTierTimeout(tier) {
|
|
432
|
+
if (this.config.timeouts?.[tier]) {
|
|
433
|
+
return this.config.timeouts[tier];
|
|
434
|
+
}
|
|
435
|
+
if (this.config.useDefaultTimeouts) {
|
|
436
|
+
return DEFAULT_TIER_TIMEOUTS[tier];
|
|
437
|
+
}
|
|
438
|
+
return undefined;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Get the next configured tier after the given tier
|
|
442
|
+
*/
|
|
443
|
+
getNextConfiguredTier(currentTier) {
|
|
444
|
+
const currentIndex = TIER_ORDER.indexOf(currentTier);
|
|
445
|
+
for (let i = currentIndex + 1; i < TIER_ORDER.length; i++) {
|
|
446
|
+
const tier = TIER_ORDER[i];
|
|
447
|
+
if (tier && this.config.tiers[tier]) {
|
|
448
|
+
return tier;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Emit a 5W+H event
|
|
455
|
+
*/
|
|
456
|
+
emitEvent(event) {
|
|
457
|
+
if (this.config.onEvent) {
|
|
458
|
+
this.config.onEvent(event);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Sleep for a given duration
|
|
463
|
+
*/
|
|
464
|
+
sleep(ms) {
|
|
465
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// ============================================================================
|
|
469
|
+
// Helper Functions
|
|
470
|
+
// ============================================================================
|
|
471
|
+
/**
|
|
472
|
+
* Create a cascade step configuration for common patterns
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* const titleCascade = createCascadeStep({
|
|
477
|
+
* name: 'generate-title',
|
|
478
|
+
* code: async (input) => {
|
|
479
|
+
* if (input.template) return { title: input.template }
|
|
480
|
+
* throw new Error('No template')
|
|
481
|
+
* },
|
|
482
|
+
* generative: async (input, ctx) => {
|
|
483
|
+
* const result = await generateProps({
|
|
484
|
+
* schema: { title: 'A compelling title' },
|
|
485
|
+
* context: input
|
|
486
|
+
* })
|
|
487
|
+
* return result.props
|
|
488
|
+
* }
|
|
489
|
+
* })
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
export function createCascadeStep(config) {
|
|
493
|
+
const tiers = {};
|
|
494
|
+
if (config.code) {
|
|
495
|
+
tiers.code = { name: `${config.name}-code`, execute: config.code };
|
|
496
|
+
}
|
|
497
|
+
if (config.generative) {
|
|
498
|
+
tiers.generative = { name: `${config.name}-generative`, execute: config.generative };
|
|
499
|
+
}
|
|
500
|
+
if (config.agentic) {
|
|
501
|
+
tiers.agentic = { name: `${config.name}-agentic`, execute: config.agentic };
|
|
502
|
+
}
|
|
503
|
+
if (config.human) {
|
|
504
|
+
tiers.human = { name: `${config.name}-human`, execute: config.human };
|
|
505
|
+
}
|
|
506
|
+
const cascadeConfig = {
|
|
507
|
+
tiers,
|
|
508
|
+
cascadeName: config.name,
|
|
509
|
+
useDefaultTimeouts: true,
|
|
510
|
+
};
|
|
511
|
+
if (config.timeouts) {
|
|
512
|
+
cascadeConfig.timeouts = config.timeouts;
|
|
513
|
+
}
|
|
514
|
+
if (config.retryConfig) {
|
|
515
|
+
cascadeConfig.retryConfig = config.retryConfig;
|
|
516
|
+
}
|
|
517
|
+
if (config.onEvent) {
|
|
518
|
+
cascadeConfig.onEvent = config.onEvent;
|
|
519
|
+
}
|
|
520
|
+
return new CascadeExecutor(cascadeConfig);
|
|
521
|
+
}
|
|
522
|
+
//# sourceMappingURL=cascade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascade.js","sourceRoot":"","sources":["../src/cascade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,CAAU,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