@upstash/workflow 0.2.22 → 0.3.0-rc
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/astro.d.mts +3 -5
- package/astro.d.ts +3 -5
- package/astro.js +7 -331
- package/astro.mjs +1 -1
- package/{chunk-BON2RKOR.mjs → chunk-AGYYZKP7.mjs} +7 -365
- package/cloudflare.d.mts +3 -5
- package/cloudflare.d.ts +3 -5
- package/cloudflare.js +7 -331
- package/cloudflare.mjs +1 -1
- package/express.d.mts +3 -5
- package/express.d.ts +3 -5
- package/express.js +7 -331
- package/express.mjs +1 -1
- package/h3.d.mts +3 -5
- package/h3.d.ts +3 -5
- package/h3.js +17 -344
- package/h3.mjs +11 -14
- package/hono.d.mts +4 -6
- package/hono.d.ts +4 -6
- package/hono.js +7 -331
- package/hono.mjs +1 -1
- package/index.d.mts +3 -5
- package/index.d.ts +3 -5
- package/index.js +7 -365
- package/index.mjs +1 -4
- package/nextjs.d.mts +4 -6
- package/nextjs.d.ts +4 -6
- package/nextjs.js +7 -331
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/{serve-many-CctdYIfB.d.mts → serve-many-DEwKPF6H.d.mts} +1 -1
- package/{serve-many-BXDr30rl.d.ts → serve-many-DVtHRxeg.d.ts} +1 -1
- package/solidjs.d.mts +1 -3
- package/solidjs.d.ts +1 -3
- package/solidjs.js +7 -331
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +4 -6
- package/svelte.d.ts +4 -6
- package/svelte.js +7 -331
- package/svelte.mjs +1 -1
- package/tanstack.d.mts +3 -5
- package/tanstack.d.ts +3 -5
- package/tanstack.js +7 -331
- package/tanstack.mjs +1 -1
- package/{types-9nCq6bRP.d.ts → types-DESkn7K9.d.mts} +4 -306
- package/{types-9nCq6bRP.d.mts → types-DESkn7K9.d.ts} +4 -306
package/index.js
CHANGED
|
@@ -28,7 +28,6 @@ __export(src_exports, {
|
|
|
28
28
|
WorkflowLogger: () => WorkflowLogger,
|
|
29
29
|
WorkflowNonRetryableError: () => WorkflowNonRetryableError,
|
|
30
30
|
WorkflowRetryAfterError: () => WorkflowRetryAfterError,
|
|
31
|
-
WorkflowTool: () => WorkflowTool,
|
|
32
31
|
serve: () => serve
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -194,12 +193,11 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
194
193
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
195
194
|
var NO_CONCURRENCY = 1;
|
|
196
195
|
var DEFAULT_RETRIES = 3;
|
|
197
|
-
var VERSION = "v0.
|
|
196
|
+
var VERSION = "v0.3.0-rc";
|
|
198
197
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
199
198
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
200
199
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
201
200
|
var TELEMETRY_HEADER_RUNTIME = "Upstash-Telemetry-Runtime";
|
|
202
|
-
var TELEMETRY_HEADER_AGENT = "Upstash-Telemetry-Agent";
|
|
203
201
|
|
|
204
202
|
// src/context/auto-executor.ts
|
|
205
203
|
var import_qstash5 = require("@upstash/qstash");
|
|
@@ -572,9 +570,9 @@ var Ok = class {
|
|
|
572
570
|
}
|
|
573
571
|
safeUnwrap() {
|
|
574
572
|
const value = this.value;
|
|
575
|
-
return function* () {
|
|
573
|
+
return (function* () {
|
|
576
574
|
return value;
|
|
577
|
-
}();
|
|
575
|
+
})();
|
|
578
576
|
}
|
|
579
577
|
_unsafeUnwrap(_) {
|
|
580
578
|
return this.value;
|
|
@@ -633,10 +631,10 @@ var Err = class {
|
|
|
633
631
|
}
|
|
634
632
|
safeUnwrap() {
|
|
635
633
|
const error = this.error;
|
|
636
|
-
return function* () {
|
|
634
|
+
return (function* () {
|
|
637
635
|
yield err(error);
|
|
638
636
|
throw new Error("Do not use this generator out of `safeTry`");
|
|
639
|
-
}();
|
|
637
|
+
})();
|
|
640
638
|
}
|
|
641
639
|
_unsafeUnwrap(config) {
|
|
642
640
|
throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
|
|
@@ -1603,20 +1601,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1603
1601
|
}
|
|
1604
1602
|
};
|
|
1605
1603
|
|
|
1606
|
-
// src/agents/constants.ts
|
|
1607
|
-
var AGENT_NAME_HEADER = "upstash-agent-name";
|
|
1608
|
-
var MANAGER_AGENT_PROMPT = `You are an agent orchestrating other AI Agents.
|
|
1609
|
-
|
|
1610
|
-
These other agents have tools available to them.
|
|
1611
|
-
|
|
1612
|
-
Given a prompt, utilize these agents to address requests.
|
|
1613
|
-
|
|
1614
|
-
Don't always call all the agents provided to you at the same time. You can call one and use it's response to call another.
|
|
1615
|
-
|
|
1616
|
-
Avoid calling the same agent twice in one turn. Instead, prefer to call it once but provide everything
|
|
1617
|
-
you need from that agent.
|
|
1618
|
-
`;
|
|
1619
|
-
|
|
1620
1604
|
// src/qstash/headers.ts
|
|
1621
1605
|
var WorkflowHeaders = class {
|
|
1622
1606
|
userHeaders;
|
|
@@ -1665,8 +1649,7 @@ var WorkflowHeaders = class {
|
|
|
1665
1649
|
[WORKFLOW_URL_HEADER]: this.workflowConfig.workflowUrl,
|
|
1666
1650
|
[WORKFLOW_FEATURE_HEADER]: "LazyFetch,InitialBody,WF_DetectTrigger" + (this.keepTriggerConfig ? ",WF_TriggerOnConfig" : ""),
|
|
1667
1651
|
[WORKFLOW_PROTOCOL_VERSION_HEADER]: WORKFLOW_PROTOCOL_VERSION,
|
|
1668
|
-
...this.workflowConfig.telemetry ? getTelemetryHeaders(this.workflowConfig.telemetry) : {}
|
|
1669
|
-
...this.workflowConfig.telemetry && this.stepInfo?.lazyStep instanceof LazyCallStep && this.stepInfo.lazyStep.headers[AGENT_NAME_HEADER] ? { [TELEMETRY_HEADER_AGENT]: "true" } : {}
|
|
1652
|
+
...this.workflowConfig.telemetry ? getTelemetryHeaders(this.workflowConfig.telemetry) : {}
|
|
1670
1653
|
};
|
|
1671
1654
|
if (this.stepInfo?.lazyStep.stepType !== "Call") {
|
|
1672
1655
|
this.headers.rawHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
|
|
@@ -2329,340 +2312,6 @@ var WorkflowApi = class extends BaseWorkflowApi {
|
|
|
2329
2312
|
}
|
|
2330
2313
|
};
|
|
2331
2314
|
|
|
2332
|
-
// src/agents/index.ts
|
|
2333
|
-
var import_openai2 = require("@ai-sdk/openai");
|
|
2334
|
-
|
|
2335
|
-
// src/agents/adapters.ts
|
|
2336
|
-
var import_ai = require("ai");
|
|
2337
|
-
var fetchWithContextCall = async (context, agentCallParams, ...params) => {
|
|
2338
|
-
const [input, init] = params;
|
|
2339
|
-
try {
|
|
2340
|
-
const headers = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
|
|
2341
|
-
const body = init?.body ? JSON.parse(init.body) : void 0;
|
|
2342
|
-
const agentName = headers[AGENT_NAME_HEADER];
|
|
2343
|
-
const stepName = agentName ? `Call Agent ${agentName}` : "Call Agent";
|
|
2344
|
-
const responseInfo = await context.call(stepName, {
|
|
2345
|
-
url: input.toString(),
|
|
2346
|
-
method: init?.method,
|
|
2347
|
-
headers,
|
|
2348
|
-
body,
|
|
2349
|
-
timeout: agentCallParams?.timeout,
|
|
2350
|
-
retries: agentCallParams?.retries,
|
|
2351
|
-
retryDelay: agentCallParams?.retryDelay,
|
|
2352
|
-
flowControl: agentCallParams?.flowControl
|
|
2353
|
-
});
|
|
2354
|
-
const responseHeaders = new Headers(
|
|
2355
|
-
Object.entries(responseInfo.header).reduce(
|
|
2356
|
-
(acc, [key, values]) => {
|
|
2357
|
-
acc[key] = values.join(", ");
|
|
2358
|
-
return acc;
|
|
2359
|
-
},
|
|
2360
|
-
{}
|
|
2361
|
-
)
|
|
2362
|
-
);
|
|
2363
|
-
return new Response(JSON.stringify(responseInfo.body), {
|
|
2364
|
-
status: responseInfo.status,
|
|
2365
|
-
headers: responseHeaders
|
|
2366
|
-
});
|
|
2367
|
-
} catch (error) {
|
|
2368
|
-
if (error instanceof Error && isInstanceOf(error, WorkflowAbort)) {
|
|
2369
|
-
throw error;
|
|
2370
|
-
} else {
|
|
2371
|
-
console.error("Error in fetch implementation:", error);
|
|
2372
|
-
throw error;
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
};
|
|
2376
|
-
var createWorkflowModel = ({
|
|
2377
|
-
context,
|
|
2378
|
-
provider,
|
|
2379
|
-
providerParams,
|
|
2380
|
-
agentCallParams
|
|
2381
|
-
}) => {
|
|
2382
|
-
return provider({
|
|
2383
|
-
fetch: (...params) => fetchWithContextCall(context, agentCallParams, ...params),
|
|
2384
|
-
...providerParams
|
|
2385
|
-
});
|
|
2386
|
-
};
|
|
2387
|
-
var wrapTools = ({
|
|
2388
|
-
context,
|
|
2389
|
-
tools
|
|
2390
|
-
}) => {
|
|
2391
|
-
return Object.fromEntries(
|
|
2392
|
-
Object.entries(tools).map((toolInfo) => {
|
|
2393
|
-
const [toolName, tool3] = toolInfo;
|
|
2394
|
-
const executeAsStep = "executeAsStep" in tool3 ? tool3.executeAsStep : true;
|
|
2395
|
-
const aiSDKTool = convertToAISDKTool(tool3);
|
|
2396
|
-
const execute = aiSDKTool.execute;
|
|
2397
|
-
if (execute && executeAsStep) {
|
|
2398
|
-
const wrappedExecute = (...params) => {
|
|
2399
|
-
return context.run(`Run tool ${toolName}`, () => execute(...params));
|
|
2400
|
-
};
|
|
2401
|
-
aiSDKTool.execute = wrappedExecute;
|
|
2402
|
-
}
|
|
2403
|
-
return [toolName, aiSDKTool];
|
|
2404
|
-
})
|
|
2405
|
-
);
|
|
2406
|
-
};
|
|
2407
|
-
var convertToAISDKTool = (tool3) => {
|
|
2408
|
-
const isLangchainTool = "invoke" in tool3;
|
|
2409
|
-
return isLangchainTool ? convertLangchainTool(tool3) : tool3;
|
|
2410
|
-
};
|
|
2411
|
-
var convertLangchainTool = (langchainTool) => {
|
|
2412
|
-
return (0, import_ai.tool)({
|
|
2413
|
-
description: langchainTool.description,
|
|
2414
|
-
parameters: langchainTool.schema,
|
|
2415
|
-
execute: async (...param) => langchainTool.invoke(...param)
|
|
2416
|
-
});
|
|
2417
|
-
};
|
|
2418
|
-
var WorkflowTool = class {
|
|
2419
|
-
/**
|
|
2420
|
-
* description of the tool
|
|
2421
|
-
*/
|
|
2422
|
-
description;
|
|
2423
|
-
/**
|
|
2424
|
-
* schema of the tool
|
|
2425
|
-
*/
|
|
2426
|
-
schema;
|
|
2427
|
-
/**
|
|
2428
|
-
* function to invoke the tool
|
|
2429
|
-
*/
|
|
2430
|
-
invoke;
|
|
2431
|
-
/**
|
|
2432
|
-
* whether the invoke method of the tool is to be wrapped with `context.run`
|
|
2433
|
-
*/
|
|
2434
|
-
executeAsStep;
|
|
2435
|
-
/**
|
|
2436
|
-
*
|
|
2437
|
-
* @param description description of the tool
|
|
2438
|
-
* @param schema schema of the tool
|
|
2439
|
-
* @param invoke function to invoke the tool
|
|
2440
|
-
* @param executeAsStep whether the invoke method of the tool is to be wrapped with `context.run`
|
|
2441
|
-
*/
|
|
2442
|
-
constructor(params) {
|
|
2443
|
-
this.description = params.description;
|
|
2444
|
-
this.schema = params.schema;
|
|
2445
|
-
this.invoke = params.invoke;
|
|
2446
|
-
this.executeAsStep = params.executeAsStep ?? true;
|
|
2447
|
-
}
|
|
2448
|
-
};
|
|
2449
|
-
|
|
2450
|
-
// src/agents/agent.ts
|
|
2451
|
-
var import_zod = require("zod");
|
|
2452
|
-
var import_ai2 = require("ai");
|
|
2453
|
-
|
|
2454
|
-
// src/serve/utils.ts
|
|
2455
|
-
var isDisabledWorkflowContext = (context) => {
|
|
2456
|
-
return "disabled" in context;
|
|
2457
|
-
};
|
|
2458
|
-
|
|
2459
|
-
// src/agents/agent.ts
|
|
2460
|
-
var Agent = class {
|
|
2461
|
-
name;
|
|
2462
|
-
tools;
|
|
2463
|
-
maxSteps;
|
|
2464
|
-
background;
|
|
2465
|
-
model;
|
|
2466
|
-
temparature;
|
|
2467
|
-
context;
|
|
2468
|
-
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
2469
|
-
this.name = name;
|
|
2470
|
-
this.tools = tools ?? {};
|
|
2471
|
-
this.maxSteps = maxSteps;
|
|
2472
|
-
this.background = background;
|
|
2473
|
-
this.model = model;
|
|
2474
|
-
this.temparature = temparature;
|
|
2475
|
-
this.context = context;
|
|
2476
|
-
}
|
|
2477
|
-
/**
|
|
2478
|
-
* Trigger the agent by passing a prompt
|
|
2479
|
-
*
|
|
2480
|
-
* @param prompt task to assign to the agent
|
|
2481
|
-
* @returns Response as `{ text: string }`
|
|
2482
|
-
*/
|
|
2483
|
-
async call({ prompt }) {
|
|
2484
|
-
try {
|
|
2485
|
-
if (isDisabledWorkflowContext(this.context)) {
|
|
2486
|
-
await this.context.sleep("abort", 0);
|
|
2487
|
-
}
|
|
2488
|
-
const result = await (0, import_ai2.generateText)({
|
|
2489
|
-
model: this.model,
|
|
2490
|
-
tools: this.tools,
|
|
2491
|
-
maxSteps: this.maxSteps,
|
|
2492
|
-
system: this.background,
|
|
2493
|
-
prompt,
|
|
2494
|
-
headers: {
|
|
2495
|
-
[AGENT_NAME_HEADER]: this.name
|
|
2496
|
-
},
|
|
2497
|
-
temperature: this.temparature
|
|
2498
|
-
});
|
|
2499
|
-
return { text: result.text };
|
|
2500
|
-
} catch (error) {
|
|
2501
|
-
if (isInstanceOf(error, import_ai2.ToolExecutionError)) {
|
|
2502
|
-
if (error.cause instanceof Error && isInstanceOf(error.cause, WorkflowAbort)) {
|
|
2503
|
-
throw error.cause;
|
|
2504
|
-
} else if (isInstanceOf(error.cause, import_ai2.ToolExecutionError) && isInstanceOf(error.cause.cause, WorkflowAbort)) {
|
|
2505
|
-
throw error.cause.cause;
|
|
2506
|
-
} else {
|
|
2507
|
-
throw error;
|
|
2508
|
-
}
|
|
2509
|
-
} else {
|
|
2510
|
-
throw error;
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
/**
|
|
2515
|
-
* Convert the agent to a tool which can be used by other agents.
|
|
2516
|
-
*
|
|
2517
|
-
* @returns the agent as a tool
|
|
2518
|
-
*/
|
|
2519
|
-
asTool() {
|
|
2520
|
-
const toolDescriptions = Object.values(this.tools).map((tool3) => tool3.description).join("\n");
|
|
2521
|
-
return (0, import_ai2.tool)({
|
|
2522
|
-
parameters: import_zod.z.object({ prompt: import_zod.z.string() }),
|
|
2523
|
-
execute: async ({ prompt }) => {
|
|
2524
|
-
return await this.call({ prompt });
|
|
2525
|
-
},
|
|
2526
|
-
description: `An AI Agent with the following background: ${this.background}Has access to the following tools: ${toolDescriptions}`
|
|
2527
|
-
});
|
|
2528
|
-
}
|
|
2529
|
-
};
|
|
2530
|
-
var ManagerAgent = class extends Agent {
|
|
2531
|
-
agents;
|
|
2532
|
-
/**
|
|
2533
|
-
* A manager agent which coordinates agents available to it to achieve a
|
|
2534
|
-
* given task
|
|
2535
|
-
*
|
|
2536
|
-
* @param name Name of the agent
|
|
2537
|
-
* @param background Background of the agent. If not passed, default will be used.
|
|
2538
|
-
* @param model LLM model to use
|
|
2539
|
-
* @param agents: List of agents available to the agent
|
|
2540
|
-
* @param maxSteps number of times the manager agent can call the LLM at most.
|
|
2541
|
-
* If the agent abruptly stops execution after calling other agents, you may
|
|
2542
|
-
* need to increase maxSteps
|
|
2543
|
-
*/
|
|
2544
|
-
constructor({
|
|
2545
|
-
agents,
|
|
2546
|
-
background = MANAGER_AGENT_PROMPT,
|
|
2547
|
-
model,
|
|
2548
|
-
maxSteps,
|
|
2549
|
-
name = "manager llm"
|
|
2550
|
-
}, context) {
|
|
2551
|
-
super(
|
|
2552
|
-
{
|
|
2553
|
-
background,
|
|
2554
|
-
maxSteps,
|
|
2555
|
-
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
2556
|
-
name,
|
|
2557
|
-
model
|
|
2558
|
-
},
|
|
2559
|
-
context
|
|
2560
|
-
);
|
|
2561
|
-
this.agents = agents;
|
|
2562
|
-
}
|
|
2563
|
-
};
|
|
2564
|
-
|
|
2565
|
-
// src/agents/task.ts
|
|
2566
|
-
var Task = class {
|
|
2567
|
-
context;
|
|
2568
|
-
taskParameters;
|
|
2569
|
-
constructor({
|
|
2570
|
-
context,
|
|
2571
|
-
taskParameters
|
|
2572
|
-
}) {
|
|
2573
|
-
this.context = context;
|
|
2574
|
-
this.taskParameters = taskParameters;
|
|
2575
|
-
}
|
|
2576
|
-
/**
|
|
2577
|
-
* Run the agents to complete the task
|
|
2578
|
-
*
|
|
2579
|
-
* @returns Result of the task as { text: string }
|
|
2580
|
-
*/
|
|
2581
|
-
async run() {
|
|
2582
|
-
const { prompt, ...otherParams } = this.taskParameters;
|
|
2583
|
-
if ("agent" in otherParams) {
|
|
2584
|
-
const agent = otherParams.agent;
|
|
2585
|
-
const result = await agent.call({
|
|
2586
|
-
prompt
|
|
2587
|
-
});
|
|
2588
|
-
return { text: result.text };
|
|
2589
|
-
} else {
|
|
2590
|
-
const { agents, maxSteps, model, background } = otherParams;
|
|
2591
|
-
const managerAgent = new ManagerAgent(
|
|
2592
|
-
{
|
|
2593
|
-
model,
|
|
2594
|
-
maxSteps,
|
|
2595
|
-
agents,
|
|
2596
|
-
name: "Manager LLM",
|
|
2597
|
-
background
|
|
2598
|
-
},
|
|
2599
|
-
this.context
|
|
2600
|
-
);
|
|
2601
|
-
const result = await managerAgent.call({ prompt });
|
|
2602
|
-
return { text: result.text };
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
};
|
|
2606
|
-
|
|
2607
|
-
// src/agents/index.ts
|
|
2608
|
-
var WorkflowAgents = class {
|
|
2609
|
-
context;
|
|
2610
|
-
constructor({ context }) {
|
|
2611
|
-
this.context = context;
|
|
2612
|
-
}
|
|
2613
|
-
/**
|
|
2614
|
-
* Defines an agent
|
|
2615
|
-
*
|
|
2616
|
-
* ```ts
|
|
2617
|
-
* const researcherAgent = context.agents.agent({
|
|
2618
|
-
* model,
|
|
2619
|
-
* name: 'academic',
|
|
2620
|
-
* maxSteps: 2,
|
|
2621
|
-
* tools: {
|
|
2622
|
-
* wikiTool: new WikipediaQueryRun({
|
|
2623
|
-
* topKResults: 1,
|
|
2624
|
-
* maxDocContentLength: 500,
|
|
2625
|
-
* })
|
|
2626
|
-
* },
|
|
2627
|
-
* background:
|
|
2628
|
-
* 'You are researcher agent with access to Wikipedia. ' +
|
|
2629
|
-
* 'Utilize Wikipedia as much as possible for correct information',
|
|
2630
|
-
* });
|
|
2631
|
-
* ```
|
|
2632
|
-
*
|
|
2633
|
-
* @param params agent parameters
|
|
2634
|
-
* @returns
|
|
2635
|
-
*/
|
|
2636
|
-
agent(params) {
|
|
2637
|
-
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
2638
|
-
return new Agent(
|
|
2639
|
-
{
|
|
2640
|
-
...params,
|
|
2641
|
-
tools: wrappedTools
|
|
2642
|
-
},
|
|
2643
|
-
this.context
|
|
2644
|
-
);
|
|
2645
|
-
}
|
|
2646
|
-
task(taskParameters) {
|
|
2647
|
-
return new Task({ context: this.context, taskParameters });
|
|
2648
|
-
}
|
|
2649
|
-
/**
|
|
2650
|
-
* creates an openai model for agents
|
|
2651
|
-
*/
|
|
2652
|
-
openai(...params) {
|
|
2653
|
-
const [model, settings] = params;
|
|
2654
|
-
const { baseURL, apiKey, callSettings, ...otherSettings } = settings ?? {};
|
|
2655
|
-
const openaiModel = this.AISDKModel({
|
|
2656
|
-
context: this.context,
|
|
2657
|
-
provider: import_openai2.createOpenAI,
|
|
2658
|
-
providerParams: { baseURL, apiKey, compatibility: "strict" },
|
|
2659
|
-
agentCallParams: callSettings
|
|
2660
|
-
});
|
|
2661
|
-
return openaiModel(model, otherSettings);
|
|
2662
|
-
}
|
|
2663
|
-
AISDKModel = createWorkflowModel;
|
|
2664
|
-
};
|
|
2665
|
-
|
|
2666
2315
|
// src/serve/serve-many.ts
|
|
2667
2316
|
var getNewUrlFromWorkflowId = (url, workflowId) => {
|
|
2668
2317
|
if (!workflowId) {
|
|
@@ -2904,7 +2553,7 @@ var WorkflowContext = class {
|
|
|
2904
2553
|
* @returns result of the step function
|
|
2905
2554
|
*/
|
|
2906
2555
|
async run(stepName, stepFunction) {
|
|
2907
|
-
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
2556
|
+
const wrappedStepFunction = (() => this.executor.wrapStep(stepName, stepFunction));
|
|
2908
2557
|
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
2909
2558
|
}
|
|
2910
2559
|
/**
|
|
@@ -3075,11 +2724,6 @@ var WorkflowContext = class {
|
|
|
3075
2724
|
context: this
|
|
3076
2725
|
});
|
|
3077
2726
|
}
|
|
3078
|
-
get agents() {
|
|
3079
|
-
return new WorkflowAgents({
|
|
3080
|
-
context: this
|
|
3081
|
-
});
|
|
3082
|
-
}
|
|
3083
2727
|
};
|
|
3084
2728
|
|
|
3085
2729
|
// src/logger.ts
|
|
@@ -3963,7 +3607,6 @@ var Client4 = class {
|
|
|
3963
3607
|
const finalWorkflowRunId = getWorkflowRunId(option.workflowRunId);
|
|
3964
3608
|
const context = new WorkflowContext({
|
|
3965
3609
|
qstashClient: this.client,
|
|
3966
|
-
// @ts-expect-error header type mismatch because of bun
|
|
3967
3610
|
headers: new Headers({
|
|
3968
3611
|
...option.headers ?? {},
|
|
3969
3612
|
...option.label ? { [WORKFLOW_LABEL_HEADER]: option.label } : {}
|
|
@@ -4067,6 +3710,5 @@ var Client4 = class {
|
|
|
4067
3710
|
WorkflowLogger,
|
|
4068
3711
|
WorkflowNonRetryableError,
|
|
4069
3712
|
WorkflowRetryAfterError,
|
|
4070
|
-
WorkflowTool,
|
|
4071
3713
|
serve
|
|
4072
3714
|
});
|
package/index.mjs
CHANGED
|
@@ -8,14 +8,13 @@ import {
|
|
|
8
8
|
WorkflowLogger,
|
|
9
9
|
WorkflowNonRetryableError,
|
|
10
10
|
WorkflowRetryAfterError,
|
|
11
|
-
WorkflowTool,
|
|
12
11
|
getWorkflowRunId,
|
|
13
12
|
makeGetWaitersRequest,
|
|
14
13
|
makeNotifyRequest,
|
|
15
14
|
prepareFlowControl,
|
|
16
15
|
serve,
|
|
17
16
|
triggerFirstInvocation
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-AGYYZKP7.mjs";
|
|
19
18
|
|
|
20
19
|
// src/client/index.ts
|
|
21
20
|
import { Client as QStashClient } from "@upstash/qstash";
|
|
@@ -247,7 +246,6 @@ var Client = class {
|
|
|
247
246
|
const finalWorkflowRunId = getWorkflowRunId(option.workflowRunId);
|
|
248
247
|
const context = new WorkflowContext({
|
|
249
248
|
qstashClient: this.client,
|
|
250
|
-
// @ts-expect-error header type mismatch because of bun
|
|
251
249
|
headers: new Headers({
|
|
252
250
|
...option.headers ?? {},
|
|
253
251
|
...option.label ? { [WORKFLOW_LABEL_HEADER]: option.label } : {}
|
|
@@ -350,6 +348,5 @@ export {
|
|
|
350
348
|
WorkflowLogger,
|
|
351
349
|
WorkflowNonRetryableError,
|
|
352
350
|
WorkflowRetryAfterError,
|
|
353
|
-
WorkflowTool,
|
|
354
351
|
serve
|
|
355
352
|
};
|
package/nextjs.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { R as RouteFunction,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-DESkn7K9.mjs';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-DEwKPF6H.mjs';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import 'ai';
|
|
7
|
-
import '@ai-sdk/openai';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Serve method to serve a Upstash Workflow in a Nextjs project
|
|
@@ -18,14 +16,14 @@ import '@ai-sdk/openai';
|
|
|
18
16
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
19
17
|
POST: (request: Request) => Promise<Response>;
|
|
20
18
|
};
|
|
21
|
-
declare const createWorkflow: <TInitialPayload, TResult>(
|
|
19
|
+
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
22
20
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
23
21
|
POST: (request: Request) => Promise<any>;
|
|
24
22
|
};
|
|
25
23
|
declare const servePagesRouter: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
26
24
|
handler: NextApiHandler;
|
|
27
25
|
};
|
|
28
|
-
declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(
|
|
26
|
+
declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(...params: Parameters<typeof servePagesRouter<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
29
27
|
declare const serveManyPagesRouter: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
30
28
|
handler: (req: NextApiRequest, res: NextApiResponse<any>) => Promise<any>;
|
|
31
29
|
};
|
package/nextjs.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
-
import { R as RouteFunction,
|
|
3
|
-
import { s as serveManyBase } from './serve-many-
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-DESkn7K9.js';
|
|
3
|
+
import { s as serveManyBase } from './serve-many-DVtHRxeg.js';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import 'ai';
|
|
7
|
-
import '@ai-sdk/openai';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Serve method to serve a Upstash Workflow in a Nextjs project
|
|
@@ -18,14 +16,14 @@ import '@ai-sdk/openai';
|
|
|
18
16
|
declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
19
17
|
POST: (request: Request) => Promise<Response>;
|
|
20
18
|
};
|
|
21
|
-
declare const createWorkflow: <TInitialPayload, TResult>(
|
|
19
|
+
declare const createWorkflow: <TInitialPayload, TResult>(...params: Parameters<typeof serve<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
22
20
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
23
21
|
POST: (request: Request) => Promise<any>;
|
|
24
22
|
};
|
|
25
23
|
declare const servePagesRouter: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
26
24
|
handler: NextApiHandler;
|
|
27
25
|
};
|
|
28
|
-
declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(
|
|
26
|
+
declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(...params: Parameters<typeof servePagesRouter<TInitialPayload, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
29
27
|
declare const serveManyPagesRouter: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
|
|
30
28
|
handler: (req: NextApiRequest, res: NextApiResponse<any>) => Promise<any>;
|
|
31
29
|
};
|