dirac-lang 0.1.97 → 0.1.99
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/{agent-MJSTQERB.js → agent-3SJF56JW.js} +5 -5
- package/dist/{chunk-4TBIVB4X.js → chunk-3VCKPUTQ.js} +143 -30
- package/dist/{chunk-SLGJRZ3P.js → chunk-53QJQ2CC.js} +1 -1
- package/dist/{chunk-ECAW4X46.js → chunk-EAM7IZWA.js} +1 -1
- package/dist/{chunk-CDTZNFCJ.js → chunk-EE3YBMAD.js} +2 -2
- package/dist/{chunk-KFMG6CZW.js → chunk-R6R6OHPA.js} +2 -2
- package/dist/{chunk-PPH7KYKH.js → chunk-ZYSWVMID.js} +6 -0
- package/dist/cli.js +12 -12
- package/dist/{cron-2J3SEPZW.js → cron-TTPFON3Y.js} +4 -4
- package/dist/index.js +5 -5
- package/dist/interpreter-ENHZAIWT.js +12 -0
- package/dist/{run-at-MHURF5PL.js → run-at-A3CJX4TR.js} +4 -4
- package/dist/{schedule-KMBLI46W.js → schedule-OYEKDXZV.js} +4 -4
- package/dist/scope-validator-TVQIOEAI.js +171 -0
- package/dist/{session-IH5LO7FS.js → session-6WX5O74B.js} +3 -1
- package/dist/{session-server-TQPJVLA4.js → session-server-LMDDND5E.js} +5 -5
- package/dist/{shell-CY5XIPQC.js → shell-PV6KIJL5.js} +156 -15
- package/dist/{subroutine-7JJKHTV4.js → subroutine-O3YGYHRZ.js} +2 -2
- package/dist/{subroutine-index-RVJSWWJ7.js → subroutine-index-GB3OSH56.js} +2 -2
- package/dist/subroutine-serializer-LNFHABUC.js +160 -0
- package/dist/{tag-validator-REN6XLMT.js → tag-validator-QS7T4GFE.js} +110 -19
- package/dist/test-runner.js +4 -4
- package/lib/native-tags.di +2 -1
- package/package.json +1 -1
- package/dist/interpreter-4CIWAOBY.js +0 -12
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
SessionServer,
|
|
3
3
|
getSocketPath,
|
|
4
4
|
isSessionRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-SLGJRZ3P.js";
|
|
5
|
+
} from "./chunk-R6R6OHPA.js";
|
|
6
|
+
import "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
9
8
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
|
|
12
12
|
// src/agent.ts
|
|
13
13
|
import fs from "fs";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
executeSubroutine
|
|
3
|
-
} from "./chunk-ECAW4X46.js";
|
|
4
1
|
import {
|
|
5
2
|
executeIndexSubroutines,
|
|
6
3
|
executeRegistryStats,
|
|
7
4
|
executeSearchSubroutines,
|
|
8
5
|
registry
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-53QJQ2CC.js";
|
|
10
7
|
import {
|
|
11
8
|
DiracParser
|
|
12
9
|
} from "./chunk-HRHAMPOB.js";
|
|
10
|
+
import {
|
|
11
|
+
executeSubroutine
|
|
12
|
+
} from "./chunk-EAM7IZWA.js";
|
|
13
13
|
import {
|
|
14
14
|
CustomLLMProvider,
|
|
15
15
|
OllamaProvider,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
substituteVariables,
|
|
35
35
|
throwException,
|
|
36
36
|
unsetExceptionBoundary
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ZYSWVMID.js";
|
|
38
38
|
|
|
39
39
|
// src/tags/parameters.ts
|
|
40
40
|
async function executeParameters(session, element) {
|
|
@@ -297,7 +297,7 @@ async function executeCall(session, element) {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
async function registerExtendChain(session, subroutine, currentName) {
|
|
300
|
-
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-
|
|
300
|
+
const { executeSubroutine: executeSubroutine2 } = await import("./subroutine-O3YGYHRZ.js");
|
|
301
301
|
const extendsAttr = subroutine.attributes.extends;
|
|
302
302
|
let parentName;
|
|
303
303
|
if (extendsAttr) {
|
|
@@ -487,12 +487,12 @@ async function executeIf(session, element) {
|
|
|
487
487
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
488
488
|
if (condition) {
|
|
489
489
|
if (thenElement) {
|
|
490
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
490
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
491
491
|
await integrateChildren2(session, thenElement);
|
|
492
492
|
}
|
|
493
493
|
} else {
|
|
494
494
|
if (elseElement) {
|
|
495
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
495
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
496
496
|
await integrateChildren2(session, elseElement);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
@@ -505,7 +505,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
505
505
|
return await evaluateCondition(session, predicateElement);
|
|
506
506
|
}
|
|
507
507
|
const outputLengthBefore = session.output.length;
|
|
508
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
508
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
509
509
|
await integrate2(session, predicateElement);
|
|
510
510
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
511
511
|
const result = newOutputChunks.join("").trim();
|
|
@@ -528,11 +528,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
528
528
|
}
|
|
529
529
|
const outputLengthBefore = session.output.length;
|
|
530
530
|
const args = [];
|
|
531
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
531
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
532
532
|
for (const child of condElement.children) {
|
|
533
533
|
if (child.tag.toLowerCase() === "arg") {
|
|
534
534
|
const argOutputStart = session.output.length;
|
|
535
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
535
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
536
536
|
await integrateChildren2(session, child);
|
|
537
537
|
const newChunks = session.output.slice(argOutputStart);
|
|
538
538
|
const argValue = newChunks.join("");
|
|
@@ -852,7 +852,7 @@ async function executeLLM(session, element) {
|
|
|
852
852
|
let systemPrompt = "";
|
|
853
853
|
let currentUserPrompt = userPrompt;
|
|
854
854
|
if (!noExtra) {
|
|
855
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
855
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-6WX5O74B.js");
|
|
856
856
|
const allSubroutines = getAvailableSubroutines2(session);
|
|
857
857
|
if (session.debug) {
|
|
858
858
|
console.error(`[LLM] Total subroutines from session: ${allSubroutines.length}`);
|
|
@@ -1075,6 +1075,7 @@ ${result}
|
|
|
1075
1075
|
console.error(`[LLM] Feedback iteration ${iteration}/${maxIterations}`);
|
|
1076
1076
|
}
|
|
1077
1077
|
let correctionMessages = [];
|
|
1078
|
+
let hasTagCorrections = false;
|
|
1078
1079
|
let diracCode = result.trim();
|
|
1079
1080
|
if (replaceTick && diracCode.startsWith("```")) {
|
|
1080
1081
|
const match = diracCode.match(/^```(\w+)?\n?/m);
|
|
@@ -1086,16 +1087,20 @@ ${result}
|
|
|
1086
1087
|
diracCode = diracCode.replace(/^```(?:xml|html|dirac)?\n?/m, "").replace(/\n?```$/m, "").trim();
|
|
1087
1088
|
}
|
|
1088
1089
|
}
|
|
1089
|
-
const outputBefore =
|
|
1090
|
+
const outputBefore = session.output.length;
|
|
1090
1091
|
try {
|
|
1092
|
+
console.error(`[LLM] Iteration ${iteration}: Parsing LLM response`);
|
|
1091
1093
|
const parser = new DiracParser();
|
|
1092
1094
|
let dynamicAST = parser.parse(diracCode);
|
|
1095
|
+
console.error(`[LLM] Iteration ${iteration}: Parse successful`);
|
|
1093
1096
|
if (validateTags) {
|
|
1097
|
+
console.error(`[LLM] Iteration ${iteration}: Starting validation (autocorrect: ${autocorrect}, deepValidation: true)`);
|
|
1094
1098
|
if (session.debug) {
|
|
1095
1099
|
console.error(`[LLM] Validation enabled, autocorrect: ${autocorrect}`);
|
|
1096
1100
|
}
|
|
1097
|
-
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-
|
|
1101
|
+
const { validateDiracCode, applyCorrectedTags } = await import("./tag-validator-QS7T4GFE.js");
|
|
1098
1102
|
let validation = await validateDiracCode(session, dynamicAST, { autocorrect, deepValidation: true });
|
|
1103
|
+
console.error(`[LLM] Iteration ${iteration}: Validation complete - valid: ${validation.valid}, errors: ${validation.errorMessages.length}`);
|
|
1099
1104
|
if (session.debug) {
|
|
1100
1105
|
console.error(`[LLM] Validation result: valid=${validation.valid}, results count=${validation.results.length}`);
|
|
1101
1106
|
if (validation.results.length > 0) {
|
|
@@ -1112,10 +1117,15 @@ ${result}
|
|
|
1112
1117
|
console.error(`[LLM] Applying corrections from initial ${validation.results.length} validation results`);
|
|
1113
1118
|
for (const result2 of validation.results) {
|
|
1114
1119
|
if (result2.corrected) {
|
|
1120
|
+
hasTagCorrections = true;
|
|
1115
1121
|
correctionMessages.push(`Auto-corrected: <${result2.originalTag}> \u2192 <${result2.tagName}> (similarity: ${result2.similarity?.toFixed(2)})`);
|
|
1116
1122
|
}
|
|
1117
1123
|
if (result2.warnings.length > 0) {
|
|
1118
|
-
|
|
1124
|
+
const nonScopeWarnings = result2.warnings.filter((w) => !w.startsWith("Scope:"));
|
|
1125
|
+
if (nonScopeWarnings.length > 0) {
|
|
1126
|
+
hasTagCorrections = true;
|
|
1127
|
+
correctionMessages.push(...nonScopeWarnings);
|
|
1128
|
+
}
|
|
1119
1129
|
}
|
|
1120
1130
|
}
|
|
1121
1131
|
console.error("[LLM] Initial correction messages collected:", correctionMessages.length);
|
|
@@ -1128,8 +1138,10 @@ ${result}
|
|
|
1128
1138
|
console.error(`[LLM] Re-validation after corrections: valid=${validation.valid}`);
|
|
1129
1139
|
}
|
|
1130
1140
|
let retryCount = 0;
|
|
1141
|
+
console.error(`[LLM] Iteration ${iteration}: Entering retry loop (validation.valid: ${validation.valid}, maxRetries: ${maxRetries})`);
|
|
1131
1142
|
while (!validation.valid && retryCount < maxRetries) {
|
|
1132
1143
|
retryCount++;
|
|
1144
|
+
console.error(`[LLM] Iteration ${iteration}: Retry ${retryCount}/${maxRetries} - validation failed with errors:`, validation.errorMessages);
|
|
1133
1145
|
if (session.debug) {
|
|
1134
1146
|
console.error(`[LLM] Validation failed (attempt ${retryCount}/${maxRetries}):`, validation.errorMessages);
|
|
1135
1147
|
}
|
|
@@ -1191,10 +1203,13 @@ ${result}
|
|
|
1191
1203
|
validation = await validateDiracCode(session, dynamicAST, { autocorrect, deepValidation: true });
|
|
1192
1204
|
}
|
|
1193
1205
|
if (!validation.valid) {
|
|
1206
|
+
console.error(`[LLM] Iteration ${iteration}: VALIDATION FAILED after ${maxRetries} retries. Throwing error.`);
|
|
1194
1207
|
throw new Error(`Tag validation failed after ${maxRetries} retries:
|
|
1195
1208
|
${validation.errorMessages.join("\n")}`);
|
|
1196
1209
|
}
|
|
1197
|
-
|
|
1210
|
+
console.error(`[LLM] Iteration ${iteration}: Validation passed, checking for corrections (hasTagCorrections: ${hasTagCorrections}, correctionMessages: ${correctionMessages.length})`);
|
|
1211
|
+
if (hasTagCorrections && correctionMessages.length > 0 && feedbackMode) {
|
|
1212
|
+
console.error(`[LLM] Iteration ${iteration}: Has tag corrections, preparing feedback (confirmCorrections: ${confirmCorrections})`);
|
|
1198
1213
|
const correctedCodeLines = [];
|
|
1199
1214
|
for (const child of dynamicAST.children) {
|
|
1200
1215
|
if (child.tag && child.tag !== "DIRAC-ROOT") {
|
|
@@ -1272,11 +1287,18 @@ ${correctedCode}
|
|
|
1272
1287
|
}
|
|
1273
1288
|
}
|
|
1274
1289
|
}
|
|
1290
|
+
console.error(`[LLM] Iteration ${iteration}: About to execute code`);
|
|
1275
1291
|
let executionError = null;
|
|
1276
1292
|
try {
|
|
1293
|
+
console.error(`[LLM] Iteration ${iteration}: Calling integrate()`);
|
|
1277
1294
|
await integrate(session, dynamicAST);
|
|
1295
|
+
console.error(`[LLM] Iteration ${iteration}: integrate() completed successfully`);
|
|
1296
|
+
if (session.output.length === outputBefore) {
|
|
1297
|
+
setVariable(session, "__llm_silent_execution__", result, false);
|
|
1298
|
+
}
|
|
1278
1299
|
} catch (execError) {
|
|
1279
1300
|
executionError = execError instanceof Error ? execError.message : String(execError);
|
|
1301
|
+
console.error(`[LLM] Iteration ${iteration}: EXECUTION ERROR: ${executionError}`);
|
|
1280
1302
|
console.error(`[LLM] Execution error: ${executionError}`);
|
|
1281
1303
|
if (feedbackMode && iteration < maxIterations) {
|
|
1282
1304
|
const errorFeedback = `System: Your code executed but encountered a runtime error:
|
|
@@ -1289,6 +1311,38 @@ Please fix the error and try again.`;
|
|
|
1289
1311
|
} else if (saveDialog) {
|
|
1290
1312
|
setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
|
|
1291
1313
|
}
|
|
1314
|
+
if (isOpenAI) {
|
|
1315
|
+
const response = await llmClient.chat.completions.create({
|
|
1316
|
+
model,
|
|
1317
|
+
max_tokens: maxTokens,
|
|
1318
|
+
temperature,
|
|
1319
|
+
messages: dialogHistory
|
|
1320
|
+
});
|
|
1321
|
+
result = response.choices[0]?.message?.content || "";
|
|
1322
|
+
} else if (isOllama) {
|
|
1323
|
+
const ollamaPrompt = dialogHistory.map((m) => `${m.role.charAt(0).toUpperCase() + m.role.slice(1)}: ${m.content}`).join("\n");
|
|
1324
|
+
result = await llmClient.complete(ollamaPrompt, {
|
|
1325
|
+
model,
|
|
1326
|
+
temperature,
|
|
1327
|
+
max_tokens: maxTokens
|
|
1328
|
+
});
|
|
1329
|
+
} else if (isCustom) {
|
|
1330
|
+
const customPrompt = dialogHistory.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
1331
|
+
result = await llmClient.complete(customPrompt, {
|
|
1332
|
+
model,
|
|
1333
|
+
temperature,
|
|
1334
|
+
max_tokens: maxTokens,
|
|
1335
|
+
messages: dialogHistory
|
|
1336
|
+
});
|
|
1337
|
+
} else {
|
|
1338
|
+
result = await callAnthropic(llmClient, model, maxTokens, temperature, dialogHistory);
|
|
1339
|
+
}
|
|
1340
|
+
dialogHistory.push({ role: "assistant", content: result });
|
|
1341
|
+
if (contextVar) {
|
|
1342
|
+
setVariable(session, contextVar, JSON.stringify(dialogHistory), true);
|
|
1343
|
+
} else if (saveDialog) {
|
|
1344
|
+
setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
|
|
1345
|
+
}
|
|
1292
1346
|
continue;
|
|
1293
1347
|
} else {
|
|
1294
1348
|
throw execError;
|
|
@@ -1321,7 +1375,7 @@ Please fix the error and try again.`;
|
|
|
1321
1375
|
}
|
|
1322
1376
|
if (feedbackMode) {
|
|
1323
1377
|
const outputAfter = session.output.slice();
|
|
1324
|
-
const executionOutput = outputAfter.slice(outputBefore
|
|
1378
|
+
const executionOutput = outputAfter.slice(outputBefore).join("");
|
|
1325
1379
|
if (executionOutput) {
|
|
1326
1380
|
process.stdout.write(executionOutput);
|
|
1327
1381
|
}
|
|
@@ -1391,13 +1445,72 @@ ${result}
|
|
|
1391
1445
|
break;
|
|
1392
1446
|
}
|
|
1393
1447
|
} catch (parseError) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1448
|
+
console.error(`[LLM] Iteration ${iteration}: ERROR CAUGHT: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
|
|
1449
|
+
const errorMsg = parseError instanceof Error ? parseError.message : String(parseError);
|
|
1450
|
+
const isValidationError = errorMsg.includes("Tag validation failed") || errorMsg.includes("Attribute") || errorMsg.includes("contains <variable> tag");
|
|
1451
|
+
if (isValidationError && feedbackMode && iteration < maxIterations) {
|
|
1452
|
+
console.error(`[LLM] Iteration ${iteration}: VALIDATION ERROR - sending to LLM for correction`);
|
|
1453
|
+
const errorFeedback = `System: Your code had validation errors:
|
|
1454
|
+
${errorMsg}
|
|
1455
|
+
|
|
1456
|
+
Please fix these errors and generate valid Dirac XML code. Remember:
|
|
1457
|
+
- Use \${varname} syntax in attributes instead of <variable name="..." /> tags
|
|
1458
|
+
- Only use allowed tags and attributes`;
|
|
1459
|
+
dialogHistory.push({ role: "user", content: errorFeedback });
|
|
1460
|
+
if (contextVar) {
|
|
1461
|
+
setVariable(session, contextVar, JSON.stringify(dialogHistory), true);
|
|
1462
|
+
} else if (saveDialog) {
|
|
1463
|
+
setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
|
|
1464
|
+
}
|
|
1465
|
+
if (isOpenAI) {
|
|
1466
|
+
const response = await llmClient.chat.completions.create({
|
|
1467
|
+
model,
|
|
1468
|
+
max_tokens: maxTokens,
|
|
1469
|
+
temperature,
|
|
1470
|
+
messages: dialogHistory
|
|
1471
|
+
});
|
|
1472
|
+
result = response.choices[0]?.message?.content || "";
|
|
1473
|
+
} else if (isOllama) {
|
|
1474
|
+
const ollamaPrompt = dialogHistory.map((m) => `${m.role.charAt(0).toUpperCase() + m.role.slice(1)}: ${m.content}`).join("\n");
|
|
1475
|
+
result = await llmClient.complete(ollamaPrompt, {
|
|
1476
|
+
model,
|
|
1477
|
+
temperature,
|
|
1478
|
+
max_tokens: maxTokens
|
|
1479
|
+
});
|
|
1480
|
+
} else if (isCustom) {
|
|
1481
|
+
const customPrompt = dialogHistory.map((m) => `${m.role}: ${m.content}`).join("\n");
|
|
1482
|
+
result = await llmClient.complete(customPrompt, {
|
|
1483
|
+
model,
|
|
1484
|
+
temperature,
|
|
1485
|
+
max_tokens: maxTokens,
|
|
1486
|
+
messages: dialogHistory
|
|
1487
|
+
});
|
|
1488
|
+
} else {
|
|
1489
|
+
result = await callAnthropic(llmClient, model, maxTokens, temperature, dialogHistory);
|
|
1490
|
+
}
|
|
1491
|
+
dialogHistory.push({ role: "assistant", content: result });
|
|
1492
|
+
if (contextVar) {
|
|
1493
|
+
setVariable(session, contextVar, JSON.stringify(dialogHistory), true);
|
|
1494
|
+
} else if (saveDialog) {
|
|
1495
|
+
setVariable(session, "__llm_dialog__", JSON.stringify(dialogHistory), true);
|
|
1496
|
+
}
|
|
1497
|
+
if (session.debug) {
|
|
1498
|
+
console.error(`[LLM] LLM correction response:
|
|
1499
|
+
${result}
|
|
1500
|
+
`);
|
|
1501
|
+
}
|
|
1502
|
+
continue;
|
|
1503
|
+
} else {
|
|
1504
|
+
console.error(`[LLM] Iteration ${iteration}: PARSE ERROR (or no feedback): ${errorMsg}`);
|
|
1505
|
+
if (session.debug) {
|
|
1506
|
+
console.error(`[LLM] Failed to parse as Dirac, treating as text: ${parseError}`);
|
|
1507
|
+
}
|
|
1508
|
+
emit(session, result);
|
|
1509
|
+
break;
|
|
1396
1510
|
}
|
|
1397
|
-
emit(session, result);
|
|
1398
|
-
break;
|
|
1399
1511
|
}
|
|
1400
1512
|
}
|
|
1513
|
+
console.error(`[LLM] Exited feedback loop after ${iteration} iterations`);
|
|
1401
1514
|
} else {
|
|
1402
1515
|
emit(session, result);
|
|
1403
1516
|
}
|
|
@@ -1855,7 +1968,7 @@ async function getBestTagMatch(candidate, allowed) {
|
|
|
1855
1968
|
return { tag: allowed[bestIdx], score: bestScore };
|
|
1856
1969
|
}
|
|
1857
1970
|
async function executeTagCheck(session, element) {
|
|
1858
|
-
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-
|
|
1971
|
+
const { getAvailableSubroutines: getAvailableSubroutines2 } = await import("./session-6WX5O74B.js");
|
|
1859
1972
|
const subroutines = getAvailableSubroutines2(session);
|
|
1860
1973
|
const allowed = new Set(subroutines.map((s) => s.name));
|
|
1861
1974
|
console.error("[tag-check] Allowed subroutines:", Array.from(allowed));
|
|
@@ -1948,7 +2061,7 @@ async function executeTagCheck(session, element) {
|
|
|
1948
2061
|
const executeTag = correctedTag || tagName;
|
|
1949
2062
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1950
2063
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1951
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2064
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
1952
2065
|
await integrate2(session, elementToExecute);
|
|
1953
2066
|
}
|
|
1954
2067
|
}
|
|
@@ -1957,7 +2070,7 @@ async function executeTagCheck(session, element) {
|
|
|
1957
2070
|
// src/tags/throw.ts
|
|
1958
2071
|
async function executeThrow(session, element) {
|
|
1959
2072
|
const exceptionName = element.attributes?.name || "exception";
|
|
1960
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2073
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
1961
2074
|
const exceptionDom = {
|
|
1962
2075
|
tag: "exception-content",
|
|
1963
2076
|
attributes: { name: exceptionName },
|
|
@@ -1970,7 +2083,7 @@ async function executeThrow(session, element) {
|
|
|
1970
2083
|
// src/tags/try.ts
|
|
1971
2084
|
async function executeTry(session, element) {
|
|
1972
2085
|
setExceptionBoundary(session);
|
|
1973
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2086
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
1974
2087
|
await integrateChildren2(session, element);
|
|
1975
2088
|
unsetExceptionBoundary(session);
|
|
1976
2089
|
}
|
|
@@ -1980,7 +2093,7 @@ async function executeCatch(session, element) {
|
|
|
1980
2093
|
const exceptionName = element.attributes?.name || "exception";
|
|
1981
2094
|
const caughtCount = lookupException(session, exceptionName);
|
|
1982
2095
|
if (caughtCount > 0) {
|
|
1983
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2096
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
1984
2097
|
await integrateChildren2(session, element);
|
|
1985
2098
|
}
|
|
1986
2099
|
flushCurrentException(session);
|
|
@@ -1989,7 +2102,7 @@ async function executeCatch(session, element) {
|
|
|
1989
2102
|
// src/tags/exception.ts
|
|
1990
2103
|
async function executeException(session, element) {
|
|
1991
2104
|
const exceptions = getCurrentExceptions(session);
|
|
1992
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
2105
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-ENHZAIWT.js");
|
|
1993
2106
|
for (const exceptionDom of exceptions) {
|
|
1994
2107
|
await integrateChildren2(session, exceptionDom);
|
|
1995
2108
|
}
|
|
@@ -2190,7 +2303,7 @@ async function executeLoadContext(session, element) {
|
|
|
2190
2303
|
query = element.text.trim();
|
|
2191
2304
|
}
|
|
2192
2305
|
if (!query && element.children.length > 0) {
|
|
2193
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2306
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
2194
2307
|
const beforeOutput = session.output.length;
|
|
2195
2308
|
for (const child of element.children) {
|
|
2196
2309
|
await integrate2(session, child);
|
|
@@ -2259,7 +2372,7 @@ async function executeLoadContext(session, element) {
|
|
|
2259
2372
|
parameters: s.parameters.map((p) => p.name),
|
|
2260
2373
|
filePath: s.filePath
|
|
2261
2374
|
}));
|
|
2262
|
-
const { setVariable: setVariable2 } = await import("./session-
|
|
2375
|
+
const { setVariable: setVariable2 } = await import("./session-6WX5O74B.js");
|
|
2263
2376
|
setVariable2(session, outputVar, JSON.stringify(summary, null, 2), false);
|
|
2264
2377
|
}
|
|
2265
2378
|
}
|
|
@@ -3034,7 +3147,7 @@ async function executeForeach(session, element) {
|
|
|
3034
3147
|
const parser2 = new DiracParser2();
|
|
3035
3148
|
try {
|
|
3036
3149
|
const fromElement = parser2.parse(fromAttr);
|
|
3037
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
3150
|
+
const { integrate: integrate2 } = await import("./interpreter-ENHZAIWT.js");
|
|
3038
3151
|
await integrate2(session, fromElement);
|
|
3039
3152
|
} catch (e) {
|
|
3040
3153
|
session.output = savedOutput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3VCKPUTQ.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-ZYSWVMID.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/llm-adapter.ts
|
|
14
14
|
function createLLMAdapter(session) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
integrate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
4
4
|
import {
|
|
5
5
|
DiracParser
|
|
6
6
|
} from "./chunk-HRHAMPOB.js";
|
|
7
7
|
import {
|
|
8
8
|
createSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZYSWVMID.js";
|
|
10
10
|
|
|
11
11
|
// src/session-server.ts
|
|
12
12
|
import net from "net";
|
|
@@ -260,6 +260,11 @@ function cleanSubroutinesToBoundary(session, callerSubroutine) {
|
|
|
260
260
|
session.subroutines = session.subroutines.slice(0, session.subBoundary);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
+
function removeSubroutine(session, name) {
|
|
264
|
+
const initialLength = session.subroutines.length;
|
|
265
|
+
session.subroutines = session.subroutines.filter((s) => s.name !== name);
|
|
266
|
+
return session.subroutines.length < initialLength;
|
|
267
|
+
}
|
|
263
268
|
function substituteVariables(session, text) {
|
|
264
269
|
return text.replace(/ /g, "\n").replace(/ /g, "\r").replace(/	/g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
265
270
|
}
|
|
@@ -351,6 +356,7 @@ export {
|
|
|
351
356
|
setSubroutineBoundary,
|
|
352
357
|
popSubroutinesToBoundary,
|
|
353
358
|
cleanSubroutinesToBoundary,
|
|
359
|
+
removeSubroutine,
|
|
354
360
|
substituteVariables,
|
|
355
361
|
emit,
|
|
356
362
|
getOutput,
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
execute
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EE3YBMAD.js";
|
|
5
5
|
import {
|
|
6
6
|
BraKetParser
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-SLGJRZ3P.js";
|
|
7
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
8
|
+
import "./chunk-53QJQ2CC.js";
|
|
10
9
|
import "./chunk-HRHAMPOB.js";
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-EAM7IZWA.js";
|
|
11
|
+
import "./chunk-ZYSWVMID.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.98",
|
|
20
20
|
description: "LLM-Augmented Declarative Execution",
|
|
21
21
|
type: "module",
|
|
22
22
|
main: "dist/index.js",
|
|
@@ -150,7 +150,7 @@ async function main() {
|
|
|
150
150
|
const args = process.argv.slice(2);
|
|
151
151
|
const calledAs = process.argv[1];
|
|
152
152
|
if (calledAs && calledAs.endsWith("/dish")) {
|
|
153
|
-
const { DiracShell } = await import("./shell-
|
|
153
|
+
const { DiracShell } = await import("./shell-PV6KIJL5.js");
|
|
154
154
|
const shellConfig = loadShellConfig(args);
|
|
155
155
|
const shell = new DiracShell(shellConfig);
|
|
156
156
|
await shell.start();
|
|
@@ -199,11 +199,11 @@ async function main() {
|
|
|
199
199
|
if (args[0] === "agent") {
|
|
200
200
|
const subcommand = args[1];
|
|
201
201
|
if (subcommand === "daemon") {
|
|
202
|
-
const { runAgentDaemon } = await import("./agent-
|
|
202
|
+
const { runAgentDaemon } = await import("./agent-3SJF56JW.js");
|
|
203
203
|
await runAgentDaemon();
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const { AgentCLI } = await import("./agent-
|
|
206
|
+
const { AgentCLI } = await import("./agent-3SJF56JW.js");
|
|
207
207
|
const agent = new AgentCLI();
|
|
208
208
|
switch (subcommand) {
|
|
209
209
|
case "start":
|
|
@@ -230,8 +230,8 @@ async function main() {
|
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
if (args[0] === "shell") {
|
|
233
|
-
const { DiracShell } = await import("./shell-
|
|
234
|
-
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-
|
|
233
|
+
const { DiracShell } = await import("./shell-PV6KIJL5.js");
|
|
234
|
+
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-LMDDND5E.js");
|
|
235
235
|
const { SessionClient } = await import("./session-client-3VTC5MLO.js");
|
|
236
236
|
const daemonMode = args.includes("--daemon") || args.includes("-d");
|
|
237
237
|
const agentMode = args.includes("--agent") || args.includes("-a");
|
|
@@ -277,7 +277,7 @@ async function main() {
|
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
if (args[0] === "daemon") {
|
|
280
|
-
const { SessionServer } = await import("./session-server-
|
|
280
|
+
const { SessionServer } = await import("./session-server-LMDDND5E.js");
|
|
281
281
|
const server = new SessionServer();
|
|
282
282
|
await server.start();
|
|
283
283
|
console.log("Session daemon started");
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
listCronJobs,
|
|
4
4
|
stopAllCronJobs,
|
|
5
5
|
stopCronJob
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-SLGJRZ3P.js";
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
9
8
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
executeCron,
|
|
13
13
|
listCronJobs,
|
package/dist/index.js
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
createLLMAdapter,
|
|
3
3
|
execute,
|
|
4
4
|
executeUserCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EE3YBMAD.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-SLGJRZ3P.js";
|
|
8
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
9
|
+
import "./chunk-53QJQ2CC.js";
|
|
11
10
|
import {
|
|
12
11
|
DiracParser
|
|
13
12
|
} from "./chunk-HRHAMPOB.js";
|
|
13
|
+
import "./chunk-EAM7IZWA.js";
|
|
14
14
|
import {
|
|
15
15
|
createSession,
|
|
16
16
|
getAvailableSubroutines,
|
|
17
17
|
getOutput
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ZYSWVMID.js";
|
|
19
19
|
export {
|
|
20
20
|
DiracParser,
|
|
21
21
|
createLLMAdapter,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
cancelScheduledRun,
|
|
4
4
|
executeRunAt,
|
|
5
5
|
listScheduledRuns
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-SLGJRZ3P.js";
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
9
8
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
cancelAllScheduledRuns,
|
|
13
13
|
cancelScheduledRun,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
listScheduledTasks,
|
|
4
4
|
stopAllScheduledTasks,
|
|
5
5
|
stopScheduledTask
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-SLGJRZ3P.js";
|
|
6
|
+
} from "./chunk-3VCKPUTQ.js";
|
|
7
|
+
import "./chunk-53QJQ2CC.js";
|
|
9
8
|
import "./chunk-HRHAMPOB.js";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-EAM7IZWA.js";
|
|
10
|
+
import "./chunk-ZYSWVMID.js";
|
|
11
11
|
export {
|
|
12
12
|
executeSchedule,
|
|
13
13
|
listScheduledTasks,
|