@upstash/workflow 0.2.5-agents → 0.2.5-agents-2

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 CHANGED
@@ -1,9 +1,8 @@
1
1
  import { APIContext, APIRoute } from 'astro';
2
- import { b as WorkflowContext, j as PublicServeOptions } from './types-BEyIoCRe.mjs';
2
+ import { b as WorkflowContext, j as PublicServeOptions } from './types-D9gwTj2n.mjs';
3
3
  import '@upstash/qstash';
4
4
  import 'ai';
5
5
  import '@ai-sdk/openai';
6
- import 'langchain/tools';
7
6
 
8
7
  declare function serve<TInitialPayload = unknown>(routeFunction: (workflowContext: WorkflowContext<TInitialPayload>, apiContext: APIContext) => Promise<void>, options?: PublicServeOptions<TInitialPayload>): {
9
8
  POST: APIRoute;
package/astro.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { APIContext, APIRoute } from 'astro';
2
- import { b as WorkflowContext, j as PublicServeOptions } from './types-BEyIoCRe.js';
2
+ import { b as WorkflowContext, j as PublicServeOptions } from './types-D9gwTj2n.js';
3
3
  import '@upstash/qstash';
4
4
  import 'ai';
5
5
  import '@ai-sdk/openai';
6
- import 'langchain/tools';
7
6
 
8
7
  declare function serve<TInitialPayload = unknown>(routeFunction: (workflowContext: WorkflowContext<TInitialPayload>, apiContext: APIContext) => Promise<void>, options?: PublicServeOptions<TInitialPayload>): {
9
8
  POST: APIRoute;
package/astro.js CHANGED
@@ -826,29 +826,16 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
826
826
  await debug?.log("SUBMIT", "SUBMIT_CLEANUP", {
827
827
  deletedWorkflowRunId: workflowContext.workflowRunId
828
828
  });
829
- try {
830
- await workflowContext.qstashClient.http.request({
831
- path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
832
- method: "DELETE",
833
- parseResponseAsJson: false
834
- });
835
- await debug?.log(
836
- "SUBMIT",
837
- "SUBMIT_CLEANUP",
838
- `workflow run ${workflowContext.workflowRunId} deleted.`
839
- );
840
- return { deleted: true };
841
- } catch (error) {
842
- if (error instanceof import_qstash3.QstashError && error.status === 404) {
843
- await debug?.log("WARN", "SUBMIT_CLEANUP", {
844
- message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
845
- name: error.name,
846
- errorMessage: error.message
847
- });
848
- return { deleted: false };
849
- }
850
- throw error;
851
- }
829
+ await workflowContext.qstashClient.http.request({
830
+ path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
831
+ method: "DELETE",
832
+ parseResponseAsJson: false
833
+ });
834
+ await debug?.log(
835
+ "SUBMIT",
836
+ "SUBMIT_CLEANUP",
837
+ `workflow run ${workflowContext.workflowRunId} deleted.`
838
+ );
852
839
  };
853
840
  var recreateUserHeaders = (headers) => {
854
841
  const filteredHeaders = new Headers();
@@ -1635,7 +1622,22 @@ var WorkflowApi = class extends BaseWorkflowApi {
1635
1622
  // src/agents/adapters.ts
1636
1623
  var import_openai2 = require("@ai-sdk/openai");
1637
1624
  var import_ai = require("ai");
1625
+
1626
+ // src/agents/constants.ts
1638
1627
  var AGENT_NAME_HEADER = "upstash-agent-name";
1628
+ var MANAGER_AGENT_PROMPT = `You are an agent orchestrating other AI Agents.
1629
+
1630
+ These other agents have tools available to them.
1631
+
1632
+ Given a prompt, utilize these agents to address requests.
1633
+
1634
+ 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.
1635
+
1636
+ Avoid calling the same agent twice in one turn. Instead, prefer to call it once but provide everything
1637
+ you need from that agent.
1638
+ `;
1639
+
1640
+ // src/agents/adapters.ts
1639
1641
  var createWorkflowOpenAI = (context) => {
1640
1642
  return (0, import_openai2.createOpenAI)({
1641
1643
  compatibility: "strict",
@@ -1702,8 +1704,7 @@ var convertLangchainTool = (langchainTool) => {
1702
1704
  return (0, import_ai.tool)({
1703
1705
  description: langchainTool.description,
1704
1706
  parameters: langchainTool.schema,
1705
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1706
- execute: async (param) => langchainTool.invoke(param)
1707
+ execute: async (...param) => langchainTool.invoke(...param)
1707
1708
  });
1708
1709
  };
1709
1710
 
@@ -1716,16 +1717,24 @@ var Agent = class {
1716
1717
  maxSteps;
1717
1718
  background;
1718
1719
  model;
1719
- constructor({ tools, maxSteps, background, name, model }) {
1720
+ temparature;
1721
+ constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }) {
1720
1722
  this.name = name;
1721
1723
  this.tools = tools ?? {};
1722
1724
  this.maxSteps = maxSteps;
1723
1725
  this.background = background;
1724
1726
  this.model = model;
1727
+ this.temparature = temparature;
1725
1728
  }
1729
+ /**
1730
+ * Trigger the agent by passing a prompt
1731
+ *
1732
+ * @param prompt task to assign to the agent
1733
+ * @returns Response as `{ text: string }`
1734
+ */
1726
1735
  async call({ prompt }) {
1727
1736
  try {
1728
- return await (0, import_ai2.generateText)({
1737
+ const result = await (0, import_ai2.generateText)({
1729
1738
  model: this.model,
1730
1739
  tools: this.tools,
1731
1740
  maxSteps: this.maxSteps,
@@ -1733,8 +1742,10 @@ var Agent = class {
1733
1742
  prompt,
1734
1743
  headers: {
1735
1744
  [AGENT_NAME_HEADER]: this.name
1736
- }
1745
+ },
1746
+ temperature: this.temparature
1737
1747
  });
1748
+ return { text: result.text };
1738
1749
  } catch (error) {
1739
1750
  if (error instanceof import_ai2.ToolExecutionError) {
1740
1751
  if (error.cause instanceof Error && error.cause.name === "WorkflowAbort") {
@@ -1749,6 +1760,11 @@ var Agent = class {
1749
1760
  }
1750
1761
  }
1751
1762
  }
1763
+ /**
1764
+ * Convert the agent to a tool which can be used by other agents.
1765
+ *
1766
+ * @returns the agent as a tool
1767
+ */
1752
1768
  asTool() {
1753
1769
  const toolDescriptions = Object.values(this.tools).map((tool3) => tool3.description).join("\n");
1754
1770
  return (0, import_ai2.tool)({
@@ -1760,18 +1776,25 @@ var Agent = class {
1760
1776
  });
1761
1777
  }
1762
1778
  };
1763
- var MANAGER_AGENT_PROMPT = `You are an AI agent who orchestrates other AI Agents.
1764
- These other agents have tools available to them.
1765
- Given a prompt, utilize these agents to address requests.
1766
- 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.
1767
- `;
1768
1779
  var ManagerAgent = class extends Agent {
1769
1780
  agents;
1781
+ /**
1782
+ * A manager agent which coordinates agents available to it to achieve a
1783
+ * given task
1784
+ *
1785
+ * @param name Name of the agent
1786
+ * @param background Background of the agent. If not passed, default will be used.
1787
+ * @param model LLM model to use
1788
+ * @param agents: List of agents available to the agent
1789
+ * @param maxSteps number of times the manager agent can call the LLM at most.
1790
+ * If the agent abruptly stops execution after calling other agents, you may
1791
+ * need to increase maxSteps
1792
+ */
1770
1793
  constructor({
1771
- maxSteps,
1772
- background = MANAGER_AGENT_PROMPT,
1773
1794
  agents,
1795
+ background = MANAGER_AGENT_PROMPT,
1774
1796
  model,
1797
+ maxSteps,
1775
1798
  name = "manager llm"
1776
1799
  }) {
1777
1800
  super({
@@ -1796,6 +1819,11 @@ var Task = class {
1796
1819
  this.context = context;
1797
1820
  this.taskParameters = taskParameters;
1798
1821
  }
1822
+ /**
1823
+ * Run the agents to complete the task
1824
+ *
1825
+ * @returns Result of the task as { text: string }
1826
+ */
1799
1827
  async run() {
1800
1828
  const { prompt, ...otherParams } = this.taskParameters;
1801
1829
  const safePrompt = await this.context.run("Get Prompt", () => prompt);
@@ -1826,6 +1854,29 @@ var WorkflowAgents = class {
1826
1854
  constructor({ context }) {
1827
1855
  this.context = context;
1828
1856
  }
1857
+ /**
1858
+ * Defines an agent
1859
+ *
1860
+ * ```ts
1861
+ * const researcherAgent = context.agents.agent({
1862
+ * model,
1863
+ * name: 'academic',
1864
+ * maxSteps: 2,
1865
+ * tools: {
1866
+ * wikiTool: new WikipediaQueryRun({
1867
+ * topKResults: 1,
1868
+ * maxDocContentLength: 500,
1869
+ * })
1870
+ * },
1871
+ * background:
1872
+ * 'You are researcher agent with access to Wikipedia. ' +
1873
+ * 'Utilize Wikipedia as much as possible for correct information',
1874
+ * });
1875
+ * ```
1876
+ *
1877
+ * @param params agent parameters
1878
+ * @returns
1879
+ */
1829
1880
  agent(params) {
1830
1881
  const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
1831
1882
  return new Agent({
@@ -1836,6 +1887,9 @@ var WorkflowAgents = class {
1836
1887
  task(taskParameters) {
1837
1888
  return new Task({ context: this.context, taskParameters });
1838
1889
  }
1890
+ /**
1891
+ * creates an openai model for agents
1892
+ */
1839
1893
  openai(...params) {
1840
1894
  const openai2 = createWorkflowOpenAI(this.context);
1841
1895
  return openai2(...params);
@@ -2436,7 +2490,6 @@ var checkIfLastOneIsDuplicate = async (steps, debug) => {
2436
2490
  if (step.stepId === lastStepId && step.targetStep === lastTargetStepId) {
2437
2491
  const message = `Upstash Workflow: The step '${step.stepName}' with id '${step.stepId}' has run twice during workflow execution. Rest of the workflow will continue running as usual.`;
2438
2492
  await debug?.log("WARN", "RESPONSE_DEFAULT", message);
2439
- console.log(steps);
2440
2493
  console.warn(message);
2441
2494
  return true;
2442
2495
  }
package/astro.mjs CHANGED
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase
4
- } from "./chunk-RFX5YRRT.mjs";
5
- import "./chunk-PU5J4TNC.mjs";
4
+ } from "./chunk-VOM3CFYZ.mjs";
6
5
 
7
6
  // platforms/astro.ts
8
7
  function serve(routeFunction, options) {
@@ -1,6 +1,34 @@
1
- import {
2
- WorkflowAgents
3
- } from "./chunk-PU5J4TNC.mjs";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
4
32
 
5
33
  // src/constants.ts
6
34
  var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
@@ -811,29 +839,16 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
811
839
  await debug?.log("SUBMIT", "SUBMIT_CLEANUP", {
812
840
  deletedWorkflowRunId: workflowContext.workflowRunId
813
841
  });
814
- try {
815
- await workflowContext.qstashClient.http.request({
816
- path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
817
- method: "DELETE",
818
- parseResponseAsJson: false
819
- });
820
- await debug?.log(
821
- "SUBMIT",
822
- "SUBMIT_CLEANUP",
823
- `workflow run ${workflowContext.workflowRunId} deleted.`
824
- );
825
- return { deleted: true };
826
- } catch (error) {
827
- if (error instanceof QstashError3 && error.status === 404) {
828
- await debug?.log("WARN", "SUBMIT_CLEANUP", {
829
- message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
830
- name: error.name,
831
- errorMessage: error.message
832
- });
833
- return { deleted: false };
834
- }
835
- throw error;
836
- }
842
+ await workflowContext.qstashClient.http.request({
843
+ path: ["v2", "workflows", "runs", `${workflowContext.workflowRunId}?cancel=${cancel}`],
844
+ method: "DELETE",
845
+ parseResponseAsJson: false
846
+ });
847
+ await debug?.log(
848
+ "SUBMIT",
849
+ "SUBMIT_CLEANUP",
850
+ `workflow run ${workflowContext.workflowRunId} deleted.`
851
+ );
837
852
  };
838
853
  var recreateUserHeaders = (headers) => {
839
854
  const filteredHeaders = new Headers();
@@ -1617,6 +1632,283 @@ var WorkflowApi = class extends BaseWorkflowApi {
1617
1632
  }
1618
1633
  };
1619
1634
 
1635
+ // src/agents/adapters.ts
1636
+ import { createOpenAI } from "@ai-sdk/openai";
1637
+ import { tool } from "ai";
1638
+
1639
+ // src/agents/constants.ts
1640
+ var AGENT_NAME_HEADER = "upstash-agent-name";
1641
+ var MANAGER_AGENT_PROMPT = `You are an agent orchestrating other AI Agents.
1642
+
1643
+ These other agents have tools available to them.
1644
+
1645
+ Given a prompt, utilize these agents to address requests.
1646
+
1647
+ 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.
1648
+
1649
+ Avoid calling the same agent twice in one turn. Instead, prefer to call it once but provide everything
1650
+ you need from that agent.
1651
+ `;
1652
+
1653
+ // src/agents/adapters.ts
1654
+ var createWorkflowOpenAI = (context) => {
1655
+ return createOpenAI({
1656
+ compatibility: "strict",
1657
+ fetch: async (input, init) => {
1658
+ try {
1659
+ const headers = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
1660
+ const body = init?.body ? JSON.parse(init.body) : void 0;
1661
+ const agentName = headers[AGENT_NAME_HEADER];
1662
+ const stepName = agentName ? `Call Agent ${agentName}` : "Call Agent";
1663
+ const responseInfo = await context.call(stepName, {
1664
+ url: input.toString(),
1665
+ method: init?.method,
1666
+ headers,
1667
+ body
1668
+ });
1669
+ const responseHeaders = new Headers(
1670
+ Object.entries(responseInfo.header).reduce(
1671
+ (acc, [key, values]) => {
1672
+ acc[key] = values.join(", ");
1673
+ return acc;
1674
+ },
1675
+ {}
1676
+ )
1677
+ );
1678
+ return new Response(JSON.stringify(responseInfo.body), {
1679
+ status: responseInfo.status,
1680
+ headers: responseHeaders
1681
+ });
1682
+ } catch (error) {
1683
+ if (error instanceof Error && error.name === "WorkflowAbort") {
1684
+ throw error;
1685
+ } else {
1686
+ console.error("Error in fetch implementation:", error);
1687
+ throw error;
1688
+ }
1689
+ }
1690
+ }
1691
+ });
1692
+ };
1693
+ var wrapTools = ({
1694
+ context,
1695
+ tools
1696
+ }) => {
1697
+ return Object.fromEntries(
1698
+ Object.entries(tools).map((toolInfo) => {
1699
+ const [toolName, tool3] = toolInfo;
1700
+ const aiSDKTool = convertToAISDKTool(tool3);
1701
+ const execute = aiSDKTool.execute;
1702
+ if (execute) {
1703
+ const wrappedExecute = (...params) => {
1704
+ return context.run(`Run tool ${toolName}`, () => execute(...params));
1705
+ };
1706
+ aiSDKTool.execute = wrappedExecute;
1707
+ }
1708
+ return [toolName, aiSDKTool];
1709
+ })
1710
+ );
1711
+ };
1712
+ var convertToAISDKTool = (tool3) => {
1713
+ const isLangchainTool = "invoke" in tool3;
1714
+ return isLangchainTool ? convertLangchainTool(tool3) : tool3;
1715
+ };
1716
+ var convertLangchainTool = (langchainTool) => {
1717
+ return tool({
1718
+ description: langchainTool.description,
1719
+ parameters: langchainTool.schema,
1720
+ execute: async (...param) => langchainTool.invoke(...param)
1721
+ });
1722
+ };
1723
+
1724
+ // src/agents/agent.ts
1725
+ import { z } from "zod";
1726
+ import { generateText, tool as tool2, ToolExecutionError } from "ai";
1727
+ var Agent = class {
1728
+ name;
1729
+ tools;
1730
+ maxSteps;
1731
+ background;
1732
+ model;
1733
+ temparature;
1734
+ constructor({ tools, maxSteps, background, name, model, temparature = 0.1 }) {
1735
+ this.name = name;
1736
+ this.tools = tools ?? {};
1737
+ this.maxSteps = maxSteps;
1738
+ this.background = background;
1739
+ this.model = model;
1740
+ this.temparature = temparature;
1741
+ }
1742
+ /**
1743
+ * Trigger the agent by passing a prompt
1744
+ *
1745
+ * @param prompt task to assign to the agent
1746
+ * @returns Response as `{ text: string }`
1747
+ */
1748
+ async call({ prompt }) {
1749
+ try {
1750
+ const result = await generateText({
1751
+ model: this.model,
1752
+ tools: this.tools,
1753
+ maxSteps: this.maxSteps,
1754
+ system: this.background,
1755
+ prompt,
1756
+ headers: {
1757
+ [AGENT_NAME_HEADER]: this.name
1758
+ },
1759
+ temperature: this.temparature
1760
+ });
1761
+ return { text: result.text };
1762
+ } catch (error) {
1763
+ if (error instanceof ToolExecutionError) {
1764
+ if (error.cause instanceof Error && error.cause.name === "WorkflowAbort") {
1765
+ throw error.cause;
1766
+ } else if (error.cause instanceof ToolExecutionError && error.cause.cause instanceof Error && error.cause.cause.name === "WorkflowAbort") {
1767
+ throw error.cause.cause;
1768
+ } else {
1769
+ throw error;
1770
+ }
1771
+ } else {
1772
+ throw error;
1773
+ }
1774
+ }
1775
+ }
1776
+ /**
1777
+ * Convert the agent to a tool which can be used by other agents.
1778
+ *
1779
+ * @returns the agent as a tool
1780
+ */
1781
+ asTool() {
1782
+ const toolDescriptions = Object.values(this.tools).map((tool3) => tool3.description).join("\n");
1783
+ return tool2({
1784
+ parameters: z.object({ prompt: z.string() }),
1785
+ execute: async ({ prompt }) => {
1786
+ return await this.call({ prompt });
1787
+ },
1788
+ description: `An AI Agent with the following background: ${this.background}Has access to the following tools: ${toolDescriptions}`
1789
+ });
1790
+ }
1791
+ };
1792
+ var ManagerAgent = class extends Agent {
1793
+ agents;
1794
+ /**
1795
+ * A manager agent which coordinates agents available to it to achieve a
1796
+ * given task
1797
+ *
1798
+ * @param name Name of the agent
1799
+ * @param background Background of the agent. If not passed, default will be used.
1800
+ * @param model LLM model to use
1801
+ * @param agents: List of agents available to the agent
1802
+ * @param maxSteps number of times the manager agent can call the LLM at most.
1803
+ * If the agent abruptly stops execution after calling other agents, you may
1804
+ * need to increase maxSteps
1805
+ */
1806
+ constructor({
1807
+ agents,
1808
+ background = MANAGER_AGENT_PROMPT,
1809
+ model,
1810
+ maxSteps,
1811
+ name = "manager llm"
1812
+ }) {
1813
+ super({
1814
+ background,
1815
+ maxSteps,
1816
+ tools: Object.fromEntries(agents.map((agent) => [agent.name, agent.asTool()])),
1817
+ name,
1818
+ model
1819
+ });
1820
+ this.agents = agents;
1821
+ }
1822
+ };
1823
+
1824
+ // src/agents/task.ts
1825
+ var Task = class {
1826
+ context;
1827
+ taskParameters;
1828
+ constructor({
1829
+ context,
1830
+ taskParameters
1831
+ }) {
1832
+ this.context = context;
1833
+ this.taskParameters = taskParameters;
1834
+ }
1835
+ /**
1836
+ * Run the agents to complete the task
1837
+ *
1838
+ * @returns Result of the task as { text: string }
1839
+ */
1840
+ async run() {
1841
+ const { prompt, ...otherParams } = this.taskParameters;
1842
+ const safePrompt = await this.context.run("Get Prompt", () => prompt);
1843
+ if ("agent" in otherParams) {
1844
+ const agent = otherParams.agent;
1845
+ const result = await agent.call({
1846
+ prompt: safePrompt
1847
+ });
1848
+ return { text: result.text };
1849
+ } else {
1850
+ const { agents, maxSteps, model, background } = otherParams;
1851
+ const managerAgent = new ManagerAgent({
1852
+ model,
1853
+ maxSteps,
1854
+ agents,
1855
+ name: "Manager LLM",
1856
+ background
1857
+ });
1858
+ const result = await managerAgent.call({ prompt: safePrompt });
1859
+ return { text: result.text };
1860
+ }
1861
+ }
1862
+ };
1863
+
1864
+ // src/agents/index.ts
1865
+ var WorkflowAgents = class {
1866
+ context;
1867
+ constructor({ context }) {
1868
+ this.context = context;
1869
+ }
1870
+ /**
1871
+ * Defines an agent
1872
+ *
1873
+ * ```ts
1874
+ * const researcherAgent = context.agents.agent({
1875
+ * model,
1876
+ * name: 'academic',
1877
+ * maxSteps: 2,
1878
+ * tools: {
1879
+ * wikiTool: new WikipediaQueryRun({
1880
+ * topKResults: 1,
1881
+ * maxDocContentLength: 500,
1882
+ * })
1883
+ * },
1884
+ * background:
1885
+ * 'You are researcher agent with access to Wikipedia. ' +
1886
+ * 'Utilize Wikipedia as much as possible for correct information',
1887
+ * });
1888
+ * ```
1889
+ *
1890
+ * @param params agent parameters
1891
+ * @returns
1892
+ */
1893
+ agent(params) {
1894
+ const wrappedTools = wrapTools({ context: this.context, tools: params.tools });
1895
+ return new Agent({
1896
+ ...params,
1897
+ tools: wrappedTools
1898
+ });
1899
+ }
1900
+ task(taskParameters) {
1901
+ return new Task({ context: this.context, taskParameters });
1902
+ }
1903
+ /**
1904
+ * creates an openai model for agents
1905
+ */
1906
+ openai(...params) {
1907
+ const openai2 = createWorkflowOpenAI(this.context);
1908
+ return openai2(...params);
1909
+ }
1910
+ };
1911
+
1620
1912
  // src/context/context.ts
1621
1913
  var WorkflowContext = class {
1622
1914
  executor;
@@ -2211,7 +2503,6 @@ var checkIfLastOneIsDuplicate = async (steps, debug) => {
2211
2503
  if (step.stepId === lastStepId && step.targetStep === lastTargetStepId) {
2212
2504
  const message = `Upstash Workflow: The step '${step.stepName}' with id '${step.stepId}' has run twice during workflow execution. Rest of the workflow will continue running as usual.`;
2213
2505
  await debug?.log("WARN", "RESPONSE_DEFAULT", message);
2214
- console.log(steps);
2215
2506
  console.warn(message);
2216
2507
  return true;
2217
2508
  }
@@ -2571,6 +2862,9 @@ var serve = (routeFunction, options) => {
2571
2862
  };
2572
2863
 
2573
2864
  export {
2865
+ __require,
2866
+ __commonJS,
2867
+ __toESM,
2574
2868
  makeNotifyRequest,
2575
2869
  makeGetWaitersRequest,
2576
2870
  SDK_TELEMETRY,
package/cloudflare.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { R as RouteFunction, j as PublicServeOptions } from './types-BEyIoCRe.mjs';
1
+ import { R as RouteFunction, j as PublicServeOptions } from './types-D9gwTj2n.mjs';
2
2
  import '@upstash/qstash';
3
3
  import 'ai';
4
4
  import '@ai-sdk/openai';
5
- import 'langchain/tools';
6
5
 
7
6
  type WorkflowBindings = {
8
7
  QSTASH_TOKEN: string;
package/cloudflare.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { R as RouteFunction, j as PublicServeOptions } from './types-BEyIoCRe.js';
1
+ import { R as RouteFunction, j as PublicServeOptions } from './types-D9gwTj2n.js';
2
2
  import '@upstash/qstash';
3
3
  import 'ai';
4
4
  import '@ai-sdk/openai';
5
- import 'langchain/tools';
6
5
 
7
6
  type WorkflowBindings = {
8
7
  QSTASH_TOKEN: string;