dirac-lang 0.1.59 → 0.1.61
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-OXQZBLNQ.js +226 -0
- package/dist/chunk-AU3YU63U.js +208 -0
- package/dist/{chunk-NVKBCTEU.js → chunk-BMKPKK7M.js} +1 -1
- package/dist/{chunk-RDVNX3JG.js → chunk-ZAA6R2TC.js} +226 -12
- package/dist/cli.js +110 -4
- package/dist/cron-BQIWLGQY.js +15 -0
- package/dist/index.js +2 -2
- package/dist/{interpreter-QC6Z7Y6R.js → interpreter-NPXTWPHN.js} +1 -1
- package/dist/run-at-KDJYTEOD.js +15 -0
- package/dist/{schedule-2NDGR5S5.js → schedule-QZ5U3YBS.js} +1 -1
- package/dist/session-client-3VTC5MLO.js +177 -0
- package/dist/session-server-QZN2RMYD.js +14 -0
- package/dist/{shell-LPNBQPXC.js → shell-OFBL57OA.js} +190 -27
- package/dist/test-runner.js +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/session-client.ts
|
|
2
|
+
import net from "net";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
var SessionClient = class extends EventEmitter {
|
|
5
|
+
socket = null;
|
|
6
|
+
buffer = "";
|
|
7
|
+
connected = false;
|
|
8
|
+
options;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this.options = {
|
|
12
|
+
autoReconnect: false,
|
|
13
|
+
reconnectDelay: 1e3,
|
|
14
|
+
...options
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async connect() {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
this.socket = net.connect(this.options.socketPath);
|
|
20
|
+
this.socket.on("connect", () => {
|
|
21
|
+
this.emit("socket-connected");
|
|
22
|
+
});
|
|
23
|
+
this.socket.on("data", (data) => {
|
|
24
|
+
this.buffer += data.toString();
|
|
25
|
+
const lines = this.buffer.split("\n");
|
|
26
|
+
this.buffer = lines.pop() || "";
|
|
27
|
+
for (const line of lines) {
|
|
28
|
+
if (!line.trim()) continue;
|
|
29
|
+
try {
|
|
30
|
+
const message = JSON.parse(line);
|
|
31
|
+
this.handleMessage(message);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
this.emit("error", new Error(`Invalid message: ${error}`));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
this.socket.on("end", () => {
|
|
38
|
+
this.connected = false;
|
|
39
|
+
this.emit("disconnected");
|
|
40
|
+
if (this.options.autoReconnect) {
|
|
41
|
+
setTimeout(() => this.connect(), this.options.reconnectDelay);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.socket.on("error", (error) => {
|
|
45
|
+
this.connected = false;
|
|
46
|
+
reject(error);
|
|
47
|
+
this.emit("error", error);
|
|
48
|
+
});
|
|
49
|
+
this.once("welcome", () => {
|
|
50
|
+
this.connected = true;
|
|
51
|
+
resolve();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
handleMessage(message) {
|
|
56
|
+
const { type, data, message: msg } = message;
|
|
57
|
+
switch (type) {
|
|
58
|
+
case "welcome":
|
|
59
|
+
this.emit("welcome", msg);
|
|
60
|
+
break;
|
|
61
|
+
case "output":
|
|
62
|
+
this.emit("output", data);
|
|
63
|
+
break;
|
|
64
|
+
case "error":
|
|
65
|
+
this.emit("error", new Error(msg || data));
|
|
66
|
+
break;
|
|
67
|
+
case "vars":
|
|
68
|
+
this.emit("vars", data);
|
|
69
|
+
break;
|
|
70
|
+
case "state":
|
|
71
|
+
this.emit("state", data);
|
|
72
|
+
break;
|
|
73
|
+
case "shutdown":
|
|
74
|
+
this.emit("shutdown");
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
this.emit("message", message);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async execute(command) {
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
if (!this.socket) {
|
|
83
|
+
reject(new Error("Not connected to session: socket is null"));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!this.connected) {
|
|
87
|
+
reject(new Error("Not connected to session: connected flag is false"));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.send({ type: "execute", data: { command } });
|
|
91
|
+
const timeout = setTimeout(() => {
|
|
92
|
+
reject(new Error("Execution timeout"));
|
|
93
|
+
}, 3e4);
|
|
94
|
+
const onOutput = (output) => {
|
|
95
|
+
clearTimeout(timeout);
|
|
96
|
+
this.off("error", onError);
|
|
97
|
+
resolve(output);
|
|
98
|
+
};
|
|
99
|
+
const onError = (error) => {
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
this.off("output", onOutput);
|
|
102
|
+
reject(error);
|
|
103
|
+
};
|
|
104
|
+
this.once("output", onOutput);
|
|
105
|
+
this.once("error", onError);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async getVars() {
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
if (!this.connected || !this.socket) {
|
|
111
|
+
reject(new Error("Not connected to session"));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.send({ type: "getVars" });
|
|
115
|
+
const timeout = setTimeout(() => {
|
|
116
|
+
reject(new Error("Timeout getting variables"));
|
|
117
|
+
}, 5e3);
|
|
118
|
+
const onVars = (vars) => {
|
|
119
|
+
clearTimeout(timeout);
|
|
120
|
+
resolve(vars);
|
|
121
|
+
};
|
|
122
|
+
this.once("vars", onVars);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
async getState() {
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
if (!this.socket) {
|
|
128
|
+
reject(new Error("Not connected to session: socket is null"));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!this.connected) {
|
|
132
|
+
reject(new Error("Not connected to session: connected flag is false"));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.send({ type: "getState" });
|
|
136
|
+
const timeout = setTimeout(() => {
|
|
137
|
+
reject(new Error("Timeout getting state"));
|
|
138
|
+
}, 5e3);
|
|
139
|
+
const onState = (state) => {
|
|
140
|
+
clearTimeout(timeout);
|
|
141
|
+
resolve(state);
|
|
142
|
+
};
|
|
143
|
+
this.once("state", onState);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async shutdown() {
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
if (!this.connected || !this.socket) {
|
|
149
|
+
resolve();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.send({ type: "shutdown" });
|
|
153
|
+
this.once("shutdown", () => {
|
|
154
|
+
resolve();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
send(message) {
|
|
159
|
+
if (!this.socket || !this.connected) {
|
|
160
|
+
throw new Error("Not connected to session");
|
|
161
|
+
}
|
|
162
|
+
this.socket.write(JSON.stringify(message) + "\n");
|
|
163
|
+
}
|
|
164
|
+
disconnect() {
|
|
165
|
+
if (this.socket) {
|
|
166
|
+
this.socket.end();
|
|
167
|
+
this.socket = null;
|
|
168
|
+
}
|
|
169
|
+
this.connected = false;
|
|
170
|
+
}
|
|
171
|
+
isConnected() {
|
|
172
|
+
return this.connected;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
export {
|
|
176
|
+
SessionClient
|
|
177
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SessionServer,
|
|
3
|
+
getSocketPath,
|
|
4
|
+
isSessionRunning
|
|
5
|
+
} from "./chunk-AU3YU63U.js";
|
|
6
|
+
import "./chunk-ZAA6R2TC.js";
|
|
7
|
+
import "./chunk-HRHAMPOB.js";
|
|
8
|
+
import "./chunk-NKA6ZJDV.js";
|
|
9
|
+
import "./chunk-3UW6GWYQ.js";
|
|
10
|
+
export {
|
|
11
|
+
SessionServer,
|
|
12
|
+
getSocketPath,
|
|
13
|
+
isSessionRunning
|
|
14
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-AJSYOXXZ.js";
|
|
5
5
|
import {
|
|
6
6
|
integrate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZAA6R2TC.js";
|
|
8
8
|
import {
|
|
9
9
|
DiracParser
|
|
10
10
|
} from "./chunk-HRHAMPOB.js";
|
|
@@ -23,6 +23,7 @@ var HISTORY_FILE = path.join(os.homedir(), ".dirac_history");
|
|
|
23
23
|
var MAX_HISTORY = 1e3;
|
|
24
24
|
var DiracShell = class {
|
|
25
25
|
session;
|
|
26
|
+
client = null;
|
|
26
27
|
braketParser;
|
|
27
28
|
xmlParser;
|
|
28
29
|
rl;
|
|
@@ -45,6 +46,12 @@ var DiracShell = class {
|
|
|
45
46
|
this.loadHistory();
|
|
46
47
|
this.setupHandlers();
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Set client for daemon mode
|
|
51
|
+
*/
|
|
52
|
+
setClient(client) {
|
|
53
|
+
this.client = client;
|
|
54
|
+
}
|
|
48
55
|
completer(line) {
|
|
49
56
|
const attrMatch = line.match(/\|([a-z0-9_-]+)\s+.*?([a-z0-9_-]*)$/i);
|
|
50
57
|
if (attrMatch) {
|
|
@@ -150,7 +157,10 @@ var DiracShell = class {
|
|
|
150
157
|
});
|
|
151
158
|
this.rl.on("close", () => {
|
|
152
159
|
this.saveHistory();
|
|
153
|
-
|
|
160
|
+
if (this.client) {
|
|
161
|
+
this.client.disconnect();
|
|
162
|
+
}
|
|
163
|
+
import("./schedule-QZ5U3YBS.js").then(({ stopAllScheduledTasks }) => {
|
|
154
164
|
stopAllScheduledTasks();
|
|
155
165
|
console.log("\nGoodbye!");
|
|
156
166
|
process.exit(0);
|
|
@@ -249,6 +259,17 @@ var DiracShell = class {
|
|
|
249
259
|
this.inputBuffer = [];
|
|
250
260
|
this.baseIndent = null;
|
|
251
261
|
try {
|
|
262
|
+
if (this.client) {
|
|
263
|
+
const xml2 = this.braketParser.parse(input);
|
|
264
|
+
if (this.config.debug) {
|
|
265
|
+
console.log("[Debug] Sending to agent:\n", xml2);
|
|
266
|
+
}
|
|
267
|
+
const output = await this.client.execute(xml2);
|
|
268
|
+
if (output) {
|
|
269
|
+
console.log(output);
|
|
270
|
+
}
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
252
273
|
this.session.output = [];
|
|
253
274
|
const xml = this.braketParser.parse(input);
|
|
254
275
|
if (this.config.debug) {
|
|
@@ -291,6 +312,12 @@ Commands:
|
|
|
291
312
|
:tasks List all scheduled tasks
|
|
292
313
|
:stop <name> Stop a scheduled task
|
|
293
314
|
:stopall Stop all scheduled tasks
|
|
315
|
+
:crons List all cron jobs
|
|
316
|
+
:stopcron <name> Stop a cron job
|
|
317
|
+
:stopallcrons Stop all cron jobs
|
|
318
|
+
:scheduled List all scheduled runs (run-at)
|
|
319
|
+
:cancel <name> Cancel a scheduled run
|
|
320
|
+
:cancelall Cancel all scheduled runs
|
|
294
321
|
:exit Exit shell
|
|
295
322
|
|
|
296
323
|
Syntax:
|
|
@@ -315,29 +342,56 @@ Examples:
|
|
|
315
342
|
`);
|
|
316
343
|
break;
|
|
317
344
|
case "vars":
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
345
|
+
try {
|
|
346
|
+
let variables;
|
|
347
|
+
if (this.client) {
|
|
348
|
+
const state = await this.client.getState();
|
|
349
|
+
variables = state.variables || [];
|
|
350
|
+
} else {
|
|
351
|
+
variables = this.session.variables;
|
|
352
|
+
}
|
|
353
|
+
if (variables.length === 0) {
|
|
354
|
+
console.log("No variables defined");
|
|
355
|
+
} else {
|
|
356
|
+
console.log("Variables:");
|
|
357
|
+
for (const v of variables) {
|
|
358
|
+
if (v.visible) {
|
|
359
|
+
console.log(` ${v.name} = ${JSON.stringify(v.value)}`);
|
|
360
|
+
}
|
|
325
361
|
}
|
|
326
362
|
}
|
|
363
|
+
} catch (error) {
|
|
364
|
+
console.error("Error getting variables:", error instanceof Error ? error.message : String(error));
|
|
327
365
|
}
|
|
328
366
|
break;
|
|
329
367
|
case "subs":
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
368
|
+
try {
|
|
369
|
+
let subroutines;
|
|
370
|
+
if (this.client) {
|
|
371
|
+
const state = await this.client.getState();
|
|
372
|
+
console.log("State received:", JSON.stringify(state, null, 2).substring(0, 500));
|
|
373
|
+
subroutines = state.subroutines || [];
|
|
374
|
+
} else {
|
|
375
|
+
subroutines = this.session.subroutines;
|
|
376
|
+
}
|
|
377
|
+
if (!Array.isArray(subroutines)) {
|
|
378
|
+
console.error("Error: subroutines is not an array, it is:", typeof subroutines);
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
if (subroutines.length === 0) {
|
|
382
|
+
console.log("No subroutines defined");
|
|
383
|
+
} else {
|
|
384
|
+
console.log("Subroutines:");
|
|
385
|
+
for (const s of subroutines) {
|
|
386
|
+
const params = s.parameters?.map((p) => p.name).join(", ") || "";
|
|
387
|
+
console.log(` ${s.name}(${params})`);
|
|
388
|
+
if (s.description) {
|
|
389
|
+
console.log(` ${s.description}`);
|
|
390
|
+
}
|
|
339
391
|
}
|
|
340
392
|
}
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.error("Error getting subroutines:", error instanceof Error ? error.message : String(error));
|
|
341
395
|
}
|
|
342
396
|
break;
|
|
343
397
|
case "clear":
|
|
@@ -471,7 +525,7 @@ Examples:
|
|
|
471
525
|
break;
|
|
472
526
|
case "tasks":
|
|
473
527
|
try {
|
|
474
|
-
const { listScheduledTasks } = await import("./schedule-
|
|
528
|
+
const { listScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
|
|
475
529
|
const tasks = listScheduledTasks();
|
|
476
530
|
if (tasks.length === 0) {
|
|
477
531
|
console.log("No scheduled tasks running.");
|
|
@@ -490,7 +544,7 @@ Examples:
|
|
|
490
544
|
console.log("Usage: :stop <task-name>");
|
|
491
545
|
} else {
|
|
492
546
|
try {
|
|
493
|
-
const { stopScheduledTask } = await import("./schedule-
|
|
547
|
+
const { stopScheduledTask } = await import("./schedule-QZ5U3YBS.js");
|
|
494
548
|
const taskName = args[0];
|
|
495
549
|
const stopped = stopScheduledTask(taskName);
|
|
496
550
|
if (stopped) {
|
|
@@ -505,13 +559,101 @@ Examples:
|
|
|
505
559
|
break;
|
|
506
560
|
case "stopall":
|
|
507
561
|
try {
|
|
508
|
-
const { stopAllScheduledTasks } = await import("./schedule-
|
|
562
|
+
const { stopAllScheduledTasks } = await import("./schedule-QZ5U3YBS.js");
|
|
509
563
|
stopAllScheduledTasks();
|
|
510
564
|
console.log("All scheduled tasks stopped.");
|
|
511
565
|
} catch (error) {
|
|
512
566
|
console.error("Error stopping tasks:", error instanceof Error ? error.message : String(error));
|
|
513
567
|
}
|
|
514
568
|
break;
|
|
569
|
+
case "crons":
|
|
570
|
+
try {
|
|
571
|
+
const { listCronJobs } = await import("./cron-BQIWLGQY.js");
|
|
572
|
+
const jobs = listCronJobs();
|
|
573
|
+
if (jobs.length === 0) {
|
|
574
|
+
console.log("No cron jobs running.");
|
|
575
|
+
} else {
|
|
576
|
+
console.log("\nCron Jobs:");
|
|
577
|
+
for (const job of jobs) {
|
|
578
|
+
const status = job.isRunning ? "(running)" : "";
|
|
579
|
+
console.log(` - ${job.name}: ${job.cronExpression} ${status}`);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
} catch (error) {
|
|
583
|
+
console.error("Error listing cron jobs:", error instanceof Error ? error.message : String(error));
|
|
584
|
+
}
|
|
585
|
+
break;
|
|
586
|
+
case "stopcron":
|
|
587
|
+
if (args.length === 0) {
|
|
588
|
+
console.log("Usage: :stopcron <job-name>");
|
|
589
|
+
} else {
|
|
590
|
+
try {
|
|
591
|
+
const { stopCronJob } = await import("./cron-BQIWLGQY.js");
|
|
592
|
+
const jobName = args[0];
|
|
593
|
+
const stopped = stopCronJob(jobName);
|
|
594
|
+
if (stopped) {
|
|
595
|
+
console.log(`Stopped cron job: ${jobName}`);
|
|
596
|
+
} else {
|
|
597
|
+
console.log(`Cron job not found: ${jobName}`);
|
|
598
|
+
}
|
|
599
|
+
} catch (error) {
|
|
600
|
+
console.error("Error stopping cron job:", error instanceof Error ? error.message : String(error));
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
break;
|
|
604
|
+
case "stopallcrons":
|
|
605
|
+
try {
|
|
606
|
+
const { stopAllCronJobs } = await import("./cron-BQIWLGQY.js");
|
|
607
|
+
stopAllCronJobs();
|
|
608
|
+
console.log("All cron jobs stopped.");
|
|
609
|
+
} catch (error) {
|
|
610
|
+
console.error("Error stopping cron jobs:", error instanceof Error ? error.message : String(error));
|
|
611
|
+
}
|
|
612
|
+
break;
|
|
613
|
+
case "scheduled":
|
|
614
|
+
try {
|
|
615
|
+
const { listScheduledRuns } = await import("./run-at-KDJYTEOD.js");
|
|
616
|
+
const runs = listScheduledRuns();
|
|
617
|
+
if (runs.length === 0) {
|
|
618
|
+
console.log("No scheduled runs pending.");
|
|
619
|
+
} else {
|
|
620
|
+
console.log("\nScheduled Runs:");
|
|
621
|
+
for (const run of runs) {
|
|
622
|
+
const status = run.isRunning ? "(running)" : "";
|
|
623
|
+
console.log(` - ${run.name}: ${run.scheduledTime.toLocaleString()} ${status}`);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
} catch (error) {
|
|
627
|
+
console.error("Error listing scheduled runs:", error instanceof Error ? error.message : String(error));
|
|
628
|
+
}
|
|
629
|
+
break;
|
|
630
|
+
case "cancel":
|
|
631
|
+
if (args.length === 0) {
|
|
632
|
+
console.log("Usage: :cancel <run-name>");
|
|
633
|
+
} else {
|
|
634
|
+
try {
|
|
635
|
+
const { cancelScheduledRun } = await import("./run-at-KDJYTEOD.js");
|
|
636
|
+
const runName = args[0];
|
|
637
|
+
const cancelled = cancelScheduledRun(runName);
|
|
638
|
+
if (cancelled) {
|
|
639
|
+
console.log(`Cancelled scheduled run: ${runName}`);
|
|
640
|
+
} else {
|
|
641
|
+
console.log(`Scheduled run not found: ${runName}`);
|
|
642
|
+
}
|
|
643
|
+
} catch (error) {
|
|
644
|
+
console.error("Error cancelling run:", error instanceof Error ? error.message : String(error));
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
break;
|
|
648
|
+
case "cancelall":
|
|
649
|
+
try {
|
|
650
|
+
const { cancelAllScheduledRuns } = await import("./run-at-KDJYTEOD.js");
|
|
651
|
+
cancelAllScheduledRuns();
|
|
652
|
+
console.log("All scheduled runs cancelled.");
|
|
653
|
+
} catch (error) {
|
|
654
|
+
console.error("Error cancelling runs:", error instanceof Error ? error.message : String(error));
|
|
655
|
+
}
|
|
656
|
+
break;
|
|
515
657
|
case "exit":
|
|
516
658
|
case "quit":
|
|
517
659
|
this.rl.close();
|
|
@@ -542,6 +684,7 @@ Examples:
|
|
|
542
684
|
}
|
|
543
685
|
/**
|
|
544
686
|
* Execute a Unix shell command
|
|
687
|
+
* If command is not found, fallback to treating it as an AI query
|
|
545
688
|
*/
|
|
546
689
|
async executeShellCommand(command) {
|
|
547
690
|
const trimmed = command.trim();
|
|
@@ -558,14 +701,29 @@ Examples:
|
|
|
558
701
|
}
|
|
559
702
|
const { spawn } = await import("child_process");
|
|
560
703
|
this.rl.pause();
|
|
561
|
-
return new Promise((resolve2) => {
|
|
704
|
+
return new Promise(async (resolve2) => {
|
|
562
705
|
const shell = process.env.SHELL || "/bin/sh";
|
|
563
706
|
const child = spawn(shell, ["-c", command], {
|
|
564
|
-
stdio: "inherit",
|
|
707
|
+
stdio: ["inherit", "inherit", "pipe"],
|
|
565
708
|
cwd: process.cwd()
|
|
566
709
|
});
|
|
567
|
-
|
|
710
|
+
let stderrData = "";
|
|
711
|
+
child.stderr?.on("data", (data) => {
|
|
712
|
+
stderrData += data.toString();
|
|
713
|
+
process.stderr.write(data);
|
|
714
|
+
});
|
|
715
|
+
child.on("close", async (code) => {
|
|
568
716
|
this.rl.resume();
|
|
717
|
+
const commandNotFound = code === 127 || stderrData.includes("command not found");
|
|
718
|
+
if (commandNotFound) {
|
|
719
|
+
console.log(`\u{1F4A1} Command not found, trying as AI query...`);
|
|
720
|
+
if (this.config.debug) {
|
|
721
|
+
console.log(`[executing: |ai>${trimmed}]`);
|
|
722
|
+
}
|
|
723
|
+
const aiInput = `|ai>${trimmed}`;
|
|
724
|
+
this.inputBuffer = [aiInput];
|
|
725
|
+
await this.executeBuffer();
|
|
726
|
+
}
|
|
569
727
|
resolve2();
|
|
570
728
|
});
|
|
571
729
|
child.on("error", (err) => {
|
|
@@ -599,9 +757,14 @@ Examples:
|
|
|
599
757
|
}
|
|
600
758
|
console.log(`Loading init script: ${scriptPath}`);
|
|
601
759
|
const scriptContent = fs.readFileSync(resolvedPath, "utf-8");
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
760
|
+
if (this.client) {
|
|
761
|
+
const xml = this.braketParser.parse(scriptContent);
|
|
762
|
+
await this.client.execute(xml);
|
|
763
|
+
} else {
|
|
764
|
+
const xml = this.braketParser.parse(scriptContent);
|
|
765
|
+
const ast = this.xmlParser.parse(xml);
|
|
766
|
+
await integrate(this.session, ast);
|
|
767
|
+
}
|
|
605
768
|
console.log(`Init script loaded.
|
|
606
769
|
`);
|
|
607
770
|
} catch (err) {
|
package/dist/test-runner.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirac-lang",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
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",
|