dirac-lang 0.1.41 → 0.1.43
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-3DUTURSM.js → chunk-BN7IKYVP.js} +87 -13
- package/dist/{chunk-G2XVIAV5.js → chunk-G5UIFJ5I.js} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.js +2 -2
- package/dist/{interpreter-ZG23OYGG.js → interpreter-7N52YTBH.js} +1 -1
- package/dist/schedule-CROFBEVH.js +15 -0
- package/dist/{shell-Z7QXHZYV.js → shell-HPRM7WFE.js} +55 -3
- package/dist/test-runner.js +1 -1
- package/package.json +1 -1
|
@@ -405,7 +405,7 @@ async function executeLoop(session, element) {
|
|
|
405
405
|
const countAttr = element.attributes.count;
|
|
406
406
|
const varName = element.attributes.var || "i";
|
|
407
407
|
if (!countAttr) {
|
|
408
|
-
throw new Error("<loop> requires count attribute");
|
|
408
|
+
throw new Error("<loop> requires count attribute. For conditional loops, use <test-if> with <break>.");
|
|
409
409
|
}
|
|
410
410
|
const substitutedCount = substituteAttribute(session, countAttr);
|
|
411
411
|
const count = parseInt(substitutedCount, 10);
|
|
@@ -448,12 +448,12 @@ async function executeIf(session, element) {
|
|
|
448
448
|
const condition = await evaluatePredicate(session, conditionElement);
|
|
449
449
|
if (condition) {
|
|
450
450
|
if (thenElement) {
|
|
451
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
451
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
452
452
|
await integrateChildren2(session, thenElement);
|
|
453
453
|
}
|
|
454
454
|
} else {
|
|
455
455
|
if (elseElement) {
|
|
456
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
456
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
457
457
|
await integrateChildren2(session, elseElement);
|
|
458
458
|
}
|
|
459
459
|
}
|
|
@@ -466,7 +466,7 @@ async function evaluatePredicate(session, predicateElement) {
|
|
|
466
466
|
return await evaluateCondition(session, predicateElement);
|
|
467
467
|
}
|
|
468
468
|
const outputLengthBefore = session.output.length;
|
|
469
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
469
|
+
const { integrate: integrate2 } = await import("./interpreter-7N52YTBH.js");
|
|
470
470
|
await integrate2(session, predicateElement);
|
|
471
471
|
const newOutputChunks = session.output.slice(outputLengthBefore);
|
|
472
472
|
const result = newOutputChunks.join("").trim();
|
|
@@ -489,11 +489,11 @@ async function evaluateCondition(session, condElement) {
|
|
|
489
489
|
}
|
|
490
490
|
const outputLengthBefore = session.output.length;
|
|
491
491
|
const args = [];
|
|
492
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
492
|
+
const { integrate: integrate2 } = await import("./interpreter-7N52YTBH.js");
|
|
493
493
|
for (const child of condElement.children) {
|
|
494
494
|
if (child.tag.toLowerCase() === "arg") {
|
|
495
495
|
const argOutputStart = session.output.length;
|
|
496
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
496
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
497
497
|
await integrateChildren2(session, child);
|
|
498
498
|
const newChunks = session.output.slice(argOutputStart);
|
|
499
499
|
const argValue = newChunks.join("");
|
|
@@ -1154,6 +1154,10 @@ async function executeExpr(session, element) {
|
|
|
1154
1154
|
case "strcmp":
|
|
1155
1155
|
result = stringArgs.length >= 2 ? stringArgs[0] === stringArgs[1] : false;
|
|
1156
1156
|
break;
|
|
1157
|
+
case "contains":
|
|
1158
|
+
case "includes":
|
|
1159
|
+
result = stringArgs.length >= 2 ? stringArgs[0].includes(stringArgs[1]) : false;
|
|
1160
|
+
break;
|
|
1157
1161
|
default:
|
|
1158
1162
|
throw new Error(`<expr> unknown operation: ${op}`);
|
|
1159
1163
|
}
|
|
@@ -1378,7 +1382,7 @@ async function executeTagCheck(session, element) {
|
|
|
1378
1382
|
const executeTag = correctedTag || tagName;
|
|
1379
1383
|
console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
|
|
1380
1384
|
const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
|
|
1381
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1385
|
+
const { integrate: integrate2 } = await import("./interpreter-7N52YTBH.js");
|
|
1382
1386
|
await integrate2(session, elementToExecute);
|
|
1383
1387
|
}
|
|
1384
1388
|
}
|
|
@@ -1387,7 +1391,7 @@ async function executeTagCheck(session, element) {
|
|
|
1387
1391
|
// src/tags/throw.ts
|
|
1388
1392
|
async function executeThrow(session, element) {
|
|
1389
1393
|
const exceptionName = element.attributes?.name || "exception";
|
|
1390
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1394
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
1391
1395
|
const exceptionDom = {
|
|
1392
1396
|
tag: "exception-content",
|
|
1393
1397
|
attributes: { name: exceptionName },
|
|
@@ -1400,7 +1404,7 @@ async function executeThrow(session, element) {
|
|
|
1400
1404
|
// src/tags/try.ts
|
|
1401
1405
|
async function executeTry(session, element) {
|
|
1402
1406
|
setExceptionBoundary(session);
|
|
1403
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1407
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
1404
1408
|
await integrateChildren2(session, element);
|
|
1405
1409
|
unsetExceptionBoundary(session);
|
|
1406
1410
|
}
|
|
@@ -1410,7 +1414,7 @@ async function executeCatch(session, element) {
|
|
|
1410
1414
|
const exceptionName = element.attributes?.name || "exception";
|
|
1411
1415
|
const caughtCount = lookupException(session, exceptionName);
|
|
1412
1416
|
if (caughtCount > 0) {
|
|
1413
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1417
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
1414
1418
|
await integrateChildren2(session, element);
|
|
1415
1419
|
}
|
|
1416
1420
|
flushCurrentException(session);
|
|
@@ -1419,7 +1423,7 @@ async function executeCatch(session, element) {
|
|
|
1419
1423
|
// src/tags/exception.ts
|
|
1420
1424
|
async function executeException(session, element) {
|
|
1421
1425
|
const exceptions = getCurrentExceptions(session);
|
|
1422
|
-
const { integrateChildren: integrateChildren2 } = await import("./interpreter-
|
|
1426
|
+
const { integrateChildren: integrateChildren2 } = await import("./interpreter-7N52YTBH.js");
|
|
1423
1427
|
for (const exceptionDom of exceptions) {
|
|
1424
1428
|
await integrateChildren2(session, exceptionDom);
|
|
1425
1429
|
}
|
|
@@ -1882,7 +1886,7 @@ async function executeLoadContext(session, element) {
|
|
|
1882
1886
|
query = element.text.trim();
|
|
1883
1887
|
}
|
|
1884
1888
|
if (!query && element.children.length > 0) {
|
|
1885
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
1889
|
+
const { integrate: integrate2 } = await import("./interpreter-7N52YTBH.js");
|
|
1886
1890
|
const beforeOutput = session.output.length;
|
|
1887
1891
|
for (const child of element.children) {
|
|
1888
1892
|
await integrate2(session, child);
|
|
@@ -2121,7 +2125,7 @@ async function executeForeach(session, element) {
|
|
|
2121
2125
|
const parser2 = new DiracParser2();
|
|
2122
2126
|
try {
|
|
2123
2127
|
const fromElement = parser2.parse(fromAttr);
|
|
2124
|
-
const { integrate: integrate2 } = await import("./interpreter-
|
|
2128
|
+
const { integrate: integrate2 } = await import("./interpreter-7N52YTBH.js");
|
|
2125
2129
|
await integrate2(session, fromElement);
|
|
2126
2130
|
} catch (e) {
|
|
2127
2131
|
session.output = savedOutput;
|
|
@@ -2495,6 +2499,9 @@ async function integrate(session, element) {
|
|
|
2495
2499
|
case "input":
|
|
2496
2500
|
await executeInput(session, element);
|
|
2497
2501
|
break;
|
|
2502
|
+
case "schedule":
|
|
2503
|
+
await executeSchedule(session, element);
|
|
2504
|
+
break;
|
|
2498
2505
|
case "require_module":
|
|
2499
2506
|
await executeRequireModule(session, element);
|
|
2500
2507
|
break;
|
|
@@ -2527,7 +2534,74 @@ async function integrateChildren(session, element) {
|
|
|
2527
2534
|
}
|
|
2528
2535
|
}
|
|
2529
2536
|
|
|
2537
|
+
// src/tags/schedule.ts
|
|
2538
|
+
var scheduledTasks = /* @__PURE__ */ new Map();
|
|
2539
|
+
async function executeSchedule(session, element) {
|
|
2540
|
+
const intervalAttr = element.attributes.interval;
|
|
2541
|
+
const name = element.attributes.name || `task-${Date.now()}`;
|
|
2542
|
+
if (!intervalAttr) {
|
|
2543
|
+
throw new Error("<schedule> requires interval attribute (in seconds)");
|
|
2544
|
+
}
|
|
2545
|
+
const substitutedInterval = substituteAttribute(session, intervalAttr);
|
|
2546
|
+
const intervalSeconds = parseInt(substitutedInterval, 10);
|
|
2547
|
+
if (isNaN(intervalSeconds) || intervalSeconds <= 0) {
|
|
2548
|
+
throw new Error(`Invalid schedule interval: ${intervalAttr} (evaluated to: ${substitutedInterval})`);
|
|
2549
|
+
}
|
|
2550
|
+
const intervalMs = intervalSeconds * 1e3;
|
|
2551
|
+
if (scheduledTasks.has(name)) {
|
|
2552
|
+
const existing = scheduledTasks.get(name);
|
|
2553
|
+
clearInterval(existing.intervalId);
|
|
2554
|
+
console.log(`[schedule] Stopped existing task: ${name}`);
|
|
2555
|
+
}
|
|
2556
|
+
const taskElement = element;
|
|
2557
|
+
console.log(`[schedule] Starting task "${name}" (every ${intervalSeconds}s)`);
|
|
2558
|
+
executeTask(session, taskElement, name).catch((err) => {
|
|
2559
|
+
console.error(`[schedule] Error in task "${name}":`, err.message);
|
|
2560
|
+
});
|
|
2561
|
+
const intervalId = setInterval(() => {
|
|
2562
|
+
executeTask(session, taskElement, name).catch((err) => {
|
|
2563
|
+
console.error(`[schedule] Error in task "${name}":`, err.message);
|
|
2564
|
+
});
|
|
2565
|
+
}, intervalMs);
|
|
2566
|
+
scheduledTasks.set(name, {
|
|
2567
|
+
name,
|
|
2568
|
+
intervalId,
|
|
2569
|
+
interval: intervalSeconds
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
async function executeTask(session, element, name) {
|
|
2573
|
+
try {
|
|
2574
|
+
await integrateChildren(session, element);
|
|
2575
|
+
} catch (error) {
|
|
2576
|
+
console.error(`[schedule] Task "${name}" failed:`, error.message);
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
function stopScheduledTask(name) {
|
|
2580
|
+
const task = scheduledTasks.get(name);
|
|
2581
|
+
if (!task) {
|
|
2582
|
+
return false;
|
|
2583
|
+
}
|
|
2584
|
+
clearInterval(task.intervalId);
|
|
2585
|
+
scheduledTasks.delete(name);
|
|
2586
|
+
console.log(`[schedule] Stopped task: ${name}`);
|
|
2587
|
+
return true;
|
|
2588
|
+
}
|
|
2589
|
+
function stopAllScheduledTasks() {
|
|
2590
|
+
for (const [name, task] of scheduledTasks) {
|
|
2591
|
+
clearInterval(task.intervalId);
|
|
2592
|
+
console.log(`[schedule] Stopped task: ${name}`);
|
|
2593
|
+
}
|
|
2594
|
+
scheduledTasks.clear();
|
|
2595
|
+
}
|
|
2596
|
+
function listScheduledTasks() {
|
|
2597
|
+
return Array.from(scheduledTasks.values());
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2530
2600
|
export {
|
|
2601
|
+
executeSchedule,
|
|
2602
|
+
stopScheduledTask,
|
|
2603
|
+
stopAllScheduledTasks,
|
|
2604
|
+
listScheduledTasks,
|
|
2531
2605
|
integrate,
|
|
2532
2606
|
integrateChildren
|
|
2533
2607
|
};
|
package/dist/cli.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
} from "./chunk-UEFKQRYN.js";
|
|
5
5
|
import {
|
|
6
6
|
execute
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-G5UIFJ5I.js";
|
|
8
|
+
import "./chunk-BN7IKYVP.js";
|
|
9
9
|
import "./chunk-HRHAMPOB.js";
|
|
10
10
|
import "./chunk-4QLTSCDG.js";
|
|
11
11
|
import "./chunk-GLXVY235.js";
|
|
@@ -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.42",
|
|
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-HPRM7WFE.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,10 +2,10 @@ import {
|
|
|
2
2
|
createLLMAdapter,
|
|
3
3
|
execute,
|
|
4
4
|
executeUserCommand
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-G5UIFJ5I.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BN7IKYVP.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeSchedule,
|
|
3
|
+
listScheduledTasks,
|
|
4
|
+
stopAllScheduledTasks,
|
|
5
|
+
stopScheduledTask
|
|
6
|
+
} from "./chunk-BN7IKYVP.js";
|
|
7
|
+
import "./chunk-HRHAMPOB.js";
|
|
8
|
+
import "./chunk-4QLTSCDG.js";
|
|
9
|
+
import "./chunk-GLXVY235.js";
|
|
10
|
+
export {
|
|
11
|
+
executeSchedule,
|
|
12
|
+
listScheduledTasks,
|
|
13
|
+
stopAllScheduledTasks,
|
|
14
|
+
stopScheduledTask
|
|
15
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-UEFKQRYN.js";
|
|
5
5
|
import {
|
|
6
6
|
integrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BN7IKYVP.js";
|
|
8
8
|
import {
|
|
9
9
|
DiracParser
|
|
10
10
|
} from "./chunk-HRHAMPOB.js";
|
|
@@ -66,8 +66,14 @@ var DiracShell = class {
|
|
|
66
66
|
});
|
|
67
67
|
this.rl.on("close", () => {
|
|
68
68
|
this.saveHistory();
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
import("./schedule-CROFBEVH.js").then(({ stopAllScheduledTasks }) => {
|
|
70
|
+
stopAllScheduledTasks();
|
|
71
|
+
console.log("\nGoodbye!");
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}).catch(() => {
|
|
74
|
+
console.log("\nGoodbye!");
|
|
75
|
+
process.exit(0);
|
|
76
|
+
});
|
|
71
77
|
});
|
|
72
78
|
this.rl.on("SIGINT", () => {
|
|
73
79
|
if (this.inputBuffer.length > 0) {
|
|
@@ -191,6 +197,9 @@ Commands:
|
|
|
191
197
|
:load <query> Load context (search and import subroutines)
|
|
192
198
|
:save <name> <file> Save subroutine to file
|
|
193
199
|
:stats Show registry statistics
|
|
200
|
+
:tasks List all scheduled tasks
|
|
201
|
+
:stop <name> Stop a scheduled task
|
|
202
|
+
:stopall Stop all scheduled tasks
|
|
194
203
|
:exit Exit shell
|
|
195
204
|
|
|
196
205
|
Syntax:
|
|
@@ -355,6 +364,49 @@ Examples:
|
|
|
355
364
|
console.error("Error getting stats:", error instanceof Error ? error.message : String(error));
|
|
356
365
|
}
|
|
357
366
|
break;
|
|
367
|
+
case "tasks":
|
|
368
|
+
try {
|
|
369
|
+
const { listScheduledTasks } = await import("./schedule-CROFBEVH.js");
|
|
370
|
+
const tasks = listScheduledTasks();
|
|
371
|
+
if (tasks.length === 0) {
|
|
372
|
+
console.log("No scheduled tasks running.");
|
|
373
|
+
} else {
|
|
374
|
+
console.log("\nScheduled Tasks:");
|
|
375
|
+
for (const task of tasks) {
|
|
376
|
+
console.log(` - ${task.name}: every ${task.interval}s`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
} catch (error) {
|
|
380
|
+
console.error("Error listing tasks:", error instanceof Error ? error.message : String(error));
|
|
381
|
+
}
|
|
382
|
+
break;
|
|
383
|
+
case "stop":
|
|
384
|
+
if (args.length === 0) {
|
|
385
|
+
console.log("Usage: :stop <task-name>");
|
|
386
|
+
} else {
|
|
387
|
+
try {
|
|
388
|
+
const { stopScheduledTask } = await import("./schedule-CROFBEVH.js");
|
|
389
|
+
const taskName = args[0];
|
|
390
|
+
const stopped = stopScheduledTask(taskName);
|
|
391
|
+
if (stopped) {
|
|
392
|
+
console.log(`Stopped task: ${taskName}`);
|
|
393
|
+
} else {
|
|
394
|
+
console.log(`Task not found: ${taskName}`);
|
|
395
|
+
}
|
|
396
|
+
} catch (error) {
|
|
397
|
+
console.error("Error stopping task:", error instanceof Error ? error.message : String(error));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
case "stopall":
|
|
402
|
+
try {
|
|
403
|
+
const { stopAllScheduledTasks } = await import("./schedule-CROFBEVH.js");
|
|
404
|
+
stopAllScheduledTasks();
|
|
405
|
+
console.log("All scheduled tasks stopped.");
|
|
406
|
+
} catch (error) {
|
|
407
|
+
console.error("Error stopping tasks:", error instanceof Error ? error.message : String(error));
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
358
410
|
case "exit":
|
|
359
411
|
case "quit":
|
|
360
412
|
this.rl.close();
|
package/dist/test-runner.js
CHANGED