@plurnk/plurnk-contracts 1.8.0 → 1.9.1

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 (84) hide show
  1. package/SPEC.md +122 -11
  2. package/dist/conformance/agui-v1.json +541 -0
  3. package/dist/schema/A2aAgentDefinition.json +44 -0
  4. package/dist/schema/AcpPlan.json +63 -0
  5. package/dist/schema/AguiClientConformance.json +74 -0
  6. package/dist/schema/AguiConformanceKit.json +111 -0
  7. package/dist/schema/AguiDiscovery.json +70 -0
  8. package/dist/schema/ClientDisplayCapabilities.json +1 -1
  9. package/dist/schema/ClientInteractionProjection.json +2 -2
  10. package/dist/schema/ClientInteractionRequest.json +1 -1
  11. package/dist/schema/ClientInteractionResolution.json +1 -1
  12. package/dist/schema/ClientStatement.json +7 -7
  13. package/dist/schema/EntryReadResult.json +2 -2
  14. package/dist/schema/FunctionalityCandidate.json +33 -0
  15. package/dist/schema/FunctionalityDefinitionState.json +33 -0
  16. package/dist/schema/FunctionalityDiscoverQuery.json +16 -0
  17. package/dist/schema/FunctionalityDiscoverResult.json +15 -0
  18. package/dist/schema/FunctionalityListResult.json +15 -0
  19. package/dist/schema/FunctionalityMutationResult.json +16 -0
  20. package/dist/schema/LineMarker.json +1 -1
  21. package/dist/schema/LoopFlags.json +1 -1
  22. package/dist/schema/MatcherBody.json +1 -1
  23. package/dist/schema/McpConfigurationOverlay.json +1 -1
  24. package/dist/schema/McpServerDefinition.json +1 -1
  25. package/dist/schema/McpServerOptions.json +8 -8
  26. package/dist/schema/ModelCatalogPage.json +2 -2
  27. package/dist/schema/ModelCatalogQuery.json +1 -1
  28. package/dist/schema/ModelReadiness.json +1 -1
  29. package/dist/schema/ModelRoute.json +1 -1
  30. package/dist/schema/Notice.json +1 -1
  31. package/dist/schema/OperationResult.json +3 -3
  32. package/dist/schema/ParsedPath.json +1 -1
  33. package/dist/schema/Plan.json +52 -0
  34. package/dist/schema/PlurnkStatement.json +9 -9
  35. package/dist/schema/Position.json +1 -1
  36. package/dist/schema/ProblemDetails.json +1 -1
  37. package/dist/schema/ProposalDisposition.json +1 -1
  38. package/dist/schema/ProposalProjection.json +5 -6
  39. package/dist/schema/ProviderAccounting.json +3 -3
  40. package/dist/schema/ProviderCost.json +1 -1
  41. package/dist/schema/ProviderRequestAccounting.json +3 -3
  42. package/dist/schema/ProviderUsage.json +1 -1
  43. package/dist/schema/RangeExtent.json +1 -1
  44. package/dist/schema/ReasoningPolicy.json +1 -1
  45. package/dist/schema/ResourceSelection.json +3 -3
  46. package/dist/schema/SendBody.json +1 -1
  47. package/dist/schema/SkillDefinition.json +26 -0
  48. package/dist/schema/TextLineMarker.json +1 -1
  49. package/dist/schema/TextRegion.json +1 -1
  50. package/dist/src/AcpPlanValue.d.ts +7 -0
  51. package/dist/src/AcpPlanValue.d.ts.map +1 -0
  52. package/dist/src/AcpPlanValue.js +32 -0
  53. package/dist/src/AcpPlanValue.js.map +1 -0
  54. package/dist/src/AguiConformance.d.ts +11 -0
  55. package/dist/src/AguiConformance.d.ts.map +1 -0
  56. package/dist/src/AguiConformance.js +16 -0
  57. package/dist/src/AguiConformance.js.map +1 -0
  58. package/dist/src/ApplicationPort.d.ts +271 -0
  59. package/dist/src/ApplicationPort.d.ts.map +1 -0
  60. package/dist/src/ApplicationPort.js +2 -0
  61. package/dist/src/ApplicationPort.js.map +1 -0
  62. package/dist/src/AstBuilder.d.ts.map +1 -1
  63. package/dist/src/AstBuilder.js +2 -1
  64. package/dist/src/AstBuilder.js.map +1 -1
  65. package/dist/src/PlanValue.d.ts +10 -0
  66. package/dist/src/PlanValue.d.ts.map +1 -0
  67. package/dist/src/PlanValue.js +58 -0
  68. package/dist/src/PlanValue.js.map +1 -0
  69. package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -1
  70. package/dist/src/PlurnkErrorStrategy.js +17 -3
  71. package/dist/src/PlurnkErrorStrategy.js.map +1 -1
  72. package/dist/src/Problems.js +1 -1
  73. package/dist/src/Validator.d.ts +40 -1
  74. package/dist/src/Validator.d.ts.map +1 -1
  75. package/dist/src/Validator.js +236 -0
  76. package/dist/src/Validator.js.map +1 -1
  77. package/dist/src/index.d.ts +6 -1
  78. package/dist/src/index.d.ts.map +1 -1
  79. package/dist/src/index.js +4 -1
  80. package/dist/src/index.js.map +1 -1
  81. package/dist/src/types.generated.d.ts +285 -2
  82. package/dist/src/types.generated.d.ts.map +1 -1
  83. package/package.json +6 -1
  84. package/plurnk.md +79 -71
package/SPEC.md CHANGED
@@ -15,7 +15,12 @@ is the single code API for those contracts.
15
15
  | Stopped-world client contract | `ProposalDisposition`, `ProposalProjection` |
16
16
  | Client-owned interaction contract | `ClientInteractionRequest`, `ClientInteractionProjection`, `ClientInteractionResolution` |
17
17
  | Client capability presentation | `ClientDisplayCapabilities` |
18
+ | Exterior adapter application calls | `ApplicationPort` |
18
19
  | Workspace MCP configuration | `McpServerDefinition`, `McpServerOptions`, `McpConfigurationOverlay` |
20
+ | Worker Agent Skills definition | `SkillDefinition` |
21
+ | Worker outbound A2A agent definition | `A2aAgentDefinition` |
22
+ | Worker Functionality lifecycle projections (family-neutral) | `FunctionalityCandidate`, `FunctionalityDiscoverQuery`, `FunctionalityDiscoverResult`, `FunctionalityDefinitionState`, `FunctionalityListResult`, `FunctionalityMutationResult` |
23
+ | AG-UI discovery, client accounting, and shared conformance specimens | `AguiDiscovery`, `AguiClientConformance`, `AguiConformanceKit` |
19
24
  | JSON Schemas | `@plurnk/plurnk-contracts/schema/*.json` |
20
25
  | Generated JSON result rendering | `renderJsonResult` |
21
26
  | Local-model rails | `@plurnk/plurnk-contracts/plurnk.{gemma,qwen}.gbnf` |
@@ -25,6 +30,45 @@ is the single code API for those contracts.
25
30
  generated from the schemas; ANTLR is authoritative for accepted model-language
26
31
  syntax; GBNF remains the bounded generation aid described in §1.2.
27
32
 
33
+ §agui-discovery-contract `AguiDiscovery` is the complete installed AG-UI+
34
+ surface at one instant. `schemaVersion` identifies its discovery shape;
35
+ `actions` maps each unique public name to exactly one `scope`, `inputSchema`,
36
+ and `outputSchema`; `notifications` maps each unique event-family name to one
37
+ `payloadSchema`; and `display` carries {§client-display-capabilities} without
38
+ another presentation mechanism. The AG-UI owner supplies the built-in registry;
39
+ an extension contributes the same schema-bearing action descriptor through its
40
+ core module registration rather than creating a second action type.
41
+
42
+ §agui-action-schema-enforcement The JSON Schema values in
43
+ {§agui-discovery-contract} are executable boundary contracts, not prose or
44
+ hints. The AG-UI boundary rejects an action input before dispatch when it does
45
+ not satisfy the advertised `inputSchema`, rejects an owner's successful output
46
+ when it does not satisfy `outputSchema`, and validates a known notification
47
+ before projecting it to AG-UI. Schemas are discovery values owned by their
48
+ registrants; validation must not annotate or otherwise mutate them.
49
+
50
+ §agui-client-conformance `AguiClientConformance` is a language-neutral JSON
51
+ document accounting for every action and notification in one
52
+ {§agui-discovery-contract}. Each name is classified as `native` (dedicated
53
+ client behavior), `generic` (lossless protocol support without dedicated UI),
54
+ or `unsupported` with an explicit reason, and cites nonempty verification
55
+ evidence. Each disposition declares the exact verification dimensions its
56
+ evidence covers; native behavior includes admission and presentation, every
57
+ action includes projection plus success and failure, and every notification
58
+ includes framing plus projection. Validation requires exact action and
59
+ notification key equality with the installed discovery surface; adding or
60
+ removing a public capability therefore breaks every stale client matrix
61
+ visibly. The contracts-owned report procedure resolves every cited evidence
62
+ path and emits one record per member with its posture and verified dimensions;
63
+ a stale or fictional citation fails the report.
64
+
65
+ §agui-conformance-kit `AguiConformanceKit` is the one versioned,
66
+ language-neutral corpus of raw SSE boundary specimens and AG-UI lifecycle
67
+ sequences used by every client transport. Its JSON resource is test input, not
68
+ a third protocol implementation: each client feeds the same chunks and events
69
+ through its production parser and projection seam, then verifies the declared
70
+ outcome. Specimen names are unique within their transport or lifecycle family.
71
+
28
72
  §json-result-rendering `renderJsonResult` is the one presentation serializer
29
73
  for generated JSON operation results. A top-level array remains one valid,
30
74
  compact JSON value but places each item on its own physical line by adding only
@@ -83,7 +127,7 @@ The schemas own the runtime-neutral shapes; core owns their stateful values.
83
127
  | ------------------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
84
128
  | `LoopFlags` | Complete effective `mode`, `auto`, `noWeb`, `noInteraction`, and `noProposals` | Validate/expand persisted partial policy before use |
85
129
  | `ProposalDisposition` | Client authority, or the loop's exact automatic accept/reject | Compute precedence from effective loop policy, proposal kind, and stale-target truth |
86
- | `ProposalProjection` | Identity, review target/body/attrs, effective flags, stale signal, disposition | Derive one validated projection for live delivery and durable reconnect discovery |
130
+ | `ProposalProjection` | Identity, `{ scheme, authority, pathname }` review target, body/attrs, effective flags, stale signal, disposition | Derive one validated projection for live delivery and durable reconnect discovery |
87
131
  | `ProviderUsage` | Conventional input/output totals with cache and reasoning details | Preserve observed quantities without replacing absence with zero |
88
132
  | `ProviderCost` | Exact charged, estimated, or unknown monetary evidence | Normalize one monetary disposition for each physical provider request |
89
133
  | `ProviderRequestAccounting` | Usage and cost evidence for one physical provider request | Preserve request order across retries, failover, success, and failure |
@@ -250,7 +294,9 @@ separator is syntax rather than body content, while any additional preceding
250
294
  blank lines remain body content.
251
295
 
252
296
  §empty-section An empty section has no body lines between its heading and the next
253
- structural heading, tolerated separator, or EOF and normalizes to a null body.
297
+ structural heading, tolerated separator, or EOF. Optional operation bodies normalize
298
+ to null; PLAN admission normalizes its required semantic body to `[]`
299
+ under {§plan-value}.
254
300
 
255
301
  | Element | Canonical contract |
256
302
  |--------------|---------------------------------------------------------------------------|
@@ -324,7 +370,7 @@ governed by {§canonical-statement}; runtime conditions remain explicit below.
324
370
 
325
371
  | OP | `[signal]` | `(path)` | `<scope>` | `body` |
326
372
  |------|-------------------------------|----------------------------------------------|---------------------------------|--------------------------------|
327
- | PLAN | none | none | none | required intended goals |
373
+ | PLAN | none | none | none | required Plurnk Plan JSON array |
328
374
  | FIND | optional add log tags | required target or glob | optional result range | optional matcher |
329
375
  | READ | optional add log tags | required target | optional text region | empty |
330
376
  | EDIT | optional add log tags | required file or entry | required for an existing target | literal text |
@@ -345,10 +391,33 @@ Directed SEND and KILL delegate any present code to the addressed target's
345
391
  operation contract; a live process may interpret a KILL code as a Unix signal,
346
392
  but that interpretation does not define KILL generally.
347
393
 
348
- §plan-intended-goals **PLAN records working-state deltas.** Its concise body adds
349
- new material conclusions or unresolved questions and the current turn's priorities;
350
- it does not restate settled context. PLAN is public, durable log content—not provider
351
- reasoning. Dispatch records it and has no other runtime effect.
394
+ §plan-value **PLAN carries one complete Plurnk Plan.** Its entries are the
395
+ model's current working-memory inventory: durable findings are `memory`, finished
396
+ actions are `completed`, open inquiries are `pending`, and active priorities are
397
+ `in_progress`. Admission parses the JSON body — one JSON array document in any whitespace layout, including the {§json-result-rendering} spread the log projects — and supplies the neutral `medium`
398
+ priority to each entry that omits it, and validates the canonical bare array:
399
+ every entry has string `content`, `priority` in
400
+ `high | medium | low`, and `status` in
401
+ `pending | in_progress | completed | memory`. A nonempty plain-text,
402
+ malformed-JSON, or otherwise invalid body becomes one `medium`, `in_progress`
403
+ entry whose content is the exact authored body; admission performs no partial
404
+ repair or list inference. An empty body becomes the planless `[]`
405
+ value. Each PLAN completely replaces the current Plan; it never expresses a
406
+ delta. The exact `turnOps` source remains forensic program evidence, while the
407
+ normalized array is the sole semantic value used by AST, persistence, durable
408
+ log bodies, and model-packet materialization. PLAN is public log content—not
409
+ provider reasoning—and Plurnk initially mints no `_meta` values. Dispatch records
410
+ the canonical value and has no other runtime effect.
411
+
412
+ §plan-acp-projection **Only an ACP-facing boundary projects the model-native
413
+ Plan.** It constructs ACP's `{ "entries": [...] }` Plan object from the internal
414
+ array, maps each `memory` entry to ACP `completed`, and prefixes its content with
415
+ exact "Memory: " framing without duplicating an existing prefix. Every other
416
+ entry field remains unchanged, and the internal value is not mutated.
417
+ The projected value validates against the separately owned ACP Plan schema pinned
418
+ to ACP v1
419
+ [`schema-v1.21.0`](https://github.com/agentclientprotocol/agent-client-protocol/tree/schema-v1.21.0)
420
+ commit `272bf799f35a258c6a4107a0410ed361e83683d3`.
352
421
 
353
422
  §log-tag-signal FIND, READ, EDIT, COPY, MOVE, and BARE canonically express additions
354
423
  as `+tag`. Because those operations have no tag-selection semantics, ANTLR also
@@ -431,7 +500,7 @@ Mutation semantics:
431
500
  | WORK | Spawn acknowledgement; the deliverable arrives through the log |
432
501
  | FORK | Spawn acknowledgement; the inherited worker's deliverable arrives through the log |
433
502
  | KILL | Status of deletion or termination |
434
- | PLAN | Status of durable intended-goals logging |
503
+ | PLAN | Status of durable complete-Plan logging |
435
504
 
436
505
  §find-result-unit For FIND, authored target shape fixes the paginated result
437
506
  unit. An exact target with a matcher pages flat match locations; a glob or
@@ -640,11 +709,11 @@ Example — a lane-0 turn stored inside a lane-2 EDIT body:
640
709
 
641
710
  ```plurnk
642
711
  # PLAN2
643
- Store the quoted turn.
712
+ [{"content":"Store the quoted turn.","status":"in_progress"}]
644
713
 
645
714
  ## EDIT2 (worker:///quoted.plurnk)
646
715
  # PLAN0
647
- Answer from memory.
716
+ [{"content":"Answer from memory.","status":"in_progress"}]
648
717
 
649
718
  ## SEND0 [200]
650
719
  Paris.
@@ -904,7 +973,7 @@ enforces both the schema and the relational endpoint invariants.
904
973
  ### §entry-read-result 13.3 Client entry reads
905
974
 
906
975
  `EntryReadResult` is the exact transport-neutral projection of one entry. It
907
- does not expose workspace IDs, storage owner IDs, split scheme/pathname fields,
976
+ does not expose workspace IDs, storage owner IDs, split persistence-coordinate fields,
908
977
  scope, or other persistence columns.
909
978
 
910
979
  | Outcome | Exact shape |
@@ -1033,6 +1102,48 @@ environment declarations, then validates the resulting
1033
1102
  `McpServerDefinition`. Carrying the overlay does not connect, persist, or
1034
1103
  expand credentials by itself.
1035
1104
 
1105
+ `SkillDefinition` is the one definition the Worker `skills` Functionality
1106
+ family accepts and persists: the standard Agent Skills `name` (the directory
1107
+ name), the universal root `scope` (`project` or `global`), and — for a
1108
+ Worker-installed skill — the standard installer package `source` that
1109
+ provides it. `Validator.assertSkillDefinition` is the family's admission
1110
+ boundary; the filesystem under the scope's root, never the definition, is the
1111
+ truth about installation.
1112
+
1113
+ `A2aAgentDefinition` is the one definition the Worker `a2a` Functionality
1114
+ family accepts and persists: the local alias `name` (the `a2a://<name>`
1115
+ authority), the remote `url` whose standard Agent Card remains the protocol
1116
+ authority, and optional local `cardPath`, `headers`, and bearer
1117
+ `authorization` whose token is a symbolic `${NAME}` reference.
1118
+ `Validator.assertA2aAgentDefinition` is the family's admission boundary.
1119
+
1120
+ ### §application-port 13.9 Exterior application port
1121
+
1122
+ `ApplicationPort` is the single transport-neutral TypeScript contract through
1123
+ which an exterior adapter drives and observes the Plurnk application. Core
1124
+ implements it; AG-UI, A2A, and other interface modules consume it. The port
1125
+ contains typed application calls and a scoped event subscription, not wire
1126
+ route names, protocol framing, persistence access, or adapter-specific methods.
1127
+ An exterior adapter owns its own protocol validation, identity binding, and
1128
+ projection while reusing the same workspace, worker, loop, operation, proposal,
1129
+ interaction, and event owners through this port.
1130
+
1131
+ `runLoop.source` is trusted causal provenance supplied by an adapter, distinct
1132
+ from user-authored prompt content. An adapter may expose no public means to set
1133
+ it; Core validates and records it through the same prompt admission path.
1134
+
1135
+ §application-worker-observation Worker observation exposes durable identity,
1136
+ origin, and immediate parent identity. `readWorker` resolves exactly one id or
1137
+ name and returns `null` when absent. `listWorkers` filters collections by origin
1138
+ or lineage position; an omitted parent filter means every position and an
1139
+ explicit `null` means roots. Singular and plural cardinalities are distinct
1140
+ contracts. Observation is not a client binding or permission grant.
1141
+
1142
+ §application-loop-observation Loop observation exposes the durable scheduler
1143
+ state and exact terminal `OperationResult` for one owned Worker. Exterior
1144
+ adapters consume this projection instead of reconstructing lifecycle from
1145
+ events or persistence; events remain the live notification edge.
1146
+
1036
1147
  ## 14. Parse diagnostics
1037
1148
 
1038
1149
  §parse-diagnostics `PlurnkParseError` is a JSON-serializable Error subclass.