dirac-lang 0.1.59 → 0.1.60

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-RDVNX3JG.js";
3
+ } from "./chunk-ZAA6R2TC.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -474,12 +474,12 @@ async function executeIf(session, element) {
474
474
  const condition = await evaluatePredicate(session, conditionElement);
475
475
  if (condition) {
476
476
  if (thenElement) {
477
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
477
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
478
478
  await integrateChildren2(session, thenElement);
479
479
  }
480
480
  } else {
481
481
  if (elseElement) {
482
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
482
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
483
483
  await integrateChildren2(session, elseElement);
484
484
  }
485
485
  }
@@ -492,7 +492,7 @@ async function evaluatePredicate(session, predicateElement) {
492
492
  return await evaluateCondition(session, predicateElement);
493
493
  }
494
494
  const outputLengthBefore = session.output.length;
495
- const { integrate: integrate2 } = await import("./interpreter-QC6Z7Y6R.js");
495
+ const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
496
496
  await integrate2(session, predicateElement);
497
497
  const newOutputChunks = session.output.slice(outputLengthBefore);
498
498
  const result = newOutputChunks.join("").trim();
@@ -515,11 +515,11 @@ async function evaluateCondition(session, condElement) {
515
515
  }
516
516
  const outputLengthBefore = session.output.length;
517
517
  const args = [];
518
- const { integrate: integrate2 } = await import("./interpreter-QC6Z7Y6R.js");
518
+ const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
519
519
  for (const child of condElement.children) {
520
520
  if (child.tag.toLowerCase() === "arg") {
521
521
  const argOutputStart = session.output.length;
522
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
522
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
523
523
  await integrateChildren2(session, child);
524
524
  const newChunks = session.output.slice(argOutputStart);
525
525
  const argValue = newChunks.join("");
@@ -1685,7 +1685,7 @@ async function executeTagCheck(session, element) {
1685
1685
  const executeTag = correctedTag || tagName;
1686
1686
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1687
1687
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1688
- const { integrate: integrate2 } = await import("./interpreter-QC6Z7Y6R.js");
1688
+ const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
1689
1689
  await integrate2(session, elementToExecute);
1690
1690
  }
1691
1691
  }
@@ -1694,7 +1694,7 @@ async function executeTagCheck(session, element) {
1694
1694
  // src/tags/throw.ts
1695
1695
  async function executeThrow(session, element) {
1696
1696
  const exceptionName = element.attributes?.name || "exception";
1697
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
1697
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1698
1698
  const exceptionDom = {
1699
1699
  tag: "exception-content",
1700
1700
  attributes: { name: exceptionName },
@@ -1707,7 +1707,7 @@ async function executeThrow(session, element) {
1707
1707
  // src/tags/try.ts
1708
1708
  async function executeTry(session, element) {
1709
1709
  setExceptionBoundary(session);
1710
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
1710
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1711
1711
  await integrateChildren2(session, element);
1712
1712
  unsetExceptionBoundary(session);
1713
1713
  }
@@ -1717,7 +1717,7 @@ async function executeCatch(session, element) {
1717
1717
  const exceptionName = element.attributes?.name || "exception";
1718
1718
  const caughtCount = lookupException(session, exceptionName);
1719
1719
  if (caughtCount > 0) {
1720
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
1720
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1721
1721
  await integrateChildren2(session, element);
1722
1722
  }
1723
1723
  flushCurrentException(session);
@@ -1726,7 +1726,7 @@ async function executeCatch(session, element) {
1726
1726
  // src/tags/exception.ts
1727
1727
  async function executeException(session, element) {
1728
1728
  const exceptions = getCurrentExceptions(session);
1729
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-QC6Z7Y6R.js");
1729
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1730
1730
  for (const exceptionDom of exceptions) {
1731
1731
  await integrateChildren2(session, exceptionDom);
1732
1732
  }
@@ -2194,7 +2194,7 @@ async function executeLoadContext(session, element) {
2194
2194
  query = element.text.trim();
2195
2195
  }
2196
2196
  if (!query && element.children.length > 0) {
2197
- const { integrate: integrate2 } = await import("./interpreter-QC6Z7Y6R.js");
2197
+ const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
2198
2198
  const beforeOutput = session.output.length;
2199
2199
  for (const child of element.children) {
2200
2200
  await integrate2(session, child);
@@ -2447,7 +2447,7 @@ async function executeForeach(session, element) {
2447
2447
  const parser2 = new DiracParser2();
2448
2448
  try {
2449
2449
  const fromElement = parser2.parse(fromAttr);
2450
- const { integrate: integrate2 } = await import("./interpreter-QC6Z7Y6R.js");
2450
+ const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
2451
2451
  await integrate2(session, fromElement);
2452
2452
  } catch (e) {
2453
2453
  session.output = savedOutput;
@@ -2702,6 +2702,206 @@ async function readLineFromFile(path4) {
2702
2702
  return result.value;
2703
2703
  }
2704
2704
 
2705
+ // src/tags/cron.ts
2706
+ import cron from "node-cron";
2707
+ var cronJobs = /* @__PURE__ */ new Map();
2708
+ async function executeCron(session, element) {
2709
+ const timeAttr = element.attributes.time;
2710
+ const name = element.attributes.name || `cron-${Date.now()}`;
2711
+ if (!timeAttr) {
2712
+ throw new Error("<cron> requires time attribute (cron expression)");
2713
+ }
2714
+ const cronExpression = substituteAttribute(session, timeAttr);
2715
+ if (!cron.validate(cronExpression)) {
2716
+ throw new Error(`Invalid cron expression: ${cronExpression}
2717
+ Format: minute hour day month weekday
2718
+ Example: "0 9 * * *" (daily at 9 AM)`);
2719
+ }
2720
+ if (cronJobs.has(name)) {
2721
+ const existing = cronJobs.get(name);
2722
+ existing.task.stop();
2723
+ console.log(`[cron] Stopped existing job: ${name}`);
2724
+ }
2725
+ console.log(`[cron] Starting job "${name}" (${cronExpression})`);
2726
+ let isRunning = false;
2727
+ const task = cron.schedule(cronExpression, async () => {
2728
+ await executeJob(session, element, name, () => isRunning, (value) => {
2729
+ isRunning = value;
2730
+ });
2731
+ }, {
2732
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
2733
+ // Use system timezone
2734
+ });
2735
+ cronJobs.set(name, {
2736
+ name,
2737
+ task,
2738
+ cronExpression,
2739
+ isRunning: false
2740
+ });
2741
+ }
2742
+ async function executeJob(session, element, name, getIsRunning, setIsRunning) {
2743
+ if (getIsRunning()) {
2744
+ console.log(`[cron] Skipping job "${name}" - previous execution still running`);
2745
+ return;
2746
+ }
2747
+ setIsRunning(true);
2748
+ console.log(`[cron] Executing job: ${name}`);
2749
+ try {
2750
+ session.output = [];
2751
+ await integrateChildren(session, element);
2752
+ if (session.output.length > 0) {
2753
+ console.log(session.output.join(""));
2754
+ }
2755
+ } catch (error) {
2756
+ console.error(`[cron] Job "${name}" failed:`, error.message);
2757
+ } finally {
2758
+ setIsRunning(false);
2759
+ }
2760
+ }
2761
+ function stopCronJob(name) {
2762
+ const job = cronJobs.get(name);
2763
+ if (!job) {
2764
+ return false;
2765
+ }
2766
+ job.task.stop();
2767
+ cronJobs.delete(name);
2768
+ console.log(`[cron] Stopped job: ${name}`);
2769
+ return true;
2770
+ }
2771
+ function stopAllCronJobs() {
2772
+ for (const [name, job] of cronJobs) {
2773
+ job.task.stop();
2774
+ console.log(`[cron] Stopped job: ${name}`);
2775
+ }
2776
+ cronJobs.clear();
2777
+ }
2778
+ function listCronJobs() {
2779
+ return Array.from(cronJobs.values()).map((job) => ({
2780
+ name: job.name,
2781
+ cronExpression: job.cronExpression,
2782
+ isRunning: job.isRunning
2783
+ }));
2784
+ }
2785
+
2786
+ // src/tags/run-at.ts
2787
+ var scheduledRuns = /* @__PURE__ */ new Map();
2788
+ async function executeRunAt(session, element) {
2789
+ const timeAttr = element.attributes.time;
2790
+ const name = element.attributes.name || `run-${Date.now()}`;
2791
+ if (!timeAttr) {
2792
+ throw new Error("<run-at> requires time attribute");
2793
+ }
2794
+ const timeStr = substituteAttribute(session, timeAttr);
2795
+ const targetTime = parseTimeExpression(timeStr);
2796
+ if (isNaN(targetTime.getTime())) {
2797
+ throw new Error(`Invalid time expression: ${timeStr}`);
2798
+ }
2799
+ const now = /* @__PURE__ */ new Date();
2800
+ const delayMs = targetTime.getTime() - now.getTime();
2801
+ if (delayMs < 0) {
2802
+ throw new Error(`Time is in the past: ${targetTime.toISOString()} (current: ${now.toISOString()})`);
2803
+ }
2804
+ if (scheduledRuns.has(name)) {
2805
+ const existing = scheduledRuns.get(name);
2806
+ clearTimeout(existing.timeoutId);
2807
+ console.log(`[run-at] Cancelled existing run: ${name}`);
2808
+ }
2809
+ console.log(`[run-at] Scheduled "${name}" for ${targetTime.toLocaleString()} (in ${formatDuration(delayMs)})`);
2810
+ const timeoutId = setTimeout(async () => {
2811
+ await executeScheduledRun(session, element, name);
2812
+ scheduledRuns.delete(name);
2813
+ }, delayMs);
2814
+ scheduledRuns.set(name, {
2815
+ name,
2816
+ timeoutId,
2817
+ scheduledTime: targetTime,
2818
+ isRunning: false
2819
+ });
2820
+ }
2821
+ async function executeScheduledRun(session, element, name) {
2822
+ const run = scheduledRuns.get(name);
2823
+ if (!run) return;
2824
+ run.isRunning = true;
2825
+ console.log(`[run-at] Executing: ${name}`);
2826
+ try {
2827
+ session.output = [];
2828
+ await integrateChildren(session, element);
2829
+ if (session.output.length > 0) {
2830
+ console.log(session.output.join(""));
2831
+ }
2832
+ } catch (error) {
2833
+ console.error(`[run-at] Run "${name}" failed:`, error.message);
2834
+ } finally {
2835
+ run.isRunning = false;
2836
+ }
2837
+ }
2838
+ function parseTimeExpression(expr) {
2839
+ expr = expr.trim();
2840
+ const relativeMatch = expr.match(/^\+(\d+)(s|m|h|d)?$/);
2841
+ if (relativeMatch) {
2842
+ const value = parseInt(relativeMatch[1], 10);
2843
+ const unit = relativeMatch[2] || "s";
2844
+ const now = Date.now();
2845
+ let offsetMs;
2846
+ switch (unit) {
2847
+ case "s":
2848
+ offsetMs = value * 1e3;
2849
+ break;
2850
+ case "m":
2851
+ offsetMs = value * 60 * 1e3;
2852
+ break;
2853
+ case "h":
2854
+ offsetMs = value * 60 * 60 * 1e3;
2855
+ break;
2856
+ case "d":
2857
+ offsetMs = value * 24 * 60 * 60 * 1e3;
2858
+ break;
2859
+ default:
2860
+ offsetMs = value * 1e3;
2861
+ }
2862
+ return new Date(now + offsetMs);
2863
+ }
2864
+ if (/^\d+$/.test(expr)) {
2865
+ const timestamp = parseInt(expr, 10);
2866
+ return new Date(timestamp);
2867
+ }
2868
+ return new Date(expr);
2869
+ }
2870
+ function formatDuration(ms) {
2871
+ const seconds = Math.floor(ms / 1e3);
2872
+ const minutes = Math.floor(seconds / 60);
2873
+ const hours = Math.floor(minutes / 60);
2874
+ const days = Math.floor(hours / 24);
2875
+ if (days > 0) return `${days}d ${hours % 24}h`;
2876
+ if (hours > 0) return `${hours}h ${minutes % 60}m`;
2877
+ if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
2878
+ return `${seconds}s`;
2879
+ }
2880
+ function cancelScheduledRun(name) {
2881
+ const run = scheduledRuns.get(name);
2882
+ if (!run) {
2883
+ return false;
2884
+ }
2885
+ clearTimeout(run.timeoutId);
2886
+ scheduledRuns.delete(name);
2887
+ console.log(`[run-at] Cancelled: ${name}`);
2888
+ return true;
2889
+ }
2890
+ function cancelAllScheduledRuns() {
2891
+ for (const [name, run] of scheduledRuns) {
2892
+ clearTimeout(run.timeoutId);
2893
+ console.log(`[run-at] Cancelled: ${name}`);
2894
+ }
2895
+ scheduledRuns.clear();
2896
+ }
2897
+ function listScheduledRuns() {
2898
+ return Array.from(scheduledRuns.values()).map((run) => ({
2899
+ name: run.name,
2900
+ scheduledTime: run.scheduledTime,
2901
+ isRunning: run.isRunning
2902
+ }));
2903
+ }
2904
+
2705
2905
  // src/runtime/interpreter.ts
2706
2906
  async function integrate(session, element) {
2707
2907
  if (session.limits.currentDepth >= session.limits.maxDepth) {
@@ -2824,6 +3024,12 @@ async function integrate(session, element) {
2824
3024
  case "schedule":
2825
3025
  await executeSchedule(session, element);
2826
3026
  break;
3027
+ case "cron":
3028
+ await executeCron(session, element);
3029
+ break;
3030
+ case "run-at":
3031
+ await executeRunAt(session, element);
3032
+ break;
2827
3033
  case "require_module":
2828
3034
  await executeRequireModule(session, element);
2829
3035
  break;
@@ -2937,6 +3143,14 @@ export {
2937
3143
  stopScheduledTask,
2938
3144
  stopAllScheduledTasks,
2939
3145
  listScheduledTasks,
3146
+ executeCron,
3147
+ stopCronJob,
3148
+ stopAllCronJobs,
3149
+ listCronJobs,
3150
+ executeRunAt,
3151
+ cancelScheduledRun,
3152
+ cancelAllScheduledRuns,
3153
+ listScheduledRuns,
2940
3154
  integrate,
2941
3155
  integrateChildren
2942
3156
  };
package/dist/cli.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  } from "./chunk-AJSYOXXZ.js";
5
5
  import {
6
6
  execute
7
- } from "./chunk-NVKBCTEU.js";
8
- import "./chunk-RDVNX3JG.js";
7
+ } from "./chunk-BMKPKK7M.js";
8
+ import "./chunk-ZAA6R2TC.js";
9
9
  import "./chunk-HRHAMPOB.js";
10
10
  import "./chunk-NKA6ZJDV.js";
11
11
  import "./chunk-3UW6GWYQ.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.58",
19
+ version: "0.1.60",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -46,16 +46,19 @@ var package_default = {
46
46
  license: "MIT",
47
47
  dependencies: {
48
48
  "@anthropic-ai/sdk": "^0.30.1",
49
+ "dirac-lang": "^0.1.59",
49
50
  "dirac-stdlib": "^0.1.0",
50
51
  dotenv: "^17.2.3",
51
52
  "fast-xml-parser": "^4.3.5",
52
53
  "js-yaml": "^4.1.1",
53
54
  mongodb: "^7.0.0",
55
+ "node-cron": "^4.2.1",
54
56
  openai: "^6.16.0"
55
57
  },
56
58
  devDependencies: {
57
59
  "@types/js-yaml": "^4.0.9",
58
60
  "@types/node": "^20.11.0",
61
+ "@types/node-cron": "^3.0.11",
59
62
  tsup: "^8.0.1",
60
63
  tsx: "^4.7.0",
61
64
  typescript: "^5.3.3",
@@ -96,7 +99,7 @@ async function main() {
96
99
  process.exit(0);
97
100
  }
98
101
  if (args[0] === "shell") {
99
- const { DiracShell } = await import("./shell-LPNBQPXC.js");
102
+ const { DiracShell } = await import("./shell-WFLXZW3I.js");
100
103
  const shellConfig = { debug: false };
101
104
  for (let i = 1; i < args.length; i++) {
102
105
  const arg = args[i];
@@ -0,0 +1,15 @@
1
+ import {
2
+ executeCron,
3
+ listCronJobs,
4
+ stopAllCronJobs,
5
+ stopCronJob
6
+ } from "./chunk-ZAA6R2TC.js";
7
+ import "./chunk-HRHAMPOB.js";
8
+ import "./chunk-NKA6ZJDV.js";
9
+ import "./chunk-3UW6GWYQ.js";
10
+ export {
11
+ executeCron,
12
+ listCronJobs,
13
+ stopAllCronJobs,
14
+ stopCronJob
15
+ };
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createLLMAdapter,
3
3
  execute,
4
4
  executeUserCommand
5
- } from "./chunk-NVKBCTEU.js";
5
+ } from "./chunk-BMKPKK7M.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-RDVNX3JG.js";
8
+ } from "./chunk-ZAA6R2TC.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-RDVNX3JG.js";
4
+ } from "./chunk-ZAA6R2TC.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
6
  import "./chunk-NKA6ZJDV.js";
7
7
  import "./chunk-3UW6GWYQ.js";
@@ -0,0 +1,15 @@
1
+ import {
2
+ cancelAllScheduledRuns,
3
+ cancelScheduledRun,
4
+ executeRunAt,
5
+ listScheduledRuns
6
+ } from "./chunk-ZAA6R2TC.js";
7
+ import "./chunk-HRHAMPOB.js";
8
+ import "./chunk-NKA6ZJDV.js";
9
+ import "./chunk-3UW6GWYQ.js";
10
+ export {
11
+ cancelAllScheduledRuns,
12
+ cancelScheduledRun,
13
+ executeRunAt,
14
+ listScheduledRuns
15
+ };
@@ -3,7 +3,7 @@ import {
3
3
  listScheduledTasks,
4
4
  stopAllScheduledTasks,
5
5
  stopScheduledTask
6
- } from "./chunk-RDVNX3JG.js";
6
+ } from "./chunk-ZAA6R2TC.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-NKA6ZJDV.js";
9
9
  import "./chunk-3UW6GWYQ.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AJSYOXXZ.js";
5
5
  import {
6
6
  integrate
7
- } from "./chunk-RDVNX3JG.js";
7
+ } from "./chunk-ZAA6R2TC.js";
8
8
  import {
9
9
  DiracParser
10
10
  } from "./chunk-HRHAMPOB.js";
@@ -150,7 +150,7 @@ var DiracShell = class {
150
150
  });
151
151
  this.rl.on("close", () => {
152
152
  this.saveHistory();
153
- import("./schedule-2NDGR5S5.js").then(({ stopAllScheduledTasks }) => {
153
+ import("./schedule-QZ5U3YBS.js").then(({ stopAllScheduledTasks }) => {
154
154
  stopAllScheduledTasks();
155
155
  console.log("\nGoodbye!");
156
156
  process.exit(0);
@@ -291,6 +291,12 @@ Commands:
291
291
  :tasks List all scheduled tasks
292
292
  :stop <name> Stop a scheduled task
293
293
  :stopall Stop all scheduled tasks
294
+ :crons List all cron jobs
295
+ :stopcron <name> Stop a cron job
296
+ :stopallcrons Stop all cron jobs
297
+ :scheduled List all scheduled runs (run-at)
298
+ :cancel <name> Cancel a scheduled run
299
+ :cancelall Cancel all scheduled runs
294
300
  :exit Exit shell
295
301
 
296
302
  Syntax:
@@ -471,7 +477,7 @@ Examples:
471
477
  break;
472
478
  case "tasks":
473
479
  try {
474
- const { listScheduledTasks } = await import("./schedule-2NDGR5S5.js");
480
+ const { listScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
475
481
  const tasks = listScheduledTasks();
476
482
  if (tasks.length === 0) {
477
483
  console.log("No scheduled tasks running.");
@@ -490,7 +496,7 @@ Examples:
490
496
  console.log("Usage: :stop <task-name>");
491
497
  } else {
492
498
  try {
493
- const { stopScheduledTask } = await import("./schedule-2NDGR5S5.js");
499
+ const { stopScheduledTask } = await import("./schedule-QZ5U3YBS.js");
494
500
  const taskName = args[0];
495
501
  const stopped = stopScheduledTask(taskName);
496
502
  if (stopped) {
@@ -505,13 +511,101 @@ Examples:
505
511
  break;
506
512
  case "stopall":
507
513
  try {
508
- const { stopAllScheduledTasks } = await import("./schedule-2NDGR5S5.js");
514
+ const { stopAllScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
509
515
  stopAllScheduledTasks();
510
516
  console.log("All scheduled tasks stopped.");
511
517
  } catch (error) {
512
518
  console.error("Error stopping tasks:", error instanceof Error ? error.message : String(error));
513
519
  }
514
520
  break;
521
+ case "crons":
522
+ try {
523
+ const { listCronJobs } = await import("./cron-BQIWLGQY.js");
524
+ const jobs = listCronJobs();
525
+ if (jobs.length === 0) {
526
+ console.log("No cron jobs running.");
527
+ } else {
528
+ console.log("\nCron Jobs:");
529
+ for (const job of jobs) {
530
+ const status = job.isRunning ? "(running)" : "";
531
+ console.log(` - ${job.name}: ${job.cronExpression} ${status}`);
532
+ }
533
+ }
534
+ } catch (error) {
535
+ console.error("Error listing cron jobs:", error instanceof Error ? error.message : String(error));
536
+ }
537
+ break;
538
+ case "stopcron":
539
+ if (args.length === 0) {
540
+ console.log("Usage: :stopcron <job-name>");
541
+ } else {
542
+ try {
543
+ const { stopCronJob } = await import("./cron-BQIWLGQY.js");
544
+ const jobName = args[0];
545
+ const stopped = stopCronJob(jobName);
546
+ if (stopped) {
547
+ console.log(`Stopped cron job: ${jobName}`);
548
+ } else {
549
+ console.log(`Cron job not found: ${jobName}`);
550
+ }
551
+ } catch (error) {
552
+ console.error("Error stopping cron job:", error instanceof Error ? error.message : String(error));
553
+ }
554
+ }
555
+ break;
556
+ case "stopallcrons":
557
+ try {
558
+ const { stopAllCronJobs } = await import("./cron-BQIWLGQY.js");
559
+ stopAllCronJobs();
560
+ console.log("All cron jobs stopped.");
561
+ } catch (error) {
562
+ console.error("Error stopping cron jobs:", error instanceof Error ? error.message : String(error));
563
+ }
564
+ break;
565
+ case "scheduled":
566
+ try {
567
+ const { listScheduledRuns } = await import("./run-at-KDJYTEOD.js");
568
+ const runs = listScheduledRuns();
569
+ if (runs.length === 0) {
570
+ console.log("No scheduled runs pending.");
571
+ } else {
572
+ console.log("\nScheduled Runs:");
573
+ for (const run of runs) {
574
+ const status = run.isRunning ? "(running)" : "";
575
+ console.log(` - ${run.name}: ${run.scheduledTime.toLocaleString()} ${status}`);
576
+ }
577
+ }
578
+ } catch (error) {
579
+ console.error("Error listing scheduled runs:", error instanceof Error ? error.message : String(error));
580
+ }
581
+ break;
582
+ case "cancel":
583
+ if (args.length === 0) {
584
+ console.log("Usage: :cancel <run-name>");
585
+ } else {
586
+ try {
587
+ const { cancelScheduledRun } = await import("./run-at-KDJYTEOD.js");
588
+ const runName = args[0];
589
+ const cancelled = cancelScheduledRun(runName);
590
+ if (cancelled) {
591
+ console.log(`Cancelled scheduled run: ${runName}`);
592
+ } else {
593
+ console.log(`Scheduled run not found: ${runName}`);
594
+ }
595
+ } catch (error) {
596
+ console.error("Error cancelling run:", error instanceof Error ? error.message : String(error));
597
+ }
598
+ }
599
+ break;
600
+ case "cancelall":
601
+ try {
602
+ const { cancelAllScheduledRuns } = await import("./run-at-KDJYTEOD.js");
603
+ cancelAllScheduledRuns();
604
+ console.log("All scheduled runs cancelled.");
605
+ } catch (error) {
606
+ console.error("Error cancelling runs:", error instanceof Error ? error.message : String(error));
607
+ }
608
+ break;
515
609
  case "exit":
516
610
  case "quit":
517
611
  this.rl.close();
@@ -542,6 +636,7 @@ Examples:
542
636
  }
543
637
  /**
544
638
  * Execute a Unix shell command
639
+ * If command is not found, fallback to treating it as an AI query
545
640
  */
546
641
  async executeShellCommand(command) {
547
642
  const trimmed = command.trim();
@@ -558,14 +653,29 @@ Examples:
558
653
  }
559
654
  const { spawn } = await import("child_process");
560
655
  this.rl.pause();
561
- return new Promise((resolve2) => {
656
+ return new Promise(async (resolve2) => {
562
657
  const shell = process.env.SHELL || "/bin/sh";
563
658
  const child = spawn(shell, ["-c", command], {
564
- stdio: "inherit",
659
+ stdio: ["inherit", "inherit", "pipe"],
565
660
  cwd: process.cwd()
566
661
  });
567
- child.on("close", () => {
662
+ let stderrData = "";
663
+ child.stderr?.on("data", (data) => {
664
+ stderrData += data.toString();
665
+ process.stderr.write(data);
666
+ });
667
+ child.on("close", async (code) => {
568
668
  this.rl.resume();
669
+ const commandNotFound = code === 127 || stderrData.includes("command not found");
670
+ if (commandNotFound) {
671
+ console.log(`\u{1F4A1} Command not found, trying as AI query...`);
672
+ if (this.config.debug) {
673
+ console.log(`[executing: |ai>${trimmed}]`);
674
+ }
675
+ const aiInput = `|ai>${trimmed}`;
676
+ this.inputBuffer = [aiInput];
677
+ await this.executeBuffer();
678
+ }
569
679
  resolve2();
570
680
  });
571
681
  child.on("error", (err) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-RDVNX3JG.js";
3
+ } from "./chunk-ZAA6R2TC.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.59",
3
+ "version": "0.1.60",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,16 +30,19 @@
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
32
  "@anthropic-ai/sdk": "^0.30.1",
33
+ "dirac-lang": "^0.1.59",
33
34
  "dirac-stdlib": "^0.1.0",
34
35
  "dotenv": "^17.2.3",
35
36
  "fast-xml-parser": "^4.3.5",
36
37
  "js-yaml": "^4.1.1",
37
38
  "mongodb": "^7.0.0",
39
+ "node-cron": "^4.2.1",
38
40
  "openai": "^6.16.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/js-yaml": "^4.0.9",
42
44
  "@types/node": "^20.11.0",
45
+ "@types/node-cron": "^3.0.11",
43
46
  "tsup": "^8.0.1",
44
47
  "tsx": "^4.7.0",
45
48
  "typescript": "^5.3.3",