@plurnk/plurnk-service 0.43.0 → 0.44.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/.env.example +1 -5
- package/SPEC.md +33 -28
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +12 -11
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +16 -21
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/schemes/Exec.d.ts +0 -1
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +2 -1
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/File.d.ts +0 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +2 -1
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Known.d.ts +0 -1
- package/dist/schemes/Known.d.ts.map +1 -1
- package/dist/schemes/Known.js +2 -1
- package/dist/schemes/Known.js.map +1 -1
- package/dist/schemes/Log.d.ts +0 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +2 -1
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Plurnk.d.ts +0 -1
- package/dist/schemes/Plurnk.d.ts.map +1 -1
- package/dist/schemes/Plurnk.js +2 -1
- package/dist/schemes/Plurnk.js.map +1 -1
- package/dist/schemes/Run.d.ts +0 -1
- package/dist/schemes/Run.d.ts.map +1 -1
- package/dist/schemes/Run.js +2 -1
- package/dist/schemes/Run.js.map +1 -1
- package/dist/schemes/Unknown.d.ts +0 -1
- package/dist/schemes/Unknown.d.ts.map +1 -1
- package/dist/schemes/Unknown.js +2 -1
- package/dist/schemes/Unknown.js.map +1 -1
- package/dist/server/methods/loop_run.d.ts.map +1 -1
- package/dist/server/methods/loop_run.js +4 -0
- package/dist/server/methods/loop_run.js.map +1 -1
- package/package.json +6 -6
- package/requirements.md +2 -1
package/.env.example
CHANGED
|
@@ -119,11 +119,6 @@ PLURNK_SESSION_RUNS_MAX_ACTIVE=-1
|
|
|
119
119
|
# adaptive / no cap, N = capped at N tokens. Provider modules translate it per model
|
|
120
120
|
# family (reasoning_effort tiers, budget_tokens). Floor (gemma): 0.
|
|
121
121
|
PLURNK_PROVIDERS_REASONING_BUDGET=-1
|
|
122
|
-
#
|
|
123
|
-
# Planning: enable the grammar's <<PLAN:...:PLAN op so the model reasons in-band before
|
|
124
|
-
# acting. A shared universal knob (like PLURNK_FETCH_TIMEOUT below): the service advertises
|
|
125
|
-
# the op in # Plurnk System Tools; the provider reads it too. =1 on, =0 off.
|
|
126
|
-
PLURNK_PLAN=0
|
|
127
122
|
# Service-wide fetch timeout in ms — the universal upper bound on any
|
|
128
123
|
# single outbound request (provider calls, future http:// scheme reads,
|
|
129
124
|
# anything that does network IO). Streamed completions can run long;
|
|
@@ -141,6 +136,7 @@ PLURNK_VERSION_POLL_TTL=3600000
|
|
|
141
136
|
# A bare name (plurnk.gbnf) is a variant shipped by
|
|
142
137
|
# @plurnk/plurnk-grammar; an absolute/relative path is your own. =0 (or empty) disables.
|
|
143
138
|
# PLURNK_PROVIDERS_GBNF=plurnk.gbnf
|
|
139
|
+
|
|
144
140
|
# Provider retry attempts (providers 0.7+): how many times generate() retries a
|
|
145
141
|
# TRANSIENT failure (429 rate-limit, 5xx/network) with exponential backoff (base 2s
|
|
146
142
|
# is a provider constant — the COUNT is the operator knob). REQUIRED, fail-hard if
|
package/SPEC.md
CHANGED
|
@@ -72,7 +72,7 @@ Independent axes on entries and channels. Confusion across them is a recurring s
|
|
|
72
72
|
| Term | Meaning |
|
|
73
73
|
|---|---|
|
|
74
74
|
| **packet** | The turn's full exchange shape: `{system, user, assistant, assistantRaw}`. Persisted on `turns.packet`. |
|
|
75
|
-
| **log** | `
|
|
75
|
+
| **log** | the `log` section. Chronological list of `log_entries` in scope this turn. |
|
|
76
76
|
| **render** | The act of computing the packet from current DB state at turn boundaries. Mimetype handlers fire at render time. |
|
|
77
77
|
|
|
78
78
|
### §test-taxonomy Test taxonomy
|
|
@@ -206,7 +206,7 @@ Plus immutable identity: `provider.contextSize` (token total, or `null` → "no
|
|
|
206
206
|
|
|
207
207
|
### §provider-guarantees Engine → provider guarantees
|
|
208
208
|
|
|
209
|
-
- `messages` is a complete prompt (
|
|
209
|
+
- `messages` is a complete prompt (the section list, pre-assembled into the system + user messages). Provider does not reorder.
|
|
210
210
|
- `signal` is wired to the run's AbortController. {§provider-guarantees-signal-wired}
|
|
211
211
|
- `generate` is single-call per turn. No parallel calls on the same instance. {§provider-guarantees-single-call}
|
|
212
212
|
- `assistantRaw` is opaque to the engine (forensics-only). {§provider-guarantees-assistantraw-opaque}
|
|
@@ -306,7 +306,7 @@ Engine → scheme guarantees:
|
|
|
306
306
|
- `ctx.writer` reflects the actual writer at this dispatch.
|
|
307
307
|
- `manifest.writableBy` checked BEFORE invocation; engine returns 403 directly on exclusion. {§scheme-surface-writableby-403}
|
|
308
308
|
- `ctx.signal` is wired to the run's AbortController (§provider-guarantees-signal-wired).
|
|
309
|
-
- Scheme exceptions become the action-entry's outcome (status 500); summary surfaces in next turn's `
|
|
309
|
+
- Scheme exceptions become the action-entry's outcome (status 500); summary surfaces in next turn's `errors` section (§telemetry). {§scheme-surface-exception-500}
|
|
310
310
|
|
|
311
311
|
**Tokenization participation.** Schemes route writes through the shared `_entry-crud.ts` write helper (in plurnk-service today; migrates to plurnk-schemes). Helper populates `entry_channels.tokens` at write time via `ctx.provider.countTokens` (§tokenomics-tokens-stored-at-write). Raw DB writes bypass tokenization — out of API scope.
|
|
312
312
|
|
|
@@ -562,7 +562,7 @@ A side-effecting op does not execute on dispatch — it **proposes**. The scheme
|
|
|
562
562
|
|
|
563
563
|
A caller-supplied `outcome` overrides the default, but `outcome` is **forensics-only** — never in the model-facing `rx`. So a YOLO accept, a human reject, and a timeout are indistinguishable to the model: the action **occurred** (200) or it **didn't** (400/499), nothing about how it was administratively resolved (§telemetry).
|
|
564
564
|
|
|
565
|
-
**A proposed row is invisible until it resolves.** A `state='proposed'` / 202 row is withheld from `
|
|
565
|
+
**A proposed row is invisible until it resolves.** A `state='proposed'` / 202 row is withheld from the `log` section; it surfaces only after resolution, carrying its terminal status — the model sees outcomes, never pending proposals. {§proposal-proposed-hidden}
|
|
566
566
|
|
|
567
567
|
---
|
|
568
568
|
|
|
@@ -586,7 +586,7 @@ SSE event types, WS message types, exec stdout/stderr each map to a named channe
|
|
|
586
586
|
|
|
587
587
|
Channels are the source of truth for chunk content. Log captures lifecycle events only: open (102), graceful close (200), cancel (499), errors (5xx), scheme-significant transitions. {§no-chunk-rows-log-captures-lifecycle-only}
|
|
588
588
|
|
|
589
|
-
Model sees lifecycle events in `
|
|
589
|
+
Model sees lifecycle events in the `log` section per turn.
|
|
590
590
|
|
|
591
591
|
### §deep-slices Deep slices on demand
|
|
592
592
|
|
|
@@ -682,7 +682,7 @@ Plugin discovery (§plugin-discovery) registers whatever's in `node_modules/@plu
|
|
|
682
682
|
| `Unknown.ts` | `@plurnk/plurnk-schemes-unknown` | Open questions / decomposition. |
|
|
683
683
|
| `Skill.ts` | `@plurnk/plurnk-schemes-skill` | Skill docs; same shape as known. |
|
|
684
684
|
| `Plurnk.ts` | may stay in-tree | `plurnk:///prompt/<loop_id>` carries each loop's prompt. Model-origin writes to `plurnk:///prompt/*` rejected in-handler. |
|
|
685
|
-
| `Log.ts` | may stay in-tree | Read-only coordinate-addressed (`log:///<L>/<T>/<S>`). Renders as JSON meta line in
|
|
685
|
+
| `Log.ts` | may stay in-tree | Read-only coordinate-addressed (`log:///<L>/<T>/<S>`). Renders as a JSON meta line in the `log` section; status ≥ 400 mirrors to the `errors` section (§telemetry). |
|
|
686
686
|
| `File.ts` | `@plurnk/plurnk-schemes-file` | Filesystem-backed. **Model is never trained on `file:///` and never sees it.** Bare paths are model-facing; `file:///` accepted as input, renders bare. |
|
|
687
687
|
| `Exec.ts` | stays in-tree | Dispatches EXEC op to runtime executors registered via [plurnk-execs](https://github.com/plurnk/plurnk-execs). |
|
|
688
688
|
|
|
@@ -998,15 +998,15 @@ Pre-stabilization. Clients track HEAD. No semver until the interface is worth co
|
|
|
998
998
|
|
|
999
999
|
Each entry: question, answer, rationale, migration path.
|
|
1000
1000
|
|
|
1001
|
-
### §packet-assembly Packet assembly: engine
|
|
1001
|
+
### §packet-assembly Packet assembly: engine builds the default list, plugins transform it
|
|
1002
1002
|
|
|
1003
|
-
**Question.** Rummy uses priority-ordered filter chains for packet assembly. Plurnk
|
|
1003
|
+
**Question.** Rummy uses priority-ordered filter chains for packet assembly. Plurnk builds a default ordered section list directly in `Engine.#buildRequestPacket`, then lets trusted plugins rewrite it.
|
|
1004
1004
|
|
|
1005
|
-
**Decision.**
|
|
1005
|
+
**Decision.** Two stages. (1) The engine builds the default section list — the kernel sections `definition`, `tools`, `schemes`, `log` (system slot), then `prompt`, `budget`, `errors`, `git`, `requirements` (user slot). (2) `SchemeRegistry.transformSections` pipes that list through every registered scheme that implements `transformSections(sections) → sections`, in registration order, before the engine measures. A plugin returns whatever list it wants — add, remove, reorder. {§packet-plugin-transform}
|
|
1006
1006
|
|
|
1007
|
-
**
|
|
1007
|
+
**Why a whole-list transform, not a per-section hook.** It is the legible, fork-avoiding seam: a plugin that can reshape the packet to its needs never has a reason to fork the engine (§ecosystem). And it is **strictly in-process and trusted** (behind `PLURNK_PLUGINS_TRUSTED_ONLY`) — the client/RPC wire never reaches the packet, because handing an untrusted connection the model's entire context is exactly the actor-boundary violation the engine exists to prevent. Pure list-in/list-out; no context is handed to plugins.
|
|
1008
1008
|
|
|
1009
|
-
**
|
|
1009
|
+
**Rationale.** The section list is first-class data (not two hardcoded render functions), so the transform is a few lines over the existing registry-pull pattern (the engine already pulls the scheme catalogue and the tools sheet from the registries). The grinder/fold (§grinder) stays engine-owned — a closed build-time concern, never a plugin seam.
|
|
1010
1010
|
|
|
1011
1011
|
### §tokenomics Tokenomics: real provider tokens, render-weight budget, turn and entry weights
|
|
1012
1012
|
|
|
@@ -1143,35 +1143,34 @@ The CAS is the **hard backstop**, at the moment of writing, on every accept path
|
|
|
1143
1143
|
|
|
1144
1144
|
## §packet Packet shape
|
|
1145
1145
|
|
|
1146
|
-
|
|
1146
|
+
**Service-owned.** grammar 0.67 deleted `Packet.json` — the protocol scoped itself to the grammar, so the packet shape is now entirely plurnk-service's. The engine assembles it in `Engine.#buildRequestPacket` as an **ordered list of sections** that trusted plugins may rewrite (§packet-assembly).
|
|
1147
1147
|
|
|
1148
1148
|
```ts
|
|
1149
|
+
type PacketSection = {
|
|
1150
|
+
name: string; // stable id: definition, tools, schemes, log, prompt, budget, errors, git, requirements — or a plugin's own
|
|
1151
|
+
slot: "system" | "user"; // the prompt-cache boundary; system-slot sections build the cache-stable system message
|
|
1152
|
+
header: string | null; // "# Plurnk System X", or null (definition renders verbatim)
|
|
1153
|
+
content: string; // rendered markdown — what the model saw
|
|
1154
|
+
tokens: number; // measured render-weight
|
|
1155
|
+
};
|
|
1149
1156
|
type Packet = {
|
|
1150
1157
|
tokens: number;
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
system_definition: string;
|
|
1154
|
-
index: PacketEntry[]; // visible entries (§mimetype / §channels)
|
|
1155
|
-
log: PacketLogRow[]; // chronological action-entries (§stream)
|
|
1156
|
-
};
|
|
1157
|
-
user: {
|
|
1158
|
-
tokens: number;
|
|
1159
|
-
prompt: string;
|
|
1160
|
-
telemetry: { budget: string; errors: object[] }; // §telemetry
|
|
1161
|
-
system_requirements: string; // §requirements
|
|
1162
|
-
};
|
|
1158
|
+
sections: PacketSection[]; // the ordered, plugin-overridable list; the wire renders it by slot
|
|
1159
|
+
telemetryErrors: object[]; // structured telemetry events — the `errors` section's source; ephemeral (the packet is their only home, §telemetry)
|
|
1163
1160
|
assistant: { tokens: number; content: string; ops: PlurnkStatement[]; reasoning: string | null };
|
|
1164
1161
|
assistantRaw: unknown;
|
|
1165
1162
|
};
|
|
1166
1163
|
```
|
|
1167
1164
|
|
|
1168
|
-
|
|
1165
|
+
The wire projection (`PacketWire.renderSlot`) groups sections by slot into the system + user ChatMessages; the digest re-renders the same stored sections byte-for-byte.
|
|
1166
|
+
|
|
1167
|
+
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a plurnk-origin `EDIT` against `plurnk:///prompt/<loop_id>` (indexable, body channel, text/markdown). At render time the current loop's prompt body materializes into the `prompt` section; the entry itself stays READ/FOLD-able like any other. The foisted `EDIT`'s **log row is folded by default** (`expanded=0`): the prompt body already lives in the `prompt` section, so the log keeps the action for forensics while collapsing the duplicate body, re-OPENable like any fold (§open-fold). {§prompt-fold}
|
|
1169
1168
|
|
|
1170
1169
|
**The entry catalog.** `plurnk:///manifest.json` is a real session entry the model READs to discover what's available — rewritten every turn as a live view of the full entry set. Built in the schemes layer (`_entry-manifest`) and materialized like any entry (the engine only orchestrates the per-turn write — the same pattern as git membership), so it's READable and queryable. Body is `application/json`: a flat, **complete, unranked** array — one item per entry across all schemes, every entry listed in no relevance order, each `{ path, tags?, channels: { <name>: { mimetype, tokens, lines } } }`. `tags` is present only when the entry carries `entry_tags` — its own categorization, surfaced so the model sees it in the directory and can `FIND` by tag without a separate read. The model ranks and filters the catalog itself by querying it (task-aware); the catalog never ranks for it — the instant it did, it would be an index again. `tokens` is the provider's write-time count (budget depth), `lines` the content extent from `Mimetypes.process().totalLines`. The engine counts neither. It does not list itself. {§packet-manifest-catalog}
|
|
1171
1170
|
|
|
1172
1171
|
### §telemetry user.telemetry — model-facing runtime telemetry
|
|
1173
1172
|
|
|
1174
|
-
|
|
1173
|
+
Telemetry the model MUST react to immediately. Errors render in their own `errors` section (§packet-assembly unbundled them from a single telemetry block) — transient, appearing on the turn AFTER the failure, clearing once seen. The `log` section is the durable audit; the `errors` section (rendered from `packet.telemetryErrors`) is the **alert**.
|
|
1175
1174
|
|
|
1176
1175
|
**Grammar contract:**
|
|
1177
1176
|
|
|
@@ -1199,7 +1198,7 @@ Strike accounting, cycle detection, sudden-death thresholds, and no-ops bookkeep
|
|
|
1199
1198
|
|
|
1200
1199
|
**No `error://` scheme.** Actionless failures route to telemetry, not a queryable scheme namespace.
|
|
1201
1200
|
|
|
1202
|
-
**Client surface: `telemetry/event` notification.** Every event the engine pushes to the loop's telemetry buffer also broadcasts live via the `telemetry/event` WS notification. Same envelope on both sides — `{ source, kind, message?, position?, …kind-specific }` per the grammar's `TelemetryEvent` schema. The model sees the event on the NEXT packet's `
|
|
1201
|
+
**Client surface: `telemetry/event` notification.** Every event the engine pushes to the loop's telemetry buffer also broadcasts live via the `telemetry/event` WS notification. Same envelope on both sides — `{ source, kind, message?, position?, …kind-specific }` per the grammar's `TelemetryEvent` schema. The model sees the event on the NEXT packet's `errors` section (drains on read); the client sees it the moment it lands. Client uses cases: render parse errors in a debug panel (the `snippet` field is content the model emitted), surface strike/sudden_death as "loop is degrading" toasts, log everything to a session timeline. Scoped to the loop's session. {§telemetry-telemetry-event-notify}
|
|
1203
1202
|
|
|
1204
1203
|
**Content-offset snippet rendering.** When telemetry carries `position: { type: "content-offset", line, column }`, plurnk-service extracts a ±N-line slice from the model's own prior `assistant.content` and renders it as an `N:\t`-prefixed heredoc under an `error://<line>` fence, immediately following the event meta line. Without the snippet, the model gets "invalid xpath at 1:0" with no way to trace what it wrote at 1:0 — and tends to regenerate the same broken emission. With it, recovery is direct (canonical case: the edit-todo demo where a READ body starting with `//` got xpath-dispatched). The snippet field is stripped from the meta JSON so it appears once, in the body block. {§telemetry-content-offset-snippet}
|
|
1205
1204
|
|
|
@@ -1209,7 +1208,13 @@ A `# Plurnk System Tools` section renders **above** `# Plurnk System Requirement
|
|
|
1209
1208
|
|
|
1210
1209
|
**Contributors: the wired executor tags.** Each available executor tag injects a line describing its tag and functionality (the boot `ExecutorRegistry` probes availability per tag), retiring the model's blind `<<EXEC[sh]…`. The plan directive does **not** render here: it is a hard requirement gated by `PLURNK_PLAN`, joined to and dropped from the rules list with the flag rather than softly advertised as an optional tool (§requirements-plan-gated).
|
|
1211
1210
|
|
|
1212
|
-
### §
|
|
1211
|
+
### §schemes user.schemes — the scheme directory
|
|
1212
|
+
|
|
1213
|
+
A `# Plurnk System Schemes` section renders in the system slot **after the definition (plurnk.md — grammar + imperatives) and the tools sheet** — a terse directory of the scheme families available this session, so the model knows what URI schemes exist before it acts. Each scheme that ships a `manifest.example` contributes ONE line — its canonical usage — plus a `(docs: plurnk://docs/<scheme>.md)` pointer when it ships `manifest.documentation`. The verbose per-scheme semantics live in that pull doc (materialized like any entry, READ on demand), not the hot path — terse pushes, depth pulls, mirroring the tools sheet (§tools). A scheme with no example (provisional) is omitted. {§schemes-directory}
|
|
1214
|
+
|
|
1215
|
+
**The scheme self-doc contract.** `example` is the hot-path one-liner; `documentation` is the deep doc — the exact shape execs already use (`example` + `documentation`). `SchemeRegistry.teach()` renders the directory; `docEntries()` materializes the docs (per loop.run, alongside the operator docs). `documentation` rides a service-side `SchemeManifest` extension until plurnk-schemes#25 lands it in the contract.
|
|
1216
|
+
|
|
1217
|
+
### §requirements The requirements section — static per-turn rules
|
|
1213
1218
|
|
|
1214
1219
|
Rendered at the END of the user packet under `# Plurnk System Requirements` {§requirements-requirements-render-last} — closest to the assistant turn so the contract the model has to honor is the most recent text it sees. The header is omitted entirely when the requirements string is empty. {§requirements-requirements-omitted-when-empty} Contains rules the grammar block doesn't cover (canonical example: "Conclude the loop with `<<SEND[200]:answer:SEND`"). The op syntax leads the section, and when `PLURNK_PLAN=1` the plan directive — *YOU MUST begin every response with `<<PLAN:...:PLAN`* — joins the rules: a hard requirement dynamically added to and removed from the list with the flag, never the soft optional-tools sheet. {§requirements-plan-gated}
|
|
1215
1220
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../src/core/Engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAwF,MAAM,wBAAwB,CAAC;AAMpJ,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,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B,KAAK,IAAI,GAAG,IAAI;CAsgB3E"}
|
package/dist/core/Engine.js
CHANGED
|
@@ -850,10 +850,10 @@ class Engine {
|
|
|
850
850
|
// the stored packet and the wire payload share one source of truth.
|
|
851
851
|
async #buildRequestPacket({ initialMessages, requirements, runId, loopId, currentTurnSeq, provider, gitStatus, telemetryErrors: presetTelemetry, }) {
|
|
852
852
|
const byRole = (role) => initialMessages.filter((m) => m.role === role).map((m) => m.content).join("\n\n");
|
|
853
|
-
// plurnk.md (grammar/dialects
|
|
854
|
-
// scheme
|
|
855
|
-
//
|
|
856
|
-
const system_definition =
|
|
853
|
+
// plurnk.md (grammar/dialects only — grammar 0.49+ is scheme-agnostic). The
|
|
854
|
+
// scheme catalogue is now its OWN section (`schemes`, below tools), so the
|
|
855
|
+
// definition is just the operator's system prompt — tools sits right below it.
|
|
856
|
+
const system_definition = byRole("system");
|
|
857
857
|
// the prompt section sources from the loop's most recent prompt entry first
|
|
858
858
|
// (plurnk:///prompt/<loop_id>/<N> for the highest N written to date).
|
|
859
859
|
// This is what inject + the turn-1 foist write into. Falls back to
|
|
@@ -888,20 +888,21 @@ class Engine {
|
|
|
888
888
|
const ceiling = _a.computeCeiling(provider.contextSize, this.#budgetCeiling);
|
|
889
889
|
const budgetReadout = this.#renderBudget(PacketWire.measureLogBudget(log, countTokens), ceiling);
|
|
890
890
|
// The default packet: an ordered list of sections, each addressable state
|
|
891
|
-
// (§packet-construction). `slot` is the prompt-cache boundary;
|
|
892
|
-
//
|
|
893
|
-
// the
|
|
894
|
-
//
|
|
895
|
-
//
|
|
896
|
-
// total is known.
|
|
891
|
+
// (§packet-construction). `slot` is the prompt-cache boundary; the STATIC
|
|
892
|
+
// sections (definition, tools, schemes) lead the system slot so they form the
|
|
893
|
+
// cached prefix, with the dynamic log after. In the user slot, requirements renders
|
|
894
|
+
// last (the contract closest to the assistant turn); budget/errors/git are
|
|
895
|
+
// peer sections (unbundled). The budget section carries its {{tokensFree}}
|
|
896
|
+
// placeholders here; they resolve below once the assembled total is known.
|
|
897
897
|
const defaults = [
|
|
898
898
|
{ name: "definition", slot: "system", header: null, content: system_definition, tokens: 0 },
|
|
899
|
+
{ name: "tools", slot: "system", header: "Plurnk System Tools", content: tools.join("\n"), tokens: 0 },
|
|
900
|
+
{ name: "schemes", slot: "system", header: "Plurnk System Schemes", content: this.#schemes.teach(), tokens: 0 },
|
|
899
901
|
{ name: "log", slot: "system", header: "Plurnk System Log", content: PacketWire.renderLog(log), tokens: 0 },
|
|
900
902
|
{ name: "prompt", slot: "user", header: "Plurnk System User Prompt", content: prompt, tokens: 0 },
|
|
901
903
|
{ name: "budget", slot: "user", header: "Plurnk System Budget", content: budgetReadout, tokens: 0 },
|
|
902
904
|
{ name: "errors", slot: "user", header: "Plurnk System Errors", content: PacketWire.renderErrors(telemetryErrors), tokens: 0 },
|
|
903
905
|
{ name: "git", slot: "user", header: "Plurnk System Git Status", content: PacketWire.renderGit(gitStatus), tokens: 0 },
|
|
904
|
-
{ name: "tools", slot: "user", header: "Plurnk System Tools", content: tools.join("\n"), tokens: 0 },
|
|
905
906
|
{ name: "requirements", slot: "user", header: "Plurnk System Requirements", content: requirementsText, tokens: 0 },
|
|
906
907
|
];
|
|
907
908
|
// Plugin packet control (§packet-construction): trusted schemes rewrite the
|