@plurnk/plurnk-service 1.6.0 → 1.7.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.
Files changed (164) hide show
  1. package/.env.defaults +7 -21
  2. package/INSTALL.md +18 -17
  3. package/README.md +1 -1
  4. package/SPEC.md +209 -136
  5. package/dist/build-info.json +1 -1
  6. package/dist/core/ChannelWrite.sql +3 -3
  7. package/dist/core/ClientInteractions.d.ts +19 -0
  8. package/dist/core/ClientInteractions.d.ts.map +1 -0
  9. package/dist/core/ClientInteractions.js +124 -0
  10. package/dist/core/ClientInteractions.js.map +1 -0
  11. package/dist/core/ClientInteractions.sql +34 -0
  12. package/dist/core/CoreSchemeServices.d.ts +9 -3
  13. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  14. package/dist/core/CoreSchemeServices.js +8 -2
  15. package/dist/core/CoreSchemeServices.js.map +1 -1
  16. package/dist/core/Dispatcher.d.ts +4 -2
  17. package/dist/core/Dispatcher.d.ts.map +1 -1
  18. package/dist/core/Dispatcher.js +116 -1149
  19. package/dist/core/Dispatcher.js.map +1 -1
  20. package/dist/core/Engine.d.ts +24 -34
  21. package/dist/core/Engine.d.ts.map +1 -1
  22. package/dist/core/Engine.js +137 -1672
  23. package/dist/core/Engine.js.map +1 -1
  24. package/dist/core/Engine.sql +46 -32
  25. package/dist/core/ExecutableTools.d.ts +1 -0
  26. package/dist/core/ExecutableTools.d.ts.map +1 -1
  27. package/dist/core/ExecutableTools.js +17 -9
  28. package/dist/core/ExecutableTools.js.map +1 -1
  29. package/dist/core/ExecutorRegistry.d.ts +11 -3
  30. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  31. package/dist/core/ExecutorRegistry.js +139 -16
  32. package/dist/core/ExecutorRegistry.js.map +1 -1
  33. package/dist/core/LogBody.d.ts +1 -0
  34. package/dist/core/LogBody.d.ts.map +1 -1
  35. package/dist/core/LogBody.js +4 -0
  36. package/dist/core/LogBody.js.map +1 -1
  37. package/dist/core/ModelCall.d.ts +2 -2
  38. package/dist/core/ModelCall.d.ts.map +1 -1
  39. package/dist/core/ModelCall.js +4 -2
  40. package/dist/core/ModelCall.js.map +1 -1
  41. package/dist/core/PacketBuilder.d.ts +11 -22
  42. package/dist/core/PacketBuilder.d.ts.map +1 -1
  43. package/dist/core/PacketBuilder.js +90 -180
  44. package/dist/core/PacketBuilder.js.map +1 -1
  45. package/dist/core/ProblemLog.d.ts +1 -1
  46. package/dist/core/ProblemLog.d.ts.map +1 -1
  47. package/dist/core/ProblemLog.js +14 -3
  48. package/dist/core/ProblemLog.js.map +1 -1
  49. package/dist/core/ProposalLifecycle.d.ts +4 -2
  50. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  51. package/dist/core/ProposalLifecycle.js +19 -7
  52. package/dist/core/ProposalLifecycle.js.map +1 -1
  53. package/dist/core/ProviderInstantiate.js +2 -2
  54. package/dist/core/ProviderInstantiate.js.map +1 -1
  55. package/dist/core/ResourceMutations.d.ts +73 -0
  56. package/dist/core/ResourceMutations.d.ts.map +1 -0
  57. package/dist/core/ResourceMutations.js +1142 -0
  58. package/dist/core/ResourceMutations.js.map +1 -0
  59. package/dist/core/SchemeRegistry.d.ts +18 -10
  60. package/dist/core/SchemeRegistry.d.ts.map +1 -1
  61. package/dist/core/SchemeRegistry.js +195 -43
  62. package/dist/core/SchemeRegistry.js.map +1 -1
  63. package/dist/core/StoredPacket.d.ts +2 -2
  64. package/dist/core/StoredPacket.js +7 -7
  65. package/dist/core/TurnRunner.d.ts +74 -0
  66. package/dist/core/TurnRunner.d.ts.map +1 -0
  67. package/dist/core/TurnRunner.js +1733 -0
  68. package/dist/core/TurnRunner.js.map +1 -0
  69. package/dist/core/WorkspaceGate.d.ts +1 -0
  70. package/dist/core/WorkspaceGate.d.ts.map +1 -1
  71. package/dist/core/WorkspaceGate.js +39 -0
  72. package/dist/core/WorkspaceGate.js.map +1 -1
  73. package/dist/core/caps/CoreInteractionCaps.d.ts +9 -0
  74. package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -0
  75. package/dist/core/caps/CoreInteractionCaps.js +14 -0
  76. package/dist/core/caps/CoreInteractionCaps.js.map +1 -0
  77. package/dist/core/caps/DbChannelCaps.js +4 -4
  78. package/dist/core/caps/DbChannelCaps.js.map +1 -1
  79. package/dist/core/caps/SchemeCtxImpl.d.ts +2 -1
  80. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  81. package/dist/core/caps/SchemeCtxImpl.js +3 -0
  82. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  83. package/dist/core/content-hash.js +2 -2
  84. package/dist/core/content-hash.js.map +1 -1
  85. package/dist/core/content-weight.d.ts +2 -0
  86. package/dist/core/content-weight.d.ts.map +1 -0
  87. package/dist/core/content-weight.js +4 -0
  88. package/dist/core/content-weight.js.map +1 -0
  89. package/dist/core/content_weight.d.ts +4 -0
  90. package/dist/core/content_weight.d.ts.map +1 -0
  91. package/dist/core/content_weight.js +6 -0
  92. package/dist/core/content_weight.js.map +1 -0
  93. package/dist/core/fork.sql +5 -5
  94. package/dist/core/packet-wire.d.ts +4 -4
  95. package/dist/core/packet-wire.d.ts.map +1 -1
  96. package/dist/core/packet-wire.js +21 -21
  97. package/dist/core/packet-wire.js.map +1 -1
  98. package/dist/core/scheme-types.d.ts +3 -2
  99. package/dist/core/scheme-types.d.ts.map +1 -1
  100. package/dist/core/scheme-types.js.map +1 -1
  101. package/dist/digest/Digest.js +1 -1
  102. package/dist/digest/Digest.js.map +1 -1
  103. package/dist/schemes/Exec.d.ts.map +1 -1
  104. package/dist/schemes/Exec.js +53 -15
  105. package/dist/schemes/Exec.js.map +1 -1
  106. package/dist/schemes/ExecOutputScheme.js +1 -1
  107. package/dist/schemes/ExecOutputScheme.js.map +1 -1
  108. package/dist/schemes/File.d.ts.map +1 -1
  109. package/dist/schemes/File.js +1 -1
  110. package/dist/schemes/File.js.map +1 -1
  111. package/dist/schemes/Log.d.ts.map +1 -1
  112. package/dist/schemes/Log.js +2 -2
  113. package/dist/schemes/Log.sql +2 -2
  114. package/dist/schemes/Worker.js +2 -2
  115. package/dist/schemes/Worker.js.map +1 -1
  116. package/dist/schemes/_entry-crud.js +4 -4
  117. package/dist/schemes/_entry-crud.js.map +1 -1
  118. package/dist/schemes/_entry-crud.sql +2 -2
  119. package/dist/schemes/_entry-find.d.ts +5 -5
  120. package/dist/schemes/_entry-find.d.ts.map +1 -1
  121. package/dist/schemes/_entry-find.js +29 -28
  122. package/dist/schemes/_entry-find.js.map +1 -1
  123. package/dist/schemes/_entry-manifest.js +4 -4
  124. package/dist/schemes/_entry-manifest.js.map +1 -1
  125. package/dist/schemes/_entry-ops.d.ts.map +1 -1
  126. package/dist/schemes/_entry-ops.js +3 -3
  127. package/dist/schemes/_entry-ops.js.map +1 -1
  128. package/dist/schemes/_entry-ops.sql +3 -3
  129. package/dist/server/Daemon.d.ts +20 -49
  130. package/dist/server/Daemon.d.ts.map +1 -1
  131. package/dist/server/Daemon.js +311 -908
  132. package/dist/server/Daemon.js.map +1 -1
  133. package/dist/server/DaemonModule.d.ts +31 -3
  134. package/dist/server/DaemonModule.d.ts.map +1 -1
  135. package/dist/server/DrainSupervisor.d.ts +117 -0
  136. package/dist/server/DrainSupervisor.d.ts.map +1 -0
  137. package/dist/server/DrainSupervisor.js +802 -0
  138. package/dist/server/DrainSupervisor.js.map +1 -0
  139. package/dist/server/client-input.d.ts +2 -0
  140. package/dist/server/client-input.d.ts.map +1 -1
  141. package/dist/server/client-input.js +12 -0
  142. package/dist/server/client-input.js.map +1 -1
  143. package/dist/server/lifecycle-recovery.sql +9 -0
  144. package/dist/server/logEntry.d.ts +1 -1
  145. package/dist/server/logEntry.js +1 -1
  146. package/dist/server/loopDocs.d.ts +1 -0
  147. package/dist/server/loopDocs.d.ts.map +1 -1
  148. package/dist/server/loopDocs.js +37 -8
  149. package/dist/server/loopDocs.js.map +1 -1
  150. package/dist/server/loopDocs.sql +10 -0
  151. package/dist/server/seam-entry-read.sql +2 -2
  152. package/dist/server/workspace-capabilities.sql +19 -0
  153. package/dist/service.js +1 -1
  154. package/dist/service.js.map +1 -1
  155. package/migrations/001_schema.sql +51 -10
  156. package/package.json +34 -33
  157. package/dist/core/ruler_count.d.ts +0 -4
  158. package/dist/core/ruler_count.d.ts.map +0 -1
  159. package/dist/core/ruler_count.js +0 -7
  160. package/dist/core/ruler_count.js.map +0 -1
  161. package/dist/core/token-ruler.d.ts +0 -2
  162. package/dist/core/token-ruler.d.ts.map +0 -1
  163. package/dist/core/token-ruler.js +0 -5
  164. package/dist/core/token-ruler.js.map +0 -1
package/.env.defaults CHANGED
@@ -45,7 +45,7 @@ PLURNK_PORT=3044
45
45
  # Optional default child-provider alias. Unset = each WORK/FORK child inherits
46
46
  # its spawning loop's provider. Clients may override this per top-level loop.
47
47
  # PLURNK_MODEL_CHILD=fast
48
- # Operator turn ceiling. -1 (default) = no cap (loops end via SEND, budget,
48
+ # Operator turn ceiling. -1 (default) = no cap (loops end via SEND, provider capacity,
49
49
  # strikes, or cycle detection). A positive value is an inviolable hard cap a
50
50
  # CoreSeam runLoop({maxTurns}) request cannot exceed (min wins).
51
51
  PLURNK_SERVICE_MAX_TURNS=-1
@@ -180,30 +180,16 @@ PLURNK_SERVICE_EDIT_RECEIPT_CONTEXT_LINES=2
180
180
  # the ceiling fails hard (508 — no queue, no retry); the acting run counts itself.
181
181
  PLURNK_SERVICE_WORKSPACE_WORKERS_MAX_ACTIVE=-1
182
182
 
183
- # --- Prompt budget and packing safety — PER ALIAS (#352) ---
184
- # Providers report the effective total context envelope and generation capacity. Core's natural
185
- # prompt gauge is the remaining input room after the generation envelope and SAFETY margin.
186
- #
187
- # PROMPT_BUDGET is optional virtual pressure: it tightens the model-facing gauge and grinder
188
- # without changing hard context admission or generation settings. Unset uses the natural prompt
189
- # gauge; a set value can only tighten it. Both core knobs resolve per
190
- # alias: _<alias> wins over bare.
191
- # The retired PLURNK_SERVICE_{CONTEXT_WINDOW,REASONING,COMPLETION} names FAIL HARD at boot naming
192
- # their successors — a stale .env never silently loses its envelope.
193
- # PLURNK_SERVICE_PROMPT_BUDGET=128000
194
- # Maximum aggregate share of the stable model-facing prompt gauge used by
183
+ # --- Prompt projection — PER ALIAS ---
184
+ # Providers derive physical input capacity from model limits and the total output envelope.
185
+ # Core projects that number into its model-facing curation gauge; no second service-side token
186
+ # budget or packing margin exists. The retired PLURNK_SERVICE_{PROMPT_BUDGET,SAFETY,
187
+ # CONTEXT_WINDOW,REASONING,COMPLETION} names fail hard at boot.
188
+ # Maximum aggregate share of the model-facing curation budget used by
195
189
  # automatic OPEN prompt bodies. The complete prompt remains stored and
196
190
  # READ/FIND-addressable; this controls projection, not prompt admission.
197
191
  # Alias-scoped overrides follow the ordinary _<alias> convention.
198
192
  PLURNK_SERVICE_PROMPT_PROJECTION=25%
199
- PLURNK_SERVICE_SAFETY=1024
200
- #
201
- # LOCAL aliases (llama-server): the window is PROBED and the reserves DERIVE from it in the
202
- # provider tier (percent defaults) — zero-config. Absolute pins, when wanted, are provider-tier:
203
- # PLURNK_PROVIDERS_{REASONING,COMPLETION}_RESERVE_<alias> (see plurnk-providers/.env.defaults).
204
- # The provider sends the resolved reasoning allowance per request; no llama-server launch-flag
205
- # synchronization is required. Pinned absolutes exceeding the detected window fail HARD at build
206
- # time, naming the provider-tier knobs.
207
193
 
208
194
  # --- Plugins (third-party trust) ---
209
195
  # (PLURNK_PLUGINS_TRUSTED_ONLY lives in @plurnk/plurnk-meta — reader-declares: the
package/INSTALL.md CHANGED
@@ -4,7 +4,7 @@ Operator guide. Put machine-specific choices in `~/.plurnk/.env`. Each installed
4
4
 
5
5
  ## Install
6
6
 
7
- ```
7
+ ```sh
8
8
  npm install -g @plurnk/plurnk-service
9
9
  plurnk-service migrate # apply the disposable version-1 schema baseline
10
10
  plurnk-service start
@@ -40,19 +40,20 @@ When a value is required, an unset or retired name fails boot naming the violate
40
40
 
41
41
  These are relationships *between* flags. Set them as a unit.
42
42
 
43
- - **Hard capacity and PLURNK pressure are separate.** Providers report the
44
- effective total context envelope and generation capacity. Core derives the
45
- natural prompt gauge from those facts. Optional `PLURNK_SERVICE_PROMPT_BUDGET_<alias>`
46
- only tightens the model-facing gauge and grinder; it is never sent to the
47
- provider and never changes hard admission or generation settings.
43
+ - **One generation envelope derives input capacity.** The provider resolves
44
+ model input/output limits, the effective context window, one total output
45
+ budget, and an optional reasoning subset. Its resulting input capacity drives
46
+ both physical request admission and Core's model-independent curation gauge;
47
+ Core has no second token budget or packing margin. Request-shaped token
48
+ evidence remains provider-owned ({§tokenomics-window-partition}).
48
49
  `PLURNK_SERVICE_PROMPT_PROJECTION_<alias>` assigns a stable percentage of
49
50
  that gauge to automatic prompt bodies; it never limits stored prompt size
50
51
  ({§prompt-projection}).
51
- - **Reasoning capacity is request-scoped on llama-server.**
52
- `PLURNK_PROVIDERS_REASONING_RESERVE_<alias>` is the adaptive cumulative
53
- response allowance. An explicit `PLURNK_PROVIDERS_REASONING_BUDGET_<alias>`
54
- may tighten but cannot exceed it. The provider sends the allowance on every
55
- request; no serving-box flag synchronization is required.
52
+ - **Reasoning is part of output.** `PLURNK_PROVIDERS_OUTPUT_BUDGET_<alias>` is
53
+ the complete response ceiling, including hidden reasoning. Optional
54
+ `PLURNK_PROVIDERS_REASONING_BUDGET_<alias>` is a strict subset; unset leaves
55
+ depth provider-adaptive. Activation remains the independent
56
+ `PLURNK_PROVIDERS_REASONING_<alias>` contract.
56
57
  - **Local GBNF is optional.** The PLURNK language is always parsed normally.
57
58
  Local llama-server users may set `PLURNK_PROVIDERS_GBNF_<alias>`; transport
58
59
  and enforcement are verified at boot. Cloud and endpoint-managed aliases
@@ -66,7 +67,7 @@ These are relationships *between* flags. Set them as a unit.
66
67
 
67
68
  ## Profiles (examples, not a decision tree — adapt to the real box)
68
69
 
69
- - **Local GPU (llama-server).** `PLURNK_MODEL_local="openai/<name>"`, `OPENAI_BASE_URL=http://127.0.0.1:<port>`, `PLURNK_MODEL=local`, `PLURNK_PROVIDERS_GBNF_local=plurnk.qwen.gbnf` for Qwen's template-prefilled `<think>` protocol (or `plurnk.gemma.gbnf` when Gemma generates a complete Harmony channel). The provider detects llama-server, verifies its GBNF transport, and derives a request-scoped reasoning allowance from the detected window. Add `PLURNK_PROVIDERS_LLAMA_SERVER_local=1` only when the endpoint cannot be fingerprinted reliably.
70
+ - **Local GPU (llama-server).** `PLURNK_MODEL_local="openai/<name>"`, `OPENAI_BASE_URL=http://127.0.0.1:<port>`, `PLURNK_MODEL=local`, `PLURNK_PROVIDERS_GBNF_local=plurnk.qwen.gbnf` for Qwen's template-prefilled `<think>` protocol (or `plurnk.gemma.gbnf` when Gemma generates a complete Harmony channel). The provider detects llama-server, verifies its GBNF transport, and derives input capacity from the detected window and configured output envelope. Add `PLURNK_PROVIDERS_LLAMA_SERVER_local=1` only when the endpoint cannot be fingerprinted reliably.
70
71
  - **Cloud, bring-your-own-key.** `PLURNK_MODEL_cloud="openrouter/<model>"`, `OPENROUTER_API_KEY=…`, `PLURNK_MODEL=cloud`. No local GBNF or `LLAMA_SERVER` pin.
71
72
  - **plurnk.ai endpoint.** `PLURNK_MODEL_plurnk="plurnk/plurnk"`, `PLURNK_API_KEY=…`, `PLURNK_MODEL=plurnk`.
72
73
  - **Headless / CI / constrained container.** A CPU-only box should NOT disable semantic search — it should point derivation at a real embedder: `PLURNK_MIMETYPES_EMBED_BASE_URL` (any OpenAI-compatible `/v1/embeddings` — a host GPU turns a CPU-hours corpus grind into seconds). Weak hardware is the target workload, not a reason to shed capability; `PLURNK_SERVICE_EMBED_DISABLE=1` exists for test lanes that deterministically assert non-semantic behavior, nothing else. Consider `PLURNK_SERVICE_MAX_TURNS=<n>` as a cost cap, `PLURNK_SERVICE_GIT_ALLOWED=0` to lock out git in a sandbox.
@@ -84,11 +85,11 @@ Each mirrors a `# --- section ---` in the floor; consult the floor for exact def
84
85
  - **Providers** — the portable provider knobs and defaults are defined by
85
86
  `@plurnk/plurnk-providers/.env.defaults`; any provider knob may take an alias
86
87
  suffix that wins over the bare fallback.
87
- - **Provider capacity and prompt budget** —
88
- `PLURNK_PROVIDERS_CONTEXT_WINDOW`/`_REASONING_RESERVE`/`_COMPLETION_RESERVE`
89
- describe provider capacity. `PLURNK_SERVICE_PROMPT_BUDGET` applies optional
90
- virtual pressure; `PLURNK_SERVICE_PROMPT_PROJECTION` assigns the automatic
91
- prompt-body share; `PLURNK_SERVICE_SAFETY` is the packing margin.
88
+ - **Provider envelope and prompt projection** —
89
+ `PLURNK_PROVIDERS_CONTEXT_WINDOW`/`_OUTPUT_BUDGET` and optional
90
+ `_REASONING_BUDGET` derive physical input capacity.
91
+ `PLURNK_SERVICE_PROMPT_PROJECTION` assigns the automatic prompt-body share
92
+ of that provider-derived curation gauge.
92
93
  - **Plugins** — bare `PLURNK_PLUGINS_TRUSTED_ONLY` (0/unset = load all installed; a value = `@plurnk/*` plus an allowlist).
93
94
  - **Semantic search** — `PLURNK_SERVICE_SEMANTIC_CHUNK_TOKENS`/`_CHUNK_OVERLAP` (service-side chunking), `PLURNK_SERVICE_EMBED_DISABLE` (FTS-only), `PLURNK_MIMETYPES_EMBED_WORKERS` (the embedder's pool — mimetypes-owned).
94
95
  - **Schemes: http** — `PLURNK_SCHEMES_HTTP_FETCH_TIMEOUT`, `_TTL_MS`, optional `# TAVILY_API_KEY=`, and `PLURNK_SCHEMES_HTTP_TAVILY_DEPTH`/`_TAVILY_TIMEOUT_MS`.
package/README.md CHANGED
@@ -28,7 +28,7 @@ a second client transport.
28
28
 
29
29
  ## Start
30
30
 
31
- ```
31
+ ```sh
32
32
  npm install -g @plurnk/plurnk-service
33
33
  plurnk-service migrate # apply the disposable version-1 schema baseline
34
34
  plurnk-service start # daemon