@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.
- package/README.md +225 -2
- package/dist/lib/knowledge.d.ts +261 -0
- package/dist/lib/knowledge.js +615 -0
- package/dist/lib/knowledge.js.map +1 -0
- package/dist/lib/memory.d.ts +152 -0
- package/dist/lib/memory.js +382 -0
- package/dist/lib/memory.js.map +1 -0
- package/dist/lib/prompt.d.ts +12 -0
- package/dist/lib/prompt.js +58 -1
- package/dist/lib/prompt.js.map +1 -1
- package/dist/lib/settings.d.ts +20 -0
- package/dist/lib/settings.js +20 -0
- package/dist/lib/settings.js.map +1 -1
- package/dist/nodes/RoleAlpha/RoleAlpha.node.js +390 -0
- package/dist/nodes/RoleAlpha/RoleAlpha.node.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,14 @@ next run follows. You don't edit code and you don't republish anything.
|
|
|
48
48
|
- **Workflows that follow the organisation.** When a step is created or changed in roleALPHA,
|
|
49
49
|
or an entity a workflow is bound to changes or is removed, a model proposes what that means for the n8n workflows. The
|
|
50
50
|
proposal becomes an inactive draft, and only a person filling the deciding role can apply it.
|
|
51
|
+
- **Memory that belongs to the role.** What an agent learns is kept for its role, without
|
|
52
|
+
approval. Give the role to another agent and the memory goes with it. Who decides and who
|
|
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.
|
|
51
59
|
- **Limits you can change without republishing.** Retries, wait times, run time and tool
|
|
52
60
|
calls come from a settings table and are clamped to fixed bounds.
|
|
53
61
|
|
|
@@ -109,13 +117,20 @@ Scheduler (cron) Event router (one webhook)
|
|
|
109
117
|
├ Settings: Resolve (limits from the settings table)
|
|
110
118
|
├ Wait: Check Start (lease, duplicate-run guard)
|
|
111
119
|
├ Share: Build Input → model → Share: Check (cached)
|
|
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)
|
|
112
123
|
├ roleALPHA: Build System Prompt
|
|
113
124
|
├ AI Agent (+ data tool limited to the domains of the agent's roles,
|
|
114
|
-
│ + roleALPHA: Tool, read only, as the agent
|
|
125
|
+
│ + roleALPHA: Tool, read only, as the agent,
|
|
126
|
+
│ + remember → Memory: Check Write → add row,
|
|
127
|
+
│ or → read page → Memory: Write Page → store page)
|
|
115
128
|
└ Wait: Plan After Run (done row, wake-ups, lease released)
|
|
116
129
|
|
|
117
130
|
Scheduler, every tick
|
|
118
131
|
└ Wait: Find Stale Waits → wake (claimed) · remove dead leases · escalate → Get Circle Lead
|
|
132
|
+
└ Memory: Consolidate → delete replaced, forgotten and expired facts
|
|
133
|
+
└ Memory: Lint Pages → per page due: Build Curation Prompt → model → Check Curation → store page
|
|
119
134
|
```
|
|
120
135
|
|
|
121
136
|
**Every read is the agent's own.** With **Connect As: Agent** the node swaps the function
|
|
@@ -331,6 +346,188 @@ agent that fills the role. Give these steps custom IDs of one prefix, e.g.
|
|
|
331
346
|
`automation:workflow-detect` and `automation:workflow-propose`, and name the prefix in **Own Step
|
|
332
347
|
Prefixes** on *Propose* (default `automation:`). They then never reach the model.
|
|
333
348
|
|
|
349
|
+
## Memory of roles
|
|
350
|
+
|
|
351
|
+
An agent that runs every month starts every month from nothing, unless it can keep what it
|
|
352
|
+
learned. Here that memory belongs to the **role**, not to the agent. The agent itself carries
|
|
353
|
+
only identity and technology; its work comes from its roles, and so does what it remembers.
|
|
354
|
+
Give the role *Controlling* to another agent, and the new agent knows what the old one
|
|
355
|
+
learned. An agent that no longer fills a role no longer sees its memory.
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
Runner
|
|
359
|
+
├ data table: Get rows (Agent Memory)
|
|
360
|
+
├ Memory: Select only roles the agent fills now (from its bundle), this step and
|
|
361
|
+
│ these records, the newest fact of each topic, within the limits
|
|
362
|
+
├ Build System Prompt Memory = output of Select: rules for remembering, and the facts
|
|
363
|
+
└ AI Agent
|
|
364
|
+
└ tool remember {fact, role?, scope?, topic?, forget?}
|
|
365
|
+
└ Memory: Check Write → ok: add row · not ok: the reason goes back to the model
|
|
366
|
+
Scheduler
|
|
367
|
+
└ Memory: Consolidate → delete the rows in remove
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Without approval, so the checks decide.** A fact is kept at once; otherwise memory would be
|
|
371
|
+
of no use in daily work. That is why **Check Write** decides what may be kept at all:
|
|
372
|
+
|
|
373
|
+
- Only for a role the agent fills in this run, read from its bundle. Circles and roles the
|
|
374
|
+
agent only reaches through other links do not count, and neither does a role the model
|
|
375
|
+
names on its own.
|
|
376
|
+
- One short fact per call (500 characters). `scope` is `role` (default), `step` (only on this
|
|
377
|
+
step) or `records` (only for these records of this step).
|
|
378
|
+
- A `topic` groups facts: a newer fact on the same role, step, records and topic replaces the
|
|
379
|
+
older one, and `forget` hides the topic. Rows are only ever added; **Consolidate** removes
|
|
380
|
+
what was replaced, forgotten or has expired, and keeps at most `keepMemoryFacts` per role.
|
|
381
|
+
- Secrets (keys, tokens, passwords) are always refused.
|
|
382
|
+
- **What else is never kept, each company decides** in *What Is Never Kept*, since it runs
|
|
383
|
+
its own n8n: e-mail addresses, UUIDs, phone numbers and the names of the persons who fill
|
|
384
|
+
the roles of the step are refused by default. **Blocked Terms** take words such as customer
|
|
385
|
+
names, matched as whole words in any case; an expression can read them from your CRM.
|
|
386
|
+
**Blocked Patterns** take regular expressions, e.g. for an IBAN. The guardrails of the agent
|
|
387
|
+
in roleALPHA still apply: the prompt tells the model not to remember anything they forbid.
|
|
388
|
+
|
|
389
|
+
**Memory is data.** The prompt lists the facts with role, scope and date as notes from earlier
|
|
390
|
+
runs, not as instructions; guardrails, policies and the current step win. The rules tell the
|
|
391
|
+
model never to remember who decides or fills a role: that is read from roleALPHA on every run.
|
|
392
|
+
Something that should change how a role works is not a fact to remember but a change of the
|
|
393
|
+
role or step, proposed as a draft.
|
|
394
|
+
|
|
395
|
+
**Setting it up**
|
|
396
|
+
|
|
397
|
+
1. Create a data table *Agent Memory* with the columns `role_uuid, step_uuid, record_keys,
|
|
398
|
+
topic, fact, agent_uuid, run_id, at, expires_at`.
|
|
399
|
+
2. In the runner, read the rows (all, or those whose `role_uuid` is one of the agent's
|
|
400
|
+
roles), run **Memory: Select** and pass its output to **Build System Prompt → Memory**.
|
|
401
|
+
3. Give the AI Agent a tool `remember`: a sub-workflow that gets `fact`, `role`, `scope`,
|
|
402
|
+
`topic` and `forget` from the model and bundle, step, record keys and run ID from the
|
|
403
|
+
runner, runs **Memory: Check Write** and adds `row` when `ok` is true. It returns the
|
|
404
|
+
result, so the model learns why a fact was refused.
|
|
405
|
+
4. In the scheduler, run **Memory: Consolidate** on all rows and delete the rows in `remove`.
|
|
406
|
+
Pass the role UUIDs that still exist as **Known Role UUIDs** to remove the memory of
|
|
407
|
+
roles that are gone.
|
|
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
|
+
|
|
334
531
|
## Nodes
|
|
335
532
|
|
|
336
533
|
### roleALPHA (`roleAlpha`)
|
|
@@ -350,12 +547,21 @@ Prefixes** on *Propose* (default `automation:`). They then never reach the model
|
|
|
350
547
|
| Responsibility | Get Circle Lead | One item per circle of the agent's roles: the role that leads the circle and its holders, e.g. to escalate to. Recognised from a lead flag on the role, else "Lead Link" in its purpose, else a custom ID ending in `:lead`, else the role that decides on or is accountable for the circle. `lead` is null when none is found. | MCP OAuth2 |
|
|
351
548
|
| Responsibility | Get Role Holders | Returns the persons (with address) and agents filling a role. | MCP OAuth2 |
|
|
352
549
|
| Tool | Call Tool / List Tools | Calls one roleALPHA MCP tool from an allow list, e.g. as the read tool of an AI agent. Tool name `list` returns the allowed tools with their arguments; the organisation is added. Errors come back as data, a refused run ends it. | MCP OAuth2 |
|
|
353
|
-
| Prompt | Build System Prompt | Builds the system prompt from the bundle, the step, the duties and the trigger. Everything in the bundle's context that is not a role (OKRs, projects, processes, competences, risks, IT systems, …) goes under *Further context*, with the attributes of its link and each value cut to 1,500 characters; the current step is not listed twice. Event data is passed as data, never as instructions. With a **Share** it adds the agent's part, what is not its part, the rules for waiting within the step, and returns `task` as the user message. | – |
|
|
550
|
+
| Prompt | Build System Prompt | Builds the system prompt from the bundle, the step, the duties and the trigger. Everything in the bundle's context that is not a role (OKRs, projects, processes, competences, risks, IT systems, …) goes under *Further context*, with the attributes of its link and each value cut to 1,500 characters; the current step is not listed twice. Event data is passed as data, never as instructions. With a **Share** it adds the agent's part, what is not its part, the rules for waiting within the step, and returns `task` as the user message. With **Memory** (output of Memory → Select, also when empty) it adds the rules for remembering and what the agent's roles remember. | – |
|
|
354
551
|
| Share | Build Input | Prepares the model call that decides the agent's part of a step: only the accountabilities of its own roles count, the other responsible roles of the step are listed with theirs. Returns `systemMessage`, `prompt` and `schema` for a structured output parser. Needs Get Step with Role Details. | – |
|
|
355
552
|
| Share | Check | Checks the model answer against roleALPHA: drops duties that are no accountability of the agent and needs on roles that are not on the step. Returns `duties` (with `needs`), `notMine`, `waitsFor` and `waitRoleUuids`. | – |
|
|
356
553
|
| Wait | Plan After Run | Decides what follows a run on a step from the stored wait rows: the `done` row to add, which waiting agents of the same step to wake (their awaited role just delivered), which rows to remove, and which waits are stuck at the attempt limit. Covers a result that arrived while the agent was deciding to wait. | – |
|
|
357
554
|
| Wait | Check Start | Duplicate-run guard. After the runner added a lease row for its run (`state = running`), the oldest live lease of the same agent, step and records wins. A later start does not run; it returns a `queueRow` that runs when the busy run ends. Leases older than the run timeout are dead and released. Fail-closed when the own lease is missing. | – |
|
|
358
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). | – |
|
|
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. | – |
|
|
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`. | – |
|
|
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. | – |
|
|
359
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. | – |
|
|
360
566
|
| Schedule | Is Due | Decides from the step `frequency` (and `termin` / due date) whether a run is due in the current period. | – |
|
|
361
567
|
|
|
@@ -418,6 +624,16 @@ with `scope = global` applies to every run. `step` (target: step UUID or custom
|
|
|
418
624
|
| `runTimeoutMinutes` | 15 | 1–120 | A run older than this counts as dead; its lease is released |
|
|
419
625
|
| `escalate` | true | – | Report stuck waits to the role that leads the circle |
|
|
420
626
|
| `shareCacheHours` | 24 | 0–720 | Reuse a share decision while step, roles and trigger kind stay the same (0 = never) |
|
|
627
|
+
| `maxMemoryFacts` | 30 | 0–200 | Remembered facts in one prompt (0 = none) |
|
|
628
|
+
| `maxMemoryChars` | 4000 | 0–20000 | Characters of all remembered facts in one prompt |
|
|
629
|
+
| `memoryTtlDays` | 180 | 1–3650 | Days a remembered fact counts; a shorter value also applies to older facts |
|
|
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 |
|
|
421
637
|
|
|
422
638
|
A row with a value outside the bounds is clamped and reported. A wrong row can make the
|
|
423
639
|
runner more careful, never unbounded.
|
|
@@ -442,6 +658,13 @@ record_keys, event, run_id, attempts, progress, at`.
|
|
|
442
658
|
change since. The approval link is a signed one-time token for one person and one decision;
|
|
443
659
|
Check Approver decides at use whether that person may still decide.
|
|
444
660
|
- Duplicate runs are blocked by leases, and wake-ups are claimed before they fire.
|
|
661
|
+
- Memory belongs to roles the agent fills in the run; secrets are never kept, and what else is
|
|
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.
|
|
445
668
|
- No credentials are kept in wait, settings or cache rows. The share cache key holds no
|
|
446
669
|
record content, and a cached answer is checked again like a fresh one.
|
|
447
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 {};
|