@rolealpha/n8n-nodes-rolealpha 0.9.2 → 0.11.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.
@@ -11,6 +11,8 @@ const schedule_1 = require("../../lib/schedule");
11
11
  const share_1 = require("../../lib/share");
12
12
  const waits_1 = require("../../lib/waits");
13
13
  const settings_1 = require("../../lib/settings");
14
+ const memory_1 = require("../../lib/memory");
15
+ const knowledge_1 = require("../../lib/knowledge");
14
16
  const agentRun_1 = require("../../lib/agentRun");
15
17
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16
18
  const show = (resource, operation) => ({ show: { resource: [resource], operation } });
@@ -33,6 +35,7 @@ const properties = [
33
35
  options: [
34
36
  { name: 'Agent', value: 'agent', description: 'Read an agent\'s context and list the agents of the organisation' },
35
37
  { name: 'Responsibility', value: 'responsibility', description: 'Traverse roles, steps and deciders' },
38
+ { name: 'Memory', value: 'memory', description: 'What the agent\'s roles remember from earlier runs: check a fact, pick facts for the prompt, clean up' },
36
39
  { name: 'Prompt', value: 'prompt', description: 'Build a system prompt from roleALPHA data' },
37
40
  { name: 'Schedule', value: 'schedule', description: 'Decide whether a step is due' },
38
41
  { name: 'Settings', value: 'settings', description: 'Runner limits from defaults and a settings table (global, step, agent)' },
@@ -348,6 +351,22 @@ const properties = [
348
351
  description: 'Output of Share → Check (optional). Adds the agent\'s part, the rules for waiting within the step and a task text.',
349
352
  displayOptions: show('prompt', ['buildSystemPrompt']),
350
353
  },
354
+ {
355
+ displayName: 'Memory',
356
+ name: 'memory',
357
+ type: 'json',
358
+ default: '',
359
+ description: 'Output of Memory → Select (optional). Set it, even empty, when the agent has the remember tool: it adds the rules for remembering and what the roles remember.',
360
+ displayOptions: show('prompt', ['buildSystemPrompt']),
361
+ },
362
+ {
363
+ displayName: 'Knowledge',
364
+ name: 'knowledge',
365
+ type: 'json',
366
+ default: '',
367
+ description: 'Output of Memory → Select Pages (optional). Set it, even empty, when knowledge pages are on: it adds what the pages of the roles and circles hold and the rules that keep knowledge apart from policies.',
368
+ displayOptions: show('prompt', ['buildSystemPrompt']),
369
+ },
351
370
  {
352
371
  displayName: 'Additional Rules',
353
372
  name: 'extraRules',
@@ -450,6 +469,184 @@ const properties = [
450
469
  { displayName: 'Run Timeout (Minutes)', name: 'runTimeoutMinutes', type: 'number', typeOptions: { minValue: 1 }, default: 15, description: 'Leases older than this count as dead' },
451
470
  ],
452
471
  },
472
+ // ---------------------------------------------------------------- memory
473
+ {
474
+ displayName: 'Operation',
475
+ name: 'operation',
476
+ type: 'options',
477
+ noDataExpression: true,
478
+ displayOptions: { show: { resource: ['memory'] } },
479
+ options: [
480
+ { name: 'Check Write', value: 'checkWrite', action: 'Check a fact to remember', description: 'Checks a remember call of the agent and returns the row to add, or the reason it is not kept' },
481
+ { name: 'Select', value: 'select', action: 'Pick what the roles remember', description: 'The facts of the roles the agent fills now, for this step and these records, within the limits' },
482
+ { name: 'Consolidate', value: 'consolidate', action: 'Clean up the memory', description: 'For a scheduler: rows to delete (expired, replaced, forgotten, over the limit per role)' },
483
+ { name: 'Locate Pages', value: 'locatePages', action: 'Locate the knowledge pages', description: 'Paths of the pages of the roles the agent fills and of their circles, to read from your store' },
484
+ { name: 'Select Pages', value: 'selectPages', action: 'Pick the knowledge for the prompt', description: 'What the pages of the agent\'s roles and circles hold, within the size limit; proposals for roleALPHA stay out' },
485
+ { name: 'Write Page', value: 'writePage', action: 'Add a fact to its page', description: 'The new content of the page for a fact Check Write sent to a page; your store writes it if the page still has the base version' },
486
+ { name: 'Build Curation Prompt', value: 'curationPrompt', action: 'Build the prompt to curate a page', description: 'Sort new entries in, merge, link, drop what is outdated or contradicts a policy' },
487
+ { name: 'Check Curation', value: 'checkCuration', action: 'Check a curated page', description: 'Frontmatter kept, nothing about persons or secrets added, no rules, within the deletion limit' },
488
+ { name: 'Lint Pages', value: 'lintPages', action: 'Find pages to curate or repair', description: 'For a scheduler: pages due for curation, of roles that are gone, without UUID, with broken links' },
489
+ ],
490
+ default: 'checkWrite',
491
+ },
492
+ {
493
+ displayName: 'Rows',
494
+ name: 'rows',
495
+ type: 'json',
496
+ default: '={{ $input.all().map(item => item.json) }}',
497
+ description: 'Stored memory rows (role_uuid, step_uuid, record_keys, topic, fact, agent_uuid, run_id, at, expires_at)',
498
+ displayOptions: show('memory', ['select', 'consolidate']),
499
+ },
500
+ {
501
+ displayName: 'Context Bundle',
502
+ name: 'bundle',
503
+ type: 'json',
504
+ default: '',
505
+ required: true,
506
+ description: 'Output of Agent → Get Context of this run. Only the roles the agent fills there count.',
507
+ displayOptions: show('memory', ['checkWrite', 'select', 'locatePages', 'selectPages', 'curationPrompt']),
508
+ },
509
+ {
510
+ displayName: 'Pages',
511
+ name: 'pages',
512
+ type: 'json',
513
+ default: '={{ $input.all().map(item => item.json) }}',
514
+ description: 'Pages read from your store, each with path, content (Markdown) and version (a Git SHA, a counter, …)',
515
+ displayOptions: show('memory', ['selectPages', 'lintPages']),
516
+ },
517
+ {
518
+ displayName: 'Circles',
519
+ name: 'circles',
520
+ type: 'json',
521
+ default: '',
522
+ description: 'Output of Responsibility → Get Circle Lead for the agent (all items), e.g. {{ $(\'Get Circle Lead\').all().map(i => i.json) }}. Circles the bundle reaches count as well.',
523
+ displayOptions: show('memory', ['checkWrite', 'locatePages', 'selectPages', 'curationPrompt']),
524
+ },
525
+ {
526
+ displayName: 'Knowledge Pages',
527
+ name: 'knowledgePages',
528
+ type: 'boolean',
529
+ default: false,
530
+ description: 'Whether lasting facts of a role (scope role) and of a circle (scope circle) go to its page instead of a row. Notes on a step or records stay rows.',
531
+ displayOptions: show('memory', ['checkWrite']),
532
+ },
533
+ {
534
+ displayName: 'Write',
535
+ name: 'write',
536
+ type: 'json',
537
+ default: '',
538
+ required: true,
539
+ description: 'Output of Memory → Check Write with target "page"',
540
+ displayOptions: show('memory', ['writePage']),
541
+ },
542
+ {
543
+ displayName: 'Page',
544
+ name: 'page',
545
+ type: 'json',
546
+ default: '',
547
+ description: 'The page as read from your store: path, content, version. Empty when it does not exist yet.',
548
+ displayOptions: show('memory', ['writePage', 'curationPrompt', 'checkCuration']),
549
+ },
550
+ {
551
+ displayName: 'Answer',
552
+ name: 'answer',
553
+ type: 'string',
554
+ typeOptions: { rows: 6 },
555
+ default: '',
556
+ required: true,
557
+ description: 'What the model answered to Build Curation Prompt: the whole page in a markdown block',
558
+ displayOptions: show('memory', ['checkCuration']),
559
+ },
560
+ {
561
+ displayName: 'Existing Pages',
562
+ name: 'existingPages',
563
+ type: 'json',
564
+ default: '',
565
+ description: 'Optional: all pages of the store as path and name, so a curation may only link to pages that exist',
566
+ displayOptions: show('memory', ['curationPrompt', 'checkCuration']),
567
+ },
568
+ {
569
+ displayName: 'Step',
570
+ name: 'stepJson',
571
+ type: 'json',
572
+ default: '',
573
+ description: 'Output of Responsibility → Get Step (optional). With holders, their names are not kept.',
574
+ displayOptions: show('memory', ['checkWrite', 'select']),
575
+ },
576
+ {
577
+ displayName: 'Record Keys',
578
+ name: 'recordKeys',
579
+ type: 'string',
580
+ default: '',
581
+ description: 'Keys of the records this run works on, comma-separated (optional)',
582
+ displayOptions: show('memory', ['checkWrite', 'select']),
583
+ },
584
+ {
585
+ displayName: 'Run ID',
586
+ name: 'memoryRunId',
587
+ type: 'string',
588
+ default: '',
589
+ displayOptions: show('memory', ['checkWrite']),
590
+ },
591
+ {
592
+ displayName: 'Remember Call',
593
+ name: 'request',
594
+ type: 'json',
595
+ default: '',
596
+ required: true,
597
+ placeholder: '{"fact":"","role":"","scope":"role","topic":""}',
598
+ description: 'What the model passed to the remember tool: fact, role (optional), scope (role, step, records), topic (optional), forget (optional)',
599
+ displayOptions: show('memory', ['checkWrite']),
600
+ },
601
+ {
602
+ displayName: 'Known Role UUIDs',
603
+ name: 'knownRoles',
604
+ type: 'string',
605
+ default: '',
606
+ description: 'Optional: the roles (and, for pages, circles) that still exist (comma-separated or an array). Facts of other roles are removed; their pages are reported as orphaned.',
607
+ displayOptions: show('memory', ['consolidate', 'lintPages']),
608
+ },
609
+ {
610
+ displayName: 'Settings Rows',
611
+ name: 'settingRows',
612
+ type: 'json',
613
+ default: '',
614
+ description: 'Optional rows of the settings table: maxMemoryFacts, maxMemoryChars, memoryTtlDays, keepMemoryFacts, and for pages maxKnowledgeChars, maxPageChars, maxNewEntries, knowledgeCurateDays, maxCurationDeletePct, knowledgeLinkDepth (global < step < agent)',
615
+ displayOptions: { show: { resource: ['memory'] } },
616
+ },
617
+ {
618
+ displayName: 'What Is Never Kept',
619
+ name: 'memoryPolicy',
620
+ type: 'collection',
621
+ placeholder: 'Add Option',
622
+ default: {},
623
+ description: 'Your company decides. Secrets are always refused.',
624
+ displayOptions: show('memory', ['checkWrite', 'checkCuration']),
625
+ options: [
626
+ { displayName: 'Block E-Mail Addresses', name: 'blockEmails', type: 'boolean', default: true },
627
+ { displayName: 'Block UUIDs', name: 'blockUuids', type: 'boolean', default: true },
628
+ { displayName: 'Block Phone Numbers', name: 'blockPhoneNumbers', type: 'boolean', default: true },
629
+ { displayName: 'Block Names of Role Holders', name: 'blockPersonNames', type: 'boolean', default: true, description: 'Whether names of the persons who fill the roles of the step are refused (needs Step with holders)' },
630
+ { displayName: 'Blocked Terms', name: 'blockedTerms', type: 'string', typeOptions: { rows: 4 }, default: '', description: 'One term per line (or comma-separated), matched as a whole word in any case, e.g. customer names read from your CRM with an expression' },
631
+ { displayName: 'Blocked Patterns', name: 'blockedPatterns', type: 'string', typeOptions: { rows: 3 }, default: '', description: 'One regular expression per line, e.g. for an IBAN' },
632
+ ],
633
+ },
634
+ {
635
+ displayName: 'Knowledge Options',
636
+ name: 'knowledgeOptions',
637
+ type: 'collection',
638
+ placeholder: 'Add Option',
639
+ default: {},
640
+ description: 'Use the same values in every node of your knowledge workflows',
641
+ displayOptions: show('memory', ['checkWrite', 'locatePages', 'selectPages', 'writePage', 'curationPrompt', 'checkCuration']),
642
+ options: [
643
+ { displayName: 'Path Template', name: 'pathTemplate', type: 'string', default: '{entity}s/{uuid}.md', description: 'Where the page of a role or circle lives. Placeholders: {entity} (role, circle), {uuid}, {slug}. The UUID keeps a page when the role is renamed.' },
644
+ { displayName: 'Language', name: 'language', type: 'options', options: [{ name: 'German', value: 'de' }, { name: 'English', value: 'en' }], default: 'de', description: 'Headings and type names of new pages; pages in either language are read' },
645
+ { displayName: 'Normative Terms', name: 'normativeTerms', type: 'string', typeOptions: { rows: 3 }, default: '', description: 'Words that make a statement a rule (one per line or comma-separated). Empty: muss, darf nicht, verboten, must, must not, shall, not allowed, … A fact with one of them goes to the proposals for roleALPHA, not into the prompt.' },
646
+ { displayName: 'Allow Rules in Curation', name: 'allowNormativeCuration', type: 'boolean', default: false, description: 'Whether a curation may add normative statements outside the proposals' },
647
+ { displayName: 'Curating Role', name: 'curatingRole', type: 'string', default: '', description: 'Role (UUID or name) whose holders curate circle pages. Empty: any role of the circle.' },
648
+ ],
649
+ },
453
650
  // ---------------------------------------------------------------- settings
454
651
  {
455
652
  displayName: 'Operation',
@@ -578,6 +775,82 @@ const properties = [
578
775
  },
579
776
  ];
580
777
  // -------------------------------------------------------------------- helpers
778
+ function bundleParam(ctx, i) {
779
+ const raw = parseJsonParam(ctx, 'bundle', i);
780
+ const bundle = (raw && typeof raw.bundle === 'object' ? raw.bundle : raw);
781
+ if (!bundle || !bundle.agent)
782
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), 'Context Bundle has no agent', { itemIndex: i });
783
+ return { ...bundle, guardrails: bundle.guardrails ?? [], context: bundle.context ?? [] };
784
+ }
785
+ function stepParamJson(ctx, i) {
786
+ const raw = parseJsonParam(ctx, 'stepJson', i);
787
+ const step = (raw && typeof raw.step === 'object' ? raw.step : raw);
788
+ return step && typeof step === 'object' && step.uuid ? step : null;
789
+ }
790
+ function knowledgeLimits(rows, agentUuid) {
791
+ const s = (0, settings_1.resolveSettings)(rows, { agentUuid }).settings;
792
+ return {
793
+ maxChars: s.maxKnowledgeChars,
794
+ maxPageChars: s.maxPageChars,
795
+ maxNewEntries: s.maxNewEntries,
796
+ curateAfterDays: s.knowledgeCurateDays,
797
+ maxDeletePct: s.maxCurationDeletePct,
798
+ linkDepth: s.knowledgeLinkDepth,
799
+ };
800
+ }
801
+ function knowledgeOptions(ctx, i) {
802
+ const o = ctx.getNodeParameter('knowledgeOptions', i, {});
803
+ const terms = String(o.normativeTerms ?? '')
804
+ .split(/\r?\n|,/)
805
+ .map((t) => t.trim())
806
+ .filter(Boolean);
807
+ return {
808
+ pathTemplate: String(o.pathTemplate ?? '').trim() || undefined,
809
+ language: o.language === 'en' ? 'en' : 'de',
810
+ normativeTerms: terms.length ? terms : undefined,
811
+ allowNormativeCuration: o.allowNormativeCuration === true,
812
+ curatingRole: String(o.curatingRole ?? '').trim() || undefined,
813
+ };
814
+ }
815
+ function listParam(ctx, name, i) {
816
+ const raw = parseJsonParam(ctx, name, i);
817
+ if (Array.isArray(raw))
818
+ return raw;
819
+ if (raw && typeof raw === 'object')
820
+ return [raw];
821
+ return [];
822
+ }
823
+ function pageParam(ctx, i) {
824
+ const raw = parseJsonParam(ctx, 'page', i);
825
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
826
+ return null;
827
+ if (typeof raw.content !== 'string')
828
+ return null;
829
+ return { path: String(raw.path ?? ''), content: raw.content, version: raw.version ?? null };
830
+ }
831
+ function memoryPolicyParam(ctx, i) {
832
+ const opts = ctx.getNodeParameter('memoryPolicy', i, {});
833
+ const lines = (v, split) => String(v ?? '').split(split).map((t) => t.trim()).filter(Boolean);
834
+ const policy = {
835
+ blockEmails: opts.blockEmails !== false,
836
+ blockUuids: opts.blockUuids !== false,
837
+ blockPhoneNumbers: opts.blockPhoneNumbers !== false,
838
+ blockPersonNames: opts.blockPersonNames !== false,
839
+ blockedTerms: lines(opts.blockedTerms, /\r?\n|,/),
840
+ blockedPatterns: lines(opts.blockedPatterns, /\r?\n/),
841
+ };
842
+ try {
843
+ (0, memory_1.compilePatterns)(policy.blockedPatterns);
844
+ }
845
+ catch (error) {
846
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), error.message, { itemIndex: i });
847
+ }
848
+ return policy;
849
+ }
850
+ function memoryLimits(rows, bundle, step) {
851
+ const s = (0, settings_1.resolveSettings)(rows, { agentUuid: bundle.agent?.uuid ?? '', stepUuid: step?.uuid ?? '', stepCustomId: step?.customId ?? '' }).settings;
852
+ return { maxFacts: s.maxMemoryFacts, maxChars: s.maxMemoryChars, ttlDays: s.memoryTtlDays, keepFacts: s.keepMemoryFacts };
853
+ }
581
854
  function parseJsonParam(ctx, name, i) {
582
855
  const value = ctx.getNodeParameter(name, i, '');
583
856
  if (value === '' || value === null || value === undefined)
@@ -862,8 +1135,111 @@ class RoleAlpha {
862
1135
  const plan = (0, waits_1.planAfterRun)(rows, run, waitOpts);
863
1136
  return [[{ json: plan }]];
864
1137
  }
1138
+ // Pages: Locate, Select and Lint look at all pages (or none) at once.
1139
+ if (resource === 'memory' && ['locatePages', 'selectPages', 'lintPages'].includes(operation)) {
1140
+ const settingRowsRaw = parseJsonParam(this, 'settingRows', 0);
1141
+ const settingRows = (Array.isArray(settingRowsRaw) ? settingRowsRaw : []);
1142
+ if (operation === 'lintPages') {
1143
+ const knownRaw = this.getNodeParameter('knownRoles', 0, '');
1144
+ const known = (Array.isArray(knownRaw) ? knownRaw : String(knownRaw ?? '').split(',')).map((v) => String(v).trim()).filter(Boolean);
1145
+ const res = (0, knowledge_1.lintPages)(parseJsonParam(this, 'pages', 0), { knownUuids: known, limits: knowledgeLimits(settingRows, '') });
1146
+ return [[{ json: res }]];
1147
+ }
1148
+ const bundle = bundleParam(this, 0);
1149
+ const circles = listParam(this, 'circles', 0);
1150
+ const opts = knowledgeOptions(this, 0);
1151
+ let refs;
1152
+ try {
1153
+ refs = (0, knowledge_1.locatePages)(bundle, circles, opts);
1154
+ }
1155
+ catch (error) {
1156
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message);
1157
+ }
1158
+ if (operation === 'locatePages')
1159
+ return [refs.map((r) => ({ json: r }))];
1160
+ const res = (0, knowledge_1.selectKnowledge)(parseJsonParam(this, 'pages', 0), { bundle, circles, opts, limits: knowledgeLimits(settingRows, bundle.agent?.uuid ?? '') });
1161
+ return [[{ json: res }]];
1162
+ }
1163
+ // Memory: Select and Consolidate look at all stored rows at once.
1164
+ if (resource === 'memory' && (operation === 'select' || operation === 'consolidate')) {
1165
+ const rows = parseJsonParam(this, 'rows', 0);
1166
+ const settingRowsRaw = parseJsonParam(this, 'settingRows', 0);
1167
+ const settingRows = (Array.isArray(settingRowsRaw) ? settingRowsRaw : []);
1168
+ if (operation === 'consolidate') {
1169
+ const s = (0, settings_1.resolveSettings)(settingRows).settings;
1170
+ const knownRaw = this.getNodeParameter('knownRoles', 0, '');
1171
+ const known = (Array.isArray(knownRaw) ? knownRaw : String(knownRaw ?? '').split(',')).map((v) => String(v).trim()).filter(Boolean);
1172
+ const res = (0, memory_1.consolidateMemory)(rows, { limits: { ttlDays: s.memoryTtlDays, keepFacts: s.keepMemoryFacts }, knownRoleUuids: known });
1173
+ return [[{ json: res }]];
1174
+ }
1175
+ const bundle = bundleParam(this, 0);
1176
+ const step = stepParamJson(this, 0);
1177
+ const limits = memoryLimits(settingRows, bundle, step);
1178
+ const res = (0, memory_1.selectMemory)(rows, { bundle, stepUuid: step?.uuid ?? null, recordKeys: this.getNodeParameter('recordKeys', 0, ''), limits });
1179
+ return [[{ json: res }]];
1180
+ }
865
1181
  for (let i = 0; i < items.length; i++) {
866
1182
  try {
1183
+ if (resource === 'memory' && operation !== 'checkWrite') {
1184
+ const settingRowsRaw = parseJsonParam(this, 'settingRows', i);
1185
+ const settingRows = (Array.isArray(settingRowsRaw) ? settingRowsRaw : []);
1186
+ const opts = knowledgeOptions(this, i);
1187
+ const page = pageParam(this, i);
1188
+ let res;
1189
+ if (operation === 'writePage') {
1190
+ const write = parseJsonParam(this, 'write', i);
1191
+ res = (0, knowledge_1.writeEntry)(write, page, opts, knowledgeLimits(settingRows, String(write?.entry?.agent ?? '')));
1192
+ }
1193
+ else if (operation === 'curationPrompt') {
1194
+ if (!page)
1195
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Page is empty: there is nothing to curate', { itemIndex: i });
1196
+ const bundle = bundleParam(this, i);
1197
+ res = (0, knowledge_1.buildCurationPrompt)({
1198
+ page,
1199
+ bundle,
1200
+ circles: listParam(this, 'circles', i),
1201
+ existing: listParam(this, 'existingPages', i),
1202
+ opts,
1203
+ limits: knowledgeLimits(settingRows, bundle.agent?.uuid ?? ''),
1204
+ });
1205
+ }
1206
+ else {
1207
+ if (!page)
1208
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Page is empty: give the page that was curated', { itemIndex: i });
1209
+ const existing = listParam(this, 'existingPages', i).map((p) => String(p?.path ?? '')).filter(Boolean);
1210
+ res = (0, knowledge_1.checkCuration)(page, String(this.getNodeParameter('answer', i, '') ?? ''), {
1211
+ policy: memoryPolicyParam(this, i),
1212
+ opts,
1213
+ limits: knowledgeLimits(settingRows, ''),
1214
+ existingPaths: existing,
1215
+ });
1216
+ }
1217
+ // A refusal is data, so the workflow can retry, report or leave the page as it is.
1218
+ out.push({ json: res, pairedItem: { item: i } });
1219
+ continue;
1220
+ }
1221
+ if (resource === 'memory') {
1222
+ const bundle = bundleParam(this, i);
1223
+ const step = stepParamJson(this, i);
1224
+ const settingRowsRaw = parseJsonParam(this, 'settingRows', i);
1225
+ const limits = memoryLimits((Array.isArray(settingRowsRaw) ? settingRowsRaw : []), bundle, step);
1226
+ const raw = parseJsonParam(this, 'request', i);
1227
+ const request = (raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {});
1228
+ const policy = memoryPolicyParam(this, i);
1229
+ const knowledgeOn = this.getNodeParameter('knowledgePages', i, false) === true;
1230
+ const res = (0, memory_1.checkWrite)(request, {
1231
+ bundle,
1232
+ step,
1233
+ recordKeys: this.getNodeParameter('recordKeys', i, ''),
1234
+ runId: String(this.getNodeParameter('memoryRunId', i, '') ?? ''),
1235
+ ttlDays: limits.ttlDays,
1236
+ policy,
1237
+ knowledge: knowledgeOn ? { enabled: true, circles: listParam(this, 'circles', i), opts: knowledgeOptions(this, i) } : null,
1238
+ });
1239
+ // A refusal is data, so the model can shorten or rephrase the fact.
1240
+ out.push({ json: res, pairedItem: { item: i } });
1241
+ continue;
1242
+ }
867
1243
  if (resource === 'agent') {
868
1244
  const agentUuid = this.getNodeParameter('agentUuid', i);
869
1245
  if (operation === 'getContextVersion') {
@@ -960,6 +1336,18 @@ class RoleAlpha {
960
1336
  const duties = parseJsonParam(this, 'duties', i);
961
1337
  const shareRaw = parseJsonParam(this, 'share', i);
962
1338
  const share = (shareRaw && Array.isArray(shareRaw.duties) ? shareRaw : null);
1339
+ const memoryRaw = parseJsonParam(this, 'memory', i);
1340
+ const memory = Array.isArray(memoryRaw)
1341
+ ? memoryRaw
1342
+ : memoryRaw && typeof memoryRaw === 'object' && Array.isArray(memoryRaw.memory)
1343
+ ? memoryRaw.memory
1344
+ : null;
1345
+ const knowledgeRaw = parseJsonParam(this, 'knowledge', i);
1346
+ const knowledge = Array.isArray(knowledgeRaw)
1347
+ ? knowledgeRaw
1348
+ : knowledgeRaw && typeof knowledgeRaw === 'object' && Array.isArray(knowledgeRaw.knowledge)
1349
+ ? knowledgeRaw.knowledge
1350
+ : null;
963
1351
  const rules = String(this.getNodeParameter('extraRules', i, '') ?? '')
964
1352
  .split(/\r?\n/)
965
1353
  .map((r) => r.trim())
@@ -971,6 +1359,8 @@ class RoleAlpha {
971
1359
  trigger: { type: this.getNodeParameter('triggerType', i, '') || undefined, event: parseJsonParam(this, 'event', i) },
972
1360
  extraRules: rules,
973
1361
  share,
1362
+ memory,
1363
+ knowledge,
974
1364
  });
975
1365
  const json = { ...items[i].json, systemPrompt };
976
1366
  if (share && step)