@rolealpha/n8n-nodes-rolealpha 0.10.0 → 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.
package/README.md CHANGED
@@ -51,6 +51,11 @@ next run follows. You don't edit code and you don't republish anything.
51
51
  - **Memory that belongs to the role.** What an agent learns is kept for its role, without
52
52
  approval. Give the role to another agent and the memory goes with it. Who decides and who
53
53
  fills a role is never kept: it is read from roleALPHA on every run.
54
+ - **Knowledge of roles and circles, kept apart from policies.** Lasting experience goes to a
55
+ Markdown page per role and per circle, a small wiki people can read and correct. It is
56
+ curated by the roles themselves. Rules stay in roleALPHA: a statement that reads as one
57
+ becomes a proposal, not knowledge. Pages live where the company wants: an n8n data table,
58
+ Git, a folder.
54
59
  - **Limits you can change without republishing.** Retries, wait times, run time and tool
55
60
  calls come from a settings table and are clamped to fixed bounds.
56
61
 
@@ -113,15 +118,19 @@ Scheduler (cron) Event router (one webhook)
113
118
  ├ Wait: Check Start (lease, duplicate-run guard)
114
119
  ├ Share: Build Input → model → Share: Check (cached)
115
120
  ├ Memory: Select (facts of the agent's roles, this step, these records)
121
+ ├ Memory: Locate Pages → store → Memory: Select Pages
122
+ │ (knowledge of the agent's roles and circles, optional)
116
123
  ├ roleALPHA: Build System Prompt
117
124
  ├ AI Agent (+ data tool limited to the domains of the agent's roles,
118
125
  │ + roleALPHA: Tool, read only, as the agent,
119
- │ + remember → Memory: Check Write → add row)
126
+ │ + remember → Memory: Check Write → add row,
127
+ │ or → read page → Memory: Write Page → store page)
120
128
  └ Wait: Plan After Run (done row, wake-ups, lease released)
121
129
 
122
130
  Scheduler, every tick
123
131
  └ Wait: Find Stale Waits → wake (claimed) · remove dead leases · escalate → Get Circle Lead
124
132
  └ Memory: Consolidate → delete replaced, forgotten and expired facts
133
+ └ Memory: Lint Pages → per page due: Build Curation Prompt → model → Check Curation → store page
125
134
  ```
126
135
 
127
136
  **Every read is the agent's own.** With **Connect As: Agent** the node swaps the function
@@ -397,6 +406,128 @@ role or step, proposed as a draft.
397
406
  Pass the role UUIDs that still exist as **Known Role UUIDs** to remove the memory of
398
407
  roles that are gone.
399
408
 
409
+ ## Knowledge of roles and circles
410
+
411
+ Memory rows are notes on the work in progress: they belong to a step or to records and expire.
412
+ What a role learns for good is something else: how the work is done well, what worked, what
413
+ was observed. That is knowledge of the organisation. It belongs to the role, or to the circle
414
+ when it holds for its other roles too, and people should be able to read, link and correct it.
415
+ So it is kept as **Markdown pages with YAML frontmatter**, one per role and one per circle: a
416
+ small wiki the roles keep themselves.
417
+
418
+ As with the rows, the package keeps no page itself. It decides; the workflow reads and writes
419
+ with ordinary n8n nodes. It sees a page only as `{ path, content, version }`, where `version`
420
+ is whatever the store uses to notice a concurrent change. Typical stores:
421
+
422
+ | Store | Read | Write | `version` |
423
+ | --- | --- | --- | --- |
424
+ | **n8n data table** (stays on the company's own n8n) | Get rows | Update the row where `path` and `version` match, else insert; no row updated = changed meanwhile | a counter (`nextVersion`) |
425
+ | **Git** (GitHub, GitLab, Gitea) via HTTP Request on the contents API | GET the file, decode base64 | PUT with the `sha` read before; 409 = changed meanwhile | the file's SHA |
426
+ | **Folder** (a mounted vault, e.g. Obsidian or Tolaria) | Read Files from Disk | Write Files from Disk | modification time |
427
+
428
+ A data table for pages needs the columns `path, entity, uuid, name, content, version`. With
429
+ Git, any editor that reads Markdown with wiki links shows the pages; a Tolaria or Obsidian
430
+ vault of its own works as is. Give the store to the agents alone: a repository or vault with
431
+ meeting or sales notes in it is the wrong place.
432
+
433
+ **A page**
434
+
435
+ ```markdown
436
+ ---
437
+ type: Rollenwissen
438
+ schema: rolealpha-knowledge/1
439
+ entity: role
440
+ uuid: e31893c0-…
441
+ name: "Kampagnenmanagement"
442
+ updated: 2026-11-22T10:00:00.000Z
443
+ ---
444
+ # Kampagnenmanagement – Wissen
445
+
446
+ > Erfahrung dieser Rolle aus ihrer Arbeit. Keine Regeln: Verbindliches steht in roleALPHA.
447
+
448
+ ## Neu
449
+ - Beiträge mit einer Zahl im ersten Satz werden seltener abgelehnt. <!-- ra:{"at":"…","topic":"einstieg","run":"68266","agent":"…"} -->
450
+
451
+ ## Kampagnenformate
452
+ - …
453
+
454
+ ## Vorschläge für roleALPHA
455
+ - Jeder Beitrag muss eine Kampagne nennen. <!-- ra:{…} -->
456
+
457
+ ## Siehe auch
458
+ - [[circles/<uuid>|Marketing – Kreiswissen]]
459
+ ```
460
+
461
+ The path follows the UUID (`roles/<uuid>.md`, `circles/<uuid>.md`; **Path Template** in the
462
+ Knowledge Options), so a page survives a renamed role; its title and `name` follow the name.
463
+ Headings come in German or English (**Language**); pages in either are read. Entries of agents
464
+ carry their metadata in an HTML comment, so a newer fact on the same topic replaces the older
465
+ one and a topic can be forgotten; text people write needs none and stays.
466
+
467
+ **Who writes what**
468
+
469
+ - **Remember** writes, as before, through **Check Write**. With **Knowledge Pages** on, scope
470
+ `role` (the default) goes to the page of the role and scope `circle` to the page of its
471
+ circle; `step` and `records` stay rows. The same checks apply: a role the agent fills, a
472
+ circle one of its roles is in (from **Get Circle Lead**, or reached in the bundle), no
473
+ secrets, persons, contact data or the company's blocked terms. **Write Page** adds the entry
474
+ under "Neu" and returns the whole new page with the version it is based on.
475
+ - **Curation** sorts the new entries into topics, merges and links them, and drops what is
476
+ outdated or contradicts a policy: the wiki part. The page of a role is curated only by an
477
+ agent that fills the role; the page of a circle by any role of the circle, or with
478
+ **Curating Role** only by that one. **Lint Pages** names the pages that are due (`maxNewEntries`
479
+ new entries, new entries older than `knowledgeCurateDays`, or larger than `maxPageChars`).
480
+ **Build Curation Prompt** gives the model the page, the policies of the curating agent and
481
+ the pages it may link to; **Check Curation** applies the answer only when the frontmatter is
482
+ kept, nothing it adds names a person, contact data, a secret or a blocked term, no rule is
483
+ added, every link points to a page that exists and no more than `maxCurationDeletePct` of the
484
+ curated text is gone.
485
+ - **People** edit pages in their editor or the data table. Nothing they write is checked or
486
+ removed by an agent unless it duplicates an entry or contradicts a policy, and every change
487
+ is in the history of the store.
488
+
489
+ **Knowledge and policies stay apart.** Policies, accountabilities and process steps are
490
+ binding and live in roleALPHA; they change only by an approved draft. Knowledge says how a role
491
+ does its work well and changes without approval. The package holds the line:
492
+
493
+ | | Policy, accountability, step (roleALPHA) | Knowledge (pages) |
494
+ | --- | --- | --- |
495
+ | Says | what has to be, what is to be done | what worked, what was observed |
496
+ | Changes | by a draft a person approves | without approval, in the store's history |
497
+ | In the prompt | binding, wins | experience, data, not instructions |
498
+
499
+ - A fact with a **normative term** (`muss`, `darf nicht`, `verboten`, `must`, `must not`,
500
+ `shall`, `not allowed`, …; your own list in **Normative Terms**) goes to "Vorschläge für
501
+ roleALPHA" / "Proposals for roleALPHA". That section never reaches the prompt. A curation
502
+ either rephrases it as experience or leaves it for the role that proposes changes of roles
503
+ and policies in roleALPHA.
504
+ - A curation may not add normative statements outside the proposals (**Allow Rules in
505
+ Curation** turns this off), is told never to copy a policy into a page and to drop entries
506
+ that contradict one.
507
+ - The prompt lists knowledge after the binding parts and says that policies, accountabilities
508
+ and the current step win; when a page contradicts them, the agent follows roleALPHA and
509
+ forgets the outdated topic.
510
+
511
+ **Into the prompt.** **Locate Pages** gives the paths of the agent's pages; read them, pass
512
+ them to **Select Pages** and its output to **Build System Prompt → Knowledge**. Only pages
513
+ whose frontmatter names the role or circle count, so a page at the wrong path is not read.
514
+ With `knowledgeLinkDepth` 1, `linked` names the pages they link to; read those too and run
515
+ Select Pages again with all of them.
516
+
517
+ **Setting it up**
518
+
519
+ 1. Pick a store and create it (data table with the columns above, a repository, a folder).
520
+ 2. In the runner, after Get Context: **Get Circle Lead** for the agent, **Locate Pages**, read
521
+ the pages, **Select Pages**, and pass it to **Build System Prompt → Knowledge**.
522
+ 3. In the `remember` sub-workflow: **Check Write** with **Knowledge Pages** on and the circles;
523
+ when `target` is `page`, read the page at `page.path`, run **Write Page** and write
524
+ `content` if the page still has `baseVersion`. If it changed meanwhile, read it again and
525
+ run Write Page again: entries are only added, nothing is lost.
526
+ 4. In the scheduler: read all pages, **Lint Pages**; for each page in `curate`, start a run of
527
+ an agent that may curate it with **Build Curation Prompt**, then **Check Curation** on its
528
+ answer and write `content`. Move `orphaned` pages to an archive.
529
+ 5. Use the same Knowledge Options in every node.
530
+
400
531
  ## Nodes
401
532
 
402
533
  ### roleALPHA (`roleAlpha`)
@@ -424,6 +555,12 @@ role or step, proposed as a draft.
424
555
  | Wait | Find Stale Waits | For a scheduler: waits nobody answered in time (e.g. a person fills the awaited role), queued starts whose busy run died, dead leases, expired rows, and waits at the attempt limit to escalate (`escalate`, reported once). | – |
425
556
  | Memory | Check Write | Checks a `remember` call: a role the agent fills (from the bundle), scope, size, secrets, and what the company never keeps. Returns `ok` and the `row` to add, or `error` and `problems` as data. | – |
426
557
  | Memory | Select | The facts for the prompt: roles the agent fills now, this step and these records, the newest of each topic, nothing forgotten or expired, within `maxMemoryFacts` and `maxMemoryChars`. Returns `memory` and `omitted`. | – |
558
+ | Memory | Locate Pages | One item per page of the agent: the roles it fills and the circles of these roles (**Circles** from Get Circle Lead, or reached in the bundle), with `path`, `entity`, `uuid`, `name`. | – |
559
+ | Memory | Select Pages | The knowledge for the prompt from the pages read: only pages whose frontmatter names the role or circle, without proposals and metadata, within `maxKnowledgeChars`. Returns `knowledge`, `missing`, `linked` (with `knowledgeLinkDepth` 1) and `omitted`. | – |
560
+ | Memory | Write Page | Adds an entry that Check Write sent to a page: under "Neu", or under the proposals when it reads as a rule; replaces an older entry on the same topic or forgets it. Makes a missing page with frontmatter. Returns `content`, `baseVersion`, `nextVersion`, or `ok: false` (another role's page at that path, page full). | – |
561
+ | Memory | Build Curation Prompt | System prompt and task to curate one page, for an agent that may curate it, with its policies and the pages it may link to. | – |
562
+ | Memory | Check Curation | Checks the page a model returned: frontmatter kept, nothing about persons, contact data, secrets or blocked terms added, no rule added, links to existing pages, deletion within `maxCurationDeletePct`. Returns the page to write or `problems`. | – |
563
+ | Memory | Lint Pages | For a scheduler: `curate` (pages due), `orphaned` (with **Known Role UUIDs**, roles and circles), `invalid`, `duplicates` and `brokenLinks`. | – |
427
564
  | Memory | Consolidate | For a scheduler: `remove` lists replaced, forgotten and expired rows, rows of roles that are gone (with **Known Role UUIDs**) and rows over `keepMemoryFacts` per role. | – |
428
565
  | Settings | Resolve | Runner limits from defaults and a settings table (`scope, target, key, value`): default < global < step < agent. Every value is clamped to fixed bounds; unknown keys and unusable values are reported in `settingProblems` and never applied. | – |
429
566
  | Schedule | Is Due | Decides from the step `frequency` (and `termin` / due date) whether a run is due in the current period. | – |
@@ -491,6 +628,12 @@ with `scope = global` applies to every run. `step` (target: step UUID or custom
491
628
  | `maxMemoryChars` | 4000 | 0–20000 | Characters of all remembered facts in one prompt |
492
629
  | `memoryTtlDays` | 180 | 1–3650 | Days a remembered fact counts; a shorter value also applies to older facts |
493
630
  | `keepMemoryFacts` | 200 | 10–2000 | Facts kept per role in the store (Consolidate) |
631
+ | `maxKnowledgeChars` | 6000 | 0–40000 | Characters of all knowledge pages in one prompt |
632
+ | `maxPageChars` | 12000 | 2000–100000 | Size of a page before it is curated; a write is refused beyond twice this size |
633
+ | `maxNewEntries` | 20 | 1–500 | New entries on a page from which it is curated |
634
+ | `knowledgeCurateDays` | 7 | 1–90 | Days after which new entries are curated even below `maxNewEntries` |
635
+ | `maxCurationDeletePct` | 30 | 0–100 | Share of the curated text one curation may delete |
636
+ | `knowledgeLinkDepth` | 0 | 0–1 | 1: pages linked from the own pages go into the prompt too |
494
637
 
495
638
  A row with a value outside the bounds is clamped and reported. A wrong row can make the
496
639
  runner more careful, never unbounded.
@@ -517,6 +660,11 @@ record_keys, event, run_id, attempts, progress, at`.
517
660
  - Duplicate runs are blocked by leases, and wake-ups are claimed before they fire.
518
661
  - Memory belongs to roles the agent fills in the run; secrets are never kept, and what else is
519
662
  never kept each company sets itself. Remembered facts reach the prompt as data, with limits.
663
+ - Knowledge pages are written only for roles the agent fills and circles of these roles, read
664
+ only when their frontmatter names them, and curated only by an agent of that role or circle.
665
+ What an agent or a curation adds is checked like a remembered fact; a rule never becomes
666
+ knowledge. A store with history keeps what was forgotten, so persons and secrets are refused
667
+ before they are written.
520
668
  - No credentials are kept in wait, settings or cache rows. The share cache key holds no
521
669
  record content, and a cached answer is checked again like a fresh one.
522
670
 
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Knowledge of roles and circles: lasting experience kept as Markdown pages with YAML
3
+ * frontmatter, one page per role and per circle, a small wiki the organisation owns. It
4
+ * belongs to the role or the circle, never to the agent, and people can read, link and
5
+ * correct it in any editor.
6
+ *
7
+ * As with the memory rows, these functions only decide; where the pages live is up to the
8
+ * workflow: an n8n data table on the company's own n8n, a Git repository through its
9
+ * contents API, a folder. The functions see a page only as { path, content, version }.
10
+ *
11
+ * Knowledge is not a rule. What is binding (policies, accountabilities, steps) lives in
12
+ * roleALPHA and changes only by an approved draft. Knowledge says how a role does its work
13
+ * well: experience, observations, what worked. A normative statement ("must", "never
14
+ * allowed") written by an agent goes to the section of proposals for roleALPHA, which is not
15
+ * part of the prompt, until it is rephrased as experience or proposed as a draft.
16
+ *
17
+ * Page layout (headings in German or English, both are read):
18
+ *
19
+ * ---
20
+ * type: Rollenwissen (Kreiswissen for a circle)
21
+ * schema: rolealpha-knowledge/1
22
+ * entity: role (circle)
23
+ * uuid: <uuid of the role or circle>
24
+ * name: <its name, refreshed on every write>
25
+ * updated: <ISO date>
26
+ * ---
27
+ * # <name> – Wissen
28
+ * > note that this is experience, not rules
29
+ * ## Neu entries of agents, not yet curated
30
+ * - fact <!-- ra:{"at":"…","topic":"…","run":"…","agent":"…"} -->
31
+ * ## <any topic> curated by the curation run or by people
32
+ * ## Vorschläge für roleALPHA normative statements, not in the prompt
33
+ * ## Siehe auch links to other pages
34
+ */
35
+ import type { ContextBundle } from './prompt';
36
+ import { type MemoryPolicy } from './memory';
37
+ export declare const KNOWLEDGE_SCHEMA = "rolealpha-knowledge/1";
38
+ export type PageEntity = 'role' | 'circle';
39
+ export type KnowledgeLanguage = 'de' | 'en';
40
+ /** A page as the store hands it over. `version` is whatever the store uses to detect a concurrent change (a Git SHA, a counter, a timestamp). */
41
+ export interface Page {
42
+ path: string;
43
+ content: string;
44
+ version?: string | number | null;
45
+ }
46
+ /** Which page belongs to which role or circle. */
47
+ export interface PageRef {
48
+ path: string;
49
+ entity: PageEntity;
50
+ uuid: string;
51
+ name: string;
52
+ }
53
+ export interface KnowledgeOptions {
54
+ /** Where the page of a role or circle lives. Placeholders: {entity} (role, circle), {uuid}, {slug}. Default "{entity}s/{uuid}.md". */
55
+ pathTemplate?: string;
56
+ /** Language of headings and type names written to new pages. Pages in either language are read. */
57
+ language?: KnowledgeLanguage;
58
+ /** Words that make a statement a rule rather than experience. Default: a short list in German and English. */
59
+ normativeTerms?: string[];
60
+ /** Whether a curation may add normative statements outside the proposals. Default false. */
61
+ allowNormativeCuration?: boolean;
62
+ /** Role (UUID or name) whose holders curate circle pages. Empty: any role of the circle. */
63
+ curatingRole?: string;
64
+ }
65
+ export interface KnowledgeLimits {
66
+ /** Characters of all pages in one prompt. */
67
+ maxChars?: number;
68
+ /** Size of a page before it has to be curated; a write is refused beyond twice this size. */
69
+ maxPageChars?: number;
70
+ /** Entries under "new" from which a page counts as due for curation. */
71
+ maxNewEntries?: number;
72
+ /** Share (percent) of the curated text a curation may delete. Entries under "new" do not count. */
73
+ maxDeletePct?: number;
74
+ /** 0: only the own pages; 1: also pages they link to. */
75
+ linkDepth?: number;
76
+ /** Days after which a page with new entries is curated even below maxNewEntries. */
77
+ curateAfterDays?: number;
78
+ }
79
+ export declare const DEFAULT_KNOWLEDGE_LIMITS: Required<KnowledgeLimits>;
80
+ /** A circle as Responsibility → Get Circle Lead returns it: the circle and the agent's roles in it. */
81
+ export interface CircleInfo {
82
+ circle: {
83
+ uuid: string;
84
+ name: string;
85
+ };
86
+ roles?: Array<{
87
+ uuid: string;
88
+ name?: string;
89
+ }>;
90
+ }
91
+ /** What Memory → Check Write hands over when a fact goes to a page. */
92
+ export interface PageWrite {
93
+ ok: true;
94
+ target: 'page';
95
+ page: PageRef;
96
+ entry: KnowledgeEntry;
97
+ }
98
+ export interface KnowledgeEntry {
99
+ text: string;
100
+ topic: string;
101
+ at: string;
102
+ run: string;
103
+ agent: string;
104
+ /** Forget the topic instead of adding to it. */
105
+ forget: boolean;
106
+ /** The statement reads as a rule; it goes to the proposals for roleALPHA. */
107
+ normative: boolean;
108
+ }
109
+ export interface KnowledgePage {
110
+ path: string;
111
+ entity: PageEntity;
112
+ uuid: string;
113
+ name: string;
114
+ /** Own page of a role the agent fills or of its circle, or a page linked from one. */
115
+ via: 'own' | 'linked';
116
+ text: string;
117
+ truncated: boolean;
118
+ }
119
+ /** Deontic words: a statement with one of them says what has to be, not what was learned. */
120
+ export declare const DEFAULT_NORMATIVE_TERMS: string[];
121
+ /** Whether a statement reads as a rule. */
122
+ export declare function isNormative(text: string, terms?: string[]): boolean;
123
+ export declare function slugOf(name: string): string;
124
+ export declare function pagePath(entity: PageEntity, uuid: string, name: string, template?: string): string;
125
+ /** The circles of the agent's roles: from Get Circle Lead, and circles the bundle itself reaches through a role. */
126
+ export declare function ownCircles(bundle: ContextBundle, circles: CircleInfo[] | null | undefined): Array<{
127
+ uuid: string;
128
+ name: string;
129
+ roles: string[];
130
+ }>;
131
+ /** The pages that belong to the agent in this run: one per role it fills, one per circle of these roles. */
132
+ export declare function locatePages(bundle: ContextBundle, circles: CircleInfo[] | null | undefined, opts?: KnowledgeOptions): PageRef[];
133
+ interface Section {
134
+ heading: string;
135
+ lines: string[];
136
+ }
137
+ export interface ParsedPage {
138
+ /** Frontmatter lines without the fences; kept as written so human additions survive. */
139
+ frontmatter: string[];
140
+ data: Record<string, string>;
141
+ title: string;
142
+ /** Lines between the title and the first section (the note). */
143
+ intro: string[];
144
+ sections: Section[];
145
+ }
146
+ export declare function parsePage(content: string): ParsedPage;
147
+ export declare function renderPage(p: ParsedPage): string;
148
+ /** Metadata of an entry written by an agent, or null for text written by people. */
149
+ export declare function entryMeta(line: string): {
150
+ topic?: string;
151
+ at?: string;
152
+ run?: string;
153
+ agent?: string;
154
+ } | null;
155
+ export declare function newPage(ref: PageRef, opts?: KnowledgeOptions, now?: Date): ParsedPage;
156
+ export type PageWriteResult = {
157
+ ok: true;
158
+ path: string;
159
+ content: string;
160
+ baseVersion: string | number | null;
161
+ nextVersion: number;
162
+ created: boolean;
163
+ section: 'fresh' | 'proposals' | 'forgotten';
164
+ removed: number;
165
+ } | {
166
+ ok: false;
167
+ error: string;
168
+ problems: string[];
169
+ };
170
+ /** Adds an entry checked by Memory → Check Write to its page (or makes the page). The store writes `content` only if the page still has `baseVersion`. */
171
+ export declare function writeEntry(write: PageWrite, page: Page | null | undefined, opts?: KnowledgeOptions, limits?: KnowledgeLimits, now?: Date): PageWriteResult;
172
+ /** Wiki links of a page: [[target]] or [[target|label]]; the target without ".md". */
173
+ export declare function linksOf(text: string): string[];
174
+ /** What goes into the prompt: the pages of the agent's roles and circles (and, with linkDepth 1, pages they link to), within the size limit. */
175
+ export declare function selectKnowledge(pagesIn: unknown, ctx: {
176
+ bundle: ContextBundle;
177
+ circles?: CircleInfo[] | null;
178
+ opts?: KnowledgeOptions;
179
+ limits?: KnowledgeLimits;
180
+ }): {
181
+ knowledge: KnowledgePage[];
182
+ linked: string[];
183
+ missing: PageRef[];
184
+ omitted: number;
185
+ };
186
+ /** Whether the agent of this bundle may curate the page: its own role's page, or a page of its circle (with Curating Role, only that role). */
187
+ export declare function mayCurate(bundle: ContextBundle, ref: Pick<PageRef, 'entity' | 'uuid'>, circles: CircleInfo[] | null | undefined, opts?: KnowledgeOptions): {
188
+ ok: boolean;
189
+ reason: string;
190
+ };
191
+ /** The prompt for the curation of one page: sort the new entries in, merge, link, drop what is outdated or a rule. */
192
+ export declare function buildCurationPrompt(input: {
193
+ page: Page;
194
+ bundle: ContextBundle;
195
+ circles?: CircleInfo[] | null;
196
+ existing?: Array<{
197
+ path: string;
198
+ name?: string;
199
+ }> | null;
200
+ opts?: KnowledgeOptions;
201
+ limits?: KnowledgeLimits;
202
+ }): {
203
+ ok: true;
204
+ systemPrompt: string;
205
+ task: string;
206
+ ref: PageRef;
207
+ } | {
208
+ ok: false;
209
+ error: string;
210
+ };
211
+ export type CurationResult = {
212
+ ok: true;
213
+ path: string;
214
+ content: string;
215
+ baseVersion: string | number | null;
216
+ nextVersion: number;
217
+ added: number;
218
+ deleted: number;
219
+ deletedPct: number;
220
+ } | {
221
+ ok: false;
222
+ error: string;
223
+ problems: string[];
224
+ };
225
+ /** Checks the page a model returned from a curation; only what it adds is checked for persons, secrets and the company's terms. */
226
+ export declare function checkCuration(old: Page, answer: string, ctx: {
227
+ policy?: MemoryPolicy;
228
+ opts?: KnowledgeOptions;
229
+ limits?: KnowledgeLimits;
230
+ existingPaths?: string[] | null;
231
+ now?: Date;
232
+ }): CurationResult;
233
+ export interface LintResult {
234
+ /** Pages due for curation: too many new entries, new entries older than curateAfterDays, or too big. */
235
+ curate: Array<{
236
+ path: string;
237
+ entity: PageEntity;
238
+ uuid: string;
239
+ name: string;
240
+ fresh: number;
241
+ proposals: number;
242
+ chars: number;
243
+ }>;
244
+ /** Pages of roles or circles that no longer exist (with Known UUIDs). */
245
+ orphaned: string[];
246
+ /** Pages without a uuid in their frontmatter. */
247
+ invalid: string[];
248
+ brokenLinks: Array<{
249
+ path: string;
250
+ link: string;
251
+ }>;
252
+ /** Rows of the same path (two writers made the page at once); keep the highest version. */
253
+ duplicates: string[];
254
+ }
255
+ /** For a scheduler: which pages to curate, archive or repair. */
256
+ export declare function lintPages(pagesIn: unknown, ctx?: {
257
+ knownUuids?: string[] | null;
258
+ limits?: KnowledgeLimits;
259
+ now?: Date;
260
+ }): LintResult;
261
+ export {};