@ftrdotdev/pi-delegates 0.0.0-stage → 0.2.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/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/OPERATIONS.md +130 -0
- package/README.md +456 -2
- package/ROADMAP.md +179 -0
- package/TESTING.md +896 -0
- package/agents.ts +8 -0
- package/examples/README.md +114 -0
- package/examples/gated.ts +28 -0
- package/index.ts +9 -0
- package/package.json +94 -4
- package/skills/pi-delegates/SKILL.md +176 -0
- package/skills/pi-delegates/references/control.md +159 -0
- package/skills/pi-delegates/references/definitions.md +163 -0
- package/skills/pi-delegates/references/gates.md +175 -0
- package/skills/pi-delegates/references/launch.md +184 -0
- package/src/docs-contract.test.ts +106 -0
- package/src/domain/definitions.test.ts +41 -0
- package/src/domain/definitions.ts +163 -0
- package/src/domain/failure.ts +33 -0
- package/src/domain/ids.ts +13 -0
- package/src/domain/model-source.ts +30 -0
- package/src/domain/names.ts +35 -0
- package/src/domain/orchestration/admission.ts +78 -0
- package/src/domain/orchestration/control.test.ts +1332 -0
- package/src/domain/orchestration/control.ts +457 -0
- package/src/domain/orchestration/fanout.test.ts +524 -0
- package/src/domain/orchestration/fanout.ts +372 -0
- package/src/domain/orchestration/gates.test.ts +685 -0
- package/src/domain/orchestration/gates.ts +360 -0
- package/src/domain/orchestration/launch.test.ts +372 -0
- package/src/domain/orchestration/launch.ts +691 -0
- package/src/domain/orchestration/requests.test.ts +695 -0
- package/src/domain/orchestration/requests.ts +782 -0
- package/src/domain/orchestration/review.test.ts +292 -0
- package/src/domain/orchestration/review.ts +168 -0
- package/src/domain/orchestration/run-wait.test.ts +265 -0
- package/src/domain/orchestration/run-wait.ts +256 -0
- package/src/domain/orchestration/workflow-section.test.ts +62 -0
- package/src/domain/orchestration/workflow-section.ts +99 -0
- package/src/domain/orchestration/workflow.test.ts +1566 -0
- package/src/domain/orchestration/workflow.ts +778 -0
- package/src/domain/run-records.test.ts +27 -0
- package/src/domain/run-records.ts +689 -0
- package/src/domain/settlement.test.ts +186 -0
- package/src/domain/settlement.ts +137 -0
- package/src/domain/shapes.test.ts +185 -0
- package/src/domain/skills.test.ts +477 -0
- package/src/domain/skills.ts +114 -0
- package/src/domain/tool-schema.test.ts +46 -0
- package/src/domain/tool-schema.ts +20 -0
- package/src/domain/toolkit.test.ts +215 -0
- package/src/domain/toolkit.ts +374 -0
- package/src/domain/turn-budget.test.ts +37 -0
- package/src/domain/turn-budget.ts +23 -0
- package/src/domain/view.test.ts +803 -0
- package/src/domain/view.ts +491 -0
- package/src/example.test.ts +15 -0
- package/src/extension/commands.test.ts +485 -0
- package/src/extension/commands.ts +230 -0
- package/src/extension/entry.test.ts +1276 -0
- package/src/extension/entry.ts +380 -0
- package/src/extension/gate-alerts.test.ts +237 -0
- package/src/extension/gate-alerts.ts +143 -0
- package/src/extension/guard.test.ts +48 -0
- package/src/extension/guard.ts +31 -0
- package/src/extension/host-signals.test.ts +20 -0
- package/src/extension/host-signals.ts +13 -0
- package/src/extension/inspector-command.test.ts +1343 -0
- package/src/extension/inspector-command.ts +685 -0
- package/src/extension/prompt.test.ts +108 -0
- package/src/extension/prompt.ts +50 -0
- package/src/extension/request-alerts.test.ts +183 -0
- package/src/extension/request-alerts.ts +181 -0
- package/src/extension/retry-observer.test.ts +292 -0
- package/src/extension/retry-observer.ts +150 -0
- package/src/extension/revocation.test.ts +81 -0
- package/src/extension/revocation.ts +84 -0
- package/src/extension/settle-alerts.test.ts +579 -0
- package/src/extension/settle-alerts.ts +175 -0
- package/src/extension/shortcut.test.ts +62 -0
- package/src/extension/shortcut.ts +105 -0
- package/src/extension/tools.test.ts +1294 -0
- package/src/extension/tools.ts +553 -0
- package/src/extension/version.test.ts +115 -0
- package/src/extension/version.ts +97 -0
- package/src/goldens.test.ts +294 -0
- package/src/harness-policy.test.ts +76 -0
- package/src/layers.test.ts +309 -0
- package/src/layers.ts +405 -0
- package/src/package-manifest.test.ts +170 -0
- package/src/presentation/actions.test.ts +221 -0
- package/src/presentation/actions.ts +85 -0
- package/src/presentation/activity.test.ts +386 -0
- package/src/presentation/activity.ts +66 -0
- package/src/presentation/close.test.ts +359 -0
- package/src/presentation/inspector.test.ts +682 -0
- package/src/presentation/inspector.ts +442 -0
- package/src/presentation/overlay.test.ts +553 -0
- package/src/presentation/overlay.ts +229 -0
- package/src/presentation/repaint.test.ts +365 -0
- package/src/presentation/shortcut.ts +2 -0
- package/src/presentation/snapshot.test.ts +535 -0
- package/src/presentation/snapshot.ts +306 -0
- package/src/presentation/status.test.ts +43 -0
- package/src/presentation/status.ts +30 -0
- package/src/presentation/strip.test.ts +203 -0
- package/src/presentation/strip.ts +67 -0
- package/src/presentation/wording.test.ts +388 -0
- package/src/presentation/wording.ts +294 -0
- package/src/runtime/bridge.test.ts +131 -0
- package/src/runtime/bridge.ts +128 -0
- package/src/runtime/clock.test.ts +31 -0
- package/src/runtime/clock.ts +31 -0
- package/src/runtime/config.test.ts +63 -0
- package/src/runtime/config.ts +92 -0
- package/src/runtime/context.test.ts +19 -0
- package/src/runtime/context.ts +9 -0
- package/src/runtime/execution-env.test.ts +33 -0
- package/src/runtime/execution-env.ts +15 -0
- package/src/runtime/extensions.test.ts +86 -0
- package/src/runtime/extensions.ts +152 -0
- package/src/runtime/handle.ts +54 -0
- package/src/runtime/log.test.ts +140 -0
- package/src/runtime/log.ts +91 -0
- package/src/runtime/mcp.test.ts +1450 -0
- package/src/runtime/mcp.ts +1005 -0
- package/src/runtime/models.test.ts +145 -0
- package/src/runtime/models.ts +259 -0
- package/src/runtime/observe.test.ts +50 -0
- package/src/runtime/observe.ts +150 -0
- package/src/runtime/runtime-state.test.ts +25 -0
- package/src/runtime/runtime-state.ts +36 -0
- package/src/runtime/session-tag.ts +11 -0
- package/src/runtime/session.test.ts +352 -0
- package/src/runtime/session.ts +263 -0
- package/src/runtime/storage.ts +29 -0
- package/src/test-hygiene.test.ts +97 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @ftrdotdev/pi-delegates
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Run delegates asynchronously. A launch accepts `"execution": "detached"` and
|
|
8
|
+
returns the run id with its opening status at claim, so a turn can start more
|
|
9
|
+
work while the child runs. When the runs settle, one status notice names them,
|
|
10
|
+
the group and each child's parent; it starts no turn, while a gate or request
|
|
11
|
+
alert still does.
|
|
12
|
+
|
|
13
|
+
A run now carries a turn budget. `maxTurns` resolves from a fanout child, then
|
|
14
|
+
the request, then the agent definition, then `defaults.maxTurns` (120), and every
|
|
15
|
+
value is clamped to `caps.maxTurns` (400); `maxTurns: 0` still runs one round.
|
|
16
|
+
|
|
17
|
+
A failed run keeps its reason. `delegate_status` prints
|
|
18
|
+
`failed (turn_limit): 1 turn`, every failed run logs one `run.failed` line with
|
|
19
|
+
`reason`, `retryable`, `remedy` and `detail`, and each scheduled durable retry
|
|
20
|
+
logs one `run.retry` line. A scripted detached launch answers
|
|
21
|
+
`{ run, answer: "", status: "queued" }`, and a v1 or v2 store opens as v3.
|
|
22
|
+
|
|
23
|
+
- 4fb9f00: Show the inspector's state in Pi's footer. The line reads `delegates off ·
|
|
24
|
+
/delegates` while the inspector is off, `delegates idle · ctrl+space` while it is
|
|
25
|
+
on and quiet, and names the live counters while work is pending. It follows the
|
|
26
|
+
`/delegates` toggle, the restore at session start, and every publication; an
|
|
27
|
+
unchanged publication writes nothing, and a reload or shutdown clears the line
|
|
28
|
+
instead of leaving a stale one. A session that never enabled the inspector shows
|
|
29
|
+
no line at all.
|
|
30
|
+
|
|
31
|
+
The README screenshot is a Markdown image now, so npm renders it.
|
|
32
|
+
|
|
33
|
+
The inspector shortcut now refuses with the same hint `/delegates:overlay`
|
|
34
|
+
prints when the inspector is off. A silent key read as a broken one, while the
|
|
35
|
+
real answer is `/delegates`.
|
|
36
|
+
|
|
37
|
+
The `Delegates` box above the editor now stays mounted from activation to
|
|
38
|
+
teardown instead of appearing only while work runs. An idle box reads `idle —
|
|
39
|
+
ctrl+space`, so the first delegate launch no longer changes whether the box
|
|
40
|
+
exists, only what it says. Zero counters no longer print, in the box or in the
|
|
41
|
+
footer: both read the same formatter, so the two surfaces cannot drift.
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 0c040e3: Declare every host-provided peer with a `"*"` range, including
|
|
46
|
+
`@earendil-works/pi-coding-agent`, as the other packages and Pi's package guide
|
|
47
|
+
do. The exact `1.6.0` pin rejected a newer host for no runtime benefit: the load
|
|
48
|
+
check already compares the host's `@earendil-works/pi-ai` against the version
|
|
49
|
+
`pi-durable` pins, and Pi suppresses peer installation for managed packages. A
|
|
50
|
+
plain `npm install` still resolves the peer, but no longer to one fixed version.
|
|
51
|
+
- Updated dependencies [a7f50b9]
|
|
52
|
+
- @ftrdotdev/pi-tui@0.9.1
|
|
53
|
+
|
|
54
|
+
## 0.1.0
|
|
55
|
+
|
|
56
|
+
### Minor Changes
|
|
57
|
+
|
|
58
|
+
- b3c7f62: Turn the inspector on automatically after the first delegate launch in a TUI
|
|
59
|
+
session. An explicit `/delegates` off stays off for later launches. Reload,
|
|
60
|
+
resume and branch switch still restore an active inspector.
|
|
61
|
+
- 735b991: Add `@ftrdotdev/pi-delegates`, a durable agent-delegation extension on `@earendil-works/pi-durable` 1.6.0.
|
|
62
|
+
|
|
63
|
+
The Review 4 minors were re-derived by a conformance audit; it added three missing example tests.
|
|
64
|
+
|
|
65
|
+
Review 5 closed the documented launch call, the `/delegates` gate listing, the version guard, the
|
|
66
|
+
admission reservation, per-child gate settlement and fanout resume.
|
|
67
|
+
|
|
68
|
+
Add `codemode: "runs"` workflows: a `kind: "workflow"` launch runs the task script through durable's
|
|
69
|
+
`codemode` tool, and the script reaches eight `runs` tools over a `WorkflowService`. A scripted child
|
|
70
|
+
is owned by the workflow run task, inherits the workflow's lane, records `parentRunId`, and appears
|
|
71
|
+
nested under the workflow. A `launch_many` child records the same parent and parks its approval gates
|
|
72
|
+
under the workflow run. A script that steers a stopped child gets a refusal, not a thrown mistake.
|
|
73
|
+
A model or thinking-level switch updates the host the script's children use. A restart replays the
|
|
74
|
+
script from durable's journal and reattaches each nested call by key, so no child is duplicated, and
|
|
75
|
+
`delegate_control resume` refuses a workflow run. The `codemode` field is owner-only, and `codemode`
|
|
76
|
+
and `runs` are reserved extension names.
|
|
77
|
+
|
|
78
|
+
A run document is version 2: an older one fills a missing mode with `single` and a missing parent
|
|
79
|
+
with `null`, and keeps both when it already carries them. The session status prints the run mode
|
|
80
|
+
and omits `single`, and `tools.status` refuses an unknown run. A restart with a pending script gate
|
|
81
|
+
reuses the same gate document instead of refusing a duplicate. A failed open closes the session
|
|
82
|
+
sandbox. The lane cap binds `launch_many` groups only, and the script the model passes is trusted
|
|
83
|
+
rather than compared with the launch script.
|
|
84
|
+
|
|
85
|
+
Add MCP servers: the package reads `mcp.json` from the agent directory and, in a trusted project,
|
|
86
|
+
`.pi/mcp.json`, with the host's override rules. Only servers a registered definition references
|
|
87
|
+
connect. Each registers one `mcp:<server>` extension and one durable tool per visible server tool,
|
|
88
|
+
selected by exact name or a `mcp__<server>__*` pattern; `exposure` and `toolExposure` map to
|
|
89
|
+
`callers` and `deferred`, and a selected tool auto-selects `codemode` or `tool-search`. Stdio and
|
|
90
|
+
streamable HTTP transports expand `${NAME}` in `env` and `headers` and never run a command. A server
|
|
91
|
+
that fails to connect degrades with one diagnostic and one warning; calls race the server's
|
|
92
|
+
`timeout` and the run's cancellation, and a result over 20 KiB is cut with the full text saved
|
|
93
|
+
under the session directory.
|
|
94
|
+
|
|
95
|
+
Add questions from a delegate: a definition that selects `questions` in `extensions` and `ask` in
|
|
96
|
+
`tools` gets a tool that commits one request document and parks. `delegate_control answer` and
|
|
97
|
+
`decline` answer it, `/delegates:answer` does the same without the model, and `question` is optional
|
|
98
|
+
because the injected message degrades to plain text. A request also ends the parent's wait: one
|
|
99
|
+
attention racer over the gate index and the request index resolves on the commit, so a 600-second
|
|
100
|
+
block becomes a follow-up turn. A request expires after 24 hours, `stop` cancels it, and a decided
|
|
101
|
+
record is pruned 7 days after it was requested. The inspector, the overlay and `/delegates:list`
|
|
102
|
+
name it; the log keeps ids only.
|
|
103
|
+
|
|
104
|
+
- 416472d: Add a live inspector: `/delegates` toggles a bordered status strip pushed from durable document observations, and `ctrl+space` opens a floating overlay with a parent/child run tree, pending gates, stop/approve/deny, and an `enter`/`i` detail expansion. Waiting children route approve/deny to the run that owns their gate; new gates send one UI warning and one parent-agent message from a session-level watcher, even while the inspector is off. Announced gates are session entries, so a reload does not repeat them. Finished rows show `took <duration>`; expanded detail is indented under a rule.
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- 7b07d56: Name the inspector attach failure in the log.
|
|
109
|
+
|
|
110
|
+
`@ftrdotdev/pi-delegates`: `describeFailure` unwrapped only `InspectorReadFailed`, so an
|
|
111
|
+
`InspectorAttachFailed` produced an empty `detail` in the log. Both errors now
|
|
112
|
+
unwrap, and the log names the attach failure's message.
|
|
113
|
+
|
|
114
|
+
- a4befb4: Document the declarative definition and gate contract in the shipped skill and
|
|
115
|
+
source, and add a runnable gated fanout example.
|
|
116
|
+
- 5cc484c: Declare `@earendil-works/pi-ai` as a peer dependency with a `*` range, so the
|
|
117
|
+
extension loader hands the extension the host's copy instead of installing a
|
|
118
|
+
second one. The loader warns about the old dependency entry on every launch.
|
|
119
|
+
- f8094f4: Show the inspector overlay in the README, and point `homepage` at the package
|
|
120
|
+
README instead of the monorepo root.
|
|
121
|
+
- Updated dependencies [891568b]
|
|
122
|
+
- Updated dependencies [9b1fcd6]
|
|
123
|
+
- Updated dependencies [eeb018a]
|
|
124
|
+
- Updated dependencies [81c4a61]
|
|
125
|
+
- Updated dependencies [f8094f4]
|
|
126
|
+
- Updated dependencies [305cdb7]
|
|
127
|
+
- Updated dependencies [36e53c0]
|
|
128
|
+
- @ftrdotdev/pi-tui@0.9.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Felix Nordén
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/OPERATIONS.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Operating pi-delegates
|
|
2
|
+
|
|
3
|
+
This page holds runtime details for operators. For install, configuration and
|
|
4
|
+
agent definitions, see [README.md](./README.md).
|
|
5
|
+
|
|
6
|
+
## Failure log
|
|
7
|
+
|
|
8
|
+
The package writes `<sessionDir>/delegates.log`, one JSON object per line. It
|
|
9
|
+
records harness reports, config diagnostics, unverified version notes, swallowed
|
|
10
|
+
tool and command errors, a launch with no host model, a control refusal for a
|
|
11
|
+
stale toolkit name, every wait outcome other than `settled`, every scheduled
|
|
12
|
+
durable retry, every failed run and every settle notice.
|
|
13
|
+
|
|
14
|
+
Nothing rotates the file. A session writes short lines, so it stays small. A log
|
|
15
|
+
that reaches 5 MB is a roadmap item, not a current behaviour.
|
|
16
|
+
|
|
17
|
+
### Fields
|
|
18
|
+
|
|
19
|
+
Each entry has `ts`, `level`, `code` and primitive fields. `level` is `debug`,
|
|
20
|
+
`info`, `warn` or `error`.
|
|
21
|
+
|
|
22
|
+
`code` is stable and dot-namespaced. The prefixes are:
|
|
23
|
+
|
|
24
|
+
- `report.<kind>` for a harness report.
|
|
25
|
+
- `config.<problem>` for a configuration diagnostic.
|
|
26
|
+
- `wait.<outcome>` for a launch wait that did not settle.
|
|
27
|
+
- `request.<kind>` for a request that is announced or aborted (`request.pending`, `request.cancelled`).
|
|
28
|
+
- `requests.<kind>` for the start-up prune (`requests.pruned`, `requests.prune_failed`).
|
|
29
|
+
- `inspector.*` for inspector observations, actions and notifications.
|
|
30
|
+
- `version.unverified`
|
|
31
|
+
- `command.viewer_failed`
|
|
32
|
+
- `command.answer_failed`
|
|
33
|
+
- `tool.not_ready`
|
|
34
|
+
- `launch.host_model_missing`
|
|
35
|
+
- `control.missing_names`
|
|
36
|
+
- `run.retry`, `run.failed` and `run.settled` for a run's lifecycle.
|
|
37
|
+
- `settle.notify_failed`, `retry.observer_failed` and `settle.scan_truncated`
|
|
38
|
+
for the observers' own narrow failures.
|
|
39
|
+
|
|
40
|
+
### Run lifecycle codes
|
|
41
|
+
|
|
42
|
+
- `run.retry` — `warn`: one warning per scheduled retry attempt, so a retried
|
|
43
|
+
generation leaves as many lines as attempts were scheduled (durable's own
|
|
44
|
+
retry). Fields: `runId`, `attempt`, `at`, `detail`.
|
|
45
|
+
- `run.failed` — `error`: exactly one line per failed run. Fields: `runId`,
|
|
46
|
+
`reason`, the canonical 200-character `detail`, `retryable` (derived from the
|
|
47
|
+
observed retry count) and `remedy` (`relaunch`, `narrow` or `fix_config`). A
|
|
48
|
+
fanout or review group writes no second line: the failed child writes its own.
|
|
49
|
+
- `run.settled` — `info`: the headless settle notice, one line per coalesced
|
|
50
|
+
batch. Fields: `runs`, `detail`.
|
|
51
|
+
- `settle.notify_failed` — `warn`: a settle message the host refused
|
|
52
|
+
synchronously; the runs stay unannounced and the next window retries.
|
|
53
|
+
`pi.sendMessage` is fire-and-forget, so a later rejection is not visible here.
|
|
54
|
+
- `retry.observer_failed` — `warn`: the retry observer could not start; no retry
|
|
55
|
+
is counted in that session.
|
|
56
|
+
- `settle.scan_truncated` — `info`: the start scan looked at the newest 200 run
|
|
57
|
+
ids only, and `omitted` names how many it skipped.
|
|
58
|
+
|
|
59
|
+
`detail` holds the error message, at most 200 characters. It is for a person to
|
|
60
|
+
read. No code path parses it or classifies state from it. A failure detail keeps
|
|
61
|
+
both ends — 120 characters from the head, then `...`, then the tail — because a
|
|
62
|
+
provider error leads with the status that matters.
|
|
63
|
+
|
|
64
|
+
An entry never holds the request, the task text, an answer, a prompt or a
|
|
65
|
+
command.
|
|
66
|
+
|
|
67
|
+
### Guarantees
|
|
68
|
+
|
|
69
|
+
- A broken log path never fails a call. The write is dropped.
|
|
70
|
+
- A logger never throws.
|
|
71
|
+
- `detail` is display text, not machine-readable state.
|
|
72
|
+
|
|
73
|
+
## Session store
|
|
74
|
+
|
|
75
|
+
The session store is at `<sessionDir>/delegates-<sessionId>.sqlite`. The Pi
|
|
76
|
+
process that owns the session is the only writer. No shipped command opens the
|
|
77
|
+
store. [`openReadOnlyRuntime`](./src/runtime/session.ts) opens a store read-only
|
|
78
|
+
and runs no task.
|
|
79
|
+
|
|
80
|
+
There is no cross-process locking and no store takeover. The roadmap covers a
|
|
81
|
+
second writer, retention and migration between package versions.
|
|
82
|
+
|
|
83
|
+
## Composition
|
|
84
|
+
|
|
85
|
+
One session is one Effect layer graph, built in one scope by
|
|
86
|
+
[`src/layers.ts`](./src/layers.ts). The order is seams, then harness, then
|
|
87
|
+
bridge, then runtime. `makeSessionSeams` provides the seven environment-specific
|
|
88
|
+
services that `SessionSeams` ([`src/runtime/handle.ts`](./src/runtime/handle.ts))
|
|
89
|
+
lists: `StorageService`, `ClockService`, `TimersService`, `LogSinkService`,
|
|
90
|
+
`ModelSourceService`, `SkillsCatalogue` and `McpHostService`. A seam is a tag
|
|
91
|
+
whose binding is environment-specific.
|
|
92
|
+
[`docs/effect-conventions.md`](../../docs/effect-conventions.md) holds the layer
|
|
93
|
+
and naming rules. A doubled seam
|
|
94
|
+
(`SeamDoubles` in [`src/layers.ts`](./src/layers.ts)) replaces the production
|
|
95
|
+
default in place, so a test builds the same graph the entry does and every other
|
|
96
|
+
seam stays production. The harness opens the store and runs the tasks. The bridge
|
|
97
|
+
is the one path every harness call takes. The runtime is the session's public
|
|
98
|
+
value: the store, the harness, the bridge and the effects a call site reads.
|
|
99
|
+
|
|
100
|
+
`openSessionRuntime` owns the graph. It returns a `SessionHandle`
|
|
101
|
+
([`src/runtime/handle.ts`](./src/runtime/handle.ts)), which holds `runtime`,
|
|
102
|
+
`run` (one effect inside the graph's context) and `close`. The extension entry
|
|
103
|
+
keeps the current handle in a `Ref` and never holds the `ManagedRuntime`. `close`
|
|
104
|
+
is that runtime's `dispose`. `closeWithin`
|
|
105
|
+
([`src/extension/revocation.ts`](./src/extension/revocation.ts)) bounds the wait,
|
|
106
|
+
and `close` can be awaited twice.
|
|
107
|
+
|
|
108
|
+
The inspector does not join the graph. `openInspectorActivation`
|
|
109
|
+
([`src/layers.ts`](./src/layers.ts)) builds `Inspector.layer` fresh in its own
|
|
110
|
+
`Scope` through `handle.run`, so a keypress after a teardown gets a new instance
|
|
111
|
+
whose `finish` has not run. `teardownActivation`
|
|
112
|
+
([`src/extension/inspector-command.ts`](./src/extension/inspector-command.ts))
|
|
113
|
+
closes the overlay, unmounts the strip, runs the remaining sinks, interrupts the
|
|
114
|
+
subscription, then closes the activation's scope.
|
|
115
|
+
|
|
116
|
+
`src/layers.ts` is the only file that builds the session graph. It defines no
|
|
117
|
+
service construction of its own: each service defines its own layer as a static
|
|
118
|
+
member (`ClockService.layer(now)`, `McpHostService.layer(options)`,
|
|
119
|
+
`McpHostService.adopt(host)`). The file merges those layers with the
|
|
120
|
+
graph-internal `SessionCore`, the bridge and the runtime layer, and it is the only
|
|
121
|
+
production file that holds a `ManagedRuntime`. `test-support/platform.ts` holds
|
|
122
|
+
its own for the platform helpers.
|
|
123
|
+
|
|
124
|
+
A new seam costs seven edits under `src`, plus one in the test fixture. Add a
|
|
125
|
+
member to `SessionSeams` ([`src/runtime/handle.ts`](./src/runtime/handle.ts)), a
|
|
126
|
+
field to `SessionConfig` and one to `SeamDoubles`, a line to `makeSessionSeams`
|
|
127
|
+
(all three in [`src/layers.ts`](./src/layers.ts)), a field to `HarnessParts` and
|
|
128
|
+
one to `SessionRuntime`, and a line to `buildSessionRuntime` (all three in
|
|
129
|
+
[`src/runtime/session.ts`](./src/runtime/session.ts)). The fixture helper
|
|
130
|
+
`test-support/seams.ts` names the new field so a test can double it.
|