@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/h3.js
CHANGED
|
@@ -102,21 +102,16 @@ function hasProp(obj, prop) {
|
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
var __defProp$2 = Object.defineProperty;
|
|
106
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
107
|
-
var __publicField$2 = (obj, key, value) => {
|
|
108
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
109
|
-
return value;
|
|
110
|
-
};
|
|
111
105
|
var H3Error = class extends Error {
|
|
106
|
+
static __h3_error__ = true;
|
|
107
|
+
statusCode = 500;
|
|
108
|
+
fatal = false;
|
|
109
|
+
unhandled = false;
|
|
110
|
+
statusMessage;
|
|
111
|
+
data;
|
|
112
|
+
cause;
|
|
112
113
|
constructor(message, opts = {}) {
|
|
113
114
|
super(message, opts);
|
|
114
|
-
__publicField$2(this, "statusCode", 500);
|
|
115
|
-
__publicField$2(this, "fatal", false);
|
|
116
|
-
__publicField$2(this, "unhandled", false);
|
|
117
|
-
__publicField$2(this, "statusMessage");
|
|
118
|
-
__publicField$2(this, "data");
|
|
119
|
-
__publicField$2(this, "cause");
|
|
120
115
|
if (opts.cause && !this.cause) {
|
|
121
116
|
this.cause = opts.cause;
|
|
122
117
|
}
|
|
@@ -135,7 +130,6 @@ var H3Error = class extends Error {
|
|
|
135
130
|
return obj;
|
|
136
131
|
}
|
|
137
132
|
};
|
|
138
|
-
__publicField$2(H3Error, "__h3_error__", true);
|
|
139
133
|
function createError(input) {
|
|
140
134
|
if (typeof input === "string") {
|
|
141
135
|
return new H3Error(input);
|
|
@@ -258,6 +252,9 @@ function readRawBody(event, encoding = "utf8") {
|
|
|
258
252
|
if (_resolved instanceof URLSearchParams) {
|
|
259
253
|
return Buffer.from(_resolved.toString());
|
|
260
254
|
}
|
|
255
|
+
if (_resolved instanceof FormData) {
|
|
256
|
+
return new Response(_resolved).bytes().then((uint8arr) => Buffer.from(uint8arr));
|
|
257
|
+
}
|
|
261
258
|
return Buffer.from(_resolved);
|
|
262
259
|
});
|
|
263
260
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
|
@@ -492,12 +489,11 @@ var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
|
|
|
492
489
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
493
490
|
var NO_CONCURRENCY = 1;
|
|
494
491
|
var DEFAULT_RETRIES = 3;
|
|
495
|
-
var VERSION = "v0.
|
|
492
|
+
var VERSION = "v0.3.0-rc";
|
|
496
493
|
var SDK_TELEMETRY = `@upstash/workflow@${VERSION}`;
|
|
497
494
|
var TELEMETRY_HEADER_SDK = "Upstash-Telemetry-Sdk";
|
|
498
495
|
var TELEMETRY_HEADER_FRAMEWORK = "Upstash-Telemetry-Framework";
|
|
499
496
|
var TELEMETRY_HEADER_RUNTIME = "Upstash-Telemetry-Runtime";
|
|
500
|
-
var TELEMETRY_HEADER_AGENT = "Upstash-Telemetry-Agent";
|
|
501
497
|
|
|
502
498
|
// src/context/auto-executor.ts
|
|
503
499
|
var import_qstash5 = require("@upstash/qstash");
|
|
@@ -870,9 +866,9 @@ var Ok = class {
|
|
|
870
866
|
}
|
|
871
867
|
safeUnwrap() {
|
|
872
868
|
const value = this.value;
|
|
873
|
-
return function* () {
|
|
869
|
+
return (function* () {
|
|
874
870
|
return value;
|
|
875
|
-
}();
|
|
871
|
+
})();
|
|
876
872
|
}
|
|
877
873
|
_unsafeUnwrap(_) {
|
|
878
874
|
return this.value;
|
|
@@ -931,10 +927,10 @@ var Err = class {
|
|
|
931
927
|
}
|
|
932
928
|
safeUnwrap() {
|
|
933
929
|
const error = this.error;
|
|
934
|
-
return function* () {
|
|
930
|
+
return (function* () {
|
|
935
931
|
yield err(error);
|
|
936
932
|
throw new Error("Do not use this generator out of `safeTry`");
|
|
937
|
-
}();
|
|
933
|
+
})();
|
|
938
934
|
}
|
|
939
935
|
_unsafeUnwrap(config) {
|
|
940
936
|
throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
|
|
@@ -1901,20 +1897,6 @@ var LazyInvokeStep = class extends BaseLazyStep {
|
|
|
1901
1897
|
}
|
|
1902
1898
|
};
|
|
1903
1899
|
|
|
1904
|
-
// src/agents/constants.ts
|
|
1905
|
-
var AGENT_NAME_HEADER = "upstash-agent-name";
|
|
1906
|
-
var MANAGER_AGENT_PROMPT = `You are an agent orchestrating other AI Agents.
|
|
1907
|
-
|
|
1908
|
-
These other agents have tools available to them.
|
|
1909
|
-
|
|
1910
|
-
Given a prompt, utilize these agents to address requests.
|
|
1911
|
-
|
|
1912
|
-
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.
|
|
1913
|
-
|
|
1914
|
-
Avoid calling the same agent twice in one turn. Instead, prefer to call it once but provide everything
|
|
1915
|
-
you need from that agent.
|
|
1916
|
-
`;
|
|
1917
|
-
|
|
1918
1900
|
// src/qstash/headers.ts
|
|
1919
1901
|
var WorkflowHeaders = class {
|
|
1920
1902
|
userHeaders;
|
|
@@ -1963,8 +1945,7 @@ var WorkflowHeaders = class {
|
|
|
1963
1945
|
[WORKFLOW_URL_HEADER]: this.workflowConfig.workflowUrl,
|
|
1964
1946
|
[WORKFLOW_FEATURE_HEADER]: "LazyFetch,InitialBody,WF_DetectTrigger" + (this.keepTriggerConfig ? ",WF_TriggerOnConfig" : ""),
|
|
1965
1947
|
[WORKFLOW_PROTOCOL_VERSION_HEADER]: WORKFLOW_PROTOCOL_VERSION,
|
|
1966
|
-
...this.workflowConfig.telemetry ? getTelemetryHeaders(this.workflowConfig.telemetry) : {}
|
|
1967
|
-
...this.workflowConfig.telemetry && this.stepInfo?.lazyStep instanceof LazyCallStep && this.stepInfo.lazyStep.headers[AGENT_NAME_HEADER] ? { [TELEMETRY_HEADER_AGENT]: "true" } : {}
|
|
1948
|
+
...this.workflowConfig.telemetry ? getTelemetryHeaders(this.workflowConfig.telemetry) : {}
|
|
1968
1949
|
};
|
|
1969
1950
|
if (this.stepInfo?.lazyStep.stepType !== "Call") {
|
|
1970
1951
|
this.headers.rawHeaders[`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`] = WORKFLOW_PROTOCOL_VERSION;
|
|
@@ -2627,309 +2608,6 @@ var WorkflowApi = class extends BaseWorkflowApi {
|
|
|
2627
2608
|
}
|
|
2628
2609
|
};
|
|
2629
2610
|
|
|
2630
|
-
// src/agents/index.ts
|
|
2631
|
-
var import_openai2 = require("@ai-sdk/openai");
|
|
2632
|
-
|
|
2633
|
-
// src/agents/adapters.ts
|
|
2634
|
-
var import_ai = require("ai");
|
|
2635
|
-
var fetchWithContextCall = async (context, agentCallParams, ...params) => {
|
|
2636
|
-
const [input, init] = params;
|
|
2637
|
-
try {
|
|
2638
|
-
const headers = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
|
|
2639
|
-
const body = init?.body ? JSON.parse(init.body) : void 0;
|
|
2640
|
-
const agentName = headers[AGENT_NAME_HEADER];
|
|
2641
|
-
const stepName = agentName ? `Call Agent ${agentName}` : "Call Agent";
|
|
2642
|
-
const responseInfo = await context.call(stepName, {
|
|
2643
|
-
url: input.toString(),
|
|
2644
|
-
method: init?.method,
|
|
2645
|
-
headers,
|
|
2646
|
-
body,
|
|
2647
|
-
timeout: agentCallParams?.timeout,
|
|
2648
|
-
retries: agentCallParams?.retries,
|
|
2649
|
-
retryDelay: agentCallParams?.retryDelay,
|
|
2650
|
-
flowControl: agentCallParams?.flowControl
|
|
2651
|
-
});
|
|
2652
|
-
const responseHeaders = new Headers(
|
|
2653
|
-
Object.entries(responseInfo.header).reduce(
|
|
2654
|
-
(acc, [key, values]) => {
|
|
2655
|
-
acc[key] = values.join(", ");
|
|
2656
|
-
return acc;
|
|
2657
|
-
},
|
|
2658
|
-
{}
|
|
2659
|
-
)
|
|
2660
|
-
);
|
|
2661
|
-
return new Response(JSON.stringify(responseInfo.body), {
|
|
2662
|
-
status: responseInfo.status,
|
|
2663
|
-
headers: responseHeaders
|
|
2664
|
-
});
|
|
2665
|
-
} catch (error) {
|
|
2666
|
-
if (error instanceof Error && isInstanceOf(error, WorkflowAbort)) {
|
|
2667
|
-
throw error;
|
|
2668
|
-
} else {
|
|
2669
|
-
console.error("Error in fetch implementation:", error);
|
|
2670
|
-
throw error;
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
};
|
|
2674
|
-
var createWorkflowModel = ({
|
|
2675
|
-
context,
|
|
2676
|
-
provider,
|
|
2677
|
-
providerParams,
|
|
2678
|
-
agentCallParams
|
|
2679
|
-
}) => {
|
|
2680
|
-
return provider({
|
|
2681
|
-
fetch: (...params) => fetchWithContextCall(context, agentCallParams, ...params),
|
|
2682
|
-
...providerParams
|
|
2683
|
-
});
|
|
2684
|
-
};
|
|
2685
|
-
var wrapTools = ({
|
|
2686
|
-
context,
|
|
2687
|
-
tools
|
|
2688
|
-
}) => {
|
|
2689
|
-
return Object.fromEntries(
|
|
2690
|
-
Object.entries(tools).map((toolInfo) => {
|
|
2691
|
-
const [toolName, tool3] = toolInfo;
|
|
2692
|
-
const executeAsStep = "executeAsStep" in tool3 ? tool3.executeAsStep : true;
|
|
2693
|
-
const aiSDKTool = convertToAISDKTool(tool3);
|
|
2694
|
-
const execute = aiSDKTool.execute;
|
|
2695
|
-
if (execute && executeAsStep) {
|
|
2696
|
-
const wrappedExecute = (...params) => {
|
|
2697
|
-
return context.run(`Run tool ${toolName}`, () => execute(...params));
|
|
2698
|
-
};
|
|
2699
|
-
aiSDKTool.execute = wrappedExecute;
|
|
2700
|
-
}
|
|
2701
|
-
return [toolName, aiSDKTool];
|
|
2702
|
-
})
|
|
2703
|
-
);
|
|
2704
|
-
};
|
|
2705
|
-
var convertToAISDKTool = (tool3) => {
|
|
2706
|
-
const isLangchainTool = "invoke" in tool3;
|
|
2707
|
-
return isLangchainTool ? convertLangchainTool(tool3) : tool3;
|
|
2708
|
-
};
|
|
2709
|
-
var convertLangchainTool = (langchainTool) => {
|
|
2710
|
-
return (0, import_ai.tool)({
|
|
2711
|
-
description: langchainTool.description,
|
|
2712
|
-
parameters: langchainTool.schema,
|
|
2713
|
-
execute: async (...param) => langchainTool.invoke(...param)
|
|
2714
|
-
});
|
|
2715
|
-
};
|
|
2716
|
-
|
|
2717
|
-
// src/agents/agent.ts
|
|
2718
|
-
var import_zod = require("zod");
|
|
2719
|
-
var import_ai2 = require("ai");
|
|
2720
|
-
|
|
2721
|
-
// src/serve/utils.ts
|
|
2722
|
-
var isDisabledWorkflowContext = (context) => {
|
|
2723
|
-
return "disabled" in context;
|
|
2724
|
-
};
|
|
2725
|
-
|
|
2726
|
-
// src/agents/agent.ts
|
|
2727
|
-
var Agent = class {
|
|
2728
|
-
name;
|
|
2729
|
-
tools;
|
|
2730
|
-
maxSteps;
|
|
2731
|
-
background;
|
|
2732
|
-
model;
|
|
2733
|
-
temparature;
|
|
2734
|
-
context;
|
|
2735
|
-
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
2736
|
-
this.name = name;
|
|
2737
|
-
this.tools = tools ?? {};
|
|
2738
|
-
this.maxSteps = maxSteps;
|
|
2739
|
-
this.background = background;
|
|
2740
|
-
this.model = model;
|
|
2741
|
-
this.temparature = temparature;
|
|
2742
|
-
this.context = context;
|
|
2743
|
-
}
|
|
2744
|
-
/**
|
|
2745
|
-
* Trigger the agent by passing a prompt
|
|
2746
|
-
*
|
|
2747
|
-
* @param prompt task to assign to the agent
|
|
2748
|
-
* @returns Response as `{ text: string }`
|
|
2749
|
-
*/
|
|
2750
|
-
async call({ prompt }) {
|
|
2751
|
-
try {
|
|
2752
|
-
if (isDisabledWorkflowContext(this.context)) {
|
|
2753
|
-
await this.context.sleep("abort", 0);
|
|
2754
|
-
}
|
|
2755
|
-
const result = await (0, import_ai2.generateText)({
|
|
2756
|
-
model: this.model,
|
|
2757
|
-
tools: this.tools,
|
|
2758
|
-
maxSteps: this.maxSteps,
|
|
2759
|
-
system: this.background,
|
|
2760
|
-
prompt,
|
|
2761
|
-
headers: {
|
|
2762
|
-
[AGENT_NAME_HEADER]: this.name
|
|
2763
|
-
},
|
|
2764
|
-
temperature: this.temparature
|
|
2765
|
-
});
|
|
2766
|
-
return { text: result.text };
|
|
2767
|
-
} catch (error) {
|
|
2768
|
-
if (isInstanceOf(error, import_ai2.ToolExecutionError)) {
|
|
2769
|
-
if (error.cause instanceof Error && isInstanceOf(error.cause, WorkflowAbort)) {
|
|
2770
|
-
throw error.cause;
|
|
2771
|
-
} else if (isInstanceOf(error.cause, import_ai2.ToolExecutionError) && isInstanceOf(error.cause.cause, WorkflowAbort)) {
|
|
2772
|
-
throw error.cause.cause;
|
|
2773
|
-
} else {
|
|
2774
|
-
throw error;
|
|
2775
|
-
}
|
|
2776
|
-
} else {
|
|
2777
|
-
throw error;
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
/**
|
|
2782
|
-
* Convert the agent to a tool which can be used by other agents.
|
|
2783
|
-
*
|
|
2784
|
-
* @returns the agent as a tool
|
|
2785
|
-
*/
|
|
2786
|
-
asTool() {
|
|
2787
|
-
const toolDescriptions = Object.values(this.tools).map((tool3) => tool3.description).join("\n");
|
|
2788
|
-
return (0, import_ai2.tool)({
|
|
2789
|
-
parameters: import_zod.z.object({ prompt: import_zod.z.string() }),
|
|
2790
|
-
execute: async ({ prompt }) => {
|
|
2791
|
-
return await this.call({ prompt });
|
|
2792
|
-
},
|
|
2793
|
-
description: `An AI Agent with the following background: ${this.background}Has access to the following tools: ${toolDescriptions}`
|
|
2794
|
-
});
|
|
2795
|
-
}
|
|
2796
|
-
};
|
|
2797
|
-
var ManagerAgent = class extends Agent {
|
|
2798
|
-
agents;
|
|
2799
|
-
/**
|
|
2800
|
-
* A manager agent which coordinates agents available to it to achieve a
|
|
2801
|
-
* given task
|
|
2802
|
-
*
|
|
2803
|
-
* @param name Name of the agent
|
|
2804
|
-
* @param background Background of the agent. If not passed, default will be used.
|
|
2805
|
-
* @param model LLM model to use
|
|
2806
|
-
* @param agents: List of agents available to the agent
|
|
2807
|
-
* @param maxSteps number of times the manager agent can call the LLM at most.
|
|
2808
|
-
* If the agent abruptly stops execution after calling other agents, you may
|
|
2809
|
-
* need to increase maxSteps
|
|
2810
|
-
*/
|
|
2811
|
-
constructor({
|
|
2812
|
-
agents,
|
|
2813
|
-
background = MANAGER_AGENT_PROMPT,
|
|
2814
|
-
model,
|
|
2815
|
-
maxSteps,
|
|
2816
|
-
name = "manager llm"
|
|
2817
|
-
}, context) {
|
|
2818
|
-
super(
|
|
2819
|
-
{
|
|
2820
|
-
background,
|
|
2821
|
-
maxSteps,
|
|
2822
|
-
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
2823
|
-
name,
|
|
2824
|
-
model
|
|
2825
|
-
},
|
|
2826
|
-
context
|
|
2827
|
-
);
|
|
2828
|
-
this.agents = agents;
|
|
2829
|
-
}
|
|
2830
|
-
};
|
|
2831
|
-
|
|
2832
|
-
// src/agents/task.ts
|
|
2833
|
-
var Task = class {
|
|
2834
|
-
context;
|
|
2835
|
-
taskParameters;
|
|
2836
|
-
constructor({
|
|
2837
|
-
context,
|
|
2838
|
-
taskParameters
|
|
2839
|
-
}) {
|
|
2840
|
-
this.context = context;
|
|
2841
|
-
this.taskParameters = taskParameters;
|
|
2842
|
-
}
|
|
2843
|
-
/**
|
|
2844
|
-
* Run the agents to complete the task
|
|
2845
|
-
*
|
|
2846
|
-
* @returns Result of the task as { text: string }
|
|
2847
|
-
*/
|
|
2848
|
-
async run() {
|
|
2849
|
-
const { prompt, ...otherParams } = this.taskParameters;
|
|
2850
|
-
if ("agent" in otherParams) {
|
|
2851
|
-
const agent = otherParams.agent;
|
|
2852
|
-
const result = await agent.call({
|
|
2853
|
-
prompt
|
|
2854
|
-
});
|
|
2855
|
-
return { text: result.text };
|
|
2856
|
-
} else {
|
|
2857
|
-
const { agents, maxSteps, model, background } = otherParams;
|
|
2858
|
-
const managerAgent = new ManagerAgent(
|
|
2859
|
-
{
|
|
2860
|
-
model,
|
|
2861
|
-
maxSteps,
|
|
2862
|
-
agents,
|
|
2863
|
-
name: "Manager LLM",
|
|
2864
|
-
background
|
|
2865
|
-
},
|
|
2866
|
-
this.context
|
|
2867
|
-
);
|
|
2868
|
-
const result = await managerAgent.call({ prompt });
|
|
2869
|
-
return { text: result.text };
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
};
|
|
2873
|
-
|
|
2874
|
-
// src/agents/index.ts
|
|
2875
|
-
var WorkflowAgents = class {
|
|
2876
|
-
context;
|
|
2877
|
-
constructor({ context }) {
|
|
2878
|
-
this.context = context;
|
|
2879
|
-
}
|
|
2880
|
-
/**
|
|
2881
|
-
* Defines an agent
|
|
2882
|
-
*
|
|
2883
|
-
* ```ts
|
|
2884
|
-
* const researcherAgent = context.agents.agent({
|
|
2885
|
-
* model,
|
|
2886
|
-
* name: 'academic',
|
|
2887
|
-
* maxSteps: 2,
|
|
2888
|
-
* tools: {
|
|
2889
|
-
* wikiTool: new WikipediaQueryRun({
|
|
2890
|
-
* topKResults: 1,
|
|
2891
|
-
* maxDocContentLength: 500,
|
|
2892
|
-
* })
|
|
2893
|
-
* },
|
|
2894
|
-
* background:
|
|
2895
|
-
* 'You are researcher agent with access to Wikipedia. ' +
|
|
2896
|
-
* 'Utilize Wikipedia as much as possible for correct information',
|
|
2897
|
-
* });
|
|
2898
|
-
* ```
|
|
2899
|
-
*
|
|
2900
|
-
* @param params agent parameters
|
|
2901
|
-
* @returns
|
|
2902
|
-
*/
|
|
2903
|
-
agent(params) {
|
|
2904
|
-
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
2905
|
-
return new Agent(
|
|
2906
|
-
{
|
|
2907
|
-
...params,
|
|
2908
|
-
tools: wrappedTools
|
|
2909
|
-
},
|
|
2910
|
-
this.context
|
|
2911
|
-
);
|
|
2912
|
-
}
|
|
2913
|
-
task(taskParameters) {
|
|
2914
|
-
return new Task({ context: this.context, taskParameters });
|
|
2915
|
-
}
|
|
2916
|
-
/**
|
|
2917
|
-
* creates an openai model for agents
|
|
2918
|
-
*/
|
|
2919
|
-
openai(...params) {
|
|
2920
|
-
const [model, settings] = params;
|
|
2921
|
-
const { baseURL, apiKey, callSettings, ...otherSettings } = settings ?? {};
|
|
2922
|
-
const openaiModel = this.AISDKModel({
|
|
2923
|
-
context: this.context,
|
|
2924
|
-
provider: import_openai2.createOpenAI,
|
|
2925
|
-
providerParams: { baseURL, apiKey, compatibility: "strict" },
|
|
2926
|
-
agentCallParams: callSettings
|
|
2927
|
-
});
|
|
2928
|
-
return openaiModel(model, otherSettings);
|
|
2929
|
-
}
|
|
2930
|
-
AISDKModel = createWorkflowModel;
|
|
2931
|
-
};
|
|
2932
|
-
|
|
2933
2611
|
// src/serve/serve-many.ts
|
|
2934
2612
|
var getWorkflowId = (url) => {
|
|
2935
2613
|
const components = url.split("/");
|
|
@@ -3238,7 +2916,7 @@ var WorkflowContext = class {
|
|
|
3238
2916
|
* @returns result of the step function
|
|
3239
2917
|
*/
|
|
3240
2918
|
async run(stepName, stepFunction) {
|
|
3241
|
-
const wrappedStepFunction = () => this.executor.wrapStep(stepName, stepFunction);
|
|
2919
|
+
const wrappedStepFunction = (() => this.executor.wrapStep(stepName, stepFunction));
|
|
3242
2920
|
return await this.addStep(new LazyFunctionStep(stepName, wrappedStepFunction));
|
|
3243
2921
|
}
|
|
3244
2922
|
/**
|
|
@@ -3409,11 +3087,6 @@ var WorkflowContext = class {
|
|
|
3409
3087
|
context: this
|
|
3410
3088
|
});
|
|
3411
3089
|
}
|
|
3412
|
-
get agents() {
|
|
3413
|
-
return new WorkflowAgents({
|
|
3414
|
-
context: this
|
|
3415
|
-
});
|
|
3416
|
-
}
|
|
3417
3090
|
};
|
|
3418
3091
|
|
|
3419
3092
|
// src/logger.ts
|
package/h3.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SDK_TELEMETRY,
|
|
3
3
|
serveBase,
|
|
4
4
|
serveManyBase
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AGYYZKP7.mjs";
|
|
6
6
|
|
|
7
7
|
// node_modules/defu/dist/defu.mjs
|
|
8
8
|
function isPlainObject(value) {
|
|
@@ -80,21 +80,16 @@ function hasProp(obj, prop) {
|
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
var __defProp$2 = Object.defineProperty;
|
|
84
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
85
|
-
var __publicField$2 = (obj, key, value) => {
|
|
86
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
87
|
-
return value;
|
|
88
|
-
};
|
|
89
83
|
var H3Error = class extends Error {
|
|
84
|
+
static __h3_error__ = true;
|
|
85
|
+
statusCode = 500;
|
|
86
|
+
fatal = false;
|
|
87
|
+
unhandled = false;
|
|
88
|
+
statusMessage;
|
|
89
|
+
data;
|
|
90
|
+
cause;
|
|
90
91
|
constructor(message, opts = {}) {
|
|
91
92
|
super(message, opts);
|
|
92
|
-
__publicField$2(this, "statusCode", 500);
|
|
93
|
-
__publicField$2(this, "fatal", false);
|
|
94
|
-
__publicField$2(this, "unhandled", false);
|
|
95
|
-
__publicField$2(this, "statusMessage");
|
|
96
|
-
__publicField$2(this, "data");
|
|
97
|
-
__publicField$2(this, "cause");
|
|
98
93
|
if (opts.cause && !this.cause) {
|
|
99
94
|
this.cause = opts.cause;
|
|
100
95
|
}
|
|
@@ -113,7 +108,6 @@ var H3Error = class extends Error {
|
|
|
113
108
|
return obj;
|
|
114
109
|
}
|
|
115
110
|
};
|
|
116
|
-
__publicField$2(H3Error, "__h3_error__", true);
|
|
117
111
|
function createError(input) {
|
|
118
112
|
if (typeof input === "string") {
|
|
119
113
|
return new H3Error(input);
|
|
@@ -236,6 +230,9 @@ function readRawBody(event, encoding = "utf8") {
|
|
|
236
230
|
if (_resolved instanceof URLSearchParams) {
|
|
237
231
|
return Buffer.from(_resolved.toString());
|
|
238
232
|
}
|
|
233
|
+
if (_resolved instanceof FormData) {
|
|
234
|
+
return new Response(_resolved).bytes().then((uint8arr) => Buffer.from(uint8arr));
|
|
235
|
+
}
|
|
239
236
|
return Buffer.from(_resolved);
|
|
240
237
|
});
|
|
241
238
|
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
package/hono.d.mts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction,
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-DESkn7K9.mjs';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-DEwKPF6H.mjs';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import 'ai';
|
|
8
|
-
import '@ai-sdk/openai';
|
|
9
7
|
|
|
10
8
|
type WorkflowBindings = {
|
|
11
9
|
QSTASH_TOKEN: string;
|
|
@@ -23,11 +21,11 @@ type WorkflowBindings = {
|
|
|
23
21
|
* @param options workflow options
|
|
24
22
|
* @returns
|
|
25
23
|
*/
|
|
26
|
-
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables =
|
|
24
|
+
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables = Variables, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => ((context: Context<{
|
|
27
25
|
Bindings: TBindings;
|
|
28
26
|
Variables: TVariables;
|
|
29
27
|
}>) => Promise<Response>);
|
|
30
|
-
declare const createWorkflow: <TInitialPayload = unknown, TResult = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables =
|
|
28
|
+
declare const createWorkflow: <TInitialPayload = unknown, TResult = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables = Variables>(...params: Parameters<typeof serve<TInitialPayload, TBindings, TVariables, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
31
29
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => (context: Context<{
|
|
32
30
|
Bindings: WorkflowBindings;
|
|
33
31
|
Variables: object;
|
package/hono.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction,
|
|
2
|
+
import { R as RouteFunction, n as PublicServeOptions, y as InvokableWorkflow } from './types-DESkn7K9.js';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
|
-
import { s as serveManyBase } from './serve-many-
|
|
4
|
+
import { s as serveManyBase } from './serve-many-DVtHRxeg.js';
|
|
5
5
|
import '@upstash/qstash';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import 'ai';
|
|
8
|
-
import '@ai-sdk/openai';
|
|
9
7
|
|
|
10
8
|
type WorkflowBindings = {
|
|
11
9
|
QSTASH_TOKEN: string;
|
|
@@ -23,11 +21,11 @@ type WorkflowBindings = {
|
|
|
23
21
|
* @param options workflow options
|
|
24
22
|
* @returns
|
|
25
23
|
*/
|
|
26
|
-
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables =
|
|
24
|
+
declare const serve: <TInitialPayload = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables = Variables, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => ((context: Context<{
|
|
27
25
|
Bindings: TBindings;
|
|
28
26
|
Variables: TVariables;
|
|
29
27
|
}>) => Promise<Response>);
|
|
30
|
-
declare const createWorkflow: <TInitialPayload = unknown, TResult = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables =
|
|
28
|
+
declare const createWorkflow: <TInitialPayload = unknown, TResult = unknown, TBindings extends WorkflowBindings = WorkflowBindings, TVariables extends Variables = Variables>(...params: Parameters<typeof serve<TInitialPayload, TBindings, TVariables, TResult>>) => InvokableWorkflow<TInitialPayload, TResult>;
|
|
31
29
|
declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => (context: Context<{
|
|
32
30
|
Bindings: WorkflowBindings;
|
|
33
31
|
Variables: object;
|