@plurnk/plurnk-contracts 7.5.0 → 9.0.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 (53) hide show
  1. package/README.md +9 -9
  2. package/SPEC.md +78 -83
  3. package/dist/schema/DaemonNotificationEnvelope.json +555 -0
  4. package/dist/schema/McpServerDefinition.json +1 -1
  5. package/dist/schema/PlurnkStatement.json +24 -0
  6. package/dist/schema/ProposalProjection.json +0 -4
  7. package/dist/src/Application.d.ts +22 -1
  8. package/dist/src/Application.d.ts.map +1 -1
  9. package/dist/src/Application.js +480 -15
  10. package/dist/src/Application.js.map +1 -1
  11. package/dist/src/ApplicationNotifications.d.ts +59 -28
  12. package/dist/src/ApplicationNotifications.d.ts.map +1 -1
  13. package/dist/src/ApplicationNotifications.js +40 -8
  14. package/dist/src/ApplicationNotifications.js.map +1 -1
  15. package/dist/src/ApplicationPort.d.ts +26 -7
  16. package/dist/src/ApplicationPort.d.ts.map +1 -1
  17. package/dist/src/ApplicationPort.js.map +1 -1
  18. package/dist/src/ApplicationStream.d.ts +4 -0
  19. package/dist/src/ApplicationStream.d.ts.map +1 -1
  20. package/dist/src/ApplicationStream.js.map +1 -1
  21. package/dist/src/LogRow.d.ts +1 -1
  22. package/dist/src/LogRow.js +1 -1
  23. package/dist/src/LogRow.js.map +1 -1
  24. package/dist/src/PathSyntax.d.ts +0 -1
  25. package/dist/src/PathSyntax.d.ts.map +1 -1
  26. package/dist/src/PathSyntax.js +1 -4
  27. package/dist/src/PathSyntax.js.map +1 -1
  28. package/dist/src/Validator.d.ts +3 -3
  29. package/dist/src/Validator.d.ts.map +1 -1
  30. package/dist/src/Validator.js +8 -16
  31. package/dist/src/Validator.js.map +1 -1
  32. package/dist/src/index.d.ts +2 -3
  33. package/dist/src/index.d.ts.map +1 -1
  34. package/dist/src/index.js +2 -3
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/types.d.ts +0 -8
  37. package/dist/src/types.d.ts.map +1 -1
  38. package/dist/src/types.generated.d.ts +820 -636
  39. package/dist/src/types.generated.d.ts.map +1 -1
  40. package/dist/src/types.generated.js.map +1 -1
  41. package/dist/src/types.js +1 -1
  42. package/dist/src/types.js.map +1 -1
  43. package/package.json +3 -3
  44. package/plurnk.md +1 -8
  45. package/dist/schema/ApplicationOperationEvent.json +0 -27
  46. package/dist/schema/CapabilityDescriptor.json +0 -28
  47. package/dist/schema/CapabilityPolicy.json +0 -22
  48. package/dist/schema/CapabilityProjection.json +0 -14
  49. package/dist/schema/CapabilitySelector.json +0 -29
  50. package/dist/src/CapabilityAdmission.d.ts +0 -11
  51. package/dist/src/CapabilityAdmission.d.ts.map +0 -1
  52. package/dist/src/CapabilityAdmission.js +0 -108
  53. package/dist/src/CapabilityAdmission.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # @plurnk/plurnk-contracts
2
2
 
3
- The single authority for PLURNK's model-facing language contract, its AST,
4
- shared schemas and types, runtime-neutral Problems, operation results,
5
- Notices, and text coordinates. See SPEC {§contract-representations}.
3
+ The single authority for PLURNK's session operating card, universal `mcp` wire
4
+ tool (`MCP_WIRE_TOOL`), statement AST, shared schemas and types,
5
+ runtime-neutral Problems, operation results, Notices, and text coordinates. See
6
+ SPEC {§contract-representations}.
6
7
 
7
8
  ## Install
8
9
 
@@ -16,17 +17,16 @@ Requires Node.js 26 or newer.
16
17
 
17
18
  | Surface | Authority or public artifact |
18
19
  |---------------------------------|------------------------------------------------------|
19
- | Concise model language teaching | [`plurnk.md`](plurnk.md) |
20
+ | Session operating card | [`plurnk.md`](plurnk.md) |
20
21
  | Stable behavioral contract | [`SPEC.md`](SPEC.md) |
21
- | Accepted language syntax | `SPEC.md` ({§operation-fences}); implemented by `@plurnk/plurnk-parser` |
22
+ | Wire `mcp` tool & statement AST | `SPEC.md` ({§mcp-expressions}); implemented by `@plurnk/plurnk-parser` |
22
23
  | Shared wire shapes | `schema/*.json` |
23
24
  | JavaScript and TypeScript API | `@plurnk/plurnk-contracts` |
24
25
  | Published JSON Schemas | `@plurnk/plurnk-contracts/schema/*.json` |
25
26
 
26
27
  JSON Schema owns shared wire shapes, generated TypeScript projects those
27
- shapes, and `@plurnk/plurnk-parser` owns accepted Heredoc Code Mode syntax and
28
- Reflective Emission Normalization (RENO). See SPEC
29
- {§contract-representations}.
28
+ shapes, and `@plurnk/plurnk-parser` owns `mcp` tool-call lowering, statement
29
+ parsing, and canonical serialization. See SPEC {§contract-representations}.
30
30
 
31
31
  ## Parser
32
32
 
@@ -66,7 +66,7 @@ npm run test:installation
66
66
 
67
67
  Generated schema-type and distribution artifacts are rebuilt by `npm run build`.
68
68
  Change the owning schema rather than editing generated output directly; the
69
- grammar and its generated parser live in `@plurnk/plurnk-parser`.
69
+ MCP expression parser lives in `@plurnk/plurnk-parser`.
70
70
 
71
71
  ## License
72
72
 
package/SPEC.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  ## §contract-representations 1. Overview and schema representations
4
4
 
5
- `@plurnk/plurnk-contracts` is the single authority for PLURNK's model-facing language specification, JSON Schemas (`schema/*.json`), generated TypeScript types, and runtime-neutral wire envelopes. `@plurnk/plurnk-parser` implements the language it specifies ({§parser-build}).
5
+ `@plurnk/plurnk-contracts` is the single authority for PLURNK's model-facing contract, JSON Schemas (`schema/*.json`), generated TypeScript types, and runtime-neutral wire envelopes. `@plurnk/plurnk-parser` implements lowering and serialization between wire `mcp` tool calls, protocol statements, and `PlurnkStatement` ASTs ({§parser-build}).
6
6
 
7
7
  | Surface | Canonical export or artifact |
8
8
  | --- | --- |
9
9
  | AST, validators, Problems, results, Notices, text regions and extents | `@plurnk/plurnk-contracts` |
10
- | Capability admission and approval ownership | `CapabilityPolicy`, `SessionOwner`, `ProposalPolicy`, `PROPOSAL_POLICIES` |
10
+ | Approval ownership and proposal policies | `SessionOwner`, `ProposalPolicy`, `PROPOSAL_POLICIES` |
11
11
  | Durable effort and model catalog discovery | `Effort`, `EFFORTS`, `ModelRoute`, `ModelCatalogQuery`, `ModelCatalogPage`, `ModelReadiness` |
12
12
  | Stopped-world proposals and client interactions | `ProposalDisposition`, `ProposalProjection`, `ClientInteractionRequest`, `ClientInteractionProjection`, `ClientInteractionResolution` |
13
13
  | Client capability presentation | `ClientDisplayCapabilities` |
@@ -16,59 +16,45 @@
16
16
  | Session Functionality lifecycle projections | `FunctionalityProvenance`, `FunctionalityCandidate`, `FunctionalityDiscoverQuery`, `FunctionalityDiscoverResult`, `FunctionalityDefinitionState`, `FunctionalityListResult`, `FunctionalityMutationResult` |
17
17
  | ACP discovery manifest | `AcpDiscovery` |
18
18
  | JSON Schemas and JSON rendering | `@plurnk/plurnk-contracts/schema/*.json`, `renderJsonResult`, `formatJsonDocument` |
19
- | Model language reference | `plurnk.md` in the package |
19
+ | Session operating card | `plurnk.md` in the package |
20
20
 
21
21
  ```mermaid
22
22
  flowchart LR
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"]
23
+ wire["Wire mcp tool calls<br/>{ server, tool, arguments, aside? }"]
24
+ stmtSrc["Protocol & ops:// statements<br/>&lt;server&gt;.&lt;tool&gt;({ ... })"]
25
+ parser["Lowering & serialization<br/>McpExpressions.ts · ExpressionSerializer.ts"]
26
26
  ast["Typed, serializable AST<br/>PlurnkStatement"]
27
- runtime["Runtime owners<br/>execution & ops:// reflection"]
28
- canon --> syntax
29
- canon --> free
30
- free --> syntax
31
- syntax --> ast
27
+ runtime["Runtime owners<br/>execution, replay & ops:// reflection"]
28
+ wire -->|"lowerMcpCall"| parser
29
+ stmtSrc -->|"parseStatements"| parser
30
+ parser --> ast
32
31
  ast --> runtime
33
- ast -->|"PlurnkParser.stringify"| syntax
32
+ ast -->|"toMcpCall"| wire
33
+ ast -->|"stringify"| stmtSrc
34
34
  ```
35
35
 
36
36
  | Layer | Owner or artifact | Contract |
37
37
  | --- | --- | --- |
38
38
  | Stable current law | `SPEC.md` | Owns invariants and boundaries; forge issues retain history |
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 |
39
+ | Session operating card | `plurnk.md` | Minimal operating guidance injected into `definition` |
40
+ | Lowering & serialization | `McpExpressions.ts`, `CallExpressionParser.ts`, `OptionCoercion.ts`, `StatementLowering.ts`, `ExpressionSerializer.ts`, `MatcherSyntax.ts`, `ScopeSyntax.ts`, `TargetSyntax.ts` | Lowers wire `mcp` tool calls (`lowerMcpCall`), inbound `/mcp` tool calls (`lowerToolCall`), and client/internal MCP statement blocks (`parseStatements`) into `PlurnkStatement` ASTs, projects statements to `McpToolCallPayload` (`toMcpCall`), and renders canonical MCP expressions for `ops://` (`stringify`) |
41
41
  | Typed admission | `PlurnkStatement` AST | Produces JSON-serializable unions and validates deterministic path/scope/matcher syntax |
42
42
  | Shared wire data | `schema/*.json` | Defines runtime-neutral data shapes projected into generated TypeScript |
43
43
  | Stateful behavior | consuming runtime | Resolves addresses, permissions, selection arithmetic, effects, and lifecycle |
44
44
 
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
+ - **Authoritative representations**: JSON Schema is authoritative for shared wire data shapes; TypeScript types are generated from `schema/*.json`; `@plurnk/plurnk-parser` is authoritative for lowering `mcp` tool calls and statement blocks into `PlurnkStatement` ASTs.
46
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`.
47
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.
48
48
 
49
- ### §capability-policy-cascade Capability admission, proposals, and model catalog
50
-
51
- ```mermaid
52
- flowchart LR
53
- S["Service CapabilityPolicy"] & W["Workspace CapabilityPolicy"] --> E["Effective intersection (deny > only > allow)"]
54
- E --> D{"Admitted?"}
55
- D -->|no| R["403 capability-denied"]
56
- D -->|yes, allow match| A["Auto-accepted execution"]
57
- D -->|yes, gated| P["ProposalDisposition (review | accept | reject)"]
58
- ```
49
+ ### §proposal-and-model-contracts Proposals, effort, and model catalog
59
50
 
60
51
  | Contract | Shape invariant | Runtime responsibility |
61
52
  | --- | --- | --- |
62
- | `CapabilityDescriptor` | One routed operation demand with its operation, access class (`read \| write \| exec \| network \| session \| interact`), resource/runtime/tool coordinates, and declared traits | Derive every demand before dispatch |
63
- | `CapabilityPolicy` | Exact `allow`/`only`/`deny` selectors; omitted `only` is unrestricted, present empty `only` denies all, and `allow` pre-approves admitted proposals | Intersect service and workspace policies |
64
- | `CapabilityProjection` | Durable `service`, client-mutable `workspace`, and normalized `effective` policies | Expose effective authority without storing session/loop policy copies |
65
- | `ProposalPolicy` | `review`, `accept`, or `reject` (`PROPOSAL_POLICIES`) | Read the server's disposition knob at the proposal boundary |
53
+ | `ProposalPolicy` | `review`, `accept`, or `reject` (`PROPOSAL_POLICIES`) | Read the server or workspace approval disposition at the proposal boundary |
66
54
  | `ProposalDisposition` | Review, or automatic accept/reject with optional outcome | Select once for the pending gate |
67
- | `ProposalProjection` | Identity, review target, body/attrs, owner, capability selector, ACP v2 subject, stale signal, disposition | One validated projection for live delivery and reconnect |
55
+ | `ProposalProjection` | Identity, review target, body/attrs, owner, ACP v2 subject, stale signal, disposition | One validated projection for live delivery and reconnect |
68
56
 
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.
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.
71
- - **Proposals and session ownership**: `ProposalPolicy` (`review | accept | reject`) and `SessionOwner` (`address`, `clientTools`, `interactive`) govern stopped-world approval after capability admission succeeds.
57
+ - **Proposals and session ownership**: `ProposalPolicy` (`review | accept | reject`) and `SessionOwner` (`address`, `tools`, `interactive`) govern stopped-world approval and standing `allow_always` / `reject_always` permission decisions.
72
58
  - **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).
73
59
 
74
60
  ### §provider-request-accounting Client interactions and provider request accounting
@@ -88,59 +74,68 @@ flowchart LR
88
74
 
89
75
  ---
90
76
 
91
- ## §operation-fences 2. Canonical Heredoc Code Mode statement form
92
-
93
- ```ts
94
- plurnk.<op>({ ... }) // optional aside
95
-
96
- <service>.<tool>({ ... })
77
+ ## §mcp-expressions 2. Universal `mcp` wire tool and internal statement form
78
+
79
+ ```json
80
+ {
81
+ "name": "mcp",
82
+ "parameters": {
83
+ "type": "object",
84
+ "required": ["server", "tool", "arguments"],
85
+ "properties": {
86
+ "server": { "type": "string" },
87
+ "tool": { "type": "string" },
88
+ "arguments": { "type": "object", "additionalProperties": true },
89
+ "aside": { "type": "string", "description": "Optional terse intent note." }
90
+ },
91
+ "additionalProperties": false
92
+ }
93
+ }
97
94
  ```
98
95
 
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.
96
+ - **Universal `mcp` wire tool**: Every emission-capable model turn exposes a single native wire tool named `mcp` taking `{ server, tool, arguments, aside? }`. `plurnk` is the built-in MCP server (`read`, `find`, `edit`, `copy`, `move`, `kill`, `note`, `work`, `fork`, `bare`, `send`, `done`, `fail`, `wait`, runtime tools `sh`, `js`, `python3`, and Functionality tools `env`, `mcp`, `members`, `personas`, `schedule`, `skills`, `question`). External MCP servers are peer `server` names (`server: "<mcp>"`, `tool: "<tool>"`).
97
+ - **Statement protocol and `ops://` representation**: Client-authored `/script` blocks and `ops://` turn-source archives use `<server>.<tool>({ ... }) // aside` statement syntax (`gitea["issue-read"]({ ... })` for non-identifier tool names), parsed by `PlurnkParser.parseStatements` and rendered by `PlurnkParser.stringify`.
102
98
 
103
- ### §fence-pairing Statement boundaries, RENO admission tolerances, and reflective rendering
99
+ ### §expression-boundaries Wire tool lowering, standalone runtime routing, and replay projection
104
100
 
105
101
  | Rule | Contract |
106
102
  | --- | --- |
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>(...)`, an unprefixed core/runtime verb, a registered `<service>.<tool>(...)`, or a RENO JSON/XML/Pythonic tool-call descriptor inside a balanced Markdown code fence (`ts`, `js`, `python`, `sh`, `bash`, `json`, `xml`, `tool_call`, `plurnk`, or unlabeled, pairing inline `<<<TAG ... TAG` heredocs before matching the outer fence closer), the parser normalizes the statement silently under RENO while preserving non-tool prose fences (`console.log(...)`, `print(...)`, nameless JSON literals, generic XML) as outside text. |
109
- | Native, markup, bare-verb, and runtime-alias recovery | 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; 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; unprefixed core/runtime calls (`read({ ... })`, `edit({ ... })`, `done()`, `env({ ... })`) lower to `plurnk.<op>`; and built-in runtime aliases (`ts`/`javascript`/`typescript`/`node` -> `js`, `bash`/`shell` -> `sh`, `python`/`py` -> `python3` when not shadowed by an explicit executor) normalize to their canonical runtime. |
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 an inline `<<<EOF\n...\nEOF` heredoc (stepping `EOF1`, `EOF2`, … when the string contains the delimiter). |
103
+ | `lowerMcpCall` envelope lowering | `PlurnkParser.lowerMcpCall({ name, arguments }, options)` requires `name === "mcp"`, decodes object or JSON-stringified `arguments`, resolves `server` and `tool` (tolerating `function` for `tool` and `args`/`params` or hoisted sibling keys for `arguments`), and dispatches to `lowerToolCall` on the `"model"` tier. |
104
+ | Standalone runtime default tool | Passing `server: "sh" \| "js" \| "python3"` (or a built-in alias `bash`/`shell` $\to$ `sh`, `ts`/`javascript`/`typescript`/`node` $\to$ `js`, `python`/`py` $\to$ `python3` when not shadowed by an explicit executor) routes any non-path `tool` name directly to that standalone runtime (`text` / `command` / `code`), while path-shaped `tool` names (`*.py`, `dir/script.sh`) bind `script`. |
105
+ | Case-insensitive method recovery | Uppercase or mixed-case core/runtime tool names recover silently to their lowercase canonical tool name. |
106
+ | Structured replay & `ops://` serialization | `PlurnkParser.toMcpCall(statement)` projects any `PlurnkStatement` to `{ server, tool, arguments, aside? }` for structured `assistant` `toolCalls` replay; `PlurnkParser.stringify(statements)` renders JSON-escaped canonical `<server>.<tool>({ ... }) // aside` lines for `ops://` storage. |
112
107
 
113
108
  ### §slot-order Argument shapes, target groups, and endpoint options
114
109
 
115
110
  | Construct | Contract |
116
111
  | --- | --- |
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")`). |
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. |
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>**`); in model-turn RENO parsing, `description`, `explanation`, or `comment` string options on core operations and built-in executors promote to `aside` when no explicit `aside` or trailing `// aside` is present. |
112
+ | Object and positional argument forms | Core operations accept their canonical `{ ... }` options object (`{ path, range?, pattern?, text?, ... }`) as well as positional shorthands on `parseStatements`. |
113
+ | Target groups and multi-target lists | `read`, `find`, and `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. `send`, `done`, and `fail` tolerate `target`/`targets`/`to` as a non-empty array of URI strings or comma/pipe-separated URI list (keeping message-reply URI lists on one statement so the body renders and weighs once, fanning out non-message `send` recipient lists per target, and refusing empty arrays or non-string targets at parse time rather than coercing to `null`; `work` and `fork` likewise refuse non-string targets). |
114
+ | `note` annotation on retrievals | Providing `note` on `read` or `find` emits a preceding `note` statement before the retrieval(s). |
115
+ | Endpoint and message options | `headers` (`Record<string, string>`) passes HTTP(S) request headers on `read`, `find`, `edit`, `send`, `kill`, and `copy`/`move` (`fromHeaders`/`toHeaders`); `remote` (`boolean`) confirms remote HTTP `DELETE` on `kill`; `attachments` (`string[]`) attaches resources to `send`, `done`, and `fail`. Unknown option keys (outside benign metadata and model-tier envelope/commentary echoes) are refused with a parser diagnostic. |
116
+ | Operation aside | `aside` on `mcp` tool calls (or trailing `// aside` on `parseStatements`, plus `description`/`explanation`/`comment`/`reason`/`what`/`why`/`intent` options on the model tier when `aside` is absent) is captured into `aside` (`string` or `null`). |
122
117
 
123
118
  ---
124
119
 
125
120
  ## §op-shapes 3. Per-operation semantics and dispositions
126
121
 
127
- | Call | Target field | Scope / matcher / endpoint fields | Content / payload fields |
122
+ | Server & tool | Target field | Scope / matcher / endpoint fields | Content / payload fields |
128
123
  | --- | --- | --- | --- |
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` |
134
- | `plurnk.<functionality>` | tool name (`env`, `mcp`, `members`, `personas`, `schedule`, `skills`, `question`) | none | JSON arguments object |
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`) |
124
+ | `plurnk` / `find` | required `path` / `paths` | optional `range`, `pattern`, `headers` | optional `note` normalized to preceding `note` |
125
+ | `plurnk` / `read` | required `path` / `paths` | optional `range`, `pattern`, `headers` | optional `note` normalized to preceding `note` |
126
+ | `plurnk` / `edit` | required `path` | `range` or `pattern` or `oldText`/`newText` (`old`/`new`, `find`/`replace`, `original`) or `edits` for existing target; `text` alone creates; optional `headers` | `text` (or tolerated `content`, `replacement`, `replace`, `newText`, `new`, `body`), or `edits` array |
127
+ | `plurnk` / `copy`, `move` | required `from` and `to` | optional `fromRange` / `toRange`, `fromHeaders` / `toHeaders` | none |
128
+ | `plurnk` / `sh`, `js`, `python3` | optional `script`, `cwd` | none | `text` (or tolerated `code` / `command` / `cmd` / `body` / `source` / `prompt`), optional `args` |
129
+ | `plurnk` / `<functionality>` | tool name (`env`, `mcp`, `members`, `personas`, `schedule`, `skills`, `question`) | none | JSON arguments object |
130
+ | `<server>` / `<tool>` | external MCP `<server>` and `<tool>` | optional `range` | JSON arguments object |
131
+ | `plurnk` / `bare` | none | none | required `text` (or tolerated `prompt` / `body` / `content` / `message`) |
132
+ | `plurnk` / `work`, `fork` | optional `target` (`session://name`) | optional `persona`, `model`, `effort` | required `text` (or tolerated `prompt` / `body` / `content` / `message`) |
133
+ | `plurnk` / `kill` | required `path` / `paths` | optional `range`, `pattern`, `remote`, `headers` | optional `note` distillation on `log:///` |
134
+ | `plurnk` / `send` | optional `target` recipient (caller aliases `user`/`client`/`human`/`operator`/`caller` normalize to `null`) | optional `headers`, `attachments` | required `text` message body |
135
+ | `plurnk` / `done` | optional `target` (`message://`; caller aliases normalize to `null`) | optional `attachments` | `text` final deliverable (required in tool schema; parser tolerates empty to resolve silently) |
136
+ | `plurnk` / `fail` | optional `target` (`message://`; caller aliases normalize to `null`) | optional `attachments` | `text` final failure explanation (required in tool schema; parser tolerates empty to cancel silently) |
137
+ | `plurnk` / `note` | none | none | `text` conclusions, findings, and plans |
138
+ | `plurnk` / `wait` | none | optional `seconds` | none (tolerated `text` normalizes to `aside`) |
144
139
 
145
140
  - **Retrieval annotations**: Nonblank `note` options on `find` or `read` normalize into a preceding `note` statement.
146
141
  - **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).
@@ -152,34 +147,34 @@ plurnk.<op>({ ... }) // optional aside
152
147
  ## §path-syntax 4. Target and path grammar
153
148
 
154
149
  - **URL vs. local path decomposition**: Targets matching `[a-z][a-z0-9+._-]*://` decompose via WHATWG `URL` into `UrlPath` (preserving lossless serialized `query` and `fragment`); all other targets become `LocalPath { kind: "local", raw, fragment? }`.
155
- - **Parenthesis escaping**: An unescaped depth-zero `)` closes `(path)`; balanced parentheses are tolerated and `\\`, `\(`, `\)` provide lossless escaping via `PathSyntax`.
150
+ - **Parenthesis tolerance and backslash escaping**: Literal parentheses render verbatim in targets and receipts; `%28`/`%29` in pathnames decode to `(` / `)`, and `\\`, `\(`, `\)` unescape losslessly via `PathSyntax`.
156
151
  - **Glob classification and session names**: `PathSyntax.hasGlob` and `globMagicIndex` classify glob metacharacters vs. exact paths. `SESSION_NAME` (`[A-Za-z0-9][A-Za-z0-9_-]{0,62}`) validates minted session authority names (excluding `_plurnk`).
157
152
 
158
153
  ---
159
154
 
160
155
  ## §matcher-prefix-claims 5. Bulk pattern matching and scope markers
161
156
 
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):
157
+ `find`, `read`, `kill`, and `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
158
 
164
159
  | Prefix | Dialect | Validation & tolerance |
165
160
  | --- | --- | --- |
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) |
161
+ | `//` | `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, and vacuous `/text()` after `@attr` steps) |
167
162
  | `/` or `^` | `regex` | ECMAScript `RegExp` (escaped pipe is literal, unescaped pipe is alternation); tolerates PCRE `\A`/`\z`/`\Z` anchors, trailing `-flags`, `/~.../` mixed prefix, unbalanced unescaped `(`, `)`, or `[`, and glob-shaped `/*text*/` |
168
163
  | `$` | `jsonpath` | Validated with RFC 9535 `json-p3` |
169
164
  | `~` | `fulltext` | Single-line FTS5 query string |
170
165
  | `&` | `graph` | `&symbol`, `&<symbol`, or `&>symbol` relation query |
171
- | none | `glob` | Fallback shell glob or single/multiline literal substring (`<<<EOF...EOF`) |
166
+ | none | `glob` | Fallback shell glob or single/multiline literal substring |
172
167
 
173
168
  - **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
- - **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.
169
+ - **Statement recovery and argument tolerances**: Statement errors fail only the offending call while admitting valid sibling calls; an inline `<L,M>` range written inside `path<L,M>` is lifted on the model tier.
170
+ - **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 on the model tier.
176
171
 
177
172
  ---
178
173
 
179
174
  ## §whitespace-contract 6. Parser architecture, whitespace, and public API
180
175
 
181
- - **Statement scanning and outside text**: `PlurnkParser.parse` partitions a model turn into ordered `statement`, `error`, and outside `text` items (`emptyTurn` is `true` when no `statement` or `error` items are produced).
182
- - **Tier entry points and runtime-neutral root**: `PlurnkParser.parse` (model turn), `PlurnkParser.parseStatements` (protocol statements), and `PlurnkParser.stringify` (canonical Code Mode rendering) are exported by `@plurnk/plurnk-parser`. The `@plurnk/plurnk-contracts` root is closed (verified by `src/index.test.ts`) and browser/DOM runtime-neutral (`tsconfig.browser.json`), with Node HTTP host types isolated in `@plurnk/plurnk-contracts/port`.
176
+ - **Structured lowering and statement parsing**: `PlurnkParser.lowerMcpCall` lowers a structured `mcp` wire tool call into `statement` and `error` items; `PlurnkParser.parseStatements` parses client/internal statement blocks without prose interleaving.
177
+ - **Tier entry points and runtime-neutral root**: `PlurnkParser.lowerMcpCall` (model wire tool call), `PlurnkParser.lowerToolCall` (inbound `/mcp` tool call), `PlurnkParser.parseStatements` (protocol/internal statements), `PlurnkParser.toMcpCall` (structured `mcp` tool-call projection), and `PlurnkParser.stringify` (canonical statement rendering) are exported by `@plurnk/plurnk-parser`. The `@plurnk/plurnk-contracts` root is closed (verified by `src/index.test.ts`) and browser/DOM runtime-neutral (`tsconfig.browser.json`), with Node HTTP host types isolated in `@plurnk/plurnk-contracts/port`.
183
178
 
184
179
  ---
185
180
 
@@ -213,8 +208,8 @@ plurnk.<op>({ ... }) // optional aside
213
208
 
214
209
  | Projection / Helper | Contract |
215
210
  | --- | --- |
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? })`. |
211
+ | `ApplicationPort` | Transport-neutral interface in `@plurnk/plurnk-contracts/port` driving workspaces, sessions, loops (`runLoop` with causal `source`, `attachments`, `envelope`), operations, proposals, client interactions, filtered discrete event subscriptions (`subscribeToEvents(handler, filter?)` and `replayNotifications({ lastEventId, filter? })` under `notificationEpoch`), and in-process sub-turn runtime streaming (`subscribeToRuntimeStream(handler)` over `APPLICATION_RUNTIME_STREAM_EVENTS`). |
212
+ | `DaemonNotification` / `NotificationFilter` | Closed discriminated union over the 16 discrete `DAEMON_NOTIFICATION_EVENTS` (`{ id, event, timestamp, workspaceId, sessionId, data }`, validated by `Validator.assertDaemonNotification` against `DaemonNotificationEnvelope.json`), constructed by `toDaemonNotification` and filtered at source by `matchesNotificationFilter(notification, { events?, workspaceId?, sessionId? })`. `isRuntimeTelemetryNotice` separates internal turn/lifecycle/derivation telemetry onto `runtime/telemetry`. |
218
213
  | `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 }`. |
219
214
  | `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. |
220
215
  | `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). |
@@ -223,7 +218,7 @@ plurnk.<op>({ ... }) // optional aside
223
218
 
224
219
  ---
225
220
 
226
- ## §parse-recovery 8. Reflective Emission Normalization (RENO), tolerances, and error shapes
221
+ ## §parse-recovery 8. Argument tolerances and error shapes
227
222
 
228
223
  `PlurnkParseError` is a JSON-serializable `Error` carrying `{ line, column, source: "lexer" | "parser" | "visitor", severity: "error" | "warning", recovery?, attempt?, operationOmitted }`:
229
224
 
@@ -236,6 +231,6 @@ plurnk.<op>({ ... }) // optional aside
236
231
 
237
232
  | Mechanism | Contract |
238
233
  | --- | --- |
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; and on `edit`, normalizes unreadable single-line literal code patterns starting with `//`, `$`, `&`, or `/` (when an interior `/` is followed by non-flag literal text rather than `/pattern/flags`) into exact literal matchers. |
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. |
234
+ | Working-form recovery & attempt | Every hard error (`severity: "error"`) populates `recovery` with the working `mcp({ server, tool, arguments })` form of the refused construct and `attempt` (`{ text, verb }`) with the refused call's source text; `operationOmitted` marks unexecuted calls. Each malformed call produces at most one hard error. |
235
+ | 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- or pipe-separated `/pattern/` lists (including `/branch1\|/branch2/` where each top-level alternation prefixes `/`) on `find` and `read` into alternation while refusing numeric/open sed ranges (`/a/,+N`, `/a/,-1`, `/a/,`) and mutating `/a/,/b/` ranges; escapes unescaped interior `/` inside closed `/pattern/flags` matchers on `find` and `read`; diagnoses trailing text after `/pattern/flags`; recovers unclosed `/pattern` at EOL; and on `edit`, normalizes unreadable single-line literal code patterns starting with `//`, `$`, `&`, or `/` (when an interior `/` is followed by non-flag literal text rather than `/pattern/flags`) into exact literal matchers. |
236
+ | Argument tolerances | Deterministically canonicalizes near-miss wire tool names (`mcp__<server>__<tool>`, `<server>.<tool>`, `<server>__<tool>`, or bare `plurnk` tool/builtin-executor names), `mcp` payloads with dotted `tool: "<server>.<tool>"` or omitted `server: "plurnk"`, nested tool calls routed through `plurnk.mcp` (`{ server\|name\|alias, tool\|function, arguments? }` without MCP server configuration keys), DSML `<|DSML|parameter name="...">` and XML `<parameter=...>` / `<tool_call><function=...>` / trailing-`>` invoke-boundary leaks inside `server` or `tool`, echoed `tool`/`function` or benign metadata keys (`tags`, `keep`, `kind`, `status`, `budget`, `maxLines`, `max_lines`, `context`) on the model tier, fallback `id` targets when canonical target keys are absent on model-tier `read`/`find`/`edit`/`kill`, `session`/`stream`/`process` target aliases on `kill`, `old`/`find`/`original` and `new`/`replace` literal replacement aliases on `edit`, `note` body fallback on `done`/`fail`, singular `line` range aliases, `wait` `stream` and `timeoutMs`/`timeout_ms`/`ms` options, pattern-shaped `range` strings when `pattern` is omitted or empty, `#<channel>`-shaped `range` strings (`/^#[A-Za-z][A-Za-z0-9_.-]*$/u`) when `channel` is omitted or empty on the model tier, and separate `channel: "#<name>" \| "<name>"` options on resource-targeting operations (folded onto fragmentless target paths as `path#channel`); lifts inline `<L,M>` ranges from `path<L,M>` strings with a warning; recovers bare `edit` anchors (`@abcde`), combined `42<@abcde>` ranges, quoted range strings (`"\"-1,1,-1,1\""`), `L<N>` / `L<N>-L<M>` and `#<N>,<M>` line markers, numeric ranges with a stray trailing `@` (`"1240,1242@"`), `@hash,hash` pairs missing the second `@` (`"@qAVg2,qAVg2"`), 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"`) while refusing ambiguous `line:col` ranges with explicit 4-coordinate `startLine,startCol,endLine,endCol` (`endCol` exclusive) recovery; and unwraps nested parameter wrappers (`params`, `parameters`, `arguments`, `args`, `input`, `options`, `properties`). |