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
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
8
|
-
import "./chunk-
|
|
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.
|
|
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",
|
|
@@ -72,9 +75,22 @@ async function main() {
|
|
|
72
75
|
if (args.includes("--help") || args.includes("-h")) {
|
|
73
76
|
console.log("Usage: dirac <file.di|file.bk>");
|
|
74
77
|
console.log(" dirac shell [options]");
|
|
78
|
+
console.log(" dirac agent <command>");
|
|
75
79
|
console.log("");
|
|
76
80
|
console.log("Commands:");
|
|
77
81
|
console.log(" shell Start interactive shell (REPL)");
|
|
82
|
+
console.log(" shell --agent Connect shell to running agent daemon");
|
|
83
|
+
console.log(" agent start Start persistent agent daemon");
|
|
84
|
+
console.log(" agent stop Stop agent daemon");
|
|
85
|
+
console.log(" agent status Check agent status");
|
|
86
|
+
console.log(" agent restart Restart agent daemon");
|
|
87
|
+
console.log(" agent logs Show agent logs");
|
|
88
|
+
console.log(" shell --daemon Start shell with persistent daemon (experimental)");
|
|
89
|
+
console.log("");
|
|
90
|
+
console.log("Shell tips:");
|
|
91
|
+
console.log(" Press Ctrl-Z to suspend shell, then `bg` to run in background");
|
|
92
|
+
console.log(" Use `fg` to bring it back to foreground");
|
|
93
|
+
console.log(" Cron jobs and run-at tasks continue running in background");
|
|
78
94
|
console.log("");
|
|
79
95
|
console.log("File formats:");
|
|
80
96
|
console.log(" .di XML notation (verbose)");
|
|
@@ -95,13 +111,54 @@ async function main() {
|
|
|
95
111
|
console.log(package_default.version);
|
|
96
112
|
process.exit(0);
|
|
97
113
|
}
|
|
114
|
+
if (args[0] === "agent") {
|
|
115
|
+
const subcommand = args[1];
|
|
116
|
+
if (subcommand === "daemon") {
|
|
117
|
+
const { runAgentDaemon } = await import("./agent-OXQZBLNQ.js");
|
|
118
|
+
await runAgentDaemon();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const { AgentCLI } = await import("./agent-OXQZBLNQ.js");
|
|
122
|
+
const agent = new AgentCLI();
|
|
123
|
+
switch (subcommand) {
|
|
124
|
+
case "start":
|
|
125
|
+
await agent.start();
|
|
126
|
+
break;
|
|
127
|
+
case "stop":
|
|
128
|
+
await agent.stop();
|
|
129
|
+
break;
|
|
130
|
+
case "status":
|
|
131
|
+
await agent.status();
|
|
132
|
+
break;
|
|
133
|
+
case "restart":
|
|
134
|
+
await agent.restart();
|
|
135
|
+
break;
|
|
136
|
+
case "logs":
|
|
137
|
+
const follow = args.includes("-f") || args.includes("--follow");
|
|
138
|
+
await agent.logs(follow);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
console.error("Unknown agent command:", subcommand);
|
|
142
|
+
console.error("Available commands: start, stop, status, restart, logs");
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
98
147
|
if (args[0] === "shell") {
|
|
99
|
-
const { DiracShell } = await import("./shell-
|
|
148
|
+
const { DiracShell } = await import("./shell-OFBL57OA.js");
|
|
149
|
+
const { SessionServer, isSessionRunning, getSocketPath } = await import("./session-server-QZN2RMYD.js");
|
|
150
|
+
const { SessionClient } = await import("./session-client-3VTC5MLO.js");
|
|
151
|
+
const daemonMode = args.includes("--daemon") || args.includes("-d");
|
|
152
|
+
const agentMode = args.includes("--agent") || args.includes("-a");
|
|
100
153
|
const shellConfig = { debug: false };
|
|
101
154
|
for (let i = 1; i < args.length; i++) {
|
|
102
155
|
const arg = args[i];
|
|
103
156
|
if (arg === "--debug") {
|
|
104
157
|
shellConfig.debug = true;
|
|
158
|
+
} else if (arg === "--daemon" || arg === "-d") {
|
|
159
|
+
continue;
|
|
160
|
+
} else if (arg === "--agent" || arg === "-a") {
|
|
161
|
+
continue;
|
|
105
162
|
} else if ((arg === "-f" || arg === "--config") && i + 1 < args.length) {
|
|
106
163
|
const configPath = resolve(args[++i]);
|
|
107
164
|
if (fs.existsSync(configPath)) {
|
|
@@ -128,10 +185,59 @@ async function main() {
|
|
|
128
185
|
}
|
|
129
186
|
}
|
|
130
187
|
}
|
|
188
|
+
if (agentMode) {
|
|
189
|
+
if (!isSessionRunning()) {
|
|
190
|
+
console.error("Error: No agent is running");
|
|
191
|
+
console.error("Start the agent first with: dirac agent start");
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
console.log("Connecting to agent...");
|
|
195
|
+
const client = new SessionClient({ socketPath: getSocketPath() });
|
|
196
|
+
client.on("error", (error) => {
|
|
197
|
+
console.error("Agent error:", error);
|
|
198
|
+
});
|
|
199
|
+
try {
|
|
200
|
+
await client.connect();
|
|
201
|
+
console.log("Connected to agent at", getSocketPath());
|
|
202
|
+
console.log("Session state is persistent across disconnects");
|
|
203
|
+
console.log("");
|
|
204
|
+
const shell2 = new DiracShell(shellConfig);
|
|
205
|
+
shell2.setClient(client);
|
|
206
|
+
process.on("SIGINT", async () => {
|
|
207
|
+
await client.disconnect();
|
|
208
|
+
process.exit(0);
|
|
209
|
+
});
|
|
210
|
+
await shell2.start();
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error("Failed to connect to agent:", error);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (daemonMode) {
|
|
218
|
+
console.log("Note: Daemon mode is under development.");
|
|
219
|
+
console.log("For now, use Ctrl-Z + bg to background the shell.");
|
|
220
|
+
console.log("");
|
|
221
|
+
}
|
|
131
222
|
const shell = new DiracShell(shellConfig);
|
|
132
223
|
await shell.start();
|
|
133
224
|
return;
|
|
134
225
|
}
|
|
226
|
+
if (args[0] === "daemon") {
|
|
227
|
+
const { SessionServer } = await import("./session-server-QZN2RMYD.js");
|
|
228
|
+
const server = new SessionServer();
|
|
229
|
+
await server.start();
|
|
230
|
+
console.log("Session daemon started");
|
|
231
|
+
process.on("SIGINT", async () => {
|
|
232
|
+
await server.shutdown();
|
|
233
|
+
process.exit(0);
|
|
234
|
+
});
|
|
235
|
+
process.on("SIGTERM", async () => {
|
|
236
|
+
await server.shutdown();
|
|
237
|
+
process.exit(0);
|
|
238
|
+
});
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
135
241
|
if (args.length === 0) {
|
|
136
242
|
console.error("Usage: dirac <file.di|file.bk>");
|
|
137
243
|
console.error(" dirac shell [options]");
|
|
@@ -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-
|
|
5
|
+
} from "./chunk-BMKPKK7M.js";
|
|
6
6
|
import {
|
|
7
7
|
integrate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZAA6R2TC.js";
|
|
9
9
|
import {
|
|
10
10
|
DiracParser
|
|
11
11
|
} from "./chunk-HRHAMPOB.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
|
+
};
|