@plurnk/plurnk-service 0.59.0 → 0.61.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 +41 -3
- package/PLURNK_PERSONALITY.md +61 -0
- package/SPEC.md +54 -45
- package/dist/core/Dispatcher.d.ts +61 -0
- package/dist/core/Dispatcher.d.ts.map +1 -0
- package/dist/core/Dispatcher.js +811 -0
- package/dist/core/Dispatcher.js.map +1 -0
- package/dist/core/Engine.d.ts +10 -45
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +269 -1489
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +55 -12
- package/dist/core/ExecutorRegistry.d.ts +2 -1
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +16 -3
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +64 -0
- package/dist/core/PacketBuilder.d.ts.map +1 -0
- package/dist/core/PacketBuilder.js +365 -0
- package/dist/core/PacketBuilder.js.map +1 -0
- package/dist/core/ProposalLifecycle.d.ts +56 -0
- package/dist/core/ProposalLifecycle.d.ts.map +1 -0
- package/dist/core/ProposalLifecycle.js +195 -0
- package/dist/core/ProposalLifecycle.js.map +1 -0
- package/dist/core/SchemeRegistry.d.ts +2 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +20 -15
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/StrikeRail.d.ts +27 -0
- package/dist/core/StrikeRail.d.ts.map +1 -0
- package/dist/core/StrikeRail.js +147 -0
- package/dist/core/StrikeRail.js.map +1 -0
- package/dist/core/TelemetryChannel.d.ts +37 -0
- package/dist/core/TelemetryChannel.d.ts.map +1 -0
- package/dist/core/TelemetryChannel.js +77 -0
- package/dist/core/TelemetryChannel.js.map +1 -0
- package/dist/core/fork.d.ts +1 -0
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +17 -4
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +6 -0
- package/dist/core/packet-inject.d.ts.map +1 -1
- package/dist/core/packet-inject.js +8 -3
- package/dist/core/packet-inject.js.map +1 -1
- package/dist/core/packet-wire.d.ts +5 -1
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +53 -19
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/plurnk-uri.d.ts +2 -0
- package/dist/core/plurnk-uri.d.ts.map +1 -1
- package/dist/core/plurnk-uri.js +11 -0
- package/dist/core/plurnk-uri.js.map +1 -1
- package/dist/core/run-cap.js +2 -2
- package/dist/core/run-cap.js.map +1 -1
- package/dist/core/run-ops.sql +21 -0
- package/dist/digest/Digest.d.ts +14 -0
- package/dist/digest/Digest.d.ts.map +1 -0
- package/dist/digest/Digest.js +321 -0
- package/dist/digest/Digest.js.map +1 -0
- package/dist/digest/digest.sql +55 -0
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +23 -24
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/File.js +2 -2
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +5 -1
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Run.d.ts.map +1 -1
- package/dist/schemes/Run.js +27 -27
- package/dist/schemes/Run.js.map +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +5 -1
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-semantic.d.ts.map +1 -1
- package/dist/schemes/_entry-semantic.js +6 -0
- package/dist/schemes/_entry-semantic.js.map +1 -1
- package/dist/server/ClientConnection.d.ts.map +1 -1
- package/dist/server/ClientConnection.js +48 -2
- package/dist/server/ClientConnection.js.map +1 -1
- package/dist/server/Daemon.d.ts +1 -1
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +29 -3
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/drain.sql +14 -0
- package/dist/server/methods/auth.d.ts +6 -0
- package/dist/server/methods/auth.d.ts.map +1 -0
- package/dist/server/methods/auth.js +45 -0
- package/dist/server/methods/auth.js.map +1 -0
- package/dist/server/methods/mcp_install.d.ts +6 -0
- package/dist/server/methods/mcp_install.d.ts.map +1 -0
- package/dist/server/methods/mcp_install.js +66 -0
- package/dist/server/methods/mcp_install.js.map +1 -0
- package/dist/server/methods/op_copy.d.ts.map +1 -1
- package/dist/server/methods/op_copy.js +1 -0
- package/dist/server/methods/op_copy.js.map +1 -1
- package/dist/server/methods/op_dispatch.d.ts.map +1 -1
- package/dist/server/methods/op_dispatch.js +1 -0
- package/dist/server/methods/op_dispatch.js.map +1 -1
- package/dist/server/methods/op_edit.d.ts.map +1 -1
- package/dist/server/methods/op_edit.js +1 -0
- package/dist/server/methods/op_edit.js.map +1 -1
- package/dist/server/methods/op_exec.d.ts.map +1 -1
- package/dist/server/methods/op_exec.js +1 -0
- package/dist/server/methods/op_exec.js.map +1 -1
- package/dist/server/methods/op_move.d.ts.map +1 -1
- package/dist/server/methods/op_move.js +1 -0
- package/dist/server/methods/op_move.js.map +1 -1
- package/dist/server/methods/session_attach.d.ts.map +1 -1
- package/dist/server/methods/session_attach.js +4 -0
- package/dist/server/methods/session_attach.js.map +1 -1
- package/dist/server/methods/session_create.d.ts.map +1 -1
- package/dist/server/methods/session_create.js +4 -0
- package/dist/server/methods/session_create.js.map +1 -1
- package/dist/server/yolo.js +1 -1
- package/dist/server/yolo.js.map +1 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +6 -0
- package/dist/service.js.map +1 -1
- package/docs/run.md +7 -3
- package/migrations/0000-00-00.01_schema.sql +8 -4
- package/package.json +22 -17
- package/requirements.md +6 -9
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { renderAddress } from "./plurnk-uri.js";
|
|
2
|
+
import { teachingLine, docsExcludeSet } from "./teaching.js";
|
|
3
|
+
import { readPacketInject, readSystemPolicy, readProjectPolicy } from "./packet-inject.js";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import Paths from "../Paths.js";
|
|
6
|
+
// Shared module imported by both Engine and bin/digest.ts, so wire
|
|
7
|
+
// projection and digest projection are structurally one function — no
|
|
8
|
+
// drift between wire and digest possible.
|
|
9
|
+
import PacketWire from "./packet-wire.js";
|
|
10
|
+
const DEFAULT_BUDGET_CEILING = 0.9;
|
|
11
|
+
// Substituted into the budget readout after the assembled packet is measured
|
|
12
|
+
// (the figure depends on the packet's own rendered size — chicken/egg).
|
|
13
|
+
const TOKENS_FREE_PLACEHOLDER = "{{tokensFree}}";
|
|
14
|
+
const TOKEN_USAGE_PLACEHOLDER = "{{tokenUsage}}";
|
|
15
|
+
const TOKEN_PERCENT_PLACEHOLDER = "{{tokenPercent}}";
|
|
16
|
+
// PLURNK_BUDGET_CEILING is dual-mode: <=1 is a fraction of the provider's
|
|
17
|
+
// context window, >1 is an absolute token wall — lets a demo pin a tiny
|
|
18
|
+
// ceiling regardless of the model's real window to force the grinder.
|
|
19
|
+
const readCeiling = () => {
|
|
20
|
+
const raw = process.env.PLURNK_BUDGET_CEILING;
|
|
21
|
+
if (raw === undefined || raw.length === 0)
|
|
22
|
+
return DEFAULT_BUDGET_CEILING;
|
|
23
|
+
const n = Number.parseFloat(raw);
|
|
24
|
+
if (!Number.isFinite(n) || n <= 0)
|
|
25
|
+
return DEFAULT_BUDGET_CEILING;
|
|
26
|
+
return n;
|
|
27
|
+
};
|
|
28
|
+
// Packet assembly (SPEC §packet-construction) + the budget grinder (§grinder):
|
|
29
|
+
// builds the spec'd request packet, measures it, and reclaims window on overflow.
|
|
30
|
+
export default class PacketBuilder {
|
|
31
|
+
static computeCeiling(contextSize, config) {
|
|
32
|
+
// Absolute wall (config > 1) is window-independent — the point of the >1
|
|
33
|
+
// mode is to pin a ceiling even when the provider reports no window; cap at
|
|
34
|
+
// the real window when one is known. Ratio mode needs a window to scale.
|
|
35
|
+
if (config > 1)
|
|
36
|
+
return contextSize === null ? Math.floor(config) : Math.min(Math.floor(config), contextSize);
|
|
37
|
+
return contextSize === null ? null : Math.floor(contextSize * config);
|
|
38
|
+
}
|
|
39
|
+
#db;
|
|
40
|
+
#schemes;
|
|
41
|
+
#telemetry;
|
|
42
|
+
// Boot-discovered runtime executors, late-injected on Engine after daemon
|
|
43
|
+
// start() — read through a thunk so the post-construction set is visible.
|
|
44
|
+
#executors;
|
|
45
|
+
#budgetCeiling;
|
|
46
|
+
constructor({ db, schemes, telemetry, executors }) {
|
|
47
|
+
this.#db = db;
|
|
48
|
+
this.#schemes = schemes;
|
|
49
|
+
this.#telemetry = telemetry;
|
|
50
|
+
this.#executors = executors;
|
|
51
|
+
this.#budgetCeiling = readCeiling();
|
|
52
|
+
}
|
|
53
|
+
ceilingFor(provider) {
|
|
54
|
+
return PacketBuilder.computeCeiling(provider.contextSize, this.#budgetCeiling);
|
|
55
|
+
}
|
|
56
|
+
// Assemble the request half of the spec'd packet (Packet.json §system
|
|
57
|
+
// and §user) BEFORE the provider call. The same packet object is then
|
|
58
|
+
// completed with assistant + assistantRaw after the model responds, so
|
|
59
|
+
// the stored packet and the wire payload share one source of truth.
|
|
60
|
+
async buildRequestPacket({ initialMessages, requirements, sessionId, runId, loopId, currentTurnSeq, provider, gitStatus, telemetryErrors: presetTelemetry, }) {
|
|
61
|
+
const byRole = (role) => initialMessages.filter((m) => m.role === role).map((m) => m.content).join("\n\n");
|
|
62
|
+
// plurnk.md (grammar/dialects) ONLY — the definition is the hot-path grammar.
|
|
63
|
+
// The scheme catalogue is its own `schemes` section below tools (§schemes-directory),
|
|
64
|
+
// NOT appended here: grammar 0.49+ is scheme-agnostic, so the service advertises
|
|
65
|
+
// the scheme set at packet-time (grammar#239 item 7) via SchemeRegistry.teach().
|
|
66
|
+
const system_definition = byRole("system");
|
|
67
|
+
// the prompt section sources from the loop's most recent prompt entry first
|
|
68
|
+
// (plurnk:///prompt/<loop_id>/<N> for the highest N written to date).
|
|
69
|
+
// This is what inject + the turn-1 foist write into. Falls back to
|
|
70
|
+
// the runLoop caller's messages.user for tests that bypass the
|
|
71
|
+
// foist mechanism entirely.
|
|
72
|
+
const promptRows = (await this.#db.drain_get_all_prompt_bodies_for_loop.all({ pattern: `/prompt/${loopId}/%` }))
|
|
73
|
+
.filter((r) => typeof r.content === "string" && r.content.length > 0);
|
|
74
|
+
const promptCap = Number.parseInt(process.env.PLURNK_PROMPT_PREVIEW_CHARS ?? "", 10);
|
|
75
|
+
const prompt = promptRows.length > 0
|
|
76
|
+
? PacketWire.renderActivePrompts(promptRows, Number.isInteger(promptCap) ? promptCap : -1)
|
|
77
|
+
: byRole("user");
|
|
78
|
+
// Requirements is engine-sourced, NOT threaded from callers — that threading is
|
|
79
|
+
// exactly how it went missing (callers read the sysprompt but never the
|
|
80
|
+
// requirements). Read Paths.defaultRequirements (PLURNK_REQUIREMENTS env →
|
|
81
|
+
// requirements.md) fresh each build so edits take effect; a non-empty param wins.
|
|
82
|
+
const baseRequirements = requirements.length > 0 ? requirements : await readFile(Paths.defaultRequirements, "utf8");
|
|
83
|
+
// No injected syntax line: the grammar already headlines the system definition (§Syntax) and
|
|
84
|
+
// leads requirements.md, so a third copy here was pure duplication in the model's packet. PLAN
|
|
85
|
+
// is mandated unconditionally by plurnk.md §Imperatives (grammar 0.70 requires every turn to
|
|
86
|
+
// lead with PLAN), so the service injects no separate plan directive either (the former
|
|
87
|
+
// PLURNK_PLAN gating is retired — PLURNK_PLAN is no longer a flag).
|
|
88
|
+
const log = await this.#buildLog(runId);
|
|
89
|
+
const telemetryErrors = presetTelemetry ?? await this.buildTelemetryErrors(loopId, currentTurnSeq);
|
|
90
|
+
const countTokens = (t) => provider.countTokens(t); // §provider-surface-counttokens
|
|
91
|
+
const tools = this.#collectTools();
|
|
92
|
+
// Budget readout (SPEC.md §tokenomics). Two-pass: render the budget from
|
|
93
|
+
// the structured log's subtotals with a {{tokensFree}} placeholder, build
|
|
94
|
+
// the section list, measure the assembled total, resolve free, substitute.
|
|
95
|
+
// Subtotals come from the real log render — meta and fences included — not
|
|
96
|
+
// a serialized approximation. ceiling is the provider's window ×
|
|
97
|
+
// PLURNK_BUDGET_CEILING (null when no window is reported → headline
|
|
98
|
+
// omitted, section lines still shown). §tokenomics-render-weight-budget
|
|
99
|
+
const ceiling = this.ceilingFor(provider);
|
|
100
|
+
const budgetReadout = this.#renderBudget(PacketWire.measureLogBudget(log, countTokens), ceiling);
|
|
101
|
+
// The default packet: an ordered list of addressable sections (§packet-construction).
|
|
102
|
+
// `slot` is a TRUST boundary (and the prompt-cache boundary): system holds only
|
|
103
|
+
// framework-authored, non-injectable sections — the static head (definition/tools/
|
|
104
|
+
// schemes/policy) forms the cached prefix, then the volatile-but-trusted tail of
|
|
105
|
+
// errors/git/budget; user holds injectable content (the log, the operator prompt) plus
|
|
106
|
+
// the requirements footer. The budget section carries its {{tokensFree}} placeholders
|
|
107
|
+
// here; they resolve below once the assembled total is known.
|
|
108
|
+
const inject = await readPacketInject(); // #240 — operator section, per-turn, fail-hard on a broken path
|
|
109
|
+
const sessionRoot = (await this.#db.envelope_get_session.get({ id: sessionId }))?.project_root ?? null;
|
|
110
|
+
const systemPolicy = await readSystemPolicy(); // ~/.plurnk/AGENTS.md (or PLURNK_POLICY)
|
|
111
|
+
const projectPolicy = await readProjectPolicy(sessionRoot); // <projectRoot>/AGENTS.md (or PLURNK_PROJECT)
|
|
112
|
+
// Child-orientation (§child-orientation): the live things THIS run holds — open streams +
|
|
113
|
+
// unconcluded child runs — surfaced every turn as terse `* <status> <path>` pointers (same shape
|
|
114
|
+
// as errors) just above the errors section. Orienting STATE so the model never loses track of
|
|
115
|
+
// what it's holding (the premature-terminate trap), never advice on what to do. Empty → omitted.
|
|
116
|
+
const childStreams = (await this.#db.engine_child_streams_open.all({ run_id: runId }))
|
|
117
|
+
.map((s) => ({ status: "active", path: renderAddress(s.scheme, s.pathname) }));
|
|
118
|
+
const childRuns = (await this.#db.engine_child_runs_live.all({ run_id: runId }))
|
|
119
|
+
.map((r) => ({ status: r.status, path: `run://${r.name}` }));
|
|
120
|
+
const defaults = [
|
|
121
|
+
{ name: "definition", slot: "system", header: null, content: system_definition, tokens: 0 },
|
|
122
|
+
{ name: "tools", slot: "system", header: null, content: tools.join("\n"), tokens: 0 }, // titleless — the examples flow on from plurnk.md (definition) directly above
|
|
123
|
+
{ name: "schemes", slot: "system", header: "Plurnk Service Schemes", content: this.#schemes.teach(), tokens: 0 },
|
|
124
|
+
...(inject !== null ? [{ name: "inject", slot: "system", header: "Plurnk Operator Notes", content: inject, tokens: 0 }] : []),
|
|
125
|
+
// policy: the client's privileged rules — ~/.plurnk/AGENTS.md (system) then <root>/AGENTS.md (project) — below grammar/tools/schemes, above budget-the-law. AGENTS is POLICY here, never a curatable READable entry. Empty content ⇒ section omitted.
|
|
126
|
+
{ name: "system-policy", slot: "system", header: "Plurnk Service Policy", content: systemPolicy ?? "", tokens: 0 },
|
|
127
|
+
{ name: "project-policy", slot: "system", header: "Project Policy", content: projectPolicy ?? "", tokens: 0 },
|
|
128
|
+
// The packet split is a TRUST boundary: system carries only framework-authored, non-injectable
|
|
129
|
+
// sections; anything that could carry attacker-reachable text (a READ result, exec output, the
|
|
130
|
+
// model's own mirrored bytes) stays in user. errors + git are framework status — the errors
|
|
131
|
+
// section is uri+status POINTERS (the error item + body live in the log), git is counts — so
|
|
132
|
+
// neither is an injection surface; both sit at the bottom of system, just above budget-the-law.
|
|
133
|
+
// child-orientation: what THIS run holds live — streams then runs — just above errors. Terse
|
|
134
|
+
// pointers (the path is the actionable address the model READs/OPENs/KILLs), never advice. §child-orientation
|
|
135
|
+
{ name: "child-streams", slot: "system", header: "Plurnk Service Child Streams", content: PacketWire.renderChildPointers(childStreams), tokens: 0 },
|
|
136
|
+
{ name: "child-runs", slot: "system", header: "Plurnk Service Child Runs", content: PacketWire.renderChildPointers(childRuns), tokens: 0 },
|
|
137
|
+
{ name: "errors", slot: "system", header: "Plurnk Service Errors", content: PacketWire.renderErrors(telemetryErrors), tokens: 0 },
|
|
138
|
+
{ name: "git", slot: "system", header: "Plurnk Service Git Status", content: PacketWire.renderGit(gitStatus), tokens: 0 },
|
|
139
|
+
// budget is the very last system line — LAW (a hard ceiling the model must obey), the final word before the model acts.
|
|
140
|
+
{ name: "budget", slot: "system", header: "Plurnk Service Budget", content: budgetReadout, tokens: 0 },
|
|
141
|
+
// log in the user slot: injectable content (READ results, exec output, the model's own mirror) — data, never rules — kept at the action point so the model consults its history.
|
|
142
|
+
{ name: "log", slot: "user", header: "Plurnk Service Log", content: PacketWire.renderLog(log, countTokens), tokens: 0 },
|
|
143
|
+
// the ACTIVE user prompts (all the current loop holds, in order — a loop admits injected
|
|
144
|
+
// prompts) render at the BOTTOM, just above requirements — at the action point, closest to
|
|
145
|
+
// the model's turn. Each is a bare heredoc (the fence is the link); §prompt-fold.
|
|
146
|
+
{ name: "prompt", slot: "user", header: "Plurnk Service Active User Prompts", content: prompt, tokens: 0 },
|
|
147
|
+
// requirements renders LAST — the user-slot footer, the syntax contract closest to the model's turn (a recency carve-out for weak models).
|
|
148
|
+
{ name: "requirements", slot: "user", header: "Plurnk Service Requirements", content: baseRequirements, tokens: 0 },
|
|
149
|
+
];
|
|
150
|
+
// Plugin packet control (§packet-construction): trusted schemes rewrite the
|
|
151
|
+
// default list — add, remove, reorder — in-process, before measurement.
|
|
152
|
+
const sections = await this.#schemes.transformSections(defaults);
|
|
153
|
+
// Pass 1: measure the assembled total with the placeholder budget in
|
|
154
|
+
// place, resolve free/percent, substitute into the budget section.
|
|
155
|
+
const total = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
|
|
156
|
+
const tokensFree = ceiling === null ? null : Math.max(0, ceiling - total); // free floors at 0 on overshoot — §tokenomics-over-budget-floor
|
|
157
|
+
const percent = ceiling === null ? null : Math.round((total / ceiling) * 100); // usage as % of the ceiling — §tokenomics-context-percent
|
|
158
|
+
if (tokensFree !== null) {
|
|
159
|
+
const budgetSec = sections.find((s) => s.name === "budget"); // a plugin may have removed it
|
|
160
|
+
if (budgetSec) {
|
|
161
|
+
budgetSec.content = budgetSec.content
|
|
162
|
+
.replace(TOKEN_USAGE_PLACEHOLDER, String(total))
|
|
163
|
+
.replace(TOKEN_PERCENT_PLACEHOLDER, percent === 0 && total > 0 ? "<1" : String(percent))
|
|
164
|
+
.replace(TOKENS_FREE_PLACEHOLDER, String(tokensFree));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Pass 2: per-section render-weight + the assembled packet total (post
|
|
168
|
+
// substitution — the placeholder/number length delta is negligible).
|
|
169
|
+
for (const s of sections)
|
|
170
|
+
s.tokens = countTokens(PacketWire.renderSection(s));
|
|
171
|
+
const packetTokens = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
|
|
172
|
+
return { tokens: packetTokens, sections, telemetryErrors };
|
|
173
|
+
}
|
|
174
|
+
// Budget readout body, rendered into the `## Plurnk Service Budget` section.
|
|
175
|
+
// Headline `ceiling/free` only when a ceiling exists; section lines for the
|
|
176
|
+
// curatable index/log weight the model can FOLD back. tokensFree is a
|
|
177
|
+
// placeholder here — buildRequestPacket substitutes it after measuring the packet.
|
|
178
|
+
#renderBudget(log, ceiling) {
|
|
179
|
+
const lines = [];
|
|
180
|
+
if (ceiling !== null)
|
|
181
|
+
lines.push(`Token Ceiling ${ceiling} · Token Usage ${TOKEN_USAGE_PLACEHOLDER} (${TOKEN_PERCENT_PLACEHOLDER}%) · Tokens Free ${TOKENS_FREE_PLACEHOLDER}`);
|
|
182
|
+
if (log.entries > 0) {
|
|
183
|
+
if (lines.length > 0)
|
|
184
|
+
lines.push("");
|
|
185
|
+
lines.push(`Log entries: ${log.entries} entries, ${log.tokens} tokens`);
|
|
186
|
+
// Per-turn weight — chronological (oldest first); the turn is the grinder's
|
|
187
|
+
// rollback unit and the rail folds the newest first (§tokenomics {§tokenomics-turn-totals}).
|
|
188
|
+
if (log.byTurn.length > 0) {
|
|
189
|
+
lines.push("", "Turns:", "| turn | tokens |", "|---|--:|");
|
|
190
|
+
for (const t of log.byTurn)
|
|
191
|
+
lines.push(`| ${t.turn} | ${t.tokens} |`);
|
|
192
|
+
}
|
|
193
|
+
// The heaviest individual log items — the FOLD targets behind the weight
|
|
194
|
+
// (§tokenomics {§tokenomics-largest-entries}). "items", not "entries": the readout
|
|
195
|
+
// lists log:/// rows (log items), distinct from catalog entries (plurnk.md: "EDIT
|
|
196
|
+
// is only for entries. Do not attempt to edit log items.").
|
|
197
|
+
if (log.largest.length > 0) {
|
|
198
|
+
lines.push("", "Heaviest items:", "| item | tokens |", "|---|--:|");
|
|
199
|
+
for (const e of log.largest)
|
|
200
|
+
lines.push(`| ${e.path} | ${e.tokens} |`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return lines.join("\n");
|
|
204
|
+
}
|
|
205
|
+
// The ## Plurnk Service Tools capability sheet (SPEC §tools). A hook: each enabled
|
|
206
|
+
// capability contributes one line, rendered above Requirements so the model sees what
|
|
207
|
+
// it can do before the rules. Each available executor tag contributes its self-documenting
|
|
208
|
+
// example (plurnk-execs#7), retiring the blind EXEC.
|
|
209
|
+
// The capability sheet — the live tool surface (wired executor tags). §tools-capability-sheet
|
|
210
|
+
#collectTools() {
|
|
211
|
+
const tools = [];
|
|
212
|
+
// Each available runtime tag contributes its self-documenting example —
|
|
213
|
+
// the example carries syntax + purpose, so there's no prose line. Tags
|
|
214
|
+
// with no example (sh/node, covered by the core prompt) contribute
|
|
215
|
+
// nothing; available-only, so the model never sees an unusable tag. `* `
|
|
216
|
+
// bullets + bare op forms match the packet's list/op rendering (no `- `,
|
|
217
|
+
// no backticks — see packet-wire.ts).
|
|
218
|
+
const executors = this.#executors();
|
|
219
|
+
if (executors !== undefined) {
|
|
220
|
+
const excluded = docsExcludeSet();
|
|
221
|
+
for (const tag of executors.availableRuntimes()) {
|
|
222
|
+
if (excluded.has(tag))
|
|
223
|
+
continue; // #240 — PLURNK_DOCS_EXCLUDE drops the oneliner + the doc
|
|
224
|
+
const entry = executors.entry(tag);
|
|
225
|
+
// #240 — identical treatment with the scheme directory: the example IS the oneliner,
|
|
226
|
+
// the fuller doc (materialized at plurnk://docs/<tag>.md) rides an inline link whose
|
|
227
|
+
// token cost lives on that manifest entry. No example → no line (like a provisional scheme).
|
|
228
|
+
if (entry?.example)
|
|
229
|
+
tools.push(teachingLine(entry.example));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return tools;
|
|
233
|
+
}
|
|
234
|
+
// #note12 — the daughter-provided reference docs (schemes' + execs' `documentation`),
|
|
235
|
+
// materialized at plurnk:///docs/<name>.md by loop_run (like operator docs) so the
|
|
236
|
+
// catalogue's doc-links READ and the manifest carries each doc's token cost.
|
|
237
|
+
docEntries() {
|
|
238
|
+
const out = this.#schemes.docs(); // scheme docs already drop PLURNK_DOCS_EXCLUDE names
|
|
239
|
+
const executors = this.#executors();
|
|
240
|
+
if (executors !== undefined) {
|
|
241
|
+
const excluded = docsExcludeSet();
|
|
242
|
+
for (const tag of executors.availableRuntimes()) {
|
|
243
|
+
if (excluded.has(tag))
|
|
244
|
+
continue; // #240 — exec docs honor the same exclude
|
|
245
|
+
const doc = executors.entry(tag)?.documentation;
|
|
246
|
+
if (doc !== undefined && doc.length > 0)
|
|
247
|
+
out.push({ name: tag, content: doc });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
// SPEC §grinder — the budget grinder. Runs pre-LLM (in runTurn, after the packet
|
|
253
|
+
// is built, before provider.generate); fires only on actual overflow. Two
|
|
254
|
+
// passes, re-measuring between. Folds (never deletes) — the prior turn's logs,
|
|
255
|
+
// then the catalog except the manifest lifeline. The strike it raises and the
|
|
256
|
+
// hard-stop it can signal are returned to runLoop, which owns abandonment.
|
|
257
|
+
// §grinder-overflow-only — fires only on actual overflow, never speculatively
|
|
258
|
+
async enforceBudget({ packet, provider, runId, loopId, turnId, mintSequence, rebuild }) {
|
|
259
|
+
const ceiling = this.ceilingFor(provider);
|
|
260
|
+
const measure = (p) => p.tokens;
|
|
261
|
+
if (ceiling === null || measure(packet) <= ceiling)
|
|
262
|
+
return { packet, fit: true, struck: false };
|
|
263
|
+
// The grinder may compact ONLY the newest turn — the immediately-prior turn's emissions
|
|
264
|
+
// (turn N>1), or, when there is no prior turn (turn 1), THIS turn's own foists. It NEVER
|
|
265
|
+
// reaches older history; the model alone curates history via FOLD/KILL, and the engine never
|
|
266
|
+
// janitors stale context. §grinder-newest-turn-only
|
|
267
|
+
let foldedAny = false;
|
|
268
|
+
const priorLogs = await this.#db.engine_grinder_prior_turn_logs.all({ loop_id: loopId, turn_id: turnId });
|
|
269
|
+
if (priorLogs.length > 0) {
|
|
270
|
+
await this.#db.engine_grinder_fold_prior_turn_logs.run({ loop_id: loopId, turn_id: turnId });
|
|
271
|
+
foldedAny = true;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
// Turn 1 — no prior turn: fold THIS turn's own foists (the catalog/prompt that overflowed). §grinder-turn-1-self-fold (#2)
|
|
275
|
+
const curLogs = await this.#db.engine_grinder_current_turn_logs.all({ loop_id: loopId, turn_id: turnId });
|
|
276
|
+
if (curLogs.length > 0) {
|
|
277
|
+
await this.#db.engine_grinder_fold_current_turn_logs.run({ loop_id: loopId, turn_id: turnId });
|
|
278
|
+
foldedAny = true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (!foldedAny)
|
|
282
|
+
return { packet, fit: measure(packet) <= ceiling, struck: false };
|
|
283
|
+
// Mint the overflow as a terse op='error' log row BEFORE the rebuild, so the rebuild's
|
|
284
|
+
// re-derived errors section surfaces it THIS turn — the warning lands at strike 1, not a
|
|
285
|
+
// turn late. The row is grinder-exempt, so it stacks into a visible recurrence trail. It
|
|
286
|
+
// sits at the turn's reserved running sequence (mintSequence) so it never collides with the
|
|
287
|
+
// post-generate dispatch rows. §telemetry-uniform-error-channel, §grinder-overflow-error-row
|
|
288
|
+
await this.#telemetry.mintEngineError("budget_overflow", { runId, loopId, turnId, sequence: mintSequence });
|
|
289
|
+
const current = await rebuild();
|
|
290
|
+
// Every compaction is a strike — including turn 0/1 (no soft exemption, #4). §grinder-compaction-strikes
|
|
291
|
+
return { packet: current, fit: measure(current) <= ceiling, struck: true };
|
|
292
|
+
}
|
|
293
|
+
// Complete the packet by adding the model's response. After this the
|
|
294
|
+
// packet matches Packet.json fully and is ready for storage.
|
|
295
|
+
completePacket(requestPacket, assistant, assistantRaw, provider) {
|
|
296
|
+
const assistantTokens = provider.countTokens(assistant.content);
|
|
297
|
+
return {
|
|
298
|
+
tokens: requestPacket.tokens + assistantTokens,
|
|
299
|
+
sections: requestPacket.sections,
|
|
300
|
+
telemetryErrors: requestPacket.telemetryErrors,
|
|
301
|
+
assistant,
|
|
302
|
+
assistantRaw,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
// SPEC §telemetry: model-facing alert surface.
|
|
306
|
+
// Two sources, merged on each packet build:
|
|
307
|
+
// 1. Previous-turn action-bound failures (status_rx >= 400 on log_entries).
|
|
308
|
+
// 2. Engine-buffered actionless failures (no_send, parse, watchdog, rails).
|
|
309
|
+
// Buffer drains on read — each error appears in exactly one packet.
|
|
310
|
+
async buildTelemetryErrors(loopId, currentTurnSeq) {
|
|
311
|
+
// The uniform error channel (§telemetry-uniform-error-channel): every 4xx/5xx log row
|
|
312
|
+
// becomes a LogCoordinate-positioned TelemetryEvent — a terse pointer; the model READs the
|
|
313
|
+
// row for its term + detail. Buffer events that point at the model's own emission keep their
|
|
314
|
+
// ContentOffset position. info-level notices (progress) are not errors and never surface here.
|
|
315
|
+
const rows = await this.#db.engine_render_telemetry_errors.all({ loop_id: loopId, current_turn_seq: currentTurnSeq });
|
|
316
|
+
const logErrors = rows.map((r) => ({
|
|
317
|
+
source: "engine:rail",
|
|
318
|
+
kind: "log_error",
|
|
319
|
+
level: "error",
|
|
320
|
+
status: r.status_rx,
|
|
321
|
+
position: { type: "log-coordinate", coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}/${r.op}` },
|
|
322
|
+
}));
|
|
323
|
+
const bufferEvents = this.#telemetry.drain(loopId).filter((e) => e.level !== "info");
|
|
324
|
+
return [...bufferEvents, ...logErrors];
|
|
325
|
+
}
|
|
326
|
+
// SPEC §packet the log section — chronological action-entries for the loop.
|
|
327
|
+
// Snapshot is taken at packet build (pre-dispatch this turn), so it
|
|
328
|
+
// reflects "what has happened before this turn." Each row carries a
|
|
329
|
+
// log:///<loop_seq>/<turn_seq>/<sequence> coordinate the model can READ.
|
|
330
|
+
async #buildLog(runId) {
|
|
331
|
+
// SPEC §packet-terms: runs own log entries — log is the run's history,
|
|
332
|
+
// not the loop's. Span all loops in the run so the model sees
|
|
333
|
+
// earlier loops' work as conversational memory.
|
|
334
|
+
//
|
|
335
|
+
// User prompts are first-class log entries: runTurn writes a
|
|
336
|
+
// client-origin SEND[200] row at sequence=0 of each new
|
|
337
|
+
// turn-1. Prompts thus surface naturally in this query — no
|
|
338
|
+
// synthetic / shim layer.
|
|
339
|
+
const rows = await this.#db.engine_render_log.all({ run_id: runId });
|
|
340
|
+
return rows.map((r) => ({
|
|
341
|
+
coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}`,
|
|
342
|
+
origin: r.origin,
|
|
343
|
+
op: r.op,
|
|
344
|
+
suffix: r.suffix,
|
|
345
|
+
signal: r.signal === null ? null : JSON.parse(r.signal),
|
|
346
|
+
target: {
|
|
347
|
+
scheme: r.scheme,
|
|
348
|
+
username: r.username, password: r.password,
|
|
349
|
+
hostname: r.hostname, port: r.port,
|
|
350
|
+
pathname: r.pathname,
|
|
351
|
+
params: r.params === null ? null : JSON.parse(r.params),
|
|
352
|
+
fragment: r.fragment,
|
|
353
|
+
},
|
|
354
|
+
status: r.status_rx,
|
|
355
|
+
rx: r.mimetype_rx === "application/json" ? JSON.parse(r.rx) : r.rx,
|
|
356
|
+
mimetype_rx: r.mimetype_rx,
|
|
357
|
+
tx: r.mimetype_tx === "application/json" ? JSON.parse(r.tx) : r.tx,
|
|
358
|
+
mimetype_tx: r.mimetype_tx,
|
|
359
|
+
folded: r.expanded === 0,
|
|
360
|
+
source: r.source,
|
|
361
|
+
attrs: r.attrs === null ? null : JSON.parse(r.attrs),
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=PacketBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PacketBuilder.js","sourceRoot":"","sources":["../../src/core/PacketBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,mEAAmE;AACnE,sEAAsE;AACtE,0CAA0C;AAC1C,OAAO,UAAkC,MAAM,kBAAkB,CAAC;AAKlE,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,6EAA6E;AAC7E,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACjD,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AACjD,MAAM,yBAAyB,GAAG,kBAAkB,CAAC;AAErD,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,WAAW,GAAG,GAAW,EAAE;IAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC9C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CA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AAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;gBACvD,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACvB;YACD,MAAM,EAAE,CAAC,CAAC,SAAS;YACnB,EAAE,EAAE,CAAC,CAAC,WAAW,KAAK,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YAClE,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,EAAE,EAAE,CAAC,CAAC,WAAW,KAAK,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YAClE,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,MAAM,EAAE,CAAC,CAAC,QAAQ,KAAK,CAAC;YACxB,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;SACvD,CAAC,CAAC,CAAC;IACR,CAAC;CACJ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { PlurnkStatement } from "@plurnk/plurnk-grammar";
|
|
2
|
+
import type { Db } from "./Db.ts";
|
|
3
|
+
import type SchemeRegistry from "./SchemeRegistry.ts";
|
|
4
|
+
import type ExecutorRegistry from "./ExecutorRegistry.ts";
|
|
5
|
+
import type TelemetryChannel from "./TelemetryChannel.ts";
|
|
6
|
+
import type { StreamEventNotify, WakeRunNotify } from "./ChannelWrite.ts";
|
|
7
|
+
import type { LoopFlags } from "./scheme-types.ts";
|
|
8
|
+
import type { DispatchResult } from "./Dispatcher.ts";
|
|
9
|
+
export type ProposalDecision = "accept" | "reject" | "cancel";
|
|
10
|
+
export interface ProposalResolution {
|
|
11
|
+
decision: ProposalDecision;
|
|
12
|
+
body?: string;
|
|
13
|
+
outcome?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ProposalPendingEvent {
|
|
16
|
+
logEntryId: number;
|
|
17
|
+
sessionId: number;
|
|
18
|
+
runId: number;
|
|
19
|
+
loopId: number;
|
|
20
|
+
turnId: number;
|
|
21
|
+
op: string;
|
|
22
|
+
target: {
|
|
23
|
+
scheme: string | null;
|
|
24
|
+
pathname: string | null;
|
|
25
|
+
};
|
|
26
|
+
body: string;
|
|
27
|
+
attrs: object;
|
|
28
|
+
flags: LoopFlags;
|
|
29
|
+
staleClobberRisk: boolean;
|
|
30
|
+
}
|
|
31
|
+
export default class ProposalLifecycle {
|
|
32
|
+
#private;
|
|
33
|
+
constructor({ db, schemes, telemetry, streamEventNotify, wakeRunNotify, tokenize, executors, loopSignal }: {
|
|
34
|
+
db: Db;
|
|
35
|
+
schemes: SchemeRegistry;
|
|
36
|
+
telemetry: TelemetryChannel;
|
|
37
|
+
streamEventNotify?: StreamEventNotify;
|
|
38
|
+
wakeRunNotify?: WakeRunNotify;
|
|
39
|
+
tokenize: (text: string) => number;
|
|
40
|
+
executors: () => ExecutorRegistry | undefined;
|
|
41
|
+
loopSignal: (loopId: number) => AbortSignal | undefined;
|
|
42
|
+
});
|
|
43
|
+
resolve(logEntryId: number, resolution: ProposalResolution): void;
|
|
44
|
+
pendingIds(): number[];
|
|
45
|
+
onPending(listener: (event: ProposalPendingEvent) => void): void;
|
|
46
|
+
notifyPending(event: ProposalPendingEvent): void;
|
|
47
|
+
awaitResolution(logEntryId: number): Promise<ProposalResolution>;
|
|
48
|
+
runApply(statement: PlurnkStatement, originalResult: DispatchResult, resolution: ProposalResolution, ids: {
|
|
49
|
+
sessionId: number;
|
|
50
|
+
runId: number;
|
|
51
|
+
loopId: number;
|
|
52
|
+
turnId: number;
|
|
53
|
+
}): Promise<ProposalResolution>;
|
|
54
|
+
applyResolution(logEntryId: number, resolution: ProposalResolution): Promise<DispatchResult>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ProposalLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProposalLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/ProposalLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAuB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC9D,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,gBAAgB,CAAC;IAK3B,IAAI,CAAC,EAAE,MAAM,CAAC;IAKd,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAYD,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC3D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