@n8n/agents 0.26.3 → 0.27.1
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/runtime/loop/agent-runtime.d.ts +24 -51
- package/dist/runtime/loop/agent-runtime.js +321 -318
- package/dist/runtime/loop/agent-runtime.js.map +1 -1
- package/dist/runtime/loop/checkpoint-data.d.ts +12 -0
- package/dist/runtime/loop/checkpoint-data.js +65 -0
- package/dist/runtime/loop/checkpoint-data.js.map +1 -0
- package/dist/runtime/loop/execution-counter.js +1 -5
- package/dist/runtime/loop/execution-counter.js.map +1 -1
- package/dist/runtime/loop/generate-sink.d.ts +2 -2
- package/dist/runtime/loop/generate-sink.js +3 -5
- package/dist/runtime/loop/generate-sink.js.map +1 -1
- package/dist/runtime/loop/run-output-sink.d.ts +3 -78
- package/dist/runtime/loop/run-output-sink.js +7 -0
- package/dist/runtime/loop/run-output-sink.js.map +1 -1
- package/dist/runtime/loop/runtime-context.d.ts +17 -1
- package/dist/runtime/loop/runtime-context.js +49 -20
- package/dist/runtime/loop/runtime-context.js.map +1 -1
- package/dist/runtime/loop/runtime-helpers.d.ts +1 -1
- package/dist/runtime/loop/stream-sink.d.ts +9 -2
- package/dist/runtime/loop/stream-sink.js +78 -56
- package/dist/runtime/loop/stream-sink.js.map +1 -1
- package/dist/runtime/memory/memory-orchestrator.d.ts +1 -1
- package/dist/runtime/memory/memory-orchestrator.js +8 -8
- package/dist/runtime/memory/memory-orchestrator.js.map +1 -1
- package/dist/runtime/memory/memory-store.d.ts +1 -1
- package/dist/runtime/memory/memory-store.js +7 -2
- package/dist/runtime/memory/memory-store.js.map +1 -1
- package/dist/runtime/memory/tool-result-memory.d.ts +7 -0
- package/dist/runtime/memory/tool-result-memory.js +65 -0
- package/dist/runtime/memory/tool-result-memory.js.map +1 -0
- package/dist/runtime/model/messages.js +20 -9
- package/dist/runtime/model/messages.js.map +1 -1
- package/dist/runtime/model/raw-error.d.ts +1 -1
- package/dist/runtime/state/run-state.d.ts +2 -2
- package/dist/runtime/state/run-state.js +4 -4
- package/dist/runtime/state/run-state.js.map +1 -1
- package/dist/runtime/telemetry/runtime-telemetry.d.ts +1 -1
- package/dist/runtime/tools/delegate-sub-agent-runner.d.ts +13 -0
- package/dist/runtime/tools/delegate-sub-agent-runner.js +361 -0
- package/dist/runtime/tools/delegate-sub-agent-runner.js.map +1 -0
- package/dist/runtime/tools/delegate-sub-agent-tool.d.ts +5 -241
- package/dist/runtime/tools/delegate-sub-agent-tool.js +94 -487
- package/dist/runtime/tools/delegate-sub-agent-tool.js.map +1 -1
- package/dist/runtime/tools/tool-adapter.js +28 -28
- package/dist/runtime/tools/tool-adapter.js.map +1 -1
- package/dist/runtime/tools/tool-call-executor.d.ts +19 -86
- package/dist/runtime/tools/tool-call-executor.js +236 -579
- package/dist/runtime/tools/tool-call-executor.js.map +1 -1
- package/dist/runtime/tools/tool-call-runner.d.ts +25 -0
- package/dist/runtime/tools/tool-call-runner.js +328 -0
- package/dist/runtime/tools/tool-call-runner.js.map +1 -0
- package/dist/runtime/tools/tool-result-guard.d.ts +2 -7
- package/dist/runtime/tools/tool-result-guard.js +13 -70
- package/dist/runtime/tools/tool-result-guard.js.map +1 -1
- package/dist/types/runtime/agent-loop.d.ts +73 -0
- package/dist/types/runtime/agent-loop.js +3 -0
- package/dist/types/runtime/agent-loop.js.map +1 -0
- package/dist/types/runtime/agent-runtime.d.ts +51 -0
- package/dist/types/runtime/agent-runtime.js +3 -0
- package/dist/types/runtime/agent-runtime.js.map +1 -0
- package/dist/types/runtime/delegation.d.ts +234 -0
- package/dist/types/runtime/delegation.js +82 -0
- package/dist/types/runtime/delegation.js.map +1 -0
- package/dist/types/runtime/tool-execution.d.ts +103 -0
- package/dist/types/runtime/tool-execution.js +3 -0
- package/dist/types/runtime/tool-execution.js.map +1 -0
- package/dist/types/sdk/agent-builder.d.ts +1 -1
- package/dist/types/sdk/memory.d.ts +2 -1
- package/package.json +6 -6
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { LanguageModel, LanguageModelCallOptions, ModelMessage, Output, SystemModelMessage, TelemetryOptions, ToolCallRepairFunction, ToolSet } from 'ai';
|
|
2
|
+
import type { FinishReason, SerializableAgentState, TokenUsage } from '../index';
|
|
3
|
+
import type { ExecutionOptions, RunOptions } from '../sdk/agent';
|
|
4
|
+
import type { AgentMessage } from '../sdk/message';
|
|
5
|
+
import type { JSONObject } from '../utils/json';
|
|
6
|
+
import type { AgentMessageList } from '../../runtime/model/message-list';
|
|
7
|
+
import type { ToolCallBatchResult, ToolCallInput, ToolCallSuspension } from './tool-execution';
|
|
8
|
+
type RunCallOptions = (RunOptions & ExecutionOptions) | undefined;
|
|
9
|
+
export type ModelTurnErrorType = 'prompt_blocked' | 'no_output';
|
|
10
|
+
export interface ModelTurnError {
|
|
11
|
+
type: ModelTurnErrorType;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ModelTurnResult {
|
|
15
|
+
aiFinishReason: string;
|
|
16
|
+
finishReason: FinishReason;
|
|
17
|
+
usage: TokenUsage | undefined;
|
|
18
|
+
newMessages: AgentMessage[];
|
|
19
|
+
toolCalls: ToolCallInput[];
|
|
20
|
+
structuredOutput: unknown;
|
|
21
|
+
errorReason?: ModelTurnError;
|
|
22
|
+
}
|
|
23
|
+
export interface ModelCallContext {
|
|
24
|
+
model: LanguageModel;
|
|
25
|
+
system: SystemModelMessage | SystemModelMessage[];
|
|
26
|
+
messages: ModelMessage[];
|
|
27
|
+
abortSignal: AbortSignal;
|
|
28
|
+
hasTools: boolean;
|
|
29
|
+
aiTools: ToolSet;
|
|
30
|
+
reasoning?: LanguageModelCallOptions['reasoning'];
|
|
31
|
+
providerOptions?: Record<string, JSONObject>;
|
|
32
|
+
outputSpec?: ReturnType<typeof Output.object>;
|
|
33
|
+
maxOutputTokens?: number;
|
|
34
|
+
onInputRejected?: (error: unknown) => Promise<void>;
|
|
35
|
+
aiSdkOptions: {
|
|
36
|
+
telemetry?: TelemetryOptions;
|
|
37
|
+
repairToolCall?: ToolCallRepairFunction<NoInfer<ToolSet>>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface SuspendEmission {
|
|
41
|
+
suspendRunId: string;
|
|
42
|
+
list: AgentMessageList;
|
|
43
|
+
usage: TokenUsage | undefined;
|
|
44
|
+
suspensions: ToolCallSuspension[];
|
|
45
|
+
}
|
|
46
|
+
export interface CompleteEmission {
|
|
47
|
+
list: AgentMessageList;
|
|
48
|
+
options: RunCallOptions;
|
|
49
|
+
finishReason: FinishReason;
|
|
50
|
+
usage: TokenUsage | undefined;
|
|
51
|
+
structuredOutput: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface RunServices {
|
|
54
|
+
readonly runId: string;
|
|
55
|
+
readonly modelId: string;
|
|
56
|
+
applyCost(usage: TokenUsage | undefined): TokenUsage | undefined;
|
|
57
|
+
saveToMemory(list: AgentMessageList, options: RunCallOptions): Promise<void>;
|
|
58
|
+
maybeGenerateTitle(list: AgentMessageList, options: RunCallOptions): Promise<void>;
|
|
59
|
+
flushTelemetry(options: RunCallOptions): Promise<void>;
|
|
60
|
+
cleanupRun(): Promise<void>;
|
|
61
|
+
updateState(patch: Partial<SerializableAgentState>): void;
|
|
62
|
+
emitAgentEnd(messages: AgentMessage[]): void;
|
|
63
|
+
getState(): SerializableAgentState;
|
|
64
|
+
}
|
|
65
|
+
export interface RunOutputSink<TResult> {
|
|
66
|
+
callModel(ctx: ModelCallContext): Promise<ModelTurnResult>;
|
|
67
|
+
reportUsage(usage: TokenUsage | undefined): void;
|
|
68
|
+
onTurnFolded?(): void;
|
|
69
|
+
emitToolBatch(batch: ToolCallBatchResult): Promise<void>;
|
|
70
|
+
finishSuspended(emission: SuspendEmission): Promise<TResult>;
|
|
71
|
+
finishComplete(emission: CompleteEmission): Promise<TResult>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-loop.js","sourceRoot":"","sources":["../../../src/types/runtime/agent-loop.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ProviderOptions } from '@ai-sdk/provider-utils';
|
|
2
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import type { FetchFn } from '../../runtime/model/model-factory';
|
|
5
|
+
import type { ScopedMemoryTaskEvent } from '../../runtime/memory/scoped-memory-task-runner';
|
|
6
|
+
import type { AgentEventBus } from '../../runtime/state/event-bus';
|
|
7
|
+
import type { RunStateManager } from '../../runtime/state/run-state';
|
|
8
|
+
import type { ModelCost } from '../../sdk/catalog';
|
|
9
|
+
import type { RuntimeSkillSource } from '../../skills/types';
|
|
10
|
+
import type { WorkspaceFilesystem } from '../../workspace';
|
|
11
|
+
import type { BuiltFileStore, BuiltMemory, BuiltProviderTool, BuiltTelemetry, BuiltTool, CheckpointStore, EpisodicMemoryConfig, McpConnectionFailedEvent, ObservationalMemoryConfig, ObservationLogMemoryConfig, ReasoningLevel, ThinkingConfig, TitleGenerationConfig } from '../index';
|
|
12
|
+
import type { AgentPersistenceOptions, ModelConfig, PromptCachingConfig } from '../sdk/agent';
|
|
13
|
+
export interface VolatileInstructionsContext {
|
|
14
|
+
persistence?: AgentPersistenceOptions;
|
|
15
|
+
}
|
|
16
|
+
export type VolatileInstructionsProvider = (context: VolatileInstructionsContext) => Promise<string | undefined>;
|
|
17
|
+
export interface AgentRuntimeConfig {
|
|
18
|
+
name: string;
|
|
19
|
+
model: ModelConfig;
|
|
20
|
+
modelFetch?: FetchFn;
|
|
21
|
+
instructions: string;
|
|
22
|
+
skillSource?: RuntimeSkillSource;
|
|
23
|
+
instructionProviderOptions?: ProviderOptions;
|
|
24
|
+
tools?: BuiltTool[];
|
|
25
|
+
deferredTools?: BuiltTool[];
|
|
26
|
+
workspaceFilesystem?: WorkspaceFilesystem;
|
|
27
|
+
toolSearch?: {
|
|
28
|
+
topK?: number;
|
|
29
|
+
};
|
|
30
|
+
providerTools?: BuiltProviderTool[];
|
|
31
|
+
memory?: BuiltMemory;
|
|
32
|
+
fileStore?: BuiltFileStore;
|
|
33
|
+
observationLog?: ObservationLogMemoryConfig;
|
|
34
|
+
observationalMemory?: ObservationalMemoryConfig;
|
|
35
|
+
episodicMemory?: EpisodicMemoryConfig;
|
|
36
|
+
structuredOutput?: z.ZodType | JSONSchema7;
|
|
37
|
+
checkpointStorage?: 'memory' | CheckpointStore;
|
|
38
|
+
thinking?: ThinkingConfig;
|
|
39
|
+
reasoning?: ReasoningLevel;
|
|
40
|
+
promptCaching?: PromptCachingConfig;
|
|
41
|
+
eventBus?: AgentEventBus;
|
|
42
|
+
toolCallConcurrency?: number;
|
|
43
|
+
titleGeneration?: TitleGenerationConfig;
|
|
44
|
+
telemetry?: BuiltTelemetry;
|
|
45
|
+
runId?: string;
|
|
46
|
+
modelCost?: ModelCost;
|
|
47
|
+
runState?: RunStateManager;
|
|
48
|
+
onMemoryTaskEvent?: (event: ScopedMemoryTaskEvent) => void;
|
|
49
|
+
mcpConnectionFailures?: McpConnectionFailedEvent[];
|
|
50
|
+
volatileInstructionsProvider?: VolatileInstructionsProvider;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runtime.js","sourceRoot":"","sources":["../../../src/types/runtime/agent-runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { SubAgentTaskPath, SubAgentTaskPathPolicy } from '../../runtime/tools/sub-agent-task-path';
|
|
3
|
+
import type { AgentExecutionCounter, FinishReason, GenerateResult, ModelConfig, StreamChunk, TokenUsage } from '../sdk/agent';
|
|
4
|
+
import type { BuiltProviderTool } from '../sdk/tool';
|
|
5
|
+
import type { BuiltTelemetry } from '../telemetry';
|
|
6
|
+
import type { JSONObject, JSONValue } from '../utils/json';
|
|
7
|
+
export declare const DELEGATE_SUB_AGENT_TOOL_NAME = "delegate_subagent";
|
|
8
|
+
export declare const INLINE_SUB_AGENT_ID = "inline";
|
|
9
|
+
export declare const DELEGATED_CHILD_SUSPEND_UNSUPPORTED_MESSAGE = "agents.chat.delegate.childSuspendUnsupported";
|
|
10
|
+
export declare const INLINE_DELEGATE_SUB_AGENT_TOOL_METADATA_KEY = "inlineDelegateSubAgent";
|
|
11
|
+
export declare const SUB_AGENT_TASK_DIFFICULTIES: readonly ['low', 'medium', 'high'];
|
|
12
|
+
declare const SubAgentTaskDifficultySchema: z.ZodEnum<["low", "medium", "high"]>;
|
|
13
|
+
export type SubAgentTaskDifficulty = z.infer<typeof SubAgentTaskDifficultySchema>;
|
|
14
|
+
export declare const delegateSubAgentInputSchema: z.ZodObject<{
|
|
15
|
+
subAgentId: z.ZodString;
|
|
16
|
+
taskName: z.ZodString;
|
|
17
|
+
goal: z.ZodString;
|
|
18
|
+
context: z.ZodOptional<z.ZodString>;
|
|
19
|
+
expectedOutput: z.ZodOptional<z.ZodString>;
|
|
20
|
+
difficulty: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
subAgentId: string;
|
|
23
|
+
taskName: string;
|
|
24
|
+
goal: string;
|
|
25
|
+
context?: string | undefined;
|
|
26
|
+
expectedOutput?: string | undefined;
|
|
27
|
+
difficulty?: "high" | "low" | "medium" | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
subAgentId: string;
|
|
30
|
+
taskName: string;
|
|
31
|
+
goal: string;
|
|
32
|
+
context?: string | undefined;
|
|
33
|
+
expectedOutput?: string | undefined;
|
|
34
|
+
difficulty?: "high" | "low" | "medium" | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const delegateSubAgentOutputSchema: z.ZodObject<{
|
|
37
|
+
status: z.ZodEnum<["completed", "failed", "suspended", "cancelled"]>;
|
|
38
|
+
taskPath: z.ZodOptional<z.ZodString>;
|
|
39
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
model: z.ZodOptional<z.ZodString>;
|
|
42
|
+
answer: z.ZodString;
|
|
43
|
+
structuredOutput: z.ZodOptional<z.ZodUnknown>;
|
|
44
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
promptTokens: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
completionTokens: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
promptTokens?: number | undefined;
|
|
51
|
+
completionTokens?: number | undefined;
|
|
52
|
+
totalTokens?: number | undefined;
|
|
53
|
+
cost?: number | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
promptTokens?: number | undefined;
|
|
56
|
+
completionTokens?: number | undefined;
|
|
57
|
+
totalTokens?: number | undefined;
|
|
58
|
+
cost?: number | undefined;
|
|
59
|
+
}>>;
|
|
60
|
+
finishReason: z.ZodOptional<z.ZodString>;
|
|
61
|
+
error: z.ZodOptional<z.ZodString>;
|
|
62
|
+
resumeContext: z.ZodOptional<z.ZodType<JSONValue, z.ZodTypeDef, JSONValue>>;
|
|
63
|
+
pendingSuspend: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
|
+
runId: z.ZodString;
|
|
65
|
+
toolCallId: z.ZodString;
|
|
66
|
+
toolName: z.ZodString;
|
|
67
|
+
input: z.ZodUnknown;
|
|
68
|
+
suspendPayload: z.ZodUnknown;
|
|
69
|
+
resumeSchema: z.ZodOptional<z.ZodUnknown>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
runId: string;
|
|
72
|
+
toolCallId: string;
|
|
73
|
+
toolName: string;
|
|
74
|
+
input?: unknown;
|
|
75
|
+
suspendPayload?: unknown;
|
|
76
|
+
resumeSchema?: unknown;
|
|
77
|
+
}, {
|
|
78
|
+
runId: string;
|
|
79
|
+
toolCallId: string;
|
|
80
|
+
toolName: string;
|
|
81
|
+
input?: unknown;
|
|
82
|
+
suspendPayload?: unknown;
|
|
83
|
+
resumeSchema?: unknown;
|
|
84
|
+
}>, "many">>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
status: "cancelled" | "completed" | "failed" | "suspended";
|
|
87
|
+
taskPath?: string | undefined;
|
|
88
|
+
runId?: string | undefined;
|
|
89
|
+
threadId?: string | undefined;
|
|
90
|
+
model?: string | undefined;
|
|
91
|
+
answer: string;
|
|
92
|
+
structuredOutput?: unknown;
|
|
93
|
+
usage?: {
|
|
94
|
+
promptTokens?: number | undefined;
|
|
95
|
+
completionTokens?: number | undefined;
|
|
96
|
+
totalTokens?: number | undefined;
|
|
97
|
+
cost?: number | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
finishReason?: string | undefined;
|
|
100
|
+
error?: string | undefined;
|
|
101
|
+
resumeContext?: JSONValue | undefined;
|
|
102
|
+
pendingSuspend?: {
|
|
103
|
+
runId: string;
|
|
104
|
+
toolCallId: string;
|
|
105
|
+
toolName: string;
|
|
106
|
+
input?: unknown;
|
|
107
|
+
suspendPayload?: unknown;
|
|
108
|
+
resumeSchema?: unknown;
|
|
109
|
+
}[] | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
status: "cancelled" | "completed" | "failed" | "suspended";
|
|
112
|
+
taskPath?: string | undefined;
|
|
113
|
+
runId?: string | undefined;
|
|
114
|
+
threadId?: string | undefined;
|
|
115
|
+
model?: string | undefined;
|
|
116
|
+
answer: string;
|
|
117
|
+
structuredOutput?: unknown;
|
|
118
|
+
usage?: {
|
|
119
|
+
promptTokens?: number | undefined;
|
|
120
|
+
completionTokens?: number | undefined;
|
|
121
|
+
totalTokens?: number | undefined;
|
|
122
|
+
cost?: number | undefined;
|
|
123
|
+
} | undefined;
|
|
124
|
+
finishReason?: string | undefined;
|
|
125
|
+
error?: string | undefined;
|
|
126
|
+
resumeContext?: JSONValue | undefined;
|
|
127
|
+
pendingSuspend?: {
|
|
128
|
+
runId: string;
|
|
129
|
+
toolCallId: string;
|
|
130
|
+
toolName: string;
|
|
131
|
+
input?: unknown;
|
|
132
|
+
suspendPayload?: unknown;
|
|
133
|
+
resumeSchema?: unknown;
|
|
134
|
+
}[] | undefined;
|
|
135
|
+
}>;
|
|
136
|
+
declare const delegateSubAgentContinuationSchema: z.ZodObject<{
|
|
137
|
+
runId: z.ZodString;
|
|
138
|
+
toolCallId: z.ZodString;
|
|
139
|
+
taskPath: z.ZodString;
|
|
140
|
+
subAgentId: z.ZodString;
|
|
141
|
+
childCount: z.ZodNumber;
|
|
142
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
143
|
+
resumeContext: z.ZodOptional<z.ZodType<JSONValue, z.ZodTypeDef, JSONValue>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
runId: string;
|
|
146
|
+
toolCallId: string;
|
|
147
|
+
taskPath: string;
|
|
148
|
+
subAgentId: string;
|
|
149
|
+
childCount: number;
|
|
150
|
+
threadId?: string | undefined;
|
|
151
|
+
resumeContext?: JSONValue | undefined;
|
|
152
|
+
}, {
|
|
153
|
+
runId: string;
|
|
154
|
+
toolCallId: string;
|
|
155
|
+
taskPath: string;
|
|
156
|
+
subAgentId: string;
|
|
157
|
+
childCount: number;
|
|
158
|
+
threadId?: string | undefined;
|
|
159
|
+
resumeContext?: JSONValue | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
export declare const delegateSubAgentSuspendSchema: z.ZodUnknown;
|
|
162
|
+
export declare const delegateSubAgentResumeSchema: z.ZodUnknown;
|
|
163
|
+
export type DelegateSubAgentContinuation = z.infer<typeof delegateSubAgentContinuationSchema>;
|
|
164
|
+
export declare function parseDelegateSubAgentContinuation(value: unknown): DelegateSubAgentContinuation | undefined;
|
|
165
|
+
export type DelegateSubAgentInput = z.infer<typeof delegateSubAgentInputSchema>;
|
|
166
|
+
export type DelegateSubAgentPolicy = SubAgentTaskPathPolicy;
|
|
167
|
+
export interface DelegateSubAgentRequest extends DelegateSubAgentInput {
|
|
168
|
+
taskPath: SubAgentTaskPath;
|
|
169
|
+
parentRunId?: string;
|
|
170
|
+
parentThreadId?: string;
|
|
171
|
+
parentResourceId?: string;
|
|
172
|
+
parentHostMetadata?: JSONObject;
|
|
173
|
+
parentToolCallId?: string;
|
|
174
|
+
parentAbortSignal?: AbortSignal;
|
|
175
|
+
parentExecutionCounter?: AgentExecutionCounter;
|
|
176
|
+
parentTelemetry?: BuiltTelemetry;
|
|
177
|
+
childCount: number;
|
|
178
|
+
policy?: DelegateSubAgentPolicy;
|
|
179
|
+
}
|
|
180
|
+
export interface DelegateSubAgentToolOutput {
|
|
181
|
+
status: 'completed' | 'failed' | 'suspended' | 'cancelled';
|
|
182
|
+
taskPath?: SubAgentTaskPath;
|
|
183
|
+
runId?: string;
|
|
184
|
+
threadId?: string;
|
|
185
|
+
model?: string;
|
|
186
|
+
answer: string;
|
|
187
|
+
structuredOutput?: unknown;
|
|
188
|
+
usage?: Pick<TokenUsage, 'promptTokens' | 'completionTokens' | 'totalTokens' | 'cost'>;
|
|
189
|
+
finishReason?: FinishReason;
|
|
190
|
+
error?: string;
|
|
191
|
+
resumeContext?: JSONValue;
|
|
192
|
+
pendingSuspend?: GenerateResult['pendingSuspend'];
|
|
193
|
+
}
|
|
194
|
+
export interface DelegateSubAgentRunnerHelpers {
|
|
195
|
+
runInlineSubAgent: (request: DelegateSubAgentRequest) => Promise<DelegateSubAgentToolOutput>;
|
|
196
|
+
emitChunk: (chunk: StreamChunk) => void;
|
|
197
|
+
}
|
|
198
|
+
export type InlineSubAgentProviderToolsResolver = (modelConfig: ModelConfig) => BuiltProviderTool[] | Promise<BuiltProviderTool[]>;
|
|
199
|
+
export type DelegateSubAgentRunner = (request: DelegateSubAgentRequest, helpers: DelegateSubAgentRunnerHelpers) => Promise<DelegateSubAgentToolOutput>;
|
|
200
|
+
export interface DelegateSubAgentCheckpointTarget {
|
|
201
|
+
childRunId: string;
|
|
202
|
+
childToolCallId: string;
|
|
203
|
+
childThreadId?: string;
|
|
204
|
+
resumeContext?: JSONValue;
|
|
205
|
+
}
|
|
206
|
+
export interface DelegateSubAgentResumeRequest extends DelegateSubAgentRequest, DelegateSubAgentCheckpointTarget {
|
|
207
|
+
resumeData: unknown;
|
|
208
|
+
}
|
|
209
|
+
export type DelegateSubAgentResumeRunner = (request: DelegateSubAgentResumeRequest, helpers: DelegateSubAgentRunnerHelpers) => Promise<DelegateSubAgentToolOutput>;
|
|
210
|
+
export interface DelegateSubAgentCancelRequest extends DelegateSubAgentRequest, DelegateSubAgentCheckpointTarget {
|
|
211
|
+
reason: string;
|
|
212
|
+
}
|
|
213
|
+
export type DelegateSubAgentCancelRunner = (request: DelegateSubAgentCancelRequest, helpers: DelegateSubAgentRunnerHelpers) => Promise<void>;
|
|
214
|
+
export interface CreateDelegateSubAgentToolOptions {
|
|
215
|
+
name?: string;
|
|
216
|
+
description?: string | null;
|
|
217
|
+
systemInstruction?: string | null;
|
|
218
|
+
availableSubAgents?: Array<{
|
|
219
|
+
id: string;
|
|
220
|
+
name: string;
|
|
221
|
+
useWhen?: string;
|
|
222
|
+
}>;
|
|
223
|
+
policy?: DelegateSubAgentPolicy;
|
|
224
|
+
inlineSubAgentBlockedTools?: string[];
|
|
225
|
+
inlineSubAgentModelsByDifficulty?: Partial<Record<SubAgentTaskDifficulty, ModelConfig>>;
|
|
226
|
+
resolveInlineSubAgentProviderTools?: InlineSubAgentProviderToolsResolver;
|
|
227
|
+
runSubAgent?: DelegateSubAgentRunner;
|
|
228
|
+
resumeSubAgent?: DelegateSubAgentResumeRunner;
|
|
229
|
+
shouldRetrySubAgentResumeError?: (error: unknown) => boolean;
|
|
230
|
+
cancelSubAgent?: DelegateSubAgentCancelRunner;
|
|
231
|
+
toModelOutput?: (output: z.infer<typeof delegateSubAgentOutputSchema>) => unknown;
|
|
232
|
+
}
|
|
233
|
+
export type DelegateSubAgentToolMetadata = CreateDelegateSubAgentToolOptions;
|
|
234
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delegateSubAgentResumeSchema = exports.delegateSubAgentSuspendSchema = exports.delegateSubAgentOutputSchema = exports.delegateSubAgentInputSchema = exports.SUB_AGENT_TASK_DIFFICULTIES = exports.INLINE_DELEGATE_SUB_AGENT_TOOL_METADATA_KEY = exports.DELEGATED_CHILD_SUSPEND_UNSUPPORTED_MESSAGE = exports.INLINE_SUB_AGENT_ID = exports.DELEGATE_SUB_AGENT_TOOL_NAME = void 0;
|
|
4
|
+
exports.parseDelegateSubAgentContinuation = parseDelegateSubAgentContinuation;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
exports.DELEGATE_SUB_AGENT_TOOL_NAME = 'delegate_subagent';
|
|
7
|
+
exports.INLINE_SUB_AGENT_ID = 'inline';
|
|
8
|
+
exports.DELEGATED_CHILD_SUSPEND_UNSUPPORTED_MESSAGE = 'agents.chat.delegate.childSuspendUnsupported';
|
|
9
|
+
exports.INLINE_DELEGATE_SUB_AGENT_TOOL_METADATA_KEY = 'inlineDelegateSubAgent';
|
|
10
|
+
exports.SUB_AGENT_TASK_DIFFICULTIES = ['low', 'medium', 'high'];
|
|
11
|
+
const SubAgentTaskDifficultySchema = zod_1.z.enum(exports.SUB_AGENT_TASK_DIFFICULTIES);
|
|
12
|
+
const jsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
13
|
+
zod_1.z.string(),
|
|
14
|
+
zod_1.z.number(),
|
|
15
|
+
zod_1.z.boolean(),
|
|
16
|
+
zod_1.z.null(),
|
|
17
|
+
zod_1.z.array(jsonValueSchema),
|
|
18
|
+
zod_1.z.record(zod_1.z.string(), jsonValueSchema),
|
|
19
|
+
]));
|
|
20
|
+
exports.delegateSubAgentInputSchema = zod_1.z.object({
|
|
21
|
+
subAgentId: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.min(1)
|
|
24
|
+
.describe('Required. Use "inline" for a one-off inline sub-agent. Use an exact configured sub-agent ID only when one is listed and fits the task.'),
|
|
25
|
+
taskName: zod_1.z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1)
|
|
28
|
+
.describe('Short human-readable name for this delegated task, e.g. "research_api".'),
|
|
29
|
+
goal: zod_1.z.string().min(1).describe('The concrete goal the sub-agent should accomplish.'),
|
|
30
|
+
context: zod_1.z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('All details the child needs, since it sees nothing else: constraints, paths, data, prior decisions, acceptance criteria, and what you have already tried or ruled out.'),
|
|
34
|
+
expectedOutput: zod_1.z.string().optional().describe('The expected shape or contents of the answer.'),
|
|
35
|
+
difficulty: SubAgentTaskDifficultySchema.optional().describe('Optional difficulty estimate for this delegated task. Use low for simple bounded work, medium for moderate analysis or implementation, and high for complex research, architecture, or multi-step reasoning.'),
|
|
36
|
+
});
|
|
37
|
+
exports.delegateSubAgentOutputSchema = zod_1.z.object({
|
|
38
|
+
status: zod_1.z.enum(['completed', 'failed', 'suspended', 'cancelled']),
|
|
39
|
+
taskPath: zod_1.z.string().optional(),
|
|
40
|
+
runId: zod_1.z.string().optional(),
|
|
41
|
+
threadId: zod_1.z.string().optional(),
|
|
42
|
+
model: zod_1.z.string().optional(),
|
|
43
|
+
answer: zod_1.z.string(),
|
|
44
|
+
structuredOutput: zod_1.z.unknown().optional(),
|
|
45
|
+
usage: zod_1.z
|
|
46
|
+
.object({
|
|
47
|
+
promptTokens: zod_1.z.number().optional(),
|
|
48
|
+
completionTokens: zod_1.z.number().optional(),
|
|
49
|
+
totalTokens: zod_1.z.number().optional(),
|
|
50
|
+
cost: zod_1.z.number().optional(),
|
|
51
|
+
})
|
|
52
|
+
.optional(),
|
|
53
|
+
finishReason: zod_1.z.string().optional(),
|
|
54
|
+
error: zod_1.z.string().optional(),
|
|
55
|
+
resumeContext: jsonValueSchema.optional(),
|
|
56
|
+
pendingSuspend: zod_1.z
|
|
57
|
+
.array(zod_1.z.object({
|
|
58
|
+
runId: zod_1.z.string(),
|
|
59
|
+
toolCallId: zod_1.z.string(),
|
|
60
|
+
toolName: zod_1.z.string(),
|
|
61
|
+
input: zod_1.z.unknown(),
|
|
62
|
+
suspendPayload: zod_1.z.unknown(),
|
|
63
|
+
resumeSchema: zod_1.z.unknown().optional(),
|
|
64
|
+
}))
|
|
65
|
+
.optional(),
|
|
66
|
+
});
|
|
67
|
+
const delegateSubAgentContinuationSchema = zod_1.z.object({
|
|
68
|
+
runId: zod_1.z.string(),
|
|
69
|
+
toolCallId: zod_1.z.string(),
|
|
70
|
+
taskPath: zod_1.z.string(),
|
|
71
|
+
subAgentId: zod_1.z.string(),
|
|
72
|
+
childCount: zod_1.z.number().int().nonnegative(),
|
|
73
|
+
threadId: zod_1.z.string().optional(),
|
|
74
|
+
resumeContext: jsonValueSchema.optional(),
|
|
75
|
+
});
|
|
76
|
+
exports.delegateSubAgentSuspendSchema = zod_1.z.unknown();
|
|
77
|
+
exports.delegateSubAgentResumeSchema = zod_1.z.unknown();
|
|
78
|
+
function parseDelegateSubAgentContinuation(value) {
|
|
79
|
+
const parsed = delegateSubAgentContinuationSchema.safeParse(value);
|
|
80
|
+
return parsed.success ? parsed.data : undefined;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=delegation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/types/runtime/delegation.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import type { AgentMessageList } from '../../runtime/model/message-list';
|
|
3
|
+
import type { TokenCounter } from '../../runtime/model/model-token-counter';
|
|
4
|
+
import type { AgentEventBus } from '../../runtime/state/event-bus';
|
|
5
|
+
import type { RuntimeTelemetry } from '../../runtime/telemetry/runtime-telemetry';
|
|
6
|
+
import type { RuntimeSkillLoader } from '../../skills/types';
|
|
7
|
+
import type { WorkspaceFilesystem } from '../../workspace/types';
|
|
8
|
+
import type { AgentExecutionCounter, BuiltTelemetry, BuiltTool, PendingToolCall, ToolSuspendOptions } from '../index';
|
|
9
|
+
import type { AgentPersistenceOptions, ToolResultEntry } from '../sdk/agent';
|
|
10
|
+
import type { AgentMessage } from '../sdk/message';
|
|
11
|
+
import type { JSONValue } from '../utils/json';
|
|
12
|
+
export interface PendingResume {
|
|
13
|
+
pendingToolCalls: Record<string, PendingToolCall>;
|
|
14
|
+
resumeToolCallId: string;
|
|
15
|
+
resumeData: unknown;
|
|
16
|
+
}
|
|
17
|
+
export type ToolCallOutcome = {
|
|
18
|
+
outcome: 'success';
|
|
19
|
+
toolEntry: ToolResultEntry;
|
|
20
|
+
modelOutput: unknown;
|
|
21
|
+
customMessage?: AgentMessage;
|
|
22
|
+
mcpServerName?: string;
|
|
23
|
+
} | {
|
|
24
|
+
outcome: 'suspended';
|
|
25
|
+
payload: unknown;
|
|
26
|
+
resumeSchema: JSONSchema7;
|
|
27
|
+
continuation?: JSONValue;
|
|
28
|
+
} | {
|
|
29
|
+
outcome: 'cancelled';
|
|
30
|
+
toolEntry: ToolResultEntry;
|
|
31
|
+
modelOutput: string;
|
|
32
|
+
userMessage: string;
|
|
33
|
+
canceled: true;
|
|
34
|
+
} | {
|
|
35
|
+
outcome: 'retryable-error';
|
|
36
|
+
} | {
|
|
37
|
+
outcome: 'error';
|
|
38
|
+
error: unknown;
|
|
39
|
+
} | {
|
|
40
|
+
outcome: 'noop';
|
|
41
|
+
};
|
|
42
|
+
export type ToolCallIdentity = Pick<PendingToolCall, 'toolCallId' | 'toolName' | 'input'>;
|
|
43
|
+
export interface ToolCallSuccess extends ToolCallIdentity {
|
|
44
|
+
toolEntry: ToolResultEntry;
|
|
45
|
+
modelOutput: unknown;
|
|
46
|
+
customMessage?: AgentMessage;
|
|
47
|
+
mcpServerName?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ToolCallSuspension extends ToolCallIdentity {
|
|
50
|
+
payload: unknown;
|
|
51
|
+
resumeSchema: JSONSchema7;
|
|
52
|
+
}
|
|
53
|
+
export interface ToolCallError extends ToolCallIdentity {
|
|
54
|
+
error: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface ToolCallBatchResult {
|
|
57
|
+
results: ToolCallSuccess[];
|
|
58
|
+
suspensions: ToolCallSuspension[];
|
|
59
|
+
errors: ToolCallError[];
|
|
60
|
+
pending: Record<string, PendingToolCall>;
|
|
61
|
+
}
|
|
62
|
+
export interface ToolCallInput {
|
|
63
|
+
toolCallId: string;
|
|
64
|
+
toolName: string;
|
|
65
|
+
input: unknown;
|
|
66
|
+
providerExecuted?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface ToolBatchContext {
|
|
69
|
+
toolMap: Map<string, BuiltTool>;
|
|
70
|
+
list: AgentMessageList;
|
|
71
|
+
runId: string;
|
|
72
|
+
persistence?: AgentPersistenceOptions;
|
|
73
|
+
telemetry?: BuiltTelemetry;
|
|
74
|
+
executionCounter?: AgentExecutionCounter;
|
|
75
|
+
abortSignal: AbortSignal;
|
|
76
|
+
isAborted: () => boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface ResumeToolBatchContext extends ToolBatchContext {
|
|
79
|
+
pendingResume: PendingResume;
|
|
80
|
+
}
|
|
81
|
+
export interface ProcessToolCallParams extends ToolCallIdentity {
|
|
82
|
+
toolMap: Map<string, BuiltTool>;
|
|
83
|
+
list: AgentMessageList;
|
|
84
|
+
runId: string;
|
|
85
|
+
persistence?: AgentPersistenceOptions;
|
|
86
|
+
resumeData?: unknown;
|
|
87
|
+
resolvedTelemetry?: BuiltTelemetry;
|
|
88
|
+
executionCounter?: AgentExecutionCounter;
|
|
89
|
+
abortSignal?: AbortSignal;
|
|
90
|
+
countToolCall?: boolean;
|
|
91
|
+
suspendPayload?: unknown;
|
|
92
|
+
continuation?: JSONValue;
|
|
93
|
+
resumeSchema?: ToolSuspendOptions['resumeSchema'];
|
|
94
|
+
}
|
|
95
|
+
export interface ToolCallExecutorDeps {
|
|
96
|
+
loadSkill?: RuntimeSkillLoader;
|
|
97
|
+
telemetry: RuntimeTelemetry;
|
|
98
|
+
eventBus: AgentEventBus;
|
|
99
|
+
concurrency: number;
|
|
100
|
+
onCancelled: () => void;
|
|
101
|
+
tokenCounter: TokenCounter;
|
|
102
|
+
workspaceFilesystem?: WorkspaceFilesystem;
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-execution.js","sourceRoot":"","sources":["../../../src/types/runtime/tool-execution.ts"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,7 @@ import type { BuiltGuardrail } from './guardrail';
|
|
|
4
4
|
import type { CheckpointStore } from './memory';
|
|
5
5
|
import type { ReasoningLevel } from './reasoning';
|
|
6
6
|
import type { BuiltProviderTool, BuiltTool } from './tool';
|
|
7
|
-
import type { VolatileInstructionsProvider } from '
|
|
7
|
+
import type { VolatileInstructionsProvider } from '../runtime/agent-runtime';
|
|
8
8
|
import type { ScopedMemoryTaskEvent } from '../../runtime/memory/scoped-memory-task-runner';
|
|
9
9
|
import type { RuntimeSkill, RuntimeSkillSource } from '../../skills';
|
|
10
10
|
export interface AgentBuilder {
|
|
@@ -31,6 +31,7 @@ export interface BuiltMemory {
|
|
|
31
31
|
threadId: string;
|
|
32
32
|
resourceId: string;
|
|
33
33
|
messages: AgentDbMessage[];
|
|
34
|
+
hostMetadata?: JSONObject;
|
|
34
35
|
}): Promise<void>;
|
|
35
36
|
deleteMessages(messageIds: string[]): Promise<void>;
|
|
36
37
|
episodic?: EpisodicMemoryMethods;
|
|
@@ -240,6 +241,6 @@ export interface CheckpointStore {
|
|
|
240
241
|
save(key: string, state: SerializableAgentState): Promise<void>;
|
|
241
242
|
load(key: string): Promise<SerializableAgentState | undefined>;
|
|
242
243
|
claimForResume?(key: string, state: SerializableAgentState): Promise<boolean>;
|
|
243
|
-
delete(key: string): Promise<void>;
|
|
244
|
+
delete(key: string, state?: SerializableAgentState): Promise<void>;
|
|
244
245
|
}
|
|
245
246
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "AI agent SDK for n8n's code-first execution engine",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@ai-sdk/xai": "^4.0.18",
|
|
95
95
|
"@daytona/sdk": "0.205.1",
|
|
96
96
|
"@modelcontextprotocol/sdk": "1.26.0",
|
|
97
|
-
"@n8n/ai-utilities": "0.
|
|
97
|
+
"@n8n/ai-utilities": "0.35.1",
|
|
98
98
|
"@n8n/sandbox-client": "0.1.1",
|
|
99
|
-
"@n8n/utils": "1.
|
|
99
|
+
"@n8n/utils": "1.49.0",
|
|
100
100
|
"@openrouter/ai-sdk-provider": "^3.0.0",
|
|
101
101
|
"@opentelemetry/exporter-trace-otlp-http": ">=0.50.0",
|
|
102
102
|
"@opentelemetry/sdk-trace-base": "2.7.1",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|
|
145
145
|
"@n8n/typescript-config": "1.12.0",
|
|
146
|
-
"@n8n/vitest-config": "1.
|
|
146
|
+
"@n8n/vitest-config": "1.23.0",
|
|
147
147
|
"@opentelemetry/api": "1.9.1",
|
|
148
148
|
"@opentelemetry/context-async-hooks": "^2.7.1",
|
|
149
149
|
"@pinecone-database/pinecone": "^5.0.2",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"@supabase/supabase-js": "2.112.3",
|
|
152
152
|
"@types/json-schema": "^7.0.15",
|
|
153
153
|
"@types/pg": "^8.15.6",
|
|
154
|
-
"@vitest/coverage-v8": "
|
|
154
|
+
"@vitest/coverage-v8": "5.0.1",
|
|
155
155
|
"dotenv": "17.2.3",
|
|
156
156
|
"cross-env": "^7.0.3",
|
|
157
157
|
"nock": "14.0.14",
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"tsx": "^4.19.3",
|
|
160
160
|
"typescript": "7.0.2",
|
|
161
161
|
"vite": "^8.0.2",
|
|
162
|
-
"vitest": "
|
|
162
|
+
"vitest": "5.0.1",
|
|
163
163
|
"vitest-mock-extended": "^3.1.0",
|
|
164
164
|
"zod": "3.25.76"
|
|
165
165
|
},
|