@monarchic-ai/monarchic-agent-protocol 0.1.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 +295 -0
- package/package.json +21 -0
- package/src/ts/index.ts +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Monarchic AI Protocol
|
|
2
|
+
|
|
3
|
+
This repository defines the shared, versioned protocol for Monarchic AI. It is the compatibility layer between the orchestrator, runner, and agent roles, so the schemas are minimal and stable while allowing forward-compatible extensions.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
- Provide versioned JSON Schemas for language-agnostic validation.
|
|
8
|
+
- Provide Rust, TypeScript, and Protobuf bindings that mirror the schemas.
|
|
9
|
+
- Keep the protocol small and explicit for v1 interoperability.
|
|
10
|
+
|
|
11
|
+
## Versioning
|
|
12
|
+
|
|
13
|
+
- Protocol versions live under `schemas/v1/`.
|
|
14
|
+
- Each v1 object requires `version: "v1"`.
|
|
15
|
+
- New versions must be added under a new directory (e.g. `schemas/v2/`) without changing existing v1 files.
|
|
16
|
+
|
|
17
|
+
## Protocol v1 schema
|
|
18
|
+
|
|
19
|
+
Schema files live under `schemas/v1/`:
|
|
20
|
+
|
|
21
|
+
- `schemas/v1/task.json`
|
|
22
|
+
- `schemas/v1/artifact.json`
|
|
23
|
+
- `schemas/v1/event.json`
|
|
24
|
+
- `schemas/v1/gate_result.json`
|
|
25
|
+
- `schemas/v1/run_context.json`
|
|
26
|
+
- `schemas/v1/agent_role.json`
|
|
27
|
+
- `schemas/v1/schema.json` (index)
|
|
28
|
+
- `schemas/v1/monarchic_agent_protocol.proto`
|
|
29
|
+
|
|
30
|
+
All schemas allow additional properties for forward compatibility.
|
|
31
|
+
|
|
32
|
+
### AgentRole
|
|
33
|
+
|
|
34
|
+
Enum values:
|
|
35
|
+
|
|
36
|
+
- `product_owner`
|
|
37
|
+
- `project_manager`
|
|
38
|
+
- `dev`
|
|
39
|
+
- `qa`
|
|
40
|
+
- `reviewer`
|
|
41
|
+
- `security`
|
|
42
|
+
- `ops`
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"role": "reviewer"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Task
|
|
53
|
+
|
|
54
|
+
Represents work assigned to an agent.
|
|
55
|
+
|
|
56
|
+
Required fields:
|
|
57
|
+
|
|
58
|
+
- `version`: `"v1"`
|
|
59
|
+
- `task_id`: stable identifier
|
|
60
|
+
- `role`: `AgentRole`
|
|
61
|
+
- `goal`: human-readable objective
|
|
62
|
+
|
|
63
|
+
Optional fields:
|
|
64
|
+
|
|
65
|
+
- `inputs`: free-form object
|
|
66
|
+
- `constraints`: free-form object
|
|
67
|
+
- `gates_required`: list of gate names to run (ex: `["qa", "security"]`)
|
|
68
|
+
- `run_context`: `RunContext`
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"version": "v1",
|
|
75
|
+
"task_id": "task-123",
|
|
76
|
+
"role": "dev",
|
|
77
|
+
"goal": "Implement protocol types",
|
|
78
|
+
"inputs": {
|
|
79
|
+
"issue": "https://example.com/issues/42"
|
|
80
|
+
},
|
|
81
|
+
"constraints": {
|
|
82
|
+
"no_network": true
|
|
83
|
+
},
|
|
84
|
+
"gates_required": ["qa", "security"],
|
|
85
|
+
"run_context": {
|
|
86
|
+
"version": "v1",
|
|
87
|
+
"repo": "monarchic-agent-protocol",
|
|
88
|
+
"worktree": "/worktrees/task-123",
|
|
89
|
+
"image": "ghcr.io/monarchic/runner:stable",
|
|
90
|
+
"runner": "vm-runner-01",
|
|
91
|
+
"labels": ["linux", "rust"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### RunContext
|
|
97
|
+
|
|
98
|
+
Execution hints for a runner.
|
|
99
|
+
|
|
100
|
+
Required fields:
|
|
101
|
+
|
|
102
|
+
- `version`: `"v1"`
|
|
103
|
+
- `repo`: repository identifier or URL
|
|
104
|
+
- `worktree`: worktree path or identifier
|
|
105
|
+
- `image`: VM/container image reference
|
|
106
|
+
- `runner`: runner identifier
|
|
107
|
+
|
|
108
|
+
Optional fields:
|
|
109
|
+
|
|
110
|
+
- `labels`: list of labels or tags
|
|
111
|
+
|
|
112
|
+
Example:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"version": "v1",
|
|
117
|
+
"repo": "monarchic-agent-protocol",
|
|
118
|
+
"worktree": "/worktrees/task-123",
|
|
119
|
+
"image": "ghcr.io/monarchic/runner:stable",
|
|
120
|
+
"runner": "vm-runner-01",
|
|
121
|
+
"labels": ["linux", "rust"]
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Artifact
|
|
126
|
+
|
|
127
|
+
Outputs produced by an agent or runner.
|
|
128
|
+
|
|
129
|
+
Required fields:
|
|
130
|
+
|
|
131
|
+
- `version`: `"v1"`
|
|
132
|
+
- `artifact_id`: stable identifier
|
|
133
|
+
- `type`: artifact type (ex: `patch`, `log`, `report`)
|
|
134
|
+
- `summary`: short description
|
|
135
|
+
- `path`: path or locator for the artifact
|
|
136
|
+
- `task_id`: task identifier that produced it
|
|
137
|
+
|
|
138
|
+
Example:
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"version": "v1",
|
|
143
|
+
"artifact_id": "artifact-987",
|
|
144
|
+
"type": "patch",
|
|
145
|
+
"summary": "Adds v1 protocol schemas",
|
|
146
|
+
"path": "artifacts/task-123/patch.diff",
|
|
147
|
+
"task_id": "task-123"
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Event
|
|
152
|
+
|
|
153
|
+
Lifecycle state updates.
|
|
154
|
+
|
|
155
|
+
Required fields:
|
|
156
|
+
|
|
157
|
+
- `version`: `"v1"`
|
|
158
|
+
- `event_type`: event category
|
|
159
|
+
- `timestamp`: ISO 8601 timestamp
|
|
160
|
+
- `task_id`: task identifier
|
|
161
|
+
- `status`: state label
|
|
162
|
+
|
|
163
|
+
Optional fields:
|
|
164
|
+
|
|
165
|
+
- `message`: human-readable details
|
|
166
|
+
|
|
167
|
+
Example:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"version": "v1",
|
|
172
|
+
"event_type": "task_started",
|
|
173
|
+
"timestamp": "2025-01-14T15:04:05Z",
|
|
174
|
+
"task_id": "task-123",
|
|
175
|
+
"status": "running",
|
|
176
|
+
"message": "Runner started VM"
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### GateResult
|
|
181
|
+
|
|
182
|
+
Outcome of QA, review, security, or other gates.
|
|
183
|
+
|
|
184
|
+
Required fields:
|
|
185
|
+
|
|
186
|
+
- `version`: `"v1"`
|
|
187
|
+
- `gate`: gate name
|
|
188
|
+
- `status`: pass/fail or other gate-specific status
|
|
189
|
+
|
|
190
|
+
Optional fields:
|
|
191
|
+
|
|
192
|
+
- `reason`: short explanation
|
|
193
|
+
- `evidence`: free-form object with supporting data
|
|
194
|
+
|
|
195
|
+
Example:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"version": "v1",
|
|
200
|
+
"gate": "security",
|
|
201
|
+
"status": "pass",
|
|
202
|
+
"reason": "No high or critical findings",
|
|
203
|
+
"evidence": {
|
|
204
|
+
"scanner": "trivy",
|
|
205
|
+
"report_path": "artifacts/task-123/security.json"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Rust
|
|
211
|
+
|
|
212
|
+
The crate lives at the repo root with sources under `src/rust/lib.rs`.
|
|
213
|
+
|
|
214
|
+
```rust
|
|
215
|
+
use monarchic_agent_protocol::{AgentRole, Task, PROTOCOL_VERSION};
|
|
216
|
+
|
|
217
|
+
let task = Task {
|
|
218
|
+
version: PROTOCOL_VERSION.to_string(),
|
|
219
|
+
task_id: "task-123".to_string(),
|
|
220
|
+
role: AgentRole::Dev,
|
|
221
|
+
goal: "Implement protocol".to_string(),
|
|
222
|
+
inputs: None,
|
|
223
|
+
constraints: None,
|
|
224
|
+
gates_required: None,
|
|
225
|
+
run_context: None,
|
|
226
|
+
extensions: Default::default(),
|
|
227
|
+
};
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## TypeScript
|
|
231
|
+
|
|
232
|
+
TypeScript bindings are in `src/ts/index.ts`.
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { Task } from "./src/ts/index";
|
|
236
|
+
|
|
237
|
+
const task: Task = {
|
|
238
|
+
version: "v1",
|
|
239
|
+
task_id: "task-123",
|
|
240
|
+
role: "dev",
|
|
241
|
+
goal: "Implement protocol",
|
|
242
|
+
};
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Protobuf
|
|
246
|
+
|
|
247
|
+
The v1 protobuf schema lives at `schemas/v1/monarchic_agent_protocol.proto`. It mirrors the JSON schema and uses `google.protobuf.Struct` for free-form objects (`inputs`, `constraints`, `evidence`, `extensions`). Additional JSON properties should be stored in the `extensions` field on each message.
|
|
248
|
+
|
|
249
|
+
Language packages are published per registry. Use the registry package for your language instead of generating local outputs.
|
|
250
|
+
|
|
251
|
+
## Examples
|
|
252
|
+
|
|
253
|
+
- Rust: `examples/rust/task.rs`
|
|
254
|
+
- TypeScript: `examples/ts/task.ts`
|
|
255
|
+
- Protobuf C++: `examples/proto/cpp/task.cpp`
|
|
256
|
+
- Protobuf Java: `examples/proto/java/TaskExample.java`
|
|
257
|
+
- Protobuf Kotlin: `examples/proto/kotlin/TaskExample.kt`
|
|
258
|
+
- Protobuf C#: `examples/proto/csharp/TaskExample.cs`
|
|
259
|
+
- Protobuf Python: `examples/proto/python/task.py`
|
|
260
|
+
- Protobuf Ruby: `examples/proto/ruby/task.rb`
|
|
261
|
+
- Protobuf Objective-C: `examples/proto/objective-c/TaskExample.m`
|
|
262
|
+
- Protobuf PHP: `examples/proto/php/task.php`
|
|
263
|
+
- Protobuf Dart: `examples/proto/dart/task.dart`
|
|
264
|
+
- Protobuf Rust: `examples/proto/rust/task.rs`
|
|
265
|
+
|
|
266
|
+
## Python (PyPI)
|
|
267
|
+
|
|
268
|
+
Install the published package and import the generated protobuf bindings:
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
from monarchic_agent_protocol import monarchic_agent_protocol_pb2 as map_pb2
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Validation and tooling
|
|
275
|
+
|
|
276
|
+
- `nix develop` provides Rust, Node, jq, Python `jsonschema`, and `protoc`.
|
|
277
|
+
- `nix flake check` validates JSON schemas, protobuf codegen, and package imports (PyPI + Rust + npm).
|
|
278
|
+
- JSON Schema test: `scripts/test-json-schema.sh`.
|
|
279
|
+
- Protobuf codegen test (all languages): `scripts/test-proto.sh`.
|
|
280
|
+
|
|
281
|
+
## Nix packages
|
|
282
|
+
|
|
283
|
+
- `packages.default`: Rust crate for protocol types
|
|
284
|
+
- `packages.rust-lib`: Rust crate for protocol types (explicit)
|
|
285
|
+
- `packages.crate-lib`: Rust crate from crates.io (registry)
|
|
286
|
+
- `packages.python-lib`: installable Python package (generated during build)
|
|
287
|
+
- `packages.pypi-lib`: PyPI package import test artifact
|
|
288
|
+
- `packages.ts-lib`: TypeScript types package (local)
|
|
289
|
+
- `packages.npm-lib`: npm registry package (types-only)
|
|
290
|
+
|
|
291
|
+
## CI and releases
|
|
292
|
+
|
|
293
|
+
- `.github/workflows/ci.yml` validates JSON schemas, protobuf codegen, and runs `cargo test`.
|
|
294
|
+
- `.github/workflows/release.yml` publishes language packages.
|
|
295
|
+
- Python publishing is implemented for PyPI; other language registry steps are scaffolded.
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@monarchic-ai/monarchic-agent-protocol",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared protocol types for Monarchic AI (TypeScript)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/monarchic-ai/monarchic-agent-protocol"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/monarchic-ai/monarchic-agent-protocol",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"types": "src/ts/index.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./src/ts/index.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"src/ts"
|
|
20
|
+
]
|
|
21
|
+
}
|
package/src/ts/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type ProtocolVersion = "v1";
|
|
2
|
+
|
|
3
|
+
export type AgentRole =
|
|
4
|
+
| "product_owner"
|
|
5
|
+
| "project_manager"
|
|
6
|
+
| "dev"
|
|
7
|
+
| "qa"
|
|
8
|
+
| "reviewer"
|
|
9
|
+
| "security"
|
|
10
|
+
| "ops";
|
|
11
|
+
|
|
12
|
+
export interface Task {
|
|
13
|
+
version: ProtocolVersion;
|
|
14
|
+
task_id: string;
|
|
15
|
+
role: AgentRole;
|
|
16
|
+
goal: string;
|
|
17
|
+
inputs?: Record<string, unknown>;
|
|
18
|
+
constraints?: Record<string, unknown>;
|
|
19
|
+
gates_required?: string[];
|
|
20
|
+
run_context?: RunContext;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Artifact {
|
|
25
|
+
version: ProtocolVersion;
|
|
26
|
+
artifact_id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
summary: string;
|
|
29
|
+
path: string;
|
|
30
|
+
task_id: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Event {
|
|
35
|
+
version: ProtocolVersion;
|
|
36
|
+
event_type: string;
|
|
37
|
+
timestamp: string;
|
|
38
|
+
task_id: string;
|
|
39
|
+
status: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GateResult {
|
|
45
|
+
version: ProtocolVersion;
|
|
46
|
+
gate: string;
|
|
47
|
+
status: string;
|
|
48
|
+
reason?: string;
|
|
49
|
+
evidence?: Record<string, unknown>;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RunContext {
|
|
54
|
+
version: ProtocolVersion;
|
|
55
|
+
repo: string;
|
|
56
|
+
worktree: string;
|
|
57
|
+
image: string;
|
|
58
|
+
runner: string;
|
|
59
|
+
labels?: string[];
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|