dirac-lang 0.1.61 → 0.1.62

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.
@@ -2,8 +2,8 @@ import {
2
2
  SessionServer,
3
3
  getSocketPath,
4
4
  isSessionRunning
5
- } from "./chunk-AU3YU63U.js";
6
- import "./chunk-ZAA6R2TC.js";
5
+ } from "./chunk-WPEAYK2Q.js";
6
+ import "./chunk-BAO2WV34.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-NKA6ZJDV.js";
9
9
  import "./chunk-3UW6GWYQ.js";
@@ -195,7 +195,8 @@ async function runAgentDaemon() {
195
195
  llmProvider: configData.llmProvider,
196
196
  llmModel: configData.llmModel,
197
197
  customLLMUrl: configData.customLLMUrl,
198
- initScript: configData.initScript
198
+ initScript: configData.initScript,
199
+ libraryPaths: configData.libraryPaths
199
200
  };
200
201
  console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] Loaded config: LLM=${config.llmProvider}/${config.llmModel}`);
201
202
  }
@@ -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-NPXTWPHN.js");
477
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
478
478
  await integrateChildren2(session, thenElement);
479
479
  }
480
480
  } else {
481
481
  if (elseElement) {
482
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
482
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.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-NPXTWPHN.js");
495
+ const { integrate: integrate2 } = await import("./interpreter-UFWRGTCM.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-NPXTWPHN.js");
518
+ const { integrate: integrate2 } = await import("./interpreter-UFWRGTCM.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-NPXTWPHN.js");
522
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
523
523
  await integrateChildren2(session, child);
524
524
  const newChunks = session.output.slice(argOutputStart);
525
525
  const argValue = newChunks.join("");
@@ -833,9 +833,10 @@ async function executeLLM(session, element) {
833
833
  example = example.replace(/"/g, '"').replace(/:/g, ":");
834
834
  systemPrompt += ">" + example + "</" + sub.name + ">";
835
835
  }
836
- currentUserPrompt = systemPrompt + "\n\nUser request: " + userPrompt;
836
+ dialogHistory.push({ role: "system", content: systemPrompt });
837
+ currentUserPrompt = userPrompt;
837
838
  if (session.debug || process.env.DIRAC_LOG_PROMPT === "1") {
838
- console.error("[LLM] Continuing dialog with updated subroutines\n");
839
+ console.error("[LLM] Continuing dialog with updated subroutines (as system message)\n");
839
840
  }
840
841
  } else {
841
842
  systemPrompt = `Dirac is a XML-based language. To define a subroutine with parameters:
@@ -1685,7 +1686,7 @@ async function executeTagCheck(session, element) {
1685
1686
  const executeTag = correctedTag || tagName;
1686
1687
  console.error(`[tag-check] Executing <${executeTag}/> as all checks passed and execute=true.`);
1687
1688
  const elementToExecute = correctedTag ? { ...child, tag: correctedTag } : child;
1688
- const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
1689
+ const { integrate: integrate2 } = await import("./interpreter-UFWRGTCM.js");
1689
1690
  await integrate2(session, elementToExecute);
1690
1691
  }
1691
1692
  }
@@ -1694,7 +1695,7 @@ async function executeTagCheck(session, element) {
1694
1695
  // src/tags/throw.ts
1695
1696
  async function executeThrow(session, element) {
1696
1697
  const exceptionName = element.attributes?.name || "exception";
1697
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1698
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
1698
1699
  const exceptionDom = {
1699
1700
  tag: "exception-content",
1700
1701
  attributes: { name: exceptionName },
@@ -1707,7 +1708,7 @@ async function executeThrow(session, element) {
1707
1708
  // src/tags/try.ts
1708
1709
  async function executeTry(session, element) {
1709
1710
  setExceptionBoundary(session);
1710
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1711
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
1711
1712
  await integrateChildren2(session, element);
1712
1713
  unsetExceptionBoundary(session);
1713
1714
  }
@@ -1717,7 +1718,7 @@ async function executeCatch(session, element) {
1717
1718
  const exceptionName = element.attributes?.name || "exception";
1718
1719
  const caughtCount = lookupException(session, exceptionName);
1719
1720
  if (caughtCount > 0) {
1720
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1721
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
1721
1722
  await integrateChildren2(session, element);
1722
1723
  }
1723
1724
  flushCurrentException(session);
@@ -1726,7 +1727,7 @@ async function executeCatch(session, element) {
1726
1727
  // src/tags/exception.ts
1727
1728
  async function executeException(session, element) {
1728
1729
  const exceptions = getCurrentExceptions(session);
1729
- const { integrateChildren: integrateChildren2 } = await import("./interpreter-NPXTWPHN.js");
1730
+ const { integrateChildren: integrateChildren2 } = await import("./interpreter-UFWRGTCM.js");
1730
1731
  for (const exceptionDom of exceptions) {
1731
1732
  await integrateChildren2(session, exceptionDom);
1732
1733
  }
@@ -2194,7 +2195,7 @@ async function executeLoadContext(session, element) {
2194
2195
  query = element.text.trim();
2195
2196
  }
2196
2197
  if (!query && element.children.length > 0) {
2197
- const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
2198
+ const { integrate: integrate2 } = await import("./interpreter-UFWRGTCM.js");
2198
2199
  const beforeOutput = session.output.length;
2199
2200
  for (const child of element.children) {
2200
2201
  await integrate2(session, child);
@@ -2447,7 +2448,7 @@ async function executeForeach(session, element) {
2447
2448
  const parser2 = new DiracParser2();
2448
2449
  try {
2449
2450
  const fromElement = parser2.parse(fromAttr);
2450
- const { integrate: integrate2 } = await import("./interpreter-NPXTWPHN.js");
2451
+ const { integrate: integrate2 } = await import("./interpreter-UFWRGTCM.js");
2451
2452
  await integrate2(session, fromElement);
2452
2453
  } catch (e) {
2453
2454
  session.output = savedOutput;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-ZAA6R2TC.js";
3
+ } from "./chunk-BAO2WV34.js";
4
4
  import {
5
5
  DiracParser
6
6
  } from "./chunk-HRHAMPOB.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-ZAA6R2TC.js";
3
+ } from "./chunk-BAO2WV34.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-AJSYOXXZ.js";
5
5
  import {
6
6
  execute
7
- } from "./chunk-BMKPKK7M.js";
8
- import "./chunk-ZAA6R2TC.js";
7
+ } from "./chunk-SVB7OJDA.js";
8
+ import "./chunk-BAO2WV34.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.60",
19
+ version: "0.1.61",
20
20
  description: "LLM-Augmented Declarative Execution",
21
21
  type: "module",
22
22
  main: "dist/index.js",
@@ -114,11 +114,11 @@ async function main() {
114
114
  if (args[0] === "agent") {
115
115
  const subcommand = args[1];
116
116
  if (subcommand === "daemon") {
117
- const { runAgentDaemon } = await import("./agent-OXQZBLNQ.js");
117
+ const { runAgentDaemon } = await import("./agent-3VQNLFHO.js");
118
118
  await runAgentDaemon();
119
119
  return;
120
120
  }
121
- const { AgentCLI } = await import("./agent-OXQZBLNQ.js");
121
+ const { AgentCLI } = await import("./agent-3VQNLFHO.js");
122
122
  const agent = new AgentCLI();
123
123
  switch (subcommand) {
124
124
  case "start":
@@ -145,8 +145,8 @@ async function main() {
145
145
  return;
146
146
  }
147
147
  if (args[0] === "shell") {
148
- const { DiracShell } = await import("./shell-OFBL57OA.js");
149
- const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-QZN2RMYD.js");
148
+ const { DiracShell } = await import("./shell-KGS3I6WX.js");
149
+ const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-BQH56RCK.js");
150
150
  const { SessionClient } = await import("./session-client-3VTC5MLO.js");
151
151
  const daemonMode = args.includes("--daemon") || args.includes("-d");
152
152
  const agentMode = args.includes("--agent") || args.includes("-a");
@@ -224,7 +224,7 @@ async function main() {
224
224
  return;
225
225
  }
226
226
  if (args[0] === "daemon") {
227
- const { SessionServer } = await import("./session-server-QZN2RMYD.js");
227
+ const { SessionServer } = await import("./session-server-BQH56RCK.js");
228
228
  const server = new SessionServer();
229
229
  await server.start();
230
230
  console.log("Session daemon started");
@@ -3,7 +3,7 @@ import {
3
3
  listCronJobs,
4
4
  stopAllCronJobs,
5
5
  stopCronJob
6
- } from "./chunk-ZAA6R2TC.js";
6
+ } from "./chunk-BAO2WV34.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-NKA6ZJDV.js";
9
9
  import "./chunk-3UW6GWYQ.js";
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createLLMAdapter,
3
3
  execute,
4
4
  executeUserCommand
5
- } from "./chunk-BMKPKK7M.js";
5
+ } from "./chunk-SVB7OJDA.js";
6
6
  import {
7
7
  integrate
8
- } from "./chunk-ZAA6R2TC.js";
8
+ } from "./chunk-BAO2WV34.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-ZAA6R2TC.js";
4
+ } from "./chunk-BAO2WV34.js";
5
5
  import "./chunk-HRHAMPOB.js";
6
6
  import "./chunk-NKA6ZJDV.js";
7
7
  import "./chunk-3UW6GWYQ.js";
@@ -3,7 +3,7 @@ import {
3
3
  cancelScheduledRun,
4
4
  executeRunAt,
5
5
  listScheduledRuns
6
- } from "./chunk-ZAA6R2TC.js";
6
+ } from "./chunk-BAO2WV34.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-NKA6ZJDV.js";
9
9
  import "./chunk-3UW6GWYQ.js";
@@ -3,7 +3,7 @@ import {
3
3
  listScheduledTasks,
4
4
  stopAllScheduledTasks,
5
5
  stopScheduledTask
6
- } from "./chunk-ZAA6R2TC.js";
6
+ } from "./chunk-BAO2WV34.js";
7
7
  import "./chunk-HRHAMPOB.js";
8
8
  import "./chunk-NKA6ZJDV.js";
9
9
  import "./chunk-3UW6GWYQ.js";
@@ -2,8 +2,8 @@ import {
2
2
  SessionServer,
3
3
  getSocketPath,
4
4
  isSessionRunning
5
- } from "./chunk-AU3YU63U.js";
6
- import "./chunk-ZAA6R2TC.js";
5
+ } from "./chunk-WPEAYK2Q.js";
6
+ import "./chunk-BAO2WV34.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-ZAA6R2TC.js";
7
+ } from "./chunk-BAO2WV34.js";
8
8
  import {
9
9
  DiracParser
10
10
  } from "./chunk-HRHAMPOB.js";
@@ -24,6 +24,8 @@ var MAX_HISTORY = 1e3;
24
24
  var DiracShell = class {
25
25
  session;
26
26
  client = null;
27
+ cachedSubroutines = [];
28
+ // Cache for agent mode tab completion
27
29
  braketParser;
28
30
  xmlParser;
29
31
  rl;
@@ -51,13 +53,26 @@ var DiracShell = class {
51
53
  */
52
54
  setClient(client) {
53
55
  this.client = client;
56
+ this.updateCachedSubroutines();
57
+ }
58
+ /**
59
+ * Update cached subroutines from agent
60
+ */
61
+ async updateCachedSubroutines() {
62
+ if (!this.client) return;
63
+ try {
64
+ const state = await this.client.getState();
65
+ this.cachedSubroutines = state.subroutines || [];
66
+ } catch (error) {
67
+ }
54
68
  }
55
69
  completer(line) {
70
+ const subroutines = this.client ? this.cachedSubroutines : this.session.subroutines;
56
71
  const attrMatch = line.match(/\|([a-z0-9_-]+)\s+.*?([a-z0-9_-]*)$/i);
57
72
  if (attrMatch) {
58
73
  const tagName = attrMatch[1];
59
74
  const attrPartial = attrMatch[2];
60
- const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
75
+ const subroutine = subroutines.find((sub) => sub.name === tagName);
61
76
  if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
62
77
  const matches = subroutine.parameters.filter(
63
78
  (p) => p.name.toLowerCase().startsWith(attrPartial.toLowerCase())
@@ -82,7 +97,7 @@ var DiracShell = class {
82
97
  const tagCompleteMatch = line.match(/\|([a-z0-9_-]+)$/i);
83
98
  if (tagCompleteMatch) {
84
99
  const tagName = tagCompleteMatch[1];
85
- const subroutine = this.session.subroutines.find((sub) => sub.name === tagName);
100
+ const subroutine = subroutines.find((sub) => sub.name === tagName);
86
101
  if (subroutine && subroutine.parameters && subroutine.parameters.length > 0) {
87
102
  console.log("\n");
88
103
  subroutine.parameters.forEach((p) => {
@@ -98,13 +113,13 @@ var DiracShell = class {
98
113
  const paramSuggestions = subroutine.parameters.map((p) => `${p.name}=`);
99
114
  return [paramSuggestions, ""];
100
115
  }
101
- const subroutineNames = this.session.subroutines.map((sub) => sub.name);
116
+ const subroutineNames = subroutines.map((sub) => sub.name);
102
117
  const matches = subroutineNames.filter(
103
118
  (name) => name.toLowerCase().startsWith(tagName.toLowerCase())
104
119
  );
105
120
  if (matches.length > 0) {
106
121
  const completions = matches.map((name) => {
107
- const sub = this.session.subroutines.find((s) => s.name === name);
122
+ const sub = subroutines.find((s) => s.name === name);
108
123
  const hasParams = sub && sub.parameters && sub.parameters.length > 0;
109
124
  return hasParams ? `|${name} ` : `|${name}>`;
110
125
  });
@@ -160,7 +175,7 @@ var DiracShell = class {
160
175
  if (this.client) {
161
176
  this.client.disconnect();
162
177
  }
163
- import("./schedule-QZ5U3YBS.js").then(({ stopAllScheduledTasks }) => {
178
+ import("./schedule-F7JHVWEV.js").then(({ stopAllScheduledTasks }) => {
164
179
  stopAllScheduledTasks();
165
180
  console.log("\nGoodbye!");
166
181
  process.exit(0);
@@ -268,6 +283,7 @@ var DiracShell = class {
268
283
  if (output) {
269
284
  console.log(output);
270
285
  }
286
+ await this.updateCachedSubroutines();
271
287
  return;
272
288
  }
273
289
  this.session.output = [];
@@ -525,7 +541,7 @@ Examples:
525
541
  break;
526
542
  case "tasks":
527
543
  try {
528
- const { listScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
544
+ const { listScheduledTasks } = await import("./schedule-F7JHVWEV.js");
529
545
  const tasks = listScheduledTasks();
530
546
  if (tasks.length === 0) {
531
547
  console.log("No scheduled tasks running.");
@@ -544,7 +560,7 @@ Examples:
544
560
  console.log("Usage: :stop <task-name>");
545
561
  } else {
546
562
  try {
547
- const { stopScheduledTask } = await import("./schedule-QZ5U3YBS.js");
563
+ const { stopScheduledTask } = await import("./schedule-F7JHVWEV.js");
548
564
  const taskName = args[0];
549
565
  const stopped = stopScheduledTask(taskName);
550
566
  if (stopped) {
@@ -559,7 +575,7 @@ Examples:
559
575
  break;
560
576
  case "stopall":
561
577
  try {
562
- const { stopAllScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
578
+ const { stopAllScheduledTasks } = await import("./schedule-F7JHVWEV.js");
563
579
  stopAllScheduledTasks();
564
580
  console.log("All scheduled tasks stopped.");
565
581
  } catch (error) {
@@ -568,7 +584,7 @@ Examples:
568
584
  break;
569
585
  case "crons":
570
586
  try {
571
- const { listCronJobs } = await import("./cron-BQIWLGQY.js");
587
+ const { listCronJobs } = await import("./cron-SUYXFAW7.js");
572
588
  const jobs = listCronJobs();
573
589
  if (jobs.length === 0) {
574
590
  console.log("No cron jobs running.");
@@ -588,7 +604,7 @@ Examples:
588
604
  console.log("Usage: :stopcron <job-name>");
589
605
  } else {
590
606
  try {
591
- const { stopCronJob } = await import("./cron-BQIWLGQY.js");
607
+ const { stopCronJob } = await import("./cron-SUYXFAW7.js");
592
608
  const jobName = args[0];
593
609
  const stopped = stopCronJob(jobName);
594
610
  if (stopped) {
@@ -603,7 +619,7 @@ Examples:
603
619
  break;
604
620
  case "stopallcrons":
605
621
  try {
606
- const { stopAllCronJobs } = await import("./cron-BQIWLGQY.js");
622
+ const { stopAllCronJobs } = await import("./cron-SUYXFAW7.js");
607
623
  stopAllCronJobs();
608
624
  console.log("All cron jobs stopped.");
609
625
  } catch (error) {
@@ -612,7 +628,7 @@ Examples:
612
628
  break;
613
629
  case "scheduled":
614
630
  try {
615
- const { listScheduledRuns } = await import("./run-at-KDJYTEOD.js");
631
+ const { listScheduledRuns } = await import("./run-at-BBMPAVED.js");
616
632
  const runs = listScheduledRuns();
617
633
  if (runs.length === 0) {
618
634
  console.log("No scheduled runs pending.");
@@ -632,7 +648,7 @@ Examples:
632
648
  console.log("Usage: :cancel <run-name>");
633
649
  } else {
634
650
  try {
635
- const { cancelScheduledRun } = await import("./run-at-KDJYTEOD.js");
651
+ const { cancelScheduledRun } = await import("./run-at-BBMPAVED.js");
636
652
  const runName = args[0];
637
653
  const cancelled = cancelScheduledRun(runName);
638
654
  if (cancelled) {
@@ -647,7 +663,7 @@ Examples:
647
663
  break;
648
664
  case "cancelall":
649
665
  try {
650
- const { cancelAllScheduledRuns } = await import("./run-at-KDJYTEOD.js");
666
+ const { cancelAllScheduledRuns } = await import("./run-at-BBMPAVED.js");
651
667
  cancelAllScheduledRuns();
652
668
  console.log("All scheduled runs cancelled.");
653
669
  } catch (error) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  integrate
3
- } from "./chunk-ZAA6R2TC.js";
3
+ } from "./chunk-BAO2WV34.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.61",
3
+ "version": "0.1.62",
4
4
  "description": "LLM-Augmented Declarative Execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",