dirac-lang 0.1.41 → 0.1.42

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.
@@ -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-ZG23OYGG.js");
451
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
452
452
  await integrateChildren2(session, thenElement);
453
453
  }
454
454
  } else {
455
455
  if (elseElement) {
456
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-ZG23OYGG.js");
456
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.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-ZG23OYGG.js");
469
+ const { integrate: integrate2 } = await import("./interpreter-U74XE6FV.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-ZG23OYGG.js");
492
+ const { integrate: integrate2 } = await import("./interpreter-U74XE6FV.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-ZG23OYGG.js");
496
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
497
497
  await integrateChildren2(session, child);
498
498
  const newChunks = session.output.slice(argOutputStart);
499
499
  const argValue = newChunks.join("");
@@ -1378,7 +1378,7 @@ async function executeTagCheck(session, element) {
1378
1378
  const executeTag = correctedTag || tagName;
1379
1379
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1380
1380
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1381
- const { integrate: integrate2 } = await import("./interpreter-ZG23OYGG.js");
1381
+ const { integrate: integrate2 } = await import("./interpreter-U74XE6FV.js");
1382
1382
  await integrate2(session, elementToExecute);
1383
1383
  }
1384
1384
  }
@@ -1387,7 +1387,7 @@ async function executeTagCheck(session, element) {
1387
1387
  // src/tags/throw.ts
1388
1388
  async function executeThrow(session, element) {
1389
1389
  const exceptionName = element.attributes?.name || "exception";
1390
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-ZG23OYGG.js");
1390
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
1391
1391
  const exceptionDom = {
1392
1392
  tag: "exception-content",
1393
1393
  attributes: { name: exceptionName },
@@ -1400,7 +1400,7 @@ async function executeThrow(session, element) {
1400
1400
  // src/tags/try.ts
1401
1401
  async function executeTry(session, element) {
1402
1402
  setExceptionBoundary(session);
1403
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-ZG23OYGG.js");
1403
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
1404
1404
  await integrateChildren2(session, element);
1405
1405
  unsetExceptionBoundary(session);
1406
1406
  }
@@ -1410,7 +1410,7 @@ async function executeCatch(session, element) {
1410
1410
  const exceptionName = element.attributes?.name || "exception";
1411
1411
  const caughtCount = lookupException(session, exceptionName);
1412
1412
  if (caughtCount > 0) {
1413
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-ZG23OYGG.js");
1413
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
1414
1414
  await integrateChildren2(session, element);
1415
1415
  }
1416
1416
  flushCurrentException(session);
@@ -1419,7 +1419,7 @@ async function executeCatch(session, element) {
1419
1419
  // src/tags/exception.ts
1420
1420
  async function executeException(session, element) {
1421
1421
  const exceptions = getCurrentExceptions(session);
1422
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-ZG23OYGG.js");
1422
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-U74XE6FV.js");
1423
1423
  for (const exceptionDom of exceptions) {
1424
1424
  await integrateChildren2(session, exceptionDom);
1425
1425
  }
@@ -1882,7 +1882,7 @@ async function executeLoadContext(session, element) {
1882
1882
  query = element.text.trim();
1883
1883
  }
1884
1884
  if (!query && element.children.length > 0) {
1885
- const { integrate: integrate2 } = await import("./interpreter-ZG23OYGG.js");
1885
+ const { integrate: integrate2 } = await import("./interpreter-U74XE6FV.js");
1886
1886
  const beforeOutput = session.output.length;
1887
1887
  for (const child of element.children) {
1888
1888
  await integrate2(session, child);
@@ -2121,7 +2121,7 @@ async function executeForeach(session, element) {
2121
2121
  const parser2 = new DiracParser2();
2122
2122
  try {
2123
2123
  const fromElement = parser2.parse(fromAttr);
2124
- const { integrate: integrate2 } = await import("./interpreter-ZG23OYGG.js");
2124
+ const { integrate: integrate2 } = await import("./interpreter-U74XE6FV.js");
2125
2125
  await integrate2(session, fromElement);
2126
2126
  } catch (e) {
2127
2127
  session.output = savedOutput;
@@ -2495,6 +2495,9 @@ async function integrate(session, element) {
2495
2495
  case "input":
2496
2496
  await executeInput(session, element);
2497
2497
  break;
2498
+ case "schedule":
2499
+ await executeSchedule(session, element);
2500
+ break;
2498
2501
  case "require_module":
2499
2502
  await executeRequireModule(session, element);
2500
2503
  break;
@@ -2527,7 +2530,74 @@ async function integrateChildren(session, element) {
2527
2530
  }
2528
2531
  }
2529
2532
 
2533
+ // src/tags/schedule.ts
2534
+ var scheduledTasks = /* @__PURE__ */ new Map();
2535
+ async function executeSchedule(session, element) {
2536
+ const intervalAttr = element.attributes.interval;
2537
+ const name = element.attributes.name || `task-${Date.now()}`;
2538
+ if (!intervalAttr) {
2539
+ throw new Error("<schedule> requires interval attribute (in seconds)");
2540
+ }
2541
+ const substitutedInterval = substituteAttribute(session, intervalAttr);
2542
+ const intervalSeconds = parseInt(substitutedInterval, 10);
2543
+ if (isNaN(intervalSeconds) || intervalSeconds <= 0) {
2544
+ throw new Error(`Invalid schedule interval: ${intervalAttr} (evaluated to: ${substitutedInterval})`);
2545
+ }
2546
+ const intervalMs = intervalSeconds * 1e3;
2547
+ if (scheduledTasks.has(name)) {
2548
+ const existing = scheduledTasks.get(name);
2549
+ clearInterval(existing.intervalId);
2550
+ console.log(`[schedule] Stopped existing task: ${name}`);
2551
+ }
2552
+ const taskElement = element;
2553
+ console.log(`[schedule] Starting task "${name}" (every ${intervalSeconds}s)`);
2554
+ executeTask(session, taskElement, name).catch((err) => {
2555
+ console.error(`[schedule] Error in task "${name}":`, err.message);
2556
+ });
2557
+ const intervalId = setInterval(() => {
2558
+ executeTask(session, taskElement, name).catch((err) => {
2559
+ console.error(`[schedule] Error in task "${name}":`, err.message);
2560
+ });
2561
+ }, intervalMs);
2562
+ scheduledTasks.set(name, {
2563
+ name,
2564
+ intervalId,
2565
+ interval: intervalSeconds
2566
+ });
2567
+ }
2568
+ async function executeTask(session, element, name) {
2569
+ try {
2570
+ await integrateChildren(session, element);
2571
+ } catch (error) {
2572
+ console.error(`[schedule] Task "${name}" failed:`, error.message);
2573
+ }
2574
+ }
2575
+ function stopScheduledTask(name) {
2576
+ const task = scheduledTasks.get(name);
2577
+ if (!task) {
2578
+ return false;
2579
+ }
2580
+ clearInterval(task.intervalId);
2581
+ scheduledTasks.delete(name);
2582
+ console.log(`[schedule] Stopped task: ${name}`);
2583
+ return true;
2584
+ }
2585
+ function stopAllScheduledTasks() {
2586
+ for (const [name, task] of scheduledTasks) {
2587
+ clearInterval(task.intervalId);
2588
+ console.log(`[schedule] Stopped task: ${name}`);
2589
+ }
2590
+ scheduledTasks.clear();
2591
+ }
2592
+ function listScheduledTasks() {
2593
+ return Array.from(scheduledTasks.values());
2594
+ }
2595
+
2530
2596
  export {
2597
+ executeSchedule,
2598
+ stopScheduledTask,
2599
+ stopAllScheduledTasks,
2600
+ listScheduledTasks,
2531
2601
  integrate,
2532
2602
  integrateChildren
2533
2603
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-3DUTURSM.js";
3
+ } from "./chunk-2J7FVKXI.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
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-G2XVIAV5.js";
8
- import "./chunk-3DUTURSM.js";
7
+ } from "./chunk-CRT4U2QX.js";
8
+ import "./chunk-2J7FVKXI.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.40",
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-Z7QXHZYV.js");
99
+ const { DiracShell } = await import("./shell-VHD65GUJ.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-G2XVIAV5.js";
5
+ } from "./chunk-CRT4U2QX.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-3DUTURSM.js";
8
+ } from "./chunk-2J7FVKXI.js";
9
9
  import {
10
10
  DiracParser
11
11
  } from "./chunk-HRHAMPOB.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  integrate,
3
3
  integrateChildren
4
- } from "./chunk-3DUTURSM.js";
4
+ } from "./chunk-2J7FVKXI.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
6
  import "./chunk-4QLTSCDG.js";
7
7
  import "./chunk-GLXVY235.js";
@@ -0,0 +1,15 @@
1
+ import {
2
+ executeSchedule,
3
+ listScheduledTasks,
4
+ stopAllScheduledTasks,
5
+ stopScheduledTask
6
+ } from "./chunk-2J7FVKXI.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-3DUTURSM.js";
7
+ } from "./chunk-2J7FVKXI.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
- console.log("\nGoodbye!");
70
- process.exit(0);
69
+ import("./schedule-H4R2Z65R.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-H4R2Z65R.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-H4R2Z65R.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-H4R2Z65R.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();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-3DUTURSM.js";
3
+ } from "./chunk-2J7FVKXI.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirac-lang",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",