@upstash/workflow 0.2.5-agents-2 → 0.2.5
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/solidjs.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/solidjs.mjs
CHANGED
package/svelte.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestHandler } from '@sveltejs/kit';
|
|
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/svelte.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestHandler } from '@sveltejs/kit';
|
|
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/svelte.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/svelte.mjs
CHANGED
|
@@ -410,7 +410,8 @@ declare class Agent {
|
|
|
410
410
|
readonly background: AgentParameters["background"];
|
|
411
411
|
readonly model: AgentParameters["model"];
|
|
412
412
|
readonly temparature: AgentParameters["temparature"];
|
|
413
|
-
|
|
413
|
+
private readonly context;
|
|
414
|
+
constructor({ tools, maxSteps, background, name, model, temparature }: AgentParameters, context: WorkflowContext);
|
|
414
415
|
/**
|
|
415
416
|
* Trigger the agent by passing a prompt
|
|
416
417
|
*
|
|
@@ -410,7 +410,8 @@ declare class Agent {
|
|
|
410
410
|
readonly background: AgentParameters["background"];
|
|
411
411
|
readonly model: AgentParameters["model"];
|
|
412
412
|
readonly temparature: AgentParameters["temparature"];
|
|
413
|
-
|
|
413
|
+
private readonly context;
|
|
414
|
+
constructor({ tools, maxSteps, background, name, model, temparature }: AgentParameters, context: WorkflowContext);
|
|
414
415
|
/**
|
|
415
416
|
* Trigger the agent by passing a prompt
|
|
416
417
|
*
|