@rolealpha/n8n-nodes-rolealpha 0.10.0 → 0.12.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 +165 -1
- package/dist/lib/agentRun.d.ts +38 -1
- package/dist/lib/agentRun.js +66 -1
- package/dist/lib/agentRun.js.map +1 -1
- 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 +15 -1
- package/dist/lib/memory.js +62 -5
- package/dist/lib/memory.js.map +1 -1
- package/dist/lib/pricing.d.ts +53 -0
- package/dist/lib/pricing.js +112 -0
- package/dist/lib/pricing.js.map +1 -0
- package/dist/lib/prompt.d.ts +9 -2
- package/dist/lib/prompt.js +37 -4
- package/dist/lib/prompt.js.map +1 -1
- package/dist/lib/settings.d.ts +12 -0
- package/dist/lib/settings.js +12 -0
- package/dist/lib/settings.js.map +1 -1
- package/dist/nodes/RoleAlpha/RoleAlpha.node.js +353 -27
- package/dist/nodes/RoleAlpha/RoleAlpha.node.js.map +1 -1
- package/package.json +1 -1
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,20 @@ 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)
|
|
128
|
+
├ roleALPHA: Report Usage (tokens, model, cost of this run → agent budget)
|
|
120
129
|
└ Wait: Plan After Run (done row, wake-ups, lease released)
|
|
121
130
|
|
|
122
131
|
Scheduler, every tick
|
|
123
132
|
└ Wait: Find Stale Waits → wake (claimed) · remove dead leases · escalate → Get Circle Lead
|
|
124
133
|
└ Memory: Consolidate → delete replaced, forgotten and expired facts
|
|
134
|
+
└ Memory: Lint Pages → per page due: Build Curation Prompt → model → Check Curation → store page
|
|
125
135
|
```
|
|
126
136
|
|
|
127
137
|
**Every read is the agent's own.** With **Connect As: Agent** the node swaps the function
|
|
@@ -131,6 +141,20 @@ see, without admin rights and without a key per agent in n8n. **Start Run** swap
|
|
|
131
141
|
returns a refusal as data (`code`, `reaction`): an agent that is paused, over budget or not
|
|
132
142
|
bound to the account does not run. There is no fallback to the view of the account.
|
|
133
143
|
|
|
144
|
+
**The run reports what it consumed.** **Report Usage** sends the tokens, the model and the cost of
|
|
145
|
+
this run to roleALPHA, for the budget of the agent: once the budget of the period is used up, the
|
|
146
|
+
next **Start Run** is refused with `agent_budget_erschoepft`. It reports with the function account,
|
|
147
|
+
not the run token, so the run that used the budget up still gets through. Report the totals of the
|
|
148
|
+
run; reporting the same run again replaces the previous report.
|
|
149
|
+
|
|
150
|
+
**The cost is yours to calculate.** With your own AI key the price depends on your contract, so
|
|
151
|
+
roleALPHA does not price runs. Pass your prices as **Price Rows** (one row per model, per million
|
|
152
|
+
tokens: `model, input, cacheRead, cacheWrite, output, currency, asOf` — e.g. all rows of a data
|
|
153
|
+
table). A model without a row is reported with tokens only and counts as "without a price" in
|
|
154
|
+
roleALPHA, never as 0. Only reports in the tenant's budget currency (USD by default) count
|
|
155
|
+
against the budget. A refusal comes back as data (`usage.reported: false`, `code`, `reaction`);
|
|
156
|
+
`stopReporting` means demand planning is not enabled in the organisation.
|
|
157
|
+
|
|
134
158
|
Approval gates follow this order: **Get Decider → Check Approver → Approval Seal: Sign**. The
|
|
135
159
|
workflow that sends runs **Approval Seal: Verify** first and stops if the content changed.
|
|
136
160
|
|
|
@@ -397,6 +421,128 @@ role or step, proposed as a draft.
|
|
|
397
421
|
Pass the role UUIDs that still exist as **Known Role UUIDs** to remove the memory of
|
|
398
422
|
roles that are gone.
|
|
399
423
|
|
|
424
|
+
## Knowledge of roles and circles
|
|
425
|
+
|
|
426
|
+
Memory rows are notes on the work in progress: they belong to a step or to records and expire.
|
|
427
|
+
What a role learns for good is something else: how the work is done well, what worked, what
|
|
428
|
+
was observed. That is knowledge of the organisation. It belongs to the role, or to the circle
|
|
429
|
+
when it holds for its other roles too, and people should be able to read, link and correct it.
|
|
430
|
+
So it is kept as **Markdown pages with YAML frontmatter**, one per role and one per circle: a
|
|
431
|
+
small wiki the roles keep themselves.
|
|
432
|
+
|
|
433
|
+
As with the rows, the package keeps no page itself. It decides; the workflow reads and writes
|
|
434
|
+
with ordinary n8n nodes. It sees a page only as `{ path, content, version }`, where `version`
|
|
435
|
+
is whatever the store uses to notice a concurrent change. Typical stores:
|
|
436
|
+
|
|
437
|
+
| Store | Read | Write | `version` |
|
|
438
|
+
| --- | --- | --- | --- |
|
|
439
|
+
| **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`) |
|
|
440
|
+
| **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 |
|
|
441
|
+
| **Folder** (a mounted vault, e.g. Obsidian or Tolaria) | Read Files from Disk | Write Files from Disk | modification time |
|
|
442
|
+
|
|
443
|
+
A data table for pages needs the columns `path, entity, uuid, name, content, version`. With
|
|
444
|
+
Git, any editor that reads Markdown with wiki links shows the pages; a Tolaria or Obsidian
|
|
445
|
+
vault of its own works as is. Give the store to the agents alone: a repository or vault with
|
|
446
|
+
meeting or sales notes in it is the wrong place.
|
|
447
|
+
|
|
448
|
+
**A page**
|
|
449
|
+
|
|
450
|
+
```markdown
|
|
451
|
+
---
|
|
452
|
+
type: Rollenwissen
|
|
453
|
+
schema: rolealpha-knowledge/1
|
|
454
|
+
entity: role
|
|
455
|
+
uuid: e31893c0-…
|
|
456
|
+
name: "Kampagnenmanagement"
|
|
457
|
+
updated: 2026-11-22T10:00:00.000Z
|
|
458
|
+
---
|
|
459
|
+
# Kampagnenmanagement – Wissen
|
|
460
|
+
|
|
461
|
+
> Erfahrung dieser Rolle aus ihrer Arbeit. Keine Regeln: Verbindliches steht in roleALPHA.
|
|
462
|
+
|
|
463
|
+
## Neu
|
|
464
|
+
- Beiträge mit einer Zahl im ersten Satz werden seltener abgelehnt. <!-- ra:{"at":"…","topic":"einstieg","run":"68266","agent":"…"} -->
|
|
465
|
+
|
|
466
|
+
## Kampagnenformate
|
|
467
|
+
- …
|
|
468
|
+
|
|
469
|
+
## Vorschläge für roleALPHA
|
|
470
|
+
- Jeder Beitrag muss eine Kampagne nennen. <!-- ra:{…} -->
|
|
471
|
+
|
|
472
|
+
## Siehe auch
|
|
473
|
+
- [[circles/<uuid>|Marketing – Kreiswissen]]
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
The path follows the UUID (`roles/<uuid>.md`, `circles/<uuid>.md`; **Path Template** in the
|
|
477
|
+
Knowledge Options), so a page survives a renamed role; its title and `name` follow the name.
|
|
478
|
+
Headings come in German or English (**Language**); pages in either are read. Entries of agents
|
|
479
|
+
carry their metadata in an HTML comment, so a newer fact on the same topic replaces the older
|
|
480
|
+
one and a topic can be forgotten; text people write needs none and stays.
|
|
481
|
+
|
|
482
|
+
**Who writes what**
|
|
483
|
+
|
|
484
|
+
- **Remember** writes, as before, through **Check Write**. With **Knowledge Pages** on, scope
|
|
485
|
+
`role` (the default) goes to the page of the role and scope `circle` to the page of its
|
|
486
|
+
circle; `step` and `records` stay rows. The same checks apply: a role the agent fills, a
|
|
487
|
+
circle one of its roles is in (from **Get Circle Lead**, or reached in the bundle), no
|
|
488
|
+
secrets, persons, contact data or the company's blocked terms. **Write Page** adds the entry
|
|
489
|
+
under "Neu" and returns the whole new page with the version it is based on.
|
|
490
|
+
- **Curation** sorts the new entries into topics, merges and links them, and drops what is
|
|
491
|
+
outdated or contradicts a policy: the wiki part. The page of a role is curated only by an
|
|
492
|
+
agent that fills the role; the page of a circle by any role of the circle, or with
|
|
493
|
+
**Curating Role** only by that one. **Lint Pages** names the pages that are due (`maxNewEntries`
|
|
494
|
+
new entries, new entries older than `knowledgeCurateDays`, or larger than `maxPageChars`).
|
|
495
|
+
**Build Curation Prompt** gives the model the page, the policies of the curating agent and
|
|
496
|
+
the pages it may link to; **Check Curation** applies the answer only when the frontmatter is
|
|
497
|
+
kept, nothing it adds names a person, contact data, a secret or a blocked term, no rule is
|
|
498
|
+
added, every link points to a page that exists and no more than `maxCurationDeletePct` of the
|
|
499
|
+
curated text is gone.
|
|
500
|
+
- **People** edit pages in their editor or the data table. Nothing they write is checked or
|
|
501
|
+
removed by an agent unless it duplicates an entry or contradicts a policy, and every change
|
|
502
|
+
is in the history of the store.
|
|
503
|
+
|
|
504
|
+
**Knowledge and policies stay apart.** Policies, accountabilities and process steps are
|
|
505
|
+
binding and live in roleALPHA; they change only by an approved draft. Knowledge says how a role
|
|
506
|
+
does its work well and changes without approval. The package holds the line:
|
|
507
|
+
|
|
508
|
+
| | Policy, accountability, step (roleALPHA) | Knowledge (pages) |
|
|
509
|
+
| --- | --- | --- |
|
|
510
|
+
| Says | what has to be, what is to be done | what worked, what was observed |
|
|
511
|
+
| Changes | by a draft a person approves | without approval, in the store's history |
|
|
512
|
+
| In the prompt | binding, wins | experience, data, not instructions |
|
|
513
|
+
|
|
514
|
+
- A fact with a **normative term** (`muss`, `darf nicht`, `verboten`, `must`, `must not`,
|
|
515
|
+
`shall`, `not allowed`, …; your own list in **Normative Terms**) goes to "Vorschläge für
|
|
516
|
+
roleALPHA" / "Proposals for roleALPHA". That section never reaches the prompt. A curation
|
|
517
|
+
either rephrases it as experience or leaves it for the role that proposes changes of roles
|
|
518
|
+
and policies in roleALPHA.
|
|
519
|
+
- A curation may not add normative statements outside the proposals (**Allow Rules in
|
|
520
|
+
Curation** turns this off), is told never to copy a policy into a page and to drop entries
|
|
521
|
+
that contradict one.
|
|
522
|
+
- The prompt lists knowledge after the binding parts and says that policies, accountabilities
|
|
523
|
+
and the current step win; when a page contradicts them, the agent follows roleALPHA and
|
|
524
|
+
forgets the outdated topic.
|
|
525
|
+
|
|
526
|
+
**Into the prompt.** **Locate Pages** gives the paths of the agent's pages; read them, pass
|
|
527
|
+
them to **Select Pages** and its output to **Build System Prompt → Knowledge**. Only pages
|
|
528
|
+
whose frontmatter names the role or circle count, so a page at the wrong path is not read.
|
|
529
|
+
With `knowledgeLinkDepth` 1, `linked` names the pages they link to; read those too and run
|
|
530
|
+
Select Pages again with all of them.
|
|
531
|
+
|
|
532
|
+
**Setting it up**
|
|
533
|
+
|
|
534
|
+
1. Pick a store and create it (data table with the columns above, a repository, a folder).
|
|
535
|
+
2. In the runner, after Get Context: **Get Circle Lead** for the agent, **Locate Pages**, read
|
|
536
|
+
the pages, **Select Pages**, and pass it to **Build System Prompt → Knowledge**.
|
|
537
|
+
3. In the `remember` sub-workflow: **Check Write** with **Knowledge Pages** on and the circles;
|
|
538
|
+
when `target` is `page`, read the page at `page.path`, run **Write Page** and write
|
|
539
|
+
`content` if the page still has `baseVersion`. If it changed meanwhile, read it again and
|
|
540
|
+
run Write Page again: entries are only added, nothing is lost.
|
|
541
|
+
4. In the scheduler: read all pages, **Lint Pages**; for each page in `curate`, start a run of
|
|
542
|
+
an agent that may curate it with **Build Curation Prompt**, then **Check Curation** on its
|
|
543
|
+
answer and write `content`. Move `orphaned` pages to an archive.
|
|
544
|
+
5. Use the same Knowledge Options in every node.
|
|
545
|
+
|
|
400
546
|
## Nodes
|
|
401
547
|
|
|
402
548
|
### roleALPHA (`roleAlpha`)
|
|
@@ -405,6 +551,7 @@ role or step, proposed as a draft.
|
|
|
405
551
|
|---|---|---|---|
|
|
406
552
|
| Agent | Get Context | Reads an agent's context bundle (identity, roles, guardrails). Fails if the agent is not `active` or has no policy, unless you switch that off. Over MCP it reads the `agent` view by default, exactly what the agent gets over its own key. | MCP OAuth2 (default) or roleALPHA Agent Keys API |
|
|
407
553
|
| Agent | Get Context Version | Change check. Cheap and not audited with agent keys; over MCP it reads the bundle. | MCP OAuth2 or roleALPHA Agent Keys API |
|
|
554
|
+
| Agent | Report Usage | Reports the tokens, model and cost of this run for the agent's budget, with the function account. The cost comes from your **Price Rows** (or **Cost**); without a matching row only tokens are sent. Returns `usage` with `reported`, `counted`, `period`, or `code` and `reaction` of the refusal. | MCP OAuth2 with client credentials |
|
|
408
555
|
| Agent | Start Run | Swaps the function account token for a run token of the agent (`agent:run`). Returns `started`, or `code` and `reaction` of the refusal (`pause`, `pauseUntilNextPeriod`, `informAdmin`, `retryLater`, …). The token never appears in the output. | MCP OAuth2 with client credentials |
|
|
409
556
|
| Agent | List Agents | Over MCP: every agent of the organisation, paged. With agent keys: one item per key. By default it skips agents that are not active. | MCP OAuth2 or roleALPHA Agent Keys API |
|
|
410
557
|
| Responsibility | Get Duties | Lists the steps the agent's roles are `RESPONSIBLE_FOR`, with the circle. | MCP OAuth2 |
|
|
@@ -424,6 +571,12 @@ role or step, proposed as a draft.
|
|
|
424
571
|
| 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
572
|
| 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
573
|
| 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`. | – |
|
|
574
|
+
| 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`. | – |
|
|
575
|
+
| 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`. | – |
|
|
576
|
+
| 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). | – |
|
|
577
|
+
| 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. | – |
|
|
578
|
+
| 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`. | – |
|
|
579
|
+
| Memory | Lint Pages | For a scheduler: `curate` (pages due), `orphaned` (with **Known Role UUIDs**, roles and circles), `invalid`, `duplicates` and `brokenLinks`. | – |
|
|
427
580
|
| 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
581
|
| 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
582
|
| Schedule | Is Due | Decides from the step `frequency` (and `termin` / due date) whether a run is due in the current period. | – |
|
|
@@ -491,6 +644,12 @@ with `scope = global` applies to every run. `step` (target: step UUID or custom
|
|
|
491
644
|
| `maxMemoryChars` | 4000 | 0–20000 | Characters of all remembered facts in one prompt |
|
|
492
645
|
| `memoryTtlDays` | 180 | 1–3650 | Days a remembered fact counts; a shorter value also applies to older facts |
|
|
493
646
|
| `keepMemoryFacts` | 200 | 10–2000 | Facts kept per role in the store (Consolidate) |
|
|
647
|
+
| `maxKnowledgeChars` | 6000 | 0–40000 | Characters of all knowledge pages in one prompt |
|
|
648
|
+
| `maxPageChars` | 12000 | 2000–100000 | Size of a page before it is curated; a write is refused beyond twice this size |
|
|
649
|
+
| `maxNewEntries` | 20 | 1–500 | New entries on a page from which it is curated |
|
|
650
|
+
| `knowledgeCurateDays` | 7 | 1–90 | Days after which new entries are curated even below `maxNewEntries` |
|
|
651
|
+
| `maxCurationDeletePct` | 30 | 0–100 | Share of the curated text one curation may delete |
|
|
652
|
+
| `knowledgeLinkDepth` | 0 | 0–1 | 1: pages linked from the own pages go into the prompt too |
|
|
494
653
|
|
|
495
654
|
A row with a value outside the bounds is clamped and reported. A wrong row can make the
|
|
496
655
|
runner more careful, never unbounded.
|
|
@@ -517,6 +676,11 @@ record_keys, event, run_id, attempts, progress, at`.
|
|
|
517
676
|
- Duplicate runs are blocked by leases, and wake-ups are claimed before they fire.
|
|
518
677
|
- Memory belongs to roles the agent fills in the run; secrets are never kept, and what else is
|
|
519
678
|
never kept each company sets itself. Remembered facts reach the prompt as data, with limits.
|
|
679
|
+
- Knowledge pages are written only for roles the agent fills and circles of these roles, read
|
|
680
|
+
only when their frontmatter names them, and curated only by an agent of that role or circle.
|
|
681
|
+
What an agent or a curation adds is checked like a remembered fact; a rule never becomes
|
|
682
|
+
knowledge. A store with history keeps what was forgotten, so persons and secrets are refused
|
|
683
|
+
before they are written.
|
|
520
684
|
- No credentials are kept in wait, settings or cache rows. The share cache key holds no
|
|
521
685
|
record content, and a cached answer is checked again like a fresh one.
|
|
522
686
|
|
package/dist/lib/agentRun.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface FunctionAccount {
|
|
|
20
20
|
authentication?: 'header' | 'body';
|
|
21
21
|
}
|
|
22
22
|
/** What the runner does on a refusal. The code decides, never the text. */
|
|
23
|
-
export type Reaction = 'fixConfig' | 'informAdmin' | 'removeAgent' | 'pause' | 'pauseUntilNextPeriod' | 'retryLater' | 'renewAccountToken' | 'endRun';
|
|
23
|
+
export type Reaction = 'fixConfig' | 'informAdmin' | 'removeAgent' | 'pause' | 'pauseUntilNextPeriod' | 'retryLater' | 'renewAccountToken' | 'endRun' | 'stopReporting';
|
|
24
24
|
export declare function reactionFor(code: string, status?: number): Reaction;
|
|
25
25
|
export declare class AgentRunError extends Error {
|
|
26
26
|
readonly code: string;
|
|
@@ -44,7 +44,36 @@ export interface RunToken {
|
|
|
44
44
|
name: string | null;
|
|
45
45
|
};
|
|
46
46
|
runId: string;
|
|
47
|
+
/** Where this run's usage is reported (`usage_url` of the exchange); absent on older servers. */
|
|
48
|
+
usageUrl?: string;
|
|
47
49
|
}
|
|
50
|
+
/** What one run consumed. Tokens are the run's totals; `cost` only from the runner's own pricing. */
|
|
51
|
+
export interface UsageReport {
|
|
52
|
+
agentUuid: string;
|
|
53
|
+
runId: string;
|
|
54
|
+
model?: string;
|
|
55
|
+
inputTokens?: number;
|
|
56
|
+
cacheReadTokens?: number;
|
|
57
|
+
cacheWriteTokens?: number;
|
|
58
|
+
outputTokens?: number;
|
|
59
|
+
/** With `currency` and `priceKind`. Without a cost the run counts as "without a price", never as 0. */
|
|
60
|
+
cost?: number;
|
|
61
|
+
currency?: string;
|
|
62
|
+
/** `tabelle`: the runner's own price table. `listenpreis`: the SDK's list price. */
|
|
63
|
+
priceKind?: 'tabelle' | 'listenpreis';
|
|
64
|
+
priceSource?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface UsageReceipt {
|
|
67
|
+
runId: string;
|
|
68
|
+
periodYear: number;
|
|
69
|
+
period: string;
|
|
70
|
+
/** Whether the run counts against the budget (priced, in the budget currency). */
|
|
71
|
+
counted: boolean;
|
|
72
|
+
budgetCurrency: string;
|
|
73
|
+
}
|
|
74
|
+
/** The reporting endpoint next to the token endpoint — used when the exchange did not name one. */
|
|
75
|
+
export declare const USAGE_PATH = "/api/agent-lauf/verbrauch";
|
|
76
|
+
export declare function defaultUsageUrl(tokenUrl: string): string;
|
|
48
77
|
export interface TokenStore {
|
|
49
78
|
accounts: Map<string, Cached>;
|
|
50
79
|
runs: Map<string, RunToken>;
|
|
@@ -64,6 +93,14 @@ export declare class AgentRunTokens {
|
|
|
64
93
|
runToken(a: FunctionAccount, agentUuid: string, runId: string, opts?: {
|
|
65
94
|
fresh?: boolean;
|
|
66
95
|
}): Promise<RunToken>;
|
|
96
|
+
/**
|
|
97
|
+
* Reports what one run consumed — with the ACCOUNT token, not the run token: once the budget is
|
|
98
|
+
* spent a new swap fails, and the run that spent it must still be able to report. Each report of
|
|
99
|
+
* the same run replaces the previous one, so report the run's running total, as often as useful.
|
|
100
|
+
*/
|
|
101
|
+
reportUsage(a: FunctionAccount, report: UsageReport, usageUrl?: string): Promise<UsageReceipt>;
|
|
102
|
+
/** The usage URL the exchange named for this run, if its token is still cached in this process. */
|
|
103
|
+
usageUrlFor(a: FunctionAccount, agentUuid: string, runId: string): string | undefined;
|
|
67
104
|
/** Forgets a run token, e.g. after the MCP endpoint refused it. */
|
|
68
105
|
forget(a: FunctionAccount, agentUuid: string, runId: string): void;
|
|
69
106
|
private prune;
|
package/dist/lib/agentRun.js
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* Tokens stay in memory only and are never written to node output.
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.AgentRunTokens = exports.PROCESS_STORE = exports.TOKEN_TYPE_ACCESS = exports.GRANT_TOKEN_EXCHANGE = exports.AgentRunError = void 0;
|
|
11
|
+
exports.AgentRunTokens = exports.PROCESS_STORE = exports.USAGE_PATH = exports.TOKEN_TYPE_ACCESS = exports.GRANT_TOKEN_EXCHANGE = exports.AgentRunError = void 0;
|
|
12
12
|
exports.reactionFor = reactionFor;
|
|
13
13
|
exports.isValidRunId = isValidRunId;
|
|
14
|
+
exports.defaultUsageUrl = defaultUsageUrl;
|
|
14
15
|
exports.mcpRefusalCode = mcpRefusalCode;
|
|
15
16
|
const REACTIONS = {
|
|
16
17
|
agent_uuid_fehlt: 'fixConfig',
|
|
@@ -33,6 +34,11 @@ const REACTIONS = {
|
|
|
33
34
|
falsche_resource: 'renewAccountToken',
|
|
34
35
|
funktionskonto_unbekannt: 'renewAccountToken',
|
|
35
36
|
secret_widerrufen: 'renewAccountToken',
|
|
37
|
+
// Reporting usage (reportUsage).
|
|
38
|
+
meldung_ungueltig: 'fixConfig',
|
|
39
|
+
planung_nicht_lizenziert: 'stopReporting',
|
|
40
|
+
planung_nicht_erreichbar: 'retryLater',
|
|
41
|
+
installation_nicht_erreichbar: 'retryLater',
|
|
36
42
|
};
|
|
37
43
|
function reactionFor(code, status = 0) {
|
|
38
44
|
return REACTIONS[code] ?? (status === 401 ? 'renewAccountToken' : status >= 500 || status === 429 ? 'retryLater' : 'endRun');
|
|
@@ -61,6 +67,30 @@ exports.TOKEN_TYPE_ACCESS = 'urn:ietf:params:oauth:token-type:access_token';
|
|
|
61
67
|
function isValidRunId(runId) {
|
|
62
68
|
return RUN_ID.test(runId);
|
|
63
69
|
}
|
|
70
|
+
/** The reporting endpoint next to the token endpoint — used when the exchange did not name one. */
|
|
71
|
+
exports.USAGE_PATH = '/api/agent-lauf/verbrauch';
|
|
72
|
+
function defaultUsageUrl(tokenUrl) {
|
|
73
|
+
return new URL(exports.USAGE_PATH, tokenUrl).toString();
|
|
74
|
+
}
|
|
75
|
+
function usageForm(r) {
|
|
76
|
+
const form = { agent_uuid: r.agentUuid.trim().toLowerCase(), run_id: r.runId };
|
|
77
|
+
const put = (k, v) => {
|
|
78
|
+
if (v !== undefined && v !== null && v !== '')
|
|
79
|
+
form[k] = String(v);
|
|
80
|
+
};
|
|
81
|
+
put('model', r.model);
|
|
82
|
+
put('input_tokens', r.inputTokens);
|
|
83
|
+
put('cache_read_tokens', r.cacheReadTokens);
|
|
84
|
+
put('cache_write_tokens', r.cacheWriteTokens);
|
|
85
|
+
put('output_tokens', r.outputTokens);
|
|
86
|
+
if (r.cost !== undefined) {
|
|
87
|
+
put('cost', r.cost);
|
|
88
|
+
put('currency', r.currency);
|
|
89
|
+
put('price_kind', r.priceKind);
|
|
90
|
+
}
|
|
91
|
+
put('price_source', r.priceSource);
|
|
92
|
+
return form;
|
|
93
|
+
}
|
|
64
94
|
function parse(body) {
|
|
65
95
|
try {
|
|
66
96
|
const v = JSON.parse(body);
|
|
@@ -141,10 +171,45 @@ class AgentRunTokens {
|
|
|
141
171
|
expiresAt: this.now() + (Number(b.expires_in) || 900) * 1000,
|
|
142
172
|
agent: { uuid: agent, name: typeof named.name === 'string' ? named.name : null },
|
|
143
173
|
runId,
|
|
174
|
+
...(typeof b.usage_url === 'string' && b.usage_url ? { usageUrl: b.usage_url } : {}),
|
|
144
175
|
};
|
|
145
176
|
this.runs.set(key, token);
|
|
146
177
|
return token;
|
|
147
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Reports what one run consumed — with the ACCOUNT token, not the run token: once the budget is
|
|
181
|
+
* spent a new swap fails, and the run that spent it must still be able to report. Each report of
|
|
182
|
+
* the same run replaces the previous one, so report the run's running total, as often as useful.
|
|
183
|
+
*/
|
|
184
|
+
async reportUsage(a, report, usageUrl) {
|
|
185
|
+
if (!UUID.test(report.agentUuid.trim()))
|
|
186
|
+
throw new AgentRunError('agent_uuid_fehlt', 400, `Not an agent UUID: "${report.agentUuid}"`);
|
|
187
|
+
if (!isValidRunId(report.runId))
|
|
188
|
+
throw new AgentRunError('run_id_ungueltig', 400, 'Run ID: 1-128 characters of A-Z a-z 0-9 . _ : -');
|
|
189
|
+
if (report.cost !== undefined && (!report.currency || !report.priceKind)) {
|
|
190
|
+
throw new AgentRunError('meldung_ungueltig', 400, 'A cost needs currency and priceKind');
|
|
191
|
+
}
|
|
192
|
+
const url = usageUrl ?? defaultUsageUrl(a.tokenUrl);
|
|
193
|
+
const form = usageForm(report);
|
|
194
|
+
const send = async (fresh) => this.post(url, form, { Authorization: `Bearer ${await this.accountToken(a, fresh)}` });
|
|
195
|
+
let reply = await send(false);
|
|
196
|
+
if (reply.status !== 200 && reactionFor(refusal(reply).code, reply.status) === 'renewAccountToken')
|
|
197
|
+
reply = await send(true);
|
|
198
|
+
if (reply.status !== 200)
|
|
199
|
+
throw refusal(reply);
|
|
200
|
+
const b = parse(reply.body);
|
|
201
|
+
return {
|
|
202
|
+
runId: String(b.run_id ?? report.runId),
|
|
203
|
+
periodYear: Number(b.period_year),
|
|
204
|
+
period: String(b.period ?? ''),
|
|
205
|
+
counted: b.counted === true,
|
|
206
|
+
budgetCurrency: String(b.budget_currency ?? ''),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/** The usage URL the exchange named for this run, if its token is still cached in this process. */
|
|
210
|
+
usageUrlFor(a, agentUuid, runId) {
|
|
211
|
+
return this.runs.get(`${this.accountKey(a)}|${agentUuid.trim().toLowerCase()}|${runId}`)?.usageUrl;
|
|
212
|
+
}
|
|
148
213
|
/** Forgets a run token, e.g. after the MCP endpoint refused it. */
|
|
149
214
|
forget(a, agentUuid, runId) {
|
|
150
215
|
this.runs.delete(`${this.accountKey(a)}|${agentUuid.trim().toLowerCase()}|${runId}`);
|
package/dist/lib/agentRun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentRun.js","sourceRoot":"","sources":["../../l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