@n8n/agents 0.6.0 → 0.7.0
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/dist/build.tsbuildinfo +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/integrations/langsmith.d.ts +2 -0
- package/dist/integrations/langsmith.js +117 -2
- package/dist/integrations/langsmith.js.map +1 -1
- package/dist/runtime/agent-runtime.d.ts +6 -7
- package/dist/runtime/agent-runtime.js +390 -204
- package/dist/runtime/agent-runtime.js.map +1 -1
- package/dist/runtime/event-bus.d.ts +1 -0
- package/dist/runtime/event-bus.js +3 -0
- package/dist/runtime/event-bus.js.map +1 -1
- package/dist/runtime/json-value.d.ts +2 -0
- package/dist/runtime/json-value.js +43 -0
- package/dist/runtime/json-value.js.map +1 -0
- package/dist/runtime/memory-store.d.ts +40 -2
- package/dist/runtime/memory-store.js +138 -3
- package/dist/runtime/memory-store.js.map +1 -1
- package/dist/runtime/message-list.d.ts +5 -0
- package/dist/runtime/message-list.js +47 -0
- package/dist/runtime/message-list.js.map +1 -1
- package/dist/runtime/messages.d.ts +0 -2
- package/dist/runtime/messages.js +127 -101
- package/dist/runtime/messages.js.map +1 -1
- package/dist/runtime/model-factory.js +117 -34
- package/dist/runtime/model-factory.js.map +1 -1
- package/dist/runtime/provider-credentials.d.ts +167 -0
- package/dist/runtime/provider-credentials.js +34 -0
- package/dist/runtime/provider-credentials.js.map +1 -0
- package/dist/runtime/runtime-helpers.d.ts +3 -4
- package/dist/runtime/runtime-helpers.js +6 -32
- package/dist/runtime/runtime-helpers.js.map +1 -1
- package/dist/runtime/stream.js +25 -43
- package/dist/runtime/stream.js.map +1 -1
- package/dist/runtime/strip-orphaned-tool-messages.js +1 -25
- package/dist/runtime/strip-orphaned-tool-messages.js.map +1 -1
- package/dist/runtime/title-generation.d.ts +12 -3
- package/dist/runtime/title-generation.js +72 -3
- package/dist/runtime/title-generation.js.map +1 -1
- package/dist/runtime/tool-adapter.d.ts +1 -1
- package/dist/runtime/tool-adapter.js +3 -2
- package/dist/runtime/tool-adapter.js.map +1 -1
- package/dist/runtime/working-memory.d.ts +1 -1
- package/dist/runtime/working-memory.js +1 -1
- package/dist/runtime/working-memory.js.map +1 -1
- package/dist/sdk/agent.d.ts +24 -23
- package/dist/sdk/agent.js +50 -324
- package/dist/sdk/agent.js.map +1 -1
- package/dist/sdk/eval.d.ts +0 -3
- package/dist/sdk/eval.js +4 -9
- package/dist/sdk/eval.js.map +1 -1
- package/dist/sdk/provider-capabilities.js +4 -2
- package/dist/sdk/provider-capabilities.js.map +1 -1
- package/dist/sdk/provider-tools.d.ts +17 -2
- package/dist/sdk/provider-tools.js +19 -0
- package/dist/sdk/provider-tools.js.map +1 -1
- package/dist/sdk/telemetry.d.ts +2 -0
- package/dist/sdk/telemetry.js +6 -0
- package/dist/sdk/telemetry.js.map +1 -1
- package/dist/sdk/tool.d.ts +17 -10
- package/dist/sdk/tool.js +34 -0
- package/dist/sdk/tool.js.map +1 -1
- package/dist/sdk/verify.js +1 -4
- package/dist/sdk/verify.js.map +1 -1
- package/dist/storage/base-memory.d.ts +64 -0
- package/dist/storage/base-memory.js +54 -0
- package/dist/storage/base-memory.js.map +1 -0
- package/dist/storage/postgres-memory.d.ts +33 -16
- package/dist/storage/postgres-memory.js +46 -25
- package/dist/storage/postgres-memory.js.map +1 -1
- package/dist/storage/sqlite-memory.d.ts +16 -6
- package/dist/storage/sqlite-memory.js +16 -10
- package/dist/storage/sqlite-memory.js.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +3 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/runtime/event.d.ts +3 -9
- package/dist/types/runtime/event.js.map +1 -1
- package/dist/types/sdk/agent-builder.d.ts +0 -3
- package/dist/types/sdk/agent.d.ts +64 -27
- package/dist/types/sdk/credential-provider.d.ts +2 -3
- package/dist/types/sdk/memory.d.ts +23 -2
- package/dist/types/sdk/message.d.ts +11 -10
- package/dist/types/sdk/observation.d.ts +100 -0
- package/dist/types/sdk/observation.js +5 -0
- package/dist/types/sdk/observation.js.map +1 -0
- package/dist/types/sdk/tool-descriptor.d.ts +13 -0
- package/dist/types/sdk/{schema.js → tool-descriptor.js} +1 -1
- package/dist/types/sdk/tool-descriptor.js.map +1 -0
- package/dist/types/sdk/tool.d.ts +8 -3
- package/dist/types/telemetry.d.ts +1 -0
- package/dist/utils/parse.d.ts +10 -0
- package/dist/utils/parse.js +26 -0
- package/dist/utils/parse.js.map +1 -0
- package/dist/utils/zod.d.ts +1 -1
- package/dist/utils/zod.js.map +1 -1
- package/dist/workspace/tools/batch-str-replace-file.d.ts +3 -0
- package/dist/workspace/tools/batch-str-replace-file.js +67 -0
- package/dist/workspace/tools/batch-str-replace-file.js.map +1 -0
- package/dist/workspace/tools/str-replace-file.d.ts +3 -0
- package/dist/workspace/tools/str-replace-file.js +51 -0
- package/dist/workspace/tools/str-replace-file.js.map +1 -0
- package/dist/workspace/tools/workspace-tools.js +4 -0
- package/dist/workspace/tools/workspace-tools.js.map +1 -1
- package/package.json +17 -8
- package/dist/codegen/generate-agent-code.d.ts +0 -2
- package/dist/codegen/generate-agent-code.js +0 -197
- package/dist/codegen/generate-agent-code.js.map +0 -1
- package/dist/sdk/from-schema.d.ts +0 -15
- package/dist/sdk/from-schema.js +0 -218
- package/dist/sdk/from-schema.js.map +0 -1
- package/dist/types/sdk/schema.d.ts +0 -99
- package/dist/types/sdk/schema.js.map +0 -1
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateAgentCode = generateAgentCode;
|
|
37
|
-
function escapeTemplateLiteral(str) {
|
|
38
|
-
return str.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
39
|
-
}
|
|
40
|
-
function escapeSingleQuote(str) {
|
|
41
|
-
return JSON.stringify(str).slice(1, -1).replace(/'/g, "\\'");
|
|
42
|
-
}
|
|
43
|
-
let prettierInstance;
|
|
44
|
-
async function formatCode(code) {
|
|
45
|
-
prettierInstance ??= await Promise.resolve().then(() => __importStar(require('prettier')));
|
|
46
|
-
return await prettierInstance.format(code, {
|
|
47
|
-
parser: 'typescript',
|
|
48
|
-
singleQuote: true,
|
|
49
|
-
useTabs: true,
|
|
50
|
-
trailingComma: 'all',
|
|
51
|
-
printWidth: 100,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function assertAllHandled(_) {
|
|
55
|
-
}
|
|
56
|
-
function modelParts(model) {
|
|
57
|
-
if (model.provider && model.name) {
|
|
58
|
-
return [`.model('${escapeSingleQuote(model.provider)}', '${escapeSingleQuote(model.name)}')`];
|
|
59
|
-
}
|
|
60
|
-
if (model.name) {
|
|
61
|
-
return [`.model('${escapeSingleQuote(model.name)}')`];
|
|
62
|
-
}
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
function toolPart(tool) {
|
|
66
|
-
if (!tool.editable) {
|
|
67
|
-
return {
|
|
68
|
-
part: `.tool(new WorkflowTool('${escapeSingleQuote(tool.name)}'))`,
|
|
69
|
-
usesWorkflowTool: true,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const parts = [`new Tool('${escapeSingleQuote(tool.name)}')`];
|
|
73
|
-
parts.push(`.description('${escapeSingleQuote(tool.description)}')`);
|
|
74
|
-
if (tool.inputSchemaSource)
|
|
75
|
-
parts.push(`.input(${tool.inputSchemaSource})`);
|
|
76
|
-
if (tool.outputSchemaSource)
|
|
77
|
-
parts.push(`.output(${tool.outputSchemaSource})`);
|
|
78
|
-
if (tool.suspendSchemaSource)
|
|
79
|
-
parts.push(`.suspend(${tool.suspendSchemaSource})`);
|
|
80
|
-
if (tool.resumeSchemaSource)
|
|
81
|
-
parts.push(`.resume(${tool.resumeSchemaSource})`);
|
|
82
|
-
if (tool.handlerSource)
|
|
83
|
-
parts.push(`.handler(${tool.handlerSource})`);
|
|
84
|
-
if (tool.toMessageSource)
|
|
85
|
-
parts.push(`.toMessage(${tool.toMessageSource})`);
|
|
86
|
-
if (tool.requireApproval)
|
|
87
|
-
parts.push('.requireApproval()');
|
|
88
|
-
if (tool.needsApprovalFnSource)
|
|
89
|
-
parts.push(`.needsApprovalFn(${tool.needsApprovalFnSource})`);
|
|
90
|
-
return { part: `.tool(${parts.join('')})`, usesWorkflowTool: false };
|
|
91
|
-
}
|
|
92
|
-
function evalPart(ev) {
|
|
93
|
-
const parts = [`new Eval('${escapeSingleQuote(ev.name)}')`];
|
|
94
|
-
if (ev.description)
|
|
95
|
-
parts.push(`.description('${escapeSingleQuote(ev.description)}')`);
|
|
96
|
-
if (ev.modelId)
|
|
97
|
-
parts.push(`.model('${escapeSingleQuote(ev.modelId)}')`);
|
|
98
|
-
if (ev.credentialName)
|
|
99
|
-
parts.push(`.credential('${escapeSingleQuote(ev.credentialName)}')`);
|
|
100
|
-
if (ev.handlerSource) {
|
|
101
|
-
parts.push(ev.type === 'check' ? `.check(${ev.handlerSource})` : `.judge(${ev.handlerSource})`);
|
|
102
|
-
}
|
|
103
|
-
return `.eval(${parts.join('')})`;
|
|
104
|
-
}
|
|
105
|
-
function guardrailPart(g) {
|
|
106
|
-
const method = g.position === 'input' ? 'inputGuardrail' : 'outputGuardrail';
|
|
107
|
-
return `.${method}(${g.source})`;
|
|
108
|
-
}
|
|
109
|
-
function memoryPart(memory) {
|
|
110
|
-
if (memory.source) {
|
|
111
|
-
return `.memory(${memory.source})`;
|
|
112
|
-
}
|
|
113
|
-
return `.memory(new Memory().lastMessages(${memory.lastMessages ?? 10}))`;
|
|
114
|
-
}
|
|
115
|
-
function thinkingPart(thinking) {
|
|
116
|
-
const props = [];
|
|
117
|
-
if (thinking.budgetTokens !== undefined)
|
|
118
|
-
props.push(`budgetTokens: ${thinking.budgetTokens}`);
|
|
119
|
-
if (thinking.reasoningEffort)
|
|
120
|
-
props.push(`reasoningEffort: '${thinking.reasoningEffort}'`);
|
|
121
|
-
if (props.length > 0) {
|
|
122
|
-
return `.thinking('${thinking.provider}', { ${props.join(', ')} })`;
|
|
123
|
-
}
|
|
124
|
-
return `.thinking('${thinking.provider}')`;
|
|
125
|
-
}
|
|
126
|
-
function buildImports(schema, needsWorkflowTool) {
|
|
127
|
-
const agentImports = new Set(['Agent']);
|
|
128
|
-
if (schema.tools.some((t) => t.editable))
|
|
129
|
-
agentImports.add('Tool');
|
|
130
|
-
if (needsWorkflowTool)
|
|
131
|
-
agentImports.add('WorkflowTool');
|
|
132
|
-
if (schema.memory)
|
|
133
|
-
agentImports.add('Memory');
|
|
134
|
-
if (schema.mcp && schema.mcp.length > 0)
|
|
135
|
-
agentImports.add('McpClient');
|
|
136
|
-
if (schema.evaluations.length > 0)
|
|
137
|
-
agentImports.add('Eval');
|
|
138
|
-
const toolsNeedZod = schema.tools.some((t) => (t.inputSchemaSource?.includes('z.') ?? false) ||
|
|
139
|
-
(t.outputSchemaSource?.includes('z.') ?? false));
|
|
140
|
-
const structuredOutputNeedsZod = schema.config.structuredOutput.schemaSource?.includes('z.') ?? false;
|
|
141
|
-
let imports = `import { ${Array.from(agentImports).sort().join(', ')} } from '@n8n/agents';`;
|
|
142
|
-
if (toolsNeedZod || structuredOutputNeedsZod)
|
|
143
|
-
imports += "\nimport { z } from 'zod';";
|
|
144
|
-
return imports;
|
|
145
|
-
}
|
|
146
|
-
async function generateAgentCode(schema, agentName) {
|
|
147
|
-
const { model, credential, instructions, description: _description, tools, providerTools, memory, evaluations, guardrails, mcp, telemetry, checkpoint, config, ...rest } = schema;
|
|
148
|
-
assertAllHandled(rest);
|
|
149
|
-
const { thinking, toolCallConcurrency, requireToolApproval, structuredOutput, ...configRest } = config;
|
|
150
|
-
assertAllHandled(configRest);
|
|
151
|
-
const parts = [];
|
|
152
|
-
let needsWorkflowTool = false;
|
|
153
|
-
parts.push(`export default new Agent('${escapeSingleQuote(agentName)}')`);
|
|
154
|
-
parts.push(...modelParts(model));
|
|
155
|
-
if (credential)
|
|
156
|
-
parts.push(`.credential('${escapeSingleQuote(credential)}')`);
|
|
157
|
-
if (instructions)
|
|
158
|
-
parts.push(`.instructions(\`${escapeTemplateLiteral(instructions)}\`)`);
|
|
159
|
-
for (const tool of tools) {
|
|
160
|
-
const { part, usesWorkflowTool } = toolPart(tool);
|
|
161
|
-
if (usesWorkflowTool)
|
|
162
|
-
needsWorkflowTool = true;
|
|
163
|
-
parts.push(part);
|
|
164
|
-
}
|
|
165
|
-
for (const pt of providerTools) {
|
|
166
|
-
parts.push(`.providerTool(${pt.source})`);
|
|
167
|
-
}
|
|
168
|
-
if (memory)
|
|
169
|
-
parts.push(memoryPart(memory));
|
|
170
|
-
for (const ev of evaluations) {
|
|
171
|
-
parts.push(evalPart(ev));
|
|
172
|
-
}
|
|
173
|
-
for (const g of guardrails) {
|
|
174
|
-
parts.push(guardrailPart(g));
|
|
175
|
-
}
|
|
176
|
-
if (mcp && mcp.length > 0) {
|
|
177
|
-
const configs = mcp.map((s) => s.configSource).join(', ');
|
|
178
|
-
parts.push(`.mcp(new McpClient([${configs}]))`);
|
|
179
|
-
}
|
|
180
|
-
if (telemetry)
|
|
181
|
-
parts.push(`.telemetry(${telemetry.source})`);
|
|
182
|
-
if (checkpoint)
|
|
183
|
-
parts.push(`.checkpoint('${escapeSingleQuote(checkpoint)}')`);
|
|
184
|
-
if (thinking)
|
|
185
|
-
parts.push(thinkingPart(thinking));
|
|
186
|
-
if (toolCallConcurrency)
|
|
187
|
-
parts.push(`.toolCallConcurrency(${toolCallConcurrency})`);
|
|
188
|
-
if (requireToolApproval)
|
|
189
|
-
parts.push('.requireToolApproval()');
|
|
190
|
-
if (structuredOutput.enabled && structuredOutput.schemaSource) {
|
|
191
|
-
parts.push(`.structuredOutput(${structuredOutput.schemaSource})`);
|
|
192
|
-
}
|
|
193
|
-
const imports = buildImports(schema, needsWorkflowTool);
|
|
194
|
-
const raw = `${imports}\n\n${parts.join('')};\n`;
|
|
195
|
-
return await formatCode(raw);
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=generate-agent-code.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-agent-code.js","sourceRoot":"","sources":["../../src/codegen/generate-ag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,IAAI,CAAC,CAAC;QAC1D,KAAK,CAAC,IAAI,CAAC,uBAAuB,OAAO,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,cAAc,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7D,IAAI,UAAU;QAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9E,IAAI,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjD,IAAI,mBAAmB;QAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,mBAAmB,GAAG,CAAC,CAAC;IACpF,IAAI,mBAAmB;QAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC9D,IAAI,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,qBAAqB,gBAAgB,CAAC,YAAY,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,GAAG,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;IACjD,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AgentBuilder } from '../types/sdk/agent-builder';
|
|
2
|
-
import type { CredentialProvider } from '../types/sdk/credential-provider';
|
|
3
|
-
import type { HandlerExecutor } from '../types/sdk/handler-executor';
|
|
4
|
-
import type { AgentSchema } from '../types/sdk/schema';
|
|
5
|
-
export interface FromSchemaOptions {
|
|
6
|
-
handlerExecutor: HandlerExecutor;
|
|
7
|
-
credentialProvider?: CredentialProvider;
|
|
8
|
-
}
|
|
9
|
-
interface SuspendResult {
|
|
10
|
-
[key: symbol]: true;
|
|
11
|
-
payload: unknown;
|
|
12
|
-
}
|
|
13
|
-
export declare function isSuspendResult(value: unknown): value is SuspendResult;
|
|
14
|
-
export declare function fromSchema(agent: AgentBuilder, schema: AgentSchema, options: FromSchemaOptions): Promise<void>;
|
|
15
|
-
export {};
|
package/dist/sdk/from-schema.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSuspendResult = isSuspendResult;
|
|
4
|
-
exports.fromSchema = fromSchema;
|
|
5
|
-
const mcp_client_1 = require("./mcp-client");
|
|
6
|
-
const memory_1 = require("./memory");
|
|
7
|
-
const tool_1 = require("./tool");
|
|
8
|
-
const SUSPEND_MARKER = Symbol.for('n8n.agent.suspend');
|
|
9
|
-
function isSuspendResult(value) {
|
|
10
|
-
return (typeof value === 'object' &&
|
|
11
|
-
value !== null &&
|
|
12
|
-
value[SUSPEND_MARKER] === true);
|
|
13
|
-
}
|
|
14
|
-
async function fromSchema(agent, schema, options) {
|
|
15
|
-
const { handlerExecutor } = options;
|
|
16
|
-
applyModel(agent, schema.model);
|
|
17
|
-
if (schema.credential !== null) {
|
|
18
|
-
agent.credential(schema.credential);
|
|
19
|
-
}
|
|
20
|
-
if (schema.instructions !== null) {
|
|
21
|
-
agent.instructions(schema.instructions);
|
|
22
|
-
}
|
|
23
|
-
await applyTools(agent, schema.tools, handlerExecutor);
|
|
24
|
-
await applyProviderTools(agent, schema.providerTools, handlerExecutor);
|
|
25
|
-
applyConfig(agent, schema.config);
|
|
26
|
-
applyMemory(agent, schema);
|
|
27
|
-
applyGuardrails(agent, schema.guardrails);
|
|
28
|
-
applyEvals(agent, schema.evaluations, handlerExecutor);
|
|
29
|
-
await applyStructuredOutput(agent, schema.config.structuredOutput, handlerExecutor);
|
|
30
|
-
if (options.credentialProvider) {
|
|
31
|
-
agent.credentialProvider(options.credentialProvider);
|
|
32
|
-
}
|
|
33
|
-
await applyMcpServers(agent, schema.mcp, handlerExecutor);
|
|
34
|
-
await applyTelemetry(agent, schema.telemetry, handlerExecutor);
|
|
35
|
-
}
|
|
36
|
-
function applyModel(agent, model) {
|
|
37
|
-
if (model.provider && model.name) {
|
|
38
|
-
agent.model(model.provider, model.name);
|
|
39
|
-
}
|
|
40
|
-
else if (model.name) {
|
|
41
|
-
agent.model(model.name);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function applyTools(agent, tools, executor) {
|
|
45
|
-
const addedTools = new Set();
|
|
46
|
-
for (const ts of tools) {
|
|
47
|
-
if (addedTools.has(ts.name)) {
|
|
48
|
-
throw new Error(`Schema has multiple definitions of tool ${ts.name}`);
|
|
49
|
-
}
|
|
50
|
-
addedTools.add(ts.name);
|
|
51
|
-
if (!ts.editable) {
|
|
52
|
-
agent.tool({
|
|
53
|
-
name: ts.name,
|
|
54
|
-
description: ts.description,
|
|
55
|
-
__workflowTool: true,
|
|
56
|
-
workflowName: ts.name,
|
|
57
|
-
});
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const schemas = {};
|
|
61
|
-
if (ts.suspendSchemaSource) {
|
|
62
|
-
schemas.suspend = await executor.evaluateSchema(ts.suspendSchemaSource);
|
|
63
|
-
}
|
|
64
|
-
if (ts.resumeSchemaSource) {
|
|
65
|
-
schemas.resume = await executor.evaluateSchema(ts.resumeSchemaSource);
|
|
66
|
-
}
|
|
67
|
-
const builtTool = buildToolFromSchema(ts, executor, schemas);
|
|
68
|
-
agent.tool(builtTool);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async function applyProviderTools(agent, providerTools, executor) {
|
|
72
|
-
for (const pt of providerTools) {
|
|
73
|
-
if (pt.source) {
|
|
74
|
-
const evaluated = (await executor.evaluateExpression(pt.source));
|
|
75
|
-
agent.providerTool({
|
|
76
|
-
name: evaluated.name,
|
|
77
|
-
args: evaluated.args ?? {},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
agent.providerTool({
|
|
82
|
-
name: pt.name,
|
|
83
|
-
args: {},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function applyConfig(agent, config) {
|
|
89
|
-
if (config.thinking !== null) {
|
|
90
|
-
const { provider, ...thinkingConfig } = config.thinking;
|
|
91
|
-
agent.thinking(provider, thinkingConfig);
|
|
92
|
-
}
|
|
93
|
-
if (config.toolCallConcurrency !== null) {
|
|
94
|
-
agent.toolCallConcurrency(config.toolCallConcurrency);
|
|
95
|
-
}
|
|
96
|
-
if (config.requireToolApproval) {
|
|
97
|
-
agent.requireToolApproval();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function applyMemory(agent, schema) {
|
|
101
|
-
if (schema.memory !== null) {
|
|
102
|
-
const memory = new memory_1.Memory();
|
|
103
|
-
if (schema.memory.lastMessages !== null) {
|
|
104
|
-
memory.lastMessages(schema.memory.lastMessages);
|
|
105
|
-
}
|
|
106
|
-
agent.memory(memory);
|
|
107
|
-
}
|
|
108
|
-
if (schema.checkpoint !== null) {
|
|
109
|
-
agent.checkpoint(schema.checkpoint);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function applyGuardrails(agent, guardrails) {
|
|
113
|
-
for (const g of guardrails) {
|
|
114
|
-
const builtGuardrail = {
|
|
115
|
-
name: g.name,
|
|
116
|
-
guardType: g.guardType,
|
|
117
|
-
strategy: g.strategy,
|
|
118
|
-
_config: g.config,
|
|
119
|
-
};
|
|
120
|
-
if (g.position === 'input') {
|
|
121
|
-
agent.inputGuardrail(builtGuardrail);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
agent.outputGuardrail(builtGuardrail);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function applyEvals(agent, evaluations, executor) {
|
|
129
|
-
for (const evalSchema of evaluations) {
|
|
130
|
-
const builtEval = buildEvalFromSchema(evalSchema, executor);
|
|
131
|
-
agent.eval(builtEval);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async function applyStructuredOutput(agent, structuredOutput, executor) {
|
|
135
|
-
if (structuredOutput.enabled && structuredOutput.schemaSource) {
|
|
136
|
-
const outputSchema = await executor.evaluateSchema(structuredOutput.schemaSource);
|
|
137
|
-
agent.structuredOutput(outputSchema);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async function applyMcpServers(agent, mcp, executor) {
|
|
141
|
-
if (!mcp || mcp.length === 0)
|
|
142
|
-
return;
|
|
143
|
-
const mcpConfigs = [];
|
|
144
|
-
for (const m of mcp) {
|
|
145
|
-
if (m.configSource) {
|
|
146
|
-
const config = (await executor.evaluateExpression(m.configSource));
|
|
147
|
-
mcpConfigs.push(config);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (mcpConfigs.length > 0) {
|
|
151
|
-
agent.mcp(new mcp_client_1.McpClient(mcpConfigs));
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
async function applyTelemetry(agent, telemetry, executor) {
|
|
155
|
-
if (telemetry?.source) {
|
|
156
|
-
const built = (await executor.evaluateExpression(telemetry.source));
|
|
157
|
-
agent.telemetry(built);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function buildToolFromSchema(toolSchema, executor, preEvaluated) {
|
|
161
|
-
const handler = async (input, ctx) => {
|
|
162
|
-
if (toolSchema.hasSuspend && 'suspend' in ctx) {
|
|
163
|
-
const interruptCtx = ctx;
|
|
164
|
-
const result = await executor.executeTool(toolSchema.name, input, {
|
|
165
|
-
resumeData: interruptCtx.resumeData,
|
|
166
|
-
parentTelemetry: ctx.parentTelemetry,
|
|
167
|
-
});
|
|
168
|
-
if (isSuspendResult(result)) {
|
|
169
|
-
return await interruptCtx.suspend(result.payload);
|
|
170
|
-
}
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
return await executor.executeTool(toolSchema.name, input, {
|
|
174
|
-
parentTelemetry: ctx.parentTelemetry,
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
let toMessage;
|
|
178
|
-
if (toolSchema.hasToMessage) {
|
|
179
|
-
if (executor.executeToMessageSync) {
|
|
180
|
-
const syncExecutor = executor.executeToMessageSync.bind(executor);
|
|
181
|
-
toMessage = (output) => {
|
|
182
|
-
return syncExecutor(toolSchema.name, output);
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
throw new Error('Executor does not support executeToMessageSync');
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const built = {
|
|
190
|
-
name: toolSchema.name,
|
|
191
|
-
description: toolSchema.description,
|
|
192
|
-
inputSchema: toolSchema.inputSchema ?? undefined,
|
|
193
|
-
handler,
|
|
194
|
-
toMessage,
|
|
195
|
-
suspendSchema: preEvaluated?.suspend,
|
|
196
|
-
resumeSchema: preEvaluated?.resume,
|
|
197
|
-
providerOptions: toolSchema.providerOptions
|
|
198
|
-
? toolSchema.providerOptions
|
|
199
|
-
: undefined,
|
|
200
|
-
};
|
|
201
|
-
if (toolSchema.requireApproval) {
|
|
202
|
-
return (0, tool_1.wrapToolForApproval)(built, { requireApproval: true });
|
|
203
|
-
}
|
|
204
|
-
return built;
|
|
205
|
-
}
|
|
206
|
-
function buildEvalFromSchema(evalSchema, executor) {
|
|
207
|
-
return {
|
|
208
|
-
name: evalSchema.name,
|
|
209
|
-
description: evalSchema.description ?? undefined,
|
|
210
|
-
evalType: evalSchema.type,
|
|
211
|
-
modelId: evalSchema.modelId ?? null,
|
|
212
|
-
credentialName: evalSchema.credentialName ?? null,
|
|
213
|
-
_run: async (evalInput) => {
|
|
214
|
-
return await executor.executeEval(evalSchema.name, evalInput);
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
//# sourceMappingURL=from-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":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ACH,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
-
export interface AgentSchema {
|
|
3
|
-
model: {
|
|
4
|
-
provider: string | null;
|
|
5
|
-
name: string | null;
|
|
6
|
-
raw?: string;
|
|
7
|
-
};
|
|
8
|
-
credential: string | null;
|
|
9
|
-
instructions: string | null;
|
|
10
|
-
description: string | null;
|
|
11
|
-
tools: ToolSchema[];
|
|
12
|
-
providerTools: ProviderToolSchema[];
|
|
13
|
-
memory: MemorySchema | null;
|
|
14
|
-
evaluations: EvalSchema[];
|
|
15
|
-
guardrails: GuardrailSchema[];
|
|
16
|
-
mcp: McpServerSchema[] | null;
|
|
17
|
-
telemetry: TelemetrySchema | null;
|
|
18
|
-
checkpoint: 'memory' | null;
|
|
19
|
-
config: {
|
|
20
|
-
structuredOutput: {
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
schemaSource: string | null;
|
|
23
|
-
};
|
|
24
|
-
thinking: ThinkingSchema | null;
|
|
25
|
-
toolCallConcurrency: number | null;
|
|
26
|
-
requireToolApproval: boolean;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface ToolSchema {
|
|
30
|
-
name: string;
|
|
31
|
-
description: string;
|
|
32
|
-
type: 'custom' | 'workflow' | 'provider' | 'mcp';
|
|
33
|
-
editable: boolean;
|
|
34
|
-
inputSchemaSource: string | null;
|
|
35
|
-
outputSchemaSource: string | null;
|
|
36
|
-
handlerSource: string | null;
|
|
37
|
-
suspendSchemaSource: string | null;
|
|
38
|
-
resumeSchemaSource: string | null;
|
|
39
|
-
toMessageSource: string | null;
|
|
40
|
-
requireApproval: boolean;
|
|
41
|
-
needsApprovalFnSource: string | null;
|
|
42
|
-
providerOptions: Record<string, unknown> | null;
|
|
43
|
-
inputSchema: JSONSchema7 | null;
|
|
44
|
-
outputSchema: JSONSchema7 | null;
|
|
45
|
-
hasSuspend: boolean;
|
|
46
|
-
hasResume: boolean;
|
|
47
|
-
hasToMessage: boolean;
|
|
48
|
-
}
|
|
49
|
-
export interface ProviderToolSchema {
|
|
50
|
-
name: string;
|
|
51
|
-
source: string;
|
|
52
|
-
}
|
|
53
|
-
export interface MemorySchema {
|
|
54
|
-
source: string | null;
|
|
55
|
-
storage: 'memory' | 'custom';
|
|
56
|
-
lastMessages: number | null;
|
|
57
|
-
semanticRecall: {
|
|
58
|
-
topK: number;
|
|
59
|
-
messageRange: {
|
|
60
|
-
before: number;
|
|
61
|
-
after: number;
|
|
62
|
-
} | null;
|
|
63
|
-
embedder: string | null;
|
|
64
|
-
} | null;
|
|
65
|
-
workingMemory: {
|
|
66
|
-
type: 'structured' | 'freeform';
|
|
67
|
-
schema?: JSONSchema7;
|
|
68
|
-
template?: string;
|
|
69
|
-
} | null;
|
|
70
|
-
}
|
|
71
|
-
export interface EvalSchema {
|
|
72
|
-
name: string;
|
|
73
|
-
description: string | null;
|
|
74
|
-
type: 'check' | 'judge';
|
|
75
|
-
modelId: string | null;
|
|
76
|
-
credentialName: string | null;
|
|
77
|
-
hasCredential: boolean;
|
|
78
|
-
handlerSource: string | null;
|
|
79
|
-
}
|
|
80
|
-
export interface GuardrailSchema {
|
|
81
|
-
name: string;
|
|
82
|
-
guardType: 'pii' | 'prompt-injection' | 'moderation' | 'custom';
|
|
83
|
-
strategy: 'block' | 'redact' | 'warn';
|
|
84
|
-
position: 'input' | 'output';
|
|
85
|
-
config: Record<string, unknown>;
|
|
86
|
-
source: string;
|
|
87
|
-
}
|
|
88
|
-
export interface McpServerSchema {
|
|
89
|
-
name: string;
|
|
90
|
-
configSource: string;
|
|
91
|
-
}
|
|
92
|
-
export interface TelemetrySchema {
|
|
93
|
-
source: string;
|
|
94
|
-
}
|
|
95
|
-
export interface ThinkingSchema {
|
|
96
|
-
provider: 'anthropic' | 'openai';
|
|
97
|
-
budgetTokens?: number;
|
|
98
|
-
reasoningEffort?: string;
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/types/sdk/schema.ts"],"names":[],"mappings":""}
|