@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,453 @@
|
|
|
1
|
+
// Packet → wire markdown projection. Single source of truth for how the
|
|
2
|
+
// Packet's ordered list of sections renders to ChatMessage.content
|
|
3
|
+
// strings the LLM receives. Engine imports this for the wire payload; the
|
|
4
|
+
// digest tool imports it to write byte-identical packetNNN.{system,user}.md
|
|
5
|
+
// files. No second implementation, no drift.
|
|
6
|
+
//
|
|
7
|
+
// Format: markdown. user picked it over rummy's XML and JSON alternatives
|
|
8
|
+
// 2026-05-22. Standard markdown idioms only — headers as section delimiters,
|
|
9
|
+
// fenced code blocks for entry bodies, lists for arrays. No invented
|
|
10
|
+
// separators. Models parse markdown natively.
|
|
11
|
+
//
|
|
12
|
+
// Section headers follow the `## Plurnk Service X` convention so the model
|
|
13
|
+
// sees consistent framing across every section it might receive. Sections
|
|
14
|
+
// with no content are omitted entirely (no empty headers in the wire).
|
|
15
|
+
import { MimetypeBinary } from "../content/index.js";
|
|
16
|
+
import { renderAddress } from "./plurnk-uri.js";
|
|
17
|
+
export default class PacketWire {
|
|
18
|
+
// Render the sections in `slot` to one ChatMessage.content string. Sections
|
|
19
|
+
// render in list order; empties are omitted (no empty headers on the wire);
|
|
20
|
+
// each is `## {header}\n\n{content}` (or bare content when header is null),
|
|
21
|
+
// trailing newlines stripped, joined with a blank line.
|
|
22
|
+
static renderSlot(sections, slot) {
|
|
23
|
+
return sections
|
|
24
|
+
.filter((s) => s.slot === slot)
|
|
25
|
+
.map((s) => PacketWire.renderSection(s))
|
|
26
|
+
.filter((p) => p.length > 0)
|
|
27
|
+
.join("\n\n");
|
|
28
|
+
}
|
|
29
|
+
// One section → its markdown block (`## {header}\n\n{content}`, or bare
|
|
30
|
+
// content when header is null/empty), trailing newlines stripped. Empty
|
|
31
|
+
// content renders to "" so renderSlot drops it. This is the unit the
|
|
32
|
+
// per-section `tokens` weight is measured over.
|
|
33
|
+
static renderSection(s) {
|
|
34
|
+
if (typeof s.content !== "string" || s.content.length === 0)
|
|
35
|
+
return "";
|
|
36
|
+
const header = typeof s.header === "string" && s.header.length > 0 ? s.header : null;
|
|
37
|
+
return (header ? `## ${header}\n\n${s.content}` : s.content).replace(/\n+$/, "");
|
|
38
|
+
}
|
|
39
|
+
// The errors section content: the structured telemetry events rendered to
|
|
40
|
+
// meta lines (+ snippet blocks). "" when empty (the section is omitted). The
|
|
41
|
+
// events are ALSO kept structured on the packet (packet.telemetryErrors) —
|
|
42
|
+
// ephemeral (the buffer drains on read), so the packet is their only home.
|
|
43
|
+
static renderErrors(errors) {
|
|
44
|
+
const events = Array.isArray(errors) ? errors : [];
|
|
45
|
+
return events.length > 0 ? PacketWire.#renderTelemetryErrors(events) : "";
|
|
46
|
+
}
|
|
47
|
+
// The Child Streams / Child Runs sections (§child-orientation) — the OPPOSITE of advice: terse
|
|
48
|
+
// `* <status> <path>` pointers (same shape as the errors section) to the live things the run holds,
|
|
49
|
+
// so the model SEES its open streams + unconcluded workers each turn and reasons for itself (READ /
|
|
50
|
+
// OPEN / KILL via the path). Orienting state, never an instruction. "" when none → section omitted.
|
|
51
|
+
static renderChildPointers(rows) {
|
|
52
|
+
const items = Array.isArray(rows) ? rows : [];
|
|
53
|
+
return items.map((r) => `* ${String(r.status)} ${String(r.path)}`).join("\n");
|
|
54
|
+
}
|
|
55
|
+
// The git section content: the working-tree summary. "" when absent.
|
|
56
|
+
static renderGit(git) {
|
|
57
|
+
return git === null || git === undefined ? "" : PacketWire.#renderGitState(git);
|
|
58
|
+
}
|
|
59
|
+
// The log section's content: the model's curated rows rendered to markdown
|
|
60
|
+
// (the same #renderLogEntries the wire ships). Empty log → "" (omitted).
|
|
61
|
+
static renderLog(entries, countTokens) {
|
|
62
|
+
const log = Array.isArray(entries) ? entries : [];
|
|
63
|
+
return log.length > 0 ? PacketWire.#renderLogEntries(log, countTokens) : "";
|
|
64
|
+
}
|
|
65
|
+
// Read one section's content by name off a packet (Engine's or re-parsed).
|
|
66
|
+
// The legible accessor — consumers name the section they want instead of
|
|
67
|
+
// indexing a fixed shape. Missing section / non-string content → "".
|
|
68
|
+
static sectionContent(packet, name) {
|
|
69
|
+
const s = packet.sections?.find((x) => x.name === name);
|
|
70
|
+
return typeof s?.content === "string" ? s.content : "";
|
|
71
|
+
}
|
|
72
|
+
// Project a packet to the request ChatMessage[] for the wire: one message
|
|
73
|
+
// per slot. Engine calls this directly; the result is what provider.generate
|
|
74
|
+
// receives. The digest calls renderSlot for byte-identical packetNNN files.
|
|
75
|
+
static packetToWireMessages(packet) {
|
|
76
|
+
const sections = packet.sections ?? [];
|
|
77
|
+
return [
|
|
78
|
+
{ role: "system", content: PacketWire.renderSlot(sections, "system") },
|
|
79
|
+
{ role: "user", content: PacketWire.renderSlot(sections, "user") },
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
// Measure the curatable log section's budget subtotals from the STRUCTURED
|
|
83
|
+
// log (the foldable unit), using the provider's tokenizer — meta lines and
|
|
84
|
+
// fences included, matching what ships. Feeds the per-turn rollup (chronological;
|
|
85
|
+
// the grinder folds the newest turn) and the FOLD unit (heaviest entries) — the
|
|
86
|
+
// two budget levers the model can pull (§tokenomics {§tokenomics-turn-totals},
|
|
87
|
+
// {§tokenomics-largest-entries}). Build-time only; the stored log section is
|
|
88
|
+
// the rendered result. §tokenomics-render-weight-budget
|
|
89
|
+
static measureLogBudget(entries, countTokens) {
|
|
90
|
+
const logEntries = Array.isArray(entries) ? entries : [];
|
|
91
|
+
const logBody = logEntries.length > 0 ? PacketWire.#renderLogEntries(logEntries, countTokens) : "";
|
|
92
|
+
const HEAVIEST_COUNT = 5;
|
|
93
|
+
const byTurn = new Map();
|
|
94
|
+
const perEntry = [];
|
|
95
|
+
for (const e of logEntries) {
|
|
96
|
+
const weight = countTokens(PacketWire.#renderLogEntries([e], countTokens));
|
|
97
|
+
const coordinate = typeof e.coordinate === "string" ? e.coordinate : null;
|
|
98
|
+
const op = typeof e.op === "string" && e.op.length > 0 ? e.op : null;
|
|
99
|
+
// Turn = the loop_seq/turn_seq prefix of the coordinate
|
|
100
|
+
// (log:///<loop_seq>/<turn_seq>/<sequence>); the sequence drops off.
|
|
101
|
+
if (coordinate !== null) {
|
|
102
|
+
const turn = coordinate.split("/").slice(0, 2).join("/");
|
|
103
|
+
byTurn.set(turn, (byTurn.get(turn) ?? 0) + weight);
|
|
104
|
+
}
|
|
105
|
+
const path = PacketWire.#entryPath(coordinate, op);
|
|
106
|
+
if (path !== null)
|
|
107
|
+
perEntry.push({ path, tokens: weight });
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
entries: logEntries.length,
|
|
111
|
+
tokens: logBody ? countTokens(`## Plurnk Service Log\n\n${logBody}`) : 0,
|
|
112
|
+
byTurn: [...byTurn.entries()]
|
|
113
|
+
.map(([turn, tokens]) => ({ turn, tokens }))
|
|
114
|
+
.toSorted((a, b) => {
|
|
115
|
+
const [al, at] = a.turn.split("/").map(Number);
|
|
116
|
+
const [bl, bt] = b.turn.split("/").map(Number);
|
|
117
|
+
return al - bl || at - bt;
|
|
118
|
+
}),
|
|
119
|
+
largest: perEntry.toSorted((a, b) => b.tokens - a.tokens).slice(0, HEAVIEST_COUNT),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// Number each line of body as `<N>:\t<line>` — mirrors rummy
|
|
123
|
+
// plugins/helpers.js numberLines. The leading digit prevents column-zero
|
|
124
|
+
// fence collisions and gives the model line refs for free (`READ<42-46>`).
|
|
125
|
+
// Used for READ@200 content; index-preview numbering is the framework's
|
|
126
|
+
// job now (baked into the preview string — see renderHeredoc).
|
|
127
|
+
static #numberLines(body, start = 1) {
|
|
128
|
+
if (!body)
|
|
129
|
+
return "";
|
|
130
|
+
const trailingNewline = body.endsWith("\n");
|
|
131
|
+
const source = trailingNewline ? body.slice(0, -1) : body;
|
|
132
|
+
const numbered = source.split("\n").map((line, i) => `${start + i}:\t${line}`).join("\n");
|
|
133
|
+
return trailingNewline ? `${numbered}\n` : numbered;
|
|
134
|
+
}
|
|
135
|
+
// The single content-body renderer EVERY output-emitting op routes through, so the line-number
|
|
136
|
+
// convention the model orients on can't drift: line-navigable mimetypes (text/*) get the `N:\t`
|
|
137
|
+
// prefix from `startLine`; tree-navigable (JSON/XML/HTML) render verbatim so jsonpath/xpath
|
|
138
|
+
// isn't shifted. Empty content ⇒ "" (the meta line stands alone). §render-rule-line-navigable-prefix
|
|
139
|
+
static #renderContentBody(fence, content, mimetype, startLine = 1) {
|
|
140
|
+
if (content.length === 0)
|
|
141
|
+
return "";
|
|
142
|
+
// Line-navigable text gets the `N:\t` source-line prefix from startLine. `startLine === null`
|
|
143
|
+
// means the content is ALREADY source-numbered — a matcher result whose lines carry their own
|
|
144
|
+
// (non-contiguous) source numbers like `143:\t…`; re-numbering would double it to `1:\t143:\t…`
|
|
145
|
+
// (plurnk.md:32 — one source-line prefix). Render verbatim. §render-rule-line-navigable-prefix
|
|
146
|
+
const rendered = MimetypeBinary.isLineNavigableMimetype(mimetype) && startLine !== null
|
|
147
|
+
? PacketWire.#numberLines(content, startLine)
|
|
148
|
+
: content;
|
|
149
|
+
return PacketWire.#wrapHeredocBody(fence, rendered);
|
|
150
|
+
}
|
|
151
|
+
// Tolerant JSON parser for log entries' rx/tx fields. The engine
|
|
152
|
+
// pre-parses application/json mimetypes, but render may also receive
|
|
153
|
+
// strings (legacy paths, manual tests). Returns null on parse failure.
|
|
154
|
+
static #safeParse(s) {
|
|
155
|
+
try {
|
|
156
|
+
return JSON.parse(s);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Stable JSON: keys sorted alphabetically so the same meta produces the
|
|
163
|
+
// same string across turns — prefix-cache friendly. Mirrors rummy
|
|
164
|
+
// plugins/helpers.js canonicalJson.
|
|
165
|
+
static #canonicalJson(obj) {
|
|
166
|
+
const keys = Object.keys(obj).sort();
|
|
167
|
+
const sorted = {};
|
|
168
|
+
for (const k of keys)
|
|
169
|
+
sorted[k] = obj[k];
|
|
170
|
+
return JSON.stringify(sorted);
|
|
171
|
+
}
|
|
172
|
+
// Wrap a body in heredoc fences. Leading `\n` always (separates the
|
|
173
|
+
// opening fence from the first body character — necessary because
|
|
174
|
+
// numbered bodies start with `1:\t…` which would otherwise collide
|
|
175
|
+
// visually with the `:::FENCE` markers). Trailing `\n` only when the
|
|
176
|
+
// body doesn't already end with one — otherwise you get a doubled
|
|
177
|
+
// newline that renders as a blank line before the closing fence, which
|
|
178
|
+
// reads as "the content has a trailing blank line" when actually it
|
|
179
|
+
// doesn't. The body's own whitespace decides the shape.
|
|
180
|
+
static #wrapHeredocBody(fence, body) {
|
|
181
|
+
const sep = body.endsWith("\n") ? "" : "\n";
|
|
182
|
+
return `<<:::${fence}\n${body}${sep}:::${fence}`;
|
|
183
|
+
}
|
|
184
|
+
// Heredoc block for one channel of one entry. Fence is `URI#channel`
|
|
185
|
+
// (the `<<:::FENCE` packet-rendering marker per wrapHeredocBody — a
|
|
186
|
+
// projection is read-only context, NOT an emittable op, so it must not
|
|
187
|
+
// wear the DSL op-fence; that conflation was the demo.sh corruption bug).
|
|
188
|
+
// When `channel` is null/empty the fence is path-only —
|
|
189
|
+
// this is the default-channel convention: the absence of `#channel` is
|
|
190
|
+
// the addressing of the scheme's default channel, not a missing field.
|
|
191
|
+
// Body is a mimetypes preview, rendered VERBATIM — the framework owns its
|
|
192
|
+
// formatting (N:\t line numbers for text, source-annotated outline for
|
|
193
|
+
// symbols, correct start-line for tail slices) and bakes it into the
|
|
194
|
+
// preview string as of mimetypes 0.7.3, so the service must not re-number
|
|
195
|
+
// it (re-numbering would double-prefix text and mis-number symbol
|
|
196
|
+
// outlines — plurnk-mimetypes#8).
|
|
197
|
+
static #renderHeredoc(uri, channel, body) {
|
|
198
|
+
const fence = channel ? `${uri}#${channel}` : uri;
|
|
199
|
+
return PacketWire.#wrapHeredocBody(fence, body);
|
|
200
|
+
}
|
|
201
|
+
// Render a (scheme, pathname) tuple as the URI the model should SEE.
|
|
202
|
+
// Null scheme → bare pathname. The `file` scheme never reaches this
|
|
203
|
+
// function because Dispatcher.#extractTarget normalizes it to null at the
|
|
204
|
+
// storage boundary; storage and wire output are uniform on this.
|
|
205
|
+
static #renderModelUri(scheme, pathname) {
|
|
206
|
+
const path = pathname ?? "";
|
|
207
|
+
// #370 — a null scheme is a workspace file, whose member key is /rel but whose MODEL-FACING
|
|
208
|
+
// form is the bare relative path (the catalog lists data/users.json; FIND returns it; the
|
|
209
|
+
// model types it). Rendering /data/users.json minted a second spelling of the same file.
|
|
210
|
+
if (scheme === null || scheme === undefined)
|
|
211
|
+
return path.replace(/^\//, "");
|
|
212
|
+
return renderAddress(scheme, path);
|
|
213
|
+
}
|
|
214
|
+
// Render one Log entry → a single bullet line carrying the meta JSON.
|
|
215
|
+
// No body, no fence — every meaningful field is in the JSON. Naming
|
|
216
|
+
// follows the uniform principle: `path` is identity (this log row's
|
|
217
|
+
// own URI), `target` is the URI the action acted on. COPY/MOVE add
|
|
218
|
+
// `source`; currently the engine emits target only (source plumbing
|
|
219
|
+
// pending the COPY/MOVE-specific log shape pass).
|
|
220
|
+
//
|
|
221
|
+
// On error, status >= 400 signals the failure; the message lives in
|
|
222
|
+
// the next packet's user.telemetry.errors[] per SPEC §telemetry. (Forward:
|
|
223
|
+
// meta will gain tokensBefore/After + linesBefore/After to convey
|
|
224
|
+
// change scope without carrying the body content.)
|
|
225
|
+
//
|
|
226
|
+
// Per-entry render: one meta JSON line plus a body block that the model
|
|
227
|
+
// can read to know what it did. Two body cases:
|
|
228
|
+
// 1. READ@200 with content → render rx.content under the target fence.
|
|
229
|
+
// The model asked for content; show it the content. (Matcher is in
|
|
230
|
+
// meta.matcher, count is in meta.matches.)
|
|
231
|
+
// 2. Every other op → re-emit tx as a heredoc in the model's native
|
|
232
|
+
// syntax. The model wrote this; mirror it back so the log is a true
|
|
233
|
+
// record of its actions instead of a row of opaque status codes.
|
|
234
|
+
// The log:/// handle the model sees for an entry — its FOLD target
|
|
235
|
+
// (§open-fold) and the label the budget's heaviest-entries readout reuses,
|
|
236
|
+
// so the readout names an entry exactly as the log does.
|
|
237
|
+
static #entryPath(coordinate, op) {
|
|
238
|
+
if (coordinate === null)
|
|
239
|
+
return null;
|
|
240
|
+
return op !== null ? `log:///${coordinate}/${op}` : `log:///${coordinate}`;
|
|
241
|
+
}
|
|
242
|
+
static #renderLogEntries(entries, countTokens) {
|
|
243
|
+
return entries.map((e) => {
|
|
244
|
+
const meta = {};
|
|
245
|
+
const coordinate = typeof e.coordinate === "string" ? e.coordinate : null;
|
|
246
|
+
const op = typeof e.op === "string" && e.op.length > 0 ? e.op : null;
|
|
247
|
+
const path = PacketWire.#entryPath(coordinate, op);
|
|
248
|
+
if (path !== null)
|
|
249
|
+
meta.path = path;
|
|
250
|
+
if (typeof e.origin === "string")
|
|
251
|
+
meta.origin = e.origin;
|
|
252
|
+
// §env-delta: the environment-delta cause (a sibling run or a scheme),
|
|
253
|
+
// rendered when present; absent ⇒ the owning run itself (self).
|
|
254
|
+
if (typeof e.source === "string" && e.source.length > 0)
|
|
255
|
+
meta.run = e.source;
|
|
256
|
+
if (op !== null)
|
|
257
|
+
meta.op = op;
|
|
258
|
+
if (typeof e.status === "number")
|
|
259
|
+
meta.status = e.status;
|
|
260
|
+
const target = PacketWire.#renderActionTarget(e.target);
|
|
261
|
+
if (target !== null)
|
|
262
|
+
meta.target = target;
|
|
263
|
+
// EXEC's output is a separate stream entry (§exec-stream); its address rides in a
|
|
264
|
+
// `stream` link, distinct from `target` (the cwd / executable path it ran in).
|
|
265
|
+
if (op === "EXEC" && e.attrs !== null && typeof e.attrs === "object" && typeof e.attrs.stream === "string") {
|
|
266
|
+
meta.stream = e.attrs.stream;
|
|
267
|
+
}
|
|
268
|
+
// Parse rx once — reused for the matcher/items enrichment and the body.
|
|
269
|
+
const rx = (typeof e.rx === "string" ? PacketWire.#safeParse(e.rx) : e.rx);
|
|
270
|
+
// §log-row-self-explains — a FAILED op row carries its failure message ON THE META LINE,
|
|
271
|
+
// so the record explains itself in every packet, folded or open. The old shape (a bare
|
|
272
|
+
// status; the message buried in an rx no render shows) is what sent the wildcard model
|
|
273
|
+
// theorizing "SEND[409] probably means bad request?" for 201s, and the jumbo model
|
|
274
|
+
// chasing a phantom "engine error" off a message-less item. The row IS the model's op
|
|
275
|
+
// result — it states its own why; the errors section stays a terse pointer at it.
|
|
276
|
+
if (typeof e.status === "number" && e.status >= 400 && rx !== null && typeof rx === "object") {
|
|
277
|
+
const why = rx;
|
|
278
|
+
const text = typeof why.error === "string" ? why.error : typeof why.reason === "string" ? why.reason : typeof why.message === "string" ? why.message : null;
|
|
279
|
+
if (text !== null && text.length > 0)
|
|
280
|
+
meta.error = text;
|
|
281
|
+
}
|
|
282
|
+
// READ + FIND enrichment: the matcher body (from tx) + `items`, the count
|
|
283
|
+
// of rows the op returned — a matcher's hits, or a bare catalog FIND's entry
|
|
284
|
+
// count. Without it the model can't tell "0 results" from "empty content",
|
|
285
|
+
// nor weigh a re-FIND. `matches` when the dispatch tallied it; else a FIND
|
|
286
|
+
// body is a JSON array whose length IS the count.
|
|
287
|
+
let items = null;
|
|
288
|
+
if (op === "READ" || op === "FIND") {
|
|
289
|
+
const tx = e.tx;
|
|
290
|
+
if (tx !== null && tx !== undefined && typeof tx === "object" && tx.body !== null && typeof tx.body === "object") {
|
|
291
|
+
if (typeof tx.body.raw === "string")
|
|
292
|
+
meta.matcher = tx.body.raw;
|
|
293
|
+
}
|
|
294
|
+
if (rx !== null && typeof rx === "object" && typeof rx.matches === "number") {
|
|
295
|
+
items = rx.matches;
|
|
296
|
+
}
|
|
297
|
+
else if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.content === "string") {
|
|
298
|
+
const parsed = PacketWire.#safeParse(rx.content);
|
|
299
|
+
if (Array.isArray(parsed))
|
|
300
|
+
items = parsed.length;
|
|
301
|
+
}
|
|
302
|
+
// The matched set's content weight (sum of the entries' live channel tokens) — the
|
|
303
|
+
// FIND self-describes its hits' READ-cost; carries the per-scheme roll-up in the foist.
|
|
304
|
+
if (op === "FIND" && rx !== null && typeof rx === "object" && typeof rx.itemsTokenTotal === "number") {
|
|
305
|
+
meta.itemsTokenTotal = rx.itemsTokenTotal;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// The foldable body — computed ALWAYS (folded too), because `tokens` measures it: for
|
|
309
|
+
// an open row that's what a FOLD would save, for a folded row what an OPEN would cost.
|
|
310
|
+
// "" ⇒ genuinely no body (an empty FIND, an empty EDIT span, a @204).
|
|
311
|
+
let body = "";
|
|
312
|
+
if (op === "FIND" && e.status === 200 && items === 0) {
|
|
313
|
+
// Empty FIND result → no body. items:0 already says "empty"; rendering [] under a
|
|
314
|
+
// fence is redundant noise. (The always-foisted empty known:///** / unknown:///**
|
|
315
|
+
// workspace rows are the common case.)
|
|
316
|
+
body = "";
|
|
317
|
+
}
|
|
318
|
+
else if ((op === "READ" || op === "FIND") && e.status === 200 &&
|
|
319
|
+
rx !== null && typeof rx === "object" && typeof rx.content === "string" && rx.content.length > 0) {
|
|
320
|
+
// READ@200 / FIND@200: the content READ pulled, or the catalog rows / matched
|
|
321
|
+
// entries FIND returned (§render-rule-find-renders-result) — the turn-0 foisted
|
|
322
|
+
// FIND(scheme:///**) reaches the packet here, as does the exec-stream injector's
|
|
323
|
+
// foisted READ of the channel. #renderContentBody applies the line-number convention
|
|
324
|
+
// (§render-rule-line-navigable-prefix / §render-rule-tree-navigable-verbatim).
|
|
325
|
+
const mimetype = typeof rx.mimetype === "string" ? rx.mimetype : "text/plain";
|
|
326
|
+
// startLine === null is the matcher-result signal (already source-numbered → verbatim);
|
|
327
|
+
// a number numbers from it; absent → 1 (whole-content default).
|
|
328
|
+
const start = rx.startLine === null ? null : (typeof rx.startLine === "number" ? rx.startLine : 1);
|
|
329
|
+
body = PacketWire.#renderContentBody(target ?? `log:///${coordinate}`, rx.content, mimetype, start);
|
|
330
|
+
}
|
|
331
|
+
else if ((op === "EDIT" || op === "COPY" || op === "MOVE") && rx !== null && typeof rx === "object" && (typeof rx.span === "string" || typeof rx.body === "string")) {
|
|
332
|
+
// EDIT (§edit-result-render): the resulting span as it looks now. editedSpan already
|
|
333
|
+
// line-numbered it with the changed region's REAL offsets (e.g. 50:\t…), so wrap
|
|
334
|
+
// verbatim — re-numbering here would double it (1:\t50:\t…) and lose the true line
|
|
335
|
+
// position. Empty span (content emptied) ⇒ no body — the meta line stands alone.
|
|
336
|
+
// The inline entry-scheme EDIT delivers the span under `span`; a PROPOSED file EDIT's
|
|
337
|
+
// accept delivers the same span under `body` (the generic accept-rx key) — render either.
|
|
338
|
+
const r = rx;
|
|
339
|
+
const span = typeof r.span === "string" ? r.span : (r.body ?? "");
|
|
340
|
+
if (span.length > 0)
|
|
341
|
+
body = PacketWire.#wrapHeredocBody(target ?? `log:///${coordinate}`, span);
|
|
342
|
+
}
|
|
343
|
+
else if (op === "EXEC" && e.tx !== null && e.tx !== undefined && typeof e.tx.body === "string") {
|
|
344
|
+
// EXEC: the literal command body, :::-fenced + line-numbered at the op's log address —
|
|
345
|
+
// the model sees what it ran and can reference lines of its own code. The OUTPUT is a
|
|
346
|
+
// SEPARATE stream (meta.stream), surfaced by the injector, never re-emitted here. §exec-stream
|
|
347
|
+
body = PacketWire.#renderContentBody(path ?? `log:///${coordinate}`, e.tx.body, "text/plain");
|
|
348
|
+
}
|
|
349
|
+
else if ((op === "PLAN" || op === "SEND" || op === "WORK" || op === "FORK") && e.tx !== null && e.tx !== undefined) {
|
|
350
|
+
// PLAN's plan / SEND's message / WORK's & FORK's seed task ride into the log as N:\t
|
|
351
|
+
// content at the op's log address — a dispatch's record IS the task it dispatched, so
|
|
352
|
+
// the next turn reads what each worker is doing (the spawn-then-retask confusion was
|
|
353
|
+
// this body missing: the log showed "spawned worker-db" with no task). The log
|
|
354
|
+
// mirrors the model's WORK, NEVER a repeated <<OP:…:OP tag (tags are emission
|
|
355
|
+
// syntax, not the log paradigm). Bodyless ops (COPY/MOVE/OPEN/FOLD, a non-200 READ/FIND
|
|
356
|
+
// whose matcher already rides in meta, a span-less EDIT) fall through to their meta line.
|
|
357
|
+
const b = e.tx.body;
|
|
358
|
+
const opBody = typeof b === "string" ? b
|
|
359
|
+
: b !== null && typeof b === "object" && typeof b.raw === "string" ? b.raw : "";
|
|
360
|
+
if (opBody.length > 0)
|
|
361
|
+
body = PacketWire.#renderContentBody(path ?? `log:///${coordinate}`, opBody, "text/plain");
|
|
362
|
+
// §run-scheme-collect: an injected SEND (a child run's concluded deliverable surfaced in
|
|
363
|
+
// the parent) has no authored tx body — its payload is the deliverable in rx (a raw string,
|
|
364
|
+
// not the {status} envelope a model SEND gets). Surface it so a child's 2xx reaches the
|
|
365
|
+
// parent OPEN (born-open at the insert), never a bodyless `*` row.
|
|
366
|
+
else if (op === "SEND" && opBody.length === 0 && typeof e.rx === "string" && e.rx.length > 0) {
|
|
367
|
+
body = PacketWire.#renderContentBody(path ?? `log:///${coordinate}`, e.rx, "text/plain");
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else if (op === "error") {
|
|
371
|
+
// §telemetry — a parse-error row is a LOG ITEM; its body is the parser message, which
|
|
372
|
+
// carries the content-offset `line:col`. The model resolves that line against its own
|
|
373
|
+
// emission — READ the folded `model` mirror row (§model-entry) — so no snippet is embedded.
|
|
374
|
+
// Foldable like any body; the errors section keeps only a pointer (status + coordinate).
|
|
375
|
+
const detail = (rx !== null && typeof rx === "object" ? rx : {});
|
|
376
|
+
if (typeof detail.message === "string" && detail.message.length > 0) {
|
|
377
|
+
body = PacketWire.#wrapHeredocBody(path ?? `log:///${coordinate}`, detail.message);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else if (op === "model") {
|
|
381
|
+
// §model-entry — the model's own verbatim emission, mirrored back so it sees exactly
|
|
382
|
+
// what it produced. Line-numbered like all content (the parser reports errors by line,
|
|
383
|
+
// so the model can reason about its own syntax error). Folded by default → just the
|
|
384
|
+
// meta line until OPENed; the turn-0 exemplar is born open (the worked example).
|
|
385
|
+
if (rx !== null && typeof rx === "object" && typeof rx.content === "string" && rx.content.length > 0) {
|
|
386
|
+
const mimetype = typeof rx.mimetype === "string" ? rx.mimetype : "text/vnd.plurnk";
|
|
387
|
+
body = PacketWire.#renderContentBody(path ?? `log:///${coordinate}`, rx.content, mimetype);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// tokens on EVERY row (0 when there's genuinely no body) so the model can always weigh
|
|
391
|
+
// it; for a folded row this is the cost an OPEN would add. items present even at 0.
|
|
392
|
+
if (items !== null)
|
|
393
|
+
meta.items = items;
|
|
394
|
+
// 0 for a genuinely empty body — never call countTokens("") (some providers return
|
|
395
|
+
// undefined for it, which JSON.stringify would drop, leaving the row with no tokens).
|
|
396
|
+
meta.tokens = body.length > 0 ? countTokens(body) : 0;
|
|
397
|
+
// lines beside tokens on any row with a navigable body — the count of `N:\t`-numbered
|
|
398
|
+
// lines (fences and unnumbered prose don't count), so the model can plan a <start,end>
|
|
399
|
+
// slice before paying for an OPEN. Omitted when the body isn't line-addressable.
|
|
400
|
+
if (body.length > 0) {
|
|
401
|
+
const navigable = body.split("\n").filter((l) => /^\d+:\t/.test(l)).length;
|
|
402
|
+
if (navigable > 0)
|
|
403
|
+
meta.lines = navigable;
|
|
404
|
+
}
|
|
405
|
+
// Body-state marker — body-aware so `-` never sits on a bodyless row:
|
|
406
|
+
// `*` no body (nothing to OPEN) · `+` open (body shown) · `-` folded (OPEN to expand).
|
|
407
|
+
const marker = body.length === 0 ? "*" : e.folded === true ? "-" : "+";
|
|
408
|
+
const metaLine = `${marker} ${PacketWire.#canonicalJson(meta)}`;
|
|
409
|
+
// Render the body only when OPEN; a folded row is its meta line alone (body hidden).
|
|
410
|
+
return (e.folded !== true && body.length > 0) ? `${metaLine}\n${body}` : metaLine;
|
|
411
|
+
}).join("\n");
|
|
412
|
+
}
|
|
413
|
+
static #renderActionTarget(target) {
|
|
414
|
+
if (target === null || target === undefined)
|
|
415
|
+
return null;
|
|
416
|
+
// An authority-bearing target (run://<name> — the run IS the authority, §run-scheme;
|
|
417
|
+
// a web host http://host/path) keeps its name in `hostname`. Without it a spawn renders
|
|
418
|
+
// as a bare `run://`, indistinguishable across workers — the model goes blind to what it
|
|
419
|
+
// spawned and re-spawns. Reconstruct the authority form when a hostname is present;
|
|
420
|
+
// namespace schemes (plurnk/known) fold their authority into the path and fall through.
|
|
421
|
+
const host = typeof target.hostname === "string" && target.hostname.length > 0 ? target.hostname : null;
|
|
422
|
+
const rendered = host !== null && typeof target.scheme === "string" && target.scheme.length > 0
|
|
423
|
+
? `${target.scheme}://${host}${target.port ? `:${target.port}` : ""}${target.pathname ?? ""}`
|
|
424
|
+
: PacketWire.#renderModelUri(target.scheme, target.pathname);
|
|
425
|
+
if (rendered.length === 0)
|
|
426
|
+
return null;
|
|
427
|
+
// The channel fragment (#stdout/#stderr) is part of the address — a stream delta has to
|
|
428
|
+
// say WHICH channel it is, not just the entry. §exec-stream
|
|
429
|
+
const fragment = typeof target.fragment === "string" && target.fragment.length > 0 ? `#${target.fragment}` : "";
|
|
430
|
+
return rendered + fragment;
|
|
431
|
+
}
|
|
432
|
+
static #renderGitState(git) {
|
|
433
|
+
const sync = git.ahead > 0 || git.behind > 0 ? ` (↑${git.ahead} ↓${git.behind})` : "";
|
|
434
|
+
return `branch \`${git.branch}\`${sync} — ${git.staged} staged, ${git.unstaged} unstaged, ${git.untracked} untracked`;
|
|
435
|
+
}
|
|
436
|
+
static #renderTelemetryErrors(errors) {
|
|
437
|
+
// Uniform projection off the formal TelemetryEvent envelope (grammar TelemetryEvent.json):
|
|
438
|
+
// render each error by its typed `position`, never by sniffing `kind`. A LogCoordinate is a
|
|
439
|
+
// terse `<status> log:///<coord>` link to the row (the row holds the term + detail); a
|
|
440
|
+
// ContentOffset points the model at the line in its own born-OPEN emission (§model-entry).
|
|
441
|
+
// No JSON dump — the packet teaches, the row carries the body.
|
|
442
|
+
return errors.map((e) => {
|
|
443
|
+
const ev = e;
|
|
444
|
+
const pos = ev.position;
|
|
445
|
+
if (pos?.type === "log-coordinate")
|
|
446
|
+
return `* ${ev.status ?? ""} log:///${pos.coordinate}`.replace(/ +/g, " ");
|
|
447
|
+
if (pos?.type === "content-offset")
|
|
448
|
+
return `* ${ev.kind ?? "error"} ${pos.line}:${pos.column}`;
|
|
449
|
+
return `* ${ev.kind ?? "error"}`;
|
|
450
|
+
}).join("\n");
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=packet-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packet-wire.js","sourceRoot":"","sources":["../../src/core/packet-wire.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,mEAAmE;AACnE,0EAA0E;AAC1E,4EAA4E;AAC5E,6CAA6C;AAC7C,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,qEAAqE;AACrE,8CAA8C;AAC9C,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,uEAAuE;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA6ChD,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,wDAAwD;IACxD,MAAM,CAAC,UAAU,CAAC,QAAuB,EAAE,IAAuB;QAC9D,OAAO,QAAQ;aACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aACvC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,cAAc,GAAG,CAAC,SAAS,YAAY,CAAC;IAC1H,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAC,MAAwB;QAClD,2FAA2F;QAC3F,4FAA4F;QAC5F,uFAAuF;QACvF,2FAA2F;QAC3F,+DAA+D;QAC/D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACpB,MAAM,EAAE,GAAG,CAA0H,CAAC;YACtI,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC;YACxB,IAAI,GAAG,EAAE,IAAI,KAAK,gBAAgB;gBAAE,OAAO,KAAK,EAAE,CAAC,MAAM,IAAI,EAAE,WAAW,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/G,IAAI,GAAG,EAAE,IAAI,KAAK,gBAAgB;gBAAE,OAAO,KAAK,EAAE,CAAC,IAAI,IAAI,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YAC/F,OAAO,KAAK,EAAE,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-decode.d.ts","sourceRoot":"","sources":["../../src/core/path-decode.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,MAAO,MAAM,KAAG,MAAuD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// #239 item 4 — the grammar's target slot is opaque: a literal `)` closes the op slot, so
|
|
2
|
+
// parens inside a path are percent-encoded (`%28`/`%29`) and the service decodes them at
|
|
3
|
+
// resolve time. ONLY parens are encoded — `:`, spaces, and drive letters pass through
|
|
4
|
+
// literally — so a targeted %28/%29 replacement is exact and safe: it never touches a
|
|
5
|
+
// literal `%` in a path (which decodeURIComponent would mangle). A regex target's source
|
|
6
|
+
// is NOT a path (its parens are groups/alternation), so callers skip it.
|
|
7
|
+
export const decodePathParens = (s) => s.replace(/%28/gi, "(").replace(/%29/gi, ")");
|
|
8
|
+
//# sourceMappingURL=path-decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-decode.js","sourceRoot":"","sources":["../../src/core/path-decode.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,yFAAyF;AACzF,sFAAsF;AACtF,sFAAsF;AACtF,yFAAyF;AACzF,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-attribution.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attribution.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAIlC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAe5D;IAGD,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAQzC;CACJ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// #249 — plugin attribution. A plugin declares an opaque tag in its package.json
|
|
2
|
+
// (plurnk.attribution: string | string[]) that rides the generate() attributions wire.
|
|
3
|
+
// @plurnk/ is reserved: only a @plurnk/-scoped package may declare a @plurnk/ tag.
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
const RESERVED_PREFIX = "@plurnk/";
|
|
6
|
+
export default class PluginAttribution {
|
|
7
|
+
// Normalize a raw `plurnk.attribution` value to a tag list AND enforce the reservation.
|
|
8
|
+
// Pure (no I/O) so the contract is unit-testable. A plugin claiming the reserved
|
|
9
|
+
// namespace is a fail-hard contract violation, not a silently-dropped tag.
|
|
10
|
+
static normalize(raw, packageName) {
|
|
11
|
+
if (raw === undefined || raw === null)
|
|
12
|
+
return [];
|
|
13
|
+
const tags = Array.isArray(raw) ? raw : [raw];
|
|
14
|
+
const firstParty = packageName.startsWith(RESERVED_PREFIX);
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const tag of tags) {
|
|
17
|
+
if (typeof tag !== "string" || tag.length === 0) {
|
|
18
|
+
throw new Error(`plugin '${packageName}': plurnk.attribution must be a non-empty string or string[]`);
|
|
19
|
+
}
|
|
20
|
+
if (tag.startsWith(RESERVED_PREFIX) && !firstParty) {
|
|
21
|
+
throw new Error(`plugin '${packageName}': '${RESERVED_PREFIX}' is reserved for ${RESERVED_PREFIX}-scoped packages — '${packageName}' cannot claim '${tag}'`);
|
|
22
|
+
}
|
|
23
|
+
out.push(tag);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
// [] when the manifest can't be resolved (strict `exports` with no `./package.json`).
|
|
28
|
+
static read(packageName) {
|
|
29
|
+
let manifest;
|
|
30
|
+
try {
|
|
31
|
+
manifest = createRequire(import.meta.url)(`${packageName}/package.json`);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return PluginAttribution.normalize(manifest?.plurnk?.attribution, packageName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=plugin-attribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-attribution.js","sourceRoot":"","sources":["../../src/core/plugin-attribution.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,uFAAuF;AACvF,mFAAmF;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAClC,wFAAwF;IACxF,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AAC,CAAC;IACnF,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParsedPath } from "@plurnk/plurnk-grammar";
|
|
2
|
+
export declare function schemeNameOf(path: ParsedPath | null): string | null;
|
|
3
|
+
export declare function foldAuthorityIntoPath(hostname: string | null, pathname: string): string;
|
|
4
|
+
export declare function promptPathname(runId: number, loopSeq: number, turnSeq: number): string;
|
|
5
|
+
export declare function promptLoopPrefix(runId: number, loopSeq: number): string;
|
|
6
|
+
export declare function renderAddress(scheme: string, pathname: string): string;
|
|
7
|
+
//# sourceMappingURL=plurnk-uri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plurnk-uri.d.ts","sourceRoot":"","sources":["../../src/core/plurnk-uri.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAKnE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvF;AAOD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWtE"}
|