@gtrabanco/agentic-workflow-schema 2.1.0 → 3.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.es.md +118 -167
- package/README.md +113 -157
- package/dist/index.d.ts +240 -5
- package/dist/index.js +1087 -10
- package/envelope.schema.json +17 -3
- package/package.json +9 -5
- package/skill-outcome.schema.json +68 -0
- package/workflow-snapshot.schema.json +90 -0
package/README.md
CHANGED
|
@@ -2,18 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> 🇪🇸 [Versión en español](README.es.md)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[agentic-workflow](https://github.com/gtrabanco/agentic-workflow)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
orchestrators can route the workflow programmatically (which command next, on
|
|
11
|
-
which model tier).
|
|
12
|
-
|
|
13
|
-
Zero runtime dependencies. Source of truth for the contract:
|
|
14
|
-
[`skills/orchestration-envelope/SKILL.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/skills/orchestration-envelope/SKILL.md);
|
|
15
|
-
driver protocol:
|
|
16
|
-
[`docs/workflow/ORCHESTRATION.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/docs/workflow/ORCHESTRATION.md).
|
|
5
|
+
Zero-runtime-dependency machine contracts for
|
|
6
|
+
[agentic-workflow](https://github.com/gtrabanco/agentic-workflow). Version 3
|
|
7
|
+
keeps the established `workflow-status` envelope while giving headless drivers
|
|
8
|
+
a smaller result for working skills and deterministic state compiled from
|
|
9
|
+
documents.
|
|
17
10
|
|
|
18
11
|
## Install
|
|
19
12
|
|
|
@@ -21,176 +14,139 @@ driver protocol:
|
|
|
21
14
|
npm install @gtrabanco/agentic-workflow-schema
|
|
22
15
|
```
|
|
23
16
|
|
|
24
|
-
##
|
|
17
|
+
## Three contracts, distinct owners
|
|
18
|
+
|
|
19
|
+
| Contract | Owner | Use |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| Envelope v2 | `workflow-status` | Full read-only sensor result and existing consumers. |
|
|
22
|
+
| SkillOutcome v1 | A driven skill turn | Small model-owned outcome, route, blockers, questions, discoveries, and evidence references. |
|
|
23
|
+
| WorkflowSnapshot v1 | The driver | Deterministic repository and document facts, with provenance, unknowns, and contradictions. |
|
|
24
|
+
|
|
25
|
+
All JSON Schemas are strict: undeclared keys are rejected. `detail` is required
|
|
26
|
+
on Envelope v2 (use `null` when empty); skill-specific extensions belong inside
|
|
27
|
+
it. The schemas are exported at `./envelope.schema.json`,
|
|
28
|
+
`./skill-outcome.schema.json`, and `./workflow-snapshot.schema.json`.
|
|
29
|
+
|
|
30
|
+
## Parse a driven turn
|
|
31
|
+
|
|
32
|
+
Use the profile metadata to select the required result, append the generated
|
|
33
|
+
instruction only to a headless invocation, then parse the final reply.
|
|
25
34
|
|
|
26
35
|
```ts
|
|
27
36
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
parseTurn,
|
|
38
|
+
renderOutputInstruction,
|
|
39
|
+
WORKFLOW_SKILL_PROFILES,
|
|
31
40
|
} from "@gtrabanco/agentic-workflow-schema";
|
|
32
41
|
|
|
33
|
-
const
|
|
42
|
+
const skill = "audit-pr";
|
|
43
|
+
const profile = WORKFLOW_SKILL_PROFILES.find((entry) => entry.skill === skill);
|
|
44
|
+
if (profile === undefined) throw new Error(`Unknown workflow skill: ${skill}`);
|
|
45
|
+
|
|
46
|
+
const output = await invokeAgent({
|
|
47
|
+
prompt: "Follow the installed skill for /audit-pr.",
|
|
48
|
+
systemAppend: renderOutputInstruction(skill),
|
|
49
|
+
});
|
|
34
50
|
|
|
35
|
-
const result =
|
|
51
|
+
const result = parseTurn({ skill, text: output, context: { unitId: "12-machine-contract" } });
|
|
36
52
|
if (!result.ok) throw new Error(result.errors.join("; "));
|
|
37
53
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else if (isTerminal(env.state)) askHuman(env);
|
|
41
|
-
else invokeNext(env.next.recommended, env.next.tier); // "strong" | "cheap"
|
|
54
|
+
// result.outcome is SkillOutcome v1; result.envelope is non-null only for v2.
|
|
55
|
+
route(result.outcome.next.intent, result.outcome.next.targets);
|
|
42
56
|
```
|
|
43
57
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
On a malformed result, re-invoke the *same session once* with `Emit only the
|
|
59
|
+
machine result for the turn above.` and parse again. A second failure is a
|
|
60
|
+
driver-level failure. Do not promote arbitrary prose to structured facts.
|
|
47
61
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`engines.node` minimum (>=18):
|
|
62
|
+
`workflow-status` keeps its native Envelope v2 result. Existing consumers may
|
|
63
|
+
continue to use `parseEnvelope(text)`; new consumers use
|
|
64
|
+
`parseEnvelopeV2Strict(text)` or the uniform `parseTurn({skill, text})`.
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
import { createRequire } from "node:module";
|
|
55
|
-
const schema = createRequire(import.meta.url)("@gtrabanco/agentic-workflow-schema/envelope.schema.json");
|
|
56
|
-
```
|
|
66
|
+
## Capability profiles
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
Every built-in profile in `WORKFLOW_SKILL_PROFILES` carries an optional,
|
|
69
|
+
immutable `capabilities` object: role, reasoning class, **maximum effects**,
|
|
70
|
+
context sources, and required evidence, all from the exported closed
|
|
71
|
+
vocabularies (`SKILL_ROLES`, `SKILL_EFFECTS`, `SKILL_REASONING`,
|
|
72
|
+
`SKILL_CONTEXT_SOURCES`, `SKILL_REQUIRED_EVIDENCE`).
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
import schema from "@gtrabanco/agentic-workflow-schema/envelope.schema.json" with { type: "json" };
|
|
62
|
-
```
|
|
74
|
+
Capability semantics:
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
| `unit.id` | string\|null | open | The unit's identifier (`NN-slug` for features, `n-topic` for fixes). |
|
|
78
|
-
| `unit.issue` | integer\|null | open | The tracking issue number, when the unit is issue-born. |
|
|
79
|
-
| `unit.branch` | string\|null | open | The working branch. |
|
|
80
|
-
| `phase.current` | string\|null | open (by convention `P1`, `P2`, …) | Phase just worked, for phased (M/L) features. |
|
|
81
|
-
| `phase.total` / `phase.completed` | integer\|null | open | Phase counts; `null` for single-pass units. |
|
|
82
|
-
| `pr.number` / `pr.url` / `pr.head_sha` | int/str\|null | open | The unit's PR, once it exists. |
|
|
83
|
-
| `pr.state` | enum | **closed** — `open` · `merged` · `none` | Merge state lives in the forge, not the roadmap. |
|
|
84
|
-
| `pr.merge_ready` | boolean\|null | open | `true` only after an `audit-pr` MERGE-READY verdict on the current head. |
|
|
85
|
-
| `pr.ci` | enum | **closed** — `green` · `red` · `pending` · `none` · `null` | `none` = the project has no CI; `null` = not checked this turn. |
|
|
86
|
-
| `gates.verification` | enum | **closed** — `green` · `red` · `not-run` · `null` | The project's own gate (type-check + tests + build) as last RUN. |
|
|
87
|
-
| `gates.review_pending` / `gates.audit_pending` | boolean\|null | open | Whether the mandatory review / merge audit still has to happen. |
|
|
88
|
-
| `findings.fix_now[]` | object array | items: `id`/`file`/`axis`/`class`/`route` (open), `severity` (**closed** — `high`·`med`·`low`), `suggested_tier` (**closed** — `strong`·`cheap`) | Findings that must fold into the CURRENT branch before it advances — one item per unfolded row of the unit's `review-findings.md` fold ledger. |
|
|
89
|
-
| `findings.issues_filed[]` | integer array | open | Issue numbers created/updated this turn. |
|
|
90
|
-
| `findings.untriaged` | integer ≥ 0 | open | Findings still without a destination — skills whose contract routes everything must report `0`. |
|
|
91
|
-
| `findings.decisions_recorded` | integer ≥ 0 | open | Decisions written to `decisions.md`-class records this turn. |
|
|
92
|
-
| `blockers[].kind` | enum | **closed** — `dependency` · `issue` · `gate` · `merge-conflict` · `substrate` · `input` | Why the unit (or run) cannot proceed. |
|
|
93
|
-
| `blockers[].scope` | enum | **closed** — `unit` · `run` | `run` means stop-the-world: nothing else proceeds either. |
|
|
94
|
-
| `blockers[].id` / `blockers[].detail` | string | open | What exactly (a slug, `#N`, a check name) + one line of context. |
|
|
95
|
-
| `dependencies.unmet[]` / `dependencies.build_order[]` | string arrays | open | Unmet roadmap/issue refs, and the deepest-first order to build them. |
|
|
96
|
-
| `recommendations.product_audit` | boolean | open | `true` when recurring drift suggests the founding assumptions are stale. |
|
|
97
|
-
| `recommendations.reason` | string\|null | open | Why (required in practice when the flag is `true`). |
|
|
98
|
-
| `needs_input` | object\|null | `question` (open) + `options[]` (open) | Non-null only on `state: NEEDS_INPUT` — the human decision to surface, with concrete options. Nothing was guessed. |
|
|
99
|
-
| `next.recommended` | string | open (a skill invocation) | The single best next command. |
|
|
100
|
-
| `next.alternatives[]` | string array | open | The other defensible choices. |
|
|
101
|
-
| `next.tier` | enum | **closed** — `strong` · `cheap` | Which model class the next step deserves — judgment vs mechanical. |
|
|
102
|
-
| `next.suggested[]` | object array, optional | items: `command`/`trigger`/`source_skill` (all open strings) | Trigger-attributed suggestions (`workflow-status` only) — each entry names the command, the exact condition that fired it, and the skill that owns that condition; single-sourced, never a second copy of the trigger logic. Absent on envelopes that don't emit it. |
|
|
103
|
-
| `detail` | any | open (skill-specific) | Per-skill payload — e.g. `workflow-status` carries the full project tree (`features`, `fixes`, `startable_now`, `blocked_units`, `crash_recovery`, …) here. |
|
|
104
|
-
|
|
105
|
-
### The `state` routing table (closed — exactly these 11)
|
|
106
|
-
|
|
107
|
-
| `state` | Meaning | Orchestrator action |
|
|
108
|
-
|---|---|---|
|
|
109
|
-
| `OK` | Skill finished its job | Invoke `next.recommended` on `next.tier` |
|
|
110
|
-
| `CONTINUE` | Same unit, more of the same work | Re-invoke `next.recommended` (advisory checkpoints also land here — the alternative is listed) |
|
|
111
|
-
| `READY_FOR_REVIEW` | Unit finished; mandatory review next | `/review-change` on a strong model, fresh context |
|
|
112
|
-
| `READY_FOR_AUDIT` | Review clean | `/audit-pr` (strong) |
|
|
113
|
-
| `MERGE_READY` | Audit passed on the current head SHA | Human merges — or your written auto-merge policy does |
|
|
114
|
-
| `MERGED` | An authorized auto-merge ran this turn | Next unit: poll `workflow-status` |
|
|
115
|
-
| `NEEDS_FIXES` | `findings.fix_now` is non-empty | Fold on-branch (commit AND push), then re-run the gate that emitted them |
|
|
116
|
-
| `BLOCKED` | Unmet dependency / external cause | Follow `dependencies.build_order`, or resolve `blockers[]` |
|
|
117
|
-
| `NEEDS_INPUT` | A human must decide | Surface `needs_input.question` + `options`; resume with the answer |
|
|
118
|
-
| `FAILED` | Retries exhausted | Stop this unit; a human looks |
|
|
119
|
-
| `HALT` | Stop-the-world discovery (`blockers[].scope: "run"`) | Stop the whole run; nothing proceeds until a human clears it |
|
|
120
|
-
|
|
121
|
-
`isTerminal(state)` covers `NEEDS_INPUT` / `FAILED` / `HALT` (+ human-gated
|
|
122
|
-
`MERGE_READY`); `isRunHalt(envelope)` is the `HALT` / run-scoped-blocker check.
|
|
123
|
-
|
|
124
|
-
## Orchestrating with this schema
|
|
125
|
-
|
|
126
|
-
Two patterns, both consuming the same envelope. In both, **inject the
|
|
127
|
-
canonical system-prompt snippet** into every headless invocation (skills do
|
|
128
|
-
not emit the envelope on their own — `workflow-status` is the one exception):
|
|
129
|
-
|
|
130
|
-
```text
|
|
131
|
-
Every turn you produce MUST end with exactly one fenced ```json block matching
|
|
132
|
-
the orchestration envelope schema (all top-level keys present; values only
|
|
133
|
-
from verified command output). Emit nothing after it.
|
|
134
|
-
```
|
|
76
|
+
- **Repository evidence is authoritative.** `effects`, `contextSources` and
|
|
77
|
+
`requiredEvidence` document the reviewed maximum capabilities from the
|
|
78
|
+
workflow's own documents (`docs/`); they never promise anything about a
|
|
79
|
+
model or provider runtime.
|
|
80
|
+
- **Context is advisory.** `semantic-context` and `episodic-memory` describe
|
|
81
|
+
context that *may* help; they never change what a skill may do.
|
|
82
|
+
- **Exports are immutable.** Vocabulary arrays and every profile are frozen at
|
|
83
|
+
runtime (`Object.isFrozen`); widening a profile at runtime is unsupported.
|
|
84
|
+
Any vocabulary or profile change is a reviewed package release.
|
|
85
|
+
|
|
86
|
+
`capabilities` is optional for source compatibility. A capability-aware
|
|
87
|
+
consumer must **fail closed** when it is absent — never infer a skill's role
|
|
88
|
+
or effects from its name.
|
|
135
89
|
|
|
136
|
-
|
|
90
|
+
## Compile deterministic state
|
|
91
|
+
|
|
92
|
+
The package never reads the filesystem, Git, or a forge. The caller supplies
|
|
93
|
+
the exact documents and repository facts it has already read, so snapshots are
|
|
94
|
+
reproducible and safe to cache by `sourceRevision`.
|
|
137
95
|
|
|
138
96
|
```ts
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
97
|
+
import { compileWorkflowSnapshot } from "@gtrabanco/agentic-workflow-schema";
|
|
98
|
+
|
|
99
|
+
const result = compileWorkflowSnapshot({
|
|
100
|
+
sourceRevision: headSha,
|
|
101
|
+
repository: { branch, headSha, dirty },
|
|
102
|
+
documents: [
|
|
103
|
+
{ path: "docs/workflow/REPOSITORY_STATE.md", content: repositoryState },
|
|
104
|
+
{ path: "docs/features/ROADMAP.md", content: roadmap },
|
|
105
|
+
{ path: "docs/features/12-machine-contract/SPEC.md", content: spec },
|
|
106
|
+
{ path: "docs/features/12-machine-contract/progress.md", content: progress },
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
if (!result.ok) throw new Error(result.errors.join("; "));
|
|
110
|
+
|
|
111
|
+
const { snapshot } = result;
|
|
112
|
+
// snapshot.unit, snapshot.phase, snapshot.provenance,
|
|
113
|
+
// snapshot.unknowns, and snapshot.contradictions are deterministic.
|
|
149
114
|
```
|
|
150
115
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
116
|
+
The compiler deliberately reports an unknown current phase instead of guessing
|
|
117
|
+
from ambiguous progress prose. A declared `Status: contradicted` is retained in
|
|
118
|
+
`snapshot.contradictions`; route it to repository-state resolution rather than
|
|
119
|
+
overwriting it.
|
|
120
|
+
|
|
121
|
+
## Validate or use another language
|
|
156
122
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
ingests raw transcripts, which is what lets it stay long-running without
|
|
161
|
-
degrading. The envelope is precisely the "structured result" this pattern
|
|
162
|
-
needs:
|
|
123
|
+
The public validators are `validateEnvelopeV2Strict`, `validateSkillOutcomeV1`,
|
|
124
|
+
and `validateWorkflowSnapshotV1`. Import a JSON Schema when a non-TypeScript
|
|
125
|
+
consumer needs the same boundary:
|
|
163
126
|
|
|
164
127
|
```ts
|
|
165
|
-
|
|
166
|
-
// in parallel and the project declares `worktrees`), read back only envelopes.
|
|
167
|
-
const status = await turn("Follow the installed SKILL.md for: /workflow-status --json-only");
|
|
168
|
-
const units = status.detail.startable_now as string[];
|
|
169
|
-
|
|
170
|
-
const results = await Promise.all(
|
|
171
|
-
units.map((u) => turn(`Follow the installed SKILL.md for: /execute-phase ${u}`))
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
for (const env of results) {
|
|
175
|
-
if (isRunHalt(env)) throw new Error(`HALT: ${JSON.stringify(env.blockers)}`);
|
|
176
|
-
if (env.state === "NEEDS_FIXES")
|
|
177
|
-
await turn(`Fold the fix-now findings on ${env.unit.branch}: ${JSON.stringify(env.findings.fix_now)}`);
|
|
178
|
-
}
|
|
179
|
-
// The conductor's own context grew by a few KB of envelopes — not by N transcripts.
|
|
128
|
+
import schema from "@gtrabanco/agentic-workflow-schema/skill-outcome.schema.json" with { type: "json" };
|
|
180
129
|
```
|
|
181
130
|
|
|
182
|
-
|
|
183
|
-
`
|
|
184
|
-
|
|
185
|
-
|
|
131
|
+
For Node versions without JSON import attributes, load the schema with
|
|
132
|
+
`createRequire`. The package supports Node 18 and later.
|
|
133
|
+
|
|
134
|
+
## Compatibility and versioning
|
|
135
|
+
|
|
136
|
+
`parseTurn` accepts strict v2 first, then only these named legacy repairs:
|
|
186
137
|
|
|
187
|
-
|
|
138
|
+
- a missing `detail` becomes `null`;
|
|
139
|
+
- legacy root `design_candidates` moves to `detail.design_candidates`;
|
|
140
|
+
- the known `audit-pr` form may map a numeric unit id from matching trusted
|
|
141
|
+
driver context, zero issue count to `[]`, and a native gate row to a canonical
|
|
142
|
+
blocker.
|
|
188
143
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
`orchestration-envelope` skill changes, this package changes in the same PR.
|
|
144
|
+
It refuses a nonzero issue count without identities, an unmatched unit id, and
|
|
145
|
+
unstructured prose. The compatibility diagnostics make every repair visible to
|
|
146
|
+
the driver.
|
|
193
147
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
148
|
+
Package major versions signal a breaking change to any published contract.
|
|
149
|
+
Additive contract fields are minor; parser, documentation, or implementation
|
|
150
|
+
fixes are patch releases. See
|
|
151
|
+
[programmatic orchestration](../../docs/workflow/ORCHESTRATION.md) for the
|
|
152
|
+
driver protocol.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @gtrabanco/agentic-workflow-schema
|
|
3
3
|
*
|
|
4
|
-
* Types, extraction, and validation for the agentic-workflow
|
|
5
|
-
*
|
|
6
|
-
* workflow-status always, and by any other skill when the driver injects the
|
|
7
|
-
* canonical system-prompt snippet).
|
|
4
|
+
* Types, extraction, and validation for the agentic-workflow machine contracts:
|
|
5
|
+
* Envelope v2, SkillOutcome v1, and WorkflowSnapshot v1.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
* Envelope parse contract:
|
|
10
8
|
* take the LAST fenced ```json block of the assistant's final message;
|
|
11
9
|
* exactly one envelope per turn; all top-level keys always present.
|
|
12
10
|
*/
|
|
@@ -146,3 +144,240 @@ export declare function parseEnvelope(text: string): ParseResult;
|
|
|
146
144
|
export declare function isTerminal(state: EnvelopeState): boolean;
|
|
147
145
|
/** True when every blocker (or any) demands stopping the whole run. */
|
|
148
146
|
export declare function isRunHalt(envelope: Envelope): boolean;
|
|
147
|
+
export type StrictEnvelopeValidationResult = {
|
|
148
|
+
ok: true;
|
|
149
|
+
envelope: Envelope;
|
|
150
|
+
} | {
|
|
151
|
+
ok: false;
|
|
152
|
+
errors: string[];
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Validates the documented v2 shape at a driver boundary.
|
|
156
|
+
*
|
|
157
|
+
* `validateEnvelope()` remains intentionally source-compatible for existing
|
|
158
|
+
* package consumers. New drivers use this stricter entry point: `detail` is
|
|
159
|
+
* present and top-level schema extensions are rejected instead of silently
|
|
160
|
+
* becoming a second, undocumented contract.
|
|
161
|
+
*/
|
|
162
|
+
export declare function validateEnvelopeV2Strict(value: unknown): StrictEnvelopeValidationResult;
|
|
163
|
+
export type StrictEnvelopeParseResult = {
|
|
164
|
+
ok: true;
|
|
165
|
+
envelope: Envelope;
|
|
166
|
+
raw: string;
|
|
167
|
+
} | {
|
|
168
|
+
ok: false;
|
|
169
|
+
errors: string[];
|
|
170
|
+
raw: string | null;
|
|
171
|
+
};
|
|
172
|
+
/** Extract, parse, and validate the strict driver-facing v2 envelope. */
|
|
173
|
+
export declare function parseEnvelopeV2Strict(text: string): StrictEnvelopeParseResult;
|
|
174
|
+
export type WorkflowIntent = "init-workspace" | "status" | "discover-repository-state" | "resolve-repository-state" | "design-feature" | "plan-feature" | "plan-fix" | "triage-issue" | "execute-phase" | "review-change" | "loop-review-fold" | "audit-pr" | "merge" | "ask-human" | "stop" | "none";
|
|
175
|
+
export declare const WORKFLOW_INTENTS: readonly WorkflowIntent[];
|
|
176
|
+
/** Role a built-in skill plays in the workflow pipeline. */
|
|
177
|
+
export declare const SKILL_ROLES: readonly ["sensor", "planner", "executor", "reviewer", "auditor", "publisher"];
|
|
178
|
+
export type SkillRole = (typeof SKILL_ROLES)[number];
|
|
179
|
+
/** Maximum repository/forge effects permitted by a built-in profile. */
|
|
180
|
+
export declare const SKILL_EFFECTS: readonly ["repository-read", "repository-write", "git-write", "forge-read", "forge-write"];
|
|
181
|
+
export type SkillEffect = (typeof SKILL_EFFECTS)[number];
|
|
182
|
+
/** Reasoning class a profile declares for its primary route. */
|
|
183
|
+
export declare const SKILL_REASONING: readonly ["mechanical", "semantic", "critical"];
|
|
184
|
+
export type SkillReasoning = (typeof SKILL_REASONING)[number];
|
|
185
|
+
/** Context sources a profile may consult. */
|
|
186
|
+
export declare const SKILL_CONTEXT_SOURCES: readonly ["repository", "semantic-context", "episodic-memory", "execution-state"];
|
|
187
|
+
export type SkillContextSource = (typeof SKILL_CONTEXT_SOURCES)[number];
|
|
188
|
+
/** Evidence a capability-aware driver should require before trusting results. */
|
|
189
|
+
export declare const SKILL_REQUIRED_EVIDENCE: readonly ["workflow-snapshot", "current-candidate", "verification", "independent-review", "audit", "issue-state", "pull-request-state"];
|
|
190
|
+
export type SkillRequiredEvidence = (typeof SKILL_REQUIRED_EVIDENCE)[number];
|
|
191
|
+
/**
|
|
192
|
+
* Declarative, closed-vocabulary capability metadata for a built-in profile.
|
|
193
|
+
* Repository evidence is the authoritative limit; semantic and episodic
|
|
194
|
+
* context is advisory and never extends the declared maximum effects.
|
|
195
|
+
*/
|
|
196
|
+
export interface WorkflowSkillCapabilities {
|
|
197
|
+
readonly role: SkillRole;
|
|
198
|
+
readonly reasoning: SkillReasoning;
|
|
199
|
+
readonly effects: readonly SkillEffect[];
|
|
200
|
+
readonly contextSources: readonly SkillContextSource[];
|
|
201
|
+
readonly requiredEvidence: readonly SkillRequiredEvidence[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Public profile boundary — source-compatible for external consumers that
|
|
205
|
+
* construct or mutate profiles. The three legacy fields are writable so
|
|
206
|
+
* third-party code can assign to them without TS2540.
|
|
207
|
+
*/
|
|
208
|
+
export interface WorkflowSkillProfile {
|
|
209
|
+
skill: string;
|
|
210
|
+
output: "envelope-v2" | "skill-outcome-v1";
|
|
211
|
+
nativeFallback: "none" | "fixed-verdict";
|
|
212
|
+
/**
|
|
213
|
+
* Optional for source compatibility; every built-in populates it and a
|
|
214
|
+
* capability-aware consumer fails closed when it is absent.
|
|
215
|
+
*/
|
|
216
|
+
capabilities?: WorkflowSkillCapabilities;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Deeply readonly boundary for shipped built-in profiles. The immutable type
|
|
220
|
+
* guarantees compile-time immutability without narrowing the public boundary.
|
|
221
|
+
*/
|
|
222
|
+
export interface BuiltInSkillProfile {
|
|
223
|
+
readonly skill: string;
|
|
224
|
+
readonly output: "envelope-v2" | "skill-outcome-v1";
|
|
225
|
+
readonly nativeFallback: "none" | "fixed-verdict";
|
|
226
|
+
readonly capabilities?: Readonly<WorkflowSkillCapabilities>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The portable skill inventory consumed by headless drivers. Profiles are
|
|
230
|
+
* programmatic metadata, not duplicated prompt sections in user-facing skills.
|
|
231
|
+
*/
|
|
232
|
+
export declare const WORKFLOW_SKILL_PROFILES: readonly BuiltInSkillProfile[];
|
|
233
|
+
export type SkillOutcomeStatus = "completed" | "continue" | "blocked" | "needs-input" | "failed";
|
|
234
|
+
export interface SkillOutcomeBlocker {
|
|
235
|
+
kind: BlockerKind;
|
|
236
|
+
id: string;
|
|
237
|
+
scope: BlockerScope;
|
|
238
|
+
detail: string;
|
|
239
|
+
}
|
|
240
|
+
export interface SkillOutcomeQuestion {
|
|
241
|
+
id: string;
|
|
242
|
+
question: string;
|
|
243
|
+
options: string[];
|
|
244
|
+
}
|
|
245
|
+
export interface SkillOutcomeDiscovery {
|
|
246
|
+
kind: "defect" | "risk" | "opportunity" | "environment" | "scope-gap" | "unknown";
|
|
247
|
+
scope: "current-unit" | "outside-unit" | "run";
|
|
248
|
+
summary: string;
|
|
249
|
+
evidence_refs: string[];
|
|
250
|
+
proposed_intent: WorkflowIntent;
|
|
251
|
+
}
|
|
252
|
+
export interface SkillOutcome {
|
|
253
|
+
contract: "agentic-workflow/skill-outcome";
|
|
254
|
+
version: 1;
|
|
255
|
+
skill: string;
|
|
256
|
+
status: SkillOutcomeStatus;
|
|
257
|
+
summary: string;
|
|
258
|
+
next: {
|
|
259
|
+
intent: WorkflowIntent;
|
|
260
|
+
targets: string[];
|
|
261
|
+
};
|
|
262
|
+
blockers: SkillOutcomeBlocker[];
|
|
263
|
+
questions: SkillOutcomeQuestion[];
|
|
264
|
+
discoveries: SkillOutcomeDiscovery[];
|
|
265
|
+
evidence_refs: string[];
|
|
266
|
+
}
|
|
267
|
+
export interface TurnParseContext {
|
|
268
|
+
/** Trusted driver state used only for a checked legacy normalization. */
|
|
269
|
+
unitId?: string;
|
|
270
|
+
}
|
|
271
|
+
export interface TurnParseDiagnostic {
|
|
272
|
+
code: string;
|
|
273
|
+
detail: string;
|
|
274
|
+
}
|
|
275
|
+
export type TurnParseSource = "skill-outcome-v1" | "envelope-v2-strict" | "envelope-v2-compat" | "native";
|
|
276
|
+
export type TurnParseResult = {
|
|
277
|
+
ok: true;
|
|
278
|
+
source: TurnParseSource;
|
|
279
|
+
outcome: SkillOutcome;
|
|
280
|
+
envelope: Envelope | null;
|
|
281
|
+
diagnostics: TurnParseDiagnostic[];
|
|
282
|
+
} | {
|
|
283
|
+
ok: false;
|
|
284
|
+
errors: string[];
|
|
285
|
+
diagnostics: TurnParseDiagnostic[];
|
|
286
|
+
};
|
|
287
|
+
export interface ParseTurnInput {
|
|
288
|
+
skill: string;
|
|
289
|
+
text: string;
|
|
290
|
+
context?: TurnParseContext;
|
|
291
|
+
}
|
|
292
|
+
export type SkillOutcomeValidationResult = {
|
|
293
|
+
ok: true;
|
|
294
|
+
outcome: SkillOutcome;
|
|
295
|
+
} | {
|
|
296
|
+
ok: false;
|
|
297
|
+
errors: string[];
|
|
298
|
+
};
|
|
299
|
+
/** Validates the strict, model-owned SkillOutcome v1 JSON contract. */
|
|
300
|
+
export declare function validateSkillOutcomeV1(value: unknown): SkillOutcomeValidationResult;
|
|
301
|
+
/**
|
|
302
|
+
* Parses a machine result in strict precedence order. Compatibility mappings
|
|
303
|
+
* are intentionally small and named; arbitrary prose is never promoted into
|
|
304
|
+
* a workflow fact.
|
|
305
|
+
*/
|
|
306
|
+
export declare function parseTurn(input: ParseTurnInput): TurnParseResult;
|
|
307
|
+
/** Returns the smallest driver instruction appropriate for the selected skill. */
|
|
308
|
+
export declare function renderOutputInstruction(skill: string): string;
|
|
309
|
+
export interface WorkflowDocument {
|
|
310
|
+
path: string;
|
|
311
|
+
content: string;
|
|
312
|
+
}
|
|
313
|
+
export interface WorkflowSnapshotInput {
|
|
314
|
+
sourceRevision: string;
|
|
315
|
+
repository: {
|
|
316
|
+
branch: string;
|
|
317
|
+
headSha: string;
|
|
318
|
+
dirty: boolean;
|
|
319
|
+
};
|
|
320
|
+
documents: WorkflowDocument[];
|
|
321
|
+
}
|
|
322
|
+
export interface SnapshotProvenance {
|
|
323
|
+
field: string;
|
|
324
|
+
source: string;
|
|
325
|
+
line: number;
|
|
326
|
+
}
|
|
327
|
+
export interface SnapshotUnknown {
|
|
328
|
+
field: string;
|
|
329
|
+
reason: string;
|
|
330
|
+
}
|
|
331
|
+
export interface SnapshotContradiction {
|
|
332
|
+
field: string;
|
|
333
|
+
source: string;
|
|
334
|
+
line: number;
|
|
335
|
+
detail: string;
|
|
336
|
+
}
|
|
337
|
+
export interface WorkflowSnapshot {
|
|
338
|
+
contract: "agentic-workflow/workflow-snapshot";
|
|
339
|
+
version: 1;
|
|
340
|
+
sourceRevision: string;
|
|
341
|
+
repository: {
|
|
342
|
+
branch: string;
|
|
343
|
+
headSha: string;
|
|
344
|
+
dirty: boolean;
|
|
345
|
+
};
|
|
346
|
+
repositoryState: "missing" | "draft" | "frozen" | "contradicted" | "needs-input" | "unknown";
|
|
347
|
+
unit: {
|
|
348
|
+
kind: "feature" | "fix";
|
|
349
|
+
id: string;
|
|
350
|
+
status: string;
|
|
351
|
+
} | null;
|
|
352
|
+
phase: {
|
|
353
|
+
current: string | null;
|
|
354
|
+
total: number | null;
|
|
355
|
+
completed: number | null;
|
|
356
|
+
names: string[];
|
|
357
|
+
};
|
|
358
|
+
provenance: SnapshotProvenance[];
|
|
359
|
+
contradictions: SnapshotContradiction[];
|
|
360
|
+
unknowns: SnapshotUnknown[];
|
|
361
|
+
}
|
|
362
|
+
export type WorkflowSnapshotResult = {
|
|
363
|
+
ok: true;
|
|
364
|
+
snapshot: WorkflowSnapshot;
|
|
365
|
+
} | {
|
|
366
|
+
ok: false;
|
|
367
|
+
errors: string[];
|
|
368
|
+
};
|
|
369
|
+
export type WorkflowSnapshotValidationResult = {
|
|
370
|
+
ok: true;
|
|
371
|
+
snapshot: WorkflowSnapshot;
|
|
372
|
+
} | {
|
|
373
|
+
ok: false;
|
|
374
|
+
errors: string[];
|
|
375
|
+
};
|
|
376
|
+
/** Validates the strict, deterministic WorkflowSnapshot v1 JSON contract. */
|
|
377
|
+
export declare function validateWorkflowSnapshotV1(value: unknown): WorkflowSnapshotValidationResult;
|
|
378
|
+
/**
|
|
379
|
+
* Compiles only facts represented by the versioned workflow documents passed
|
|
380
|
+
* in by the caller. It performs no filesystem or Git I/O and records source
|
|
381
|
+
* locations for every value it derives.
|
|
382
|
+
*/
|
|
383
|
+
export declare function compileWorkflowSnapshot(input: WorkflowSnapshotInput): WorkflowSnapshotResult;
|