@aionis/manifest 0.1.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/CHANGELOG.md +26 -0
- package/LICENSE +178 -0
- package/README.md +170 -0
- package/dist/ast/types.d.ts +34 -0
- package/dist/ast/types.js +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +122 -0
- package/dist/compile.d.ts +14 -0
- package/dist/compile.js +219 -0
- package/dist/contracts.d.ts +12610 -0
- package/dist/contracts.js +401 -0
- package/dist/diagnostics/types.d.ts +17 -0
- package/dist/diagnostics/types.js +1 -0
- package/dist/execute/localRuntime.d.ts +5 -0
- package/dist/execute/localRuntime.js +165 -0
- package/dist/execute/moduleRuntime.d.ts +25 -0
- package/dist/execute/moduleRuntime.js +352 -0
- package/dist/execute/types.d.ts +113 -0
- package/dist/execute/types.js +1 -0
- package/dist/execute-cli.d.ts +2 -0
- package/dist/execute-cli.js +112 -0
- package/dist/execute.d.ts +6 -0
- package/dist/execute.js +46 -0
- package/dist/graph/buildExecutionGraph.d.ts +8 -0
- package/dist/graph/buildExecutionGraph.js +69 -0
- package/dist/graph/types.d.ts +24 -0
- package/dist/graph/types.js +1 -0
- package/dist/handoff-store-cli.d.ts +2 -0
- package/dist/handoff-store-cli.js +139 -0
- package/dist/handoff-store.d.ts +103 -0
- package/dist/handoff-store.js +78 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +21 -0
- package/dist/ir/types.d.ts +92 -0
- package/dist/ir/types.js +1 -0
- package/dist/parser/parseAst.d.ts +3 -0
- package/dist/parser/parseAst.js +207 -0
- package/dist/parser/payload.d.ts +6 -0
- package/dist/parser/payload.js +211 -0
- package/dist/plan/buildExecutionPlan.d.ts +9 -0
- package/dist/plan/buildExecutionPlan.js +98 -0
- package/dist/plan/types.d.ts +44 -0
- package/dist/plan/types.js +1 -0
- package/dist/publish-cli.d.ts +2 -0
- package/dist/publish-cli.js +249 -0
- package/dist/publish.d.ts +148 -0
- package/dist/publish.js +190 -0
- package/dist/recover-cli.d.ts +2 -0
- package/dist/recover-cli.js +258 -0
- package/dist/recover.d.ts +489 -0
- package/dist/recover.js +290 -0
- package/dist/refs/resolveRefs.d.ts +13 -0
- package/dist/refs/resolveRefs.js +104 -0
- package/dist/registry/loadModuleRegistry.d.ts +28 -0
- package/dist/registry/loadModuleRegistry.js +97 -0
- package/dist/registry/types.d.ts +20 -0
- package/dist/registry/types.js +2 -0
- package/dist/resume-cli.d.ts +2 -0
- package/dist/resume-cli.js +379 -0
- package/dist/resume.d.ts +2076 -0
- package/dist/resume.js +452 -0
- package/dist/run-cli.d.ts +2 -0
- package/dist/run-cli.js +119 -0
- package/dist/run.d.ts +9 -0
- package/dist/run.js +43 -0
- package/dist/runtime-handoff-cli.d.ts +2 -0
- package/dist/runtime-handoff-cli.js +179 -0
- package/dist/runtime-handoff.d.ts +914 -0
- package/dist/runtime-handoff.js +383 -0
- package/dist/scanner/scanSource.d.ts +9 -0
- package/dist/scanner/scanSource.js +43 -0
- package/dist/schema/validateIrSchemas.d.ts +3 -0
- package/dist/schema/validateIrSchemas.js +64 -0
- package/dist/validate-module-cli.d.ts +2 -0
- package/dist/validate-module-cli.js +93 -0
- package/dist/validate-registry-cli.d.ts +2 -0
- package/dist/validate-registry-cli.js +82 -0
- package/dist/validate.d.ts +52 -0
- package/dist/validate.js +91 -0
- package/fixtures/duplicate-doc.aionis.md +19 -0
- package/fixtures/fenced-example.aionis.md +27 -0
- package/fixtures/malformed-payload.aionis.md +9 -0
- package/fixtures/npm-installed-module-registry.json +17 -0
- package/fixtures/standalone-module-registry.json +13 -0
- package/fixtures/standalone-runner-plan.json +51 -0
- package/fixtures/standalone-runner.aionis.md +29 -0
- package/fixtures/unresolved-ref.aionis.md +14 -0
- package/fixtures/valid-minimal.aionis.md +24 -0
- package/fixtures/valid-workflow.aionis.md +29 -0
- package/official-modules/copy-summary/CHANGELOG.md +6 -0
- package/official-modules/copy-summary/README.md +43 -0
- package/official-modules/copy-summary/index.mjs +41 -0
- package/official-modules/copy-summary/package.json +31 -0
- package/official-modules/json-transform/CHANGELOG.md +6 -0
- package/official-modules/json-transform/README.md +51 -0
- package/official-modules/json-transform/index.mjs +53 -0
- package/official-modules/json-transform/package.json +31 -0
- package/official-modules/research-claims/CHANGELOG.md +6 -0
- package/official-modules/research-claims/README.md +47 -0
- package/official-modules/research-claims/index.mjs +44 -0
- package/official-modules/research-claims/package.json +31 -0
- package/package.json +74 -0
package/dist/compile.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { parseAst } from "./parser/parseAst.js";
|
|
2
|
+
import { resolveRefs } from "./refs/resolveRefs.js";
|
|
3
|
+
import { scanSource } from "./scanner/scanSource.js";
|
|
4
|
+
import { validateIrSchemas } from "./schema/validateIrSchemas.js";
|
|
5
|
+
import { buildExecutionGraph } from "./graph/buildExecutionGraph.js";
|
|
6
|
+
import { buildExecutionPlanV1 } from "./plan/buildExecutionPlan.js";
|
|
7
|
+
function isObject(value) {
|
|
8
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function asString(value) {
|
|
11
|
+
return typeof value === "string" ? value : undefined;
|
|
12
|
+
}
|
|
13
|
+
function asBoolean(value) {
|
|
14
|
+
return typeof value === "boolean" ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
function asNumber(value) {
|
|
17
|
+
return typeof value === "number" ? value : undefined;
|
|
18
|
+
}
|
|
19
|
+
function asStringArray(value) {
|
|
20
|
+
if (!Array.isArray(value))
|
|
21
|
+
return undefined;
|
|
22
|
+
const strings = value.filter((item) => typeof item === "string");
|
|
23
|
+
return strings.length === value.length ? strings : undefined;
|
|
24
|
+
}
|
|
25
|
+
function makeDiagnostic(loc, code, message) {
|
|
26
|
+
return {
|
|
27
|
+
severity: "error",
|
|
28
|
+
code,
|
|
29
|
+
message,
|
|
30
|
+
loc: loc ?? {
|
|
31
|
+
start: { line: 1, column: 1, offset: 0 },
|
|
32
|
+
end: { line: 1, column: 1, offset: 0 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function normalizeManifest(payload, loc) {
|
|
37
|
+
return {
|
|
38
|
+
id: asString(payload.id) ?? "",
|
|
39
|
+
version: asString(payload.version) ?? "",
|
|
40
|
+
kind: asString(payload.kind),
|
|
41
|
+
title: asString(payload.title),
|
|
42
|
+
status: asString(payload.status),
|
|
43
|
+
tags: asStringArray(payload.tags),
|
|
44
|
+
data: payload,
|
|
45
|
+
loc,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function normalizeContext(payload, loc) {
|
|
49
|
+
return {
|
|
50
|
+
objective: asString(payload.objective),
|
|
51
|
+
audience: asStringArray(payload.audience),
|
|
52
|
+
constraints: asStringArray(payload.constraints),
|
|
53
|
+
data: payload,
|
|
54
|
+
loc,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function normalizePlan(payload, loc) {
|
|
58
|
+
return {
|
|
59
|
+
steps: asStringArray(payload.steps),
|
|
60
|
+
success_criteria: asStringArray(payload.success_criteria),
|
|
61
|
+
checkpoints: asStringArray(payload.checkpoints),
|
|
62
|
+
fallbacks: asStringArray(payload.fallbacks),
|
|
63
|
+
data: payload,
|
|
64
|
+
loc,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function normalizeExecute(payload, loc) {
|
|
68
|
+
return {
|
|
69
|
+
module: asString(payload.module),
|
|
70
|
+
tool: asString(payload.tool),
|
|
71
|
+
agent: asString(payload.agent),
|
|
72
|
+
input: isObject(payload.input) ? payload.input : undefined,
|
|
73
|
+
input_ref: asString(payload.input_ref),
|
|
74
|
+
output_ref: asString(payload.output_ref),
|
|
75
|
+
deterministic: asBoolean(payload.deterministic),
|
|
76
|
+
depends_on: asStringArray(payload.depends_on),
|
|
77
|
+
data: payload,
|
|
78
|
+
loc,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function normalizeDecision(payload, loc) {
|
|
82
|
+
return {
|
|
83
|
+
decision: asString(payload.decision),
|
|
84
|
+
rationale: asString(payload.rationale),
|
|
85
|
+
confidence: asNumber(payload.confidence),
|
|
86
|
+
data: payload,
|
|
87
|
+
loc,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function normalizeEvidence(payload, loc) {
|
|
91
|
+
return {
|
|
92
|
+
sources: Array.isArray(payload.sources) ? payload.sources : undefined,
|
|
93
|
+
confidence: asNumber(payload.confidence),
|
|
94
|
+
claims_supported: asStringArray(payload.claims_supported),
|
|
95
|
+
data: payload,
|
|
96
|
+
loc,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function normalizeReplay(payload, loc) {
|
|
100
|
+
const rawMode = asString(payload.mode);
|
|
101
|
+
return {
|
|
102
|
+
executable: asBoolean(payload.executable),
|
|
103
|
+
mode: rawMode === "deterministic" || rawMode === "assisted" || rawMode === "advisory" ? rawMode : undefined,
|
|
104
|
+
workflow_id: asString(payload.workflow_id),
|
|
105
|
+
expected_outputs: asStringArray(payload.expected_outputs),
|
|
106
|
+
data: payload,
|
|
107
|
+
loc,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function normalizeMemory(payload, loc) {
|
|
111
|
+
return {
|
|
112
|
+
topics: asStringArray(payload.topics),
|
|
113
|
+
entities: asStringArray(payload.entities),
|
|
114
|
+
writeback: asBoolean(payload.writeback),
|
|
115
|
+
summary_layer: asString(payload.summary_layer),
|
|
116
|
+
data: payload,
|
|
117
|
+
loc,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function normalizeState(payload, loc) {
|
|
121
|
+
return {
|
|
122
|
+
phase: asString(payload.phase),
|
|
123
|
+
run_id: asString(payload.run_id),
|
|
124
|
+
owner: asString(payload.owner),
|
|
125
|
+
data: payload,
|
|
126
|
+
loc,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function normalizeAstToIr(ast) {
|
|
130
|
+
const ir = {
|
|
131
|
+
doc: null,
|
|
132
|
+
context: [],
|
|
133
|
+
plans: [],
|
|
134
|
+
executions: [],
|
|
135
|
+
decisions: [],
|
|
136
|
+
evidence: [],
|
|
137
|
+
replay: [],
|
|
138
|
+
memory: [],
|
|
139
|
+
state: [],
|
|
140
|
+
diagnostics: [],
|
|
141
|
+
};
|
|
142
|
+
for (const child of ast.children) {
|
|
143
|
+
if (child.type !== "DirectiveNode")
|
|
144
|
+
continue;
|
|
145
|
+
const directive = child;
|
|
146
|
+
if (!isObject(directive.payload)) {
|
|
147
|
+
if (directive.payload === null)
|
|
148
|
+
continue;
|
|
149
|
+
ir.diagnostics.push(makeDiagnostic(directive.loc, "INVALID_SCHEMA", `@${directive.name} expects an object payload.`));
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
switch (directive.name) {
|
|
153
|
+
case "manifest":
|
|
154
|
+
case "doc":
|
|
155
|
+
if (ir.doc) {
|
|
156
|
+
ir.diagnostics.push(makeDiagnostic(directive.loc, "DUPLICATE_MANIFEST", "Only one @manifest metadata directive is allowed. Legacy @doc counts as the same metadata block."));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
ir.doc = normalizeManifest(directive.payload, directive.loc);
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case "context":
|
|
163
|
+
ir.context.push(normalizeContext(directive.payload, directive.loc));
|
|
164
|
+
break;
|
|
165
|
+
case "plan":
|
|
166
|
+
ir.plans.push(normalizePlan(directive.payload, directive.loc));
|
|
167
|
+
break;
|
|
168
|
+
case "execute":
|
|
169
|
+
ir.executions.push(normalizeExecute(directive.payload, directive.loc));
|
|
170
|
+
break;
|
|
171
|
+
case "decision":
|
|
172
|
+
ir.decisions.push(normalizeDecision(directive.payload, directive.loc));
|
|
173
|
+
break;
|
|
174
|
+
case "evidence":
|
|
175
|
+
ir.evidence.push(normalizeEvidence(directive.payload, directive.loc));
|
|
176
|
+
break;
|
|
177
|
+
case "replay":
|
|
178
|
+
ir.replay.push(normalizeReplay(directive.payload, directive.loc));
|
|
179
|
+
break;
|
|
180
|
+
case "memory":
|
|
181
|
+
ir.memory.push(normalizeMemory(directive.payload, directive.loc));
|
|
182
|
+
break;
|
|
183
|
+
case "state":
|
|
184
|
+
ir.state.push(normalizeState(directive.payload, directive.loc));
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return ir;
|
|
191
|
+
}
|
|
192
|
+
export function compileAionisManifest(source) {
|
|
193
|
+
const scan = scanSource(source);
|
|
194
|
+
const ast = parseAst(scan);
|
|
195
|
+
const ir = normalizeAstToIr(ast);
|
|
196
|
+
const schemaDiagnostics = validateIrSchemas(ir);
|
|
197
|
+
const refResult = resolveRefs(ir);
|
|
198
|
+
const graphResult = buildExecutionGraph(refResult.ir);
|
|
199
|
+
const diagnostics = [
|
|
200
|
+
...ast.diagnostics,
|
|
201
|
+
...ir.diagnostics,
|
|
202
|
+
...schemaDiagnostics,
|
|
203
|
+
...refResult.diagnostics,
|
|
204
|
+
...graphResult.diagnostics,
|
|
205
|
+
];
|
|
206
|
+
const plan = buildExecutionPlanV1({
|
|
207
|
+
ir: refResult.ir,
|
|
208
|
+
graph: graphResult.value,
|
|
209
|
+
diagnostics,
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
ast,
|
|
213
|
+
ir: refResult.ir,
|
|
214
|
+
graph: graphResult.value,
|
|
215
|
+
plan,
|
|
216
|
+
diagnostics,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export const compileAionisDoc = compileAionisManifest;
|