@agentproto/corpus-cli 0.10.1 → 0.11.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/dist/cli.mjs +164 -93
- package/dist/cli.mjs.map +1 -1
- package/dist/ports/index.d.ts +37 -1
- package/dist/ports/index.mjs +141 -74
- package/dist/ports/index.mjs.map +1 -1
- package/dist/specs/resources/aip-14/draft/TOOL.schema.json +1 -1
- package/dist/specs/resources/aip-15/draft/WORKFLOW.schema.json +47 -52
- package/dist/specs/resources/aip-18/draft/COLLECTION.schema.json +128 -7
- package/dist/specs/resources/aip-36/draft/SANDBOX.schema.json +13 -0
- package/dist/specs/resources/aip-41/draft/ROUTINE.schema.json +21 -2
- package/dist/specs/resources/aip-42/draft/AGENT.schema.json +1 -1
- package/dist/specs/resources/aip-47/draft/ROLE.schema.json +1 -1
- package/dist/specs/resources/aip-49/draft/ASSET.schema.json +232 -0
- package/dist/specs/resources/aip-50/draft/AUTH.schema.json +114 -0
- package/dist/specs/resources/aip-53/draft/APP.schema.json +273 -0
- package/dist/specs/resources/aip-54/draft/REF.schema.json +1 -1
- package/dist/specs/resources/aip-54/draft/WS-REF.schema.json +46 -0
- package/dist/specs/resources/aip-55/draft/PRODUCT.schema.json +172 -38
- package/dist/specs/resources/aip-58/draft/vectors/v8-heuristic-not-suspend.json +1 -1
- package/dist/specs/resources/aip-62/draft/ATTESTATION.schema.json +197 -0
- package/dist/specs/resources/aip-62/draft/REVIEW-PACK.schema.json +70 -0
- package/dist/specs/resources/aip-62/draft/REVIEW.schema.json +192 -0
- package/dist/specs/resources/aip-63/draft/BROWSER.schema.json +423 -0
- package/dist/specs/resources/aip-7/draft/GOVERNANCE.schema.json +147 -1
- package/dist/specs/resources/{aip-52/draft → pending/harness}/HARNESS.schema.json +1 -1
- package/package.json +3 -3
- package/dist/specs/resources/aip-52/draft/ADAPTER.md +0 -193
- package/dist/specs/resources/aip-54/draft/REF.md +0 -89
- package/dist/specs/resources/aip-55/draft/PRODUCT.md +0 -143
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://agentproto.sh/schemas/aip-7/GOVERNANCE.schema.json",
|
|
4
4
|
"title": "agentgovernance/v1 (AIP-7)",
|
|
5
|
-
"description": "Validates the
|
|
5
|
+
"description": "Validates the five AIP-7 doctypes: signature (approval event), audit-event (append-only log line), policy (declarative autonomy rule), approval-request (pending human decision over a pinned payload), and governance.workspace/v1 (workspace manifest, root or view). Branch on the `doctype` (or for the workspace, the `schema`) field.",
|
|
6
6
|
"oneOf": [
|
|
7
7
|
{ "$ref": "#/$defs/signature" },
|
|
8
8
|
{ "$ref": "#/$defs/auditEvent" },
|
|
9
9
|
{ "$ref": "#/$defs/policy" },
|
|
10
|
+
{ "$ref": "#/$defs/approvalRequest" },
|
|
10
11
|
{ "$ref": "#/$defs/workspace" }
|
|
11
12
|
],
|
|
12
13
|
"$defs": {
|
|
@@ -112,7 +113,38 @@
|
|
|
112
113
|
"maxLength": 4000,
|
|
113
114
|
"description": "Required when decision is 'reject'. Recommended for 'approve' in multi-signer flows."
|
|
114
115
|
},
|
|
116
|
+
"documentHash": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"pattern": "^[0-9a-f]{64}$",
|
|
119
|
+
"description": "Lowercase hex SHA-256 of the artifact's bytes at signing time. For a signature that resolves an approval-request, MUST equal that request's payloadHash."
|
|
120
|
+
},
|
|
115
121
|
"signer": { "$ref": "#/$defs/signer" },
|
|
122
|
+
"signerKind": {
|
|
123
|
+
"enum": ["operator", "user", "counterparty", "agent", "external"],
|
|
124
|
+
"description": "What kind of principal signed. An approve that resolves an approval-request MUST carry 'user'."
|
|
125
|
+
},
|
|
126
|
+
"method": {
|
|
127
|
+
"enum": ["typed_name", "agent_confirm", "click_through", "esign_external"],
|
|
128
|
+
"description": "How the signature was produced. An approve that resolves an approval-request MUST carry 'click_through'."
|
|
129
|
+
},
|
|
130
|
+
"evidence": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"required": ["kind"],
|
|
133
|
+
"additionalProperties": true,
|
|
134
|
+
"properties": {
|
|
135
|
+
"kind": {
|
|
136
|
+
"enum": ["typed_name", "agent_confirm", "click_through", "esign_external"],
|
|
137
|
+
"description": "MUST equal `method` when both are present."
|
|
138
|
+
},
|
|
139
|
+
"ipAddress": { "type": "string" },
|
|
140
|
+
"userAgent": { "type": "string" },
|
|
141
|
+
"signedUrlToken": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"description": "click_through: a value unique to this decision. For a ui_card decision, the hash of the one-time ticket, never the ticket."
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"description": "Method-specific evidence. Shape shown is for click_through; other methods define their own members."
|
|
147
|
+
},
|
|
116
148
|
"signedAt": { "$ref": "#/$defs/isoDateTime" },
|
|
117
149
|
"policy": { "$ref": "#/$defs/policyRef" },
|
|
118
150
|
"signature": { "$ref": "#/$defs/signatureBlock" },
|
|
@@ -129,6 +161,120 @@
|
|
|
129
161
|
}
|
|
130
162
|
]
|
|
131
163
|
},
|
|
164
|
+
"approvalRequest": {
|
|
165
|
+
"type": "object",
|
|
166
|
+
"title": "approval-request (pending human decision over a pinned payload)",
|
|
167
|
+
"required": [
|
|
168
|
+
"$schema",
|
|
169
|
+
"doctype",
|
|
170
|
+
"id",
|
|
171
|
+
"kind",
|
|
172
|
+
"title",
|
|
173
|
+
"payloadHash",
|
|
174
|
+
"status",
|
|
175
|
+
"requestedBy",
|
|
176
|
+
"channels",
|
|
177
|
+
"requestedAt"
|
|
178
|
+
],
|
|
179
|
+
"additionalProperties": false,
|
|
180
|
+
"properties": {
|
|
181
|
+
"$schema": { "$ref": "#/$defs/schemaTag" },
|
|
182
|
+
"doctype": { "const": "approval-request" },
|
|
183
|
+
"id": {
|
|
184
|
+
"type": "string",
|
|
185
|
+
"minLength": 1,
|
|
186
|
+
"maxLength": 128,
|
|
187
|
+
"pattern": "^[A-Za-z0-9_-]+$",
|
|
188
|
+
"description": "Opaque unique identifier, stable for the life of the request."
|
|
189
|
+
},
|
|
190
|
+
"kind": {
|
|
191
|
+
"type": "string",
|
|
192
|
+
"minLength": 1,
|
|
193
|
+
"maxLength": 128,
|
|
194
|
+
"description": "Free-form class of the thing being approved."
|
|
195
|
+
},
|
|
196
|
+
"title": { "type": "string", "minLength": 1, "maxLength": 256 },
|
|
197
|
+
"preview": {
|
|
198
|
+
"description": "JSON value supplied by the requester for a human-facing surface to render. Opaque to the host and NOT covered by payloadHash."
|
|
199
|
+
},
|
|
200
|
+
"payloadHash": {
|
|
201
|
+
"type": "string",
|
|
202
|
+
"pattern": "^[0-9a-f]{64}$",
|
|
203
|
+
"description": "Lowercase hex SHA-256 of the UTF-8 bytes of the canonical JSON of the pinned payload (keys sorted recursively by UTF-16 code unit, arrays in order, undefined as null)."
|
|
204
|
+
},
|
|
205
|
+
"status": {
|
|
206
|
+
"enum": ["pending", "approved", "denied", "expired", "consumed"],
|
|
207
|
+
"description": "pending -> approved | denied | expired; approved -> consumed. denied, expired, and consumed are terminal."
|
|
208
|
+
},
|
|
209
|
+
"requestedBy": {
|
|
210
|
+
"oneOf": [
|
|
211
|
+
{
|
|
212
|
+
"type": "object",
|
|
213
|
+
"required": ["sessionId"],
|
|
214
|
+
"additionalProperties": false,
|
|
215
|
+
"properties": {
|
|
216
|
+
"sessionId": { "type": "string", "minLength": 1 }
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"type": "object",
|
|
221
|
+
"required": ["operator"],
|
|
222
|
+
"additionalProperties": false,
|
|
223
|
+
"properties": {
|
|
224
|
+
"operator": { "const": true }
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"description": "The requester: an agent session, or the operator acting directly. Only the requester (an operator for operator-made requests) may consume."
|
|
229
|
+
},
|
|
230
|
+
"taskId": { "type": "string", "minLength": 1 },
|
|
231
|
+
"appId": { "type": "string", "minLength": 1 },
|
|
232
|
+
"channels": {
|
|
233
|
+
"type": "array",
|
|
234
|
+
"uniqueItems": true,
|
|
235
|
+
"items": { "$ref": "#/$defs/approvalChannel" },
|
|
236
|
+
"description": "Human channels allowed to decide this request. A decision on any other channel MUST be rejected. Empty when no declared channel is enabled."
|
|
237
|
+
},
|
|
238
|
+
"requestedAt": { "$ref": "#/$defs/isoDateTime" },
|
|
239
|
+
"expiresAt": { "$ref": "#/$defs/isoDateTime" },
|
|
240
|
+
"decision": {
|
|
241
|
+
"type": "object",
|
|
242
|
+
"required": ["decision", "channel", "decidedAt"],
|
|
243
|
+
"additionalProperties": false,
|
|
244
|
+
"properties": {
|
|
245
|
+
"decision": { "enum": ["approved", "denied"] },
|
|
246
|
+
"channel": { "$ref": "#/$defs/approvalChannel" },
|
|
247
|
+
"decidedAt": { "$ref": "#/$defs/isoDateTime" },
|
|
248
|
+
"signaturePath": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"description": "Workspace-relative path to the signature.json. Present only when decision is 'approved', and written after the signature exists."
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
"consumedAt": { "$ref": "#/$defs/isoDateTime" }
|
|
255
|
+
},
|
|
256
|
+
"allOf": [
|
|
257
|
+
{
|
|
258
|
+
"if": { "properties": { "status": { "enum": ["approved", "denied", "consumed"] } } },
|
|
259
|
+
"then": { "required": ["decision"] }
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"if": { "properties": { "status": { "const": "consumed" } } },
|
|
263
|
+
"then": { "required": ["consumedAt"] }
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"if": {
|
|
267
|
+
"required": ["decision"],
|
|
268
|
+
"properties": { "decision": { "properties": { "decision": { "const": "denied" } } } }
|
|
269
|
+
},
|
|
270
|
+
"then": { "properties": { "decision": { "not": { "required": ["signaturePath"] } } } }
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
"approvalChannel": {
|
|
275
|
+
"enum": ["web_click", "ui_card"],
|
|
276
|
+
"description": "A declared human channel. web_click: bearer credential plus an Origin on a configured allowlist. ui_card: one-time ticket minted per card render, app-only decide action, served on a surface agent sessions cannot reach. Further channels MAY be registered; each MUST satisfy the AIP-7 human channel rule."
|
|
277
|
+
},
|
|
132
278
|
"auditEvent": {
|
|
133
279
|
"type": "object",
|
|
134
280
|
"title": "audit-event (append-only chain entry)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://agentproto.sh/schemas/
|
|
3
|
+
"$id": "https://agentproto.sh/schemas/pending/harness/HARNESS.schema.json",
|
|
4
4
|
"title": "HarnessDefinition",
|
|
5
5
|
"description": "Validates the YAML frontmatter of a .harness/<slug>.md file. A Harness is a stateful conversational shell with modes, threads, tool-approval gates, subagents, and observational memory. Today the canonical runtime is Mastra's Harness class (@mastra/core/harness); the spec is implementation-agnostic.",
|
|
6
6
|
"$comment": "Relationship to other AIPs: a Harness HAS agents (via modes[].agent and HarnessConfig.agent) but IS NOT a subtype of AIP-42. AIP-42 agents are referenced from harness manifests via $resolver. See also AIP-12 for agent pack ingestion — packs can auto-generate .harness/ manifests from modes/*.md files.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/corpus-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "@agentproto/corpus-cli — the `corpus` binary. Validate, lint, and operate an AIP-10 corpus workspace from the command line. Local-topology host for @agentproto/corpus — pair with a local backing engine (qdrant docker / gbrain) for a fully offline corpus runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"zod": "^4.6.5",
|
|
55
55
|
"@agentproto/batch": "0.2.2",
|
|
56
56
|
"@agentproto/cli-exec": "0.1.1",
|
|
57
|
-
"@agentproto/corpus": "0.8.
|
|
58
|
-
"@agentproto/corpus-presets": "0.2.
|
|
57
|
+
"@agentproto/corpus": "0.8.2",
|
|
58
|
+
"@agentproto/corpus-presets": "0.2.14"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "^25.9.5",
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# AIP-52 — Harness · Implementer Guide
|
|
2
|
-
|
|
3
|
-
> **Status:** Draft
|
|
4
|
-
> **Schema:** `HARNESS.schema.json`
|
|
5
|
-
> **Canonical runtime:** `@mastra/core/harness` (Mastra's `Harness` class)
|
|
6
|
-
|
|
7
|
-
## What is a Harness?
|
|
8
|
-
|
|
9
|
-
A Harness is a **stateful, multi-mode conversational shell**. Where an AIP-42 Agent is
|
|
10
|
-
a single-purpose inference unit, a Harness composes multiple agents into an orchestrated
|
|
11
|
-
shell that can:
|
|
12
|
-
|
|
13
|
-
- Switch between **modes** (e.g. plan → execute → review) with distinct agents, tools,
|
|
14
|
-
and permission rules per mode.
|
|
15
|
-
- Hold a **typed conversation state** (`stateSchema` + `initialState`) that persists
|
|
16
|
-
across turns and is visible to all modes.
|
|
17
|
-
- Spawn **subagents** via the built-in `subagent` tool (forked or isolated thread).
|
|
18
|
-
- Gate tool calls via **tool-approval gates** (`permissions`, `submit_plan` builtin).
|
|
19
|
-
- Run **heartbeat handlers** in the background (OM reflector, progress reporter, etc.).
|
|
20
|
-
|
|
21
|
-
A Harness IS NOT a subtype of AIP-42. Agents are referenced _from_ harness manifests
|
|
22
|
-
via `$resolver` / `$ref`; the harness is the orchestrator, not the agent itself.
|
|
23
|
-
|
|
24
|
-
## Filesystem layout
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
.harness/
|
|
28
|
-
<slug>.md ← one manifest per harness (YAML frontmatter + prose body)
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The markdown body (after the frontmatter block) is purely documentary — it is not
|
|
32
|
-
parsed by the runtime.
|
|
33
|
-
|
|
34
|
-
## Manifest shape
|
|
35
|
-
|
|
36
|
-
```yaml
|
|
37
|
-
---
|
|
38
|
-
spec: harness/v1
|
|
39
|
-
id: my-harness
|
|
40
|
-
name: My Harness
|
|
41
|
-
version: 1.0.0
|
|
42
|
-
description: One-sentence description.
|
|
43
|
-
|
|
44
|
-
storage:
|
|
45
|
-
$resolver: mastra.storage.composite # must resolve to MastraCompositeStore
|
|
46
|
-
|
|
47
|
-
modes:
|
|
48
|
-
- id: plan
|
|
49
|
-
default: true
|
|
50
|
-
name: Plan
|
|
51
|
-
agent: { $resolver: my-agent }
|
|
52
|
-
model: { $resolver: model.plan }
|
|
53
|
-
builtins:
|
|
54
|
-
ask_user: true
|
|
55
|
-
submit_plan: required # blocks until approved
|
|
56
|
-
transitionsTo: execute
|
|
57
|
-
|
|
58
|
-
- id: execute
|
|
59
|
-
name: Execute
|
|
60
|
-
agent: { $resolver: my-agent }
|
|
61
|
-
model: { $resolver: model.execute }
|
|
62
|
-
builtins:
|
|
63
|
-
ask_user: false
|
|
64
|
-
subagent: true
|
|
65
|
-
|
|
66
|
-
models:
|
|
67
|
-
resolver: { $resolver: model.resolver } # (modelId) => LanguageModel
|
|
68
|
-
|
|
69
|
-
subagents:
|
|
70
|
-
- id: researcher
|
|
71
|
-
name: Researcher
|
|
72
|
-
description: Searches and summarises.
|
|
73
|
-
agent: { $resolver: researcher-agent }
|
|
74
|
-
forked: false # isolated thread (default)
|
|
75
|
-
maxSteps: 20
|
|
76
|
-
|
|
77
|
-
memory:
|
|
78
|
-
$resolver: mastra.memory.thread
|
|
79
|
-
|
|
80
|
-
observability:
|
|
81
|
-
$resolver: my.telemetry.entrypoint
|
|
82
|
-
---
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Required fields
|
|
86
|
-
|
|
87
|
-
| Field | Type | Notes |
|
|
88
|
-
|---|---|---|
|
|
89
|
-
| `spec` | `"harness/v1"` | Version pin. |
|
|
90
|
-
| `id` | `string` (kebab-case) | Registry key; must be unique within a workspace. |
|
|
91
|
-
| `name` | `string` | Human label (≤ 80 chars). |
|
|
92
|
-
| `version` | `semver` | Bump on breaking mode / subagent changes. |
|
|
93
|
-
| `storage` | `refOrString` | Must resolve to `MastraCompositeStore`. |
|
|
94
|
-
| `modes` | `mode[]` | At least one mode required. |
|
|
95
|
-
| `models.resolver` | `refOrString` | `(modelId: string) => LanguageModel`. |
|
|
96
|
-
|
|
97
|
-
## Resolver syntax (`refOrString`)
|
|
98
|
-
|
|
99
|
-
Three forms are accepted for any field annotated `$ref: "#/$defs/refOrString"`:
|
|
100
|
-
|
|
101
|
-
```yaml
|
|
102
|
-
# 1. Inline literal string (if the field accepts a raw value)
|
|
103
|
-
storage: "fs://./data/state"
|
|
104
|
-
|
|
105
|
-
# 2. Named registry ref — resolved at harness boot from the resolver registry
|
|
106
|
-
storage:
|
|
107
|
-
$ref: myApp.storage.main
|
|
108
|
-
|
|
109
|
-
# 3. Dynamic resolver call — arbitrary typed input passed to the resolver
|
|
110
|
-
storage:
|
|
111
|
-
$resolver: myApp.storage.build
|
|
112
|
-
input: { path: "./state", ttl: 3600 }
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Modes
|
|
116
|
-
|
|
117
|
-
Each mode entry defines **one operational context**:
|
|
118
|
-
|
|
119
|
-
| Field | Required | Notes |
|
|
120
|
-
|---|---|---|
|
|
121
|
-
| `id` | ✅ | Unique within this harness (kebab-case recommended). |
|
|
122
|
-
| `agent` | ✅ | Backing `Mastra Agent` instance (via resolver). |
|
|
123
|
-
| `model` | ✅ | Resolver returning `{ modelId, defaultModelId?, allowed? }`. |
|
|
124
|
-
| `default` | — | First mode with `default: true` activates on new sessions. |
|
|
125
|
-
| `transitionsTo` | — | Auto-switch to this mode id after `submit_plan` approval. |
|
|
126
|
-
| `tools` | — | Replaces the agent's built-in tools entirely (mutually exclusive with `additionalTools`). |
|
|
127
|
-
| `prompt.blocks` | — | Instruction blocks resolved and concatenated as `instructions`. |
|
|
128
|
-
| `builtins.*` | — | Enable / disable built-in tools: `ask_user`, `submit_plan`, `task_write`, `task_check`, `subagent`. |
|
|
129
|
-
| `permissions` | — | `PermissionRules` resolver — default tool-approval policy for this mode. |
|
|
130
|
-
|
|
131
|
-
### `submit_plan` values
|
|
132
|
-
|
|
133
|
-
| Value | Behaviour |
|
|
134
|
-
|---|---|
|
|
135
|
-
| `false` (default) | Tool not registered. |
|
|
136
|
-
| `true` | Registered; plan approval is optional. |
|
|
137
|
-
| `"required"` | Registered; the mode blocks on plan approval and then transitions to `transitionsTo`. |
|
|
138
|
-
|
|
139
|
-
## Subagents
|
|
140
|
-
|
|
141
|
-
```yaml
|
|
142
|
-
subagents:
|
|
143
|
-
- id: drafter
|
|
144
|
-
name: Drafter
|
|
145
|
-
description: Writes first-draft content.
|
|
146
|
-
agent: { $resolver: drafter-agent }
|
|
147
|
-
forked: true # inherits parent thread + prompt cache
|
|
148
|
-
maxSteps: 30
|
|
149
|
-
allowedHarnessTools: [ask_user, task_write]
|
|
150
|
-
allowedWorkspaceTools: [read_file, write_file]
|
|
151
|
-
prompt:
|
|
152
|
-
blocks:
|
|
153
|
-
- "You are a concise technical writer."
|
|
154
|
-
- { $ref: brand.voice.guide }
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
- `forked: true` — subagent inherits the parent conversation thread and prompt cache
|
|
158
|
-
(cheaper, shares context).
|
|
159
|
-
- `forked: false` (default) — fresh isolated thread; the subagent is context-blind to
|
|
160
|
-
the parent.
|
|
161
|
-
|
|
162
|
-
## Heartbeats
|
|
163
|
-
|
|
164
|
-
Heartbeats are periodic background handlers registered on the Harness constructor's
|
|
165
|
-
`heartbeats` array. Each entry is a `refOrString` resolving to a `HeartbeatConfig`
|
|
166
|
-
(interval + handler function). Common uses: Observational Memory reflector, progress
|
|
167
|
-
reporter, stale-session reaper.
|
|
168
|
-
|
|
169
|
-
## Loading algorithm
|
|
170
|
-
|
|
171
|
-
1. Locate `.harness/<slug>.md` in the workspace (or agent pack).
|
|
172
|
-
2. Parse the YAML frontmatter block; validate against `HARNESS.schema.json`.
|
|
173
|
-
3. Resolve all `$ref` / `$resolver` entries against the resolver registry at boot time
|
|
174
|
-
— fail loudly if any resolver is missing.
|
|
175
|
-
4. Instantiate the `Harness` object (Mastra constructor) with the resolved config.
|
|
176
|
-
5. Register in the harness registry keyed by `id`.
|
|
177
|
-
|
|
178
|
-
**Never execute a harness at load time** — only parse, validate, and register.
|
|
179
|
-
|
|
180
|
-
## Relationship to other AIPs
|
|
181
|
-
|
|
182
|
-
| AIP | Relationship |
|
|
183
|
-
|---|---|
|
|
184
|
-
| AIP-42 (Agent) | Harness agents are AIP-42 instances. A Harness orchestrates them; it is NOT an AIP-42 agent itself. |
|
|
185
|
-
| AIP-12 (Playbook) | Agent packs can auto-generate `.harness/` manifests from `modes/*.md` files during ingestion. |
|
|
186
|
-
| AIP-35 (Storage) | `storage` field resolves to a provider defined under AIP-35. |
|
|
187
|
-
| AIP-37 (Lifecycle Events) | Harness emits `harness-session-start`, `harness-mode-switch`, `harness-session-end` events. |
|
|
188
|
-
| AIP-47 (Role) | `permissions` per mode align with AIP-47 role-based access scopes. |
|
|
189
|
-
|
|
190
|
-
## See also
|
|
191
|
-
|
|
192
|
-
- `HARNESS.schema.json` — canonical validation schema
|
|
193
|
-
- `@mastra/core/harness` — canonical runtime implementation
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# AIP-54 — Ref · Implementer Guide
|
|
2
|
-
|
|
3
|
-
> **Status:** Draft
|
|
4
|
-
> **Schema:** `REF.schema.json`
|
|
5
|
-
> **Reference runtime:** `@agentproto/ref`
|
|
6
|
-
|
|
7
|
-
## What is a Ref?
|
|
8
|
-
|
|
9
|
-
A Ref is **one typed, cross-AIP reference** — `{aip, id, version?}`,
|
|
10
|
-
serialized in string contexts as `aip://<aip>/<id>[@version]`. It is
|
|
11
|
-
the general answer to a question every AIP has answered differently:
|
|
12
|
-
|
|
13
|
-
- AIP-18's `ref` field — an id string scoped to ONE named collection,
|
|
14
|
-
no shape guarantee.
|
|
15
|
-
- app-kit's `attach` — a structural `DoctypeHandle` that serializes
|
|
16
|
-
the whole bundle and carries no reliable discriminator.
|
|
17
|
-
- AIP-42's `AnyRef` — bare strings, typed only by call-site convention.
|
|
18
|
-
- AIP-55's first draft — bespoke `appRef`/`packRef` per target kind.
|
|
19
|
-
|
|
20
|
-
A Ref IS NOT a handle. It is inert data pointing at one; the AIP-43
|
|
21
|
-
registry owns the handle. A Ref IS NOT resolvable by itself —
|
|
22
|
-
resolution is the host's `RefCatalog`, which joins per-family AIP-43
|
|
23
|
-
registries.
|
|
24
|
-
|
|
25
|
-
## Reference runtime
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { RefCatalog, refFor, refToUri, refFromUri } from "@agentproto/ref"
|
|
29
|
-
|
|
30
|
-
const cat = new RefCatalog()
|
|
31
|
-
cat.registerFamily(42, { family: "app", keyBy: h => h.id! }, appRegistry)
|
|
32
|
-
cat.registerFamily(52, { family: "pack", keyBy: h => h.name }, packRegistry)
|
|
33
|
-
|
|
34
|
-
const ref = refFor({ aip: 52, keyBy: h => h.name }, packHandle, "1.0.0")
|
|
35
|
-
// { aip: 52, id: "the-agentic-coder", version: "1.0.0" }
|
|
36
|
-
|
|
37
|
-
const hit = cat.resolveStrict(ref) // { handle, family } — throws if dangling
|
|
38
|
-
const uri = refToUri(ref) // "aip://52/the-agentic-coder@1.0.0"
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Normative rules
|
|
42
|
-
|
|
43
|
-
1. **keyBy identity.** The `keyBy` passed to `refFor` MUST be the same
|
|
44
|
-
function the family's registry uses. A ref id that drifts from its
|
|
45
|
-
registry key is a HARD authoring error.
|
|
46
|
-
2. **Unreferenceable handles.** A handle with no registry key (no
|
|
47
|
-
`id`/`provider`/`slug`/`name`) MUST be refused by `refFor` — the
|
|
48
|
-
pre-AIP-54 world silently produced dangling id strings. Anonymous
|
|
49
|
-
AIP-42 apps (no `id`) are unreferenceable; hosts MUST refuse.
|
|
50
|
-
3. **Loud failure.** `resolve` on an unknown aip or id returns
|
|
51
|
-
`undefined` (default) or throws `RefFamilyError` /
|
|
52
|
-
`RefUnresolvableError` (`onUnresolvable: "throw"` / `resolveStrict`).
|
|
53
|
-
A dangling ref MUST never masquerade as a resolution.
|
|
54
|
-
4. **Ref is inert.** Frozen at construction; carries no behavior. All
|
|
55
|
-
semantics live in the catalog + registries.
|
|
56
|
-
5. **One family per aip.** Re-registering replaces the binding
|
|
57
|
-
(hot-reload parity with AIP-43's `replace`).
|
|
58
|
-
|
|
59
|
-
### Conventions for referenced handles
|
|
60
|
-
|
|
61
|
-
- **Handles SHOULD carry `schema: "<doctype>/vN"`.** Several existing
|
|
62
|
-
handles don't (e.g. the in-memory AIP-42 `AppHandle` never carries
|
|
63
|
-
the `schema: "app/v1"` literal that `emit` writes into `APP.md`) —
|
|
64
|
-
until they do, `refFor` requires the family spec to be supplied
|
|
65
|
-
explicitly, and a bare serialized handle cannot self-describe into a
|
|
66
|
-
ref. New doctypes SHOULD include it in `createDoctype`'s default
|
|
67
|
-
`build()`.
|
|
68
|
-
- **Family keys are the family's choice.** Most families key on `id`
|
|
69
|
-
(or `provider`/`slug` per AIP-43's default), but packs (AIP-52) key
|
|
70
|
-
on `name`. The `RefCatalog` owns the `aip → family + keyBy` table;
|
|
71
|
-
`refFor` MUST be given the same `keyBy` the family's registry uses.
|
|
72
|
-
|
|
73
|
-
## Migration notes for existing mechanisms
|
|
74
|
-
|
|
75
|
-
| Existing | Migration |
|
|
76
|
-
|---|---|
|
|
77
|
-
| AIP-18 `ref` field + `refKind` | Validate ref values as `aip://` URIs; `refKind` narrows the accepted `aip`(s). |
|
|
78
|
-
| app-kit `attach` (DoctypeHandle) | Carry `ArtifactRef`s; the host resolves through its catalog. Fixes the inline-the-whole-bundle flaw. |
|
|
79
|
-
| AIP-42 `AnyRef` string form | Unchanged at the string layer; `aip://` URIs are a valid `ref:` value hosts narrow to `ref/v1`. |
|
|
80
|
-
| AIP-52 `$resolver` | A URI rendering of the same coordinates. |
|
|
81
|
-
| AIP-53 draft `target` union | Replaced by `on: ref/v1` (see AIP-53). |
|
|
82
|
-
|
|
83
|
-
## What a new AIP needs to be referenceable
|
|
84
|
-
|
|
85
|
-
Nothing ref-specific. It needs what every AIP needs anyway: a
|
|
86
|
-
`defineX` handle with a stable identity field, and (for hosts that
|
|
87
|
-
resolve in-memory) an AIP-43 registry entry with a `family` + `keyBy`.
|
|
88
|
-
Pricing, entitling, or any future capability composes ON TOP via a
|
|
89
|
-
capability attached to a ref — the target AIP never learns about it.
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
# AIP-55 — Product (pricing capability) · Implementer Guide
|
|
2
|
-
|
|
3
|
-
> **Status:** Draft (v2 — capability form)
|
|
4
|
-
> **Schema:** `PRODUCT.schema.json`
|
|
5
|
-
> **Reference runtime:** `@agentproto/product`
|
|
6
|
-
> **Depends on:** AIP-54 (`ref/v1`) — this spec's `on` field IS an AIP-54 ref.
|
|
7
|
-
|
|
8
|
-
## What is a Product?
|
|
9
|
-
|
|
10
|
-
A Product is **a pricing capability attached to any referenced AIP
|
|
11
|
-
artifact**. It is not a wrapper doctype: there is no per-target-kind
|
|
12
|
-
union, no `appRef`/`packRef`, no inlined handles. The target is
|
|
13
|
-
addressed by an AIP-54 `ref/v1` and needs zero pricing awareness —
|
|
14
|
-
"sandbox has a price" is expressible without the sandbox AIP changing.
|
|
15
|
-
|
|
16
|
-
A Product IS NOT:
|
|
17
|
-
|
|
18
|
-
- an AIP-49 wallet `asset` — AIP-49 models value *movement*; AIP-55
|
|
19
|
-
models the *catalog entry*. `defineAsset` is taken.
|
|
20
|
-
- an AIP-18 collection item — no money type, no discriminated union,
|
|
21
|
-
`refKind` is collection-scoped.
|
|
22
|
-
- an AIP-40 extension of AIP-42 — pricing is not app-specific.
|
|
23
|
-
|
|
24
|
-
## Filesystem layout
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
products/
|
|
28
|
-
<id>.md ← one manifest per pricing capability
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The markdown body (after the frontmatter block) is purely documentary.
|
|
32
|
-
|
|
33
|
-
## Manifest shape
|
|
34
|
-
|
|
35
|
-
```yaml
|
|
36
|
-
---
|
|
37
|
-
schema: product/v1
|
|
38
|
-
id: book1-coder
|
|
39
|
-
kind: pricing
|
|
40
|
-
title: book1 companion — coder
|
|
41
|
-
description: Open-source companion code, pay per call.
|
|
42
|
-
on: aip://14/coder # AIP-54 ref — the ONLY reference field
|
|
43
|
-
|
|
44
|
-
price:
|
|
45
|
-
model: pay-per-call
|
|
46
|
-
unitPriceMinor: 2
|
|
47
|
-
currency: usd
|
|
48
|
-
meter: agent-call
|
|
49
|
-
|
|
50
|
-
billingRail:
|
|
51
|
-
rail: stripe
|
|
52
|
-
priceId: price_metered_1
|
|
53
|
-
meterId: meter_abc
|
|
54
|
-
recurrence: month
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Normative fields
|
|
58
|
-
|
|
59
|
-
| Field | Req | Notes |
|
|
60
|
-
|---|---|---|
|
|
61
|
-
| `schema` | MUST | `product/v1` |
|
|
62
|
-
| `id` | MUST | kebab-case |
|
|
63
|
-
| `on` | MUST | AIP-54 `ref/v1`. May also be given as the `aip://<aip>/<id>[@version]` string form, which implementations MUST normalize (parse + validate) into `ref/v1` before storing. The target AIP needs zero pricing awareness. Hosts MUST refuse unresolvable refs. |
|
|
64
|
-
| `price` | MUST | Discriminated on `model`: `one-time` \| `prepaid-pool` \| `pay-per-call`. **Minor units are normative.** |
|
|
65
|
-
| `billingRail` | MAY | Projection config, never the price's source of truth. See § Billing rails. |
|
|
66
|
-
| `kind` | MUST | `pricing` (fixed — this AIP defines the pricing capability; future capability kinds may share the pattern). |
|
|
67
|
-
| `title`, `description`, `metadata` | MAY | |
|
|
68
|
-
|
|
69
|
-
## Billing rails
|
|
70
|
-
|
|
71
|
-
The rail is **config, not truth**. A generator derives the provider
|
|
72
|
-
objects from `price`; the ids stored on the rail are caches of the last
|
|
73
|
-
projection.
|
|
74
|
-
|
|
75
|
-
- **`stripe`** — `one-time` → Product + `one_time` Price (1:1, no leak).
|
|
76
|
-
`pay-per-call` → metered Price **plus a Stripe Meter**, created
|
|
77
|
-
out-of-band: `meterId` is REQUIRED. `prepaid-pool` has NO native
|
|
78
|
-
Stripe primitive — pool state lives host-side on every rail; Stripe
|
|
79
|
-
only initiates the top-up payment.
|
|
80
|
-
- **`autumn`** — natively models both metered usage and prepaid credit
|
|
81
|
-
grants; both metered shapes project onto one `featureId`. No leak.
|
|
82
|
-
- **`tbd`** — shape decided, provider not chosen.
|
|
83
|
-
- **Vendor rails** — open, config rides along.
|
|
84
|
-
|
|
85
|
-
## Worked examples (Agentik verticals)
|
|
86
|
-
|
|
87
|
-
```yaml
|
|
88
|
-
# book1/coder — open repo, pay-per-call
|
|
89
|
-
schema: product/v1
|
|
90
|
-
id: book1-coder
|
|
91
|
-
kind: pricing
|
|
92
|
-
on: aip://14/coder
|
|
93
|
-
price: { model: pay-per-call, unitPriceMinor: 2, currency: usd, meter: agent-call }
|
|
94
|
-
billingRail: { rail: stripe, meterId: meter_abc, recurrence: month }
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
```yaml
|
|
98
|
-
# book3/SEO — private bundle, prepaid pool
|
|
99
|
-
schema: product/v1
|
|
100
|
-
id: book3-seo
|
|
101
|
-
kind: pricing
|
|
102
|
-
on: aip://14/seo-private@1.2.0
|
|
103
|
-
price: { model: prepaid-pool, unitPriceMinor: 5, currency: usd, grantUnits: 200 }
|
|
104
|
-
billingRail: { rail: autumn, featureId: seo-credits }
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
```yaml
|
|
108
|
-
# default vertical — book + private app bundle, one-time
|
|
109
|
-
schema: product/v1
|
|
110
|
-
id: bookN-companion
|
|
111
|
-
kind: pricing
|
|
112
|
-
on: aip://42/book-companion
|
|
113
|
-
price: { model: one-time, amountMinor: 4900, currency: usd }
|
|
114
|
-
billingRail: { rail: tbd }
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Implementation sketch (TS path)
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
import { attachPricing } from "@agentproto/product"
|
|
121
|
-
import { refFor } from "@agentproto/ref"
|
|
122
|
-
|
|
123
|
-
const cap = attachPricing(refFor(appSpec, appHandle, "1.2.0"), {
|
|
124
|
-
model: "one-time", amountMinor: 4900, currency: "usd",
|
|
125
|
-
})
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
"a collection of priced things" = `collectPriced(products, ref =>
|
|
129
|
-
catalog.resolve(ref))` — returns `{resolved, dangling}`: `resolved` pairs
|
|
130
|
-
each product with its resolved target, and `dangling` lists the products
|
|
131
|
-
whose `on` ref did not resolve, so a host can surface them instead of
|
|
132
|
-
having them silently dropped from the collection.
|
|
133
|
-
|
|
134
|
-
## Residual risks (from dogfooding)
|
|
135
|
-
|
|
136
|
-
1. **AIP-52's legacy `pricing` block** (unitless `{ebook?, bundle,
|
|
137
|
-
step?}`) predates this spec. THIS product's price is authoritative;
|
|
138
|
-
hosts SHOULD warn when a pack's `pricing` diverges from a pricing
|
|
139
|
-
capability attached to it.
|
|
140
|
-
2. **Stripe prepaid-pool leak is inherent**: Stripe has no credit-pool
|
|
141
|
-
concept; pool state lives host-side on every rail. The schema says
|
|
142
|
-
so rather than implying a clean projection.
|
|
143
|
-
3. **Autumn composes cleanly for both metered shapes.**
|