@plurnk/plurnk-service 1.6.1 → 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 (83) hide show
  1. package/SPEC.md +84 -21
  2. package/dist/build-info.json +1 -1
  3. package/dist/core/ClientInteractions.d.ts +19 -0
  4. package/dist/core/ClientInteractions.d.ts.map +1 -0
  5. package/dist/core/ClientInteractions.js +124 -0
  6. package/dist/core/ClientInteractions.js.map +1 -0
  7. package/dist/core/ClientInteractions.sql +34 -0
  8. package/dist/core/CoreSchemeServices.d.ts +8 -2
  9. package/dist/core/CoreSchemeServices.d.ts.map +1 -1
  10. package/dist/core/CoreSchemeServices.js +7 -1
  11. package/dist/core/CoreSchemeServices.js.map +1 -1
  12. package/dist/core/Dispatcher.d.ts +3 -1
  13. package/dist/core/Dispatcher.d.ts.map +1 -1
  14. package/dist/core/Dispatcher.js +41 -38
  15. package/dist/core/Dispatcher.js.map +1 -1
  16. package/dist/core/Engine.d.ts +15 -1
  17. package/dist/core/Engine.d.ts.map +1 -1
  18. package/dist/core/Engine.js +80 -17
  19. package/dist/core/Engine.js.map +1 -1
  20. package/dist/core/ExecutableTools.d.ts +1 -0
  21. package/dist/core/ExecutableTools.d.ts.map +1 -1
  22. package/dist/core/ExecutableTools.js +17 -9
  23. package/dist/core/ExecutableTools.js.map +1 -1
  24. package/dist/core/ExecutorRegistry.d.ts +11 -3
  25. package/dist/core/ExecutorRegistry.d.ts.map +1 -1
  26. package/dist/core/ExecutorRegistry.js +139 -16
  27. package/dist/core/ExecutorRegistry.js.map +1 -1
  28. package/dist/core/PacketBuilder.d.ts.map +1 -1
  29. package/dist/core/PacketBuilder.js +24 -12
  30. package/dist/core/PacketBuilder.js.map +1 -1
  31. package/dist/core/ProposalLifecycle.d.ts +3 -1
  32. package/dist/core/ProposalLifecycle.d.ts.map +1 -1
  33. package/dist/core/ProposalLifecycle.js +6 -3
  34. package/dist/core/ProposalLifecycle.js.map +1 -1
  35. package/dist/core/ResourceMutations.d.ts +2 -2
  36. package/dist/core/ResourceMutations.d.ts.map +1 -1
  37. package/dist/core/ResourceMutations.js +8 -8
  38. package/dist/core/ResourceMutations.js.map +1 -1
  39. package/dist/core/SchemeRegistry.d.ts +18 -10
  40. package/dist/core/SchemeRegistry.d.ts.map +1 -1
  41. package/dist/core/SchemeRegistry.js +194 -42
  42. package/dist/core/SchemeRegistry.js.map +1 -1
  43. package/dist/core/TurnRunner.d.ts +3 -1
  44. package/dist/core/TurnRunner.d.ts.map +1 -1
  45. package/dist/core/TurnRunner.js +8 -5
  46. package/dist/core/TurnRunner.js.map +1 -1
  47. package/dist/core/WorkspaceGate.d.ts +1 -0
  48. package/dist/core/WorkspaceGate.d.ts.map +1 -1
  49. package/dist/core/WorkspaceGate.js +39 -0
  50. package/dist/core/WorkspaceGate.js.map +1 -1
  51. package/dist/core/caps/CoreInteractionCaps.d.ts +9 -0
  52. package/dist/core/caps/CoreInteractionCaps.d.ts.map +1 -0
  53. package/dist/core/caps/CoreInteractionCaps.js +14 -0
  54. package/dist/core/caps/CoreInteractionCaps.js.map +1 -0
  55. package/dist/core/caps/SchemeCtxImpl.d.ts +2 -1
  56. package/dist/core/caps/SchemeCtxImpl.d.ts.map +1 -1
  57. package/dist/core/caps/SchemeCtxImpl.js +3 -0
  58. package/dist/core/caps/SchemeCtxImpl.js.map +1 -1
  59. package/dist/core/scheme-types.d.ts +2 -1
  60. package/dist/core/scheme-types.d.ts.map +1 -1
  61. package/dist/core/scheme-types.js.map +1 -1
  62. package/dist/schemes/Exec.d.ts.map +1 -1
  63. package/dist/schemes/Exec.js +27 -5
  64. package/dist/schemes/Exec.js.map +1 -1
  65. package/dist/server/Daemon.d.ts +13 -7
  66. package/dist/server/Daemon.d.ts.map +1 -1
  67. package/dist/server/Daemon.js +187 -21
  68. package/dist/server/Daemon.js.map +1 -1
  69. package/dist/server/DaemonModule.d.ts +31 -3
  70. package/dist/server/DaemonModule.d.ts.map +1 -1
  71. package/dist/server/client-input.d.ts +2 -0
  72. package/dist/server/client-input.d.ts.map +1 -1
  73. package/dist/server/client-input.js +12 -0
  74. package/dist/server/client-input.js.map +1 -1
  75. package/dist/server/lifecycle-recovery.sql +6 -0
  76. package/dist/server/loopDocs.d.ts +1 -0
  77. package/dist/server/loopDocs.d.ts.map +1 -1
  78. package/dist/server/loopDocs.js +37 -8
  79. package/dist/server/loopDocs.js.map +1 -1
  80. package/dist/server/loopDocs.sql +10 -0
  81. package/dist/server/workspace-capabilities.sql +19 -0
  82. package/migrations/001_schema.sql +31 -0
  83. package/package.json +34 -33
package/SPEC.md CHANGED
@@ -103,7 +103,7 @@ shown. The current streak may ride first-party provider metadata
103
103
  | §mode-ask-read-only **mode** | `"ask" \| "act"`. Per-loop. Ask = read-only: the dispatch gate refuses every side-effecting op (a filesystem write — EDIT/COPY-dest/MOVE/KILL on the `file` scheme — or any EXEC invocation); reads of the workspace stay open. `act` = full surface. Ask never changes the world. |
104
104
  | **flag** | Per-loop value: `mode`, `noWeb`, and `noInteraction` shape scheme authority ({§manifest-flag-affinity}); `auto` and `noProposals` select proposal settlement. |
105
105
  | **proposal** | A deferred side-effecting action. State machine: `proposed → resolved` (accept), `→ failed` (reject), or `→ cancelled` (cancel). Its core-owned disposition says whether the client or loop owns resolution ({§proposal-disposition}). |
106
- | **resolution** | Accept, reject, or cancel of a durable proposal. Client-owned authority enters core through `resolveProposal`; AG-UI carries it in standard resume entries ({§methods-proposal-resolve}, {§agui-proposal-resolve}). |
106
+ | **resolution** | A client decision delivered through a standard resume entry. Proposal resolutions accept, reject, or cancel ({§methods-proposal-resolve}); client-interaction resolutions return a payload or cancel ({§methods-client-interaction-resolve}, {§agui-proposal-resolve}). |
107
107
 
108
108
  ### §packet-terms Packet terms
109
109
 
@@ -669,7 +669,7 @@ boundary.
669
669
  - §worker-lifecycle-idle-is-concluded **An idle worker concludes; it does not park.** A loop is idle only when it has neither live obligations nor completed results awaiting their first packet. A live child or stream blocks a SEND signal `202` join; a completed stream, child result, or same-turn retrieval continues directly to the next packet where it is observed. Only after those sets are drained does signal `202` resolve like signal `200`. There is no held-open idle loop and no `loop/quiesced` soft signal. A concluded worker is durable working history and an addressed arrival reawakens it as a new loop.
670
670
  - §worker-lifecycle-no-lost-loop **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.
671
671
  - §worker-lifecycle-durable-disposition **Durable disposition wins cancellation races.** At a turn boundary, the engine reads the loop's durable status before interpreting a process-local abort. A committed `202` park survives a later daemon-shutdown signal; only a loop still durably running at `102` can be terminalized by that cancellation.
672
- - §worker-lifecycle-restart-recovery **Restart is owner-loss reconciliation, not replay.** Before opening client transports, the service holds an exclusive database-adjacent daemon lock; a second live owner fails before touching SQLite, while a dead-PID crash claim is replaced atomically without a timeout lease. Boot preserves accepted `100` loops and restores their drains. A `102` loop belonged to a vanished drain/provider call, so it settles `500` with the interruption on its durable row—never replayed across an unknown effect boundary. Every pending physical provider request beneath that loop first settles as an error with absent usage and explicitly unknown cost, then its logical model call closes; recovery never fabricates zero evidence. Every durable proposed operation likewise lost its process-local resolution waiter and settles as a visible `500 owner_vanished` occurrence rather than an unresolvable interrupt ({§proposal-list}). Every durable-open subscription belonged to a vanished callable: active channels become errored and its row closes `500`. A `202` continuation survives only while a live child obligation remains; after reconciliation, an unblocked park requeues `202→100` and resumes in place. Child terminalization wakes its parked parent on every outcome, including provider exceptions, cancellation, and restart interruption, recursively through the durable parent edges. These operations are idempotent, so an interrupted recovery safely repeats.
672
+ - §worker-lifecycle-restart-recovery **Restart is owner-loss reconciliation, not replay.** Before opening client transports, the service holds an exclusive database-adjacent daemon lock; a second live owner fails before touching SQLite, while a dead-PID crash claim is replaced atomically without a timeout lease. Boot preserves accepted `100` loops and restores their drains. A `102` loop belonged to a vanished drain/provider call, so it settles `500` with the interruption on its durable row—never replayed across an unknown effect boundary. Every pending physical provider request beneath that loop first settles as an error with absent usage and explicitly unknown cost, then its logical model call closes; recovery never fabricates zero evidence. Every durable proposed operation likewise lost its process-local resolution waiter and settles as a visible `500 owner_vanished` occurrence rather than an unresolvable interrupt ({§proposal-list}). A pending client interaction also lost its exact awaiting operation, so boot removes the orphan instead of replaying work or inventing a response ({§client-interactions}). Every durable-open subscription belonged to a vanished callable: active channels become errored and its row closes `500`. A `202` continuation survives only while a live child obligation remains; after reconciliation, an unblocked park requeues `202→100` and resumes in place. Child terminalization wakes its parked parent on every outcome, including provider exceptions, cancellation, and restart interruption, recursively through the durable parent edges. These operations are idempotent, so an interrupted recovery safely repeats.
673
673
 
674
674
  ---
675
675
 
@@ -1584,8 +1584,9 @@ the loop continue; repeated offenses terminate through the engine's 500.
1584
1584
  AST: `{ op: "EXEC", target (optional runtime-specific target), body: string | null (runtime-specific input), signal: string | null (runtime tag), lineMarker (timeout/poll) }`.
1585
1585
 
1586
1586
  §exec-target-routing Engine routes unconditionally to the `exec` scheme,
1587
- resolves the runtime first, and enforces that runtime's required
1588
- {§executor-invocation} declaration before effect admission. Core owns target
1587
+ resolves the runtime first, selects its static {§executor-invocation} or exact
1588
+ {§executor-tool-registry} entry, and enforces that declaration before effect
1589
+ admission. Core owns target
1589
1590
  realization; neither filesystem type nor body presence may invent a target role
1590
1591
  the selected runtime did not declare. With no declared directory override,
1591
1592
  `cwd` is the workspace's `project_root`, where the File scheme writes — never
@@ -1616,6 +1617,13 @@ its one declared role whether the body is empty or non-empty. Runtime selection,
1616
1617
  target validation, and body/target relation failures therefore occur before
1617
1618
  effect classification or proposal creation.
1618
1619
 
1620
+ A runtime with {§executor-tool-registry} admits only the snapshot's exact
1621
+ literal targets. An absent target is 400; a target outside that closed enabled
1622
+ set is 404; neither reaches effect classification or proposal creation. The
1623
+ selected entry's invocation—not the family's structural fallback—owns body
1624
+ requiredness and roles. The executor independently rejects an unregistered
1625
+ target at its run boundary.
1626
+
1619
1627
  §exec-source-temporary A non-file `resource` target is materialized into one
1620
1628
  core-owned temporary file after acceptance. Core reparses the complete authored
1621
1629
  address and resolves one exact `<1,-1>` READ through
@@ -1644,15 +1652,24 @@ unchanged for proposal policy, application, stream registration, and
1644
1652
  effect-qualified hold policy. The post-acceptance materialization path never
1645
1653
  triggers reclassification.
1646
1654
 
1647
- §exec-registry-resolves The runtime slot (`signal`) selects an executor,
1648
- resolved against the boot-time `ExecutorRegistry`: siblings are discovered and
1649
- probed at startup, and availability is cached. An absent or empty tag selects
1655
+ §exec-registry-resolves The runtime slot (`signal`) selects an executor from
1656
+ the current workspace snapshot. Installed siblings form the immutable base:
1657
+ they are discovered and probed at startup, and availability is cached.
1658
+ Workspace capability providers may atomically overlay additional names under
1659
+ {§module-workspace-capabilities}; a name has one owner within a workspace, while
1660
+ independent workspaces may use the same name. An absent or empty tag selects
1650
1661
  `sh`; a non-empty tag selects exactly that registered executable tool. Unknown
1651
1662
  tags are refused 501 with direction to use only the advertised catalogue or
1652
1663
  put a complete command in bare `EXEC`; they are never reinterpreted as shell
1653
1664
  command words. An unavailable runtime is also 501 and carries the probe
1654
1665
  `detail`.
1655
1666
 
1667
+ For a family runtime, `ExecutorRegistry.toolRegistry(tag, workspaceId)`
1668
+ validates the one executor-owned snapshot used by packet presentation,
1669
+ dispatch admission, and pull-document materialization. Core performs no
1670
+ protocol discovery while building a packet and has no alternate tool
1671
+ catalogue.
1672
+
1656
1673
  Per-tool programs such as `go`, `cargo`, `make`, and `npm` do not earn executor tags merely because they are executables; they are complete shell commands under `## EXEC0` or `## EXEC0 [sh]`. Registered tags exist only for tools that own a distinct body, target, or output contract. {§exec-registry-resolves}
1657
1674
 
1658
1675
  **Timeout and poll — `<T,P>` on the `<L>` slot (grammar 0.74.20).** EXEC
@@ -1770,6 +1787,23 @@ Core derives the contracts-owned `ProposalProjection` from the durable proposed
1770
1787
 
1771
1788
  Workspace scope remains the event envelope / seam argument ({§notifications-envelope-carries-workspaceid}); it is not forged into `ProposalProjection`. Malformed durable JSON, target metadata, result envelopes, loop policy, or final projection fails at core with its cause; after insertion, core terminalizes that row as a 500 `policy_failed` before propagating the internal failure, so no waiter or durable stopped world is orphaned.
1772
1789
 
1790
+ ### §client-interactions Client-owned interaction lifecycle
1791
+
1792
+ A scheme or executor may pause its current operation on one
1793
+ `ClientInteractionRequest` ({§client-interaction-wire}). Core first inserts a
1794
+ pending-only `client_interactions` row bound to one exact
1795
+ workspace/worker/loop/turn ownership chain, then publishes the same validated
1796
+ `ClientInteractionProjection` through `loop/interaction` and reconnect
1797
+ discovery. The projection contains no workspace id or private upstream
1798
+ continuation state; those remain respectively in the event envelope and the
1799
+ awaiting operation owner.
1800
+
1801
+ Only the live process-local waiter can make a durable row resolvable. Resolution
1802
+ validates one `ClientInteractionResolution`, deletes the pending row, then
1803
+ releases the owner exactly once. Owner abort deletes the row and rejects the
1804
+ waiter. Reconnect discovery intersects durable rows with live waiters; restart
1805
+ removes ownerless rows without fabricating cancellation, payload, or replay.
1806
+
1773
1807
  ### §proposal-disposition Settlement authority and precedence
1774
1808
 
1775
1809
  `ProposalDisposition` is either `{ owner: "client" }` or `{ owner: "loop", decision: "accept" | "reject", outcome? }`. The decision table is complete and ordered:
@@ -2121,10 +2155,11 @@ leak into another.
2121
2155
  {§executor-policy}. Keys are matched case-insensitively and must be
2122
2156
  `PLURNK_EXECS_ONLY` or `PLURNK_EXECS_<canonical-runtime-tag>`; MCP connection
2123
2157
  configuration and non-string values are rejected. The boot-discovered
2124
- registry is authoritative and the workspace layer only intersects it: it
2125
- cannot register or re-enable a runtime. A canonical key for a currently
2126
- absent tag is accepted as inert policy and applies if that tag later belongs
2127
- to the boot set. Dispatch, the model-facing capability sheet, and executor
2158
+ effective workspace registry is authoritative and the settings layer only
2159
+ intersects it: settings cannot register or re-enable a runtime. A canonical
2160
+ key for a currently absent tag is accepted as inert policy and applies if a
2161
+ workspace capability provider later publishes that tag. Dispatch, the
2162
+ model-facing capability sheet, and executor
2128
2163
  document materialization use the same registered-set intersection and policy
2129
2164
  predicate, so a workspace-disabled tag is neither executable nor taught.
2130
2165
 
@@ -2148,7 +2183,7 @@ names, request validation, discovery result, and event projection.
2148
2183
  ```mermaid
2149
2184
  flowchart LR
2150
2185
  register["Daemon.registerModule"] --> setup["module.setup(ModuleSetupSeam)"]
2151
- setup --> capabilities["Register runtimes, schemes,<br/>and extension actions"]
2186
+ setup --> capabilities["Register static capabilities,<br/>workspace providers, and actions"]
2152
2187
  capabilities --> ready["Schemes ready; docs published;<br/>durable lifecycle recovered"]
2153
2188
  ready --> start["module.start(CoreSeam)"]
2154
2189
  start --> interface["Module-owned listener<br/>and client protocol"]
@@ -2180,11 +2215,28 @@ flowchart LR
2180
2215
  wakes --> database[Release database]
2181
2216
  ```
2182
2217
 
2183
- | Setup function | Contract |
2184
- |------------------------------------------------------------------------|----------|
2185
- | `registerRuntime({ decl, executor, availability, scheme? })` | Admits one canonical tag under {§executor-runtime-declaration}, then adds its executor and optional claimed scheme facet atomically. |
2186
- | `registerScheme(name, handler)` | Adds one addressable scheme handler; scheme readiness and model-facing capability publication remain core-owned. |
2187
- | §module-action-registration `registerModuleAction(name, handler)` | Adds a non-empty, extension-unique name and a handler receiving only `Readonly<Record<string, unknown>>`. Core supplies no implicit workspace or transport context. A client-interface module decides whether and how that name becomes public, and owns collisions with its built-ins. |
2218
+ | Setup function | Contract |
2219
+ |---|---|
2220
+ | `registerRuntimes([{ decl, executor, availability, scheme? }, ...])` | Validates the complete canonical tag set under {§executor-runtime-declaration}, then publishes every process-wide executor and optional claimed scheme facet atomically. |
2221
+ | `registerScheme(name, handler)` | Adds one process-wide addressable scheme handler; scheme readiness and model-facing capability publication remain core-owned. |
2222
+ | §module-action-registration `registerModuleAction({ name, scope, handler })` | Adds one non-empty, extension-unique action. `scope` is exactly `worldless` or `workspace`; the handler receives validated params and a separate matching context. A workspace context contains the trusted bound `workspaceId`, never a client parameter. A client-interface module decides whether and how the name becomes public and owns collisions with its built-ins. |
2223
+ | §module-workspace-provider `registerWorkspaceCapabilityProvider(namespaceOwner, provider)` | Registers one extension-unique provider whose `hydrate(workspaceId)` reconstructs its effective snapshot. Core invokes every provider for existing workspaces before capability publication and for a new workspace before that workspace is returned or advertised. |
2224
+ | §module-workspace-state `readWorkspaceModuleState(workspaceId, namespaceOwner)` | Reads the provider's one nullable JSON state value. Core owns workspace isolation and storage; the provider owns and validates its schema. Secret values are forbidden when a durable symbolic reference can identify their authoritative source. |
2225
+ | §module-workspace-capabilities `replaceWorkspaceCapabilities({ workspaceId, namespaceOwner, state, runtimes })` | Replaces one provider's complete durable state and runtime/scheme snapshot at a quiescent workspace boundary. Core validates base/peer namespace claims before mutation, blocks new turns, commits the snapshot, and reconciles pull docs as one operation. Failure restores the prior state and presentation. The empty runtime set removes that provider's workspace namespace. |
2226
+
2227
+ §module-workspace-quiescence **A capability snapshot changes only between
2228
+ workspace operations.** A replacement attempt while a turn or another
2229
+ capability mutation owns the workspace fails 409 instead of waiting behind an
2230
+ unbounded proposal. Candidate discovery may occur before the gate, but the
2231
+ provider must re-check its old connection for active user work after acquiring
2232
+ the gate. Infrastructure-owned watches may be cancelled during replacement;
2233
+ an active request, input exchange, or Task keeps the old snapshot authoritative
2234
+ and makes replacement fail 409.
2235
+
2236
+ The version-1 baseline table `workspace_module_state` stores one JSON value per
2237
+ `(workspace_id, namespace_owner)`. It is not an alternate registry: executable
2238
+ and resource presentation always comes from the in-memory snapshot reconstructed
2239
+ by the registered provider. Deleting a workspace cascades its module state.
2188
2240
 
2189
2241
  ### §methods CoreSeam function set
2190
2242
 
@@ -2197,6 +2249,8 @@ Its function names are transport-neutral library calls, not public wire names.
2197
2249
  | §methods-event-subscribe Events | `subscribeToEvents(handler) -> unsubscribe` | Subscribes to the raw event source in {§notifications}. A subscriber failure is logged and cannot re-enter engine control flow. |
2198
2250
  | §proposal-list Proposals | `pendingProposals(workspaceId)` | Intersects durable proposed rows with the lifecycle owner's live resolution waiters, then returns their validated {§proposal-projection}; persistence alone cannot advertise an unresolvable client interrupt. |
2199
2251
  | §methods-proposal-resolve Proposals | `resolveProposal(logEntryId, resolution)` | Validates and delivers one accept, reject, or cancel decision to the engine. An unknown or already-resolved id fails; the client protocol owns how the decision arrived. |
2252
+ | §client-interaction-list Client interactions | `pendingClientInteractions(workspaceId)` | Intersects durable interaction rows with their live operation waiters and returns the contracts-owned projection; a row alone is not a resumable interaction. |
2253
+ | §methods-client-interaction-resolve Client interactions | `resolveClientInteraction(interactionId, resolution)` | Validates and delivers one resolved payload or cancellation. Unknown, ownerless, and already-resolved identities fail before affecting an operation. |
2200
2254
  | §methods-loop-run Loops | `runLoop({ workspaceId, workerId, prompt, maxTurns?, flags?, openPaths?, alias?, model?, childAlias?, childModel? })` | Validates a model worker and provider policy, persists it with the effective turn ceiling, then returns an immediate status-100 acknowledgement with `loopId` and `action`. The exact terminal result arrives only through `loop/terminated`; parking and resuming do not replace the loop. |
2201
2255
  | §methods-loop-cancel Loops | `cancelDrain(workerId, reason?)` | Begins durable structured cancellation of the worker tree and reaps its process-local scopes. The boolean reports whether process-local work existed when called; queued or parked durable work is still terminalized when it is `false`. |
2202
2256
  | §methods-op-mirror Client dispatch | `dispatchClientAction({ workspaceId, workerId, statements })` | Dispatches already-parsed grammar statements as one client action and one journal segment. Every statement is an ordered turn, and every committed `log/entry` is emitted before the action promise resolves; a proposal may keep that promise and segment open until resolution. Core exposes no per-op method family. |
@@ -2214,7 +2268,7 @@ Its function names are transport-neutral library calls, not public wire names.
2214
2268
  | Workspace metadata | `constrain(...)`, `unconstrain(...)`, `listConstraints(...)`, `listMembers(...)` | Owns the membership overlay and returns its resolved effects; clients do not reimplement constraint semantics. |
2215
2269
  | §methods-workspace-prompts Workspace metadata | `listPrompts(workspaceId, limit?)` | Returns nonempty loop-seed prompts from the workspace's model-origin root conversations, newest-first. The positive limit defaults to 100; spawned and forked child prompts are excluded. |
2216
2270
  | Workspace metadata | `listWorkspaces()`, `listWorkers(...)`, `workspaceDerivationStatus(...)` | Reads current workspace topology and derivation progress. |
2217
- | Extension actions | `listModuleActions()`, `invokeModuleAction(name, params)` | Lists setup-registered names in sorted order and invokes the exact registered handler. Missing names fail; handler values remain opaque to core. |
2271
+ | Extension actions | `listModuleActions()`, `invokeModuleAction(name, params, context)` | Lists setup-registered `{ name, scope }` descriptors in sorted order. Invocation requires a context matching the registered scope; missing names, forged scope, and missing workspace identity fail before the owner runs. Handler values remain opaque to core. |
2218
2272
 
2219
2273
  §methods-loop-run-fold-consistency **A folded prompt cannot silently reconfigure
2220
2274
  its loop.** When `runLoop` targets an active or 202-parked loop, core appends the
@@ -2305,6 +2359,7 @@ active lifecycle behind. LOOK text anchors resolve through the same
2305
2359
  | §notifications-log-entry-notify `log/entry` | `{ entry: LogEntry }` | A `log_entries` row is committed. |
2306
2360
  | §notifications-loop-terminated `loop/terminated` | `{ workerId, loopId, result, hitMaxTurns, turnIds, usage: { accounting, curationWeight, curationBudget, contextTokens, contextCapacity, meta }, attributions }` | One loop reaches a terminal state. `result` is the exact universal operation result, including its RFC 9457 Problem Details on failure. `accounting` is the loop's contracts-owned {§provider-accounting}; the two curation facts and two physical-context facts follow {§tokenomics-client-gauge}; `meta` is that turn's opaque provider bag. `attributions` is the sorted union of exact provider-request evidence ({§attribution}), separate from accounting. Worker and loop are an inseparable owning coordinate. |
2307
2361
  | §notifications-loop-proposal `loop/proposal` | contracts-owned `ProposalProjection` | Dispatch pauses on a durable 202 proposal. `disposition` is the sole authority for whether a client presents review UI; live and reconnect share {§proposal-projection}. |
2362
+ | §notifications-loop-interaction `loop/interaction` | contracts-owned `ClientInteractionProjection` | An operation is paused on client input. Live delivery and reconnect discovery share {§client-interactions}; workspace scope remains the event envelope. |
2308
2363
  | §notifications-workspace-created `workspace/created` | `{ id, name, projectRoot }` | A workspace is created. This is the only current global event. |
2309
2364
  | §notifications-workspace-branch-batch `workspace/branch-batch` | Branch-batch lifecycle payload | A branch batch enters queued, running, completed, failed, or recovery-required state. |
2310
2365
  | §notifications-stream-event-on-channel-change `stream/event` | `{ entryId, workerId, target, channel, state, contentLength, mimetype?, loop_seq?, turn_seq?, sequence? }` | Channel content grows or channel state transitions. `workerId` is the entry owner and read perspective; `target` is its canonical URI. The optional coordinate is copied from schemes whose addresses carry one. Core-managed channel writes include the current stored `mimetype`, which may change per call ({§channel-mimetype}); the generic plugin notification capability does not require it. It carries metadata, not content; consumers read bytes from the stated worker perspective. |
@@ -3031,7 +3086,7 @@ turn.** It cannot execute operations or alter the audited history.
3031
3086
 
3032
3087
  ### §tools user.tools — the capability sheet
3033
3088
 
3034
- §tools-capability-sheet The tools capability sheet renders under `## Registered Tools`, after the policy sections. One generated Markdown table is the closed set of valid executor selectors and states each runtime declaration's model-facing `(target)` role, body role, and exact canonical example. The compact legend leaves required inputs unmarked, marks optional inputs with `?`, pairs mutually exclusive alternatives with `↔`, marks refused buckets with `—`, and locates optional `<timeout,poll>` on the heading. The preface prefers purpose-built Plurnk operations over EXEC scripts. For a declaration with `target.directory: "cwd"`, the target cell distinguishes a local-directory working context from the plugin-authored non-directory target role. Optional non-EXEC operations render separately under `## Enabled Optional Operations` in a `plurnk` fence, so the catalogue remains truthful. `PacketBuilder.#collectTools` assembles both; a prose notice (e.g. the EXEC-disabled line) stays beside the table, and empty sections are omitted.
3089
+ §tools-capability-sheet The tools capability sheet renders under `## Registered Tools`, after the policy sections. One generated Markdown table is the closed set of valid executor selectors. Its columns state `[executor]`, the `(target)` role and any concrete target witness, the body role, and `Invocation`: a body example, a schema-derived signature, or `bodyless`. The Invocation cell never repeats the `## EXEC0 [executor] (target)` syntax already defined by the headers and columns. A runtime exposing {§executor-tool-registry} contributes exactly one row per enabled exact target instead of its general row; an empty exact registry contributes no row and has no fallback. The compact legend leaves required inputs unmarked, marks optional inputs with `?`, pairs mutually exclusive alternatives with `↔`, marks refused buckets with `—`, and locates optional `<timeout,poll>` on the heading. The preface prefers purpose-built Plurnk operations over EXEC scripts. For a declaration with `target.directory: "cwd"`, the target cell distinguishes a local-directory working context from the plugin-authored non-directory target role. Optional non-EXEC operations render separately under `## Enabled Optional Operations` in a `plurnk` fence, so the catalogue remains truthful. `PacketBuilder.#collectTools` assembles both; a prose notice (e.g. the EXEC-disabled line) stays beside the table, and empty sections are omitted.
3035
3090
 
3036
3091
  §tools-loop-affinity **The capability sheet describes the current loop.** The
3037
3092
  sheet filters registered capabilities through the same
@@ -3040,7 +3095,15 @@ registered executors exist but EXEC is inactive, their table is replaced by
3040
3095
  an explicit disabled notice rather than silent absence. The dispatch 403 remains
3041
3096
  the backstop and names the non-retryable loop restriction.
3042
3097
 
3043
- **Contributors: the wired executor tags.** Every available executor tag contributes exactly one row derived from its required {§executor-invocation} declaration. Its doc is materialized at `worker://plurnk/docs/<tag>.md` and discovered via the turn-0 `## FIND0 [+init,+docs] (worker://plurnk/docs/**)` foist, not linked inline. `PLURNK_SERVICE_DOCS_EXCLUDE` drops a named tag's row and doc. The boot `ExecutorRegistry` probes availability per tag, so the table advertises runnable selectors instead of presuming a particular runtime exists.
3098
+ **Contributors: the workspace executor snapshot.** Every available executor tag
3099
+ contributes its general {§executor-invocation} row or the closed rows and
3100
+ documentation from its {§executor-tool-registry} snapshot. Its doc is
3101
+ materialized at `worker://plurnk/docs/<tag>.md` and discovered via the turn-0
3102
+ `## FIND0 [+init,+docs] (worker://plurnk/docs/**)` foist, not linked inline.
3103
+ `PLURNK_SERVICE_DOCS_EXCLUDE` drops a named tag's rows and doc. Installed
3104
+ executors are probed once; workspace providers publish only prepared runnable
3105
+ selectors, so the table never presumes that another workspace's capability is
3106
+ available here.
3044
3107
 
3045
3108
  ### §schemes user.schemes — the resource directory
3046
3109
 
@@ -3061,7 +3124,7 @@ surfaces with its cause and leaves no apparently initialized home.
3061
3124
  After that bootstrap the file is user-owned: edits and deletion persist, and a
3062
3125
  later boot never refreshes or recreates it.
3063
3126
 
3064
- §schemes-self-doc-materialization **The scheme self-doc contract.** `@plurnk/plurnk-schemes` owns `example` and `documentation` in `SchemeManifest` ({§manifest-self-doc}); the former is the hot-path operation example set and the latter is the deep pull doc. `SchemeRegistry.teach()` renders the directory, `SchemeRegistry.docs()` resolves corpus-or-manifest documentation, and `docEntries()` materializes the result when core publishes capabilities for a workspace.
3127
+ §schemes-self-doc-materialization **The scheme self-doc contract.** `@plurnk/plurnk-schemes` owns `example` and `documentation` in `SchemeManifest` ({§manifest-self-doc}); the former is the hot-path operation example set and the latter is the deep pull doc. `SchemeRegistry.teach(workspaceId)` renders the effective directory, `SchemeRegistry.docs(workspaceId)` resolves corpus-or-manifest documentation, and `docEntries(workspaceId)` supplies the current pull-document set when core publishes capabilities for a workspace. Materialization reconciles `worker://plurnk/docs/` exactly under the workspace capability gate: vanished contributions are deleted before current documents are upserted, so an excluded, disabled, detached, or replaced capability cannot leave a stale model-facing contract.
3065
3128
 
3066
3129
  ### §packet-git-status The Git status section — compact repository state
3067
3130
 
@@ -1 +1 @@
1
- {"package":"@plurnk/plurnk-service","version":"1.6.1","revision":"5ae0f70cbbf35cadf4bb2a9777d713e5d726afe9","dirty":false}
1
+ {"package":"@plurnk/plurnk-service","version":"1.7.0","revision":"b77596d160fcca8ef1ca6cce3b68d2b3e4c2494e","dirty":false}
@@ -0,0 +1,19 @@
1
+ import { type ClientInteractionProjection, type ClientInteractionRequest, type ClientInteractionResolution } from "@plurnk/plurnk-contracts";
2
+ import type { Db } from "./Db.ts";
3
+ export interface ClientInteractionPendingEvent extends ClientInteractionProjection {
4
+ readonly workspaceId: number;
5
+ }
6
+ export default class ClientInteractions {
7
+ #private;
8
+ constructor(db: Db);
9
+ onPending(listener: (event: ClientInteractionPendingEvent) => void): void;
10
+ request(request: ClientInteractionRequest, ids: {
11
+ workspaceId: number;
12
+ workerId: number;
13
+ loopId: number;
14
+ turnId: number;
15
+ }, signal?: AbortSignal): Promise<ClientInteractionResolution>;
16
+ resolve(interactionId: number, resolution: ClientInteractionResolution): Promise<void>;
17
+ list(workspaceId: number): Promise<ClientInteractionProjection[]>;
18
+ }
19
+ //# sourceMappingURL=ClientInteractions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientInteractions.d.ts","sourceRoot":"","sources":["../../src/core/ClientInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EACnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAGlC,MAAM,WAAW,6BAA8B,SAAQ,2BAA2B;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAChC;AAmCD,MAAM,CAAC,OAAO,OAAO,kBAAkB;;IAKnC,YAAY,EAAE,EAAE,EAAE,EAEjB;IAED,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,6BAA6B,KAAK,IAAI,GAAG,IAAI,CAExE;IAEK,OAAO,CACT,OAAO,EAAE,wBAAwB,EACjC,GAAG,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAC9E,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,2BAA2B,CAAC,CAqEtC;IAEK,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAM3F;IAEK,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAKtE;CAiBJ"}
@@ -0,0 +1,124 @@
1
+ import { Validator, } from "@plurnk/plurnk-contracts";
2
+ import Results, { OperationFailureError } from "./results.js";
3
+ const pendingFailure = (interactionId) => new OperationFailureError(Results.failure("interaction:resolution", "interaction-not-pending", 409, `Client interaction ${interactionId} is not pending.`, {}, {
4
+ interactionId,
5
+ stage: "interaction-resolution",
6
+ recovery: "Refresh pending interactions before resolving one.",
7
+ retryable: false,
8
+ }));
9
+ export default class ClientInteractions {
10
+ #db;
11
+ #pending = new Map();
12
+ #listeners = [];
13
+ constructor(db) {
14
+ this.#db = db;
15
+ }
16
+ onPending(listener) {
17
+ this.#listeners.push(listener);
18
+ }
19
+ async request(request, ids, signal) {
20
+ const exact = structuredClone(Validator.assertClientInteractionRequest(request));
21
+ signal?.throwIfAborted();
22
+ const inserted = await this.#db.client_interaction_insert.get({
23
+ workspace_id: ids.workspaceId,
24
+ worker_id: ids.workerId,
25
+ loop_id: ids.loopId,
26
+ turn_id: ids.turnId,
27
+ request: JSON.stringify(exact),
28
+ });
29
+ if (inserted === undefined) {
30
+ throw new Error(`Client interaction coordinates do not identify one operation: worker ${ids.workerId}, loop ${ids.loopId}, turn ${ids.turnId}.`);
31
+ }
32
+ const deferred = Promise.withResolvers();
33
+ const interactionId = inserted.id;
34
+ let settled = false;
35
+ const onAbort = () => {
36
+ void waiter.settle({
37
+ rejection: signal?.reason ?? new DOMException("Operation aborted", "AbortError"),
38
+ });
39
+ };
40
+ const waiter = {
41
+ settle: async (settlement) => {
42
+ if (settled)
43
+ return pendingFailure(interactionId);
44
+ settled = true;
45
+ this.#pending.delete(interactionId);
46
+ signal?.removeEventListener("abort", onAbort);
47
+ try {
48
+ const deleted = await this.#db.client_interaction_delete.get({
49
+ interaction_id: interactionId,
50
+ });
51
+ if (deleted === undefined) {
52
+ throw new Error(`Pending client interaction ${interactionId} lost its durable row.`);
53
+ }
54
+ }
55
+ catch (cause) {
56
+ deferred.reject(cause);
57
+ return cause;
58
+ }
59
+ if (settlement.rejection !== undefined)
60
+ deferred.reject(settlement.rejection);
61
+ else if (settlement.resolution !== undefined)
62
+ deferred.resolve(settlement.resolution);
63
+ else
64
+ deferred.reject(new Error(`Client interaction ${interactionId} settled without an outcome.`));
65
+ return null;
66
+ },
67
+ };
68
+ this.#pending.set(interactionId, waiter);
69
+ signal?.addEventListener("abort", onAbort, { once: true });
70
+ const event = {
71
+ ...Validator.assertClientInteractionProjection({
72
+ interactionId,
73
+ workerId: ids.workerId,
74
+ loopId: ids.loopId,
75
+ turnId: ids.turnId,
76
+ request: exact,
77
+ }),
78
+ workspaceId: ids.workspaceId,
79
+ };
80
+ for (const listener of this.#listeners) {
81
+ try {
82
+ listener(event);
83
+ }
84
+ catch (cause) {
85
+ console.error("client interaction pending observer failed:", cause);
86
+ }
87
+ }
88
+ if (signal?.aborted)
89
+ onAbort();
90
+ return deferred.promise;
91
+ }
92
+ async resolve(interactionId, resolution) {
93
+ const waiter = this.#pending.get(interactionId);
94
+ if (waiter === undefined)
95
+ throw pendingFailure(interactionId);
96
+ const exact = structuredClone(Validator.assertClientInteractionResolution(resolution));
97
+ const failure = await waiter.settle({ resolution: exact });
98
+ if (failure !== null)
99
+ throw failure;
100
+ }
101
+ async list(workspaceId) {
102
+ const rows = await this.#db.client_interaction_list.all({ workspace_id: workspaceId });
103
+ return rows
104
+ .filter((row) => this.#pending.has(row.interactionId))
105
+ .map((row) => ClientInteractions.#project(row));
106
+ }
107
+ static #project(row) {
108
+ let request;
109
+ try {
110
+ request = JSON.parse(row.request);
111
+ }
112
+ catch (cause) {
113
+ throw new Error(`Pending client interaction ${row.interactionId} has invalid request JSON.`, { cause });
114
+ }
115
+ return Validator.assertClientInteractionProjection({
116
+ interactionId: row.interactionId,
117
+ workerId: row.workerId,
118
+ loopId: row.loopId,
119
+ turnId: row.turnId,
120
+ request: Validator.assertClientInteractionRequest(request),
121
+ });
122
+ }
123
+ }
124
+ //# sourceMappingURL=ClientInteractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientInteractions.js","sourceRoot":"","sources":["../../src/core/ClientInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,GAIZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,OAAO,EAAE,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAwB9D,MAAM,cAAc,GAAG,CAAC,aAAqB,EAAyB,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ert only when all supplied coordinates describe one existing operation.
5
+ INSERT INTO client_interactions (worker_id, loop_id, turn_id, request)
6
+ SELECT $worker_id, $loop_id, $turn_id, $request
7
+ WHERE EXISTS (
8
+ SELECT 1
9
+ FROM turns t
10
+ JOIN loops l ON l.id = t.loop_id
11
+ JOIN workers w ON w.id = l.worker_id
12
+ WHERE t.id = $turn_id
13
+ AND l.id = $loop_id
14
+ AND l.worker_id = $worker_id
15
+ AND w.workspace_id = $workspace_id
16
+ )
17
+ RETURNING id;
18
+
19
+ -- PREP: client_interaction_list
20
+ SELECT i.id AS interactionId,
21
+ w.workspace_id AS workspaceId,
22
+ i.worker_id AS workerId,
23
+ i.loop_id AS loopId,
24
+ i.turn_id AS turnId,
25
+ i.request
26
+ FROM client_interactions i
27
+ JOIN workers w ON w.id = i.worker_id
28
+ WHERE w.workspace_id = $workspace_id
29
+ ORDER BY i.id;
30
+
31
+ -- PREP: client_interaction_delete
32
+ DELETE FROM client_interactions
33
+ WHERE id = $interaction_id
34
+ RETURNING id;
@@ -2,7 +2,7 @@ import type { Db } from "./Db.ts";
2
2
  import type { Mimetypes } from "@plurnk/plurnk-mimetypes";
3
3
  import type ExecutorRegistry from "./ExecutorRegistry.ts";
4
4
  import type { InjectWorkerNotify, StreamEventNotify, WakeWorkerNotify } from "./ChannelWrite.ts";
5
- import type { Notice, ParsedPath, ReadStatement } from "@plurnk/plurnk-contracts";
5
+ import type { ClientInteractionRequest, ClientInteractionResolution, Notice, ParsedPath, ReadStatement } from "@plurnk/plurnk-contracts";
6
6
  import type { PlurnkSchemeContext } from "./scheme-types.ts";
7
7
  import type { SchemeCtx, SchemeResult, StoredEntryData } from "@plurnk/plurnk-schemes";
8
8
  import type LiveSubscriptions from "./LiveSubscriptions.ts";
@@ -15,8 +15,14 @@ export interface CoreSchemeServices {
15
15
  readonly wakeWorkerNotify: WakeWorkerNotify | undefined;
16
16
  readonly injectWorker: InjectWorkerNotify | undefined;
17
17
  readonly pushNotice: (workspaceId: number, loopId: number, notice: Notice) => void;
18
- readonly defaultChannelFor: (scheme: string) => string;
18
+ readonly defaultChannelFor: (scheme: string, workspaceId: number) => string;
19
19
  readonly readExecSource: (statement: ReadStatement, ctx: PlurnkSchemeContext) => Promise<SchemeResult>;
20
+ readonly requestInteraction: (request: ClientInteractionRequest, ids: {
21
+ workspaceId: number;
22
+ workerId: number;
23
+ loopId: number;
24
+ turnId: number;
25
+ }, signal?: AbortSignal) => Promise<ClientInteractionResolution>;
20
26
  readonly liveSubscriptions: LiveSubscriptions;
21
27
  }
22
28
  export interface CoreSchemeAdapter {
@@ -1 +1 @@
1
- {"version":3,"file":"CoreSchemeServices.d.ts","sourceRoot":"","sources":["../../src/core/CoreSchemeServices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,gBAAgB,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;I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C;AAMD,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,mBAAmB,CAAC;AAEpE,8BAAsB,qBAAsB,YAAW,iBAAiB;;IAGpE,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAE3C;IAED,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,qBAAqB,GAAG,mBAAmB,CA2BrE;IAED,SAAS,CAAC,iBAAiB,IAAI,iBAAiB,CAI/C;IAED,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAIpG;CACJ"}
@@ -23,8 +23,14 @@ export class CoreSchemeAdapterBase {
23
23
  mimetypes: services.mimetypes,
24
24
  executors: services.executors(),
25
25
  weigh: services.weigh,
26
- defaultChannelFor: services.defaultChannelFor,
26
+ defaultChannelFor: (scheme) => services.defaultChannelFor(scheme, ctx.workspaceId),
27
27
  pushNotice: (notice) => services.pushNotice(ctx.workspaceId, ctx.loopId, notice),
28
+ requestInteraction: (request) => services.requestInteraction(request, {
29
+ workspaceId: ctx.workspaceId,
30
+ workerId: ctx.workerId,
31
+ loopId: ctx.loopId,
32
+ turnId: ctx.turnId,
33
+ }, ctx.signal),
28
34
  };
29
35
  }
30
36
  liveSubscriptions() {
@@ -1 +1 @@
1
- {"version":3,"file":"CoreSchemeServices.js","sourceRoot":"","sources":["../../src/core/CoreSchemeServices.ts"],"names":[],"mappings":"AAsDA,MAAM,OAAgB,qBAAqB;IACvC,SAAS,CAAiC;IAE1C,QAAQ,CAAC,QAA4B;QACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAES,WAAW,CAAC,GAA0B;QAC5C,IAAI,IAAI,IAAI,GAAG;YAAE,OAAO,GAAG,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAA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AAQ,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;YAChF,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,EAAE;gBAClE,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,MAAM,EAAE,GAAG,CAAC,MAAM;aACrB,EAAE,GAAG,CAAC,MAAM,CAAC;SACjB,CAAC;IACN,CAAC;IAES,iBAAiB;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,+BAA+B,CAAC,CAAC;QACrG,OAAO,QAAQ,CAAC,iBAAiB,CAAC;IACtC,CAAC;IAES,cAAc,CAAC,SAAwB,EAAE,GAA0B;QACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,+BAA+B,CAAC,CAAC;QACrG,OAAO,QAAQ,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ"}
@@ -5,6 +5,7 @@ import type SchemeRegistry from "./SchemeRegistry.ts";
5
5
  import type ExecutorRegistry from "./ExecutorRegistry.ts";
6
6
  import type NoticeChannel from "./NoticeChannel.ts";
7
7
  import type ProposalLifecycle from "./ProposalLifecycle.ts";
8
+ import type ClientInteractions from "./ClientInteractions.ts";
8
9
  import type { WriterTier, PlurnkSchemeContext } from "./scheme-types.ts";
9
10
  import { type StreamEventNotify, type WakeWorkerNotify, type InjectWorkerNotify, type BranchWorkerNotify, type BranchCompletionGate, type CancelWorkerNotify, type CancelDescendantsNotify } from "./ChannelWrite.ts";
10
11
  import type LiveSubscriptions from "./LiveSubscriptions.ts";
@@ -29,13 +30,14 @@ export interface ResolvedClientEntryAddress {
29
30
  }
30
31
  export default class Dispatcher {
31
32
  #private;
32
- constructor({ db, schemes, mimetypes, weigh, notices, proposals, executors, loopSignal, streamEventNotify, wakeWorkerNotify, injectWorker, branchWorker, branchCompletionGate, cancelWorker, cancelDescendants, searchGate, parkDeadlines, joinTargets, liveSubscriptions }: {
33
+ constructor({ db, schemes, mimetypes, weigh, notices, proposals, interactions, executors, loopSignal, streamEventNotify, wakeWorkerNotify, injectWorker, branchWorker, branchCompletionGate, cancelWorker, cancelDescendants, searchGate, parkDeadlines, joinTargets, liveSubscriptions }: {
33
34
  db: Db;
34
35
  schemes: SchemeRegistry;
35
36
  mimetypes: Mimetypes;
36
37
  weigh: (text: string) => number;
37
38
  notices: NoticeChannel;
38
39
  proposals: ProposalLifecycle;
40
+ interactions: ClientInteractions;
39
41
  executors: () => ExecutorRegistry | undefined;
40
42
  loopSignal: (loopId: number) => AbortSignal | undefined;
41
43
  streamEventNotify?: StreamEventNotify;
@@ -1 +1 @@
1
- {"version":3,"file":"Dispatcher.d.ts","sourceRoot":"","sources":["../../src/core/Dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EAIb,UAAU,EAEV,eAAe,EACf,aAAa,EAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAIlC,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,iBAAiB,MAAM,wBA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