@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.
- package/README.md +9 -9
- package/SPEC.md +78 -83
- package/dist/schema/DaemonNotificationEnvelope.json +555 -0
- package/dist/schema/McpServerDefinition.json +1 -1
- package/dist/schema/PlurnkStatement.json +24 -0
- package/dist/schema/ProposalProjection.json +0 -4
- package/dist/src/Application.d.ts +22 -1
- package/dist/src/Application.d.ts.map +1 -1
- package/dist/src/Application.js +480 -15
- package/dist/src/Application.js.map +1 -1
- package/dist/src/ApplicationNotifications.d.ts +59 -28
- package/dist/src/ApplicationNotifications.d.ts.map +1 -1
- package/dist/src/ApplicationNotifications.js +40 -8
- package/dist/src/ApplicationNotifications.js.map +1 -1
- package/dist/src/ApplicationPort.d.ts +26 -7
- package/dist/src/ApplicationPort.d.ts.map +1 -1
- package/dist/src/ApplicationPort.js.map +1 -1
- package/dist/src/ApplicationStream.d.ts +4 -0
- package/dist/src/ApplicationStream.d.ts.map +1 -1
- package/dist/src/ApplicationStream.js.map +1 -1
- package/dist/src/LogRow.d.ts +1 -1
- package/dist/src/LogRow.js +1 -1
- package/dist/src/LogRow.js.map +1 -1
- package/dist/src/PathSyntax.d.ts +0 -1
- package/dist/src/PathSyntax.d.ts.map +1 -1
- package/dist/src/PathSyntax.js +1 -4
- package/dist/src/PathSyntax.js.map +1 -1
- package/dist/src/Validator.d.ts +3 -3
- package/dist/src/Validator.d.ts.map +1 -1
- package/dist/src/Validator.js +8 -16
- package/dist/src/Validator.js.map +1 -1
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +0 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.generated.d.ts +820 -636
- package/dist/src/types.generated.d.ts.map +1 -1
- package/dist/src/types.generated.js.map +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +3 -3
- package/plurnk.md +1 -8
- package/dist/schema/ApplicationOperationEvent.json +0 -27
- package/dist/schema/CapabilityDescriptor.json +0 -28
- package/dist/schema/CapabilityPolicy.json +0 -22
- package/dist/schema/CapabilityProjection.json +0 -14
- package/dist/schema/CapabilitySelector.json +0 -29
- package/dist/src/CapabilityAdmission.d.ts +0 -11
- package/dist/src/CapabilityAdmission.d.ts.map +0 -1
- package/dist/src/CapabilityAdmission.js +0 -108
- 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
|
|
4
|
-
|
|
5
|
-
Notices, and text coordinates. See
|
|
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
|
-
|
|
|
20
|
+
| Session operating card | [`plurnk.md`](plurnk.md) |
|
|
20
21
|
| Stable behavioral contract | [`SPEC.md`](SPEC.md) |
|
|
21
|
-
|
|
|
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
|
|
28
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
|
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
|
-
|
|
|
19
|
+
| Session operating card | `plurnk.md` in the package |
|
|
20
20
|
|
|
21
21
|
```mermaid
|
|
22
22
|
flowchart LR
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
wire["Wire mcp tool calls<br/>{ server, tool, arguments, aside? }"]
|
|
24
|
+
stmtSrc["Protocol & ops:// statements<br/><server>.<tool>({ ... })"]
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 -->|"
|
|
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
|
-
|
|
|
40
|
-
|
|
|
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
|
|
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
|
-
### §
|
|
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
|
-
| `
|
|
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,
|
|
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
|
-
- **
|
|
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
|
-
## §
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
- **
|
|
100
|
-
- **
|
|
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
|
-
### §
|
|
99
|
+
### §expression-boundaries Wire tool lowering, standalone runtime routing, and replay projection
|
|
104
100
|
|
|
105
101
|
| Rule | Contract |
|
|
106
102
|
| --- | --- |
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
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
|
|
118
|
-
| Target groups and multi-target lists | `
|
|
119
|
-
| `note` annotation on retrievals | Providing `note` on `
|
|
120
|
-
| Endpoint and message options | `headers` (`Record<string, string>`) passes HTTP(S) request headers on `
|
|
121
|
-
| Operation aside |
|
|
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
|
-
|
|
|
122
|
+
| Server & tool | Target field | Scope / matcher / endpoint fields | Content / payload fields |
|
|
128
123
|
| --- | --- | --- | --- |
|
|
129
|
-
| `plurnk
|
|
130
|
-
| `plurnk
|
|
131
|
-
| `plurnk
|
|
132
|
-
| `plurnk
|
|
133
|
-
| `plurnk
|
|
134
|
-
| `plurnk
|
|
135
|
-
| `<
|
|
136
|
-
| `plurnk
|
|
137
|
-
| `plurnk
|
|
138
|
-
| `plurnk
|
|
139
|
-
| `plurnk
|
|
140
|
-
| `plurnk
|
|
141
|
-
| `plurnk
|
|
142
|
-
| `plurnk
|
|
143
|
-
| `plurnk
|
|
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**:
|
|
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
|
-
`
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
- **
|
|
182
|
-
- **Tier entry points and runtime-neutral root**: `PlurnkParser.
|
|
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,
|
|
217
|
-
| `DaemonNotification` / `NotificationFilter` | Closed discriminated union over the
|
|
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.
|
|
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
|
|
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
|
|
241
|
-
|
|
|
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`). |
|