dirac-lang 0.1.54 → 0.1.56
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-C6DBZRQZ.js → chunk-AJSYOXXZ.js} +3 -0
- package/dist/{chunk-A4SFB5W4.js → chunk-IN55WRFB.js} +2 -0
- package/dist/{chunk-QZGTAT3E.js → chunk-M43Y5X5P.js} +82 -35
- package/dist/{chunk-EXP3R5ZJ.js → chunk-NK2ZTQGT.js} +2 -2
- package/dist/{chunk-ZY37RS4P.js → chunk-WX7VHQYL.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/index.js +4 -4
- package/dist/{interpreter-I4SRKXYK.js → interpreter-RV7UVTYE.js} +3 -3
- package/dist/{schedule-7ZFCWNEF.js → schedule-2LAUKHZX.js} +3 -3
- package/dist/{session-5PEIMBGV.js → session-MRU57VMJ.js} +1 -1
- package/dist/{shell-XIJKOMBE.js → shell-WMXFN2EX.js} +35 -16
- package/dist/{subroutine-VIACWZPF.js → subroutine-RBTBNR2T.js} +2 -2
- package/dist/{tag-validator-AZXYIKQV.js → tag-validator-BTBNFPJD.js} +1 -1
- package/dist/test-runner.js +3 -3
- package/package.json +1 -1
|
@@ -73,6 +73,9 @@ var BraKetParser = class {
|
|
|
73
73
|
if (!content.trim()) {
|
|
74
74
|
return { indent, type: "empty", raw };
|
|
75
75
|
}
|
|
76
|
+
if (content.startsWith("#")) {
|
|
77
|
+
return { indent, type: "empty", raw };
|
|
78
|
+
}
|
|
76
79
|
if (content.startsWith("<") && content.endsWith("|")) {
|
|
77
80
|
const tagMatch = content.match(/^<([a-zA-Z_][a-zA-Z0-9_-]*)\s*/);
|
|
78
81
|
if (tagMatch) {
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-HRHAMPOB.js";
|
|
4
4
|
import {
|
|
5
5
|
executeSubroutine
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WX7VHQYL.js";
|
|
7
7
|
import {
|
|
8
|
+
CustomLLMProvider,
|
|
9
|
+
OllamaProvider,
|
|
8
10
|
cleanSubroutinesToBoundary,
|
|
9
11
|
cleanToBoundary,
|
|
10
12
|
emit,
|
|
@@ -26,7 +28,7 @@ import {
|
|
|
26
28
|
substituteVariables,
|
|
27
29
|
throwException,
|
|
28
30
|
unsetExceptionBoundary
|
|
29
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-IN55WRFB.js";
|
|
30
32
|
|
|
31
33
|
// src/tags/parameters.ts
|
|
32
34
|
async function executeParameters(session, element) {
|
|
@@ -282,7 +284,7 @@ async function executeCall(session, element) {
|
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
286
|
async function registerExtendChain(session, subroutine, currentName) {
|
|
285
|
-
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-
|
|
287
|
+
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-RBTBNR2T.js");
|
|
286
288
|
const extendsAttr = subroutine.attributes.extends;
|
|
287
289
|
let parentName;
|
|
288
290
|
if (extendsAttr) {
|
|
@@ -472,12 +474,12 @@ async function executeIf(session, element) {
|
|
|
472
474
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
473
475
|
if (condition) {
|
|
474
476
|
if (thenElement) {
|
|
475
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
477
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
476
478
|
await integrateChildren2(session, thenElement);
|
|
477
479
|
}
|
|
478
480
|
} else {
|
|
479
481
|
if (elseElement) {
|
|
480
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
482
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
481
483
|
await integrateChildren2(session, elseElement);
|
|
482
484
|
}
|
|
483
485
|
}
|
|
@@ -490,7 +492,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
490
492
|
return await evaluateCondition(session, predicateElement);
|
|
491
493
|
}
|
|
492
494
|
const outputLengthBefore = session.output.length;
|
|
493
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
495
|
+
const { integrate: integrate2 } = await import("./interpreter-RV7UVTYE.js");
|
|
494
496
|
await integrate2(session, predicateElement);
|
|
495
497
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
496
498
|
const result = newOutputChunks.join("").trim();
|
|
@@ -513,11 +515,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
513
515
|
}
|
|
514
516
|
const outputLengthBefore = session.output.length;
|
|
515
517
|
const args = [];
|
|
516
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
518
|
+
const { integrate: integrate2 } = await import("./interpreter-RV7UVTYE.js");
|
|
517
519
|
for (const child of condElement.children) {
|
|
518
520
|
if (child.tag.toLowerCase() === "arg") {
|
|
519
521
|
const argOutputStart = session.output.length;
|
|
520
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
522
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
521
523
|
await integrateChildren2(session, child);
|
|
522
524
|
const newChunks = session.output.slice(argOutputStart);
|
|
523
525
|
const argValue = newChunks.join("");
|
|
@@ -576,9 +578,31 @@ function evaluateConditionType(evalType, args) {
|
|
|
576
578
|
}
|
|
577
579
|
|
|
578
580
|
// src/tags/llm.ts
|
|
581
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
582
|
+
import OpenAI from "openai";
|
|
579
583
|
import * as fs2 from "fs";
|
|
580
584
|
import * as path2 from "path";
|
|
581
585
|
import * as os from "os";
|
|
586
|
+
function createLLMClient(provider, model) {
|
|
587
|
+
const anthropicKey = process.env.ANTHROPIC_API_KEY;
|
|
588
|
+
const openaiKey = process.env.OPENAI_API_KEY;
|
|
589
|
+
const ollamaModel = model || process.env.LLM_MODEL || "llama2";
|
|
590
|
+
const customBaseUrl = process.env.CUSTOM_LLM_URL || "http://localhost:5001";
|
|
591
|
+
switch (provider) {
|
|
592
|
+
case "ollama":
|
|
593
|
+
return new OllamaProvider({ model: ollamaModel });
|
|
594
|
+
case "anthropic":
|
|
595
|
+
if (!anthropicKey) throw new Error("ANTHROPIC_API_KEY required for Anthropic provider");
|
|
596
|
+
return new Anthropic({ apiKey: anthropicKey });
|
|
597
|
+
case "openai":
|
|
598
|
+
if (!openaiKey) throw new Error("OPENAI_API_KEY required for OpenAI provider");
|
|
599
|
+
return new OpenAI({ apiKey: openaiKey });
|
|
600
|
+
case "custom":
|
|
601
|
+
return new CustomLLMProvider({ baseUrl: customBaseUrl, model: ollamaModel });
|
|
602
|
+
default:
|
|
603
|
+
throw new Error(`Unknown LLM provider: ${provider}. Use 'ollama', 'anthropic', 'openai', or 'custom'.`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
582
606
|
function dumpGeneratedSubroutines(session, diracCode, userPrompt) {
|
|
583
607
|
try {
|
|
584
608
|
let findSubroutines2 = function(element) {
|
|
@@ -687,7 +711,19 @@ async function executeLLM(session, element) {
|
|
|
687
711
|
throw new Error("Maximum LLM calls exceeded");
|
|
688
712
|
}
|
|
689
713
|
session.limits.currentLLMCalls++;
|
|
690
|
-
const
|
|
714
|
+
const requestedProvider = element.attributes.provider;
|
|
715
|
+
let llmClient = session.llmClient;
|
|
716
|
+
if (requestedProvider) {
|
|
717
|
+
const requestedModel = element.attributes.model || process.env.DEFAULT_MODEL;
|
|
718
|
+
llmClient = createLLMClient(requestedProvider, requestedModel);
|
|
719
|
+
if (session.debug) {
|
|
720
|
+
console.error(`[LLM] Switching to provider: ${requestedProvider}`);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (!llmClient) {
|
|
724
|
+
throw new Error("No LLM provider configured. Set provider attribute or configure session with LLM_PROVIDER.");
|
|
725
|
+
}
|
|
726
|
+
const providerName = llmClient.constructor.name;
|
|
691
727
|
const isOpenAI = providerName === "OpenAI";
|
|
692
728
|
const isOllama = providerName === "OllamaProvider";
|
|
693
729
|
const isCustom = providerName === "CustomLLMProvider";
|
|
@@ -729,15 +765,26 @@ async function executeLLM(session, element) {
|
|
|
729
765
|
dialogHistory = [...existing];
|
|
730
766
|
hasExistingDialog = dialogHistory.length > 0;
|
|
731
767
|
} else if (existing) {
|
|
732
|
-
|
|
733
|
-
|
|
768
|
+
try {
|
|
769
|
+
const parsed = JSON.parse(String(existing));
|
|
770
|
+
if (Array.isArray(parsed)) {
|
|
771
|
+
dialogHistory = parsed;
|
|
772
|
+
hasExistingDialog = dialogHistory.length > 0;
|
|
773
|
+
} else {
|
|
774
|
+
dialogHistory = [{ role: "system", content: String(existing) }];
|
|
775
|
+
hasExistingDialog = true;
|
|
776
|
+
}
|
|
777
|
+
} catch {
|
|
778
|
+
dialogHistory = [{ role: "system", content: String(existing) }];
|
|
779
|
+
hasExistingDialog = true;
|
|
780
|
+
}
|
|
734
781
|
}
|
|
735
782
|
}
|
|
736
783
|
const noExtra = element.attributes.noextra === "true";
|
|
737
784
|
let systemPrompt = "";
|
|
738
785
|
let currentUserPrompt = userPrompt;
|
|
739
786
|
if (!noExtra) {
|
|
740
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
787
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-MRU57VMJ.js");
|
|
741
788
|
const subroutines = getAvailableSubroutines2(session);
|
|
742
789
|
if (session.debug) {
|
|
743
790
|
console.error(
|
|
@@ -828,7 +875,7 @@ CRITICAL: When defining parameters:
|
|
|
828
875
|
try {
|
|
829
876
|
let result;
|
|
830
877
|
if (isOpenAI) {
|
|
831
|
-
const response = await
|
|
878
|
+
const response = await llmClient.chat.completions.create({
|
|
832
879
|
model,
|
|
833
880
|
max_tokens: maxTokens,
|
|
834
881
|
temperature,
|
|
@@ -837,21 +884,21 @@ CRITICAL: When defining parameters:
|
|
|
837
884
|
result = response.choices[0]?.message?.content || "";
|
|
838
885
|
} else if (isOllama) {
|
|
839
886
|
const ollamaPrompt = dialogHistory.map((m) => `${m.role.charAt(0).toUpperCase() + m.role.slice(1)}: ${m.content}`).join("\n");
|
|
840
|
-
result = await
|
|
887
|
+
result = await llmClient.complete(ollamaPrompt, {
|
|
841
888
|
model,
|
|
842
889
|
temperature,
|
|
843
890
|
max_tokens: maxTokens
|
|
844
891
|
});
|
|
845
892
|
} else if (isCustom) {
|
|
846
893
|
const customPrompt = dialogHistory.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
847
|
-
result = await
|
|
894
|
+
result = await llmClient.complete(customPrompt, {
|
|
848
895
|
model,
|
|
849
896
|
temperature,
|
|
850
897
|
max_tokens: maxTokens,
|
|
851
898
|
messages: dialogHistory
|
|
852
899
|
});
|
|
853
900
|
} else {
|
|
854
|
-
result = await callAnthropic(
|
|
901
|
+
result = await callAnthropic(llmClient, model, maxTokens, temperature, dialogHistory);
|
|
855
902
|
}
|
|
856
903
|
if (session.debug) {
|
|
857
904
|
console.error(`[LLM] Response length: ${result.length}`);
|
|
@@ -865,7 +912,7 @@ ${result}
|
|
|
865
912
|
if (session.debug) {
|
|
866
913
|
console.error(`[LLM] Saving dialog history (${dialogHistory.length} messages) to: ${varName}`);
|
|
867
914
|
}
|
|
868
|
-
setVariable(session, varName, dialogHistory, true);
|
|
915
|
+
setVariable(session, varName, JSON.stringify(dialogHistory), true);
|
|
869
916
|
}
|
|
870
917
|
if (outputVar) {
|
|
871
918
|
setVariable(session, outputVar, result, false);
|
|
@@ -909,7 +956,7 @@ ${result}
|
|
|
909
956
|
const parser = new DiracParser();
|
|
910
957
|
let dynamicAST = parser.parse(diracCode);
|
|
911
958
|
if (validateTags) {
|
|
912
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
959
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-BTBNFPJD.js");
|
|
913
960
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect });
|
|
914
961
|
let retryCount = 0;
|
|
915
962
|
while (!validation.valid && retryCount < maxRetries) {
|
|
@@ -924,7 +971,7 @@ ${errorFeedback}
|
|
|
924
971
|
Please fix these errors and generate valid Dirac XML again. Remember to only use the allowed tags.`;
|
|
925
972
|
dialogHistory.push({ role: "user", content: retryPrompt });
|
|
926
973
|
if (isOpenAI) {
|
|
927
|
-
const response = await
|
|
974
|
+
const response = await llmClient.chat.completions.create({
|
|
928
975
|
model,
|
|
929
976
|
max_tokens: maxTokens,
|
|
930
977
|
temperature,
|
|
@@ -933,21 +980,21 @@ Please fix these errors and generate valid Dirac XML again. Remember to only use
|
|
|
933
980
|
result = response.choices[0]?.message?.content || "";
|
|
934
981
|
} else if (isOllama) {
|
|
935
982
|
const ollamaPrompt = dialogHistory.map((m) => `${m.role.charAt(0).toUpperCase() + m.role.slice(1)}: ${m.content}`).join("\n");
|
|
936
|
-
result = await
|
|
983
|
+
result = await llmClient.complete(ollamaPrompt, {
|
|
937
984
|
model,
|
|
938
985
|
temperature,
|
|
939
986
|
max_tokens: maxTokens
|
|
940
987
|
});
|
|
941
988
|
} else if (isCustom) {
|
|
942
989
|
const customPrompt = dialogHistory.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
943
|
-
result = await
|
|
990
|
+
result = await llmClient.complete(customPrompt, {
|
|
944
991
|
model,
|
|
945
992
|
temperature,
|
|
946
993
|
max_tokens: maxTokens,
|
|
947
994
|
messages: dialogHistory
|
|
948
995
|
});
|
|
949
996
|
} else {
|
|
950
|
-
result = await callAnthropic(
|
|
997
|
+
result = await callAnthropic(llmClient, model, maxTokens, temperature, dialogHistory);
|
|
951
998
|
}
|
|
952
999
|
dialogHistory.push({ role: "assistant", content: result });
|
|
953
1000
|
if (contextVar) {
|
|
@@ -1010,7 +1057,7 @@ ${feedbackPrompt}
|
|
|
1010
1057
|
}
|
|
1011
1058
|
dialogHistory.push({ role: "user", content: feedbackPrompt });
|
|
1012
1059
|
if (isOpenAI) {
|
|
1013
|
-
const response = await
|
|
1060
|
+
const response = await llmClient.chat.completions.create({
|
|
1014
1061
|
model,
|
|
1015
1062
|
max_tokens: maxTokens,
|
|
1016
1063
|
temperature,
|
|
@@ -1019,21 +1066,21 @@ ${feedbackPrompt}
|
|
|
1019
1066
|
result = response.choices[0]?.message?.content || "";
|
|
1020
1067
|
} else if (isOllama) {
|
|
1021
1068
|
const ollamaPrompt = dialogHistory.map((m) => `${m.role.charAt(0).toUpperCase() + m.role.slice(1)}: ${m.content}`).join("\n");
|
|
1022
|
-
result = await
|
|
1069
|
+
result = await llmClient.complete(ollamaPrompt, {
|
|
1023
1070
|
model,
|
|
1024
1071
|
temperature,
|
|
1025
1072
|
max_tokens: maxTokens
|
|
1026
1073
|
});
|
|
1027
1074
|
} else if (isCustom) {
|
|
1028
1075
|
const customPrompt = dialogHistory.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
1029
|
-
result = await
|
|
1076
|
+
result = await llmClient.complete(customPrompt, {
|
|
1030
1077
|
model,
|
|
1031
1078
|
temperature,
|
|
1032
1079
|
max_tokens: maxTokens,
|
|
1033
1080
|
messages: dialogHistory
|
|
1034
1081
|
});
|
|
1035
1082
|
} else {
|
|
1036
|
-
result = await callAnthropic(
|
|
1083
|
+
result = await callAnthropic(llmClient, model, maxTokens, temperature, dialogHistory);
|
|
1037
1084
|
}
|
|
1038
1085
|
dialogHistory.push({ role: "assistant", content: result });
|
|
1039
1086
|
if (contextVar) {
|
|
@@ -1520,7 +1567,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1520
1567
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1521
1568
|
}
|
|
1522
1569
|
async function executeTagCheck(session, element) {
|
|
1523
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
1570
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-MRU57VMJ.js");
|
|
1524
1571
|
const subroutines = getAvailableSubroutines2(session);
|
|
1525
1572
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1526
1573
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -1613,7 +1660,7 @@ async function executeTagCheck(session, element) {
|
|
|
1613
1660
|
const executeTag = correctedTag || tagName;
|
|
1614
1661
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1615
1662
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1616
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1663
|
+
const { integrate: integrate2 } = await import("./interpreter-RV7UVTYE.js");
|
|
1617
1664
|
await integrate2(session, elementToExecute);
|
|
1618
1665
|
}
|
|
1619
1666
|
}
|
|
@@ -1622,7 +1669,7 @@ async function executeTagCheck(session, element) {
|
|
|
1622
1669
|
// src/tags/throw.ts
|
|
1623
1670
|
async function executeThrow(session, element) {
|
|
1624
1671
|
const exceptionName = element.attributes?.name || "exception";
|
|
1625
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1672
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
1626
1673
|
const exceptionDom = {
|
|
1627
1674
|
tag: "exception-content",
|
|
1628
1675
|
attributes: { name: exceptionName },
|
|
@@ -1635,7 +1682,7 @@ async function executeThrow(session, element) {
|
|
|
1635
1682
|
// src/tags/try.ts
|
|
1636
1683
|
async function executeTry(session, element) {
|
|
1637
1684
|
setExceptionBoundary(session);
|
|
1638
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1685
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
1639
1686
|
await integrateChildren2(session, element);
|
|
1640
1687
|
unsetExceptionBoundary(session);
|
|
1641
1688
|
}
|
|
@@ -1645,7 +1692,7 @@ async function executeCatch(session, element) {
|
|
|
1645
1692
|
const exceptionName = element.attributes?.name || "exception";
|
|
1646
1693
|
const caughtCount = lookupException(session, exceptionName);
|
|
1647
1694
|
if (caughtCount > 0) {
|
|
1648
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1695
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
1649
1696
|
await integrateChildren2(session, element);
|
|
1650
1697
|
}
|
|
1651
1698
|
flushCurrentException(session);
|
|
@@ -1654,7 +1701,7 @@ async function executeCatch(session, element) {
|
|
|
1654
1701
|
// src/tags/exception.ts
|
|
1655
1702
|
async function executeException(session, element) {
|
|
1656
1703
|
const exceptions = getCurrentExceptions(session);
|
|
1657
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1704
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-RV7UVTYE.js");
|
|
1658
1705
|
for (const exceptionDom of exceptions) {
|
|
1659
1706
|
await integrateChildren2(session, exceptionDom);
|
|
1660
1707
|
}
|
|
@@ -2122,7 +2169,7 @@ async function executeLoadContext(session, element) {
|
|
|
2122
2169
|
query = element.text.trim();
|
|
2123
2170
|
}
|
|
2124
2171
|
if (!query && element.children.length > 0) {
|
|
2125
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2172
|
+
const { integrate: integrate2 } = await import("./interpreter-RV7UVTYE.js");
|
|
2126
2173
|
const beforeOutput = session.output.length;
|
|
2127
2174
|
for (const child of element.children) {
|
|
2128
2175
|
await integrate2(session, child);
|
|
@@ -2191,7 +2238,7 @@ async function executeLoadContext(session, element) {
|
|
|
2191
2238
|
parameters: s.parameters.map((p) => p.name),
|
|
2192
2239
|
filePath: s.filePath
|
|
2193
2240
|
}));
|
|
2194
|
-
const { setVariable: setVariable2 } = await import("./session-
|
|
2241
|
+
const { setVariable: setVariable2 } = await import("./session-MRU57VMJ.js");
|
|
2195
2242
|
setVariable2(session, outputVar, JSON.stringify(summary, null, 2), false);
|
|
2196
2243
|
}
|
|
2197
2244
|
}
|
|
@@ -2375,7 +2422,7 @@ async function executeForeach(session, element) {
|
|
|
2375
2422
|
const parser2 = new DiracParser2();
|
|
2376
2423
|
try {
|
|
2377
2424
|
const fromElement = parser2.parse(fromAttr);
|
|
2378
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2425
|
+
const { integrate: integrate2 } = await import("./interpreter-RV7UVTYE.js");
|
|
2379
2426
|
await integrate2(session, fromElement);
|
|
2380
2427
|
} catch (e) {
|
|
2381
2428
|
session.output = savedOutput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M43Y5X5P.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-IN55WRFB.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/llm-adapter.ts
|
|
14
14
|
function createLLMAdapter(session) {
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
BraKetParser
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AJSYOXXZ.js";
|
|
5
5
|
import {
|
|
6
6
|
execute
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-NK2ZTQGT.js";
|
|
8
|
+
import "./chunk-M43Y5X5P.js";
|
|
9
9
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-WX7VHQYL.js";
|
|
11
|
+
import "./chunk-IN55WRFB.js";
|
|
12
12
|
|
|
13
13
|
// src/cli.ts
|
|
14
14
|
import "dotenv/config";
|
|
@@ -16,7 +16,7 @@ import "dotenv/config";
|
|
|
16
16
|
// package.json
|
|
17
17
|
var package_default = {
|
|
18
18
|
name: "dirac-lang",
|
|
19
|
-
version: "0.1.
|
|
19
|
+
version: "0.1.56",
|
|
20
20
|
description: "LLM-Augmented Declarative Execution",
|
|
21
21
|
type: "module",
|
|
22
22
|
main: "dist/index.js",
|
|
@@ -96,7 +96,7 @@ async function main() {
|
|
|
96
96
|
process.exit(0);
|
|
97
97
|
}
|
|
98
98
|
if (args[0] === "shell") {
|
|
99
|
-
const { DiracShell } = await import("./shell-
|
|
99
|
+
const { DiracShell } = await import("./shell-WMXFN2EX.js");
|
|
100
100
|
const shellConfig = { debug: false };
|
|
101
101
|
for (let i = 1; i < args.length; i++) {
|
|
102
102
|
const arg = args[i];
|
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-NK2ZTQGT.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-M43Y5X5P.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-WX7VHQYL.js";
|
|
13
13
|
import {
|
|
14
14
|
createSession,
|
|
15
15
|
getAvailableSubroutines,
|
|
16
16
|
getOutput
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-IN55WRFB.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-M43Y5X5P.js";
|
|
5
5
|
import "./chunk-HRHAMPOB.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-WX7VHQYL.js";
|
|
7
|
+
import "./chunk-IN55WRFB.js";
|
|
8
8
|
export {
|
|
9
9
|
integrate,
|
|
10
10
|
integrateChildren
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
listScheduledTasks,
|
|
4
4
|
stopAllScheduledTasks,
|
|
5
5
|
stopScheduledTask
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-M43Y5X5P.js";
|
|
7
7
|
import "./chunk-HRHAMPOB.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-WX7VHQYL.js";
|
|
9
|
+
import "./chunk-IN55WRFB.js";
|
|
10
10
|
export {
|
|
11
11
|
executeSchedule,
|
|
12
12
|
listScheduledTasks,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
BraKetParser
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AJSYOXXZ.js";
|
|
5
5
|
import {
|
|
6
6
|
integrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-M43Y5X5P.js";
|
|
8
8
|
import {
|
|
9
9
|
DiracParser
|
|
10
10
|
} from "./chunk-HRHAMPOB.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-WX7VHQYL.js";
|
|
12
12
|
import {
|
|
13
13
|
createSession
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-IN55WRFB.js";
|
|
15
15
|
|
|
16
16
|
// src/shell.ts
|
|
17
17
|
import * as readline from "readline";
|
|
@@ -52,11 +52,23 @@ var DiracShell = class {
|
|
|
52
52
|
const attrPartial = attrMatch[2];
|
|
53
53
|
const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
|
|
54
54
|
if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
(name) => name.toLowerCase().startsWith(attrPartial.toLowerCase())
|
|
55
|
+
const matches = subroutine.parameters.filter(
|
|
56
|
+
(p) => p.name.toLowerCase().startsWith(attrPartial.toLowerCase())
|
|
58
57
|
);
|
|
59
|
-
|
|
58
|
+
if (matches.length > 1) {
|
|
59
|
+
console.log("\n");
|
|
60
|
+
matches.forEach((p) => {
|
|
61
|
+
const parts = [];
|
|
62
|
+
if (p.type) parts.push(p.type);
|
|
63
|
+
if (p.required) parts.push("required");
|
|
64
|
+
if (p.description) parts.push(p.description);
|
|
65
|
+
if (p.options && p.options.length > 0) parts.push(`[${p.options.join(",")}]`);
|
|
66
|
+
if (p.examples && p.examples.length > 0) parts.push(`eg:${p.examples[0]}`);
|
|
67
|
+
const info = parts.length > 0 ? ` (${parts.join(" | ")})` : "";
|
|
68
|
+
console.log(` ${p.name}=${info}`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const completions = matches.map((p) => `${p.name}=`);
|
|
60
72
|
return [completions, attrPartial];
|
|
61
73
|
}
|
|
62
74
|
}
|
|
@@ -65,11 +77,18 @@ var DiracShell = class {
|
|
|
65
77
|
const tagName = tagCompleteMatch[1];
|
|
66
78
|
const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
|
|
67
79
|
if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
80
|
+
console.log("\n");
|
|
81
|
+
subroutine.parameters.forEach((p) => {
|
|
82
|
+
const parts = [];
|
|
83
|
+
if (p.type) parts.push(p.type);
|
|
84
|
+
if (p.required) parts.push("required");
|
|
85
|
+
if (p.description) parts.push(p.description);
|
|
86
|
+
if (p.options && p.options.length > 0) parts.push(`[${p.options.join(",")}]`);
|
|
87
|
+
if (p.examples && p.examples.length > 0) parts.push(`eg:${p.examples[0]}`);
|
|
88
|
+
const info = parts.length > 0 ? ` (${parts.join(" | ")})` : "";
|
|
89
|
+
console.log(` ${p.name}=${info}`);
|
|
72
90
|
});
|
|
91
|
+
const paramSuggestions = subroutine.parameters.map((p) => `${p.name}=`);
|
|
73
92
|
return [paramSuggestions, ""];
|
|
74
93
|
}
|
|
75
94
|
const subroutineNames = this.session.subroutines.map((sub) => sub.name);
|
|
@@ -131,7 +150,7 @@ var DiracShell = class {
|
|
|
131
150
|
});
|
|
132
151
|
this.rl.on("close", () => {
|
|
133
152
|
this.saveHistory();
|
|
134
|
-
import("./schedule-
|
|
153
|
+
import("./schedule-2LAUKHZX.js").then(({ stopAllScheduledTasks }) => {
|
|
135
154
|
stopAllScheduledTasks();
|
|
136
155
|
console.log("\nGoodbye!");
|
|
137
156
|
process.exit(0);
|
|
@@ -452,7 +471,7 @@ Examples:
|
|
|
452
471
|
break;
|
|
453
472
|
case "tasks":
|
|
454
473
|
try {
|
|
455
|
-
const { listScheduledTasks } = await import("./schedule-
|
|
474
|
+
const { listScheduledTasks } = await import("./schedule-2LAUKHZX.js");
|
|
456
475
|
const tasks = listScheduledTasks();
|
|
457
476
|
if (tasks.length === 0) {
|
|
458
477
|
console.log("No scheduled tasks running.");
|
|
@@ -471,7 +490,7 @@ Examples:
|
|
|
471
490
|
console.log("Usage: :stop <task-name>");
|
|
472
491
|
} else {
|
|
473
492
|
try {
|
|
474
|
-
const { stopScheduledTask } = await import("./schedule-
|
|
493
|
+
const { stopScheduledTask } = await import("./schedule-2LAUKHZX.js");
|
|
475
494
|
const taskName = args[0];
|
|
476
495
|
const stopped = stopScheduledTask(taskName);
|
|
477
496
|
if (stopped) {
|
|
@@ -486,7 +505,7 @@ Examples:
|
|
|
486
505
|
break;
|
|
487
506
|
case "stopall":
|
|
488
507
|
try {
|
|
489
|
-
const { stopAllScheduledTasks } = await import("./schedule-
|
|
508
|
+
const { stopAllScheduledTasks } = await import("./schedule-2LAUKHZX.js");
|
|
490
509
|
stopAllScheduledTasks();
|
|
491
510
|
console.log("All scheduled tasks stopped.");
|
|
492
511
|
} catch (error) {
|
|
@@ -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-MRU57VMJ.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-M43Y5X5P.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-WX7VHQYL.js";
|
|
8
8
|
import {
|
|
9
9
|
createSession,
|
|
10
10
|
getOutput
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IN55WRFB.js";
|
|
12
12
|
|
|
13
13
|
// src/test-runner.ts
|
|
14
14
|
import fs from "fs";
|