@plurnk/plurnk-service 1.0.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.defaults +208 -0
- package/INSTALL.md +69 -0
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/SPEC.md +1511 -0
- package/dist/Paths.d.ts +13 -0
- package/dist/Paths.d.ts.map +1 -0
- package/dist/Paths.js +60 -0
- package/dist/Paths.js.map +1 -0
- package/dist/content/edited-span.d.ts +2 -0
- package/dist/content/edited-span.d.ts.map +1 -0
- package/dist/content/edited-span.js +33 -0
- package/dist/content/edited-span.js.map +1 -0
- package/dist/content/index.d.ts +10 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +11 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/line-marker.d.ts +15 -0
- package/dist/content/line-marker.d.ts.map +1 -0
- package/dist/content/line-marker.js +21 -0
- package/dist/content/line-marker.js.map +1 -0
- package/dist/content/matcher.d.ts +44 -0
- package/dist/content/matcher.d.ts.map +1 -0
- package/dist/content/matcher.js +126 -0
- package/dist/content/matcher.js.map +1 -0
- package/dist/content/mimetype-binary.d.ts +8 -0
- package/dist/content/mimetype-binary.d.ts.map +1 -0
- package/dist/content/mimetype-binary.js +17 -0
- package/dist/content/mimetype-binary.js.map +1 -0
- package/dist/content/path-mimetype.d.ts +5 -0
- package/dist/content/path-mimetype.d.ts.map +1 -0
- package/dist/content/path-mimetype.js +15 -0
- package/dist/content/path-mimetype.js.map +1 -0
- package/dist/content/read-resolve.d.ts +20 -0
- package/dist/content/read-resolve.d.ts.map +1 -0
- package/dist/content/read-resolve.js +68 -0
- package/dist/content/read-resolve.js.map +1 -0
- package/dist/core/ChannelWrite.d.ts +100 -0
- package/dist/core/ChannelWrite.d.ts.map +1 -0
- package/dist/core/ChannelWrite.js +112 -0
- package/dist/core/ChannelWrite.js.map +1 -0
- package/dist/core/ChannelWrite.sql +84 -0
- package/dist/core/Db.d.ts +14 -0
- package/dist/core/Db.d.ts.map +1 -0
- package/dist/core/Db.js +7 -0
- package/dist/core/Db.js.map +1 -0
- package/dist/core/Dispatcher.d.ts +67 -0
- package/dist/core/Dispatcher.d.ts.map +1 -0
- package/dist/core/Dispatcher.js +1021 -0
- package/dist/core/Dispatcher.js.map +1 -0
- package/dist/core/Engine.d.ts +113 -0
- package/dist/core/Engine.d.ts.map +1 -0
- package/dist/core/Engine.js +1410 -0
- package/dist/core/Engine.js.map +1 -0
- package/dist/core/Engine.sql +538 -0
- package/dist/core/EnvFlags.d.ts +13 -0
- package/dist/core/EnvFlags.d.ts.map +1 -0
- package/dist/core/EnvFlags.js +84 -0
- package/dist/core/EnvFlags.js.map +1 -0
- package/dist/core/ExecutorRegistry.d.ts +45 -0
- package/dist/core/ExecutorRegistry.d.ts.map +1 -0
- package/dist/core/ExecutorRegistry.js +128 -0
- package/dist/core/ExecutorRegistry.js.map +1 -0
- package/dist/core/PacketBuilder.d.ts +67 -0
- package/dist/core/PacketBuilder.d.ts.map +1 -0
- package/dist/core/PacketBuilder.js +524 -0
- package/dist/core/PacketBuilder.js.map +1 -0
- package/dist/core/PluginLoader.d.ts +17 -0
- package/dist/core/PluginLoader.d.ts.map +1 -0
- package/dist/core/PluginLoader.js +97 -0
- package/dist/core/PluginLoader.js.map +1 -0
- package/dist/core/ProposalLifecycle.d.ts +59 -0
- package/dist/core/ProposalLifecycle.d.ts.map +1 -0
- package/dist/core/ProposalLifecycle.js +215 -0
- package/dist/core/ProposalLifecycle.js.map +1 -0
- package/dist/core/ProviderInstantiate.d.ts +9 -0
- package/dist/core/ProviderInstantiate.d.ts.map +1 -0
- package/dist/core/ProviderInstantiate.js +156 -0
- package/dist/core/ProviderInstantiate.js.map +1 -0
- package/dist/core/SchemeRegistry.d.ts +26 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -0
- package/dist/core/SchemeRegistry.js +205 -0
- package/dist/core/SchemeRegistry.js.map +1 -0
- package/dist/core/StrikeRail.d.ts +28 -0
- package/dist/core/StrikeRail.d.ts.map +1 -0
- package/dist/core/StrikeRail.js +165 -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/TokenGauge.d.ts +16 -0
- package/dist/core/TokenGauge.d.ts.map +1 -0
- package/dist/core/TokenGauge.js +58 -0
- package/dist/core/TokenGauge.js.map +1 -0
- package/dist/core/caps/CapsResolve.d.ts +5 -0
- package/dist/core/caps/CapsResolve.d.ts.map +1 -0
- package/dist/core/caps/CapsResolve.js +13 -0
- package/dist/core/caps/CapsResolve.js.map +1 -0
- package/dist/core/caps/DbChannelCaps.d.ts +16 -0
- package/dist/core/caps/DbChannelCaps.d.ts.map +1 -0
- package/dist/core/caps/DbChannelCaps.js +41 -0
- package/dist/core/caps/DbChannelCaps.js.map +1 -0
- package/dist/core/caps/DbEntryCaps.d.ts +19 -0
- package/dist/core/caps/DbEntryCaps.d.ts.map +1 -0
- package/dist/core/caps/DbEntryCaps.js +28 -0
- package/dist/core/caps/DbEntryCaps.js.map +1 -0
- package/dist/core/caps/DbNotifyCaps.d.ts +8 -0
- package/dist/core/caps/DbNotifyCaps.d.ts.map +1 -0
- package/dist/core/caps/DbNotifyCaps.js +35 -0
- package/dist/core/caps/DbNotifyCaps.js.map +1 -0
- package/dist/core/caps/DbSubscriptionCaps.d.ts +10 -0
- package/dist/core/caps/DbSubscriptionCaps.d.ts.map +1 -0
- package/dist/core/caps/DbSubscriptionCaps.js +86 -0
- package/dist/core/caps/DbSubscriptionCaps.js.map +1 -0
- package/dist/core/caps/DbTagCaps.d.ts +17 -0
- package/dist/core/caps/DbTagCaps.d.ts.map +1 -0
- package/dist/core/caps/DbTagCaps.js +37 -0
- package/dist/core/caps/DbTagCaps.js.map +1 -0
- package/dist/core/caps/SchemeCtxImpl.d.ts +18 -0
- package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -0
- package/dist/core/caps/SchemeCtxImpl.js +42 -0
- package/dist/core/caps/SchemeCtxImpl.js.map +1 -0
- package/dist/core/env-defaults.d.ts +19 -0
- package/dist/core/env-defaults.d.ts.map +1 -0
- package/dist/core/env-defaults.js +89 -0
- package/dist/core/env-defaults.js.map +1 -0
- package/dist/core/fork.d.ts +6 -0
- package/dist/core/fork.d.ts.map +1 -0
- package/dist/core/fork.js +84 -0
- package/dist/core/fork.js.map +1 -0
- package/dist/core/fork.sql +85 -0
- package/dist/core/git-membership.d.ts +23 -0
- package/dist/core/git-membership.d.ts.map +1 -0
- package/dist/core/git-membership.js +366 -0
- package/dist/core/git-membership.js.map +1 -0
- package/dist/core/git-state.d.ts +15 -0
- package/dist/core/git-state.d.ts.map +1 -0
- package/dist/core/git-state.js +67 -0
- package/dist/core/git-state.js.map +1 -0
- package/dist/core/packet-inject.d.ts +5 -0
- package/dist/core/packet-inject.d.ts.map +1 -0
- package/dist/core/packet-inject.js +48 -0
- package/dist/core/packet-inject.js.map +1 -0
- package/dist/core/packet-wire.d.ts +46 -0
- package/dist/core/packet-wire.d.ts.map +1 -0
- package/dist/core/packet-wire.js +453 -0
- package/dist/core/packet-wire.js.map +1 -0
- package/dist/core/path-decode.d.ts +2 -0
- package/dist/core/path-decode.d.ts.map +1 -0
- package/dist/core/path-decode.js +8 -0
- package/dist/core/path-decode.js.map +1 -0
- package/dist/core/plugin-attribution.d.ts +5 -0
- package/dist/core/plugin-attribution.d.ts.map +1 -0
- package/dist/core/plugin-attribution.js +39 -0
- package/dist/core/plugin-attribution.js.map +1 -0
- package/dist/core/plurnk-uri.d.ts +7 -0
- package/dist/core/plurnk-uri.d.ts.map +1 -0
- package/dist/core/plurnk-uri.js +52 -0
- package/dist/core/plurnk-uri.js.map +1 -0
- package/dist/core/resolveForLoop.d.ts +5 -0
- package/dist/core/resolveForLoop.d.ts.map +1 -0
- package/dist/core/resolveForLoop.js +12 -0
- package/dist/core/resolveForLoop.js.map +1 -0
- package/dist/core/results.d.ts +12 -0
- package/dist/core/results.d.ts.map +1 -0
- package/dist/core/results.js +27 -0
- package/dist/core/results.js.map +1 -0
- package/dist/core/run-cap.d.ts +8 -0
- package/dist/core/run-cap.d.ts.map +1 -0
- package/dist/core/run-cap.js +20 -0
- package/dist/core/run-cap.js.map +1 -0
- package/dist/core/run-ops.sql +43 -0
- package/dist/core/scheme-types.d.ts +45 -0
- package/dist/core/scheme-types.d.ts.map +1 -0
- package/dist/core/scheme-types.js +6 -0
- package/dist/core/scheme-types.js.map +1 -0
- package/dist/core/session-settings.d.ts +23 -0
- package/dist/core/session-settings.d.ts.map +1 -0
- package/dist/core/session-settings.js +55 -0
- package/dist/core/session-settings.js.map +1 -0
- package/dist/core/teaching.d.ts +3 -0
- package/dist/core/teaching.d.ts.map +1 -0
- package/dist/core/teaching.js +13 -0
- package/dist/core/teaching.js.map +1 -0
- package/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/digest/Digest.d.ts +20 -0
- package/dist/digest/Digest.d.ts.map +1 -0
- package/dist/digest/Digest.js +451 -0
- package/dist/digest/Digest.js.map +1 -0
- package/dist/digest/Digest.sql +1 -0
- package/dist/digest/digest.sql +55 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/schemes/EffectPolicy.d.ts +6 -0
- package/dist/schemes/EffectPolicy.d.ts.map +1 -0
- package/dist/schemes/EffectPolicy.js +18 -0
- package/dist/schemes/EffectPolicy.js.map +1 -0
- package/dist/schemes/Exec.d.ts +39 -0
- package/dist/schemes/Exec.d.ts.map +1 -0
- package/dist/schemes/Exec.js +510 -0
- package/dist/schemes/Exec.js.map +1 -0
- package/dist/schemes/ExecOutputScheme.d.ts +20 -0
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -0
- package/dist/schemes/ExecOutputScheme.js +39 -0
- package/dist/schemes/ExecOutputScheme.js.map +1 -0
- package/dist/schemes/File.d.ts +42 -0
- package/dist/schemes/File.d.ts.map +1 -0
- package/dist/schemes/File.js +356 -0
- package/dist/schemes/File.js.map +1 -0
- package/dist/schemes/Known.d.ts +17 -0
- package/dist/schemes/Known.d.ts.map +1 -0
- package/dist/schemes/Known.js +40 -0
- package/dist/schemes/Known.js.map +1 -0
- package/dist/schemes/Log.d.ts +22 -0
- package/dist/schemes/Log.d.ts.map +1 -0
- package/dist/schemes/Log.js +269 -0
- package/dist/schemes/Log.js.map +1 -0
- package/dist/schemes/Log.sql +59 -0
- package/dist/schemes/Plurnk.d.ts +17 -0
- package/dist/schemes/Plurnk.d.ts.map +1 -0
- package/dist/schemes/Plurnk.js +46 -0
- package/dist/schemes/Plurnk.js.map +1 -0
- package/dist/schemes/Run.d.ts +25 -0
- package/dist/schemes/Run.d.ts.map +1 -0
- package/dist/schemes/Run.js +172 -0
- package/dist/schemes/Run.js.map +1 -0
- package/dist/schemes/Skill.d.ts +17 -0
- package/dist/schemes/Skill.d.ts.map +1 -0
- package/dist/schemes/Skill.js +40 -0
- package/dist/schemes/Skill.js.map +1 -0
- package/dist/schemes/Unknown.d.ts +17 -0
- package/dist/schemes/Unknown.d.ts.map +1 -0
- package/dist/schemes/Unknown.js +39 -0
- package/dist/schemes/Unknown.js.map +1 -0
- package/dist/schemes/_entry-chunk.d.ts +11 -0
- package/dist/schemes/_entry-chunk.d.ts.map +1 -0
- package/dist/schemes/_entry-chunk.js +100 -0
- package/dist/schemes/_entry-chunk.js.map +1 -0
- package/dist/schemes/_entry-crud.d.ts +31 -0
- package/dist/schemes/_entry-crud.d.ts.map +1 -0
- package/dist/schemes/_entry-crud.js +77 -0
- package/dist/schemes/_entry-crud.js.map +1 -0
- package/dist/schemes/_entry-crud.sql +101 -0
- package/dist/schemes/_entry-find.d.ts +32 -0
- package/dist/schemes/_entry-find.d.ts.map +1 -0
- package/dist/schemes/_entry-find.js +226 -0
- package/dist/schemes/_entry-find.js.map +1 -0
- package/dist/schemes/_entry-find.sql +54 -0
- package/dist/schemes/_entry-graph.d.ts +16 -0
- package/dist/schemes/_entry-graph.d.ts.map +1 -0
- package/dist/schemes/_entry-graph.js +94 -0
- package/dist/schemes/_entry-graph.js.map +1 -0
- package/dist/schemes/_entry-graph.sql +52 -0
- package/dist/schemes/_entry-manifest.d.ts +25 -0
- package/dist/schemes/_entry-manifest.d.ts.map +1 -0
- package/dist/schemes/_entry-manifest.js +266 -0
- package/dist/schemes/_entry-manifest.js.map +1 -0
- package/dist/schemes/_entry-ops.d.ts +32 -0
- package/dist/schemes/_entry-ops.d.ts.map +1 -0
- package/dist/schemes/_entry-ops.js +216 -0
- package/dist/schemes/_entry-ops.js.map +1 -0
- package/dist/schemes/_entry-ops.sql +31 -0
- package/dist/schemes/_entry-semantic.d.ts +38 -0
- package/dist/schemes/_entry-semantic.d.ts.map +1 -0
- package/dist/schemes/_entry-semantic.js +202 -0
- package/dist/schemes/_entry-semantic.js.map +1 -0
- package/dist/schemes/_entry-semantic.sql +95 -0
- package/dist/schemes/_entry-send.d.ts +11 -0
- package/dist/schemes/_entry-send.d.ts.map +1 -0
- package/dist/schemes/_entry-send.js +66 -0
- package/dist/schemes/_entry-send.js.map +1 -0
- package/dist/schemes/cosine.d.ts +4 -0
- package/dist/schemes/cosine.d.ts.map +1 -0
- package/dist/schemes/cosine.js +9 -0
- package/dist/schemes/cosine.js.map +1 -0
- package/dist/schemes/exec-abort.d.ts +15 -0
- package/dist/schemes/exec-abort.d.ts.map +1 -0
- package/dist/schemes/exec-abort.js +29 -0
- package/dist/schemes/exec-abort.js.map +1 -0
- package/dist/schemes/exec-env.d.ts +5 -0
- package/dist/schemes/exec-env.d.ts.map +1 -0
- package/dist/schemes/exec-env.js +34 -0
- package/dist/schemes/exec-env.js.map +1 -0
- package/dist/server/Daemon.d.ts +244 -0
- package/dist/server/Daemon.d.ts.map +1 -0
- package/dist/server/Daemon.js +1119 -0
- package/dist/server/Daemon.js.map +1 -0
- package/dist/server/client-input.d.ts +11 -0
- package/dist/server/client-input.d.ts.map +1 -0
- package/dist/server/client-input.js +145 -0
- package/dist/server/client-input.js.map +1 -0
- package/dist/server/clientTurn.d.ts +6 -0
- package/dist/server/clientTurn.d.ts.map +1 -0
- package/dist/server/clientTurn.js +23 -0
- package/dist/server/clientTurn.js.map +1 -0
- package/dist/server/clientTurn.sql +10 -0
- package/dist/server/dispatch-as-plurnk.d.ts +7 -0
- package/dist/server/dispatch-as-plurnk.d.ts.map +1 -0
- package/dist/server/dispatch-as-plurnk.js +23 -0
- package/dist/server/dispatch-as-plurnk.js.map +1 -0
- package/dist/server/drain.sql +124 -0
- package/dist/server/envelope.d.ts +53 -0
- package/dist/server/envelope.d.ts.map +1 -0
- package/dist/server/envelope.js +172 -0
- package/dist/server/envelope.js.map +1 -0
- package/dist/server/envelope.sql +76 -0
- package/dist/server/logEntry.d.ts +35 -0
- package/dist/server/logEntry.d.ts.map +1 -0
- package/dist/server/logEntry.js +49 -0
- package/dist/server/logEntry.js.map +1 -0
- package/dist/server/logEntry.sql +10 -0
- package/dist/server/loopDocs.d.ts +6 -0
- package/dist/server/loopDocs.d.ts.map +1 -0
- package/dist/server/loopDocs.js +22 -0
- package/dist/server/loopDocs.js.map +1 -0
- package/dist/server/noProposals.d.ts +6 -0
- package/dist/server/noProposals.d.ts.map +1 -0
- package/dist/server/noProposals.js +37 -0
- package/dist/server/noProposals.js.map +1 -0
- package/dist/server/seam-entry-read.sql +21 -0
- package/dist/server/seam-log-read.sql +21 -0
- package/dist/server/seam-loop.sql +9 -0
- package/dist/server/seam-proposal-list.sql +13 -0
- package/dist/server/version-info.d.ts +14 -0
- package/dist/server/version-info.d.ts.map +1 -0
- package/dist/server/version-info.js +69 -0
- package/dist/server/version-info.js.map +1 -0
- package/dist/server/yolo.d.ts +6 -0
- package/dist/server/yolo.d.ts.map +1 -0
- package/dist/server/yolo.js +64 -0
- package/dist/server/yolo.js.map +1 -0
- package/dist/service.d.ts +6 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +309 -0
- package/dist/service.js.map +1 -0
- package/migrations/0000-00-00.01_schema.sql +500 -0
- package/package.json +86 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { renderAddress, promptLoopPrefix } from "./plurnk-uri.js";
|
|
3
|
+
import { teachingLine, docsExcludeSet } from "./teaching.js";
|
|
4
|
+
import { Policy } from "@plurnk/plurnk-execs";
|
|
5
|
+
import SessionSettings from "./session-settings.js";
|
|
6
|
+
import { DEFAULT_LOOP_FLAGS } from "./scheme-types.js";
|
|
7
|
+
import { readPacketInject, readSystemPolicy, readProjectPolicy } from "./packet-inject.js";
|
|
8
|
+
import { readFile } from "node:fs/promises";
|
|
9
|
+
import { resolve as resolvePath } from "node:path";
|
|
10
|
+
import Paths from "../Paths.js";
|
|
11
|
+
// Shared module imported by both Engine and bin/digest.ts, so wire
|
|
12
|
+
// projection and digest projection are structurally one function — no
|
|
13
|
+
// drift between wire and digest possible.
|
|
14
|
+
import PacketWire from "./packet-wire.js";
|
|
15
|
+
import { scopeEnvToAlias, resolveActiveAlias } from "@plurnk/plurnk-providers";
|
|
16
|
+
import ProviderInstantiate from "./ProviderInstantiate.js";
|
|
17
|
+
// Substituted into the budget readout after the assembled packet is measured
|
|
18
|
+
// (the figure depends on the packet's own rendered size — chicken/egg).
|
|
19
|
+
const TOKENS_FREE_PLACEHOLDER = "{{tokensFree}}";
|
|
20
|
+
const TOKEN_USAGE_PLACEHOLDER = "{{tokenUsage}}";
|
|
21
|
+
const TOKEN_PERCENT_PLACEHOLDER = "{{tokenPercent}}";
|
|
22
|
+
// §tokenomics-window-partition — the four partition numbers. REQUIRED (fail-hard, the
|
|
23
|
+
// providers-env convention): the ceiling is DERIVED from these, never set directly
|
|
24
|
+
// (PLURNK_BUDGET_CEILING is retired — a settable ceiling let policy contradict physics).
|
|
25
|
+
const readPartitionIntFrom = (env, name, min) => {
|
|
26
|
+
const raw = env[name];
|
|
27
|
+
const n = Number.parseInt(raw ?? "", 10);
|
|
28
|
+
if (!Number.isFinite(n) || n < min)
|
|
29
|
+
throw new Error(`${name} must be an integer >= ${min}; got ${raw}`);
|
|
30
|
+
return n;
|
|
31
|
+
};
|
|
32
|
+
// Packet assembly (SPEC §packet-assembly) + the budget grinder (§grinder):
|
|
33
|
+
// builds the spec'd request packet, measures it, and reclaims window on overflow.
|
|
34
|
+
class PacketBuilder {
|
|
35
|
+
#db;
|
|
36
|
+
#schemes;
|
|
37
|
+
#telemetry;
|
|
38
|
+
// Boot-discovered runtime executors, late-injected on Engine after daemon
|
|
39
|
+
// start() — read through a thunk so the post-construction set is visible.
|
|
40
|
+
#executors;
|
|
41
|
+
// §tokenomics-window-partition — the partition is PER-ALIAS (#352), resolved per provider in
|
|
42
|
+
// #partitionFor and cached by alias; no boot-time global read.
|
|
43
|
+
constructor({ db, schemes, telemetry, executors }) {
|
|
44
|
+
this.#db = db;
|
|
45
|
+
this.#schemes = schemes;
|
|
46
|
+
this.#telemetry = telemetry;
|
|
47
|
+
this.#executors = executors;
|
|
48
|
+
// Prime the ACTIVE alias's partition NOW — capturing the env at construction, so a caller
|
|
49
|
+
// that sets PLURNK_SERVICE_* then constructs then restores (the budget tests, boot) reads
|
|
50
|
+
// the intended window. Per-alias overrides (a loop.run alias the boot env didn't set)
|
|
51
|
+
// resolve fresh at call time.
|
|
52
|
+
const bootAlias = resolveActiveAlias(process.env)?.alias ?? "";
|
|
53
|
+
this.#partitions.set(bootAlias, this.#resolvePartition(bootAlias));
|
|
54
|
+
}
|
|
55
|
+
// #352 — the generation envelope is PER-ALIAS: gemma keeps its measured llama-server policy
|
|
56
|
+
// envelope (n_predict honored to the context wall — the cap MUST bound it, providers#10);
|
|
57
|
+
// cloud aliases get a generous default and the backend self-clamps to its true output limit.
|
|
58
|
+
// scopeEnvToAlias resolves PLURNK_SERVICE_*_<alias> over the bare fallback with providers' own
|
|
59
|
+
// battle-tested suffix parser. Cached per alias; the boot-global case falls back to the active
|
|
60
|
+
// alias when a provider carries no side-table entry (a test Mock).
|
|
61
|
+
static #KNOBS = ["PLURNK_SERVICE_CTX", "PLURNK_SERVICE_REASONING", "PLURNK_SERVICE_ASSISTANT", "PLURNK_SERVICE_SAFETY"];
|
|
62
|
+
#partitions = new Map();
|
|
63
|
+
#resolvePartition(alias) {
|
|
64
|
+
const view = scopeEnvToAlias(process.env, alias, _a.#KNOBS);
|
|
65
|
+
return {
|
|
66
|
+
ctx: readPartitionIntFrom(view, "PLURNK_SERVICE_CTX", 1),
|
|
67
|
+
reasoning: readPartitionIntFrom(view, "PLURNK_SERVICE_REASONING", 0),
|
|
68
|
+
assistant: readPartitionIntFrom(view, "PLURNK_SERVICE_ASSISTANT", 0),
|
|
69
|
+
safety: readPartitionIntFrom(view, "PLURNK_SERVICE_SAFETY", 0),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// #377 — a per-alias partition knob present in env (same suffix/fold rule as providers'
|
|
73
|
+
// scopeEnvToAlias: PLURNK_SERVICE_<KNOB>_<alias>, alias case-folded, a key that IS a bare knob
|
|
74
|
+
// is never an override).
|
|
75
|
+
static #hasAliasKnob(alias) {
|
|
76
|
+
if (alias.length === 0)
|
|
77
|
+
return false;
|
|
78
|
+
const folded = alias.toLowerCase();
|
|
79
|
+
for (const knob of _a.#KNOBS) {
|
|
80
|
+
for (const key of Object.keys(process.env)) {
|
|
81
|
+
if (!key.startsWith(knob + "_"))
|
|
82
|
+
continue;
|
|
83
|
+
if (_a.#KNOBS.includes(key))
|
|
84
|
+
continue;
|
|
85
|
+
if (key.slice(knob.length + 1).toLowerCase() === folded && (process.env[key] ?? "").length > 0)
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
#partitionFor(provider) {
|
|
92
|
+
const alias = ProviderInstantiate.aliasOf(provider) ?? resolveActiveAlias(process.env)?.alias ?? "";
|
|
93
|
+
// #377 — §tokenomics-window-unpollable-deliberate: "CTX stands in for unknown physics" is
|
|
94
|
+
// only honest when the CTX is the operator's DELIBERATE policy for THIS alias. An unpollable
|
|
95
|
+
// window (provider.contextSize null — the provider's machine signal after env/probe/catalog
|
|
96
|
+
// all miss) riding BARE partition numbers is nobody's policy: numbers tuned for some other
|
|
97
|
+
// model silently applied, surfacing later as truncation/overflow telemetry (#352's failure
|
|
98
|
+
// mode recurring for every unpollable model). Fail loud at first use, naming both remedies.
|
|
99
|
+
if (provider.contextSize === null && !_a.#hasAliasKnob(alias)) {
|
|
100
|
+
// BEFORE the cache lookup — the constructor pre-primes the boot alias's partition, and a
|
|
101
|
+
// cache hit must never bypass this refusal (the check keys on the PROVIDER's null window,
|
|
102
|
+
// which the cached partition knows nothing about).
|
|
103
|
+
throw new Error(`window unpollable for alias '${alias || "<active>"}' and its partition rides bare numbers — nobody chose this envelope for this model. Either set PLURNK_PROVIDERS_CONTEXT_SIZE_${alias || "<alias>"} (so the window is known) or set the per-alias partition (PLURNK_SERVICE_{CTX,REASONING,ASSISTANT,SAFETY}_${alias || "<alias>"}) so the numbers are deliberate.`);
|
|
104
|
+
}
|
|
105
|
+
const hit = this.#partitions.get(alias);
|
|
106
|
+
if (hit !== undefined)
|
|
107
|
+
return hit;
|
|
108
|
+
const part = this.#resolvePartition(alias);
|
|
109
|
+
this.#partitions.set(alias, part);
|
|
110
|
+
return part;
|
|
111
|
+
}
|
|
112
|
+
// The generation envelope — REASONING + ASSISTANT, one undifferentiated pool, passed on
|
|
113
|
+
// every generate({maxTokens}): no decode is unbounded (§tokenomics-window-partition). Per
|
|
114
|
+
// alias (#352): gemma's measured envelope; a cloud alias's generous default the backend clamps.
|
|
115
|
+
decodeBudget(provider) {
|
|
116
|
+
const { reasoning, assistant } = this.#partitionFor(provider);
|
|
117
|
+
return reasoning + assistant;
|
|
118
|
+
}
|
|
119
|
+
// §tokenomics-window-partition ÷ §tokenomics-ceiling-calibrates-to-usage — the prompt ceiling
|
|
120
|
+
// is DERIVED, never set: effectiveWindow = min(CTX, provider window; CTX alone when the
|
|
121
|
+
// provider reports none) minus the reserves, divided by the loop's observed real/measured
|
|
122
|
+
// token ratio (usage.prompt is ground truth; a heuristic ruler shipped a 65k-real packet into
|
|
123
|
+
// a 49k window, #311). A fractional ceiling also budgeted the prompt against the window and
|
|
124
|
+
// FORGOT the response lives there too. Reserves exceeding the window is a configuration
|
|
125
|
+
// contradiction — fail hard. ratio floors at 1: an overcounting ruler never expands the budget.
|
|
126
|
+
// #274/#312 follow-up (owner): the CLIENT-facing gauge denominator — the prompt budget the
|
|
127
|
+
// packet actually lives under (effective window minus the partition reserves), in REAL token
|
|
128
|
+
// space (usage.prompt, the numerator, is real; the calibration ratio maps measured→real and
|
|
129
|
+
// has no business here). The raw n_ctx overstates usable room by the reserve total.
|
|
130
|
+
promptBudgetFor(provider) {
|
|
131
|
+
const { ctx, reasoning, assistant, safety } = this.#partitionFor(provider);
|
|
132
|
+
const effectiveWindow = provider.contextSize === null ? ctx : Math.min(ctx, provider.contextSize);
|
|
133
|
+
return Math.max(0, effectiveWindow - reasoning - assistant - safety);
|
|
134
|
+
}
|
|
135
|
+
// tokenRatio is real/measured, calibrated by Engine per loop (§tokenomics-ceiling-calibrates-to-usage).
|
|
136
|
+
// BELOW 1 is legitimate: a certified upper-bound ruler (no exact tokenizer)
|
|
137
|
+
// overmeasures, and the ceiling expands to observed truth — Engine applies the floor for
|
|
138
|
+
// exact rulers; this method trusts its input (run24: the floor-at-1 halved gbuild's window).
|
|
139
|
+
ceilingFor(provider, tokenRatio = 1) {
|
|
140
|
+
if (tokenRatio <= 0)
|
|
141
|
+
throw new Error(`ceilingFor: tokenRatio must be > 0, got ${tokenRatio}`);
|
|
142
|
+
const { ctx, reasoning, assistant, safety } = this.#partitionFor(provider);
|
|
143
|
+
const effectiveWindow = provider.contextSize === null ? ctx : Math.min(ctx, provider.contextSize);
|
|
144
|
+
const promptBudget = effectiveWindow - reasoning - assistant - safety;
|
|
145
|
+
if (promptBudget <= 0) {
|
|
146
|
+
const alias = ProviderInstantiate.aliasOf(provider) ?? resolveActiveAlias(process.env)?.alias ?? "";
|
|
147
|
+
throw new Error(`window partition contradiction for alias '${alias}': effective window ${effectiveWindow} <= reserves ${reasoning}+${assistant}+${safety}. A local (llama-server) alias needs its OWN measured envelope — set PLURNK_SERVICE_{CTX,REASONING,ASSISTANT,SAFETY}_${alias || "<alias>"} (the bare defaults are cloud-generous; #352).`);
|
|
148
|
+
}
|
|
149
|
+
return Math.floor(promptBudget / tokenRatio);
|
|
150
|
+
}
|
|
151
|
+
// Assemble the request half of the spec'd packet (Packet.json system
|
|
152
|
+
// and §user) BEFORE the provider call. The same packet object is then
|
|
153
|
+
// completed with assistant + assistantRaw after the model responds, so
|
|
154
|
+
// the stored packet and the wire payload share one source of truth.
|
|
155
|
+
async buildRequestPacket({ initialMessages, requirements, sessionId, runId, loopId, currentTurnSeq, provider, gitStatus, tokenRatio = 1, telemetryErrors: presetTelemetry, }) {
|
|
156
|
+
const byRole = (role) => initialMessages.filter((m) => m.role === role).map((m) => m.content).join("\n\n");
|
|
157
|
+
// plurnk.md (grammar/dialects) ONLY — the definition is the hot-path grammar.
|
|
158
|
+
// The scheme catalogue is its own `schemes` section below tools (§schemes-directory),
|
|
159
|
+
// NOT appended here: grammar 0.49+ is scheme-agnostic, so the service advertises
|
|
160
|
+
// the scheme set at packet-time (grammar#239 item 7) via SchemeRegistry.teach().
|
|
161
|
+
const system_definition = byRole("system");
|
|
162
|
+
// the prompt section sources from the loop's most recent prompt entry first
|
|
163
|
+
// (plurnk://prompt/<run>/<loop>/<N> for the highest N written to date).
|
|
164
|
+
// This is what inject + the turn-1 foist write into. Falls back to
|
|
165
|
+
// the runLoop caller's messages.user for tests that bypass the
|
|
166
|
+
// foist mechanism entirely.
|
|
167
|
+
const loopSeqRow = await this.#db.engine_loop_sequence.get({ loop_id: loopId });
|
|
168
|
+
const promptRows = (await this.#db.drain_get_all_prompt_bodies_for_loop.all({ pattern: `${promptLoopPrefix(runId, loopSeqRow?.sequence ?? loopId)}%` }))
|
|
169
|
+
.filter((r) => typeof r.content === "string" && r.content.length > 0);
|
|
170
|
+
// §prompt-auto-read (owner): the section is a PATHS list (the errors shape — no bodies);
|
|
171
|
+
// each prompt's content reaches the model through its foisted auto-READ in the log, and
|
|
172
|
+
// prior prompts stay READable by the listed address — never silently lost, never an
|
|
173
|
+
// unfair curation imposition. Fallback: callers that bypass the foist (bare messages)
|
|
174
|
+
// still get their user text rendered directly.
|
|
175
|
+
const prompt = promptRows.length > 0
|
|
176
|
+
? promptRows.map((r) => `* plurnk://${r.pathname.slice(1)}`).join("\n")
|
|
177
|
+
: byRole("user");
|
|
178
|
+
// Requirements is engine-sourced, NOT threaded from callers — that threading is
|
|
179
|
+
// exactly how it went missing (callers read the sysprompt but never the
|
|
180
|
+
// requirements). Read Paths.defaultRequirements (PLURNK_SERVICE_REQUIREMENTS env →
|
|
181
|
+
// requirements.md) fresh each build so edits take effect; a non-empty param wins.
|
|
182
|
+
const baseRequirements = requirements.length > 0 ? requirements : await readFile(Paths.defaultRequirements, "utf8");
|
|
183
|
+
// No injected syntax line: the grammar already headlines the system definition (§Syntax) and
|
|
184
|
+
// leads requirements.md, so a third copy here was pure duplication in the model's packet. PLAN
|
|
185
|
+
// is mandated unconditionally by plurnk.md §Imperatives (grammar 0.70 requires every turn to
|
|
186
|
+
// lead with PLAN), so the service injects no separate plan directive either.
|
|
187
|
+
const log = await this.#buildLog(runId);
|
|
188
|
+
const telemetryErrors = presetTelemetry ?? await this.buildTelemetryErrors(loopId, currentTurnSeq);
|
|
189
|
+
const countTokens = (t) => provider.countTokens(t); // §provider-surface-counttokens
|
|
190
|
+
// #367 — the capability sheet must reflect the LOOP MODE, not just session-enablement: an
|
|
191
|
+
// ask-mode loop advertises only what its dispatch gate (resolveForLoop) will accept, so the
|
|
192
|
+
// model is never taught a tag it'll then be 403'd on (the taught→emitted→rejected→508 spiral).
|
|
193
|
+
const activeSchemes = this.#schemes.resolveForLoop(await this.#loadLoopFlags(loopId));
|
|
194
|
+
const tools = this.#collectTools(await this.#sessionEnabled(sessionId), await SessionSettings.questionsEnabled(this.#db, sessionId), activeSchemes);
|
|
195
|
+
// Budget readout (SPEC.md §tokenomics). Two-pass: render the budget from
|
|
196
|
+
// the structured log's subtotals with a {{tokensFree}} placeholder, build
|
|
197
|
+
// the section list, measure the assembled total, resolve free, substitute.
|
|
198
|
+
// Subtotals come from the real log render — meta and fences included — not
|
|
199
|
+
// a serialized approximation. ceiling is the provider's window ×
|
|
200
|
+
// PLURNK_BUDGET_CEILING (null when no window is reported → headline
|
|
201
|
+
// omitted, section lines still shown). §tokenomics-render-weight-budget
|
|
202
|
+
const ceiling = this.ceilingFor(provider, tokenRatio);
|
|
203
|
+
const budgetReadout = this.#renderBudget(PacketWire.measureLogBudget(log, countTokens), ceiling);
|
|
204
|
+
// The default packet: an ordered list of addressable sections (§packet-assembly).
|
|
205
|
+
// `slot` is a TRUST boundary (and the prompt-cache boundary): system holds only
|
|
206
|
+
// framework-authored, non-injectable sections — the static head (definition/tools/
|
|
207
|
+
// schemes/policy) forms the cached prefix, then the volatile-but-trusted tail of
|
|
208
|
+
// errors/git/budget; user holds injectable content (the log, the operator prompt) plus
|
|
209
|
+
// the requirements footer. The budget section carries its {{tokensFree}} placeholders
|
|
210
|
+
// here; they resolve below once the assembled total is known.
|
|
211
|
+
const inject = await readPacketInject(); // #240 — operator section, per-turn, fail-hard on a broken path
|
|
212
|
+
const sessionRoot = (await this.#db.envelope_get_session.get({ id: sessionId }))?.project_root ?? null;
|
|
213
|
+
const systemPolicy = await readSystemPolicy(); // ~/.plurnk/AGENTS.md (or PLURNK_SERVICE_POLICY)
|
|
214
|
+
const projectPolicy = await readProjectPolicy(sessionRoot); // <projectRoot>/AGENTS.md (or PLURNK_SERVICE_PROJECT)
|
|
215
|
+
// Child-orientation (§child-orientation): the live things THIS run holds — open streams +
|
|
216
|
+
// unconcluded child runs — surfaced every turn as terse `* <status> <path>` pointers (same shape
|
|
217
|
+
// as errors) just above the errors section. Orienting STATE so the model never loses track of
|
|
218
|
+
// what it's holding (the premature-terminate trap), never advice on what to do. Empty → omitted.
|
|
219
|
+
const childStreams = (await this.#db.engine_child_streams_open.all({ run_id: runId }))
|
|
220
|
+
.map((s) => ({ status: "active", path: renderAddress(s.scheme, s.pathname) }));
|
|
221
|
+
const childRuns = (await this.#db.engine_child_runs_live.all({ run_id: runId }))
|
|
222
|
+
.map((r) => ({ status: r.status, path: `run://${r.name}` }));
|
|
223
|
+
const defaults = [
|
|
224
|
+
{ name: "definition", slot: "system", header: null, content: system_definition, tokens: 0 },
|
|
225
|
+
{ name: "tools", slot: "system", header: null, content: tools.join("\n"), tokens: 0 }, // titleless — the examples flow on from plurnk.md (definition) directly above
|
|
226
|
+
{ name: "schemes", slot: "system", header: "Plurnk Service Schemes", content: this.#schemes.teach(), tokens: 0 },
|
|
227
|
+
...(inject !== null ? [{ name: "inject", slot: "system", header: "Plurnk Operator Notes", content: inject, tokens: 0 }] : []),
|
|
228
|
+
// 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.
|
|
229
|
+
{ name: "system-policy", slot: "system", header: "Plurnk Service Policy", content: systemPolicy ?? "", tokens: 0 },
|
|
230
|
+
{ name: "project-policy", slot: "system", header: "Project Policy", content: projectPolicy ?? "", tokens: 0 },
|
|
231
|
+
// The packet split is a TRUST boundary: system carries only framework-authored, non-injectable
|
|
232
|
+
// sections; anything that could carry attacker-reachable text (a READ result, exec output, the
|
|
233
|
+
// model's own mirrored bytes) stays in user. errors + git are framework status — the errors
|
|
234
|
+
// section is uri+status POINTERS (the error item + body live in the log), git is counts — so
|
|
235
|
+
// neither is an injection surface; both sit at the bottom of system, just above budget-the-law.
|
|
236
|
+
// child-orientation: what THIS run holds live — streams then runs — just above errors. Terse
|
|
237
|
+
// pointers (the path is the actionable address the model READs/OPENs/KILLs), never advice. §child-orientation
|
|
238
|
+
{ name: "child-streams", slot: "system", header: "Plurnk Service Child Streams", content: PacketWire.renderChildPointers(childStreams), tokens: 0 },
|
|
239
|
+
{ name: "child-runs", slot: "system", header: "Plurnk Service Active Child Worker Runs", content: PacketWire.renderChildPointers(childRuns), tokens: 0 },
|
|
240
|
+
{ name: "errors", slot: "system", header: "Plurnk Service Errors", content: PacketWire.renderErrors(telemetryErrors), tokens: 0 },
|
|
241
|
+
{ name: "git", slot: "system", header: "Plurnk Service Git Status", content: PacketWire.renderGit(gitStatus), tokens: 0 },
|
|
242
|
+
// budget — LAW (a hard ceiling the model must obey).
|
|
243
|
+
{ name: "budget", slot: "system", header: "Plurnk Service Budget", content: budgetReadout, tokens: 0 },
|
|
244
|
+
// §prompt-auto-read (owner): the prompts section is the system slot's very bottom —
|
|
245
|
+
// a paths-only list (the errors shape); bodies arrive via the foisted auto-READ.
|
|
246
|
+
{ name: "prompt", slot: "system", header: "Plurnk Service User Prompts", content: prompt, tokens: 0 },
|
|
247
|
+
// 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.
|
|
248
|
+
{ name: "log", slot: "user", header: "Plurnk Service Log", content: PacketWire.renderLog(log, countTokens), tokens: 0 },
|
|
249
|
+
// requirements renders LAST — the user-slot footer, the syntax contract closest to the model's turn (a recency carve-out for weak models).
|
|
250
|
+
{ name: "requirements", slot: "user", header: "Plurnk Service Requirements", content: baseRequirements, tokens: 0 },
|
|
251
|
+
];
|
|
252
|
+
// Plugin packet control (§packet-assembly): trusted schemes rewrite the
|
|
253
|
+
// default list — add, remove, reorder — in-process, before measurement.
|
|
254
|
+
const sections = await this.#schemes.transformSections(defaults);
|
|
255
|
+
// Pass 1: measure the assembled total with the placeholder budget in
|
|
256
|
+
// place, resolve free/percent, substitute into the budget section.
|
|
257
|
+
let total = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
|
|
258
|
+
{
|
|
259
|
+
const budgetSec = sections.find((s) => s.name === "budget"); // a plugin may have removed it
|
|
260
|
+
if (budgetSec) {
|
|
261
|
+
// Curation pressure gates on OCCUPANCY (§tokenomics-pressure-gates-on-occupancy, #308):
|
|
262
|
+
// the Turns/Heaviest tables are a standing FOLD-target list, and a high-headroom model
|
|
263
|
+
// reads them as a todo — burning turns on token hygiene at 3% of a 64k window. Under
|
|
264
|
+
// half-full, the headline's numbers stand alone (truncate at the first blank line) and
|
|
265
|
+
// the total RE-measures — the substituted figures must reconcile with what ships.
|
|
266
|
+
// A null ceiling can't calibrate, so the full readout stays.
|
|
267
|
+
if ((total / ceiling) * 100 < 50) {
|
|
268
|
+
const cut = budgetSec.content.indexOf("\n\n");
|
|
269
|
+
if (cut !== -1) {
|
|
270
|
+
budgetSec.content = budgetSec.content.slice(0, cut);
|
|
271
|
+
total = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const tokensFree = Math.max(0, ceiling - total); // free floors at 0 on overshoot — §tokenomics-over-budget-floor
|
|
275
|
+
const percent = (total / ceiling) * 100; // usage as % of the ceiling — §tokenomics-context-percent
|
|
276
|
+
budgetSec.content = budgetSec.content
|
|
277
|
+
.replace(TOKEN_USAGE_PLACEHOLDER, String(total))
|
|
278
|
+
// Any nonzero usage under 1% is "<1" — Math.round alone claimed "1%" from 0.51%,
|
|
279
|
+
// overstating a near-empty window.
|
|
280
|
+
.replace(TOKEN_PERCENT_PLACEHOLDER, total > 0 && percent < 1 ? "<1" : String(Math.round(percent)))
|
|
281
|
+
.replace(TOKENS_FREE_PLACEHOLDER, String(tokensFree));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Pass 2: per-section render-weight + the assembled packet total (post
|
|
285
|
+
// substitution — the placeholder/number length delta is negligible).
|
|
286
|
+
for (const s of sections)
|
|
287
|
+
s.tokens = countTokens(PacketWire.renderSection(s));
|
|
288
|
+
const packetTokens = countTokens(PacketWire.renderSlot(sections, "system")) + countTokens(PacketWire.renderSlot(sections, "user"));
|
|
289
|
+
return { tokens: packetTokens, sections, telemetryErrors };
|
|
290
|
+
}
|
|
291
|
+
// Budget readout body, rendered into the `## Plurnk Service Budget` section.
|
|
292
|
+
// Headline `ceiling/free` only when a ceiling exists; section lines for the
|
|
293
|
+
// curatable index/log weight the model can FOLD back. tokensFree is a
|
|
294
|
+
// placeholder here — buildRequestPacket substitutes it after measuring the packet.
|
|
295
|
+
#renderBudget(log, ceiling) {
|
|
296
|
+
const lines = [];
|
|
297
|
+
lines.push(`Token Ceiling ${ceiling} · Token Usage ${TOKEN_USAGE_PLACEHOLDER} (${TOKEN_PERCENT_PLACEHOLDER}%) · Tokens Free ${TOKENS_FREE_PLACEHOLDER}`);
|
|
298
|
+
if (log.entries > 0) {
|
|
299
|
+
if (lines.length > 0)
|
|
300
|
+
lines.push("");
|
|
301
|
+
lines.push(`Log entries: ${log.entries} entries, ${log.tokens} tokens`);
|
|
302
|
+
// Per-turn weight — chronological (oldest first); the turn is the grinder's
|
|
303
|
+
// rollback unit and the rail folds the newest first (§tokenomics {§tokenomics-turn-totals}).
|
|
304
|
+
if (log.byTurn.length > 0) {
|
|
305
|
+
lines.push("", "Turns:", "| turn | tokens |", "|---|--:|");
|
|
306
|
+
for (const t of log.byTurn)
|
|
307
|
+
lines.push(`| ${t.turn} | ${t.tokens} |`);
|
|
308
|
+
}
|
|
309
|
+
// The heaviest individual log items — the FOLD targets behind the weight
|
|
310
|
+
// (§tokenomics {§tokenomics-largest-entries}). "items", not "entries": the readout
|
|
311
|
+
// lists log:/// rows (log items), distinct from catalog entries (plurnk.md: "EDIT
|
|
312
|
+
// is only for entries. Do not attempt to edit log items.").
|
|
313
|
+
if (log.largest.length > 0) {
|
|
314
|
+
lines.push("", "Heaviest items (FOLD targets — folding reclaims their tokens):", "| item | tokens |", "|---|--:|");
|
|
315
|
+
for (const e of log.largest)
|
|
316
|
+
lines.push(`| ${e.path} | ${e.tokens} |`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return lines.join("\n");
|
|
320
|
+
}
|
|
321
|
+
// #328 — the per-session client execs policy narrows what the packet ADVERTISES, matching what
|
|
322
|
+
// dispatch refuses: a session-disabled tag is absent from the capability sheet and the doc set,
|
|
323
|
+
// never taught-then-refused. No policy (execs unset) → everything boot-registered shows.
|
|
324
|
+
async #sessionEnabled(sessionId) {
|
|
325
|
+
const { execs } = await SessionSettings.read(this.#db, sessionId);
|
|
326
|
+
if (execs === null)
|
|
327
|
+
return () => true;
|
|
328
|
+
return (tag) => Policy.isEnabled(tag, execs);
|
|
329
|
+
}
|
|
330
|
+
// The ## Plurnk Service Tools capability sheet (SPEC §tools). A hook: each enabled
|
|
331
|
+
// capability contributes one line, rendered above Requirements so the model sees what
|
|
332
|
+
// it can do before the rules. Each available executor tag contributes its self-documenting
|
|
333
|
+
// example (plurnk-execs#7), retiring the blind EXEC.
|
|
334
|
+
// The capability sheet — the live tool surface (wired executor tags). §tools-capability-sheet
|
|
335
|
+
// Mirror of Dispatcher.#loadLoopFlags — the packet reads the SAME persisted flags the gate does.
|
|
336
|
+
async #loadLoopFlags(loopId) {
|
|
337
|
+
const row = await this.#db.engine_get_loop_flags.get({ loop_id: loopId });
|
|
338
|
+
if (row === undefined)
|
|
339
|
+
return DEFAULT_LOOP_FLAGS;
|
|
340
|
+
try {
|
|
341
|
+
return { ...DEFAULT_LOOP_FLAGS, ...JSON.parse(row.flags) };
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
return DEFAULT_LOOP_FLAGS;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
#collectTools(sessionEnabled, questionsOn = false, activeSchemes) {
|
|
348
|
+
const tools = [];
|
|
349
|
+
// §send-300-choices — the one-liner rides ONLY where questions are enabled (allowed +
|
|
350
|
+
// client-requested); the fuller questions.md doc injects through docEntries the same way.
|
|
351
|
+
if (questionsOn)
|
|
352
|
+
tools.push(teachingLine("<<SEND[300]:Deploy where?;staging;production:SEND"));
|
|
353
|
+
// Each available runtime tag contributes its self-documenting example —
|
|
354
|
+
// the example carries syntax + purpose, so there's no prose line. Tags
|
|
355
|
+
// with no example (sh/node, covered by the core prompt) contribute
|
|
356
|
+
// nothing; available-only, so the model never sees an unusable tag. `* `
|
|
357
|
+
// bullets + bare op forms match the packet's list/op rendering (no `- `,
|
|
358
|
+
// no backticks — see packet-wire.ts).
|
|
359
|
+
const executors = this.#executors();
|
|
360
|
+
if (executors !== undefined) {
|
|
361
|
+
const excluded = docsExcludeSet();
|
|
362
|
+
const runtimes = executors.availableRuntimes();
|
|
363
|
+
// execs#24 (operator design, via the client) + the #367 filter CORRECTED: the per-tag
|
|
364
|
+
// runtime schemes are READ faces (reading sh:// history is legitimate in ask mode), so
|
|
365
|
+
// keying the sheet on activeSchemes.has(tag) filtered NOTHING — the untested corner of
|
|
366
|
+
// be8a77c. The sheet's lines are EXEC-usage examples, so the key is the 'exec' scheme
|
|
367
|
+
// (the op face, excludedInAsk). When it's inactive, say so POSITIVELY: plurnk.md still
|
|
368
|
+
// teaches EXEC as language, and silent absence measurably invites confabulated runtimes
|
|
369
|
+
// (the client's 5-probe: 500×3). Core speaks the line — only core knows the gate closed.
|
|
370
|
+
const execActive = activeSchemes === undefined || activeSchemes.has("exec");
|
|
371
|
+
if (runtimes.length > 0 && !execActive) {
|
|
372
|
+
tools.push(teachingLine("EXEC operations are disabled for this loop — do not run commands; answer or advise directly"));
|
|
373
|
+
return tools;
|
|
374
|
+
}
|
|
375
|
+
for (const tag of runtimes) {
|
|
376
|
+
if (excluded.has(tag))
|
|
377
|
+
continue; // #240 — PLURNK_SERVICE_DOCS_EXCLUDE drops the oneliner + the doc
|
|
378
|
+
if (!sessionEnabled(tag))
|
|
379
|
+
continue; // #328 — session-disabled tags aren't advertised
|
|
380
|
+
const entry = executors.entry(tag);
|
|
381
|
+
// #240 — identical treatment with the scheme directory: the example IS the oneliner,
|
|
382
|
+
// the fuller doc (materialized at plurnk://docs/<tag>.md) rides an inline link whose
|
|
383
|
+
// token cost lives on that manifest entry. No example → no line (like a provisional scheme).
|
|
384
|
+
if (entry?.example)
|
|
385
|
+
tools.push(teachingLine(entry.example));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return tools;
|
|
389
|
+
}
|
|
390
|
+
// #note12 — the daughter-provided reference docs (schemes' + execs' `documentation`),
|
|
391
|
+
// materialized at plurnk:///docs/<name>.md by loop_run (like operator docs) so the
|
|
392
|
+
// catalogue's doc-links READ and the manifest carries each doc's token cost.
|
|
393
|
+
async docEntries(sessionId) {
|
|
394
|
+
const out = this.#schemes.docs(); // scheme docs already drop PLURNK_SERVICE_DOCS_EXCLUDE names
|
|
395
|
+
// §send-300-choices — the conditional teaching: questions.md (from the docs corpus)
|
|
396
|
+
// materializes ONLY for enabled sessions — the same conditional-doc mechanism as the EXEC
|
|
397
|
+
// plugin docs below. An un-enabled session is never taught the op it can't use.
|
|
398
|
+
if (await SessionSettings.questionsEnabled(this.#db, sessionId)) {
|
|
399
|
+
try {
|
|
400
|
+
const q = await readFile(resolvePath(Paths.schemeDocs, "questions.md"), "utf8");
|
|
401
|
+
if (q.length > 0)
|
|
402
|
+
out.push({ name: "questions", content: q });
|
|
403
|
+
}
|
|
404
|
+
catch { /* docs package without questions.md — nothing to inject */ }
|
|
405
|
+
}
|
|
406
|
+
const executors = this.#executors();
|
|
407
|
+
if (executors !== undefined) {
|
|
408
|
+
const excluded = docsExcludeSet();
|
|
409
|
+
const sessionEnabled = await this.#sessionEnabled(sessionId); // #328 — no doc for a disabled tag
|
|
410
|
+
for (const tag of executors.availableRuntimes()) {
|
|
411
|
+
if (excluded.has(tag))
|
|
412
|
+
continue; // #240 — exec docs honor the same exclude
|
|
413
|
+
if (!sessionEnabled(tag))
|
|
414
|
+
continue;
|
|
415
|
+
const doc = executors.entry(tag)?.documentation;
|
|
416
|
+
if (doc !== undefined && doc.length > 0)
|
|
417
|
+
out.push({ name: tag, content: doc });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
// SPEC §grinder — the budget grinder. Runs pre-LLM (in runTurn, after the packet
|
|
423
|
+
// is built, before provider.generate); fires only on actual overflow. One rule:
|
|
424
|
+
// fold the NEWEST turn boundary's open rows (errors exempt) — never history —
|
|
425
|
+
// strike, rebuild, re-measure. Folds (never deletes). The strike it raises and
|
|
426
|
+
// the hard-stop it can signal are returned to runLoop, which owns abandonment.
|
|
427
|
+
// §grinder-overflow-only — fires only on actual overflow, never speculatively
|
|
428
|
+
async enforceBudget({ packet, provider, runId, loopId, turnId, mintSequence, tokenRatio = 1, rebuild }) {
|
|
429
|
+
const ceiling = this.ceilingFor(provider, tokenRatio);
|
|
430
|
+
const measure = (p) => p.tokens;
|
|
431
|
+
if (measure(packet) <= ceiling)
|
|
432
|
+
return { packet, fit: true, struck: false };
|
|
433
|
+
// ONE rule, every turn — turn 1 and turn 101 alike (§grinder-layer1-rollback): fold the
|
|
434
|
+
// NEWEST turn boundary's still-open rows (the prior turn's emissions + this turn's
|
|
435
|
+
// pre-model rows; errors exempt) in one set-op, strike once, rebuild, re-measure.
|
|
436
|
+
// THE DOCTRINE: the log is the model's memory and the model ALONE curates history — the
|
|
437
|
+
// grinder never reaches back; it only blocks NEW memories from landing when there is no
|
|
438
|
+
// room, forcing the model to do its own housekeeping (the strike is the escalation,
|
|
439
|
+
// §grinder-compaction-strikes; a model that won't curate hard-413s/strikes out).
|
|
440
|
+
// Mint the overflow as a terse op='error' log row BEFORE the rebuild, so the rebuild's
|
|
441
|
+
// re-derived errors section surfaces it THIS turn — the warning lands at strike 1, not a
|
|
442
|
+
// turn late. The row is grinder-exempt, so it stacks into a visible recurrence trail. It
|
|
443
|
+
// sits at the turn's reserved running sequence (mintSequence) so it never collides with the
|
|
444
|
+
// post-generate dispatch rows. §telemetry-uniform-error-channel, §grinder-overflow-error-row
|
|
445
|
+
await this.#telemetry.mintEngineError("budget_overflow", { runId, loopId, turnId, sequence: mintSequence });
|
|
446
|
+
await this.#db.engine_grinder_fold_newest_turn.run({ loop_id: loopId, turn_id: turnId });
|
|
447
|
+
const current = await rebuild();
|
|
448
|
+
return { packet: current, fit: measure(current) <= ceiling, struck: true };
|
|
449
|
+
}
|
|
450
|
+
// Complete the packet by adding the model's response. After this the
|
|
451
|
+
// packet matches Packet.json fully and is ready for storage.
|
|
452
|
+
completePacket(requestPacket, assistant, assistantRaw, provider) {
|
|
453
|
+
const assistantTokens = provider.countTokens(assistant.content);
|
|
454
|
+
return {
|
|
455
|
+
tokens: requestPacket.tokens + assistantTokens,
|
|
456
|
+
sections: requestPacket.sections,
|
|
457
|
+
telemetryErrors: requestPacket.telemetryErrors,
|
|
458
|
+
assistant,
|
|
459
|
+
assistantRaw,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
// SPEC §telemetry: model-facing alert surface.
|
|
463
|
+
// Two sources, merged on each packet build:
|
|
464
|
+
// 1. Previous-turn action-bound failures (status_rx >= 400 on log_entries).
|
|
465
|
+
// 2. Engine-buffered actionless failures (no_send, parse, watchdog, rails).
|
|
466
|
+
// Buffer drains on read — each error appears in exactly one packet.
|
|
467
|
+
async buildTelemetryErrors(loopId, currentTurnSeq) {
|
|
468
|
+
// The uniform error channel (§telemetry-uniform-error-channel): every 4xx/5xx log row
|
|
469
|
+
// becomes a LogCoordinate-positioned TelemetryEvent — a terse pointer; the model READs the
|
|
470
|
+
// row for its term + detail. Buffer events that point at the model's own emission keep their
|
|
471
|
+
// ContentOffset position. info-level notices (progress) are not errors and never surface here.
|
|
472
|
+
const rows = await this.#db.engine_render_telemetry_errors.all({ loop_id: loopId, current_turn_seq: currentTurnSeq });
|
|
473
|
+
const logErrors = rows.map((r) => ({
|
|
474
|
+
source: "engine:rail",
|
|
475
|
+
kind: "log_error",
|
|
476
|
+
level: "error",
|
|
477
|
+
status: r.status_rx,
|
|
478
|
+
position: { type: "log-coordinate", coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}/${r.op}` },
|
|
479
|
+
}));
|
|
480
|
+
const bufferEvents = this.#telemetry.drain(loopId).filter((e) => e.level !== "info");
|
|
481
|
+
return [...bufferEvents, ...logErrors];
|
|
482
|
+
}
|
|
483
|
+
// SPEC §packet the log section — chronological action-entries for the loop.
|
|
484
|
+
// Snapshot is taken at packet build (pre-dispatch this turn), so it
|
|
485
|
+
// reflects "what has happened before this turn." Each row carries a
|
|
486
|
+
// log:///<loop_seq>/<turn_seq>/<sequence> coordinate the model can READ.
|
|
487
|
+
async #buildLog(runId) {
|
|
488
|
+
// SPEC §packet-terms: runs own log entries — log is the run's history,
|
|
489
|
+
// not the loop's. Span all loops in the run so the model sees
|
|
490
|
+
// earlier loops' work as conversational memory.
|
|
491
|
+
//
|
|
492
|
+
// User prompts are first-class log entries: runTurn writes a
|
|
493
|
+
// client-origin SEND[200] row at sequence=0 of each new
|
|
494
|
+
// turn-1. Prompts thus surface naturally in this query — no
|
|
495
|
+
// synthetic / shim layer.
|
|
496
|
+
const rows = await this.#db.engine_render_log.all({ run_id: runId });
|
|
497
|
+
return rows.map((r) => ({
|
|
498
|
+
coordinate: `${r.loop_seq}/${r.turn_seq}/${r.sequence}`,
|
|
499
|
+
origin: r.origin,
|
|
500
|
+
op: r.op,
|
|
501
|
+
suffix: r.suffix,
|
|
502
|
+
signal: r.signal === null ? null : JSON.parse(r.signal),
|
|
503
|
+
target: {
|
|
504
|
+
scheme: r.scheme,
|
|
505
|
+
username: r.username, password: r.password,
|
|
506
|
+
hostname: r.hostname, port: r.port,
|
|
507
|
+
pathname: r.pathname,
|
|
508
|
+
params: r.params === null ? null : JSON.parse(r.params),
|
|
509
|
+
fragment: r.fragment,
|
|
510
|
+
},
|
|
511
|
+
status: r.status_rx,
|
|
512
|
+
rx: r.mimetype_rx === "application/json" ? JSON.parse(r.rx) : r.rx,
|
|
513
|
+
mimetype_rx: r.mimetype_rx,
|
|
514
|
+
tx: r.mimetype_tx === "application/json" ? JSON.parse(r.tx) : r.tx,
|
|
515
|
+
mimetype_tx: r.mimetype_tx,
|
|
516
|
+
folded: r.expanded === 0,
|
|
517
|
+
source: r.source,
|
|
518
|
+
attrs: r.attrs === null ? null : JSON.parse(r.attrs),
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
_a = PacketBuilder;
|
|
523
|
+
export default PacketBuilder;
|
|
524
|
+
//# 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,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,mEAAmE;AACnE,sEAAsE;AACtE,0CAA0C;AAC1C,OAAO,UAAkC,MAAM,kBAAkB,CAAC;AAIlE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,6EAA6E;AAC7E,wEAAwE;AACx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Q,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;gBAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,MAAM,EAAE,CAAC,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,17 @@
|
|
|
1
|
+
export type PluginKind = "provider" | "scheme" | "mimetype";
|
|
2
|
+
export interface PluginManifest {
|
|
3
|
+
kind: PluginKind;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DiscoveredPlugin {
|
|
7
|
+
packageName: string;
|
|
8
|
+
packagePath: string;
|
|
9
|
+
manifest: PluginManifest;
|
|
10
|
+
}
|
|
11
|
+
export default class PluginLoader {
|
|
12
|
+
#private;
|
|
13
|
+
static discoverPlugins(nodeModulesDir: string): Promise<DiscoveredPlugin[]>;
|
|
14
|
+
static loadPlugin(plugin: DiscoveredPlugin): Promise<unknown>;
|
|
15
|
+
static assertIdentityMatch(plugin: DiscoveredPlugin, instance: unknown): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=PluginLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginLoader.d.ts","sourceRoot":"","sources":["../../src/core/PluginLoader.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,CAAC,OAAO,OAAO,YAAY;;IAK7B,OAAa,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0BhF;IAQD,OAAa,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CASlE;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAiC5E;CACJ"}
|