@upstash/workflow 0.2.5-agents-2 → 0.2.5-agents-3
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 +1 -1
- package/astro.d.ts +1 -1
- package/astro.js +44 -23
- package/astro.mjs +1 -1
- package/{chunk-VOM3CFYZ.mjs → chunk-42MM2EPQ.mjs} +44 -23
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +44 -23
- package/cloudflare.mjs +1 -1
- package/express.d.mts +1 -1
- package/express.d.ts +1 -1
- package/express.js +44 -23
- package/express.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +44 -23
- package/h3.mjs +1 -1
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +44 -23
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +44 -23
- package/index.mjs +1 -1
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +44 -23
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +44 -23
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +44 -23
- package/svelte.mjs +1 -1
- package/{types-D9gwTj2n.d.mts → types-CalpUeFX.d.mts} +2 -1
- package/{types-D9gwTj2n.d.ts → types-CalpUeFX.d.ts} +2 -1
package/h3.js
CHANGED
|
@@ -2023,6 +2023,13 @@ var convertLangchainTool = (langchainTool) => {
|
|
|
2023
2023
|
// src/agents/agent.ts
|
|
2024
2024
|
var import_zod = require("zod");
|
|
2025
2025
|
var import_ai2 = require("ai");
|
|
2026
|
+
|
|
2027
|
+
// src/serve/utils.ts
|
|
2028
|
+
var isDisabledWorkflowContext = (context) => {
|
|
2029
|
+
return "disabled" in context;
|
|
2030
|
+
};
|
|
2031
|
+
|
|
2032
|
+
// src/agents/agent.ts
|
|
2026
2033
|
var Agent = class {
|
|
2027
2034
|
name;
|
|
2028
2035
|
tools;
|
|
@@ -2030,13 +2037,15 @@ var Agent = class {
|
|
|
2030
2037
|
background;
|
|
2031
2038
|
model;
|
|
2032
2039
|
temparature;
|
|
2033
|
-
|
|
2040
|
+
context;
|
|
2041
|
+
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
2034
2042
|
this.name = name;
|
|
2035
2043
|
this.tools = tools ?? {};
|
|
2036
2044
|
this.maxSteps = maxSteps;
|
|
2037
2045
|
this.background = background;
|
|
2038
2046
|
this.model = model;
|
|
2039
2047
|
this.temparature = temparature;
|
|
2048
|
+
this.context = context;
|
|
2040
2049
|
}
|
|
2041
2050
|
/**
|
|
2042
2051
|
* Trigger the agent by passing a prompt
|
|
@@ -2046,6 +2055,9 @@ var Agent = class {
|
|
|
2046
2055
|
*/
|
|
2047
2056
|
async call({ prompt }) {
|
|
2048
2057
|
try {
|
|
2058
|
+
if (isDisabledWorkflowContext(this.context)) {
|
|
2059
|
+
await this.context.sleep("abort", 0);
|
|
2060
|
+
}
|
|
2049
2061
|
const result = await (0, import_ai2.generateText)({
|
|
2050
2062
|
model: this.model,
|
|
2051
2063
|
tools: this.tools,
|
|
@@ -2108,14 +2120,17 @@ var ManagerAgent = class extends Agent {
|
|
|
2108
2120
|
model,
|
|
2109
2121
|
maxSteps,
|
|
2110
2122
|
name = "manager llm"
|
|
2111
|
-
}) {
|
|
2112
|
-
super(
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2123
|
+
}, context) {
|
|
2124
|
+
super(
|
|
2125
|
+
{
|
|
2126
|
+
background,
|
|
2127
|
+
maxSteps,
|
|
2128
|
+
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
2129
|
+
name,
|
|
2130
|
+
model
|
|
2131
|
+
},
|
|
2132
|
+
context
|
|
2133
|
+
);
|
|
2119
2134
|
this.agents = agents;
|
|
2120
2135
|
}
|
|
2121
2136
|
};
|
|
@@ -2138,23 +2153,25 @@ var Task = class {
|
|
|
2138
2153
|
*/
|
|
2139
2154
|
async run() {
|
|
2140
2155
|
const { prompt, ...otherParams } = this.taskParameters;
|
|
2141
|
-
const safePrompt = await this.context.run("Get Prompt", () => prompt);
|
|
2142
2156
|
if ("agent" in otherParams) {
|
|
2143
2157
|
const agent = otherParams.agent;
|
|
2144
2158
|
const result = await agent.call({
|
|
2145
|
-
prompt
|
|
2159
|
+
prompt
|
|
2146
2160
|
});
|
|
2147
2161
|
return { text: result.text };
|
|
2148
2162
|
} else {
|
|
2149
2163
|
const { agents, maxSteps, model, background } = otherParams;
|
|
2150
|
-
const managerAgent = new ManagerAgent(
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2164
|
+
const managerAgent = new ManagerAgent(
|
|
2165
|
+
{
|
|
2166
|
+
model,
|
|
2167
|
+
maxSteps,
|
|
2168
|
+
agents,
|
|
2169
|
+
name: "Manager LLM",
|
|
2170
|
+
background
|
|
2171
|
+
},
|
|
2172
|
+
this.context
|
|
2173
|
+
);
|
|
2174
|
+
const result = await managerAgent.call({ prompt });
|
|
2158
2175
|
return { text: result.text };
|
|
2159
2176
|
}
|
|
2160
2177
|
}
|
|
@@ -2191,10 +2208,13 @@ var WorkflowAgents = class {
|
|
|
2191
2208
|
*/
|
|
2192
2209
|
agent(params) {
|
|
2193
2210
|
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
2194
|
-
return new Agent(
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2211
|
+
return new Agent(
|
|
2212
|
+
{
|
|
2213
|
+
...params,
|
|
2214
|
+
tools: wrappedTools
|
|
2215
|
+
},
|
|
2216
|
+
this.context
|
|
2217
|
+
);
|
|
2198
2218
|
}
|
|
2199
2219
|
task(taskParameters) {
|
|
2200
2220
|
return new Task({ context: this.context, taskParameters });
|
|
@@ -2678,6 +2698,7 @@ function decodeBase64(base64) {
|
|
|
2678
2698
|
var import_qstash8 = require("@upstash/qstash");
|
|
2679
2699
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
2680
2700
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
2701
|
+
disabled = true;
|
|
2681
2702
|
/**
|
|
2682
2703
|
* overwrite the WorkflowContext.addStep method to always raise WorkflowAbort
|
|
2683
2704
|
* error in order to stop the execution whenever we encounter a step.
|
package/h3.mjs
CHANGED
package/hono.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.mjs';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'ai';
|
package/hono.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.js';
|
|
3
3
|
import { Variables } from 'hono/types';
|
|
4
4
|
import '@upstash/qstash';
|
|
5
5
|
import 'ai';
|
package/hono.js
CHANGED
|
@@ -1711,6 +1711,13 @@ var convertLangchainTool = (langchainTool) => {
|
|
|
1711
1711
|
// src/agents/agent.ts
|
|
1712
1712
|
var import_zod = require("zod");
|
|
1713
1713
|
var import_ai2 = require("ai");
|
|
1714
|
+
|
|
1715
|
+
// src/serve/utils.ts
|
|
1716
|
+
var isDisabledWorkflowContext = (context) => {
|
|
1717
|
+
return "disabled" in context;
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
// src/agents/agent.ts
|
|
1714
1721
|
var Agent = class {
|
|
1715
1722
|
name;
|
|
1716
1723
|
tools;
|
|
@@ -1718,13 +1725,15 @@ var Agent = class {
|
|
|
1718
1725
|
background;
|
|
1719
1726
|
model;
|
|
1720
1727
|
temparature;
|
|
1721
|
-
|
|
1728
|
+
context;
|
|
1729
|
+
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
1722
1730
|
this.name = name;
|
|
1723
1731
|
this.tools = tools ?? {};
|
|
1724
1732
|
this.maxSteps = maxSteps;
|
|
1725
1733
|
this.background = background;
|
|
1726
1734
|
this.model = model;
|
|
1727
1735
|
this.temparature = temparature;
|
|
1736
|
+
this.context = context;
|
|
1728
1737
|
}
|
|
1729
1738
|
/**
|
|
1730
1739
|
* Trigger the agent by passing a prompt
|
|
@@ -1734,6 +1743,9 @@ var Agent = class {
|
|
|
1734
1743
|
*/
|
|
1735
1744
|
async call({ prompt }) {
|
|
1736
1745
|
try {
|
|
1746
|
+
if (isDisabledWorkflowContext(this.context)) {
|
|
1747
|
+
await this.context.sleep("abort", 0);
|
|
1748
|
+
}
|
|
1737
1749
|
const result = await (0, import_ai2.generateText)({
|
|
1738
1750
|
model: this.model,
|
|
1739
1751
|
tools: this.tools,
|
|
@@ -1796,14 +1808,17 @@ var ManagerAgent = class extends Agent {
|
|
|
1796
1808
|
model,
|
|
1797
1809
|
maxSteps,
|
|
1798
1810
|
name = "manager llm"
|
|
1799
|
-
}) {
|
|
1800
|
-
super(
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1811
|
+
}, context) {
|
|
1812
|
+
super(
|
|
1813
|
+
{
|
|
1814
|
+
background,
|
|
1815
|
+
maxSteps,
|
|
1816
|
+
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
1817
|
+
name,
|
|
1818
|
+
model
|
|
1819
|
+
},
|
|
1820
|
+
context
|
|
1821
|
+
);
|
|
1807
1822
|
this.agents = agents;
|
|
1808
1823
|
}
|
|
1809
1824
|
};
|
|
@@ -1826,23 +1841,25 @@ var Task = class {
|
|
|
1826
1841
|
*/
|
|
1827
1842
|
async run() {
|
|
1828
1843
|
const { prompt, ...otherParams } = this.taskParameters;
|
|
1829
|
-
const safePrompt = await this.context.run("Get Prompt", () => prompt);
|
|
1830
1844
|
if ("agent" in otherParams) {
|
|
1831
1845
|
const agent = otherParams.agent;
|
|
1832
1846
|
const result = await agent.call({
|
|
1833
|
-
prompt
|
|
1847
|
+
prompt
|
|
1834
1848
|
});
|
|
1835
1849
|
return { text: result.text };
|
|
1836
1850
|
} else {
|
|
1837
1851
|
const { agents, maxSteps, model, background } = otherParams;
|
|
1838
|
-
const managerAgent = new ManagerAgent(
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1852
|
+
const managerAgent = new ManagerAgent(
|
|
1853
|
+
{
|
|
1854
|
+
model,
|
|
1855
|
+
maxSteps,
|
|
1856
|
+
agents,
|
|
1857
|
+
name: "Manager LLM",
|
|
1858
|
+
background
|
|
1859
|
+
},
|
|
1860
|
+
this.context
|
|
1861
|
+
);
|
|
1862
|
+
const result = await managerAgent.call({ prompt });
|
|
1846
1863
|
return { text: result.text };
|
|
1847
1864
|
}
|
|
1848
1865
|
}
|
|
@@ -1879,10 +1896,13 @@ var WorkflowAgents = class {
|
|
|
1879
1896
|
*/
|
|
1880
1897
|
agent(params) {
|
|
1881
1898
|
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
1882
|
-
return new Agent(
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1899
|
+
return new Agent(
|
|
1900
|
+
{
|
|
1901
|
+
...params,
|
|
1902
|
+
tools: wrappedTools
|
|
1903
|
+
},
|
|
1904
|
+
this.context
|
|
1905
|
+
);
|
|
1886
1906
|
}
|
|
1887
1907
|
task(taskParameters) {
|
|
1888
1908
|
return new Task({ context: this.context, taskParameters });
|
|
@@ -2366,6 +2386,7 @@ function decodeBase64(base64) {
|
|
|
2366
2386
|
var import_qstash8 = require("@upstash/qstash");
|
|
2367
2387
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
2368
2388
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
2389
|
+
disabled = true;
|
|
2369
2390
|
/**
|
|
2370
2391
|
* overwrite the WorkflowContext.addStep method to always raise WorkflowAbort
|
|
2371
2392
|
* error in order to stop the execution whenever we encounter a step.
|
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, T as Telemetry, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, s as WorkflowLogger, r as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CalpUeFX.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, T as Telemetry, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, s as WorkflowLogger, r as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CalpUeFX.mjs';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, T as Telemetry, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, s as WorkflowLogger, r as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CalpUeFX.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, T as Telemetry, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, s as WorkflowLogger, r as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CalpUeFX.js';
|
|
3
3
|
import { Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|
package/index.js
CHANGED
|
@@ -1724,6 +1724,13 @@ var convertLangchainTool = (langchainTool) => {
|
|
|
1724
1724
|
// src/agents/agent.ts
|
|
1725
1725
|
var import_zod = require("zod");
|
|
1726
1726
|
var import_ai2 = require("ai");
|
|
1727
|
+
|
|
1728
|
+
// src/serve/utils.ts
|
|
1729
|
+
var isDisabledWorkflowContext = (context) => {
|
|
1730
|
+
return "disabled" in context;
|
|
1731
|
+
};
|
|
1732
|
+
|
|
1733
|
+
// src/agents/agent.ts
|
|
1727
1734
|
var Agent = class {
|
|
1728
1735
|
name;
|
|
1729
1736
|
tools;
|
|
@@ -1731,13 +1738,15 @@ var Agent = class {
|
|
|
1731
1738
|
background;
|
|
1732
1739
|
model;
|
|
1733
1740
|
temparature;
|
|
1734
|
-
|
|
1741
|
+
context;
|
|
1742
|
+
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
1735
1743
|
this.name = name;
|
|
1736
1744
|
this.tools = tools ?? {};
|
|
1737
1745
|
this.maxSteps = maxSteps;
|
|
1738
1746
|
this.background = background;
|
|
1739
1747
|
this.model = model;
|
|
1740
1748
|
this.temparature = temparature;
|
|
1749
|
+
this.context = context;
|
|
1741
1750
|
}
|
|
1742
1751
|
/**
|
|
1743
1752
|
* Trigger the agent by passing a prompt
|
|
@@ -1747,6 +1756,9 @@ var Agent = class {
|
|
|
1747
1756
|
*/
|
|
1748
1757
|
async call({ prompt }) {
|
|
1749
1758
|
try {
|
|
1759
|
+
if (isDisabledWorkflowContext(this.context)) {
|
|
1760
|
+
await this.context.sleep("abort", 0);
|
|
1761
|
+
}
|
|
1750
1762
|
const result = await (0, import_ai2.generateText)({
|
|
1751
1763
|
model: this.model,
|
|
1752
1764
|
tools: this.tools,
|
|
@@ -1809,14 +1821,17 @@ var ManagerAgent = class extends Agent {
|
|
|
1809
1821
|
model,
|
|
1810
1822
|
maxSteps,
|
|
1811
1823
|
name = "manager llm"
|
|
1812
|
-
}) {
|
|
1813
|
-
super(
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1824
|
+
}, context) {
|
|
1825
|
+
super(
|
|
1826
|
+
{
|
|
1827
|
+
background,
|
|
1828
|
+
maxSteps,
|
|
1829
|
+
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
1830
|
+
name,
|
|
1831
|
+
model
|
|
1832
|
+
},
|
|
1833
|
+
context
|
|
1834
|
+
);
|
|
1820
1835
|
this.agents = agents;
|
|
1821
1836
|
}
|
|
1822
1837
|
};
|
|
@@ -1839,23 +1854,25 @@ var Task = class {
|
|
|
1839
1854
|
*/
|
|
1840
1855
|
async run() {
|
|
1841
1856
|
const { prompt, ...otherParams } = this.taskParameters;
|
|
1842
|
-
const safePrompt = await this.context.run("Get Prompt", () => prompt);
|
|
1843
1857
|
if ("agent" in otherParams) {
|
|
1844
1858
|
const agent = otherParams.agent;
|
|
1845
1859
|
const result = await agent.call({
|
|
1846
|
-
prompt
|
|
1860
|
+
prompt
|
|
1847
1861
|
});
|
|
1848
1862
|
return { text: result.text };
|
|
1849
1863
|
} else {
|
|
1850
1864
|
const { agents, maxSteps, model, background } = otherParams;
|
|
1851
|
-
const managerAgent = new ManagerAgent(
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1865
|
+
const managerAgent = new ManagerAgent(
|
|
1866
|
+
{
|
|
1867
|
+
model,
|
|
1868
|
+
maxSteps,
|
|
1869
|
+
agents,
|
|
1870
|
+
name: "Manager LLM",
|
|
1871
|
+
background
|
|
1872
|
+
},
|
|
1873
|
+
this.context
|
|
1874
|
+
);
|
|
1875
|
+
const result = await managerAgent.call({ prompt });
|
|
1859
1876
|
return { text: result.text };
|
|
1860
1877
|
}
|
|
1861
1878
|
}
|
|
@@ -1892,10 +1909,13 @@ var WorkflowAgents = class {
|
|
|
1892
1909
|
*/
|
|
1893
1910
|
agent(params) {
|
|
1894
1911
|
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
1895
|
-
return new Agent(
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1912
|
+
return new Agent(
|
|
1913
|
+
{
|
|
1914
|
+
...params,
|
|
1915
|
+
tools: wrappedTools
|
|
1916
|
+
},
|
|
1917
|
+
this.context
|
|
1918
|
+
);
|
|
1899
1919
|
}
|
|
1900
1920
|
task(taskParameters) {
|
|
1901
1921
|
return new Task({ context: this.context, taskParameters });
|
|
@@ -2379,6 +2399,7 @@ function decodeBase64(base64) {
|
|
|
2379
2399
|
var import_qstash8 = require("@upstash/qstash");
|
|
2380
2400
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
2381
2401
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
2402
|
+
disabled = true;
|
|
2382
2403
|
/**
|
|
2383
2404
|
* overwrite the WorkflowContext.addStep method to always raise WorkflowAbort
|
|
2384
2405
|
* error in order to stop the execution whenever we encounter a step.
|
package/index.mjs
CHANGED
package/nextjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|
package/nextjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextApiHandler } from 'next';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|
package/nextjs.js
CHANGED
|
@@ -1712,6 +1712,13 @@ var convertLangchainTool = (langchainTool) => {
|
|
|
1712
1712
|
// src/agents/agent.ts
|
|
1713
1713
|
var import_zod = require("zod");
|
|
1714
1714
|
var import_ai2 = require("ai");
|
|
1715
|
+
|
|
1716
|
+
// src/serve/utils.ts
|
|
1717
|
+
var isDisabledWorkflowContext = (context) => {
|
|
1718
|
+
return "disabled" in context;
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
// src/agents/agent.ts
|
|
1715
1722
|
var Agent = class {
|
|
1716
1723
|
name;
|
|
1717
1724
|
tools;
|
|
@@ -1719,13 +1726,15 @@ var Agent = class {
|
|
|
1719
1726
|
background;
|
|
1720
1727
|
model;
|
|
1721
1728
|
temparature;
|
|
1722
|
-
|
|
1729
|
+
context;
|
|
1730
|
+
constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }, context) {
|
|
1723
1731
|
this.name = name;
|
|
1724
1732
|
this.tools = tools ?? {};
|
|
1725
1733
|
this.maxSteps = maxSteps;
|
|
1726
1734
|
this.background = background;
|
|
1727
1735
|
this.model = model;
|
|
1728
1736
|
this.temparature = temparature;
|
|
1737
|
+
this.context = context;
|
|
1729
1738
|
}
|
|
1730
1739
|
/**
|
|
1731
1740
|
* Trigger the agent by passing a prompt
|
|
@@ -1735,6 +1744,9 @@ var Agent = class {
|
|
|
1735
1744
|
*/
|
|
1736
1745
|
async call({ prompt }) {
|
|
1737
1746
|
try {
|
|
1747
|
+
if (isDisabledWorkflowContext(this.context)) {
|
|
1748
|
+
await this.context.sleep("abort", 0);
|
|
1749
|
+
}
|
|
1738
1750
|
const result = await (0, import_ai2.generateText)({
|
|
1739
1751
|
model: this.model,
|
|
1740
1752
|
tools: this.tools,
|
|
@@ -1797,14 +1809,17 @@ var ManagerAgent = class extends Agent {
|
|
|
1797
1809
|
model,
|
|
1798
1810
|
maxSteps,
|
|
1799
1811
|
name = "manager llm"
|
|
1800
|
-
}) {
|
|
1801
|
-
super(
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1812
|
+
}, context) {
|
|
1813
|
+
super(
|
|
1814
|
+
{
|
|
1815
|
+
background,
|
|
1816
|
+
maxSteps,
|
|
1817
|
+
tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
|
|
1818
|
+
name,
|
|
1819
|
+
model
|
|
1820
|
+
},
|
|
1821
|
+
context
|
|
1822
|
+
);
|
|
1808
1823
|
this.agents = agents;
|
|
1809
1824
|
}
|
|
1810
1825
|
};
|
|
@@ -1827,23 +1842,25 @@ var Task = class {
|
|
|
1827
1842
|
*/
|
|
1828
1843
|
async run() {
|
|
1829
1844
|
const { prompt, ...otherParams } = this.taskParameters;
|
|
1830
|
-
const safePrompt = await this.context.run("Get Prompt", () => prompt);
|
|
1831
1845
|
if ("agent" in otherParams) {
|
|
1832
1846
|
const agent = otherParams.agent;
|
|
1833
1847
|
const result = await agent.call({
|
|
1834
|
-
prompt
|
|
1848
|
+
prompt
|
|
1835
1849
|
});
|
|
1836
1850
|
return { text: result.text };
|
|
1837
1851
|
} else {
|
|
1838
1852
|
const { agents, maxSteps, model, background } = otherParams;
|
|
1839
|
-
const managerAgent = new ManagerAgent(
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1853
|
+
const managerAgent = new ManagerAgent(
|
|
1854
|
+
{
|
|
1855
|
+
model,
|
|
1856
|
+
maxSteps,
|
|
1857
|
+
agents,
|
|
1858
|
+
name: "Manager LLM",
|
|
1859
|
+
background
|
|
1860
|
+
},
|
|
1861
|
+
this.context
|
|
1862
|
+
);
|
|
1863
|
+
const result = await managerAgent.call({ prompt });
|
|
1847
1864
|
return { text: result.text };
|
|
1848
1865
|
}
|
|
1849
1866
|
}
|
|
@@ -1880,10 +1897,13 @@ var WorkflowAgents = class {
|
|
|
1880
1897
|
*/
|
|
1881
1898
|
agent(params) {
|
|
1882
1899
|
const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
|
|
1883
|
-
return new Agent(
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1900
|
+
return new Agent(
|
|
1901
|
+
{
|
|
1902
|
+
...params,
|
|
1903
|
+
tools: wrappedTools
|
|
1904
|
+
},
|
|
1905
|
+
this.context
|
|
1906
|
+
);
|
|
1887
1907
|
}
|
|
1888
1908
|
task(taskParameters) {
|
|
1889
1909
|
return new Task({ context: this.context, taskParameters });
|
|
@@ -2367,6 +2387,7 @@ function decodeBase64(base64) {
|
|
|
2367
2387
|
var import_qstash8 = require("@upstash/qstash");
|
|
2368
2388
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
2369
2389
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
2390
|
+
disabled = true;
|
|
2370
2391
|
/**
|
|
2371
2392
|
* overwrite the WorkflowContext.addStep method to always raise WorkflowAbort
|
|
2372
2393
|
* error in order to stop the execution whenever we encounter a step.
|
package/nextjs.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/workflow","version":"v0.2.5-agents-
|
|
1
|
+
{"name":"@upstash/workflow","version":"v0.2.5-agents-3","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./astro":{"import":"./astro.mjs","require":"./astro.js"},"./express":{"import":"./express.mjs","require":"./express.js"}},"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"repository":{"type":"git","url":"git+https://github.com/upstash/workflow-ts.git"},"keywords":["upstash","qstash","workflow","serverless"],"author":"Cahid Arda Oz","license":"MIT","bugs":{"url":"https://github.com/upstash/workflow-ts/issues"},"homepage":"https://github.com/upstash/workflow-ts#readme","devDependencies":{"@commitlint/cli":"^19.5.0","@commitlint/config-conventional":"^19.5.0","@eslint/js":"^9.11.1","@solidjs/start":"^1.0.8","@sveltejs/kit":"^2.6.1","@types/bun":"^1.1.10","@types/express":"^5.0.0","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^4.21.1","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.3","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsup":"^8.3.0","typescript":"^5.7.2","typescript-eslint":"^8.18.0"},"dependencies":{"@ai-sdk/openai":"^1.0.15","@upstash/qstash":"^2.7.20","ai":"^4.0.30","zod":"^3.24.1"},"directories":{"example":"examples"}}
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction, j as PublicServeOptions } from './types-
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-CalpUeFX.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '@ai-sdk/openai';
|