lunel-cli 0.1.116 → 0.1.117
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/codex.d.ts +1 -0
- package/dist/ai/codex.js +7 -2
- package/dist/ai/opencode.d.ts +3 -0
- package/dist/ai/opencode.js +25 -10
- package/package.json +1 -1
package/dist/ai/codex.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class CodexProvider implements AIProvider {
|
|
|
14
14
|
private assistantMessageIdByTurnId;
|
|
15
15
|
private partTextById;
|
|
16
16
|
private debugLog;
|
|
17
|
+
private debugHistory;
|
|
17
18
|
init(): Promise<void>;
|
|
18
19
|
destroy(): Promise<void>;
|
|
19
20
|
subscribe(emitter: AiEventEmitter): () => void;
|
package/dist/ai/codex.js
CHANGED
|
@@ -57,6 +57,11 @@ export class CodexProvider {
|
|
|
57
57
|
const suffix = fields ? ` ${JSON.stringify(fields)}` : "";
|
|
58
58
|
console.log(`[codex] ${message}${suffix}`);
|
|
59
59
|
}
|
|
60
|
+
debugHistory(message, fields) {
|
|
61
|
+
if (!DEBUG_MODE)
|
|
62
|
+
return;
|
|
63
|
+
console.log(`[codex-history] ${message} ${JSON.stringify(fields)}`);
|
|
64
|
+
}
|
|
60
65
|
async init() {
|
|
61
66
|
if (DEBUG_MODE)
|
|
62
67
|
console.log("Starting Codex app-server...");
|
|
@@ -1337,12 +1342,12 @@ export class CodexProvider {
|
|
|
1337
1342
|
}),
|
|
1338
1343
|
};
|
|
1339
1344
|
});
|
|
1340
|
-
|
|
1345
|
+
this.debugHistory("thread/read summary", {
|
|
1341
1346
|
sessionId,
|
|
1342
1347
|
threadId: this.readString(threadObject.id) ?? null,
|
|
1343
1348
|
turnCount: turns.length,
|
|
1344
1349
|
turnSummaries,
|
|
1345
|
-
})
|
|
1350
|
+
});
|
|
1346
1351
|
}
|
|
1347
1352
|
decodeStoredToolLikePart(type, itemObject, threadId, messageId, itemId) {
|
|
1348
1353
|
if (type === "filechange" || type === "diff" || this.isFileChangeStructuredItem(type, itemObject)) {
|
package/dist/ai/opencode.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare class OpenCodeProvider implements AIProvider {
|
|
|
8
8
|
private emitter;
|
|
9
9
|
private knownPendingPermissionIds;
|
|
10
10
|
private knownPendingQuestionIds;
|
|
11
|
+
private debugLog;
|
|
12
|
+
private debugWarn;
|
|
13
|
+
private debugError;
|
|
11
14
|
init(): Promise<void>;
|
|
12
15
|
destroy(): Promise<void>;
|
|
13
16
|
subscribe(emitter: AiEventEmitter): () => void;
|
package/dist/ai/opencode.js
CHANGED
|
@@ -262,6 +262,21 @@ export class OpenCodeProvider {
|
|
|
262
262
|
emitter = null;
|
|
263
263
|
knownPendingPermissionIds = new Set();
|
|
264
264
|
knownPendingQuestionIds = new Set();
|
|
265
|
+
debugLog(message, ...args) {
|
|
266
|
+
if (!VERBOSE_AI_LOGS)
|
|
267
|
+
return;
|
|
268
|
+
console.log(message, ...args);
|
|
269
|
+
}
|
|
270
|
+
debugWarn(message, ...args) {
|
|
271
|
+
if (!VERBOSE_AI_LOGS)
|
|
272
|
+
return;
|
|
273
|
+
console.warn(message, ...args);
|
|
274
|
+
}
|
|
275
|
+
debugError(message, ...args) {
|
|
276
|
+
if (!VERBOSE_AI_LOGS)
|
|
277
|
+
return;
|
|
278
|
+
console.error(message, ...args);
|
|
279
|
+
}
|
|
265
280
|
async init() {
|
|
266
281
|
const opencodeUsername = "lunel";
|
|
267
282
|
const opencodePassword = crypto.randomBytes(32).toString("base64url");
|
|
@@ -521,13 +536,13 @@ export class OpenCodeProvider {
|
|
|
521
536
|
path: { id: this.lastActiveSessionId },
|
|
522
537
|
});
|
|
523
538
|
if (checkResp.error) {
|
|
524
|
-
|
|
539
|
+
this.debugWarn(`[sse] OpenCode session ${this.lastActiveSessionId} was garbage-collected. Notifying app.`);
|
|
525
540
|
const gcSessionId = this.lastActiveSessionId;
|
|
526
541
|
this.lastActiveSessionId = null;
|
|
527
542
|
this.emitter?.({ type: "session_gc", properties: { sessionId: gcSessionId } });
|
|
528
543
|
}
|
|
529
544
|
else {
|
|
530
|
-
|
|
545
|
+
this.debugLog(`[sse] Active session ${this.lastActiveSessionId} still valid.`);
|
|
531
546
|
}
|
|
532
547
|
}
|
|
533
548
|
if (attempt > 0) {
|
|
@@ -535,7 +550,7 @@ export class OpenCodeProvider {
|
|
|
535
550
|
}
|
|
536
551
|
const events = await this.client.event.subscribe();
|
|
537
552
|
if (attempt > 0) {
|
|
538
|
-
|
|
553
|
+
this.debugLog(`[sse] reconnected after ${attempt} attempt(s)`);
|
|
539
554
|
}
|
|
540
555
|
attempt = 0;
|
|
541
556
|
for await (const raw of events.stream) {
|
|
@@ -549,11 +564,11 @@ export class OpenCodeProvider {
|
|
|
549
564
|
? parsed.payload
|
|
550
565
|
: parsed;
|
|
551
566
|
if (!base || typeof base.type !== "string") {
|
|
552
|
-
|
|
567
|
+
this.debugWarn("[sse] Dropped malformed event:", redactSensitive(JSON.stringify(parsed).substring(0, 200)));
|
|
553
568
|
continue;
|
|
554
569
|
}
|
|
555
570
|
if (base.type !== "server.heartbeat") {
|
|
556
|
-
|
|
571
|
+
this.debugLog("[sse]", base.type);
|
|
557
572
|
}
|
|
558
573
|
const normalizedEvent = normalizeOpenCodeEvent({
|
|
559
574
|
type: base.type,
|
|
@@ -562,7 +577,7 @@ export class OpenCodeProvider {
|
|
|
562
577
|
this.trackPermissionEvent(normalizedEvent.type, normalizedEvent.properties || {});
|
|
563
578
|
this.emitter?.(normalizedEvent);
|
|
564
579
|
}
|
|
565
|
-
|
|
580
|
+
this.debugLog("[sse] Event stream ended, reconnecting...");
|
|
566
581
|
attempt++;
|
|
567
582
|
}
|
|
568
583
|
catch (err) {
|
|
@@ -570,9 +585,9 @@ export class OpenCodeProvider {
|
|
|
570
585
|
return;
|
|
571
586
|
attempt++;
|
|
572
587
|
const delay = backoffMs(attempt - 1);
|
|
573
|
-
|
|
588
|
+
this.debugError(`[sse] Stream error (attempt ${attempt}/${SSE_MAX_RETRIES}): ${err.message}. Retrying in ${delay}ms`);
|
|
574
589
|
if (attempt >= SSE_MAX_RETRIES) {
|
|
575
|
-
|
|
590
|
+
this.debugError("[sse] Max retries reached. Sending error event to app and giving up.");
|
|
576
591
|
this.emitter?.({
|
|
577
592
|
type: "sse_dead",
|
|
578
593
|
properties: { error: err.message, attempts: attempt },
|
|
@@ -668,10 +683,10 @@ export class OpenCodeProvider {
|
|
|
668
683
|
});
|
|
669
684
|
}
|
|
670
685
|
}
|
|
671
|
-
|
|
686
|
+
this.debugLog(`[sse] Re-synced messages for busy session ${sessionId} after reconnect`);
|
|
672
687
|
}
|
|
673
688
|
catch (err) {
|
|
674
|
-
|
|
689
|
+
this.debugWarn(`[sse] Failed to refresh messages for busy session ${sessionId}:`, err.message);
|
|
675
690
|
}
|
|
676
691
|
}
|
|
677
692
|
}
|