@pieceful/ravel-core 0.1.1 → 0.3.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/LICENSE CHANGED
@@ -2,8 +2,20 @@ MIT License
2
2
 
3
3
  Copyright (c) 2026 James Taylor
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
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:
6
11
 
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
8
14
 
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
@@ -1,6 +1,6 @@
1
1
  # @pieceful/ravel-core
2
2
 
3
- The portable composition engine behind Ravel. It parses chunk references,
3
+ The portable composition engine behind [Ravel](https://github.com/jostylr/ravel). It parses chunk references,
4
4
  resolves the dependency graph, evaluates static composition, reports
5
5
  source-linked diagnostics, and creates provenance maps for generated output.
6
6
 
@@ -13,9 +13,15 @@ It is native ESM and deliberately has no filesystem, process, shell, or network
13
13
  capabilities. Pair it with an adapter such as `@pieceful/ravel-markdown` and a
14
14
  host that supplies any I/O you need.
15
15
 
16
- The documented public functions include `combineMaps`, `transformGraph`, and
17
- the generated/source provenance query helpers. Requires Node.js 22 or newer
18
- when used in Node.
16
+ `parseRavelDirectiveBlock` is the shared source-mapped parser for graph
17
+ directive bodies. Markdown `ravel` fences and MyST `{ravel}` directives use
18
+ this same grammar.
19
+
20
+ The documented public functions include `combineMaps`, `transformGraph`, the
21
+ generated/source provenance query helpers, and the 0.2
22
+ `planLiveExecutions` / `executeLiveProgram` provider boundary. Core selects and
23
+ schedules providers but does not import a language runtime. Requires Node.js 22
24
+ or newer when used in Node.
19
25
 
20
26
  See the [Ravel documentation](https://ravel.jostylr.com/) for the public API,
21
27
  Ravel Map contract, chunk syntax, and provenance format.
package/package.json CHANGED
@@ -1,20 +1,39 @@
1
1
  {
2
2
  "name": "@pieceful/ravel-core",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Ravel chunk syntax, resolution, graph evaluation, and diagnostics.",
6
6
  "license": "MIT",
7
7
  "author": "James Taylor",
8
- "repository": { "type": "git", "url": "git+https://github.com/jostylr/ravel.git", "directory": "packages/core" },
9
- "bugs": { "url": "https://github.com/jostylr/ravel/issues" },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/jostylr/ravel.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/jostylr/ravel/issues"
15
+ },
10
16
  "homepage": "https://ravel.jostylr.com/",
11
- "engines": { "node": ">=22" },
12
- "keywords": ["ravel", "literate-programming", "graph", "composition"],
13
- "publishConfig": { "access": "public" },
17
+ "engines": {
18
+ "node": ">=22"
19
+ },
20
+ "keywords": [
21
+ "ravel",
22
+ "literate-programming",
23
+ "graph",
24
+ "composition"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
14
29
  "exports": {
15
30
  ".": "./src/index.js",
16
31
  "./directives": "./src/directives.js"
17
32
  },
18
33
  "types": "./src/index.d.ts",
19
- "files": ["src", "README.md", "LICENSE"]
34
+ "files": [
35
+ "src",
36
+ "README.md",
37
+ "LICENSE"
38
+ ]
20
39
  }
@@ -0,0 +1,354 @@
1
+ const diagnostic = (message, source) => ({
2
+ code: "RM104",
3
+ severity: "error",
4
+ message,
5
+ source
6
+ });
7
+
8
+ const stringValue = (value) => {
9
+ if (value.startsWith("\"")) {
10
+ try {
11
+ return JSON.parse(value);
12
+ } catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ if (value.startsWith("'") && value.endsWith("'")) {
17
+ return value.slice(1, -1).replace(/\\'/g, "'").replace(/\\\\/g, "\\");
18
+ }
19
+ return value;
20
+ };
21
+
22
+ const tokenize = (text, sourceAt, diagnostics) => {
23
+ const result = [];
24
+ let index = 0;
25
+ const add = (type, value, start, end) =>
26
+ result.push({ type, value, start, end, source: sourceAt(start, end) });
27
+ const readString = (start, reference = false) => {
28
+ const quote = text[index];
29
+ index += 1;
30
+ let escaped = false;
31
+ while (index < text.length) {
32
+ const character = text[index];
33
+ if (escaped) escaped = false;
34
+ else if (character === "\\") escaped = true;
35
+ else if (character === quote) break;
36
+ index += 1;
37
+ }
38
+ if (index >= text.length) {
39
+ diagnostics.push(diagnostic(
40
+ "Unterminated directive string.",
41
+ sourceAt(start, text.length)
42
+ ));
43
+ return;
44
+ }
45
+ const raw = text.slice(start + (reference ? 1 : 0), index + 1);
46
+ const value = stringValue(raw);
47
+ if (typeof value !== "string") {
48
+ diagnostics.push(diagnostic(
49
+ "Malformed directive string.",
50
+ sourceAt(start, index + 1)
51
+ ));
52
+ } else {
53
+ add(reference ? "reference" : "string", value, start, index + 1);
54
+ }
55
+ index += 1;
56
+ };
57
+
58
+ while (index < text.length) {
59
+ const character = text[index];
60
+ if (/\s/.test(character)) {
61
+ index += 1;
62
+ } else if (character === "_" &&
63
+ (text[index + 1] === "\"" || text[index + 1] === "'")) {
64
+ const start = index;
65
+ index += 1;
66
+ readString(start, true);
67
+ } else if (character === "\"" || character === "'") {
68
+ const start = index;
69
+ readString(start);
70
+ } else if (/[a-z]/.test(character)) {
71
+ const start = index;
72
+ index += 1;
73
+ while (/[a-z0-9-]/.test(text[index] ?? "")) index += 1;
74
+ add("identifier", text.slice(start, index), start, index);
75
+ } else if (/[0-9]/.test(character)) {
76
+ const start = index;
77
+ index += 1;
78
+ while (/[0-9]/.test(text[index] ?? "")) index += 1;
79
+ add("number", Number(text.slice(start, index)), start, index);
80
+ } else if (character === "(" || character === ")" ||
81
+ character === "," || character === ";") {
82
+ add(character, character, index, index + 1);
83
+ index += 1;
84
+ } else {
85
+ diagnostics.push(diagnostic(
86
+ "Unexpected directive character: " + character,
87
+ sourceAt(index, index + 1)
88
+ ));
89
+ index += 1;
90
+ }
91
+ }
92
+ return result;
93
+ };
94
+
95
+ const commandsFrom = (text, sourceAt, diagnostics) => {
96
+ const tokens = tokenize(text, sourceAt, diagnostics);
97
+ let index = 0;
98
+ const current = () => tokens[index];
99
+ const take = (type) => {
100
+ if (current()?.type === type) return tokens[index++];
101
+ return null;
102
+ };
103
+ const error = (message, token = current()) => diagnostics.push(diagnostic(
104
+ message,
105
+ token?.source ?? sourceAt(text.length, text.length)
106
+ ));
107
+
108
+ const expression = () => {
109
+ const token = current();
110
+ if (!token) return null;
111
+ if (token.type === "string" || token.type === "reference" ||
112
+ token.type === "number") {
113
+ index += 1;
114
+ return { type: token.type, value: token.value, source: token.source };
115
+ }
116
+ if (token.type !== "identifier") {
117
+ error("Expected a directive value.");
118
+ return null;
119
+ }
120
+ index += 1;
121
+ const name = token.value;
122
+ if (!take("(")) {
123
+ error("Directive names must be followed by (...).", current() ?? token);
124
+ return null;
125
+ }
126
+ const argumentsValue = [];
127
+ if (!take(")")) {
128
+ while (true) {
129
+ const value = expression();
130
+ if (!value) return null;
131
+ argumentsValue.push(value);
132
+ if (take(")")) break;
133
+ if (!take(",")) {
134
+ error("Expected , or ) in directive call.");
135
+ return null;
136
+ }
137
+ }
138
+ }
139
+ const end = tokens[index - 1]?.end ?? token.end;
140
+ return {
141
+ type: "call",
142
+ name,
143
+ arguments: argumentsValue,
144
+ source: sourceAt(token.start, end)
145
+ };
146
+ };
147
+
148
+ const commands = [];
149
+ while (index < tokens.length) {
150
+ const command = expression();
151
+ if (!command) {
152
+ index += 1;
153
+ continue;
154
+ }
155
+ if (command.type !== "call") {
156
+ error("Top-level directive entries must be calls.", command);
157
+ } else {
158
+ commands.push(command);
159
+ }
160
+ take(";");
161
+ }
162
+ return commands;
163
+ };
164
+
165
+ const pipelineCall = (call, diagnostics) => {
166
+ if (call.type !== "call") {
167
+ diagnostics.push(diagnostic(
168
+ "pipe and pass accept command calls only.",
169
+ call.source
170
+ ));
171
+ return null;
172
+ }
173
+ if (call.name === "emit") {
174
+ if (call.arguments.length !== 1 ||
175
+ call.arguments[0].type !== "string") {
176
+ diagnostics.push(diagnostic(
177
+ "emit requires one string suffix.",
178
+ call.source
179
+ ));
180
+ return null;
181
+ }
182
+ return {
183
+ type: "emit",
184
+ suffix: call.arguments[0].value,
185
+ metadata: {},
186
+ source: call.source
187
+ };
188
+ }
189
+ if (call.arguments.some((argument) =>
190
+ argument.type !== "string" && argument.type !== "number"
191
+ )) {
192
+ diagnostics.push(diagnostic(
193
+ "Transform arguments must be strings or numbers.",
194
+ call.source
195
+ ));
196
+ return null;
197
+ }
198
+ return {
199
+ type: "transform",
200
+ name: call.name,
201
+ arguments: call.arguments.map((argument) => argument.value),
202
+ source: call.source
203
+ };
204
+ };
205
+
206
+ const composeStep = (value, diagnostics) => {
207
+ if (value.type === "reference") {
208
+ return {
209
+ kind: "append",
210
+ reference: value.value,
211
+ source: value.source
212
+ };
213
+ }
214
+ if (value.type !== "call") {
215
+ diagnostics.push(diagnostic(
216
+ "compose accepts references or directive calls.",
217
+ value.source
218
+ ));
219
+ return null;
220
+ }
221
+ if (value.name === "newline") {
222
+ if (value.arguments.length !== 1 ||
223
+ value.arguments[0].type !== "number" ||
224
+ value.arguments[0].value < 0) {
225
+ diagnostics.push(diagnostic(
226
+ "newline requires one non-negative integer.",
227
+ value.source
228
+ ));
229
+ return null;
230
+ }
231
+ return {
232
+ kind: "newline",
233
+ count: value.arguments[0].value,
234
+ source: value.source
235
+ };
236
+ }
237
+ if (value.name === "append") {
238
+ if (value.arguments.length !== 1 ||
239
+ value.arguments[0].type !== "reference") {
240
+ diagnostics.push(diagnostic(
241
+ "append requires one quoted reference.",
242
+ value.source
243
+ ));
244
+ return null;
245
+ }
246
+ return {
247
+ kind: "append",
248
+ reference: value.arguments[0].value,
249
+ source: value.source
250
+ };
251
+ }
252
+ if (value.name === "pipe" || value.name === "pass") {
253
+ const steps = value.arguments.map((argument) =>
254
+ pipelineCall(argument, diagnostics)
255
+ );
256
+ return steps.some((step) => !step)
257
+ ? null
258
+ : { kind: value.name, steps, source: value.source };
259
+ }
260
+ diagnostics.push(diagnostic(
261
+ "Unknown compose step: " + value.name,
262
+ value.source
263
+ ));
264
+ return null;
265
+ };
266
+
267
+ const directiveFrom = (command, document, diagnostics) => {
268
+ const args = command.arguments;
269
+ if (command.name === "create") {
270
+ if (args.length !== 2 || args[0].type !== "string" ||
271
+ args[1].type !== "call" || args[1].name !== "compose") {
272
+ diagnostics.push(diagnostic(
273
+ "create requires a local name and compose(...).",
274
+ command.source
275
+ ));
276
+ return null;
277
+ }
278
+ const steps = args[1].arguments.map((value) =>
279
+ composeStep(value, diagnostics)
280
+ );
281
+ return steps.some((step) => !step)
282
+ ? null
283
+ : {
284
+ kind: "create",
285
+ document,
286
+ name: args[0].value,
287
+ compose: steps,
288
+ source: command.source
289
+ };
290
+ }
291
+ if (command.name === "alias") {
292
+ if (args.length !== 2 || args[0].type !== "string" ||
293
+ args[1].type !== "reference") {
294
+ diagnostics.push(diagnostic(
295
+ "alias requires a local name and quoted reference.",
296
+ command.source
297
+ ));
298
+ return null;
299
+ }
300
+ return {
301
+ kind: "alias",
302
+ document,
303
+ name: args[0].value,
304
+ reference: args[1].value,
305
+ source: command.source
306
+ };
307
+ }
308
+ if (command.name === "in") {
309
+ if (args.length !== 1 || args[0].type !== "string") {
310
+ diagnostics.push(diagnostic(
311
+ "in requires one file path string.",
312
+ command.source
313
+ ));
314
+ return null;
315
+ }
316
+ return { kind: "in", target: args[0].value, source: command.source };
317
+ }
318
+ if (command.name === "out") {
319
+ if (args.length !== 2 || args[0].type !== "string" ||
320
+ args[1].type !== "reference") {
321
+ diagnostics.push(diagnostic(
322
+ "out requires a file name and quoted reference.",
323
+ command.source
324
+ ));
325
+ return null;
326
+ }
327
+ const from = args[1].value.includes("::")
328
+ ? args[1].value
329
+ : document + "::" + args[1].value;
330
+ return {
331
+ kind: "out",
332
+ name: args[0].value,
333
+ from,
334
+ source: command.source
335
+ };
336
+ }
337
+ diagnostics.push(diagnostic(
338
+ "Unknown Ravel directive: " + command.name,
339
+ command.source
340
+ ));
341
+ return null;
342
+ };
343
+
344
+ export const parseRavelDirectiveBlock = (
345
+ text,
346
+ { document, sourceAt }
347
+ ) => {
348
+ const diagnostics = [];
349
+ const commands = commandsFrom(text, sourceAt, diagnostics);
350
+ const directives = commands
351
+ .map((command) => directiveFrom(command, document, diagnostics))
352
+ .filter(Boolean);
353
+ return { directives, diagnostics };
354
+ };
@@ -5,5 +5,5 @@ export function append(reference: string, source: SourceLocation): unknown;
5
5
  export function newline(count: number, source: SourceLocation): unknown;
6
6
  export function pipe(steps: unknown[], source: SourceLocation): unknown;
7
7
  export function pass(steps: unknown[], source: SourceLocation): unknown;
8
- export function createDirective(name: string, value: unknown, source: SourceLocation): unknown;
9
- export function aliasDirective(name: string, reference: string, source: SourceLocation): unknown;
8
+ export function createDirective(name: string, value: unknown[] | string, source: SourceLocation, document?: string): { kind: "create"; document?: string; name: string; compose?: unknown[]; body?: string; source: SourceLocation };
9
+ export function aliasDirective(name: string, reference: string, source: SourceLocation, document?: string): { kind: "alias"; document?: string; name: string; reference: string; source: SourceLocation };
package/src/directives.js CHANGED
@@ -12,5 +12,18 @@ export const pass = (steps, source) => ({ kind: "pass", steps, source });
12
12
  * document's canonical chunk identity. Alias is intentionally the only
13
13
  * directive that may introduce an alternate graph name for an existing node.
14
14
  */
15
- export const createDirective = (name, value, source) => ({ kind: "create", name, value, source });
16
- export const aliasDirective = (name, reference, source) => ({ kind: "alias", name, reference, source });
15
+ export const createDirective = (name, value, source, document) => ({
16
+ kind: "create",
17
+ ...(document === undefined ? {} : { document }),
18
+ name,
19
+ // An array is a compose step list; a string is a chunk body.
20
+ ...(Array.isArray(value) ? { compose: value } : { body: String(value ?? "") }),
21
+ source
22
+ });
23
+ export const aliasDirective = (name, reference, source, document) => ({
24
+ kind: "alias",
25
+ ...(document === undefined ? {} : { document }),
26
+ name,
27
+ reference,
28
+ source
29
+ });
package/src/index.d.ts CHANGED
@@ -2,7 +2,8 @@ export interface SourcePosition { line: number; column: number; offset: number;
2
2
  export interface SourceRange { start: SourcePosition; end: SourcePosition; }
3
3
  export interface SourceLocation { uri: string; range: SourceRange; }
4
4
  export interface Diagnostic { code: string; severity: "error" | "warning" | "info"; message: string; source: SourceLocation; related?: SourceLocation[]; }
5
- export interface ChunkIdentity { document: string | null; chunk: string | null; minor: string | null; type: string | null; explicitDocument?: boolean; }
5
+ export type RavelValue = null | boolean | number | string | RavelValue[] | { [key: string]: RavelValue };
6
+ export interface ChunkIdentity { document: string | null; chunk: string | null; minor: string | null; type: string | null; explicitDocument?: boolean; relativePath?: string; }
6
7
  export interface RavelMap { version: 1; document: { id: string; uri: string; format: string }; chunks: Array<Record<string, unknown>>; directives?: Array<Record<string, unknown>>; diagnostics?: Diagnostic[]; }
7
8
  export interface PretransformGraph { version: 1; documents: Array<{ id: string; uri: string; format: string }>; chunks: Array<Record<string, unknown>>; directives: Array<Record<string, unknown>>; diagnostics: Diagnostic[]; }
8
9
  export interface ProvenanceStep { kind: string; source?: SourceLocation; from?: string; to?: string; name?: string; phase?: number; value?: string; owner?: string; target?: string; }
@@ -10,15 +11,119 @@ export interface ProvenanceOrigin { source: SourceLocation | null; chunk: string
10
11
  export interface ProvenanceSegment { generated: { start: number; end: number }; source: SourceLocation | null; chunk: string; kind: string; precision: "exact" | "coarse"; via: ProvenanceStep[]; origins?: ProvenanceOrigin[]; }
11
12
  export interface DeliverableProvenanceMap { version: 1; kind: "ravel-provenance-map"; generated: { uri: string; length: number; offsetEncoding: "utf-16" }; from: string; segments: ProvenanceSegment[]; }
12
13
  export interface BuildProvenanceMap { version: 1; kind: "ravel-provenance-bundle"; maps: DeliverableProvenanceMap[]; }
13
- export interface ProgramChunk { id: string; identity: ChunkIdentity; value: string; segments: ProvenanceSegment[]; source: SourceLocation; dependencies: string[]; references: Array<{ chunk: string; requested: string; source: SourceLocation }>; provenance: unknown[]; generated?: boolean; }
14
+ export interface ProgramChunk { id: string; identity: ChunkIdentity; value: string; segments: ProvenanceSegment[]; metadata: { language?: string; data?: { ravel?: { run?: boolean; provider?: string; [key: string]: unknown }; [key: string]: unknown }; [key: string]: unknown }; source: SourceLocation; dependencies: string[]; references: Array<{ chunk: string; requested: string; source: SourceLocation }>; provenance: unknown[]; generated?: boolean; }
14
15
  export interface Deliverable { name: string; from: string; value: string; segments: ProvenanceSegment[]; source: SourceLocation; dependencies: string[]; }
15
16
  export interface RavelProgram { version: 1; documents: PretransformGraph["documents"]; chunks: Record<string, ProgramChunk>; deliverables: Record<string, Deliverable>; diagnostics: Diagnostic[]; trace: { chunks: Record<string, unknown[]> }; }
16
17
  export interface TransformCall { type?: "transform"; name: string; arguments?: unknown[]; source?: SourceLocation; }
18
+ /** Stable v0.2 execution-boundary contract. Providers must preserve this shape. */
19
+ export type LiveContractVersion = 1;
20
+ export type LiveExecutionStatus = "succeeded" | "failed";
21
+ export interface LiveDependency { reference: string; source?: SourceLocation; }
22
+ export interface LiveResourceRequest { name?: string; path?: string; source?: SourceLocation; }
23
+ export interface LiveModuleRequest { specifier: string; source?: SourceLocation; }
24
+ export interface LiveAnalysis {
25
+ version: LiveContractVersion;
26
+ dependencies: Array<string | LiveDependency>;
27
+ resources: Array<string | LiveResourceRequest>;
28
+ modules: Array<string | LiveModuleRequest>;
29
+ diagnostics: Diagnostic[];
30
+ }
31
+ export interface LiveAnalysisRequest {
32
+ id: string;
33
+ language: string;
34
+ source: string;
35
+ sourceLocation: SourceLocation;
36
+ }
37
+ export interface LiveExecutionRequest {
38
+ version: LiveContractVersion;
39
+ id: string;
40
+ runId: string;
41
+ language: string;
42
+ source: string;
43
+ sourceLocation: SourceLocation;
44
+ inputs: Record<string, RavelValue>;
45
+ resources: Record<string, RavelValue>;
46
+ analysis: LiveAnalysis;
47
+ limits: Record<string, unknown>;
48
+ signal?: AbortSignal;
49
+ }
50
+ export interface LiveExecutionOutcome {
51
+ version: LiveContractVersion;
52
+ ok: boolean;
53
+ status: LiveExecutionStatus;
54
+ hasExport: boolean;
55
+ value?: RavelValue;
56
+ serialized?: string;
57
+ diagnostics: Diagnostic[];
58
+ durationMs?: number;
59
+ }
60
+ export interface ExecutionProvider {
61
+ id: string;
62
+ version: string;
63
+ languages: readonly string[] | ReadonlySet<string>;
64
+ analyze(request: LiveAnalysisRequest): LiveAnalysis;
65
+ execute(request: LiveExecutionRequest): Promise<LiveExecutionOutcome> | LiveExecutionOutcome;
66
+ dispose?(): Promise<void> | void;
67
+ }
68
+ export interface LiveExecutionPlan {
69
+ version: 1;
70
+ nodes: Record<string, {
71
+ id: string;
72
+ language: string;
73
+ provider: { id: string; version: string };
74
+ source: SourceLocation;
75
+ dependencies: Array<{ reference: string; id: string; source: SourceLocation }>;
76
+ resources: Array<string | LiveResourceRequest>;
77
+ modules: Array<string | LiveModuleRequest>;
78
+ analysis: LiveAnalysis;
79
+ }>;
80
+ diagnostics: Diagnostic[];
81
+ ok: boolean;
82
+ }
83
+ export interface LiveProgramResult {
84
+ version: 1;
85
+ program: RavelProgram;
86
+ plan: LiveExecutionPlan;
87
+ executions: Record<string, {
88
+ id: string;
89
+ status: LiveExecutionStatus;
90
+ value?: RavelValue;
91
+ serialized?: string;
92
+ provider?: { id: string; version: string };
93
+ durationMs?: number;
94
+ }>;
95
+ diagnostics: Diagnostic[];
96
+ ok: boolean;
97
+ }
17
98
  export function formatChunkId(identity: ChunkIdentity): string;
18
99
  export function parseChunkId(input: string, options?: { reference?: boolean }): ChunkIdentity | null;
19
- export function parseChunk(body: string, source: SourceLocation): { nodes: unknown[]; diagnostics: Diagnostic[] };
100
+ export interface ChunkReferenceSyntaxOptions {
101
+ nowebReferences?: boolean;
102
+ nowebPlus?: boolean;
103
+ underscoreReferences?: boolean;
104
+ referenceAliases?: Record<string, string>;
105
+ }
106
+ export function parseChunk(body: string, source: SourceLocation, options?: ChunkReferenceSyntaxOptions): { nodes: unknown[]; diagnostics: Diagnostic[] };
107
+ export function nowebReferenceAt(body: string, index: number): { authored: string; end: number } | null;
108
+ export function parseDefinitionPipeline(text: string, source: SourceLocation): { pipeline: TransformCall[]; diagnostics: Diagnostic[] };
20
109
  export function combineMaps(maps: RavelMap[]): PretransformGraph;
21
- export function transformGraph(graph: PretransformGraph, options?: { transforms?: Record<string, (value: string, ...argumentsValue: unknown[]) => string> | Map<string, Function> }): RavelProgram;
110
+ export function transformGraph(graph: PretransformGraph, options?: {
111
+ transforms?: Record<string, (value: string, ...argumentsValue: unknown[]) => string> | Map<string, Function>;
112
+ deferLiveResults?: boolean;
113
+ liveResults?: LiveProgramResult | LiveProgramResult["executions"] | Map<string, LiveProgramResult["executions"][string]>;
114
+ }): RavelProgram;
115
+ export function ravelValueIssue(value: unknown, path?: string): string | null;
116
+ export function serializeRavelValue(value: unknown): string;
117
+ export function cloneRavelValue(value: RavelValue): RavelValue;
118
+ export function planLiveExecutions(program: RavelProgram, options?: { providers?: ExecutionProvider[] | Map<string, ExecutionProvider> | Record<string, ExecutionProvider> }): LiveExecutionPlan;
119
+ export interface LiveExecutionOptions {
120
+ providers?: ExecutionProvider[] | Map<string, ExecutionProvider> | Record<string, ExecutionProvider>;
121
+ resources?: Map<string, RavelValue> | Record<string, RavelValue>;
122
+ limits?: Record<string, unknown>;
123
+ runId?: string;
124
+ signal?: AbortSignal;
125
+ }
126
+ export function executeLiveProgram(program: RavelProgram, options?: LiveExecutionOptions): Promise<LiveProgramResult>;
22
127
  export const provenanceMapVersion: 1;
23
128
  export function createDeliverableProvenanceMap(deliverable: Deliverable): DeliverableProvenanceMap;
24
129
  export function createBuildProvenanceMap(program: RavelProgram): BuildProvenanceMap;
@@ -33,5 +138,9 @@ export function append(reference: string, source: SourceLocation): unknown;
33
138
  export function newline(count: number, source: SourceLocation): unknown;
34
139
  export function pipe(steps: unknown[], source: SourceLocation): unknown;
35
140
  export function pass(steps: unknown[], source: SourceLocation): unknown;
36
- export function createDirective(name: string, value: unknown, source: SourceLocation): unknown;
37
- export function aliasDirective(name: string, reference: string, source: SourceLocation): unknown;
141
+ export function createDirective(name: string, value: unknown[] | string, source: SourceLocation, document?: string): { kind: "create"; document?: string; name: string; compose?: unknown[]; body?: string; source: SourceLocation };
142
+ export function aliasDirective(name: string, reference: string, source: SourceLocation, document?: string): { kind: "alias"; document?: string; name: string; reference: string; source: SourceLocation };
143
+ export function parseRavelDirectiveBlock(text: string, options: {
144
+ document: string;
145
+ sourceAt(start: number, end: number): SourceLocation;
146
+ }): { directives: Array<Record<string, unknown>>; diagnostics: Diagnostic[] };