@n8n/agents 0.6.0 → 0.8.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 +18 -11
- package/dist/index.js +37 -10
- 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 +30 -19
- package/dist/runtime/agent-runtime.js +616 -280
- package/dist/runtime/agent-runtime.js.map +1 -1
- package/dist/runtime/background-task-tracker.d.ts +6 -0
- package/dist/runtime/background-task-tracker.js +26 -0
- package/dist/runtime/background-task-tracker.js.map +1 -0
- package/dist/runtime/deferred-tool-manager.d.ts +28 -0
- package/dist/runtime/deferred-tool-manager.js +205 -0
- package/dist/runtime/deferred-tool-manager.js.map +1 -0
- 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 +34 -11
- package/dist/runtime/memory-store.js +210 -8
- package/dist/runtime/memory-store.js.map +1 -1
- package/dist/runtime/message-list.d.ts +6 -7
- package/dist/runtime/message-list.js +50 -6
- 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/observation-log-defaults.d.ts +20 -0
- package/dist/runtime/observation-log-defaults.js +523 -0
- package/dist/runtime/observation-log-defaults.js.map +1 -0
- package/dist/runtime/observation-log-observer.d.ts +64 -0
- package/dist/runtime/observation-log-observer.js +235 -0
- package/dist/runtime/observation-log-observer.js.map +1 -0
- package/dist/runtime/observation-log-reflector.d.ts +36 -0
- package/dist/runtime/observation-log-reflector.js +292 -0
- package/dist/runtime/observation-log-reflector.js.map +1 -0
- package/dist/runtime/observation-log-renderer.d.ts +6 -0
- package/dist/runtime/observation-log-renderer.js +73 -0
- package/dist/runtime/observation-log-renderer.js.map +1 -0
- package/dist/runtime/observation-log-store.d.ts +3 -0
- package/dist/runtime/observation-log-store.js +26 -0
- package/dist/runtime/observation-log-store.js.map +1 -0
- 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/scoped-memory-task-runner.d.ts +79 -0
- package/dist/runtime/scoped-memory-task-runner.js +134 -0
- package/dist/runtime/scoped-memory-task-runner.js.map +1 -0
- 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/sdk/agent.d.ts +35 -22
- package/dist/sdk/agent.js +106 -331
- package/dist/sdk/agent.js.map +1 -1
- package/dist/sdk/catalog.d.ts +1 -0
- package/dist/sdk/catalog.js +1 -0
- package/dist/sdk/catalog.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/memory.d.ts +12 -12
- package/dist/sdk/memory.js +71 -51
- package/dist/sdk/memory.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 +54 -0
- package/dist/storage/base-memory.js +48 -0
- package/dist/storage/base-memory.js.map +1 -0
- package/dist/types/index.d.ts +6 -3
- package/dist/types/index.js +7 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/runtime/event.d.ts +4 -9
- package/dist/types/runtime/event.js.map +1 -1
- package/dist/types/sdk/agent-builder.d.ts +5 -3
- package/dist/types/sdk/agent.d.ts +70 -27
- package/dist/types/sdk/credential-provider.d.ts +2 -3
- package/dist/types/sdk/memory.d.ts +33 -20
- package/dist/types/sdk/message.d.ts +11 -10
- package/dist/types/sdk/observation-log.d.ts +99 -0
- package/dist/types/sdk/observation-log.js +17 -0
- package/dist/types/sdk/observation-log.js.map +1 -0
- package/dist/types/sdk/observation.d.ts +9 -0
- package/dist/types/sdk/{schema.js → observation.js} +1 -1
- package/dist/types/sdk/observation.js.map +1 -0
- package/dist/types/sdk/provider.d.ts +5 -2
- package/dist/types/sdk/tool-descriptor.d.ts +13 -0
- package/dist/types/sdk/tool-descriptor.js +3 -0
- 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 +16 -11
- 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/runtime/working-memory.d.ts +0 -14
- package/dist/runtime/working-memory.js +0 -69
- package/dist/runtime/working-memory.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/storage/postgres-memory.d.ts +0 -79
- package/dist/storage/postgres-memory.js +0 -410
- package/dist/storage/postgres-memory.js.map +0 -1
- package/dist/storage/sqlite-memory.d.ts +0 -60
- package/dist/storage/sqlite-memory.js +0 -348
- package/dist/storage/sqlite-memory.js.map +0 -1
- package/dist/types/sdk/schema.d.ts +0 -99
- package/dist/types/sdk/schema.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { AgentDbMessage } from './message';
|
|
2
|
+
export declare const OBSERVATION_LOG_MARKERS: readonly ["critical", "important", "info", "completion"];
|
|
3
|
+
export type ObservationLogMarker = (typeof OBSERVATION_LOG_MARKERS)[number];
|
|
4
|
+
export declare const OBSERVATION_LOG_STATUSES: readonly ["active", "superseded", "dropped"];
|
|
5
|
+
export type ObservationLogStatus = (typeof OBSERVATION_LOG_STATUSES)[number];
|
|
6
|
+
export type ObservationLogScopeKind = 'thread' | 'resource';
|
|
7
|
+
export type ObservationLogTaskKind = 'observer' | 'reflector';
|
|
8
|
+
export declare function createObservationLogThreadScopeId(threadId: string, resourceId: string): string;
|
|
9
|
+
export declare function createObservationLogThreadScopePrefix(threadId: string): string;
|
|
10
|
+
export interface ObservationLogScope {
|
|
11
|
+
scopeKind: ObservationLogScopeKind;
|
|
12
|
+
scopeId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ObservationLogTaskLockHandle extends ObservationLogScope {
|
|
15
|
+
taskKind: ObservationLogTaskKind;
|
|
16
|
+
holderId: string;
|
|
17
|
+
heldUntil: Date;
|
|
18
|
+
}
|
|
19
|
+
export interface ObservationLogEntry extends ObservationLogScope {
|
|
20
|
+
id: string;
|
|
21
|
+
marker: ObservationLogMarker;
|
|
22
|
+
text: string;
|
|
23
|
+
parentId: string | null;
|
|
24
|
+
tokenCount: number;
|
|
25
|
+
status: ObservationLogStatus;
|
|
26
|
+
supersededBy: string | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
}
|
|
29
|
+
export interface NewObservationLogEntry extends ObservationLogScope {
|
|
30
|
+
marker: ObservationLogMarker;
|
|
31
|
+
text: string;
|
|
32
|
+
parentId?: string | null;
|
|
33
|
+
tokenCount?: number;
|
|
34
|
+
createdAt?: Date;
|
|
35
|
+
}
|
|
36
|
+
export interface ObservationLogReadOptions extends ObservationLogScope {
|
|
37
|
+
status?: ObservationLogStatus;
|
|
38
|
+
parentId?: string | null;
|
|
39
|
+
limit?: number;
|
|
40
|
+
order?: 'asc' | 'desc';
|
|
41
|
+
}
|
|
42
|
+
export interface ObservationLogMerge {
|
|
43
|
+
supersedes: string[];
|
|
44
|
+
marker: ObservationLogMarker;
|
|
45
|
+
text: string;
|
|
46
|
+
parentId?: string | null;
|
|
47
|
+
tokenCount?: number;
|
|
48
|
+
createdAt?: Date;
|
|
49
|
+
}
|
|
50
|
+
export interface ObservationLogReflection {
|
|
51
|
+
drop: string[];
|
|
52
|
+
merge: ObservationLogMerge[];
|
|
53
|
+
}
|
|
54
|
+
export interface ObservationLogReflectionResult {
|
|
55
|
+
droppedIds: string[];
|
|
56
|
+
supersededIds: string[];
|
|
57
|
+
inserted: ObservationLogEntry[];
|
|
58
|
+
}
|
|
59
|
+
export type TokenCounter = (text: string) => number;
|
|
60
|
+
export declare const estimateObservationTokens: TokenCounter;
|
|
61
|
+
export interface ObservationLogObserverInput {
|
|
62
|
+
scopeKind: ObservationLogScopeKind;
|
|
63
|
+
scopeId: string;
|
|
64
|
+
now: Date;
|
|
65
|
+
deltaMessages: AgentDbMessage[];
|
|
66
|
+
transcript: string;
|
|
67
|
+
transcriptTokenCount: number;
|
|
68
|
+
observationLogTail: ObservationLogEntry[];
|
|
69
|
+
renderedObservationLogTail: string | null;
|
|
70
|
+
}
|
|
71
|
+
export type ObservationLogObserveFn = (input: ObservationLogObserverInput) => Promise<string>;
|
|
72
|
+
export interface ObservationLogReflectorInput {
|
|
73
|
+
scopeKind: ObservationLogScopeKind;
|
|
74
|
+
scopeId: string;
|
|
75
|
+
now: Date;
|
|
76
|
+
activeObservationLog: ObservationLogEntry[];
|
|
77
|
+
renderedObservationLog: string;
|
|
78
|
+
tokenCount: number;
|
|
79
|
+
tokenBudget: number;
|
|
80
|
+
}
|
|
81
|
+
export type ObservationLogReflectFn = (input: ObservationLogReflectorInput) => Promise<string>;
|
|
82
|
+
export interface BuiltObservationLogStore {
|
|
83
|
+
appendObservationLogEntries(rows: NewObservationLogEntry[]): Promise<ObservationLogEntry[]>;
|
|
84
|
+
getActiveObservationLog(scope: ObservationLogScope & {
|
|
85
|
+
limit?: number;
|
|
86
|
+
order?: 'asc' | 'desc';
|
|
87
|
+
}): Promise<ObservationLogEntry[]>;
|
|
88
|
+
getObservationLog(opts: ObservationLogReadOptions): Promise<ObservationLogEntry[]>;
|
|
89
|
+
dropObservationLogEntries(ids: string[]): Promise<void>;
|
|
90
|
+
supersedeObservationLogEntries(ids: string[], supersededBy: string): Promise<void>;
|
|
91
|
+
applyObservationLogReflection(scope: ObservationLogScope, reflection: ObservationLogReflection): Promise<ObservationLogReflectionResult>;
|
|
92
|
+
}
|
|
93
|
+
export interface BuiltObservationLogTaskLockStore {
|
|
94
|
+
acquireObservationLogTaskLock(scopeKind: ObservationLogScopeKind, scopeId: string, taskKind: ObservationLogTaskKind, opts: {
|
|
95
|
+
ttlMs: number;
|
|
96
|
+
holderId: string;
|
|
97
|
+
}): Promise<ObservationLogTaskLockHandle | null>;
|
|
98
|
+
releaseObservationLogTaskLock(handle: ObservationLogTaskLockHandle): Promise<void>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateObservationTokens = exports.OBSERVATION_LOG_STATUSES = exports.OBSERVATION_LOG_MARKERS = void 0;
|
|
4
|
+
exports.createObservationLogThreadScopeId = createObservationLogThreadScopeId;
|
|
5
|
+
exports.createObservationLogThreadScopePrefix = createObservationLogThreadScopePrefix;
|
|
6
|
+
exports.OBSERVATION_LOG_MARKERS = ['critical', 'important', 'info', 'completion'];
|
|
7
|
+
exports.OBSERVATION_LOG_STATUSES = ['active', 'superseded', 'dropped'];
|
|
8
|
+
const OBSERVATION_LOG_THREAD_SCOPE_PREFIX = 'thread';
|
|
9
|
+
function createObservationLogThreadScopeId(threadId, resourceId) {
|
|
10
|
+
return `${OBSERVATION_LOG_THREAD_SCOPE_PREFIX}:${encodeURIComponent(threadId)}:resource:${encodeURIComponent(resourceId)}`;
|
|
11
|
+
}
|
|
12
|
+
function createObservationLogThreadScopePrefix(threadId) {
|
|
13
|
+
return `${OBSERVATION_LOG_THREAD_SCOPE_PREFIX}:${encodeURIComponent(threadId)}:resource:`;
|
|
14
|
+
}
|
|
15
|
+
const estimateObservationTokens = (text) => Math.ceil(text.length / 4);
|
|
16
|
+
exports.estimateObservationTokens = estimateObservationTokens;
|
|
17
|
+
//# sourceMappingURL=observation-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation-log.js","sourceRoot":"","sources":["../../../src/types/sdk/observation-log.ts"],"names":[],"mappings":";;;AAgBA,8EAEC;AAED,sFAEC;AApBY,QAAA,uBAAuB,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,CAAU,CAAC;AAInF,QAAA,wBAAwB,GAAG,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAU,CAAC;AAQrF,MAAM,mCAAmC,GAAG,QAAQ,CAAC;AAErD,SAAgB,iCAAiC,CAAC,QAAgB,EAAE,UAAkB;IACrF,OAAO,GAAG,mCAAmC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,aAAa,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;AAC5H,CAAC;AAED,SAAgB,qCAAqC,CAAC,QAAgB;IACrE,OAAO,GAAG,mCAAmC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC;AAC3F,CAAC;AA6DM,MAAM,yBAAyB,GAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAA/E,QAAA,yBAAyB,6BAAsD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ObservationLogScopeKind } from './observation-log';
|
|
2
|
+
export type ScopeKind = ObservationLogScopeKind;
|
|
3
|
+
export interface ObservationCursor {
|
|
4
|
+
scopeKind: ObservationLogScopeKind;
|
|
5
|
+
scopeId: string;
|
|
6
|
+
lastObservedMessageId: string;
|
|
7
|
+
lastObservedAt: Date;
|
|
8
|
+
updatedAt: Date;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation.js","sourceRoot":"","sources":["../../../src/types/sdk/observation.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export type Provider = 'anthropic' | 'cerebras' | 'deepinfra' | 'deepseek' | 'google' | 'groq' | 'mistral' | 'openai' | 'openrouter' | 'perplexity' | 'togetherai' | 'vercel' | 'xai' | (string & {});
|
|
2
|
-
export
|
|
2
|
+
export type AnthropicThinkingConfig = {
|
|
3
|
+
mode: 'adaptive';
|
|
4
|
+
} | {
|
|
5
|
+
mode?: 'enabled';
|
|
3
6
|
budgetTokens?: number;
|
|
4
|
-
}
|
|
7
|
+
};
|
|
5
8
|
export interface OpenAIThinkingConfig {
|
|
6
9
|
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
7
10
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
export interface ToolDescriptor {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
systemInstruction: string | null;
|
|
6
|
+
inputSchema: JSONSchema7 | null;
|
|
7
|
+
outputSchema: JSONSchema7 | null;
|
|
8
|
+
hasSuspend: boolean;
|
|
9
|
+
hasResume: boolean;
|
|
10
|
+
hasToMessage: boolean;
|
|
11
|
+
requireApproval: boolean;
|
|
12
|
+
providerOptions: Record<string, unknown> | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-descriptor.js","sourceRoot":"","sources":["../../../src/types/sdk/tool-descriptor.ts"],"names":[],"mappings":""}
|
package/dist/types/sdk/tool.d.ts
CHANGED
|
@@ -4,27 +4,32 @@ import type { AgentMessage } from './message';
|
|
|
4
4
|
import type { BuiltTelemetry } from '../telemetry';
|
|
5
5
|
import type { JSONObject } from '../utils/json';
|
|
6
6
|
export interface ToolContext {
|
|
7
|
+
toolCallId?: string;
|
|
7
8
|
parentTelemetry?: BuiltTelemetry;
|
|
8
9
|
}
|
|
9
10
|
export interface InterruptibleToolContext<S = unknown, R = unknown> {
|
|
10
11
|
suspend: (payload: S) => Promise<never>;
|
|
11
12
|
resumeData: R | undefined;
|
|
13
|
+
toolCallId?: string;
|
|
12
14
|
parentTelemetry?: BuiltTelemetry;
|
|
13
15
|
}
|
|
14
16
|
export interface BuiltTool {
|
|
15
17
|
readonly name: string;
|
|
16
18
|
readonly description: string;
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
+
readonly systemInstruction?: string;
|
|
20
|
+
readonly suspendSchema?: ZodType | JSONSchema7;
|
|
21
|
+
readonly resumeSchema?: ZodType | JSONSchema7;
|
|
19
22
|
readonly withDefaultApproval?: boolean;
|
|
20
23
|
readonly toMessage?: (output: unknown) => AgentMessage | undefined;
|
|
21
24
|
readonly toModelOutput?: (output: unknown) => unknown;
|
|
22
25
|
readonly handler?: (input: unknown, ctx: ToolContext | InterruptibleToolContext) => Promise<unknown>;
|
|
23
26
|
readonly inputSchema?: ZodType | JSONSchema7;
|
|
24
|
-
readonly outputSchema?: ZodType;
|
|
27
|
+
readonly outputSchema?: ZodType | JSONSchema7;
|
|
25
28
|
readonly mcpTool?: boolean;
|
|
26
29
|
readonly mcpServerName?: string;
|
|
27
30
|
readonly providerOptions?: Record<string, JSONObject>;
|
|
31
|
+
readonly metadata?: Record<string, unknown>;
|
|
32
|
+
readonly editable?: boolean;
|
|
28
33
|
}
|
|
29
34
|
export interface BuiltProviderTool {
|
|
30
35
|
readonly name: `${string}.${string}`;
|
|
@@ -11,6 +11,7 @@ export interface BuiltTelemetry {
|
|
|
11
11
|
readonly metadata?: Record<string, AttributeValue>;
|
|
12
12
|
readonly recordInputs: boolean;
|
|
13
13
|
readonly recordOutputs: boolean;
|
|
14
|
+
readonly runtimeRootSpanEnabled?: boolean;
|
|
14
15
|
readonly integrations: TelemetryIntegration[];
|
|
15
16
|
readonly tracer?: OpaqueTracer;
|
|
16
17
|
readonly provider?: OpaqueTracerProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import type { ZodType } from 'zod';
|
|
3
|
+
export type ParseResult<T = unknown> = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function parseWithSchema(schema: ZodType | JSONSchema7, data: unknown): Promise<ParseResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseWithSchema = parseWithSchema;
|
|
4
|
+
const zod_1 = require("./zod");
|
|
5
|
+
let ajvInstance;
|
|
6
|
+
function getAjv() {
|
|
7
|
+
if (!ajvInstance) {
|
|
8
|
+
const { default: Ajv } = require('ajv');
|
|
9
|
+
ajvInstance = new Ajv({ strict: false });
|
|
10
|
+
}
|
|
11
|
+
return ajvInstance;
|
|
12
|
+
}
|
|
13
|
+
async function parseWithSchema(schema, data) {
|
|
14
|
+
if ((0, zod_1.isZodSchema)(schema)) {
|
|
15
|
+
const result = await schema.safeParseAsync(data);
|
|
16
|
+
if (result.success)
|
|
17
|
+
return { success: true, data: result.data };
|
|
18
|
+
return { success: false, error: result.error.message };
|
|
19
|
+
}
|
|
20
|
+
const ajv = getAjv();
|
|
21
|
+
const validate = ajv.compile(schema);
|
|
22
|
+
if (validate(data))
|
|
23
|
+
return { success: true, data };
|
|
24
|
+
return { success: false, error: ajv.errorsText(validate.errors) };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":";;AAyBA,0CAcC;AAnCD,+BAAoC;AAMpC,IAAI,WAAqD,CAAC;AAE1D,SAAS,MAAM;IACd,IAAI,CAAC,WAAW,EAAE,CAAC;QAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CAAgC,CAAC;QACvE,WAAW,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC;AAMM,KAAK,UAAU,eAAe,CACpC,MAA6B,EAC7B,IAAa;IAEb,IAAI,IAAA,iBAAW,EAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAChE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/utils/zod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { JSONSchema7 } from 'json-schema';
|
|
2
2
|
import type { ZodType } from 'zod';
|
|
3
|
-
export declare function isZodSchema(schema:
|
|
3
|
+
export declare function isZodSchema(schema: unknown): schema is ZodType;
|
|
4
4
|
export declare function zodToJsonSchema(schema?: unknown): JSONSchema7 | null;
|
package/dist/utils/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":";;AAKA,kCAMC;AAED,0CAgBC;AA3BD,2DAA4E;AAG5E,SAAgB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":";;AAKA,kCAMC;AAED,0CAgBC;AA3BD,2DAA4E;AAG5E,SAAgB,WAAW,CAAC,MAAe;IAC1C,OAAO,CACN,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,OAAQ,MAAkC,CAAC,SAAS,KAAK,UAAU,CACnE,CAAC;AACH,CAAC;AAED,SAAgB,eAAe,CAAC,MAAgB;IAC/C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC;QACJ,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,IAAI,cAAc,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;gBAC3E,OAAQ,MAAyD,CAAC,YAAY,EAAE,CAAC;YAClF,CAAC;YACD,OAAO,IAAA,oCAAmB,EAAC,MAAM,CAA4B,CAAC;QAC/D,CAAC;QACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBatchStrReplaceFileTool = createBatchStrReplaceFileTool;
|
|
4
|
+
const text_editor_1 = require("@n8n/ai-utilities/text-editor");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const tool_1 = require("../../sdk/tool");
|
|
7
|
+
const strReplacementSchema = zod_1.z.object({
|
|
8
|
+
old_str: zod_1.z.string().describe('Exact text to replace. Must match exactly and be unique.'),
|
|
9
|
+
new_str: zod_1.z.string().describe('Replacement text to write in place of old_str.'),
|
|
10
|
+
});
|
|
11
|
+
const inputSchema = zod_1.z.object({
|
|
12
|
+
path: zod_1.z.string().describe('Path to the file to edit'),
|
|
13
|
+
replacements: zod_1.z
|
|
14
|
+
.array(strReplacementSchema)
|
|
15
|
+
.describe('Ordered exact string replacements applied atomically.'),
|
|
16
|
+
});
|
|
17
|
+
const batchReplaceResultSchema = zod_1.z.object({
|
|
18
|
+
index: zod_1.z.number().int(),
|
|
19
|
+
old_str: zod_1.z.string(),
|
|
20
|
+
status: zod_1.z.enum(['success', 'failed', 'not_attempted']),
|
|
21
|
+
error: zod_1.z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
const outputSchema = zod_1.z.object({
|
|
24
|
+
success: zod_1.z.boolean().describe('Whether all replacements were applied'),
|
|
25
|
+
result: zod_1.z.string().optional().describe('Success message'),
|
|
26
|
+
error: zod_1.z.string().optional().describe('Error message when replacements could not be applied'),
|
|
27
|
+
results: zod_1.z
|
|
28
|
+
.array(batchReplaceResultSchema)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe('Per-replacement statuses for a failed batch edit'),
|
|
31
|
+
});
|
|
32
|
+
function createErrorOutput(error) {
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
error: error instanceof Error ? error.message : 'Unknown workspace edit error.',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function isBatchReplaceResult(result) {
|
|
39
|
+
return Array.isArray(result);
|
|
40
|
+
}
|
|
41
|
+
function createBatchStrReplaceFileTool(filesystem) {
|
|
42
|
+
return new tool_1.Tool('workspace_batch_str_replace_file')
|
|
43
|
+
.description('Apply multiple exact text replacements to a workspace file atomically. If any replacement fails, no changes are written.')
|
|
44
|
+
.input(inputSchema)
|
|
45
|
+
.output(outputSchema)
|
|
46
|
+
.handler(async (input) => {
|
|
47
|
+
try {
|
|
48
|
+
const content = await filesystem.readFile(input.path, { encoding: 'utf-8' });
|
|
49
|
+
const editor = new text_editor_1.TextEditorDocument({ initialText: content.toString() });
|
|
50
|
+
const result = editor.executeBatch(input.replacements);
|
|
51
|
+
if (isBatchReplaceResult(result)) {
|
|
52
|
+
return { success: false, error: 'Batch replacement failed.', results: result };
|
|
53
|
+
}
|
|
54
|
+
const editedContent = editor.getText();
|
|
55
|
+
if (editedContent === null) {
|
|
56
|
+
throw new Error(`File "${input.path}" is not loaded.`);
|
|
57
|
+
}
|
|
58
|
+
await filesystem.writeFile(input.path, editedContent, { overwrite: true });
|
|
59
|
+
return { success: true, result };
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return createErrorOutput(error);
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.build();
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=batch-str-replace-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-str-replace-file.js","sourceRoot":"","sources":["../../../src/workspace/tools/batch-str-replace-file.ts"],"names":[],"mappings":";;AAmDA,sEA6BC;AAhFD,+DAA4F;AAC5F,6BAAwB;AAExB,yCAAsC;AAItC,MAAM,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;IACxF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;CAC9E,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IACrD,YAAY,EAAE,OAAC;SACb,KAAK,CAAC,oBAAoB,CAAC;SAC3B,QAAQ,CAAC,uDAAuD,CAAC;CACnE,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,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AAI,gCAAkB,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAEvD,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAChF,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACvC,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,IAAI,kBAAkB,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACF,CAAC,CAAC;SACD,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStrReplaceFileTool = createStrReplaceFileTool;
|
|
4
|
+
const text_editor_1 = require("@n8n/ai-utilities/text-editor");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const tool_1 = require("../../sdk/tool");
|
|
7
|
+
const inputSchema = zod_1.z.object({
|
|
8
|
+
path: zod_1.z.string().describe('Path to the file to edit'),
|
|
9
|
+
old_str: zod_1.z.string().describe('Exact text to replace. Must match exactly and be unique.'),
|
|
10
|
+
new_str: zod_1.z.string().describe('Replacement text to write in place of old_str.'),
|
|
11
|
+
});
|
|
12
|
+
const outputSchema = zod_1.z.object({
|
|
13
|
+
success: zod_1.z.boolean().describe('Whether the edit was applied'),
|
|
14
|
+
result: zod_1.z.string().optional().describe('Success message'),
|
|
15
|
+
error: zod_1.z.string().optional().describe('Error message when the edit could not be applied'),
|
|
16
|
+
});
|
|
17
|
+
function createErrorOutput(error) {
|
|
18
|
+
return {
|
|
19
|
+
success: false,
|
|
20
|
+
error: error instanceof Error ? error.message : 'Unknown workspace edit error.',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createStrReplaceFileTool(filesystem) {
|
|
24
|
+
return new tool_1.Tool('workspace_str_replace_file')
|
|
25
|
+
.description('Replace one exact, unique text match in a workspace file without rewriting the whole file.')
|
|
26
|
+
.input(inputSchema)
|
|
27
|
+
.output(outputSchema)
|
|
28
|
+
.handler(async (input) => {
|
|
29
|
+
try {
|
|
30
|
+
const content = await filesystem.readFile(input.path, { encoding: 'utf-8' });
|
|
31
|
+
const editor = new text_editor_1.TextEditorDocument({ initialText: content.toString() });
|
|
32
|
+
const result = editor.execute({
|
|
33
|
+
command: 'str_replace',
|
|
34
|
+
path: input.path,
|
|
35
|
+
old_str: input.old_str,
|
|
36
|
+
new_str: input.new_str,
|
|
37
|
+
});
|
|
38
|
+
const editedContent = editor.getText();
|
|
39
|
+
if (editedContent === null) {
|
|
40
|
+
throw new Error(`File "${input.path}" is not loaded.`);
|
|
41
|
+
}
|
|
42
|
+
await filesystem.writeFile(input.path, editedContent, { overwrite: true });
|
|
43
|
+
return { success: true, result };
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return createErrorOutput(error);
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
.build();
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=str-replace-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"str-replace-file.js","sourceRoot":"","sources":["../../../src/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EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7E,MAAM,MAAM,GAAG,IAAI,gCAAkB,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;gBAC7B,OAAO,EAAE,aAAa;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;aACtB,CAAC,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YACvC,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,IAAI,kBAAkB,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;IACF,CAAC,CAAC;SACD,KAAK,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWorkspaceTools = createWorkspaceTools;
|
|
4
4
|
const append_file_1 = require("./append-file");
|
|
5
|
+
const batch_str_replace_file_1 = require("./batch-str-replace-file");
|
|
5
6
|
const copy_file_1 = require("./copy-file");
|
|
6
7
|
const delete_file_1 = require("./delete-file");
|
|
7
8
|
const execute_command_1 = require("./execute-command");
|
|
@@ -12,11 +13,14 @@ const move_file_1 = require("./move-file");
|
|
|
12
13
|
const process_tools_1 = require("./process-tools");
|
|
13
14
|
const read_file_1 = require("./read-file");
|
|
14
15
|
const rmdir_1 = require("./rmdir");
|
|
16
|
+
const str_replace_file_1 = require("./str-replace-file");
|
|
15
17
|
const write_file_1 = require("./write-file");
|
|
16
18
|
function createWorkspaceTools(workspace) {
|
|
17
19
|
const tools = [];
|
|
18
20
|
if (workspace.filesystem) {
|
|
19
21
|
tools.push((0, read_file_1.createReadFileTool)(workspace.filesystem));
|
|
22
|
+
tools.push((0, str_replace_file_1.createStrReplaceFileTool)(workspace.filesystem));
|
|
23
|
+
tools.push((0, batch_str_replace_file_1.createBatchStrReplaceFileTool)(workspace.filesystem));
|
|
20
24
|
tools.push((0, write_file_1.createWriteFileTool)(workspace.filesystem));
|
|
21
25
|
tools.push((0, list_files_1.createListFilesTool)(workspace.filesystem));
|
|
22
26
|
tools.push((0, file_stat_1.createFileStatTool)(workspace.filesystem));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-tools.js","sourceRoot":"","sources":["../../../src/workspace/tools/workspace-tools.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"workspace-tools.js","sourceRoot":"","sources":["../../../src/workspace/tools/workspace-tools.ts"],"names":[],"mappings":";;AAsBA,oDA4BC;AAhDD,+CAAqD;AACrD,qEAAyE;AACzE,2CAAiD;AACjD,+CAAqD;AACrD,uDAA6D;AAC7D,2CAAiD;AACjD,6CAAmD;AACnD,mCAA0C;AAC1C,2CAAiD;AACjD,mDAAiF;AACjF,2CAAiD;AACjD,mCAA0C;AAC1C,yDAA8D;AAC9D,6CAAmD;AAOnD,SAAgB,oBAAoB,CAAC,SAAwB;IAC5D,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAkB,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;QACrD,KAAK,CAAC,IAAI,CAAC,IAAA,2CAAwB,EAAC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AC,IAAI,CAAC,IAAA,qCAAqB,EAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "AI agent SDK for n8n's code-first execution engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -11,23 +11,30 @@
|
|
|
11
11
|
"LICENSE_EE.md"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@ai-sdk/amazon-bedrock": "^4.0.95",
|
|
14
15
|
"@ai-sdk/anthropic": "^3.0.58",
|
|
16
|
+
"@ai-sdk/azure": "^3.0.54",
|
|
17
|
+
"@ai-sdk/cohere": "^3.0.30",
|
|
18
|
+
"@ai-sdk/deepseek": "^2.0.29",
|
|
19
|
+
"@ai-sdk/gateway": "^3.0.104",
|
|
15
20
|
"@ai-sdk/google": "^3.0.43",
|
|
21
|
+
"@ai-sdk/groq": "^3.0.35",
|
|
22
|
+
"@ai-sdk/mistral": "^3.0.30",
|
|
16
23
|
"@ai-sdk/openai": "^3.0.41",
|
|
17
|
-
"@ai-sdk/xai": "^3.0.67",
|
|
18
24
|
"@ai-sdk/provider-utils": "^4.0.21",
|
|
25
|
+
"@ai-sdk/xai": "^3.0.67",
|
|
19
26
|
"@modelcontextprotocol/sdk": "1.26.0",
|
|
20
|
-
"
|
|
21
|
-
"@libsql/client": "^0.17.0",
|
|
27
|
+
"@openrouter/ai-sdk-provider": "^2.8.0",
|
|
22
28
|
"ai": "^6.0.116",
|
|
23
|
-
"
|
|
24
|
-
"zod": "3.25.67"
|
|
29
|
+
"ajv": "^8.18.0",
|
|
30
|
+
"zod": "3.25.67",
|
|
31
|
+
"@n8n/ai-utilities": "0.16.0"
|
|
25
32
|
},
|
|
26
33
|
"peerDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"@opentelemetry/sdk-trace-node": ">=1.0.0",
|
|
34
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.50.0",
|
|
29
35
|
"@opentelemetry/sdk-trace-base": ">=1.0.0",
|
|
30
|
-
"@opentelemetry/
|
|
36
|
+
"@opentelemetry/sdk-trace-node": ">=1.0.0",
|
|
37
|
+
"langsmith": "0.6.0"
|
|
31
38
|
},
|
|
32
39
|
"peerDependenciesMeta": {
|
|
33
40
|
"langsmith": {
|
|
@@ -45,8 +52,6 @@
|
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
47
54
|
"@types/json-schema": "^7.0.15",
|
|
48
|
-
"@types/pg": "^8.15.6",
|
|
49
|
-
"testcontainers": "^11.13.0",
|
|
50
55
|
"@n8n/typescript-config": "1.4.0"
|
|
51
56
|
},
|
|
52
57
|
"license": "SEE LICENSE IN LICENSE.md",
|