@n8n-plus/n8n-plus
Version:
n8n Workflow Automation Tool (plus edition)
63 lines (61 loc) • 2.77 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigRulesSection = getConfigRulesSection;
exports.getSchemaReferenceSection = getSchemaReferenceSection;
const zod_1 = require("zod");
const zod_to_json_schema_1 = require("zod-to-json-schema");
const api_types_1 = require("@n8n/api-types");
const schema_text_serializer_1 = require("../../json-config/schema-text-serializer");
const BuilderPromptMemoryConfigSchema = zod_1.z.object({
enabled: zod_1.z.boolean(),
storage: zod_1.z.literal('n8n'),
lastMessages: zod_1.z.number().int().min(1).max(200).optional(),
observationalMemory: zod_1.z
.object({
enabled: zod_1.z.boolean().optional(),
observerThresholdTokens: zod_1.z.number().int().min(1).optional(),
reflectorThresholdTokens: zod_1.z.number().int().min(1).optional(),
renderTokenBudget: zod_1.z.number().int().min(1).optional(),
observationLogTailLimit: zod_1.z.number().int().min(1).optional(),
lockTtlMs: zod_1.z.number().int().min(0).optional(),
})
.optional(),
episodicMemory: zod_1.z
.discriminatedUnion('enabled', [
zod_1.z.object({ enabled: zod_1.z.literal(false) }),
zod_1.z.object({
enabled: zod_1.z.literal(true),
credential: zod_1.z.string().min(1),
topK: zod_1.z.number().int().min(1).max(100).optional(),
maxEntriesPerRun: zod_1.z.number().int().min(1).max(50).optional(),
}),
])
.optional(),
});
const BuilderPromptAgentJsonConfigSchema = api_types_1.RunnableAgentJsonConfigSchema.extend({
memory: BuilderPromptMemoryConfigSchema.optional(),
});
function getConfigRulesSection() {
return `\
#### Agent Config Rules
- \`model\` must be "provider/model-name".
- \`credential\` must be the id returned by \`resolve_llm\` or \`ask_llm\`.
- Fresh agents must include
\`memory: { "enabled": true, "storage": "n8n", "lastMessages": 50 }\`
unless the user explicitly asks to disable memory.
- \`memory.storage\` must be "n8n"; \`memory.lastMessages\` defaults to 50.
- \`memory.episodicMemory\` requires \`ask_credential\` with
\`credentialType: "openAiApi"\`.
- \`config.maxIterations\` caps the number of agent loop iterations per run. Do not set or change this unless the user explicitly asks.
- Fresh agents need a real model, credential, and instructions before config
is written.`;
}
function getSchemaReferenceSection() {
const jsonSchemaText = (0, schema_text_serializer_1.jsonSchemaToCompactText)((0, zod_to_json_schema_1.zodToJsonSchema)(BuilderPromptAgentJsonConfigSchema));
return `\
#### Config Schema Reference
\`\`\`text
${jsonSchemaText}
\`\`\``;
}
//# sourceMappingURL=config-rules.prompt.js.map