dirac-lang 0.1.27 → 0.1.29
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/dist/{chunk-52ED23DR.js → chunk-BSQV77YM.js} +17 -15
- package/dist/{chunk-E7PWEMZA.js → chunk-LXF5PGUX.js} +1 -1
- package/dist/{chunk-7OUYWIZV.js → chunk-VURAZURY.js} +26 -18
- package/dist/{chunk-OUMUIBK3.js → chunk-YV6QRRMT.js} +2 -2
- package/dist/cli.js +5 -5
- package/dist/index.js +4 -4
- package/dist/{interpreter-MTIIHIIQ.js → interpreter-BB4H4XG4.js} +3 -3
- package/dist/{session-4ZNNZ6R3.js → session-QXKZY7G2.js} +1 -1
- package/dist/{subroutine-K4YTGUGJ.js → subroutine-GG66UT4D.js} +2 -2
- package/dist/{tag-validator-HBCGQV6F.js → tag-validator-ANTK7UTG.js} +1 -1
- package/dist/test-runner.js +3 -3
- package/package.json +1 -1
|
@@ -67,21 +67,23 @@ function createSession(config = {}) {
|
|
|
67
67
|
const openaiKey = config.apiKey || process.env.OPENAI_API_KEY;
|
|
68
68
|
const llmProvider = config.llmProvider || process.env.LLM_PROVIDER;
|
|
69
69
|
const ollamaModel = config.llmModel || process.env.LLM_MODEL || "llama2";
|
|
70
|
-
let llmClient;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
let llmClient = null;
|
|
71
|
+
if (llmProvider) {
|
|
72
|
+
switch (llmProvider) {
|
|
73
|
+
case "ollama":
|
|
74
|
+
llmClient = new OllamaProvider({ model: ollamaModel });
|
|
75
|
+
break;
|
|
76
|
+
case "anthropic":
|
|
77
|
+
if (!anthropicKey) throw new Error("ANTHROPIC_API_KEY required for Anthropic provider");
|
|
78
|
+
llmClient = new Anthropic({ apiKey: anthropicKey });
|
|
79
|
+
break;
|
|
80
|
+
case "openai":
|
|
81
|
+
if (!openaiKey) throw new Error("OPENAI_API_KEY required for OpenAI provider");
|
|
82
|
+
llmClient = new OpenAI({ apiKey: openaiKey });
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
throw new Error(`Unknown LLM provider: ${llmProvider}. Use 'ollama', 'anthropic', or 'openai'.`);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
return {
|
|
87
89
|
variables: [],
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-HRHAMPOB.js";
|
|
4
4
|
import {
|
|
5
5
|
executeSubroutine
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LXF5PGUX.js";
|
|
7
7
|
import {
|
|
8
8
|
cleanToBoundary,
|
|
9
9
|
emit,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
substituteVariables,
|
|
24
24
|
throwException,
|
|
25
25
|
unsetExceptionBoundary
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BSQV77YM.js";
|
|
27
27
|
|
|
28
28
|
// src/tags/parameters.ts
|
|
29
29
|
async function executeParameters(session, element) {
|
|
@@ -255,7 +255,7 @@ async function executeCall(session, element) {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
async function registerExtendChain(session, subroutine, currentName) {
|
|
258
|
-
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-
|
|
258
|
+
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-GG66UT4D.js");
|
|
259
259
|
const extendsAttr = subroutine.attributes.extends;
|
|
260
260
|
let parentName;
|
|
261
261
|
if (extendsAttr) {
|
|
@@ -419,12 +419,12 @@ async function executeIf(session, element) {
|
|
|
419
419
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
420
420
|
if (condition) {
|
|
421
421
|
if (thenElement) {
|
|
422
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
422
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
423
423
|
await integrateChildren2(session, thenElement);
|
|
424
424
|
}
|
|
425
425
|
} else {
|
|
426
426
|
if (elseElement) {
|
|
427
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
427
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
428
428
|
await integrateChildren2(session, elseElement);
|
|
429
429
|
}
|
|
430
430
|
}
|
|
@@ -437,7 +437,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
437
437
|
return await evaluateCondition(session, predicateElement);
|
|
438
438
|
}
|
|
439
439
|
const outputLengthBefore = session.output.length;
|
|
440
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
440
|
+
const { integrate: integrate2 } = await import("./interpreter-BB4H4XG4.js");
|
|
441
441
|
await integrate2(session, predicateElement);
|
|
442
442
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
443
443
|
const result = newOutputChunks.join("").trim();
|
|
@@ -460,11 +460,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
460
460
|
}
|
|
461
461
|
const outputLengthBefore = session.output.length;
|
|
462
462
|
const args = [];
|
|
463
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
463
|
+
const { integrate: integrate2 } = await import("./interpreter-BB4H4XG4.js");
|
|
464
464
|
for (const child of condElement.children) {
|
|
465
465
|
if (child.tag.toLowerCase() === "arg") {
|
|
466
466
|
const argOutputStart = session.output.length;
|
|
467
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
467
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
468
468
|
await integrateChildren2(session, child);
|
|
469
469
|
const newChunks = session.output.slice(argOutputStart);
|
|
470
470
|
const argValue = newChunks.join("");
|
|
@@ -525,7 +525,7 @@ function evaluateConditionType(evalType, args) {
|
|
|
525
525
|
// src/tags/llm.ts
|
|
526
526
|
async function executeLLM(session, element) {
|
|
527
527
|
if (!session.llmClient) {
|
|
528
|
-
throw new Error("<
|
|
528
|
+
throw new Error("<llm> tag requires LLM configuration. Set LLM_PROVIDER (ollama/anthropic/openai) and appropriate API keys in environment or config.yml");
|
|
529
529
|
}
|
|
530
530
|
if (session.limits.currentLLMCalls >= session.limits.maxLLMCalls) {
|
|
531
531
|
throw new Error("Maximum LLM calls exceeded");
|
|
@@ -573,7 +573,7 @@ async function executeLLM(session, element) {
|
|
|
573
573
|
console.error("[LLM] Full prompt sent to LLM (noextra):\n" + prompt + "\n");
|
|
574
574
|
}
|
|
575
575
|
} else {
|
|
576
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
576
|
+
const { getAvailableSubroutines } = await import("./session-QXKZY7G2.js");
|
|
577
577
|
const subroutines = getAvailableSubroutines(session);
|
|
578
578
|
if (session.debug) {
|
|
579
579
|
console.error(
|
|
@@ -700,7 +700,7 @@ ${result}
|
|
|
700
700
|
const parser = new DiracParser();
|
|
701
701
|
let dynamicAST = parser.parse(diracCode);
|
|
702
702
|
if (validateTags) {
|
|
703
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
703
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-ANTK7UTG.js");
|
|
704
704
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect });
|
|
705
705
|
let retryCount = 0;
|
|
706
706
|
while (!validation.valid && retryCount < maxRetries) {
|
|
@@ -1230,7 +1230,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1230
1230
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1231
1231
|
}
|
|
1232
1232
|
async function executeTagCheck(session, element) {
|
|
1233
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
1233
|
+
const { getAvailableSubroutines } = await import("./session-QXKZY7G2.js");
|
|
1234
1234
|
const subroutines = getAvailableSubroutines(session);
|
|
1235
1235
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1236
1236
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -1323,7 +1323,7 @@ async function executeTagCheck(session, element) {
|
|
|
1323
1323
|
const executeTag = correctedTag || tagName;
|
|
1324
1324
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1325
1325
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1326
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1326
|
+
const { integrate: integrate2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1327
1327
|
await integrate2(session, elementToExecute);
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
@@ -1332,7 +1332,7 @@ async function executeTagCheck(session, element) {
|
|
|
1332
1332
|
// src/tags/throw.ts
|
|
1333
1333
|
async function executeThrow(session, element) {
|
|
1334
1334
|
const exceptionName = element.attributes?.name || "exception";
|
|
1335
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1335
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1336
1336
|
const exceptionDom = {
|
|
1337
1337
|
tag: "exception-content",
|
|
1338
1338
|
attributes: { name: exceptionName },
|
|
@@ -1345,7 +1345,7 @@ async function executeThrow(session, element) {
|
|
|
1345
1345
|
// src/tags/try.ts
|
|
1346
1346
|
async function executeTry(session, element) {
|
|
1347
1347
|
setExceptionBoundary(session);
|
|
1348
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1348
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1349
1349
|
await integrateChildren2(session, element);
|
|
1350
1350
|
unsetExceptionBoundary(session);
|
|
1351
1351
|
}
|
|
@@ -1355,7 +1355,7 @@ async function executeCatch(session, element) {
|
|
|
1355
1355
|
const exceptionName = element.attributes?.name || "exception";
|
|
1356
1356
|
const caughtCount = lookupException(session, exceptionName);
|
|
1357
1357
|
if (caughtCount > 0) {
|
|
1358
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1358
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1359
1359
|
await integrateChildren2(session, element);
|
|
1360
1360
|
}
|
|
1361
1361
|
flushCurrentException(session);
|
|
@@ -1364,7 +1364,7 @@ async function executeCatch(session, element) {
|
|
|
1364
1364
|
// src/tags/exception.ts
|
|
1365
1365
|
async function executeException(session, element) {
|
|
1366
1366
|
const exceptions = getCurrentExceptions(session);
|
|
1367
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1367
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1368
1368
|
for (const exceptionDom of exceptions) {
|
|
1369
1369
|
await integrateChildren2(session, exceptionDom);
|
|
1370
1370
|
}
|
|
@@ -1504,7 +1504,7 @@ async function executeForeach(session, element) {
|
|
|
1504
1504
|
const parser2 = new DiracParser2();
|
|
1505
1505
|
try {
|
|
1506
1506
|
const fromElement = parser2.parse(fromAttr);
|
|
1507
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1507
|
+
const { integrate: integrate2 } = await import("./interpreter-BB4H4XG4.js");
|
|
1508
1508
|
await integrate2(session, fromElement);
|
|
1509
1509
|
} catch (e) {
|
|
1510
1510
|
session.output = savedOutput;
|
|
@@ -1597,6 +1597,11 @@ function matchesXPath(item, xpath) {
|
|
|
1597
1597
|
return true;
|
|
1598
1598
|
}
|
|
1599
1599
|
|
|
1600
|
+
// src/tags/break.ts
|
|
1601
|
+
async function executeBreak(session, element) {
|
|
1602
|
+
session.isBreak = true;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1600
1605
|
// src/tags/attr.ts
|
|
1601
1606
|
async function executeAttr(session, element) {
|
|
1602
1607
|
const nameAttr = element.attributes.name;
|
|
@@ -1791,6 +1796,9 @@ async function integrate(session, element) {
|
|
|
1791
1796
|
case "loop":
|
|
1792
1797
|
await executeLoop(session, element);
|
|
1793
1798
|
break;
|
|
1799
|
+
case "break":
|
|
1800
|
+
await executeBreak(session, element);
|
|
1801
|
+
break;
|
|
1794
1802
|
case "if":
|
|
1795
1803
|
await executeIf(session, element);
|
|
1796
1804
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VURAZURY.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createSession,
|
|
9
9
|
getAvailableSubroutines,
|
|
10
10
|
getOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BSQV77YM.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/llm-adapter.ts
|
|
14
14
|
function createLLMAdapter(session) {
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
execute
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-YV6QRRMT.js";
|
|
5
|
+
import "./chunk-VURAZURY.js";
|
|
6
6
|
import "./chunk-HRHAMPOB.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-LXF5PGUX.js";
|
|
8
|
+
import "./chunk-BSQV77YM.js";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
11
|
import "dotenv/config";
|
|
@@ -13,7 +13,7 @@ import "dotenv/config";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "dirac-lang",
|
|
16
|
-
version: "0.1.
|
|
16
|
+
version: "0.1.28",
|
|
17
17
|
description: "LLM-Augmented Declarative Execution",
|
|
18
18
|
type: "module",
|
|
19
19
|
main: "dist/index.js",
|
package/dist/index.js
CHANGED
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
createLLMAdapter,
|
|
3
3
|
execute,
|
|
4
4
|
executeUserCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YV6QRRMT.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VURAZURY.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-LXF5PGUX.js";
|
|
13
13
|
import {
|
|
14
14
|
createSession,
|
|
15
15
|
getAvailableSubroutines,
|
|
16
16
|
getOutput
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-BSQV77YM.js";
|
|
18
18
|
export {
|
|
19
19
|
DiracParser,
|
|
20
20
|
createLLMAdapter,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate,
|
|
3
3
|
integrateChildren
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VURAZURY.js";
|
|
5
5
|
import "./chunk-HRHAMPOB.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-LXF5PGUX.js";
|
|
7
|
+
import "./chunk-BSQV77YM.js";
|
|
8
8
|
export {
|
|
9
9
|
integrate,
|
|
10
10
|
integrateChildren
|
|
@@ -49,7 +49,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
49
49
|
}
|
|
50
50
|
async function validateTag(session, element, options = {}) {
|
|
51
51
|
const { autocorrect = false, similarityCutoff = SIMILARITY_CUTOFF } = options;
|
|
52
|
-
const { getAvailableSubroutines } = await import("./session-
|
|
52
|
+
const { getAvailableSubroutines } = await import("./session-QXKZY7G2.js");
|
|
53
53
|
const subroutines = getAvailableSubroutines(session);
|
|
54
54
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
55
55
|
const tagName = element.tag;
|
package/dist/test-runner.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VURAZURY.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-LXF5PGUX.js";
|
|
8
8
|
import {
|
|
9
9
|
createSession,
|
|
10
10
|
getOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-BSQV77YM.js";
|
|
12
12
|
|
|
13
13
|
// src/test-runner.ts
|
|
14
14
|
import fs from "fs";
|