@plurnk/plurnk-service 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +41 -24
- package/README.md +37 -18
- package/SPEC.md +34 -10
- package/dist/core/ChannelWrite.d.ts +4 -0
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +9 -0
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +69 -0
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +146 -103
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +307 -0
- package/dist/core/ExecutorRegistry.d.ts +4 -2
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +20 -5
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts +3 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +37 -0
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +8 -1
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +50 -0
- package/dist/core/packet-wire.d.ts +1 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +11 -0
- package/dist/core/packet-wire.js.map +1 -1
- 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/run-ops.sql +16 -0
- package/dist/core/scheme-types.d.ts +1 -0
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/session-settings.d.ts +1 -0
- package/dist/core/session-settings.d.ts.map +1 -1
- package/dist/core/session-settings.js +2 -1
- package/dist/core/session-settings.js.map +1 -1
- package/dist/schemes/Exec.d.ts +2 -1
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +39 -22
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +27 -3
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.sql +37 -0
- package/dist/schemes/_entry-crud.sql +88 -0
- package/dist/schemes/_entry-find.sql +31 -0
- package/dist/schemes/_entry-graph.sql +60 -0
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +11 -3
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +20 -0
- package/dist/schemes/_entry-semantic.d.ts.map +1 -1
- package/dist/schemes/_entry-semantic.js +14 -7
- package/dist/schemes/_entry-semantic.js.map +1 -1
- package/dist/schemes/_entry-semantic.sql +80 -0
- package/dist/schemes/exec-abort.d.ts +11 -0
- package/dist/schemes/exec-abort.d.ts.map +1 -0
- package/dist/schemes/exec-abort.js +23 -0
- package/dist/schemes/exec-abort.js.map +1 -0
- package/dist/schemes/exec-env.js +1 -1
- package/dist/schemes/exec-env.js.map +1 -1
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +162 -76
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/clientTurn.sql +10 -0
- package/dist/server/drain.sql +92 -0
- package/dist/server/dsl.d.ts.map +1 -1
- package/dist/server/dsl.js +11 -4
- package/dist/server/dsl.js.map +1 -1
- package/dist/server/envelope.sql +75 -0
- package/dist/server/logEntry.sql +10 -0
- package/dist/server/methods/_dispatchAsClient.d.ts.map +1 -1
- package/dist/server/methods/_dispatchAsClient.js +11 -6
- package/dist/server/methods/_dispatchAsClient.js.map +1 -1
- package/dist/server/methods/entry_read.sql +21 -0
- package/dist/server/methods/log_read.sql +11 -0
- package/dist/server/methods/loop_run.d.ts.map +1 -1
- package/dist/server/methods/loop_run.js +31 -11
- package/dist/server/methods/loop_run.js.map +1 -1
- package/dist/server/methods/loop_run.sql +9 -0
- package/dist/server/methods/session_create.d.ts.map +1 -1
- package/dist/server/methods/session_create.js +10 -3
- package/dist/server/methods/session_create.js.map +1 -1
- package/dist/service.d.ts +6 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +221 -0
- package/dist/service.js.map +1 -0
- package/migrations/0000-00-00.01_schema.sql +2 -2
- package/package.json +27 -13
- package/bin/plurnk-service.ts +0 -176
- package/dist/core/ProviderRegistry.d.ts +0 -42
- package/dist/core/ProviderRegistry.d.ts.map +0 -1
- package/dist/core/ProviderRegistry.js +0 -72
- package/dist/core/ProviderRegistry.js.map +0 -1
- package/dist/core/line-marker.d.ts +0 -23
- package/dist/core/line-marker.d.ts.map +0 -1
- package/dist/core/line-marker.js +0 -321
- package/dist/core/line-marker.js.map +0 -1
- package/dist/core/matcher.d.ts +0 -12
- package/dist/core/matcher.d.ts.map +0 -1
- package/dist/core/matcher.js +0 -72
- package/dist/core/matcher.js.map +0 -1
- package/dist/core/mimetype-binary.d.ts +0 -6
- package/dist/core/mimetype-binary.d.ts.map +0 -1
- package/dist/core/mimetype-binary.js +0 -82
- package/dist/core/mimetype-binary.js.map +0 -1
- package/dist/core/path-mimetype.d.ts +0 -3
- package/dist/core/path-mimetype.d.ts.map +0 -1
- package/dist/core/path-mimetype.js +0 -47
- package/dist/core/path-mimetype.js.map +0 -1
- package/dist/core/plugin-trust.d.ts +0 -4
- package/dist/core/plugin-trust.d.ts.map +0 -1
- package/dist/core/plugin-trust.js +0 -23
- package/dist/core/plugin-trust.js.map +0 -1
- package/dist/providers/Mock.d.ts +0 -43
- package/dist/providers/Mock.d.ts.map +0 -1
- package/dist/providers/Mock.js +0 -36
- package/dist/providers/Mock.js.map +0 -1
- package/dist/server/methods/op_hide.d.ts +0 -5
- package/dist/server/methods/op_hide.d.ts.map +0 -1
- package/dist/server/methods/op_hide.js +0 -24
- package/dist/server/methods/op_hide.js.map +0 -1
- package/dist/server/methods/op_show.d.ts +0 -5
- package/dist/server/methods/op_show.d.ts.map +0 -1
- package/dist/server/methods/op_show.js +0 -24
- package/dist/server/methods/op_show.js.map +0 -1
- package/dist/server/methods/session_set_persona.d.ts +0 -5
- package/dist/server/methods/session_set_persona.d.ts.map +0 -1
- package/dist/server/methods/session_set_persona.js +0 -29
- package/dist/server/methods/session_set_persona.js.map +0 -1
package/.env.example
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
# plurnk-service
|
|
1
|
+
# plurnk-service config — the shipped legend: every knob + its default.
|
|
2
2
|
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# On first run this file is copied to ~/.plurnk/.env.example, which is the cascade FLOOR.
|
|
4
|
+
# Edit there (or layer ~/.plurnk/.env over it). This node_modules copy is the SEED + the
|
|
5
|
+
# source of derived --<knob> CLI flags — it is NOT itself a runtime layer.
|
|
6
|
+
#
|
|
7
|
+
# Override order (low → high precedence):
|
|
8
|
+
# ~/.plurnk/.env.example (the floor — override, don't remove!)
|
|
9
|
+
# < ~/.plurnk/.env (your home config)
|
|
10
|
+
# < ./.env (per-project, current directory)
|
|
11
|
+
# < --env-file=… / --config=…
|
|
12
|
+
# < shell environment
|
|
13
|
+
# < --<knob> CLI flags
|
|
14
|
+
# Feature-flag bools use `=== "1"` exactly, never `=== "true"`. `~/` expands to your home.
|
|
5
15
|
|
|
6
16
|
# --- Storage ---
|
|
7
|
-
PLURNK_DB_PATH
|
|
17
|
+
PLURNK_DB_PATH=~/.plurnk/plurnk.db
|
|
8
18
|
|
|
9
19
|
# --- Sqlite tuning (curated knobs passed through to sqlrite; optional) ---
|
|
10
20
|
# sqlrite already sets the safe posture (WAL + synchronous=NORMAL + busy_timeout=5000ms).
|
|
@@ -22,29 +32,27 @@ PLURNK_DB_PATH=./plurnk.db
|
|
|
22
32
|
PLURNK_HOST=127.0.0.1
|
|
23
33
|
PLURNK_PORT=3044
|
|
24
34
|
|
|
25
|
-
# ---
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# default: Plurnk, Inc.'s hosted, grammar-tuned model at model.plurnk.ai, served
|
|
29
|
-
# anonymously with no account on a throttled free tier. Change this one line to
|
|
30
|
-
# use another model; set it empty for no default provider. Prompts on the default
|
|
31
|
-
# route to model.plurnk.ai — see "Plurnk account" below for (optional) creds.
|
|
32
|
-
PLURNK_MODEL=plurnk
|
|
35
|
+
# --- Client (read by the `plurnk` CLI from this shared home; the daemon ignores it) ---
|
|
36
|
+
# The daemon WebSocket URL the client connects to (mirrors PLURNK_HOST/PORT above).
|
|
37
|
+
# PLURNK_WS=ws://127.0.0.1:3044
|
|
33
38
|
|
|
39
|
+
# --- Model aliases ---
|
|
40
|
+
# PLURNK_MODEL is the active provider for every loop (a client may override per loop
|
|
41
|
+
# via loop.run({alias})). Out of the box it is `plurnk`. Change this one line to use
|
|
42
|
+
# another model; set it empty for no default provider.
|
|
43
|
+
# PLURNK_MODEL_alias=openai/gemma (presumes PLURNK_BASE_URL set locally)
|
|
34
44
|
PLURNK_MODEL_plurnk="plurnk/plurnk"
|
|
35
45
|
|
|
46
|
+
PLURNK_MODEL=plurnk
|
|
47
|
+
|
|
36
48
|
# --- Plurnk account (OPTIONAL) ---
|
|
37
|
-
# Plurnk Service is vendor-agnostic
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
# The hosted endpoint defaults to https://model.plurnk.ai/v1; override it to self-
|
|
45
|
-
# host the model or point at a mirror — it speaks the llama-server API (same grammar
|
|
46
|
-
# transport) like the local model.
|
|
47
|
-
# PLURNK_BASE_URL="https://model.plurnk.ai/v1"
|
|
49
|
+
# Plurnk Service is vendor-agnostic and connects to (almost) any LLM. MIT Licensed.
|
|
50
|
+
# You may (OPTIONALLY) obtain a free PLURNK_API_KEY bearer token at https://plurnk.ai.
|
|
51
|
+
|
|
52
|
+
# PLURNK_API_KEY="..."
|
|
53
|
+
# PLURNK_BASE_URL overrides the default endpoint — self-host or point at a mirror that
|
|
54
|
+
# speaks the llama-server API (same grammar transport).
|
|
55
|
+
# PLURNK_BASE_URL="..."
|
|
48
56
|
|
|
49
57
|
# --- Loop control ---
|
|
50
58
|
# Operator turn ceiling. -1 (default) = no cap (loops end via SEND, budget,
|
|
@@ -60,7 +68,12 @@ PLURNK_RPC_TIMEOUT=30000
|
|
|
60
68
|
# so a fast exec's output can land in it instead of a turn later. A fixed grace
|
|
61
69
|
# beat, NOT a wait-for-completion (slow execs proceed + surface via the wake path).
|
|
62
70
|
# 0 = off (the model sees fast-exec output a turn late, as today).
|
|
63
|
-
PLURNK_EXEC_WAIT_MS=
|
|
71
|
+
PLURNK_EXEC_WAIT_MS=1000
|
|
72
|
+
# Teardown reap grace: when a loop/run tears down a background exec, the spawn gets a polite
|
|
73
|
+
# signal first (SIGHUP, or the model's KILL[code]); a stream that IGNORES it is hard-killed
|
|
74
|
+
# (SIGKILL, to the whole process group) this many ms later — so the reap can't wedge on a
|
|
75
|
+
# signal-ignoring child. plurnk-execs refuses to bake this number; the consumer owns it.
|
|
76
|
+
PLURNK_EXEC_KILL_GRACE_MS=2000
|
|
64
77
|
PLURNK_LOOP_TIMEOUT=86400000
|
|
65
78
|
|
|
66
79
|
# --- Engine rails ---
|
|
@@ -137,6 +150,10 @@ PLURNK_VERSION_POLL_TTL=3600000
|
|
|
137
150
|
# @plurnk/plurnk-grammar; an absolute/relative path is your own. =0 (or empty) disables.
|
|
138
151
|
# PLURNK_PROVIDERS_GBNF=plurnk.gbnf
|
|
139
152
|
|
|
153
|
+
# GBNF debug, honored natively by @plurnk/plurnk-providers (>=0.13.0): validate the grammar locally
|
|
154
|
+
# (fail-hard if malformed) and run UNCONSTRAINED, never sending it to the model. Dev aid; off by default.
|
|
155
|
+
PLURNK_GBNF_DEBUG=0
|
|
156
|
+
|
|
140
157
|
# Provider retry attempts (providers 0.7+): how many times generate() retries a
|
|
141
158
|
# TRANSIENT failure (429 rate-limit, 5xx/network) with exponential backoff (base 2s
|
|
142
159
|
# is a provider constant — the COUNT is the operator knob). REQUIRED, fail-hard if
|
package/README.md
CHANGED
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
# plurnk-service
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Default Provider: [plurnk.ai](https://plurnk.ai).
|
|
3
|
+
> Plurnk is in early-alpha public testing — see https://status.plurnk.ai for current status.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
* Plurnk Service is MIT Licensed and owned by Plurnk Foundation, not Plurnk, Inc.
|
|
8
|
-
* Plurnk, Inc.'s grammar-tuned [plurnk.ai](https://plurnk.ai) model is offered as an optional convenience.
|
|
9
|
-
* You may (OPTIONALLY) obtain free PLURNK_ACCOUNT and PLURNK_KEY variables at [plurnk.ai](https://plurnk.ai).
|
|
5
|
+
LLM agent runtime engine. Consumes [plurnk-grammar](https://github.com/plurnk/plurnk-grammar); exposes WebSocket JSON-RPC. User-facing CLI: [plurnk](https://github.com/plurnk/plurnk). Provider-agnostic, MIT — no vendor or model lock-in.
|
|
10
6
|
|
|
11
|
-
##
|
|
7
|
+
## What an agent can do
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
- [`AGENTS.md`](./AGENTS.md) — collaboration memory for agents working on this repo (gitignored).
|
|
9
|
+
Grammar ops: `PLAN` reason · `READ`/`EDIT` files · `FIND` search · `EXEC` run shell/code · `SEND` message or conclude · `COPY`/`MOVE`/`KILL` manage · `OPEN`/`FOLD` curate its own context.
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
Over schemes: `file://` project files · `exec://` command output · `http(s)://` web fetch · `run://` sibling agent runs (spawn / fork / message) · `known://` scratch · `log://` own history.
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
## Loop model
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
Session = the shared world (one filesystem + membership overlay). Run = one agent's private log. Loop = one `prompt → ops → SEND[terminal]` cycle; every turn leads with `PLAN`. Runs fork and message each other — many clients, many runs, one session.
|
|
16
|
+
|
|
17
|
+
## Integration (WebSocket JSON-RPC)
|
|
18
|
+
|
|
19
|
+
Methods: `session.*` (create / attach / constrain / list…) · `loop.run` / `loop.inject` / `loop.resolve` · `op.*` (read / edit / find / exec / send…) · `log.read` · `run.fork`. Streams: `log/entry` → … → `loop/terminated`, plus `loop/proposal`, `telemetry/event`. Full live catalog: the `discover` RPC.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
ws connect → session.create({ projectRoot }) → loop.run({ prompt })
|
|
23
|
+
→ read log/entry notifications until loop/terminated
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The human CLI over this surface is [plurnk](https://github.com/plurnk/plurnk).
|
|
27
|
+
|
|
28
|
+
## Run
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
npm install -g @plurnk/plurnk-service
|
|
32
|
+
plurnk-service start # daemon (`migrate` initializes the DB)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Config + state live in `~/.plurnk/` (created on first run): set `PLURNK_MODEL` and friends in `~/.plurnk/.env`; the DB defaults to `~/.plurnk/plurnk.db`. Provider-agnostic — point `PLURNK_MODEL` at any vendor. Full override cascade (`~/.plurnk` < `./.env` < `--env-file` < shell < `--flags`) is documented at the top of `.env.example`. Also exports `{ Engine, Daemon, SchemeRegistry }` for in-process embedding.
|
|
36
|
+
|
|
37
|
+
## Contract & siblings
|
|
38
|
+
|
|
39
|
+
- [`SPEC.md`](./SPEC.md) — canonical specification. One `§<tag>` namespace; anchors `{§<tag>}` bind 1:1 to `test/intg/spec-anchors.test.ts`.
|
|
40
|
+
- [plurnk-providers](https://github.com/plurnk/plurnk-providers) §provider · [plurnk-schemes](https://github.com/plurnk/plurnk-schemes) §scheme-surface · [plurnk-mimetypes](https://github.com/plurnk/plurnk-mimetypes) §mimetype-surface · [plurnk-execs](https://github.com/plurnk/plurnk-execs) §bundled-set.
|
|
41
|
+
|
|
42
|
+
## Semantic search
|
|
43
|
+
|
|
44
|
+
`FIND`'s `~query` ranks semantically via an optional embedder peer, `@plurnk/plurnk-mimetypes-embeddings` (heavy native deps; not installed by default). Absent → `~query` falls back to FTS keyword ranking and `start` prints an `embedder inactive` notice. Enable vector search: `npm i @plurnk/plurnk-mimetypes-embeddings`.
|
|
26
45
|
|
|
27
46
|
## Tests
|
|
28
47
|
|
|
29
|
-
|
|
48
|
+
`test:lint`, `test:unit`, `test:intg`, `test:live`, `test:demo`; off-hot-path `test:installation`.
|
package/SPEC.md
CHANGED
|
@@ -102,7 +102,7 @@ Dependency direction (from root to leaf):
|
|
|
102
102
|
- `plurnk-mimetypes` — handler base classes, discovery, fitting algorithm, matcher dispatch. Handler children are per-mimetype: `plurnk-mimetypes-text-{python,typescript,markdown,html,csv,plain}`, `plurnk-mimetypes-application-{json,yaml,toml,pdf}`, …
|
|
103
103
|
- `plurnk-schemes` — scheme-author types (`SchemeManifest`, `WriterTier`, `LoopFlags`), result-shape contracts (`EntryResult` / `ProposalResult` / `PassthroughResult`), slicing primitives, matcher helpers, `schemeError(...)` constructor. Future scheme children: `plurnk-schemes-http`, `plurnk-schemes-git`, …
|
|
104
104
|
- `plurnk-execs` — `BaseExecutor`, `SubprocessExecutor`, runtime resolver, discovery. Children declare runtimes: `plurnk-execs-sh`, future `plurnk-execs-search`, `plurnk-execs-node`, …
|
|
105
|
-
- **`plurnk-service`** (this repo) — consumes all of the above. Implements the engine, dispatches ops through scheme handlers, hosts the in-tree set of schemes (`plurnk`, `log`, `exec`, `known`, `unknown`, `skill`, `file`), discovers installed mimetype handlers + provider vendors + executor siblings at boot, hosts the daemon (`
|
|
105
|
+
- **`plurnk-service`** (this repo) — consumes all of the above. Implements the engine, dispatches ops through scheme handlers, hosts the in-tree set of schemes (`plurnk`, `log`, `exec`, `known`, `unknown`, `skill`, `file`), discovers installed mimetype handlers + provider vendors + executor siblings at boot, hosts the daemon (`src/service.ts` over WebSocket + JSON-RPC), and projects packets to the wire per `Packet.json`. Most of the substantive runtime work lives here.
|
|
106
106
|
- **`plurnk`** (client) — terminal UI consuming the daemon's RPC surface. Renders `telemetry/event` notifications, subscribes to log/stream/proposal events. No engine logic of its own.
|
|
107
107
|
|
|
108
108
|
The grammar is the contract. The frameworks consume the contract and add author-facing surfaces. The service consumes the frameworks and runs the engine. The client consumes the service and renders to humans. Each tier is its own published package; each tier's evolution happens in its own repo.
|
|
@@ -188,6 +188,17 @@ Beyond the three creation ops:
|
|
|
188
188
|
- **Cap** — `PLURNK_SESSION_RUNS_MAX_ACTIVE` ceilings the *concurrent* active runs per session (a run with a non-terminal loop); a spawn or fork past it fails hard (508 — no queue, no retry), irc exempt; `-1` disables it. The fork-bomb brake, sized for sessions that live for months. {§run-scheme-cap}
|
|
189
189
|
- **Collect** — a run's loop reaching a terminal status surfaces to its sisters as an ambient FOLDED delta (§env-delta): a `SEND` from `run:///<name>` carrying the loop's deliverable — the `SEND[200]` body, or for an abandonment the reason. Every death-path is stamped uniformly, so no termination is silent; collection is the shared world moving, never a verb. {§run-scheme-collect}
|
|
190
190
|
|
|
191
|
+
### §run-lifecycle Run lifecycle: the drain, the reap, the passive wake
|
|
192
|
+
|
|
193
|
+
A run is a **log plus a cancellation scope** — one `AbortController` per run, reused while live and replaced only once aborted, so a cancel ends the run as a unit and a later `loop.run` is never born cancelled. A run's queued loops are advanced by a **drain**: a single per-run worker that claims loops atomically (status 100→102) and runs each under the run's scope. A loop may spawn **streams** (execs) that outlive it; each is a row in the subscription registry (§subscriptions) — the durable record of what the run holds open. Cancellation and conclusion are defined against these structures, never wall-clock timing.
|
|
194
|
+
|
|
195
|
+
- **One drain advances a run.** At most one drain is registered for a run at any instant: a `loop.run` or wake on a run with a live drain folds in (active→next-turn) or enqueues a loop that drain claims, never a second parallel drain. A drain's start and its empty-queue teardown relinquish run under one per-run lock, so the teardown's re-claim cannot race a concurrent start into a double-drain. {§run-lifecycle-single-drain}
|
|
196
|
+
- **A cancel reaps every stream the run holds — by the registry.** `loop.cancel` / `KILL` / shutdown abort the run scope AND iterate the run's open subscriptions, aborting each via its owning scheme; the registry is the source of truth, the in-process abort signal a fast-path optimization. A stream that is running, mid-spawn (its row written before it is killable), or spawned after the cancel is reaped alike. The teardown abort is a BOUNDED reap — the executor sends a polite signal then SIGKILL after a consumer-set grace (`PLURNK_EXEC_KILL_GRACE_MS`), so a signal-ignoring stream can't wedge it; a model `KILL[code]` on a live stream instead delivers exactly that signal once (bare `KILL` → the executor's SIGHUP default, `KILL[9]` → SIGKILL), the model owning any escalation. {§run-lifecycle-total-reap}
|
|
197
|
+
- **A stream's kill binds to the scope it captured at spawn.** A stream captures the run's cancellation scope as it registers and wires its kill to it, re-checking `aborted` AFTER wiring — no check-then-listen gap can drop an abort that lands mid-registration. Because the scope is replaced only once aborted, a captured-then-replaced scope is necessarily already aborted, so replacement never strands a live stream. {§run-lifecycle-exec-epoch-bound}
|
|
198
|
+
- **A cancelled run is not resurrected by its own torn-down work.** A stream conclusion delivered to a cancelled, idle run starts no fresh drain: an aborted (499) conclusion is skipped, and a straggler that concluded cleanly surfaces its deliverable as an environment delta (§env-delta), never a revived loop. The cancel was deliberate; only an explicit `loop.run` resumes the run. {§run-lifecycle-no-resurrection}
|
|
199
|
+
- **A stream conclusion always reaches its run.** When a backgrounded stream concludes, the daemon routes it through the same inject seam as any loop source (§actor-boundary-passive-wake): an active run folds the conclusion into its next turn; a run parked at a **slept loop** (`SEND[202]`) **awakens that loop in place** — the slept loop *is* the continuation, so there is no fresh loop and no summary-as-prompt fiction. The result is never lost: a parked loop sleeps rather than ending, and the stream's status-transition is the OPEN event (§actor-boundary-passive-wake) that wakes it; on resume it reads the concluded stream's own state, not a synthetic prompt. {§run-lifecycle-wake-liveness}
|
|
200
|
+
- **A loop is never stranded by a drain's exit.** A drain relinquishes its registry slot only after a lock-held re-claim confirms the queue is empty; a loop enqueued during that teardown is either re-claimed by the exiting drain or claimed by a fresh drain that a later inject starts. The relinquish and the start are serialized, so neither the lost-loop hang nor a transient double-drain can occur. {§run-lifecycle-no-lost-loop}
|
|
201
|
+
|
|
191
202
|
---
|
|
192
203
|
|
|
193
204
|
## §provider Provider Contract
|
|
@@ -212,6 +223,20 @@ Plus immutable identity: `provider.contextSize` (token total, or `null` → "no
|
|
|
212
223
|
- `assistantRaw` is opaque to the engine (forensics-only). {§provider-guarantees-assistantraw-opaque}
|
|
213
224
|
- `countTokens` is cheap by contract; engine calls frequently.
|
|
214
225
|
|
|
226
|
+
### §attribution First-party plugin attribution
|
|
227
|
+
|
|
228
|
+
A plugin declares an opaque attribution tag in its `package.json` so the creators behind it can be credited when the plugin is active:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
{ "plurnk": { "attribution": "@acme/widgets" } } // a string, or string[]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The engine unions the declared tags of the active plugin families (schemes, execs) onto `generate({ attributions })`, deduped + stable, per turn; an empty set is omitted. The service does not interpret a tag; richer creator identities (`@plurnk/creators/<name>`) ride the same namespace later.
|
|
235
|
+
|
|
236
|
+
**The `@plurnk/` namespace is reserved.** A package may declare an `@plurnk/` tag only if it is itself `@plurnk/`-scoped (npm enforces scope ownership at publish); otherwise it fails hard. {§attribution-plurnk-namespace-reserved}
|
|
237
|
+
|
|
238
|
+
Deferred (#249): grounding the value in real per-turn value flow rather than the active-plugin placeholder, token-weighting, entry-level attribution, and the `client` id. Native surfacing of the field in each framework's `discover()` supersedes the service-side manifest read and extends collection to mimetype + provider plugins.
|
|
239
|
+
|
|
215
240
|
### §provider-instantiation Provider instantiation
|
|
216
241
|
|
|
217
242
|
Model alias parsing (`parseAliasesFromEnv` / `resolveActiveAlias`) lives in [`@plurnk/plurnk-providers`](https://github.com/plurnk/plurnk-providers). {§provider-instantiation-alias-resolution} Dynamic provider instantiation (`instantiateProvider` / `loadActiveProvider`) lives in `src/core/ProviderInstantiate.ts` here — `import()` resolves package specifiers relative to the calling module, so the dynamic-import path stays in the consumer where the `@plurnk/plurnk-providers-<vendor>` packages are installed.
|
|
@@ -714,7 +739,7 @@ Plugin discovery (§plugin-discovery) registers whatever's in `node_modules/@plu
|
|
|
714
739
|
|
|
715
740
|
## §operator-config Operator Configuration
|
|
716
741
|
|
|
717
|
-
Env-var cascade: `.env.example` < `.env` < `.env.<config>` (via `--config=`) < shell < CLI flags. `
|
|
742
|
+
Env-var cascade: `.env.example` < `.env` < `.env.<config>` (via `--config=`) < shell < CLI flags. `src/service.ts` auto-loads `.env.example`; zero-setup boot.
|
|
718
743
|
|
|
719
744
|
Model selection: separate alias cascade in `ProviderRegistry` (§provider-instantiation). `PLURNK_MODEL_<alias>=<provider>/<model-id>` declares; `PLURNK_MODEL=<alias>` selects. Aliases live in `.env`, not `.env.example` (operator-specific).
|
|
720
745
|
|
|
@@ -734,7 +759,6 @@ Model selection: separate alias cascade in `ProviderRegistry` (§provider-instan
|
|
|
734
759
|
| `PLURNK_MANIFEST_ITEMS` | `0` | enforced | Turn-0 manifest preview foisted into the model's first turn. `-1` = full `plurnk:///manifest.json`; positive `N` = the first N items (jsonpath slice); `0` / unset = off (§actor-boundary-manifest-preview). |
|
|
735
760
|
| `PLURNK_PROPOSAL_TIMEOUT_MS` | `300000` | enforced | ms wait for a proposed entry (status=202) to be resolved before timing out. |
|
|
736
761
|
| `PLURNK_PROVIDERS_REASON_LEVEL` | `0` | enforced | Reasoning **magnitude** sent to the providers: `0` = none, positive = effort/budget the provider module translates to wire format (o-series tiers, Anthropic `budget_tokens`). The on/off is the `PLURNK_PROVIDERS_REASONING` gate. |
|
|
737
|
-
| `PLURNK_PLAN` | `0` | enforced | Enable the grammar's `<<PLAN` op — advertised in the `# Plurnk System Tools` packet section (§tools). `1` on, `0` off. |
|
|
738
762
|
| `PLURNK_FETCH_TIMEOUT` | `600000` | enforced | Service-wide ms ceiling on any outbound request (providers, future http schemes). Module-specific overrides are allowed below the ceiling. |
|
|
739
763
|
| `PLURNK_DEBUG` | `0` | reserved | Schema-validation toggle. Not yet enforced. |
|
|
740
764
|
| `PLURNK_LOG_LEVEL` | `info` | reserved | Stdout banner verbosity. Not yet enforced. |
|
|
@@ -754,14 +778,14 @@ Enforcement is per-use-site — no central most-restrictive pass; each ceiling i
|
|
|
754
778
|
- `settings.mdDocs` (`[{alias, content}]`) **unions** with the server's `PLURNK_MD_*` docs, keyed by alias — a client adds its own repo docs atop the operator's systemwide policy doc. On alias collision the client wins (a deliberate shadow), but by default the policy doc rides into every session. The client sends content (it owns the file), not a path. {§operator-config-session-md-docs}
|
|
755
779
|
|
|
756
780
|
*Ceilings — most-restrictive-wins (the client may only narrow, never widen):*
|
|
757
|
-
- `settings.maxCommands` (number) **min()s** the `PLURNK_MAX_COMMANDS` per-emission cap for the session — a client tightens the runaway-op guard, never raises it past the operator's. {§operator-config-session-max-commands}
|
|
781
|
+
- `settings.maxCommands` (number) **min()s** the `PLURNK_MAX_COMMANDS` per-emission cap for the session — a client tightens the runaway-op guard, never raises it past the operator's. {§operator-config-session-max-commands} The cap bounds *actions* only: PLAN (reasoning) and a terminal `SEND` (signal ≥ 200, the conclusion) are never counted and always dispatch — so `0` is a valid floor (the tightest), admitting a plan and a conclusion with zero actions. {§operator-config-session-max-commands-floor}
|
|
758
782
|
- `settings.git` (`false`) **denies** git for the session (`PLURNK_GIT_ALLOWED` AND session) — the client opts its session out of git membership + telemetry; it can never re-enable git past the operator's service-wide lockout. {§operator-config-session-git}
|
|
759
783
|
|
|
760
784
|
Feature-flag bools use `process.env.X === "1"` exactly — never `=== "true"`.
|
|
761
785
|
|
|
762
786
|
External plugins declare their own env vars in their own `.env.example`; service merges at boot via the cascade.
|
|
763
787
|
|
|
764
|
-
**Admin CLI flag derivation.** `
|
|
788
|
+
**Admin CLI flag derivation.** `src/service.ts` auto-derives flags from `.env.example`: every `PLURNK_*` becomes `--<kebab-cased-name>` (prefix stripped, lowercased, underscores → dashes). Comment immediately above (no blank line) becomes `-h` description. Non-`PLURNK_*` vars in `.env.example` are bugs — vendor config belongs in the vendor's package namespace.
|
|
765
789
|
|
|
766
790
|
---
|
|
767
791
|
|
|
@@ -872,7 +896,7 @@ registry.register("loop.run", {
|
|
|
872
896
|
|
|
873
897
|
| Method | Params | Result | Notes |
|
|
874
898
|
|-------------------|-------------------------------------|------------------------|-------|
|
|
875
|
-
| `loop.run` | `prompt: string`, `maxTurns?: number`, `alias?: string`, `flags?: LoopFlags` | `{ loopId,
|
|
899
|
+
| `loop.run` | `prompt: string`, `maxTurns?: number`, `alias?: string`, `flags?: LoopFlags` | `{ loopId, action, finalStatus: 100 }` | Model-driven loop. **Accepts and returns immediately** (`finalStatus: 100`; `action` = `enqueued_new_loop` \| `injected_next_turn`) — it never blocks on the loop, which can park indefinitely (`SEND[202]`, §run-lifecycle-wake-liveness). The loop's outcome — `finalStatus`, `turnIds`, `hitMaxTurns`, `usage` — arrives on the **`loop/terminated`** event. Optional `alias` overrides the boot-time `PLURNK_MODEL`. Optional `flags` carries per-loop flags (`{yolo?: boolean}`; more as wired — see §engine-rails). Streams `log/entry` and `loop/proposal` during. `longRunning: false`. {§methods-loop-run} |
|
|
876
900
|
| `loop.resolve` | `logEntryId: number`, `decision: "accept" \| "reject" \| "cancel"`, `body?: string`, `outcome?: string` | `{ status, logEntryId }` | Resolve a pending proposal (status=202 log entry). Engine.dispatch unpauses on resolution. |
|
|
877
901
|
| `loop.cancel` | `reason?: string` | `{ cancelled, runId, reason }` | Abort the attached run's active drain. `{cancelled: true}` if a drain was running, `{false}` if idle. Cancelled loops close at 499; queued-but-unclaimed loops stay enqueued. Default reason `user_cancelled`. {§methods-loop-cancel} |
|
|
878
902
|
| `providers.list` | none | `{ aliases: ProviderAlias[] }` | Lists configured `PLURNK_MODEL_<alias>` entries with `{alias, provider, model, active}`. Clients use to populate model-selection UI. |
|
|
@@ -923,7 +947,7 @@ Server-initiated events on the same WebSocket.
|
|
|
923
947
|
| `loop/proposal` | `{ logEntryId, sessionId, runId, loopId, turnId, op, target, body, attrs, flags }` | Dispatch pauses on status=202. Carries `flags` so server-YOLO clients can suppress review UI. Client responds with `loop.resolve` (or `PLURNK_PROPOSAL_TIMEOUT_MS` fires). |
|
|
924
948
|
| `session/created` | `{ id, name, projectRoot }` | Any client creates a session. |
|
|
925
949
|
| `stream/event` | `{ entryId, channel, state, contentLength }` | Channel content grows or state transitions. {§notifications-stream-event-on-channel-change} |
|
|
926
|
-
| `stream/concluded` | `{ entryId, target, subscriptionId, scheme, closeStatus, summary, wakeAction, wakeLoopId? }` | A streaming subscription closed (subprocess finished / errored / cancelled). `wakeAction` says
|
|
950
|
+
| `stream/concluded` | `{ entryId, target, subscriptionId, scheme, closeStatus, summary, wakeAction, wakeLoopId? }` | A streaming subscription closed (subprocess finished / errored / cancelled). `wakeAction` says how the conclusion reached the run: `resumed-loop` (a slept `202` loop resumed in place, §run-lifecycle-wake-liveness), `no-op-active-loop` (folded into a live loop's next turn), `skipped-aborted`/`skipped-cancelled`/`skipped-no-provider`, or `no-loop` (nothing to resume). `summary` rides the notification for client display; it is no longer fed to the model as a prompt. {§notifications-stream-concluded} |
|
|
927
951
|
| `telemetry/event` | `{ loopId, event: TelemetryEvent }` | A TelemetryEvent (parse error, engine-rail strike/cycle/sudden-death, scheme/provider failure) was buffered — the same envelope the model sees on the next packet, delivered live for client surfacing. {§notifications-telemetry-event} |
|
|
928
952
|
|
|
929
953
|
`stream/event` carries metadata only, never content. Clients fetch via `entry.read({target})`. **Every notification envelope carries its `sessionId`** (and `runId` where the emitter has it) so a multi-session client — one connection, many sessions — can route it ({§notifications-envelope-carries-sessionid}); the broadcast stays session-scoped too.
|
|
@@ -1166,7 +1190,7 @@ The wire projection (`PacketWire.renderSlot`) groups sections by slot into the s
|
|
|
1166
1190
|
|
|
1167
1191
|
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a plurnk-origin `EDIT` against `plurnk:///prompt/<loop_id>` (indexable, body channel, text/markdown). At render time the current loop's prompt body materializes into the `prompt` section; the entry itself stays READ/FOLD-able like any other. The foisted `EDIT`'s **log row is folded by default** (`expanded=0`): the prompt body already lives in the `prompt` section, so the log keeps the action for forensics while collapsing the duplicate body, re-OPENable like any fold (§open-fold). {§prompt-fold}
|
|
1168
1192
|
|
|
1169
|
-
**The entry catalog.** `plurnk:///manifest.json` is a real session entry the model READs to discover what's available — rewritten every turn as a live view of the full entry set. Built in the schemes layer (`_entry-manifest`) and materialized like any entry (the engine only orchestrates the per-turn write — the same pattern as git membership), so it's READable and queryable. Body is `application/json`: a flat, **complete, unranked** array — one item per entry across all schemes, every entry listed in no relevance order, each `{ path, tags?, channels: { <
|
|
1193
|
+
**The entry catalog.** `plurnk:///manifest.json` is a real session entry the model READs to discover what's available — rewritten every turn as a live view of the full entry set. Built in the schemes layer (`_entry-manifest`) and materialized like any entry (the engine only orchestrates the per-turn write — the same pattern as git membership), so it's READable and queryable. Body is `application/json`: a flat, **complete, unranked** array — one item per entry across all schemes, every entry listed in no relevance order, each `{ path, tags?, channels: { <uri>: { mimetype, tokens, lines } } }` — every channel keyed by the URI the model READs (the default channel by the bare path, a non-default by `path#channel`), so it reaches a channel without guessing. `tags` is present only when the entry carries `entry_tags` — its own categorization, surfaced so the model sees it in the directory and can `FIND` by tag without a separate read. The model ranks and filters the catalog itself by querying it (task-aware); the catalog never ranks for it — the instant it did, it would be an index again. `tokens` is the provider's write-time count (budget depth), `lines` the content extent from `Mimetypes.process().totalLines`. The engine counts neither. It does not list itself. {§packet-manifest-catalog}
|
|
1170
1194
|
|
|
1171
1195
|
### §telemetry user.telemetry — model-facing runtime telemetry
|
|
1172
1196
|
|
|
@@ -1206,7 +1230,7 @@ Strike accounting, cycle detection, sudden-death thresholds, and no-ops bookkeep
|
|
|
1206
1230
|
|
|
1207
1231
|
A `# Plurnk System Tools` section renders **above** `# Plurnk System Requirements` — a hook-populated list of the capabilities enabled this session, so the model sees what it can *do* before the rules it must follow. Each enabled capability contributes one line via `Engine.#collectTools`; the whole section is omitted when nothing is enabled. {§tools-capability-sheet}
|
|
1208
1232
|
|
|
1209
|
-
**Contributors: the wired executor tags.** Each available executor tag injects a line describing its tag and functionality (the boot `ExecutorRegistry` probes availability per tag), retiring the model's blind `<<EXEC[sh]…`.
|
|
1233
|
+
**Contributors: the wired executor tags.** Each available executor tag injects a line describing its tag and functionality (the boot `ExecutorRegistry` probes availability per tag), retiring the model's blind `<<EXEC[sh]…`.
|
|
1210
1234
|
|
|
1211
1235
|
### §schemes user.schemes — the scheme directory
|
|
1212
1236
|
|
|
@@ -1216,7 +1240,7 @@ A `# Plurnk System Schemes` section renders in the system slot **after the defin
|
|
|
1216
1240
|
|
|
1217
1241
|
### §requirements The requirements section — static per-turn rules
|
|
1218
1242
|
|
|
1219
|
-
Rendered at the END of the user packet under `# Plurnk System Requirements` {§requirements-requirements-render-last} — closest to the assistant turn so the contract the model has to honor is the most recent text it sees. The header is omitted entirely when the requirements string is empty. {§requirements-requirements-omitted-when-empty} Contains rules the grammar block doesn't cover (canonical example: "Conclude the loop with `<<SEND[200]:answer:SEND`"). The op syntax leads the section
|
|
1243
|
+
Rendered at the END of the user packet under `# Plurnk System Requirements` {§requirements-requirements-render-last} — closest to the assistant turn so the contract the model has to honor is the most recent text it sees. The header is omitted entirely when the requirements string is empty. {§requirements-requirements-omitted-when-empty} Contains rules the grammar block doesn't cover (canonical example: "Conclude the loop with `<<SEND[200]:answer:SEND`"). The op syntax leads the section. PLAN is mandated unconditionally by plurnk.md §Imperatives (grammar 0.70 requires every turn to lead with `<<PLAN`), so the service injects no separate plan directive here.
|
|
1220
1244
|
|
|
1221
1245
|
**Sourcing:** caller supplies the string via `runLoop({ requirements })` / `runTurn({ requirements })`. Plurnk-service exposes `PATHS.defaultRequirements` (resolves `PLURNK_REQUIREMENTS` env → in-package `requirements.md`). No DB cascade — same string every turn.
|
|
1222
1246
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelWrite.d.ts","sourceRoot":"","sources":["../../src/core/ChannelWrite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAA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CAAA;KAAE,GACvD,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;WAUpD,2BAA2B,CACpC,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAGpD"}
|
|
@@ -15,6 +15,7 @@ export default class ChannelWrite {
|
|
|
15
15
|
static #openSubStmt(db) { return db.open_subscription; }
|
|
16
16
|
static #closeSubStmt(db) { return db.close_subscription; }
|
|
17
17
|
static #findActiveStmt(db) { return db.find_active_subscription; }
|
|
18
|
+
static #openSubsForRunStmt(db) { return db.find_open_subscriptions_for_run; }
|
|
18
19
|
static #execTerminalStmt(db) { return db.find_exec_close_status; }
|
|
19
20
|
// The entry's target URI for stream notifications (#179). A NULL scheme is
|
|
20
21
|
// a filesystem entry (the file scheme stores scheme=NULL), so it decodes to
|
|
@@ -76,5 +77,13 @@ export default class ChannelWrite {
|
|
|
76
77
|
const row = await ChannelWrite.#findActiveStmt(db).get({ run_id: runId, entry_id: entryId });
|
|
77
78
|
return row ?? null;
|
|
78
79
|
}
|
|
80
|
+
// The run's still-open subscriptions — the registry-routed reap
|
|
81
|
+
// (§run-lifecycle-total-reap). A cancel iterates these and aborts each via the
|
|
82
|
+
// owning scheme, so a backgrounded exec is reaped regardless of in-process
|
|
83
|
+
// AbortSignal-listener timing (R1): the registry is the source of truth, the
|
|
84
|
+
// signal an optimization.
|
|
85
|
+
static async findOpenSubscriptionsForRun(db, runId) {
|
|
86
|
+
return ChannelWrite.#openSubsForRunStmt(db).all({ run_id: runId });
|
|
87
|
+
}
|
|
79
88
|
}
|
|
80
89
|
//# sourceMappingURL=ChannelWrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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AC,KAAK,CAAC,kBAAkB,CAC3B,EAAM,EACN,EAAE,SAAS,EAAE,QAAQ,EAA2C;QAEhE,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAG,CAA2B,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxH,OAAO,GAAG,EAAE,YAAY,IAAI,IAAI,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAC/B,EAAM,EACN,EAAE,KAAK,EAAE,OAAO,EAAsC;QAEtD,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,GAAG,CAAiD,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7I,OAAO,GAAG,IAAI,IAAI,CAAC;IACvB,CAAC;IAED,gEAAgE;IAChE,+EAA+E;IAC/E,2EAA2E;IAC3E,6EAA6E;IAC7E,0BAA0B;IAC1B,MAAM,CAAC,KAAK,CAAC,2BAA2B,CACpC,EAAM,EACN,KAAa;QAEb,OAAO,YAAY,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,GAAG,CAAiC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACvG,CAAC;CACJ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
-- Channel-write SQL for streaming schemes. SPEC §channel-state + §subscriptions + §notifications.
|
|
2
|
+
|
|
3
|
+
-- PREP: channel_meta
|
|
4
|
+
SELECT e.session_id, e.scheme, e.pathname, ec.state, ec.mimetype, length(ec.content) AS contentLength
|
|
5
|
+
FROM entry_channels ec
|
|
6
|
+
JOIN entries e ON e.id = ec.entry_id
|
|
7
|
+
WHERE ec.entry_id = $entry_id AND ec.name = $channel;
|
|
8
|
+
|
|
9
|
+
-- PREP: append_to_channel
|
|
10
|
+
UPDATE entry_channels
|
|
11
|
+
SET content = content || $chunk
|
|
12
|
+
WHERE entry_id = $entry_id AND name = $channel;
|
|
13
|
+
|
|
14
|
+
-- PREP: set_channel_state
|
|
15
|
+
UPDATE entry_channels
|
|
16
|
+
SET state = $state
|
|
17
|
+
WHERE entry_id = $entry_id AND name = $channel;
|
|
18
|
+
|
|
19
|
+
-- PREP: set_channel_mimetype
|
|
20
|
+
-- A streaming scheme labels the channel with the body's per-call type (#226 —
|
|
21
|
+
-- http's Content-Type varies per fetch). Conditional: only writes when the type
|
|
22
|
+
-- actually changed, so labelling every chunk is a steady-state no-op.
|
|
23
|
+
UPDATE entry_channels
|
|
24
|
+
SET mimetype = $mimetype
|
|
25
|
+
WHERE entry_id = $entry_id AND name = $channel AND mimetype != $mimetype;
|
|
26
|
+
|
|
27
|
+
-- PREP: replace_channel_content
|
|
28
|
+
-- Full content swap for one channel (ChannelCaps.replace). Re-tokenizes at
|
|
29
|
+
-- write (unlike append_to_channel, which defers token count to render).
|
|
30
|
+
UPDATE entry_channels
|
|
31
|
+
SET content = $content, tokens = $tokens
|
|
32
|
+
WHERE entry_id = $entry_id AND name = $channel;
|
|
33
|
+
|
|
34
|
+
-- PREP: open_subscription
|
|
35
|
+
INSERT INTO subscriptions (run_id, entry_id, scheme, handle)
|
|
36
|
+
VALUES ($run_id, $entry_id, $scheme, $handle)
|
|
37
|
+
RETURNING id;
|
|
38
|
+
|
|
39
|
+
-- PREP: close_subscription
|
|
40
|
+
UPDATE subscriptions
|
|
41
|
+
SET closed_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
42
|
+
, close_status = $status
|
|
43
|
+
WHERE id = $subscription_id AND closed_at IS NULL;
|
|
44
|
+
|
|
45
|
+
-- PREP: find_active_subscription
|
|
46
|
+
SELECT id, scheme, handle
|
|
47
|
+
FROM subscriptions
|
|
48
|
+
WHERE run_id = $run_id AND entry_id = $entry_id AND closed_at IS NULL;
|
|
49
|
+
|
|
50
|
+
-- PREP: find_open_subscriptions_for_run
|
|
51
|
+
-- The run's still-open subscriptions — the registry-routed reap (§run-lifecycle-total-reap):
|
|
52
|
+
-- loop.cancel / KILL / shutdown iterate these and abort each via the owning scheme, so a
|
|
53
|
+
-- backgrounded exec is reaped independent of any in-process AbortSignal-listener timing.
|
|
54
|
+
SELECT id, scheme
|
|
55
|
+
FROM subscriptions
|
|
56
|
+
WHERE run_id = $run_id AND closed_at IS NULL;
|
|
57
|
+
|
|
58
|
+
-- PREP: find_exec_close_status
|
|
59
|
+
-- Terminal outcome of a finished exec stream, addressed by its coordinate
|
|
60
|
+
-- pathname — the KILL-on-a-non-running-exec lookup. 499 (aborted) = killed
|
|
61
|
+
-- earlier; any other terminal status = exited naturally; no row = unknown exec.
|
|
62
|
+
SELECT s.close_status
|
|
63
|
+
FROM entries e
|
|
64
|
+
JOIN subscriptions s ON s.entry_id = e.id
|
|
65
|
+
WHERE e.scope = 'session' AND e.session_id = $session_id
|
|
66
|
+
AND e.scheme = 'exec' AND e.pathname = $pathname
|
|
67
|
+
AND s.closed_at IS NOT NULL
|
|
68
|
+
ORDER BY s.closed_at DESC
|
|
69
|
+
LIMIT 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../src/core/Engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAwF,MAAM,wBAAwB,CAAC;AAMpJ,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAiB,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAW9C,OAAO,KAAK,EAAkB,UAAU,EAAuB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA8Dl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