@gtrabanco/agentic-workflow-schema 1.0.0 → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +14 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +136 -17
- package/envelope.schema.json +1 -1
- package/package.json +5 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gabriel Trabanco <gtrabanco@users.noreply.github.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Types, JSON Schema, and parser/validator for the
|
|
4
4
|
[agentic-workflow](https://github.com/gtrabanco/agentic-workflow) **machine
|
|
5
|
-
envelope** — the fixed JSON block
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
envelope** — the fixed JSON block a driven agent turn ends with (emitted by
|
|
6
|
+
`workflow-status` always, and by any other skill when the driver injects the
|
|
7
|
+
canonical system-prompt snippet — see the driver protocol below), so external
|
|
8
|
+
orchestrators can route the workflow programmatically (which command next, on
|
|
9
|
+
which model tier).
|
|
8
10
|
|
|
9
11
|
Zero runtime dependencies. Source of truth for the contract:
|
|
10
12
|
[`skills/orchestration-envelope/SKILL.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/skills/orchestration-envelope/SKILL.md);
|
|
@@ -43,7 +45,15 @@ one per turn, all top-level keys always present.
|
|
|
43
45
|
|
|
44
46
|
Also exported: `extractLastJsonBlock(text)`, `validateEnvelope(value)`,
|
|
45
47
|
`ENVELOPE_STATES` (the 11-state enum), `TERMINAL_STATES`, and every field
|
|
46
|
-
type. A language-agnostic **JSON Schema** ships too
|
|
48
|
+
type. A language-agnostic **JSON Schema** ships too — works on the
|
|
49
|
+
`engines.node` minimum (>=18):
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { createRequire } from "node:module";
|
|
53
|
+
const schema = createRequire(import.meta.url)("@gtrabanco/agentic-workflow-schema/envelope.schema.json");
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
On Node 20.10+/22, the newer import-attributes form also works:
|
|
47
57
|
|
|
48
58
|
```ts
|
|
49
59
|
import schema from "@gtrabanco/agentic-workflow-schema/envelope.schema.json" with { type: "json" };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @gtrabanco/agentic-workflow-schema
|
|
3
3
|
*
|
|
4
4
|
* Types, extraction, and validation for the agentic-workflow **machine
|
|
5
|
-
* envelope** — the fixed JSON block
|
|
6
|
-
*
|
|
5
|
+
* envelope** — the fixed JSON block a driven agent turn ends with (emitted by
|
|
6
|
+
* workflow-status always, and by any other skill when the driver injects the
|
|
7
|
+
* canonical system-prompt snippet).
|
|
7
8
|
*
|
|
8
9
|
* Parse contract (mirrors skills/orchestration-envelope/SKILL.md):
|
|
9
10
|
* take the LAST fenced ```json block of the assistant's final message;
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @gtrabanco/agentic-workflow-schema
|
|
3
3
|
*
|
|
4
4
|
* Types, extraction, and validation for the agentic-workflow **machine
|
|
5
|
-
* envelope** — the fixed JSON block
|
|
6
|
-
*
|
|
5
|
+
* envelope** — the fixed JSON block a driven agent turn ends with (emitted by
|
|
6
|
+
* workflow-status always, and by any other skill when the driver injects the
|
|
7
|
+
* canonical system-prompt snippet).
|
|
7
8
|
*
|
|
8
9
|
* Parse contract (mirrors skills/orchestration-envelope/SKILL.md):
|
|
9
10
|
* take the LAST fenced ```json block of the assistant's final message;
|
|
@@ -49,6 +50,28 @@ export function extractLastJsonBlock(text) {
|
|
|
49
50
|
function isObj(v) {
|
|
50
51
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
51
52
|
}
|
|
53
|
+
function isIntOrNull(v) {
|
|
54
|
+
return v === null || (typeof v === "number" && Number.isInteger(v));
|
|
55
|
+
}
|
|
56
|
+
function isStringOrNull(v) {
|
|
57
|
+
return v === null || typeof v === "string";
|
|
58
|
+
}
|
|
59
|
+
function isStringArray(v) {
|
|
60
|
+
return Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
61
|
+
}
|
|
62
|
+
const UNIT_TYPES = ["feature", "fix", "docs", "none"];
|
|
63
|
+
const PR_STATES = ["open", "merged", "none"];
|
|
64
|
+
const CI_STATES = ["green", "red", "pending", "none"];
|
|
65
|
+
const VERIFICATION_STATES = ["green", "red", "not-run"];
|
|
66
|
+
const BLOCKER_KINDS = [
|
|
67
|
+
"dependency",
|
|
68
|
+
"issue",
|
|
69
|
+
"gate",
|
|
70
|
+
"merge-conflict",
|
|
71
|
+
"substrate",
|
|
72
|
+
"input",
|
|
73
|
+
];
|
|
74
|
+
const BLOCKER_SCOPES = ["unit", "run"];
|
|
52
75
|
const REQUIRED_KEYS = [
|
|
53
76
|
"skill",
|
|
54
77
|
"state",
|
|
@@ -87,46 +110,137 @@ export function validateEnvelope(value) {
|
|
|
87
110
|
if (typeof value.summary !== "string") {
|
|
88
111
|
errors.push("summary must be a string");
|
|
89
112
|
}
|
|
90
|
-
if (!isObj(value.unit))
|
|
113
|
+
if (!isObj(value.unit)) {
|
|
91
114
|
errors.push("unit must be an object");
|
|
92
|
-
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const unit = value.unit;
|
|
118
|
+
if (!UNIT_TYPES.includes(unit.type)) {
|
|
119
|
+
errors.push(`unit.type must be one of ${UNIT_TYPES.join("|")} (got: ${String(unit.type)})`);
|
|
120
|
+
}
|
|
121
|
+
if (!isStringOrNull(unit.id))
|
|
122
|
+
errors.push("unit.id must be a string or null");
|
|
123
|
+
if (!isIntOrNull(unit.issue))
|
|
124
|
+
errors.push("unit.issue must be an integer or null");
|
|
125
|
+
if (!isStringOrNull(unit.branch))
|
|
126
|
+
errors.push("unit.branch must be a string or null");
|
|
127
|
+
}
|
|
128
|
+
if (!isObj(value.phase)) {
|
|
93
129
|
errors.push("phase must be an object");
|
|
94
|
-
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const phase = value.phase;
|
|
133
|
+
if (!isStringOrNull(phase.current))
|
|
134
|
+
errors.push("phase.current must be a string or null");
|
|
135
|
+
if (!isIntOrNull(phase.total))
|
|
136
|
+
errors.push("phase.total must be an integer or null");
|
|
137
|
+
if (!isIntOrNull(phase.completed))
|
|
138
|
+
errors.push("phase.completed must be an integer or null");
|
|
139
|
+
}
|
|
140
|
+
if (!isObj(value.pr)) {
|
|
95
141
|
errors.push("pr must be an object");
|
|
96
|
-
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const pr = value.pr;
|
|
145
|
+
if (!isIntOrNull(pr.number))
|
|
146
|
+
errors.push("pr.number must be an integer or null");
|
|
147
|
+
if (!isStringOrNull(pr.url))
|
|
148
|
+
errors.push("pr.url must be a string or null");
|
|
149
|
+
if (!PR_STATES.includes(pr.state)) {
|
|
150
|
+
errors.push(`pr.state must be one of ${PR_STATES.join("|")} (got: ${String(pr.state)})`);
|
|
151
|
+
}
|
|
152
|
+
if (!isStringOrNull(pr.head_sha))
|
|
153
|
+
errors.push("pr.head_sha must be a string or null");
|
|
154
|
+
if (pr.merge_ready !== null && typeof pr.merge_ready !== "boolean") {
|
|
155
|
+
errors.push("pr.merge_ready must be a boolean or null");
|
|
156
|
+
}
|
|
157
|
+
if (pr.ci !== null && !CI_STATES.includes(pr.ci)) {
|
|
158
|
+
errors.push(`pr.ci must be one of ${CI_STATES.join("|")} or null (got: ${String(pr.ci)})`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (!isObj(value.gates)) {
|
|
97
162
|
errors.push("gates must be an object");
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const gates = value.gates;
|
|
166
|
+
if (gates.verification !== null && !VERIFICATION_STATES.includes(gates.verification)) {
|
|
167
|
+
errors.push(`gates.verification must be one of ${VERIFICATION_STATES.join("|")} or null (got: ${String(gates.verification)})`);
|
|
168
|
+
}
|
|
169
|
+
if (gates.review_pending !== null && typeof gates.review_pending !== "boolean") {
|
|
170
|
+
errors.push("gates.review_pending must be a boolean or null");
|
|
171
|
+
}
|
|
172
|
+
if (gates.audit_pending !== null && typeof gates.audit_pending !== "boolean") {
|
|
173
|
+
errors.push("gates.audit_pending must be a boolean or null");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
98
176
|
if (!Array.isArray(value.blockers)) {
|
|
99
177
|
errors.push("blockers must be an array");
|
|
100
178
|
}
|
|
101
179
|
else {
|
|
102
180
|
value.blockers.forEach((b, i) => {
|
|
103
|
-
if (!isObj(b)
|
|
104
|
-
errors.push(`blockers[${i}] must be
|
|
181
|
+
if (!isObj(b)) {
|
|
182
|
+
errors.push(`blockers[${i}] must be an object`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!BLOCKER_KINDS.includes(b.kind)) {
|
|
186
|
+
errors.push(`blockers[${i}].kind must be one of ${BLOCKER_KINDS.join("|")} (got: ${String(b.kind)})`);
|
|
105
187
|
}
|
|
188
|
+
if (typeof b.id !== "string")
|
|
189
|
+
errors.push(`blockers[${i}].id must be a string`);
|
|
190
|
+
if (!BLOCKER_SCOPES.includes(b.scope)) {
|
|
191
|
+
errors.push(`blockers[${i}].scope must be one of ${BLOCKER_SCOPES.join("|")} (got: ${String(b.scope)})`);
|
|
192
|
+
}
|
|
193
|
+
if (typeof b.detail !== "string")
|
|
194
|
+
errors.push(`blockers[${i}].detail must be a string`);
|
|
106
195
|
});
|
|
107
196
|
}
|
|
108
197
|
if (!isObj(value.dependencies)) {
|
|
109
198
|
errors.push("dependencies must be an object");
|
|
110
199
|
}
|
|
111
200
|
else {
|
|
112
|
-
if (!
|
|
113
|
-
errors.push("dependencies.unmet must be an array");
|
|
201
|
+
if (!isStringArray(value.dependencies.unmet)) {
|
|
202
|
+
errors.push("dependencies.unmet must be an array of strings");
|
|
114
203
|
}
|
|
115
|
-
if (!
|
|
116
|
-
errors.push("dependencies.build_order must be an array");
|
|
204
|
+
if (!isStringArray(value.dependencies.build_order)) {
|
|
205
|
+
errors.push("dependencies.build_order must be an array of strings");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (!isObj(value.recommendations)) {
|
|
209
|
+
errors.push("recommendations must be an object");
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
if (typeof value.recommendations.product_audit !== "boolean") {
|
|
213
|
+
errors.push("recommendations.product_audit must be a boolean");
|
|
214
|
+
}
|
|
215
|
+
if (!isStringOrNull(value.recommendations.reason)) {
|
|
216
|
+
errors.push("recommendations.reason must be a string or null");
|
|
117
217
|
}
|
|
118
218
|
}
|
|
119
219
|
if (!isObj(value.findings)) {
|
|
120
220
|
errors.push("findings must be an object");
|
|
121
221
|
}
|
|
122
222
|
else {
|
|
123
|
-
|
|
223
|
+
const findings = value.findings;
|
|
224
|
+
if (!Array.isArray(findings.fix_now)) {
|
|
124
225
|
errors.push("findings.fix_now must be an array");
|
|
125
226
|
}
|
|
126
|
-
|
|
127
|
-
|
|
227
|
+
else {
|
|
228
|
+
findings.fix_now.forEach((f, i) => {
|
|
229
|
+
if (!isObj(f) || typeof f.ref !== "string" || typeof f.title !== "string") {
|
|
230
|
+
errors.push(`findings.fix_now[${i}] must be {ref, title, file?}`);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (!Array.isArray(findings.issues_filed) ||
|
|
235
|
+
!findings.issues_filed.every((n) => typeof n === "number" && Number.isInteger(n))) {
|
|
128
236
|
errors.push("findings.issues_filed must be an array of integers");
|
|
129
237
|
}
|
|
238
|
+
if (typeof findings.untriaged !== "number" || !Number.isInteger(findings.untriaged)) {
|
|
239
|
+
errors.push("findings.untriaged must be an integer");
|
|
240
|
+
}
|
|
241
|
+
if (typeof findings.decisions_recorded !== "number" || !Number.isInteger(findings.decisions_recorded)) {
|
|
242
|
+
errors.push("findings.decisions_recorded must be an integer");
|
|
243
|
+
}
|
|
130
244
|
}
|
|
131
245
|
if (!isObj(value.next)) {
|
|
132
246
|
errors.push("next must be an object");
|
|
@@ -135,13 +249,18 @@ export function validateEnvelope(value) {
|
|
|
135
249
|
if (typeof value.next.recommended !== "string") {
|
|
136
250
|
errors.push("next.recommended must be a string");
|
|
137
251
|
}
|
|
252
|
+
if (!isStringArray(value.next.alternatives)) {
|
|
253
|
+
errors.push("next.alternatives must be an array of strings");
|
|
254
|
+
}
|
|
138
255
|
if (value.next.tier !== "strong" && value.next.tier !== "cheap") {
|
|
139
256
|
errors.push(`next.tier must be strong|cheap (got: ${String(value.next.tier)})`);
|
|
140
257
|
}
|
|
141
258
|
}
|
|
142
259
|
if (value.needs_input !== null && value.needs_input !== undefined) {
|
|
143
|
-
if (!isObj(value.needs_input) ||
|
|
144
|
-
|
|
260
|
+
if (!isObj(value.needs_input) ||
|
|
261
|
+
typeof value.needs_input.question !== "string" ||
|
|
262
|
+
!isStringArray(value.needs_input.options)) {
|
|
263
|
+
errors.push("needs_input must be null or {question: string, options: string[]}");
|
|
145
264
|
}
|
|
146
265
|
}
|
|
147
266
|
if (errors.length > 0)
|
package/envelope.schema.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://github.com/gtrabanco/agentic-workflow/packages/agentic-workflow-schema/envelope.schema.json",
|
|
4
4
|
"title": "agentic-workflow machine envelope",
|
|
5
|
-
"description": "The fixed JSON block
|
|
5
|
+
"description": "The fixed JSON block a driven agentic-workflow agent turn ends with (emitted by workflow-status always, and by any other skill when the driver injects the canonical system-prompt snippet). Source of truth: skills/orchestration-envelope/SKILL.md.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"required": [
|
|
8
8
|
"skill",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtrabanco/agentic-workflow-schema",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Types, JSON Schema, and parser/validator for the agentic-workflow machine envelope — the fixed JSON block
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Types, JSON Schema, and parser/validator for the agentic-workflow machine envelope — the fixed JSON block a driven agent turn ends with (workflow-status always; other skills under the driver-injected snippet), for programmatic orchestration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentic-workflow",
|
|
7
7
|
"agent",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
33
|
"envelope.schema.json",
|
|
34
|
-
"README.md"
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
35
36
|
],
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=18"
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "tsc",
|
|
44
|
-
"test": "
|
|
45
|
+
"test": "tsc && node --test test/index.test.mjs",
|
|
45
46
|
"prepublishOnly": "npm test"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|