@plurnk/plurnk-contracts 7.3.0 → 7.4.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 (61) hide show
  1. package/.env.defaults +8 -7
  2. package/README.md +4 -3
  3. package/SPEC.md +58 -56
  4. package/dist/schema/CapabilityDescriptor.json +1 -1
  5. package/dist/schema/CapabilitySelector.json +1 -1
  6. package/dist/schema/MatcherBody.json +3 -3
  7. package/dist/schema/McpServerDefinition.json +1 -1
  8. package/dist/schema/PlurnkStatement.json +55 -64
  9. package/dist/schema/ProposalProjection.json +1 -2
  10. package/dist/schema/ResourceSelection.json +6 -6
  11. package/dist/src/Application.d.ts +27 -5
  12. package/dist/src/Application.d.ts.map +1 -1
  13. package/dist/src/Application.js.map +1 -1
  14. package/dist/src/ApplicationNotifications.d.ts +135 -2
  15. package/dist/src/ApplicationNotifications.d.ts.map +1 -1
  16. package/dist/src/ApplicationNotifications.js +95 -1
  17. package/dist/src/ApplicationNotifications.js.map +1 -1
  18. package/dist/src/ApplicationPort.d.ts +2 -1
  19. package/dist/src/ApplicationPort.d.ts.map +1 -1
  20. package/dist/src/ApplicationPort.js.map +1 -1
  21. package/dist/src/ApplicationStream.d.ts +1 -3
  22. package/dist/src/ApplicationStream.d.ts.map +1 -1
  23. package/dist/src/ApplicationStream.js.map +1 -1
  24. package/dist/src/CapabilityAdmission.js.map +1 -1
  25. package/dist/src/Excerpt.js.map +1 -1
  26. package/dist/src/Functionality.js.map +1 -1
  27. package/dist/src/HttpOrigin.d.ts +27 -0
  28. package/dist/src/HttpOrigin.d.ts.map +1 -1
  29. package/dist/src/HttpOrigin.js +69 -0
  30. package/dist/src/HttpOrigin.js.map +1 -1
  31. package/dist/src/JsonDocument.js.map +1 -1
  32. package/dist/src/JsonResult.js.map +1 -1
  33. package/dist/src/LogRow.d.ts +1 -1
  34. package/dist/src/LogRow.d.ts.map +1 -1
  35. package/dist/src/LogRow.js +0 -2
  36. package/dist/src/LogRow.js.map +1 -1
  37. package/dist/src/LoopLifecycle.js.map +1 -1
  38. package/dist/src/MessageResource.js.map +1 -1
  39. package/dist/src/PathSyntax.js.map +1 -1
  40. package/dist/src/PlurnkParseError.js.map +1 -1
  41. package/dist/src/Problems.js.map +1 -1
  42. package/dist/src/TurnDisposition.js.map +1 -1
  43. package/dist/src/Validator.js.map +1 -1
  44. package/dist/src/guards.js.map +1 -1
  45. package/dist/src/index.d.ts +3 -4
  46. package/dist/src/index.d.ts.map +1 -1
  47. package/dist/src/index.js +2 -2
  48. package/dist/src/index.js.map +1 -1
  49. package/dist/src/types.d.ts +1 -1
  50. package/dist/src/types.d.ts.map +1 -1
  51. package/dist/src/types.generated.d.ts +52 -52
  52. package/dist/src/types.generated.d.ts.map +1 -1
  53. package/dist/src/types.generated.js.map +1 -1
  54. package/dist/src/types.js +1 -1
  55. package/dist/src/types.js.map +1 -1
  56. package/package.json +3 -3
  57. package/plurnk.md +4 -9
  58. package/dist/src/TodoItems.d.ts +0 -6
  59. package/dist/src/TodoItems.d.ts.map +0 -1
  60. package/dist/src/TodoItems.js +0 -145
  61. package/dist/src/TodoItems.js.map +0 -1
package/.env.defaults CHANGED
@@ -17,12 +17,13 @@ PLURNK_PORT=1066
17
17
  # from what else is set.
18
18
  PLURNK_AUTH=1
19
19
  # The operator's client secret ({§auth-oauth-clients}): what the terminal client and every other
20
- # tool of yours exchanges for access tokens. Unset, the daemon mints one at every boot into the
21
- # file `secret` beside its database (0600), where a tool running as you reads it. Set it here, and
22
- # the same value in the tool's environment, for a tool on another host or under another user.
20
+ # tool of yours exchanges for access tokens. Unset, the daemon mints a durable secret into the file
21
+ # `secret` beside its database (0600), reused across restarts where a tool running as you reads it.
22
+ # Set it here, and the same value in the tool's environment, for a tool on another host or under
23
+ # another user.
23
24
  # PLURNK_SECRET=
24
- # The operator's browser sign-in ({§auth-oauth-clients}): the password a browser signs in with,
25
- # compared in constant time at the authorization endpoint. No browser is the operator without it:
26
- # while it is empty, the sign-in page says so and where to set it, and admits nobody
27
- # ({§auth-oauth-clients}). The terminal client and your other tools use PLURNK_SECRET instead.
25
+ # The operator's browser sign-in ({§auth-oauth-clients}): the password a remote browser signs in
26
+ # with, compared in constant time at the authorization endpoint. While it is empty, password sign-in
27
+ # is disabled (`503`); a browser on the same host can sign in directly through `plurnk web` (`/oauth/handoff`),
28
+ # and the terminal client and your other tools use PLURNK_SECRET instead.
28
29
  PLURNK_PASS=
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The single authority for PLURNK's model-facing language contract, its AST,
4
4
  shared schemas and types, runtime-neutral Problems, operation results,
5
- Notices, and text coordinates. See SPEC {§whitespace-contract}.
5
+ Notices, and text coordinates. See SPEC {§contract-representations}.
6
6
 
7
7
  ## Install
8
8
 
@@ -24,12 +24,13 @@ Requires Node.js 26 or newer.
24
24
  | Published JSON Schemas | `@plurnk/plurnk-contracts/schema/*.json` |
25
25
 
26
26
  JSON Schema owns shared wire shapes, generated TypeScript projects those
27
- shapes, and `@plurnk/plurnk-parser` owns accepted Code Mode syntax. See SPEC
27
+ shapes, and `@plurnk/plurnk-parser` owns accepted Heredoc Code Mode syntax and
28
+ Reflective Emission Normalization (RENO). See SPEC
28
29
  {§contract-representations}.
29
30
 
30
31
  ## Parser
31
32
 
32
- The parser that implements this language is [`@plurnk/plurnk-parser`](../plurnk-parser):
33
+ The parser that implements this language is [`@plurnk/plurnk-parser`](https://github.com/plurnk/plurnk-service/tree/main/plurnk-parser):
33
34
  `PlurnkParser` and `parsePath` are its exports, and it depends on this package for
34
35
  the AST and wire types. A consumer that validates or presents the wire needs only
35
36
  this package.
package/SPEC.md CHANGED
@@ -20,28 +20,29 @@
20
20
 
21
21
  ```mermaid
22
22
  flowchart LR
23
- canon["Canonical model teaching<br/>plurnk.md"]
24
- free["Other admitted input"]
25
- syntax["Code Mode parser<br/>CodeMode.ts"]
23
+ canon["Canonical model teaching<br/>plurnk.md (Heredoc Code Mode)"]
24
+ free["Other admitted input<br/>(post-training envelopes & near-misses)"]
25
+ syntax["Heredoc Code Mode parser & RENO<br/>CodeMode.ts · CodeSerializer.ts"]
26
26
  ast["Typed, serializable AST<br/>PlurnkStatement"]
27
- runtime["Runtime owners<br/>stateful semantics and effects"]
27
+ runtime["Runtime owners<br/>execution & ops:// reflection"]
28
28
  canon --> syntax
29
29
  canon --> free
30
30
  free --> syntax
31
31
  syntax --> ast
32
32
  ast --> runtime
33
+ ast -->|"PlurnkParser.stringify"| syntax
33
34
  ```
34
35
 
35
36
  | Layer | Owner or artifact | Contract |
36
37
  | --- | --- | --- |
37
38
  | Stable current law | `SPEC.md` | Owns invariants and boundaries; forge issues retain history |
38
- | Canonical model teaching | `plurnk.md` | Teaches the lean Code Mode call syntax and operational model the model should emit |
39
- | Accepted syntax | `CodeMode.ts`, `MatcherSyntax.ts`, `ScopeSyntax.ts`, `TargetSyntax.ts` | Recognizes declarative `await <service>.<tool>(args);` calls, literal argument shapes, and outside text |
39
+ | Canonical model teaching | `plurnk.md` | Teaches the lean Heredoc Code Mode call syntax and operational model the model should emit |
40
+ | Accepted syntax & RENO | `CodeMode.ts`, `SourceIndex.ts`, `ChunkScanner.ts`, `EnvelopeScanner.ts`, `MarkupReader.ts`, `TargetResolver.ts`, `CallExpressionParser.ts`, `OptionCoercion.ts`, `StatementLowering.ts`, `CodeSerializer.ts`, `HeredocSyntax.ts`, `MatcherSyntax.ts`, `ScopeSyntax.ts`, `TargetSyntax.ts` | Recognizes declarative `<service>.<tool>(args)` calls (and tolerated `await <service>.<tool>(args)`) with `<<<EOF` heredocs, normalizes deterministic post-training tool-call envelopes and argument near-misses on admission, and serializes canonical Heredoc Code Mode for `ops://` reflection |
40
41
  | Typed admission | `PlurnkStatement` AST | Produces JSON-serializable unions and validates deterministic path/scope/matcher syntax |
41
42
  | Shared wire data | `schema/*.json` | Defines runtime-neutral data shapes projected into generated TypeScript |
42
43
  | Stateful behavior | consuming runtime | Resolves addresses, permissions, selection arithmetic, effects, and lifecycle |
43
44
 
44
- - **Authoritative representations**: JSON Schema is authoritative for shared wire data shapes; TypeScript types are generated from `schema/*.json`; `@plurnk/plurnk-parser` is authoritative for accepted Code Mode syntax.
45
+ - **Authoritative representations**: JSON Schema is authoritative for shared wire data shapes; TypeScript types are generated from `schema/*.json`; `@plurnk/plurnk-parser` is authoritative for accepted Heredoc Code Mode syntax and Reflective Emission Normalization (RENO).
45
46
  - **ACP discovery and schema enforcement**: `AcpDiscovery` enumerates the installed ACP v2 actions (`scope`, `inputSchema`, `outputSchema`), notifications (`payloadSchema`), and `display` capabilities. Boundary validators enforce these schemas without mutating them and report structured validation `issues` in RFC 9457 Problem `detail`.
46
47
  - **JSON result and document presentation**: `renderJsonResult` formats compact aggregate operation rows (placing top-level array items on individual lines without rewriting stored JSON coordinates). `formatJsonDocument` performs two-space whitespace-only formatting of complete strict JSON documents before representation storage.
47
48
 
@@ -66,7 +67,7 @@ flowchart LR
66
67
  | `ProposalProjection` | Identity, review target, body/attrs, owner, capability selector, ACP v2 subject, stale signal, disposition | One validated projection for live delivery and reconnect |
67
68
 
68
69
  - **Exact selector conjunction**: A capability selector matches a `CapabilityDescriptor` when every declared field equals the descriptor and every declared `trait` occurs in the descriptor's trait set. Within a policy layer, `deny` wins over `only` and `allow`; when `only` is present, at least one selector must match. An empty policy admits everything; an empty `only` list admits nothing.
69
- - **Subtractive cascade**: Capability admission is purely subtractive and order-independent: a descriptor is admitted only when every active layer (`service` and `workspace`) admits it. Workspace policy cannot restore authority denied by the service. A demand is pre-approved across layers only when it is admitted across every layer and matches at least one layer's `allow` selector. Log/program control (`plurnk.kill` on `log:///...`, native dispositions `WAIT`/`NOTE`/`TODO`, `DONE`, `FAIL`, and targetless `SEND`) creates no capability demand.
70
+ - **Subtractive cascade**: Capability admission is purely subtractive and order-independent: a descriptor is admitted only when every active layer (`service` and `workspace`) admits it. Workspace policy cannot restore authority denied by the service. A demand is pre-approved across layers only when it is admitted across every layer and matches at least one layer's `allow` selector. Log/program control (`plurnk.kill` on `log:///...`, native dispositions `wait`/`note`, `done`, `fail`, and targetless `send`) creates no capability demand.
70
71
  - **Proposals and session ownership**: `ProposalPolicy` (`review | accept | reject`) and `SessionOwner` (`address`, `clientTools`, `interactive`) govern stopped-world approval after capability admission succeeds.
71
72
  - **Effort and model catalog wire**: `Effort` is `off | adaptive | low | medium | high | xhigh | max`. `ModelRoute`, `ModelCatalogPage`, and `ModelReadiness` expose provider/model identity, capabilities (including supported `efforts`), physical limits, and alternative required environment-variable name sets (names only, never values, credentials, or tuning internals).
72
73
 
@@ -87,65 +88,64 @@ flowchart LR
87
88
 
88
89
  ---
89
90
 
90
- ## §operation-fences 2. Canonical Code Mode statement form
91
+ ## §operation-fences 2. Canonical Heredoc Code Mode statement form
91
92
 
92
93
  ```ts
93
- await plurnk.<op>({ ... }); // optional aside
94
+ plurnk.<op>({ ... }) // optional aside
94
95
 
95
- await <service>.<tool>({ ... });
96
+ <service>.<tool>({ ... })
96
97
  ```
97
98
 
98
- - **Declarative top-level tool calls**: Every canonical statement is an unwrapped TypeScript/JavaScript `await <service>.<tool>(args);` call (with `await` and trailing `;` optional). `plurnk` is the built-in runtime service (`plurnk.read`, `plurnk.find`, `plurnk.edit`, `plurnk.copy`, `plurnk.move`, `plurnk.kill`, `plurnk.note`, `plurnk.todo`, `plurnk.work`, `plurnk.fork`, `plurnk.bare`, `plurnk.send`, `plurnk.done`, `plurnk.fail`, `plurnk.wait`, REPL tools `plurnk.sh`, `plurnk.js`, `plurnk.python3`, and Functionality tools `plurnk.env`, `plurnk.mcp`, `plurnk.members`, `plurnk.personas`, `plurnk.schedule`, `plurnk.skills`, `plurnk.question`). External MCP servers are peer top-level namespaces (`await <service>.<tool>(args);`).
99
- - **Bracket property access**: Non-identifier tool names use bracket notation (`await gitea["issue-read"]({ ... });`).
100
- - **No free JavaScript execution in the parser**: Top-level statements are parsed as declarative calls with literal arguments (`{ ... }`, `[ ... ]`, strings/backticks, numbers, booleans, `null`); variable declarations and control-flow constructs (`const`, `let`, `var`, `if`, `for`, `while`, `function`, `try`) are refused with a parser diagnostic directing JavaScript logic to `await plurnk.js({ code: "..." });`.
99
+ - **Declarative top-level tool calls**: Every canonical Heredoc Code Mode statement is an unwrapped TypeScript/JavaScript `<service>.<tool>(args)` call (with leading `await` and trailing `;` tolerated on input and stripped in canonical serialization). `plurnk` is the built-in runtime service (`plurnk.read`, `plurnk.find`, `plurnk.edit`, `plurnk.copy`, `plurnk.move`, `plurnk.kill`, `plurnk.note`, `plurnk.work`, `plurnk.fork`, `plurnk.bare`, `plurnk.send`, `plurnk.done`, `plurnk.fail`, `plurnk.wait`, REPL tools `plurnk.sh`, `plurnk.js`, `plurnk.python3`, and Functionality tools `plurnk.env`, `plurnk.mcp`, `plurnk.members`, `plurnk.personas`, `plurnk.schedule`, `plurnk.skills`, `plurnk.question`). External MCP servers are peer top-level namespaces (`<service>.<tool>(args)`).
100
+ - **Bracket property access**: Non-identifier tool names use bracket notation (`gitea["issue-read"]({ ... })`).
101
+ - **No free JavaScript execution in the parser**: Top-level statements are parsed as declarative calls with literal arguments (`{ ... }`, `[ ... ]`, strings/backticks, `<<<EOF ... EOF` heredocs, numbers, booleans, `null`); variable declarations and control-flow constructs (`const`, `let`, `var`, `if`, `for`, `while`, `function`, `try`) invoking `plurnk` or tool calls are refused with a parser diagnostic directing JavaScript logic to `plurnk.js({ text: "..." })`, while unfenced general JavaScript snippets in model prose that do not invoke `plurnk`, a registered executor, or a literal-object tool call remain outside text.
101
102
 
102
- ### §fence-pairing Statement boundaries, unwrapped tolerances, and canonical rendering
103
+ ### §fence-pairing Statement boundaries, RENO admission tolerances, and reflective rendering
103
104
 
104
105
  | Rule | Contract |
105
106
  | --- | --- |
106
- | Balanced call boundaries | A statement spans from its `<service>.<tool>(` head through its matching closing `)` and optional `;` and trailing `// aside` comment. Multi-line strings and template literals (`` `...` ``) preserve embedded newlines and treat unescaped `${...}` as literal text. |
107
- | Markdown fence unwrapping | Code Mode statements require no Markdown fence; if a model wraps `await plurnk.<op>(...)` or `await <service>.<tool>(...)` inside a balanced `ts`, `js`, or plain Markdown code fence, the parser unwraps the block with a warning-severity advisory. |
108
- | Native and markup tool-call translation | Tool-call wrapper tags (`<tool_call>`, `<tool_calls>`, `<function_call>`, `<function_calls>`, `<|DSML|function_calls>`, `<||DSML|| function_calls>`, `<\|tool_call\|>`, `<|tool▁calls▁begin|>`, `<\|tool_calls_section_begin\|>`, `<\|python_tag\|>`, `[TOOL_CALLS]`) around Code Mode statements unwrap silently, and structured XML/DSML/token-delimited (`<function=...>`, `<invoke name="...">`, `<|DSML|invoke name="...">`, `<plurnk.<op> ... />`, `<|tool▁call▁begin|>`, `<\|tool_call_begin\|>`, `<\|tool_call\|>name`) or JSON tool calls targeting `plurnk` operations or `<service>.<tool>` translate silently into canonical Code Mode statements without advisory warnings. |
109
- | Case-insensitive method recovery | Uppercase or mixed-case method names (`plurnk.READ(...)`, `plurnk.SH(...)`) recover to their lowercase canonical tool name with a warning-severity advisory. |
110
- | Statement rendering | `PlurnkParser.stringify` formats AST statements back into canonical `await plurnk.<op>({ ... });` or `await <service>.<tool>({ ... });` statements, normalizing empty optional bodies to `null`. |
107
+ | Balanced call boundaries & heredocs | A statement spans from its `<service>.<tool>(` head through its matching closing `)` and optional `;` and trailing `// aside` comment. In any value position, `<<<TAG\n...\nTAG` (where `TAG` matches `[A-Za-z][A-Za-z0-9_-]{0,16}`, optionally single- or double-quoted on the opener, or placed after `})` as a statement-trailing heredoc) captures raw unescaped text between its opener newline and closer line, pairing nested `<<TAG` / `<<-TAG` shell heredocs before closing the outer `TAG`. Multi-line strings and template literals (`` `...` ``) preserve embedded newlines and treat unescaped `${...}` as literal text. |
108
+ | Markdown fence unwrapping & `await` tolerance | Heredoc Code Mode statements require neither a Markdown fence nor `await`; if a model prefixes `await` or wraps `plurnk.<op>(...)` or a registered `<service>.<tool>(...)` (or `await <service>.<tool>(...)`) inside a balanced `ts`, `js`, or plain Markdown code fence, the parser normalizes the statement silently under RENO. |
109
+ | Native and markup tool-call translation | Tool-call wrapper tags (`<tool_call>`, `<tool_calls>`, `<function_call>`, `<function_calls>`, `<|DSML|function_calls>`, `<||DSML|| function_calls>`, `<\|tool_call\|>`, `<|tool▁calls▁begin|>`, `<\|tool_calls_section_begin\|>`, `<\|python_tag\|>`, `[TOOL_CALLS]`) around Code Mode statements unwrap silently, and structured XML/DSML/token-delimited (`<function=...>`, `<invoke name="...">`, `<|DSML|invoke name="...">`, `<plurnk.<op> ... />`, `<|tool▁call▁begin|>`, `<\|tool_call_begin\|>`, `<\|tool_call\|>name`, `<\|channel\|>... to=name`) or JSON tool calls targeting `plurnk` operations or `<service>.<tool>` translate silently into canonical Heredoc Code Mode statements. |
110
+ | Case-insensitive method recovery | Uppercase or mixed-case method names (`plurnk.READ(...)`, `plurnk.SH(...)`) recover silently to their lowercase canonical tool name. |
111
+ | Reflective statement rendering | `PlurnkParser.stringify` formats AST statements back into canonical `plurnk.<op>({ ... })` or `<service>.<tool>({ ... })` Heredoc Code Mode statements for `emission` / `emission-history` (`assistant` turn) reflection, normalizing empty optional bodies to `null` and rendering every `pattern` field and any string value containing `\n` (as well as the Turn 0 `Resolve all Open Work.` note seed) as an inline `<<<EOF\n...\nEOF` heredoc (stepping `EOF1`, `EOF2`, … when the string contains the delimiter). |
111
112
 
112
- ### §slot-order Argument shapes, target groups, and metadata modifiers
113
+ ### §slot-order Argument shapes, target groups, and endpoint options
113
114
 
114
115
  | Construct | Contract |
115
116
  | --- | --- |
116
- | Object and positional argument forms | Core operations accept their canonical `{ ... }` options object (`{ path, range?, pattern?, content?, ... }`) as well as concise positional string/array shorthands (`plurnk.read("a.ts")`, `plurnk.copy("a.ts", "b.ts")`, `plurnk.note("text")`). |
117
+ | Object and positional argument forms | Core operations accept their canonical `{ ... }` options object (`{ path, range?, pattern?, text?, ... }`) as well as concise positional string/array shorthands (`plurnk.read("a.ts")`, `plurnk.copy("a.ts", "b.ts")`, `plurnk.note("text")`). |
117
118
  | Target groups and multi-target lists | `plurnk.read`, `plurnk.find`, and `plurnk.kill` accept `path` or `paths` as a string or array of strings; comma/pipe/whitespace-separated `scheme://` URI lists and comma/pipe-separated local path/glob lists outside brackets/braces expand into one statement per target in authored order. |
118
- | `note` annotation on retrievals | Providing `note` on `plurnk.read` or `plurnk.find` emits a preceding `NOTE` statement before the retrieval(s). |
119
- | Scheme metadata modifier | `metadata` (`string` or `string[]`) passes raw metadata options to the target scheme or executor (`MetadataOptions` parses first-party arrays of option objects and reserves `env`). |
120
- | Operation aside | A trailing `// aside` comment after `;` or `)` on the closing line of a statement is captured into `aside` (`string` or `null`) as descriptive metadata. |
119
+ | `note` annotation on retrievals | Providing `note` on `plurnk.read` or `plurnk.find` emits a preceding `note` statement before the retrieval(s). |
120
+ | Endpoint and message options | `headers` (`Record<string, string>`) passes HTTP(S) request headers on `plurnk.read`, `plurnk.find`, `plurnk.edit`, `plurnk.send`, `plurnk.kill`, and `plurnk.copy`/`plurnk.move` (`fromHeaders`/`toHeaders`); `remote` (`boolean`) confirms remote HTTP `DELETE` on `plurnk.kill`; `attachments` (`string[]`) attaches resources to `plurnk.send`, `plurnk.done`, and `plurnk.fail`. Unknown option keys on `plurnk.<op>({ ... })` are refused with a parser diagnostic. |
121
+ | Operation aside | A trailing `// aside` comment after `;` or `)` on the closing line of a statement is captured into `aside` (`string` or `null`) as descriptive commentary, splitting before any glued transcript heading (`### log:///` or `**<service>: <label>**`). |
121
122
 
122
123
  ---
123
124
 
124
125
  ## §op-shapes 3. Per-operation semantics and dispositions
125
126
 
126
- | Call | Target field | Scope / matcher fields | Content / payload fields |
127
+ | Call | Target field | Scope / matcher / endpoint fields | Content / payload fields |
127
128
  | --- | --- | --- | --- |
128
- | `plurnk.find` | required `path` / `paths` | optional `range`, `pattern` | optional `note` normalized to preceding `NOTE` |
129
- | `plurnk.read` | required `path` / `paths` | optional `range`, `pattern` | optional `note` normalized to preceding `NOTE` |
130
- | `plurnk.edit` | required `path` | `range` or `pattern` or `oldText`/`newText` or `edits` for existing target; `content` alone creates | `content`, `newText`, or `edits` array |
131
- | `plurnk.copy` / `plurnk.move` | required `from` and `to` | optional `fromRange` / `toRange` (or inline `path<L,M>`) | none |
132
- | `plurnk.sh` / `plurnk.js` / `plurnk.python3` | optional `cwd`, `script` | optional `range`, `metadata` | `command` (`sh`) or `code` (`js`, `python3`), optional `args` |
129
+ | `plurnk.find` | required `path` / `paths` | optional `range`, `pattern`, `headers` | optional `note` normalized to preceding `note` |
130
+ | `plurnk.read` | required `path` / `paths` | optional `range`, `pattern`, `headers` | optional `note` normalized to preceding `note` |
131
+ | `plurnk.edit` | required `path` | `range` or `pattern` or `oldText`/`newText` or `edits` for existing target; `text` alone creates; optional `headers` | `text` (or tolerated `content`, `replacement`, `newText`, `body`), or `edits` array |
132
+ | `plurnk.copy` / `plurnk.move` | required `from` and `to` | optional `fromRange` / `toRange`, `fromHeaders` / `toHeaders` | none |
133
+ | `plurnk.sh` / `plurnk.js` / `plurnk.python3` | optional `script`, `cwd` | none | `text` (or tolerated `code` / `command` / `cmd` / `body` / `source` / `prompt`), optional `args` |
133
134
  | `plurnk.<functionality>` | tool name (`env`, `mcp`, `members`, `personas`, `schedule`, `skills`, `question`) | none | JSON arguments object |
134
- | `<service>.<tool>` | external MCP `<service>` and `<tool>` | optional second `{ range, metadata }` options arg | JSON arguments object or string |
135
- | `plurnk.bare` | optional `target` prompt resource | none | `prompt` / `text` |
136
- | `plurnk.work` / `plurnk.fork` | optional `target` (`session://name` or prompt resource) | none | `prompt` / `text` |
137
- | `plurnk.kill` | required `path` / `paths` | optional `range`, `pattern` | optional `note` distillation on `log:///` |
138
- | `plurnk.send` | optional `target` recipient | none | `text` message body |
139
- | `plurnk.done` | optional `target` (`message://`) | none | optional `text` final deliverable |
140
- | `plurnk.fail` | optional `target` (`message://`) | none | optional `text` final failure explanation |
141
- | `plurnk.note` | none | none | `text` literal working memory |
142
- | `plurnk.todo` | none | none | required `items` remaining step list (or tolerated `todos` / `text`) |
143
- | `plurnk.wait` | optional `target` label | optional `seconds` | `text` wait explanation |
144
-
145
- - **Retrieval annotations**: Nonblank bodies beneath `FIND` or `READ` normalize into a preceding `NOTE` statement.
146
- - **Text scope algebra**: `<N>` selects whole line `N` (`0` prepends, `-1` appends on mutation); `<N,M>` selects inclusive lines `N..M`; `<SL,SC,EL,EC>` selects an exact 1-based Unicode code-point region with exclusive end (three-integer scopes normalize to four).
135
+ | `<service>.<tool>` | external MCP `<service>` and `<tool>` | optional second `{ range }` options arg | JSON arguments object or string |
136
+ | `plurnk.bare` | none | none | required `text` (or tolerated `prompt` / `body` / `content` / `message`) |
137
+ | `plurnk.work` / `plurnk.fork` | optional `target` (`session://name`) | none | required `text` (or tolerated `prompt` / `body` / `content` / `message`) |
138
+ | `plurnk.kill` | required `path` / `paths` | optional `range`, `pattern`, `remote`, `headers` | optional `note` distillation on `log:///` |
139
+ | `plurnk.send` | optional `target` recipient (caller aliases `user`/`client`/`human`/`operator`/`caller` normalize to `null`) | optional `headers`, `attachments` | required `text` message body |
140
+ | `plurnk.done` | optional `target` (`message://`; caller aliases normalize to `null`) | optional `attachments` | optional `text` final deliverable (`plurnk.done()` / `plurnk.done({})` resolves silently when empty) |
141
+ | `plurnk.fail` | optional `target` (`message://`; caller aliases normalize to `null`) | optional `attachments` | optional `text` final failure explanation (`plurnk.fail()` / `plurnk.fail({})` cancels silently when empty) |
142
+ | `plurnk.note` | none | none | `text` facts, ideas, and plans |
143
+ | `plurnk.wait` | none | optional `seconds` | none (uses trailing `// aside`; tolerated `text` normalizes to `aside`) |
144
+
145
+ - **Retrieval annotations**: Nonblank `note` options on `find` or `read` normalize into a preceding `note` statement.
146
+ - **Text range algebra**: `"N"` selects whole line `N` (`"0"` prepends, `"-1"` appends on mutation); `"N,M"` selects inclusive lines `N..M`; `"SL,SC,EL,EC"` selects an exact 1-based Unicode code-point region with exclusive end (three-integer ranges normalize to four).
147
147
  - **Local path fragments**: Bare paths decompose `#channel` into `fragment` just like `scheme://` URLs so channel selectors round-trip identically.
148
- - **Turn dispositions (`WAIT`, `DONE`, and `FAIL`)**: Dispositions may appear anywhere in a turn; multiple `WAIT` statements coalesce to the shortest `[seconds]` bound, and `DONE` (`200`) or `FAIL` (`499`) resolves an Open Message once all earlier operations in the turn settle.
148
+ - **Turn dispositions (`wait`, `done`, and `fail`)**: Dispositions may appear anywhere in a turn; multiple `wait` statements coalesce to the shortest `seconds` bound, and `done` (`200`) or `fail` (`499`) resolves an Open Message once all earlier operations in the turn settle.
149
149
 
150
150
  ---
151
151
 
@@ -159,20 +159,20 @@ await <service>.<tool>({ ... });
159
159
 
160
160
  ## §matcher-prefix-claims 5. Bulk pattern matching and scope markers
161
161
 
162
- `FIND`, `READ`, `KILL`, and `EDIT` accept a single-line matcher on the heading line classified by leading sigil:
162
+ `plurnk.find`, `plurnk.read`, `plurnk.kill`, and `plurnk.edit` accept a `pattern` matcher classified by leading sigil (`glob` and `regex` may span multiple lines; `xpath`, `jsonpath`, `fts`, and `graph` are single-line):
163
163
 
164
164
  | Prefix | Dialect | Validation & tolerance |
165
165
  | --- | --- | --- |
166
- | `//` | `xpath` | Validated with XPath 1.0 parser before regex classification |
167
- | `/` or `^` | `regex` | ECMAScript `RegExp`; tolerates `\|` alternation, trailing `-flags`, and glob-shaped `/*text*/` with advisories |
166
+ | `//` | `xpath` | Validated with XPath 1.0 parser before regex classification (also silently normalizes single-slash absolute XPath location paths such as `/root/item[@id='old']/@id` or `/root/item/text()`, regex-wrapped or trailing-slash XPath selectors such as `///item[@id='old']/`, `//item[@id='old']/`, or `/\/\/item[@id='old']/`, and vacuous `/text()` after `@attr` steps) |
167
+ | `/` or `^` | `regex` | ECMAScript `RegExp`; tolerates `\|` alternation, trailing `-flags`, `/~.../` mixed prefix, unbalanced unescaped `(`, `)`, or `[`, and glob-shaped `/*text*/` |
168
168
  | `$` | `jsonpath` | Validated with RFC 9535 `json-p3` |
169
169
  | `~` | `fulltext` | Single-line FTS5 query string |
170
170
  | `&` | `graph` | `&symbol`, `&<symbol`, or `&>symbol` relation query |
171
- | none | `glob` | Fallback shell glob or literal substring |
171
+ | none | `glob` | Fallback shell glob or single/multiline literal substring (`<<<EOF...EOF`) |
172
172
 
173
173
  - **Soft matcher refusal**: An invalid matcher expression is admitted as `matcher.dialect = "unreadable"` with its diagnostic and working-form `recovery` so only that operation fails `400 grammar/matcher/unreadable-pattern` while sibling statements in the turn still execute.
174
- - **Heading recovery and slot tolerances**: Statement errors recover at the next column-0 heading; a `<scope>` written inside `(path<L,M>)` is lifted with a warning; extra `(path)` slots beyond the operation's arity fail only that statement.
175
- - **Line anchors and scope range recovery**: `TextLineMarker` accepts `@<5 Base62 chars>` line anchors in line positions; reversed or zero-based two-number scopes (`<0,N>`, `<M,N>` with `M > N`, `<N,+K>`) normalize with a warning advisory.
174
+ - **Statement recovery and argument tolerances**: Statement errors recover at the next top-level call; an inline `<L,M>` range written inside `path<L,M>` is lifted silently; extra positional arguments beyond the operation's arity fail only that statement.
175
+ - **Line anchors and range recovery**: `TextLineMarker` accepts `@<5 Base62 chars>` line anchors (with optional `[+-]K` offsets or surrounding `<...>`) in line positions; reversed or count two-number ranges (`"M,N"` with `M > N`, `"N,+K"`) and unambiguous anchor forms (`"@hash,1"` as `"@hash"`, `"@hash,0"` as `"@hash,1,@hash,1"`, and `"@start,@end,SC[,EC]"` as `"@start,SC,@end[,EC]"`) normalize silently under RENO.
176
176
 
177
177
  ---
178
178
 
@@ -213,7 +213,9 @@ await <service>.<tool>({ ... });
213
213
 
214
214
  | Projection / Helper | Contract |
215
215
  | --- | --- |
216
- | `ApplicationPort` | Transport-neutral interface in `@plurnk/plurnk-contracts/port` driving workspaces, sessions, loops (`runLoop` with causal `source`, `attachments`, `envelope`), operations, proposals, client interactions, and event subscriptions (`ApplicationOperationEvent`). |
216
+ | `ApplicationPort` | Transport-neutral interface in `@plurnk/plurnk-contracts/port` driving workspaces, sessions, loops (`runLoop` with causal `source`, `attachments`, `envelope`), operations, proposals, client interactions, and filtered event subscriptions (`subscribeToEvents(handler, filter?)`). |
217
+ | `DaemonNotification` / `NotificationFilter` | Closed discriminated union over the 20 `DAEMON_NOTIFICATION_EVENTS` (`{ id, event, timestamp, workspaceId, sessionId, data }`), constructed by `toDaemonNotification` and filtered at source by `matchesNotificationFilter(notification, { events?, workspaceId?, sessionId? })`. |
218
+ | `admitBearerRequest` | Runtime-neutral OAuth 2.1 Bearer and optional `?access_token=` admission helper over `CredentialAuthority` returning `{ ok: true, family, subject }` or `{ ok: false, problem, challenge }`. |
217
219
  | `selectSessionLoop` | Chooses `running` before `parked` before `queued` (oldest unresolved sequence wins ties); with no live work, the latest terminal settlement wins. Maintenance-only loops do not change this projection. |
218
220
  | `lifecycleOfLoopStatus` | Maps loop status to client lifecycle vocabulary: no loop `idle`; `100` `queued`; `102` `running`; `202` `parked`; `< 400` `completed`; `499` `cancelled`; `>= 400` `failed` (`413` budget, `429` turn ceiling, `500` fail, `504` timeout, `508` runaway). |
219
221
  | `excerptOf` | Extracts the first non-blank line of a message truncated to at most `N` code points without splitting a character, with trailing whitespace trimmed and `continued: boolean`. |
@@ -221,7 +223,7 @@ await <service>.<tool>({ ... });
221
223
 
222
224
  ---
223
225
 
224
- ## §parse-recovery 8. Parse diagnostics, tolerances, and error shapes
226
+ ## §parse-recovery 8. Reflective Emission Normalization (RENO), tolerances, and error shapes
225
227
 
226
228
  `PlurnkParseError` is a JSON-serializable `Error` carrying `{ line, column, source: "lexer" | "parser" | "visitor", severity: "error" | "warning", recovery?, attempt?, operationOmitted }`:
227
229
 
@@ -234,6 +236,6 @@ await <service>.<tool>({ ... });
234
236
 
235
237
  | Mechanism | Contract |
236
238
  | --- | --- |
237
- | Working-form recovery & attempt | Every hard error (`severity: "error"`) populates `recovery` with the canonical Code Mode syntax of the refused construct and `attempt` (`{ text, verb }`) with the refused statement's source text; `operationOmitted` marks unexecuted call fragments. Each malformed statement produces at most one hard error. |
238
- | Regex and matcher tolerances | Lifts leading PCRE inline flags `(?ims)` with a warning; folds comma-separated `/pattern/` lists on `FIND` and `READ` into alternation with a warning while refusing numeric/open sed ranges (`/a/,+N`, `/a/,-1`, `/a/,`) and mutating `/a/,/b/` ranges; diagnoses trailing text after `/pattern/flags`; recovers unclosed `/pattern` at EOL. |
239
- | Statement & argument tolerances | Lifts inline `<L,M>` scopes from `path<L,M>` strings with a warning; recovers bare `EDIT` anchors (`@abcde`) and combined `42<@abcde>` scopes; unwraps Markdown-fenced Code Mode statements with a warning; and sets `unparsedTail` when an unclosed string, comment, parenthesis, bracket, or brace reaches end of input. |
239
+ | Working-form recovery & attempt | Every hard error (`severity: "error"`) populates `recovery` with the canonical Heredoc Code Mode syntax of the refused construct and `attempt` (`{ text, verb }`) with the refused statement's source text; `operationOmitted` marks unexecuted call fragments. Each malformed statement produces at most one hard error. |
240
+ | Regex and matcher tolerances | Lifts leading PCRE inline flags `(?ims)` with a warning; recognizes unslashed line-anchored regexes opening with `^` or closing with `$`; folds comma-separated `/pattern/` lists on `find` and `read` into alternation with a warning while refusing numeric/open sed ranges (`/a/,+N`, `/a/,-1`, `/a/,`) and mutating `/a/,/b/` ranges; diagnoses trailing text after `/pattern/flags`; recovers unclosed `/pattern` at EOL. |
241
+ | Statement & argument tolerances (RENO) | Lifts inline `<L,M>` ranges from `path<L,M>` strings with a warning; recovers bare `edit` anchors (`@abcde`), combined `42<@abcde>` ranges, trailing commas in range lists (`"17,18,"`), unbalanced angle brackets around `@hash` ranges (`"<@abcde,@fghij"`), anchor-first column tuples (`"@SL,@EL,SC[,EC]"`), and packet-header line counts (`"N lines"`); recovers extra or transposed delimiters on heredoc closers (`EOF)})`, `EOF)}`, `EOF)]`) and closing `}}` call braces; unwraps nested parameter wrappers (`params`, `parameters`, `arguments`, `args`, `input`, `options`, `properties`, `text`); transduces foreign native tool-call envelopes (`<tool_call>`, `<TOOLCALL>`, `<\|tool_call_start\|>`, `<\|python_tag\|>`, `[TOOL_CALLS]...[ARGS]`, `Action:` JSON fences, `<arg_key>`/`<arg_value>`, `<seed:think>`, `<mm:think>`); unwraps Markdown-fenced Code Mode statements and accepts redundant `await` prefixes silently; suppresses standalone `**<service>: <label>**` transcript-echo headings and trailing canonical duplicate statements in model emissions; and sets `unparsedTail` when an unclosed string, comment, parenthesis, bracket, or brace reaches end of input. |
@@ -11,7 +11,7 @@
11
11
  "description": "An operation keyword, or a runtime tag: an execution's operation is its runtime.",
12
12
  "anyOf": [
13
13
  { "enum": ["find", "read", "edit", "copy", "move", "send", "bare", "work", "fork", "kill"] },
14
- { "type": "string", "pattern": "^[a-z][a-z0-9+._-]*$", "not": { "enum": ["done", "fail", "note", "todo", "wait", "extension", "error"] } }
14
+ { "type": "string", "pattern": "^[a-z][a-z0-9+._-]*$", "not": { "enum": ["done", "fail", "note", "wait", "extension", "error"] } }
15
15
  ],
16
16
  "tsType": "\"find\" | \"read\" | \"edit\" | \"copy\" | \"move\" | \"send\" | \"bare\" | \"work\" | \"fork\" | \"kill\" | Lowercase<string>"
17
17
  },
@@ -11,7 +11,7 @@
11
11
  "description": "An operation keyword, or a runtime tag: an execution's operation is its runtime.",
12
12
  "anyOf": [
13
13
  { "enum": ["find", "read", "edit", "copy", "move", "send", "bare", "work", "fork", "kill"] },
14
- { "type": "string", "pattern": "^[a-z][a-z0-9+._-]*$", "not": { "enum": ["done", "fail", "note", "todo", "wait", "extension", "error"] } }
14
+ { "type": "string", "pattern": "^[a-z][a-z0-9+._-]*$", "not": { "enum": ["done", "fail", "note", "wait", "extension", "error"] } }
15
15
  ],
16
16
  "tsType": "\"find\" | \"read\" | \"edit\" | \"copy\" | \"move\" | \"send\" | \"bare\" | \"work\" | \"fork\" | \"kill\" | Lowercase<string>"
17
17
  },
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://schemas.plurnk.xyz/v0/MatcherBody.json",
4
4
  "title": "MatcherBody",
5
- "description": "Parsed single-line body of a matcher-bearing statement, discriminated on `dialect`. The dialect is determined by the body's leading characters (`//` xpath, `/` regex, `$` jsonpath, `~` full-text, `&` graph, else glob); a body the parser could not read in its claimed dialect is `unreadable` ({§matcher-prefix-claims}). The regex variant carries pattern and flags split out of the `/pattern/flags` literal; every variant remains JSON-serializable.",
5
+ "description": "Parsed body of a matcher-bearing statement, discriminated on `dialect`. The dialect is determined by the body's leading characters (`//` xpath, `/` regex, `$` jsonpath, `~` full-text, `&` graph, else glob); a body the parser could not read in its claimed dialect is `unreadable` ({§matcher-prefix-claims}). The regex variant carries pattern and flags split out of the `/pattern/flags` literal; every variant remains JSON-serializable.",
6
6
  "oneOf": [
7
7
  { "$ref": "#/$defs/XPathBody" },
8
8
  { "$ref": "#/$defs/RegexBody" },
@@ -32,7 +32,7 @@
32
32
  "additionalProperties": false,
33
33
  "properties": {
34
34
  "dialect": { "const": "regex" },
35
- "raw": { "type": "string", "minLength": 2, "pattern": "^[^\\r\\n]*$" },
35
+ "raw": { "type": "string", "minLength": 2 },
36
36
  "pattern": { "type": "string" },
37
37
  "flags": { "type": "string" }
38
38
  }
@@ -91,7 +91,7 @@
91
91
  "additionalProperties": false,
92
92
  "properties": {
93
93
  "dialect": { "const": "glob" },
94
- "raw": { "type": "string", "pattern": "^[^\\r\\n]*$" }
94
+ "raw": { "type": "string" }
95
95
  }
96
96
  }
97
97
  }
@@ -14,7 +14,7 @@
14
14
  "$defs": {
15
15
  "name": {
16
16
  "title": "McpServerName",
17
- "description": "The server's alias: the runtime tag whose fence invokes it and its resource scheme.",
17
+ "description": "The server's alias: its runtime name (`<alias>.<tool>`) and resource scheme (`<alias>://`).",
18
18
  "type": "string",
19
19
  "pattern": "^[a-z][a-z0-9_-]*$"
20
20
  },