lunel-cli 0.1.102 → 0.1.104
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/ai/index.js +2 -1
- package/dist/index.js +36 -12
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export class AiManager {
|
|
|
11
11
|
this.tryInit("codex"),
|
|
12
12
|
]);
|
|
13
13
|
if (this._available.length === 0) {
|
|
14
|
-
|
|
14
|
+
console.warn("[ai] No AI backends available. CLI will continue without AI features.");
|
|
15
|
+
return;
|
|
15
16
|
}
|
|
16
17
|
if (DEBUG_MODE) {
|
|
17
18
|
console.log(`[ai] Available backends: ${this._available.join(", ")}`);
|
package/dist/index.js
CHANGED
|
@@ -76,6 +76,7 @@ const processOutputBuffers = new Map();
|
|
|
76
76
|
let lastCpuInfo = null;
|
|
77
77
|
// AI manager — runs OpenCode and Codex simultaneously, routes by backend
|
|
78
78
|
let aiManager = null;
|
|
79
|
+
let aiManagerInitPromise = null;
|
|
79
80
|
// Proxy tunnel management
|
|
80
81
|
let currentSessionCode = null;
|
|
81
82
|
let currentSessionPassword = null;
|
|
@@ -2957,6 +2958,38 @@ function gracefulShutdown() {
|
|
|
2957
2958
|
cleanupAllTunnels();
|
|
2958
2959
|
process.exit(0);
|
|
2959
2960
|
}
|
|
2961
|
+
function startAiManagerInBackground() {
|
|
2962
|
+
if (aiManager || aiManagerInitPromise)
|
|
2963
|
+
return;
|
|
2964
|
+
aiManagerInitPromise = (async () => {
|
|
2965
|
+
try {
|
|
2966
|
+
const manager = await createAiManager();
|
|
2967
|
+
if (shuttingDown) {
|
|
2968
|
+
await manager.destroy();
|
|
2969
|
+
return;
|
|
2970
|
+
}
|
|
2971
|
+
aiManager = manager;
|
|
2972
|
+
aiManager.subscribe((backend, event) => {
|
|
2973
|
+
emitAppEvent({
|
|
2974
|
+
v: 1,
|
|
2975
|
+
id: `evt-${Date.now()}`,
|
|
2976
|
+
ns: "ai",
|
|
2977
|
+
action: "event",
|
|
2978
|
+
payload: { ...event, backend },
|
|
2979
|
+
});
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
catch (error) {
|
|
2983
|
+
if (DEBUG_MODE) {
|
|
2984
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2985
|
+
console.error(`[ai] background init failed: ${message}`);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
finally {
|
|
2989
|
+
aiManagerInitPromise = null;
|
|
2990
|
+
}
|
|
2991
|
+
})();
|
|
2992
|
+
}
|
|
2960
2993
|
async function connectWebSocketV2() {
|
|
2961
2994
|
const gatewayUrl = currentPrimaryGateway;
|
|
2962
2995
|
if (!currentSessionPassword) {
|
|
@@ -3079,18 +3112,9 @@ async function main() {
|
|
|
3079
3112
|
else {
|
|
3080
3113
|
debugLog(`PTY runtime unsupported on ${os.platform()}/${os.arch()}. Skipping prefetch.\n`);
|
|
3081
3114
|
}
|
|
3082
|
-
// Start
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
aiManager.subscribe((backend, event) => {
|
|
3086
|
-
emitAppEvent({
|
|
3087
|
-
v: 1,
|
|
3088
|
-
id: `evt-${Date.now()}`,
|
|
3089
|
-
ns: "ai",
|
|
3090
|
-
action: "event",
|
|
3091
|
-
payload: { ...event, backend },
|
|
3092
|
-
});
|
|
3093
|
-
});
|
|
3115
|
+
// Start AI backends in the background so missing or slow AI runtimes never
|
|
3116
|
+
// block QR/session startup for the rest of the CLI.
|
|
3117
|
+
startAiManagerInBackground();
|
|
3094
3118
|
let sessionCodeToUse = null;
|
|
3095
3119
|
let sessionPasswordToUse;
|
|
3096
3120
|
if (!FORCE_NEW_CODE && savedSession) {
|