@activepieces/piece-ai 0.4.3 → 0.4.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.
Files changed (53) hide show
  1. package/package.json +7 -30
  2. package/src/index.js +271 -28
  3. package/src/index.d.ts +0 -4
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/actions/agents/agent-output-builder.d.ts +0 -32
  7. package/src/lib/actions/agents/agent-output-builder.d.ts.map +0 -1
  8. package/src/lib/actions/agents/agent-output-builder.js +0 -112
  9. package/src/lib/actions/agents/agent-output-builder.js.map +0 -1
  10. package/src/lib/actions/agents/run-agent.d.ts +0 -10
  11. package/src/lib/actions/agents/run-agent.d.ts.map +0 -1
  12. package/src/lib/actions/agents/run-agent.js +0 -324
  13. package/src/lib/actions/agents/run-agent.js.map +0 -1
  14. package/src/lib/actions/agents/tools.d.ts +0 -30
  15. package/src/lib/actions/agents/tools.d.ts.map +0 -1
  16. package/src/lib/actions/agents/tools.js +0 -307
  17. package/src/lib/actions/agents/tools.js.map +0 -1
  18. package/src/lib/actions/agents/utils.d.ts +0 -24
  19. package/src/lib/actions/agents/utils.d.ts.map +0 -1
  20. package/src/lib/actions/agents/utils.js +0 -190
  21. package/src/lib/actions/agents/utils.js.map +0 -1
  22. package/src/lib/actions/image/generate-image.d.ts +0 -8
  23. package/src/lib/actions/image/generate-image.d.ts.map +0 -1
  24. package/src/lib/actions/image/generate-image.js +0 -285
  25. package/src/lib/actions/image/generate-image.js.map +0 -1
  26. package/src/lib/actions/text/ask-ai.d.ts +0 -11
  27. package/src/lib/actions/text/ask-ai.d.ts.map +0 -1
  28. package/src/lib/actions/text/ask-ai.js +0 -114
  29. package/src/lib/actions/text/ask-ai.js.map +0 -1
  30. package/src/lib/actions/text/summarize-text.d.ts +0 -8
  31. package/src/lib/actions/text/summarize-text.d.ts.map +0 -1
  32. package/src/lib/actions/text/summarize-text.js +0 -64
  33. package/src/lib/actions/text/summarize-text.js.map +0 -1
  34. package/src/lib/actions/utility/classify-text.d.ts +0 -7
  35. package/src/lib/actions/utility/classify-text.d.ts.map +0 -1
  36. package/src/lib/actions/utility/classify-text.js +0 -54
  37. package/src/lib/actions/utility/classify-text.js.map +0 -1
  38. package/src/lib/actions/utility/extract-structured-data.d.ts +0 -11
  39. package/src/lib/actions/utility/extract-structured-data.d.ts.map +0 -1
  40. package/src/lib/actions/utility/extract-structured-data.js +0 -259
  41. package/src/lib/actions/utility/extract-structured-data.js.map +0 -1
  42. package/src/lib/common/ai-sdk.d.ts +0 -90
  43. package/src/lib/common/ai-sdk.d.ts.map +0 -1
  44. package/src/lib/common/ai-sdk.js +0 -242
  45. package/src/lib/common/ai-sdk.js.map +0 -1
  46. package/src/lib/common/props.d.ts +0 -12
  47. package/src/lib/common/props.d.ts.map +0 -1
  48. package/src/lib/common/props.js +0 -69
  49. package/src/lib/common/props.js.map +0 -1
  50. package/src/lib/common/web-search.d.ts +0 -41
  51. package/src/lib/common/web-search.d.ts.map +0 -1
  52. package/src/lib/common/web-search.js +0 -191
  53. package/src/lib/common/web-search.js.map +0 -1
package/src/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const ai: import("@activepieces/pieces-framework").Piece<undefined>;
2
- export * from './lib/common/props';
3
- export * from './lib/common/ai-sdk';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,EAAE,2DAYb,CAAC;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AACA,qEAAwE;AACxE,iDAAqD;AACrD,sDAAkD;AAClD,sEAAkE;AAClE,uEAAyE;AACzE,uEAAmE;AACnE,2FAAsF;AACtF,8DAA0D;AAG7C,QAAA,EAAE,GAAG,IAAA,8BAAW,EAAC;IAC5B,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,uBAAuB,EAAE,QAAQ;IACjC,UAAU,EAAE;QACV,sBAAa,CAAC,uBAAuB;QACrC,sBAAa,CAAC,YAAY;KAC3B;IACD,OAAO,EAAE,0DAA0D;IACnE,OAAO,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,iBAAiB,CAAC;IACjD,OAAO,EAAE,CAAC,cAAK,EAAE,8BAAa,EAAE,oCAAmB,EAAE,4BAAY,EAAE,+CAAqB,EAAE,oBAAQ,CAAC;IACnG,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH,6DAAmC;AACnC,8DAAoC"}
@@ -1,32 +0,0 @@
1
- import { AgentResult, AgentTaskStatus, AgentTool } from '@activepieces/shared';
2
- export declare const agentOutputBuilder: (prompt: string) => {
3
- setStatus(_status: AgentTaskStatus): void;
4
- setToolMap(map: ToolKeyToAgentTool): void;
5
- setStructuredOutput(output: Record<string, unknown>): void;
6
- appendErrorToStructuredOutput(errorDetails: unknown): void;
7
- fail({ message }: FinishParams): void;
8
- addMarkdown(markdown: string): void;
9
- startToolCall({ toolName, toolCallId, input }: StartToolCallParams): void;
10
- finishToolCall({ toolCallId, output }: FinishToolCallParams): void;
11
- failToolCall({ toolCallId }: FailToolCallParams): void;
12
- hasTextContent(): boolean;
13
- build(): AgentResult;
14
- };
15
- type FinishToolCallParams = {
16
- toolCallId: string;
17
- output: Record<string, unknown>;
18
- };
19
- type FailToolCallParams = {
20
- toolCallId: string;
21
- };
22
- type StartToolCallParams = {
23
- toolName: string;
24
- toolCallId: string;
25
- input: Record<string, unknown>;
26
- };
27
- type FinishParams = {
28
- message?: string;
29
- };
30
- export type ToolKeyToAgentTool = Record<string, AgentTool>;
31
- export {};
32
- //# sourceMappingURL=agent-output-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-output-builder.d.ts","sourceRoot":"","sources":["../../../../../src/lib/actions/agents/agent-output-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,eAAe,EACf,SAAS,EAWV,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,kBAAkB,WAAY,MAAM;uBAO1B,eAAe;oBAGlB,kBAAkB;gCAGN,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gDAGP,OAAO;sBAKjC,YAAY;0BAOR,MAAM;mDAYmB,mBAAmB;2CAY3B,oBAAoB;iCAiB9B,kBAAkB;sBAmB7B,OAAO;aAOhB,WAAW;CASvB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AA8DF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.agentOutputBuilder = void 0;
4
- const shared_1 = require("@activepieces/shared");
5
- const agentOutputBuilder = (prompt) => {
6
- let status = shared_1.AgentTaskStatus.IN_PROGRESS;
7
- const steps = [];
8
- let structuredOutput = undefined;
9
- let toolKeyToAgentTool = {};
10
- return {
11
- setStatus(_status) {
12
- status = _status;
13
- },
14
- setToolMap(map) {
15
- toolKeyToAgentTool = map;
16
- },
17
- setStructuredOutput(output) {
18
- structuredOutput = output;
19
- },
20
- appendErrorToStructuredOutput(errorDetails) {
21
- if (structuredOutput) {
22
- structuredOutput["errors"] = [...(structuredOutput["errors"] || []), errorDetails];
23
- }
24
- },
25
- fail({ message }) {
26
- status = shared_1.AgentTaskStatus.FAILED;
27
- if (!(0, shared_1.isNil)(message)) {
28
- this.addMarkdown(message);
29
- this.appendErrorToStructuredOutput({ message });
30
- }
31
- },
32
- addMarkdown(markdown) {
33
- if (steps.length === 0 ||
34
- steps[steps.length - 1].type !== shared_1.ContentBlockType.MARKDOWN) {
35
- steps.push({
36
- type: shared_1.ContentBlockType.MARKDOWN,
37
- markdown: '',
38
- });
39
- }
40
- steps[steps.length - 1].markdown += markdown;
41
- },
42
- startToolCall({ toolName, toolCallId, input }) {
43
- const baseTool = {
44
- toolName,
45
- toolCallId,
46
- type: shared_1.ContentBlockType.TOOL_CALL,
47
- status: shared_1.ToolCallStatus.IN_PROGRESS,
48
- input,
49
- output: undefined,
50
- startTime: new Date().toISOString(),
51
- };
52
- steps.push(getToolMetadata({ toolName, baseTool, toolKeyToAgentTool }));
53
- },
54
- finishToolCall({ toolCallId, output }) {
55
- const toolIdx = steps.findIndex((block) => block.type === shared_1.ContentBlockType.TOOL_CALL &&
56
- block.toolCallId === toolCallId);
57
- if (toolIdx === -1) {
58
- return;
59
- }
60
- const tool = steps[toolIdx];
61
- steps[toolIdx] = Object.assign(Object.assign({}, tool), { status: shared_1.ToolCallStatus.COMPLETED, endTime: new Date().toISOString(), output });
62
- },
63
- failToolCall({ toolCallId }) {
64
- const toolIdx = steps.findIndex((block) => block.type === shared_1.ContentBlockType.TOOL_CALL &&
65
- block.toolCallId === toolCallId);
66
- if (toolIdx === -1) {
67
- return;
68
- }
69
- const tool = steps[toolIdx];
70
- steps[toolIdx] = Object.assign(Object.assign({}, tool), { status: shared_1.ToolCallStatus.COMPLETED, endTime: new Date().toISOString(), output: {
71
- status: shared_1.ExecutionToolStatus.FAILED
72
- } });
73
- },
74
- hasTextContent() {
75
- return steps.some((step) => step.type === shared_1.ContentBlockType.MARKDOWN &&
76
- step.markdown.trim().length > 0);
77
- },
78
- build() {
79
- return {
80
- status,
81
- steps,
82
- structuredOutput,
83
- prompt,
84
- };
85
- },
86
- };
87
- };
88
- exports.agentOutputBuilder = agentOutputBuilder;
89
- function getToolMetadata({ toolName, baseTool, toolKeyToAgentTool, }) {
90
- const tool = toolKeyToAgentTool[toolName];
91
- if ((0, shared_1.isNil)(tool)) {
92
- return Object.assign(Object.assign({}, baseTool), { toolCallType: shared_1.ToolCallType.UNKNOWN, displayName: toolName });
93
- }
94
- switch (tool.type) {
95
- case shared_1.AgentToolType.PIECE: {
96
- (0, shared_1.assertNotNullOrUndefined)(tool.pieceMetadata, 'Piece metadata is required');
97
- return Object.assign(Object.assign({}, baseTool), { toolCallType: shared_1.ToolCallType.PIECE, pieceName: tool.pieceMetadata.pieceName, pieceVersion: tool.pieceMetadata.pieceVersion, actionName: tool.pieceMetadata.actionName });
98
- }
99
- case shared_1.AgentToolType.FLOW: {
100
- (0, shared_1.assertNotNullOrUndefined)(tool.externalFlowId, 'Flow ID is required');
101
- return Object.assign(Object.assign({}, baseTool), { toolCallType: shared_1.ToolCallType.FLOW, displayName: tool.toolName, externalFlowId: tool.externalFlowId });
102
- }
103
- case shared_1.AgentToolType.MCP: {
104
- (0, shared_1.assertNotNullOrUndefined)(tool.serverUrl, 'MCP server URL is required');
105
- return Object.assign(Object.assign({}, baseTool), { toolCallType: shared_1.ToolCallType.MCP, displayName: toolName, serverUrl: tool.serverUrl });
106
- }
107
- case shared_1.AgentToolType.KNOWLEDGE_BASE: {
108
- return Object.assign(Object.assign({}, baseTool), { toolCallType: shared_1.ToolCallType.KNOWLEDGE_BASE, displayName: tool.sourceName, sourceType: tool.sourceType });
109
- }
110
- }
111
- }
112
- //# sourceMappingURL=agent-output-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-output-builder.js","sourceRoot":"","sources":["../../../../../src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K,QAAQ,KACX,YAAY,EAAE,qBAAY,CAAC,KAAK,EAChC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EACvC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,EAC7C,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,IACzC;QACJ,CAAC;QACD,KAAK,sBAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YACxB,IAAA,iCAAwB,EAAC,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;YACrE,uCACK,QAAQ,KACX,YAAY,EAAE,qBAAY,CAAC,IAAI,EAC/B,WAAW,EAAE,IAAI,CAAC,QAAQ,EAC1B,cAAc,EAAE,IAAI,CAAC,cAAc,IACnC;QACJ,CAAC;QACD,KAAK,sBAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,IAAA,iCAAwB,EAAC,IAAI,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC;YACvE,uCACK,QAAQ,KACX,YAAY,EAAE,qBAAY,CAAC,GAAG,EAC9B,WAAW,EAAE,QAAQ,EACrB,SAAS,EAAE,IAAI,CAAC,SAAS,IACzB;QACJ,CAAC;QACD,KAAK,sBAAa,CAAC,cAAc,CAAC,CAAC,CAAC;YAClC,uCACK,QAAQ,KACX,YAAY,EAAE,qBAAY,CAAC,cAAc,EACzC,WAAW,EAAE,IAAI,CAAC,UAAU,EAC5B,UAAU,EAAE,IAAI,CAAC,UAAU,IAC3B;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare const runAgent: import("@activepieces/pieces-framework").IAction<undefined, {
2
- prompt: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
- aiProviderModel: import("@activepieces/pieces-framework").ObjectProperty<true>;
4
- agentTools: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
5
- structuredOutput: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
6
- maxSteps: import("@activepieces/pieces-framework").NumberProperty<true>;
7
- webSearch: import("@activepieces/pieces-framework").CheckboxProperty<false>;
8
- webSearchOptions: import("@activepieces/pieces-framework").DynamicProperties<false, undefined>;
9
- }>;
10
- //# sourceMappingURL=run-agent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-agent.d.ts","sourceRoot":"","sources":["../../../../../src/lib/actions/agents/run-agent.ts"],"names":[],"mappings":"AA+EA,eAAO,MAAM,QAAQ;;;;;;;;EAuRnB,CAAC"}
@@ -1,324 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runAgent = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const shared_1 = require("@activepieces/shared");
7
- const ai_1 = require("ai");
8
- const agent_output_builder_1 = require("./agent-output-builder");
9
- const ai_sdk_1 = require("../../common/ai-sdk");
10
- const util_1 = require("util");
11
- const utils_1 = require("./utils");
12
- const tools_1 = require("./tools");
13
- const web_search_1 = require("../../common/web-search");
14
- const agentToolArrayItems = {
15
- type: pieces_framework_1.Property.ShortText({
16
- displayName: 'Tool Type',
17
- required: true,
18
- }),
19
- toolName: pieces_framework_1.Property.ShortText({
20
- displayName: 'Tool Name',
21
- required: true,
22
- }),
23
- pieceMetadata: pieces_framework_1.Property.Json({
24
- displayName: 'Piece Metadata',
25
- required: false,
26
- }),
27
- externalFlowId: pieces_framework_1.Property.ShortText({
28
- displayName: 'Flow External ID',
29
- required: false,
30
- }),
31
- serverUrl: pieces_framework_1.Property.ShortText({
32
- displayName: 'MCP Server URL',
33
- required: false,
34
- }),
35
- protocol: pieces_framework_1.Property.ShortText({
36
- displayName: 'Protocol',
37
- required: false,
38
- }),
39
- auth: pieces_framework_1.Property.Json({
40
- displayName: 'Auth Configuration',
41
- required: false,
42
- }),
43
- sourceType: pieces_framework_1.Property.ShortText({
44
- displayName: 'Source Type',
45
- required: false,
46
- }),
47
- sourceId: pieces_framework_1.Property.ShortText({
48
- displayName: 'Source ID',
49
- required: false,
50
- }),
51
- sourceName: pieces_framework_1.Property.ShortText({
52
- displayName: 'Source Name',
53
- required: false,
54
- }),
55
- };
56
- exports.runAgent = (0, pieces_framework_1.createAction)({
57
- name: 'run_agent',
58
- displayName: 'Run Agent',
59
- description: 'Handles complex, multi-step tasks by reasoning through problems, using tools accurately, and iterating until the job is done.',
60
- auth: pieces_framework_1.PieceAuth.None(),
61
- props: {
62
- [shared_1.AgentPieceProps.PROMPT]: pieces_framework_1.Property.LongText({
63
- displayName: 'Prompt',
64
- description: 'Describe what you want the assistant to do.',
65
- required: true,
66
- }),
67
- [shared_1.AgentPieceProps.AI_PROVIDER_MODEL]: pieces_framework_1.Property.Object({
68
- displayName: 'AI Model',
69
- required: true,
70
- }),
71
- [shared_1.AgentPieceProps.AGENT_TOOLS]: pieces_framework_1.Property.Array({
72
- displayName: 'Agent Tools',
73
- required: false,
74
- properties: agentToolArrayItems,
75
- }),
76
- [shared_1.AgentPieceProps.STRUCTURED_OUTPUT]: pieces_framework_1.Property.Array({
77
- displayName: 'Structured Output',
78
- defaultValue: undefined,
79
- required: false,
80
- properties: {
81
- displayName: pieces_framework_1.Property.ShortText({
82
- displayName: 'Display Name',
83
- required: true,
84
- }),
85
- description: pieces_framework_1.Property.ShortText({
86
- displayName: 'Description',
87
- required: false,
88
- }),
89
- type: pieces_framework_1.Property.ShortText({
90
- displayName: 'Type',
91
- required: true,
92
- }),
93
- },
94
- }),
95
- [shared_1.AgentPieceProps.MAX_STEPS]: pieces_framework_1.Property.Number({
96
- displayName: 'Max steps',
97
- description: 'The number of iterations the agent can do',
98
- required: true,
99
- defaultValue: 20,
100
- }),
101
- [shared_1.AgentPieceProps.WEB_SEARCH]: pieces_framework_1.Property.Checkbox({
102
- displayName: 'Web Search',
103
- required: false,
104
- defaultValue: false,
105
- description: 'Whether to use web search to find information for the AI to use.',
106
- }),
107
- [shared_1.AgentPieceProps.WEB_SEARCH_OPTIONS]: (0, web_search_1.buildWebSearchOptionsProperty)((propsValue) => {
108
- const aiProviderModel = propsValue['aiProviderModel'];
109
- return { provider: aiProviderModel === null || aiProviderModel === void 0 ? void 0 : aiProviderModel.provider, model: aiProviderModel === null || aiProviderModel === void 0 ? void 0 : aiProviderModel.model };
110
- }, ['webSearch', 'aiProviderModel'], { showIncludeSources: false }),
111
- },
112
- run(context) {
113
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
114
- var _a, e_1, _b, _c;
115
- var _d;
116
- const { prompt, maxSteps, aiProviderModel } = context.propsValue;
117
- const agentProviderModel = aiProviderModel;
118
- const provider = agentProviderModel.provider;
119
- const webSearchEnabled = !!(context.propsValue.webSearch);
120
- const webSearchOptions = ((_d = context.propsValue.webSearchOptions) !== null && _d !== void 0 ? _d : {});
121
- const { tools: webSearchTools, providerOptions } = (0, web_search_1.buildWebSearchConfig)({
122
- provider,
123
- model: agentProviderModel.model,
124
- webSearchEnabled,
125
- webSearchOptions,
126
- });
127
- const { provider: effectiveProvider } = (0, shared_1.getEffectiveProviderAndModel)({
128
- provider,
129
- model: agentProviderModel.model,
130
- });
131
- const model = yield (0, ai_sdk_1.createAIModel)(Object.assign({ modelId: agentProviderModel.model, provider, engineToken: context.server.token, apiUrl: context.server.apiUrl, projectId: context.project.id, flowId: context.flows.current.id, runId: context.run.id }, (0, shared_1.spreadIfDefined)('openaiResponsesModel', webSearchEnabled && effectiveProvider === shared_1.AIProviderName.OPENAI ? true : undefined)));
132
- const outputBuilder = (0, agent_output_builder_1.agentOutputBuilder)(prompt);
133
- const hasStructuredOutput = !(0, shared_1.isNil)(context.propsValue.structuredOutput) &&
134
- context.propsValue.structuredOutput.length > 0;
135
- const structuredOutput = hasStructuredOutput ? context.propsValue.structuredOutput : undefined;
136
- const agentTools = context.propsValue.agentTools;
137
- const hasKnowledgeBaseTools = agentTools.some(t => t.type === shared_1.AgentToolType.KNOWLEDGE_BASE);
138
- const kbFileTools = agentTools.filter((t) => t.type === shared_1.AgentToolType.KNOWLEDGE_BASE && t.sourceType === shared_1.KnowledgeBaseSourceType.FILE);
139
- const hasKbFileTools = kbFileTools.length > 0;
140
- let embeddingConfig;
141
- if (hasKbFileTools) {
142
- try {
143
- const result = yield (0, ai_sdk_1.createEmbeddingModel)({
144
- provider: agentProviderModel.provider,
145
- engineToken: context.server.token,
146
- apiUrl: context.server.apiUrl,
147
- });
148
- embeddingConfig = { model: result.model, providerOptions: result.providerOptions };
149
- }
150
- catch (err) {
151
- outputBuilder.addMarkdown(`\n\n**Warning:** Could not create embedding model for knowledge base search: ${err instanceof Error ? err.message : 'Unknown error'}\n\n`);
152
- }
153
- }
154
- const { mcpClients, tools, toolKeyToAgentTool } = yield (0, tools_1.constructAgentTools)({
155
- context,
156
- agentTools,
157
- model,
158
- outputBuilder,
159
- structuredOutput,
160
- embeddingConfig,
161
- });
162
- outputBuilder.setToolMap(toolKeyToAgentTool);
163
- const allTools = webSearchTools
164
- ? Object.assign(Object.assign({}, webSearchTools), tools) : tools;
165
- const errors = [];
166
- try {
167
- const prompts = utils_1.agentUtils.getPrompts(prompt, { hasKnowledgeBaseTools });
168
- const stream = (0, ai_1.streamText)({
169
- model: model,
170
- system: prompts.system,
171
- prompt: prompts.prompt,
172
- tools: allTools,
173
- stopWhen: [(0, ai_1.stepCountIs)(maxSteps), (0, ai_1.hasToolCall)(shared_1.TASK_COMPLETION_TOOL_NAME)],
174
- providerOptions,
175
- onFinish: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
176
- yield Promise.all(mcpClients.map((client) => tslib_1.__awaiter(this, void 0, void 0, function* () { return client.close(); })));
177
- }),
178
- });
179
- try {
180
- for (var _e = true, _f = tslib_1.__asyncValues(stream.fullStream), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) {
181
- _c = _g.value;
182
- _e = false;
183
- const chunk = _c;
184
- try {
185
- switch (chunk.type) {
186
- case 'text-delta': {
187
- outputBuilder.addMarkdown(chunk.text);
188
- break;
189
- }
190
- case 'reasoning-delta': {
191
- if ('text' in chunk && typeof chunk.text === 'string') {
192
- outputBuilder.addMarkdown(chunk.text);
193
- }
194
- else if ('delta' in chunk && typeof chunk.delta === 'string') {
195
- outputBuilder.addMarkdown(chunk.delta);
196
- }
197
- break;
198
- }
199
- case 'tool-call': {
200
- if (utils_1.agentUtils.isTaskCompletionToolCall(chunk.toolName)) {
201
- continue;
202
- }
203
- outputBuilder.startToolCall({
204
- toolName: chunk.toolName,
205
- toolCallId: chunk.toolCallId,
206
- input: chunk.input,
207
- });
208
- break;
209
- }
210
- case 'tool-result': {
211
- if (utils_1.agentUtils.isTaskCompletionToolCall(chunk.toolName)) {
212
- continue;
213
- }
214
- const rawOutput = chunk.output;
215
- const toolOutput = (0, shared_1.normalizeToolOutputToExecuteResponse)(rawOutput);
216
- if (toolOutput['status'] === shared_1.ExecutionToolStatus.FAILED && toolOutput['errorMessage']) {
217
- outputBuilder.addMarkdown(`\n\n**Error:** ${JSON.stringify(toolOutput['errorMessage'])}\n\n`);
218
- }
219
- outputBuilder.finishToolCall({
220
- toolCallId: chunk.toolCallId,
221
- output: toolOutput,
222
- });
223
- break;
224
- }
225
- case 'tool-error': {
226
- errors.push({
227
- type: 'tool-error',
228
- message: `Tool ${chunk.toolName} failed`,
229
- details: chunk.error,
230
- });
231
- outputBuilder.failToolCall({
232
- toolCallId: chunk.toolCallId,
233
- });
234
- break;
235
- }
236
- case 'error': {
237
- errors.push({
238
- type: 'stream-error',
239
- message: 'Error during streaming',
240
- details: (0, util_1.inspect)(chunk.error),
241
- });
242
- break;
243
- }
244
- case 'start':
245
- case 'start-step':
246
- case 'tool-input-start':
247
- case 'tool-input-delta':
248
- case 'tool-input-end':
249
- case 'finish-step':
250
- case 'finish':
251
- break;
252
- default:
253
- break;
254
- }
255
- yield context.output.update({ data: outputBuilder.build() });
256
- }
257
- catch (innerError) {
258
- let detailsStr;
259
- try {
260
- detailsStr = typeof innerError === 'object' && innerError !== null && 'message' in innerError
261
- ? `${innerError.message}${innerError.stack ? `\n${innerError.stack}` : ''}`
262
- : (0, util_1.inspect)(innerError);
263
- }
264
- catch (_h) {
265
- detailsStr = String(innerError);
266
- }
267
- errors.push({
268
- type: 'chunk-processing-error',
269
- message: `Error processing chunk (type=${chunk.type})`,
270
- details: detailsStr,
271
- });
272
- }
273
- }
274
- }
275
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
276
- finally {
277
- try {
278
- if (!_e && !_a && (_b = _f.return)) yield _b.call(_f);
279
- }
280
- finally { if (e_1) throw e_1.error; }
281
- }
282
- if (!outputBuilder.hasTextContent()) {
283
- try {
284
- const accumulatedText = yield stream.text;
285
- if (accumulatedText === null || accumulatedText === void 0 ? void 0 : accumulatedText.trim()) {
286
- outputBuilder.addMarkdown(accumulatedText);
287
- yield context.output.update({ data: outputBuilder.build() });
288
- }
289
- }
290
- catch (_j) {
291
- // ignore
292
- }
293
- }
294
- if (errors.length > 0) {
295
- const errorSummary = errors.map(e => {
296
- const detail = e.details != null ? `\n ${String(e.details)}` : '';
297
- return `${e.type}: ${e.message}${detail}`;
298
- }).join('\n');
299
- outputBuilder.addMarkdown(`\n\n**Errors encountered:**\n${errorSummary}`);
300
- outputBuilder.fail({ message: 'Agent completed with errors' });
301
- yield context.output.update({ data: outputBuilder.build() });
302
- }
303
- else {
304
- outputBuilder.setStatus(shared_1.AgentTaskStatus.COMPLETED);
305
- }
306
- }
307
- catch (error) {
308
- let errorMessage = `Agent failed unexpectedly: ${(0, util_1.inspect)(error)}`;
309
- if (errors.length > 0) {
310
- const collectedErrors = errors.map(e => {
311
- const detail = e.details != null ? `\n ${String(e.details)}` : '';
312
- return `${e.type}: ${e.message}${detail}`;
313
- }).join('\n');
314
- errorMessage += `\n\nCollected stream errors:\n${collectedErrors}`;
315
- }
316
- outputBuilder.fail({ message: errorMessage });
317
- yield context.output.update({ data: outputBuilder.build() });
318
- yield Promise.all(mcpClients.map((client) => tslib_1.__awaiter(this, void 0, void 0, function* () { return client.close(); })));
319
- }
320
- return outputBuilder.build();
321
- });
322
- }
323
- });
324
- //# sourceMappingURL=run-agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../../../../../src/lib/actions/agents/run-agent.ts"],"names":[],"mappings":";;;;AAAA,qEAKwC;AACxC,iDAgB8B;AAC9B,2BAA0D;AAC1D,iEAA4D;AAC5D,gDAA0E;AAC1E,+BAA+B;AAC/B,mCAAqC;AACrC,mCAA8C;AAC9C,wDAAgH;AAEhH,MAAM,mBAAmB,GAA2B;IAClD,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;QACvB,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,IAAI;KACf,CAAC;IAEF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC3B,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,IAAI;KACf,CAAC;IAEF,aAAa,EAAE,2BAAQ,CAAC,IAAI,CAAC;QAC3B,WAAW,EAAE,gBAAgB;QAC7B,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,cAAc,EAAE,2BAAQ,CAAC,SAAS,CAAC;QACjC,WAAW,EAAE,kBAAkB;QAC/B,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC5B,WAAW,EAAE,gBAAgB;QAC7B,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC3B,WAAW,EAAE,UAAU;QACvB,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;QAClB,WAAW,EAAE,oBAAoB;QACjC,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;QAC7B,WAAW,EAAE,aAAa;QAC1B,QAAQ,EAAE,KAAK;KAChB,CAAC;IACF,QAAQ,EAAE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;QAC/B,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,30 +0,0 @@
1
- import { EmbeddingModel, LanguageModel, Tool } from "ai";
2
- import { agentOutputBuilder } from "./agent-output-builder";
3
- import { AgentOutputField, AgentTool } from "@activepieces/shared";
4
- import { ActionContext } from "@activepieces/pieces-framework";
5
- import { ProviderOptions } from "@ai-sdk/provider-utils";
6
- import { MCPClient } from '@ai-sdk/mcp';
7
- export declare function constructAgentTools(params: ConstructAgentToolParams): Promise<{
8
- tools: Record<string, Tool>;
9
- mcpClients: MCPClient[];
10
- toolKeyToAgentTool: Record<string, AgentTool>;
11
- }>;
12
- type ConstructAgentToolParams = {
13
- outputBuilder: ReturnType<typeof agentOutputBuilder>;
14
- structuredOutput?: AgentOutputField[];
15
- agentTools: AgentTool[];
16
- context: ActionContext;
17
- model: LanguageModel;
18
- embeddingConfig?: EmbeddingConfig;
19
- };
20
- type EmbeddingConfig = {
21
- model: EmbeddingModel;
22
- providerOptions: ProviderOptions;
23
- };
24
- export type McpServerTools = {
25
- mcpName: string;
26
- mcpClient: MCPClient;
27
- tools: Record<string, Tool>;
28
- };
29
- export {};
30
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../src/lib/actions/agents/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAGxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAwC,gBAAgB,EAAmB,SAAS,EAAuI,MAAM,sBAAsB,CAAC;AAE/P,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAmD,SAAS,EAAgB,MAAM,aAAa,CAAC;AAoRvG,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,wB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