@iletai/nzb 1.6.1 → 1.6.2
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/copilot/orchestrator.js +17 -5
- package/package.json +2 -2
|
@@ -31,6 +31,8 @@ let healthCheckTimer;
|
|
|
31
31
|
let orchestratorSession;
|
|
32
32
|
// Coalesces concurrent ensureOrchestratorSession calls
|
|
33
33
|
let sessionCreatePromise;
|
|
34
|
+
// Tracks in-flight context recovery injection so we don't race with real messages
|
|
35
|
+
let recoveryInjectionPromise;
|
|
34
36
|
const messageQueue = [];
|
|
35
37
|
let processing = false;
|
|
36
38
|
let currentCallback;
|
|
@@ -244,16 +246,22 @@ async function createOrResumeSession() {
|
|
|
244
246
|
setState(ORCHESTRATOR_SESSION_KEY, session.sessionId);
|
|
245
247
|
console.log(`[nzb] Created orchestrator session ${session.sessionId.slice(0, 8)}…`);
|
|
246
248
|
// Recover conversation context if available (session was lost, not first run)
|
|
247
|
-
//
|
|
249
|
+
// Runs concurrently but is awaited before any real message is sent on the session
|
|
248
250
|
const recentHistory = getRecentConversation(10);
|
|
249
251
|
if (recentHistory) {
|
|
250
|
-
console.log(`[nzb] Injecting recent conversation context into new session
|
|
251
|
-
session
|
|
252
|
+
console.log(`[nzb] Injecting recent conversation context into new session`);
|
|
253
|
+
recoveryInjectionPromise = session
|
|
252
254
|
.sendAndWait({
|
|
253
255
|
prompt: `[System: Session recovered] Your previous session was lost. Here's the recent conversation for context — do NOT respond to these messages, just absorb the context silently:\n\n${recentHistory}\n\n(End of recovery context. Wait for the next real message.)`,
|
|
254
256
|
}, 20_000)
|
|
257
|
+
.then(() => {
|
|
258
|
+
console.log(`[nzb] Context recovery injection completed`);
|
|
259
|
+
})
|
|
255
260
|
.catch((err) => {
|
|
256
261
|
console.log(`[nzb] Context recovery injection failed (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
262
|
+
})
|
|
263
|
+
.finally(() => {
|
|
264
|
+
recoveryInjectionPromise = undefined;
|
|
257
265
|
});
|
|
258
266
|
}
|
|
259
267
|
return session;
|
|
@@ -291,6 +299,11 @@ export async function initOrchestrator(client) {
|
|
|
291
299
|
/** Send a prompt on the persistent session, return the response. */
|
|
292
300
|
async function executeOnSession(prompt, callback, onToolEvent, onUsage) {
|
|
293
301
|
const session = await ensureOrchestratorSession();
|
|
302
|
+
// Wait for any in-flight context recovery injection to finish before sending
|
|
303
|
+
if (recoveryInjectionPromise) {
|
|
304
|
+
console.log(`[nzb] Waiting for context recovery injection to complete before sending…`);
|
|
305
|
+
await recoveryInjectionPromise;
|
|
306
|
+
}
|
|
294
307
|
currentCallback = callback;
|
|
295
308
|
let accumulated = "";
|
|
296
309
|
let toolCallExecuted = false;
|
|
@@ -479,8 +492,7 @@ export async function sendToOrchestrator(prompt, source, callback, onToolEvent,
|
|
|
479
492
|
await callback(finalContent, true, { assistantLogId });
|
|
480
493
|
// Auto-continue: if the response was cut short by timeout, automatically
|
|
481
494
|
// send a follow-up "Continue" message so the user doesn't have to
|
|
482
|
-
if (finalContent.includes("⏱ Response was cut short (timeout)") &&
|
|
483
|
-
_autoContinueCount < MAX_AUTO_CONTINUE) {
|
|
495
|
+
if (finalContent.includes("⏱ Response was cut short (timeout)") && _autoContinueCount < MAX_AUTO_CONTINUE) {
|
|
484
496
|
console.log(`[nzb] Auto-continuing after timeout (${_autoContinueCount + 1}/${MAX_AUTO_CONTINUE})…`);
|
|
485
497
|
await sleep(1000);
|
|
486
498
|
void sendToOrchestrator("Continue from where you left off. Do not repeat what was already said.", source, callback, onToolEvent, onUsage, _autoContinueCount + 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iletai/nzb",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "NZB — a personal AI assistant for developers, built on the GitHub Copilot SDK",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nzb": "dist/cli.js"
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"typescript": "^5.9.3",
|
|
70
70
|
"vitest": "^4.1.0"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|