@adhdev/daemon-core 0.8.33 → 0.8.35
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/index.d.ts +1 -1
- package/dist/index.js +127 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -102
- package/dist/index.mjs.map +1 -1
- package/dist/shared-types.d.ts +38 -0
- package/dist/status/reporter.d.ts +3 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/agent-stream/forward.d.ts +8 -0
- package/src/agent-stream/index.d.ts +6 -0
- package/src/agent-stream/manager.d.ts +60 -0
- package/src/agent-stream/poller.d.ts +41 -0
- package/src/agent-stream/provider-adapter.d.ts +36 -0
- package/src/agent-stream/types.d.ts +68 -0
- package/src/boot/daemon-lifecycle.d.ts +100 -0
- package/src/cdp/devtools.d.ts +51 -0
- package/src/cdp/initializer.d.ts +50 -0
- package/src/cdp/manager.d.ts +147 -0
- package/src/cdp/scanner.d.ts +58 -0
- package/src/cdp/setup.d.ts +58 -0
- package/src/cli-adapter-types.d.ts +57 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +177 -0
- package/src/cli-adapters/provider-cli-adapter.ts +115 -91
- package/src/cli-adapters/provider-cli-config.d.ts +30 -0
- package/src/cli-adapters/provider-cli-parse.d.ts +42 -0
- package/src/cli-adapters/provider-cli-runtime.d.ts +29 -0
- package/src/cli-adapters/provider-cli-shared.d.ts +158 -0
- package/src/cli-adapters/pty-transport.d.ts +48 -0
- package/src/cli-adapters/session-host-transport.d.ts +20 -0
- package/src/cli-adapters/spawn-env.d.ts +8 -0
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +16 -0
- package/src/cli-adapters/terminal-backends/types.d.ts +18 -0
- package/src/cli-adapters/terminal-backends/xterm-backend.d.ts +17 -0
- package/src/cli-adapters/terminal-screen.d.ts +33 -0
- package/src/commands/cdp-commands.d.ts +15 -0
- package/src/commands/chat-commands.d.ts +15 -0
- package/src/commands/cli-manager.d.ts +94 -0
- package/src/commands/handler.d.ts +103 -0
- package/src/commands/router.d.ts +98 -0
- package/src/commands/stream-commands.d.ts +14 -0
- package/src/commands/upgrade-helper.d.ts +10 -0
- package/src/commands/workspace-commands.d.ts +11 -0
- package/src/config/chat-history.d.ts +99 -0
- package/src/config/config.d.ts +14 -0
- package/src/config/recent-activity.d.ts +29 -0
- package/src/config/saved-sessions.d.ts +22 -0
- package/src/config/state-store.d.ts +32 -0
- package/src/config/workspaces.d.ts +0 -1
- package/src/daemon/dev-auto-implement.d.ts +43 -0
- package/src/daemon/dev-cdp-handlers.d.ts +22 -0
- package/src/daemon/dev-cli-debug.d.ts +106 -0
- package/src/daemon/dev-server-types.d.ts +43 -0
- package/src/daemon/dev-server.d.ts +140 -0
- package/src/daemon/scaffold-template.d.ts +32 -0
- package/src/daemon-core.d.ts +36 -0
- package/src/detection/cli-detector.d.ts +31 -0
- package/src/detection/ide-detector.d.ts +35 -0
- package/src/index.d.ts +83 -0
- package/src/index.ts +2 -0
- package/src/installer.d.ts +50 -0
- package/src/ipc-protocol.d.ts +111 -0
- package/src/launch.d.ts +46 -0
- package/src/logging/command-log.d.ts +31 -0
- package/src/logging/logger.d.ts +89 -0
- package/src/providers/acp-provider-instance.d.ts +102 -0
- package/src/providers/approval-utils.d.ts +7 -0
- package/src/providers/cli-provider-instance.d.ts +86 -0
- package/src/providers/contracts.d.ts +193 -1
- package/src/providers/control-effects.d.ts +4 -0
- package/src/providers/extension-provider-instance.d.ts +61 -0
- package/src/providers/ide-provider-instance.d.ts +70 -0
- package/src/providers/provider-instance-manager.d.ts +84 -0
- package/src/providers/provider-instance.d.ts +7 -1
- package/src/providers/provider-loader.d.ts +299 -0
- package/src/providers/status-monitor.d.ts +48 -0
- package/src/providers/version-archive.d.ts +52 -0
- package/src/session-host/runtime-support.d.ts +8 -0
- package/src/sessions/reconcile.d.ts +22 -0
- package/src/sessions/registry.d.ts +24 -0
- package/src/shared-types-extra.d.ts +29 -0
- package/src/shared-types.d.ts +79 -22
- package/src/shared-types.ts +40 -0
- package/src/status/builders.d.ts +33 -0
- package/src/status/reporter.d.ts +69 -0
- package/src/status/reporter.ts +16 -13
- package/src/status/snapshot.d.ts +58 -0
- package/src/system/host-memory.d.ts +19 -0
- package/src/types.d.ts +3 -7
package/dist/index.mjs
CHANGED
|
@@ -2485,8 +2485,6 @@ ${data.message || ""}`.trim();
|
|
|
2485
2485
|
if (blockingModal || this.currentStatus === "waiting_approval") {
|
|
2486
2486
|
throw new Error(`${this.cliName} is awaiting confirmation before it can accept a prompt`);
|
|
2487
2487
|
}
|
|
2488
|
-
this.committedMessages.push({ role: "user", content: text, timestamp: Date.now() });
|
|
2489
|
-
this.syncMessageViews();
|
|
2490
2488
|
this.isWaitingForResponse = true;
|
|
2491
2489
|
this.responseBuffer = "";
|
|
2492
2490
|
this.finishRetryCount = 0;
|
|
@@ -2518,6 +2516,13 @@ ${data.message || ""}`.trim();
|
|
|
2518
2516
|
const submitDelayMs = this.sendDelayMs + Math.min(2e3, Math.max(0, estimatedLines - 1) * 350);
|
|
2519
2517
|
const maxEchoWaitMs = submitDelayMs + Math.max(1500, Math.min(5e3, estimatedLines * 500));
|
|
2520
2518
|
const retryDelayMs = Math.max(350, Math.min(1500, Math.max(this.sendDelayMs, submitDelayMs)));
|
|
2519
|
+
let didCommitUserTurn = false;
|
|
2520
|
+
const commitUserTurn = () => {
|
|
2521
|
+
if (didCommitUserTurn) return;
|
|
2522
|
+
didCommitUserTurn = true;
|
|
2523
|
+
this.committedMessages.push({ role: "user", content: text, timestamp: Date.now() });
|
|
2524
|
+
this.syncMessageViews();
|
|
2525
|
+
};
|
|
2521
2526
|
if (this.settleTimer) {
|
|
2522
2527
|
clearTimeout(this.settleTimer);
|
|
2523
2528
|
this.settleTimer = null;
|
|
@@ -2530,109 +2535,128 @@ ${data.message || ""}`.trim();
|
|
|
2530
2535
|
if (this.isWaitingForResponse) this.finishResponse();
|
|
2531
2536
|
}, this.timeouts.maxResponse);
|
|
2532
2537
|
};
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2538
|
+
await new Promise((resolve12) => {
|
|
2539
|
+
let resolved = false;
|
|
2540
|
+
const resolveOnce = () => {
|
|
2541
|
+
if (resolved) return;
|
|
2542
|
+
resolved = true;
|
|
2543
|
+
resolve12();
|
|
2544
|
+
};
|
|
2545
|
+
const submit = () => {
|
|
2546
|
+
if (!this.ptyProcess) {
|
|
2547
|
+
resolveOnce();
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
commitUserTurn();
|
|
2551
|
+
this.submitPendingUntil = 0;
|
|
2547
2552
|
const screenText = this.terminalScreen.getText();
|
|
2548
|
-
if (!promptLikelyVisible(screenText, normalizedPromptSnippet)) return;
|
|
2549
|
-
if (/Esc to interrupt|Do you want to proceed|This command requires approval|Allow Codex to|Approve and run now|Always approve this session|Running…|Running\.\.\./i.test(screenText)) return;
|
|
2550
|
-
this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
|
|
2551
|
-
LOG.info("CLI", `[${this.cliType}] Retrying submit key for stuck prompt (attempt ${attempt})`);
|
|
2552
2553
|
this.recordTrace("submit_write", {
|
|
2553
|
-
mode: "
|
|
2554
|
-
attempt,
|
|
2554
|
+
mode: "submit_key",
|
|
2555
2555
|
sendKey: this.sendKey,
|
|
2556
2556
|
screenText: summarizeCliTraceText(screenText, 500)
|
|
2557
2557
|
});
|
|
2558
2558
|
this.ptyProcess.write(this.sendKey);
|
|
2559
|
-
|
|
2560
|
-
this.
|
|
2561
|
-
return;
|
|
2562
|
-
|
|
2563
|
-
|
|
2559
|
+
const retrySubmitIfStuck = (attempt) => {
|
|
2560
|
+
this.submitRetryTimer = null;
|
|
2561
|
+
if (!this.ptyProcess || !this.isWaitingForResponse || this.submitRetryUsed) return;
|
|
2562
|
+
if (this.currentStatus === "waiting_approval") return;
|
|
2563
|
+
if ((this.responseBuffer || "").trim()) return;
|
|
2564
|
+
const screenText2 = this.terminalScreen.getText();
|
|
2565
|
+
if (!promptLikelyVisible(screenText2, normalizedPromptSnippet)) return;
|
|
2566
|
+
if (/Esc to interrupt|Do you want to proceed|This command requires approval|Allow Codex to|Approve and run now|Always approve this session|Running…|Running\.\.\./i.test(screenText2)) return;
|
|
2567
|
+
this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
|
|
2568
|
+
LOG.info("CLI", `[${this.cliType}] Retrying submit key for stuck prompt (attempt ${attempt})`);
|
|
2569
|
+
this.recordTrace("submit_write", {
|
|
2570
|
+
mode: "submit_retry",
|
|
2571
|
+
attempt,
|
|
2572
|
+
sendKey: this.sendKey,
|
|
2573
|
+
screenText: summarizeCliTraceText(screenText2, 500)
|
|
2574
|
+
});
|
|
2575
|
+
this.ptyProcess.write(this.sendKey);
|
|
2576
|
+
if (attempt >= 3) {
|
|
2577
|
+
this.submitRetryUsed = true;
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
this.submitRetryTimer = setTimeout(() => retrySubmitIfStuck(attempt + 1), retryDelayMs);
|
|
2581
|
+
};
|
|
2582
|
+
this.submitRetryTimer = setTimeout(() => retrySubmitIfStuck(1), retryDelayMs);
|
|
2583
|
+
startResponseTimeout();
|
|
2584
|
+
resolveOnce();
|
|
2564
2585
|
};
|
|
2565
|
-
this.
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2586
|
+
if (this.submitStrategy === "immediate") {
|
|
2587
|
+
commitUserTurn();
|
|
2588
|
+
this.submitPendingUntil = 0;
|
|
2589
|
+
this.recordTrace("submit_write", {
|
|
2590
|
+
mode: "immediate",
|
|
2591
|
+
text: summarizeCliTraceText(text, 500),
|
|
2592
|
+
sendKey: this.sendKey,
|
|
2593
|
+
screenText: summarizeCliTraceText(this.terminalScreen.getText(), 500)
|
|
2594
|
+
});
|
|
2595
|
+
this.ptyProcess.write(text + this.sendKey);
|
|
2596
|
+
this.submitRetryTimer = setTimeout(() => {
|
|
2597
|
+
this.submitRetryTimer = null;
|
|
2598
|
+
if (!this.ptyProcess || !this.isWaitingForResponse || this.submitRetryUsed) return;
|
|
2599
|
+
if (this.currentStatus === "waiting_approval") return;
|
|
2600
|
+
if ((this.responseBuffer || "").trim()) return;
|
|
2601
|
+
const screenText = this.terminalScreen.getText();
|
|
2602
|
+
if (!promptLikelyVisible(screenText, normalizedPromptSnippet)) return;
|
|
2603
|
+
LOG.info("CLI", `[${this.cliType}] Retrying submit key for stuck prompt (attempt 1)`);
|
|
2604
|
+
this.responseSettleIgnoreUntil = Date.now() + this.timeouts.outputSettle + 400;
|
|
2605
|
+
this.recordTrace("submit_write", {
|
|
2606
|
+
mode: "immediate_retry",
|
|
2607
|
+
attempt: 1,
|
|
2608
|
+
sendKey: this.sendKey,
|
|
2609
|
+
screenText: summarizeCliTraceText(screenText, 500)
|
|
2610
|
+
});
|
|
2611
|
+
this.ptyProcess.write(this.sendKey);
|
|
2612
|
+
this.submitRetryUsed = true;
|
|
2613
|
+
}, retryDelayMs);
|
|
2614
|
+
startResponseTimeout();
|
|
2615
|
+
resolveOnce();
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
if (submitDelayMs > 0) {
|
|
2619
|
+
this.submitPendingUntil = Date.now() + submitDelayMs;
|
|
2620
|
+
}
|
|
2621
|
+
this.ptyProcess.write(text);
|
|
2570
2622
|
this.recordTrace("submit_write", {
|
|
2571
|
-
mode: "
|
|
2623
|
+
mode: "type_then_submit",
|
|
2572
2624
|
text: summarizeCliTraceText(text, 500),
|
|
2573
2625
|
sendKey: this.sendKey,
|
|
2574
2626
|
screenText: summarizeCliTraceText(this.terminalScreen.getText(), 500)
|
|
2575
2627
|
});
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
if (this.
|
|
2581
|
-
|
|
2628
|
+
const submitStartedAt = Date.now();
|
|
2629
|
+
let lastNormalizedScreen = "";
|
|
2630
|
+
let lastScreenChangeAt = submitStartedAt;
|
|
2631
|
+
const waitForEchoAndSubmit = () => {
|
|
2632
|
+
if (!this.ptyProcess) {
|
|
2633
|
+
resolveOnce();
|
|
2634
|
+
return;
|
|
2635
|
+
}
|
|
2636
|
+
const now = Date.now();
|
|
2637
|
+
const elapsed = now - submitStartedAt;
|
|
2582
2638
|
const screenText = this.terminalScreen.getText();
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
}
|
|
2598
|
-
if (submitDelayMs > 0) {
|
|
2599
|
-
this.submitPendingUntil = Date.now() + submitDelayMs;
|
|
2600
|
-
}
|
|
2601
|
-
this.ptyProcess.write(text);
|
|
2602
|
-
this.recordTrace("submit_write", {
|
|
2603
|
-
mode: "type_then_submit",
|
|
2604
|
-
text: summarizeCliTraceText(text, 500),
|
|
2605
|
-
sendKey: this.sendKey,
|
|
2606
|
-
screenText: summarizeCliTraceText(this.terminalScreen.getText(), 500)
|
|
2607
|
-
});
|
|
2608
|
-
const submitStartedAt = Date.now();
|
|
2609
|
-
let lastNormalizedScreen = "";
|
|
2610
|
-
let lastScreenChangeAt = submitStartedAt;
|
|
2611
|
-
const waitForEchoAndSubmit = () => {
|
|
2612
|
-
if (!this.ptyProcess) return;
|
|
2613
|
-
const now = Date.now();
|
|
2614
|
-
const elapsed = now - submitStartedAt;
|
|
2615
|
-
const screenText = this.terminalScreen.getText();
|
|
2616
|
-
const normalizedScreen = normalizePromptText(screenText);
|
|
2617
|
-
if (normalizedScreen !== lastNormalizedScreen) {
|
|
2618
|
-
lastNormalizedScreen = normalizedScreen;
|
|
2619
|
-
lastScreenChangeAt = now;
|
|
2620
|
-
}
|
|
2621
|
-
const echoVisible = !normalizedPromptSnippet || promptLikelyVisible(screenText, normalizedPromptSnippet);
|
|
2622
|
-
if (echoVisible) {
|
|
2623
|
-
const screenSettled = now - lastScreenChangeAt >= 500;
|
|
2624
|
-
if (elapsed >= submitDelayMs && screenSettled) {
|
|
2639
|
+
const normalizedScreen = normalizePromptText(screenText);
|
|
2640
|
+
if (normalizedScreen !== lastNormalizedScreen) {
|
|
2641
|
+
lastNormalizedScreen = normalizedScreen;
|
|
2642
|
+
lastScreenChangeAt = now;
|
|
2643
|
+
}
|
|
2644
|
+
const echoVisible = !normalizedPromptSnippet || promptLikelyVisible(screenText, normalizedPromptSnippet);
|
|
2645
|
+
if (echoVisible) {
|
|
2646
|
+
const screenSettled = now - lastScreenChangeAt >= 500;
|
|
2647
|
+
if (elapsed >= submitDelayMs && screenSettled) {
|
|
2648
|
+
submit();
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
if (elapsed >= maxEchoWaitMs) {
|
|
2625
2653
|
submit();
|
|
2626
2654
|
return;
|
|
2627
2655
|
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
}
|
|
2633
|
-
setTimeout(waitForEchoAndSubmit, 50);
|
|
2634
|
-
};
|
|
2635
|
-
waitForEchoAndSubmit();
|
|
2656
|
+
setTimeout(waitForEchoAndSubmit, 50);
|
|
2657
|
+
};
|
|
2658
|
+
waitForEchoAndSubmit();
|
|
2659
|
+
});
|
|
2636
2660
|
}
|
|
2637
2661
|
getPartialResponse() {
|
|
2638
2662
|
if (!this.isWaitingForResponse) return "";
|
|
@@ -14336,6 +14360,7 @@ var DaemonStatusReporter = class {
|
|
|
14336
14360
|
lastStatusSentAt = 0;
|
|
14337
14361
|
statusPendingThrottle = false;
|
|
14338
14362
|
lastP2PStatusHash = "";
|
|
14363
|
+
lastServerStatusHash = "";
|
|
14339
14364
|
lastStatusSummary = "";
|
|
14340
14365
|
statusTimer = null;
|
|
14341
14366
|
p2pTimer = null;
|
|
@@ -14346,11 +14371,11 @@ var DaemonStatusReporter = class {
|
|
|
14346
14371
|
// ─── Lifecycle ───────────────────────────────────
|
|
14347
14372
|
startReporting() {
|
|
14348
14373
|
setTimeout(() => {
|
|
14349
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
14374
|
+
this.sendUnifiedStatusReport({ forceServer: true, reason: "initial" }).catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
14350
14375
|
}, 2e3);
|
|
14351
14376
|
const scheduleServerReport = () => {
|
|
14352
14377
|
this.statusTimer = setTimeout(() => {
|
|
14353
|
-
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
14378
|
+
this.sendUnifiedStatusReport({ forceServer: true, reason: "periodic" }).catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
14354
14379
|
scheduleServerReport();
|
|
14355
14380
|
}, 3e4);
|
|
14356
14381
|
};
|
|
@@ -14497,24 +14522,24 @@ var DaemonStatusReporter = class {
|
|
|
14497
14522
|
cdpConnected: session.cdpConnected,
|
|
14498
14523
|
currentModel: session.currentModel,
|
|
14499
14524
|
currentPlan: session.currentPlan,
|
|
14500
|
-
currentAutoApprove: session.currentAutoApprove
|
|
14501
|
-
lastUpdated: session.lastUpdated,
|
|
14502
|
-
unread: session.unread,
|
|
14503
|
-
lastSeenAt: session.lastSeenAt,
|
|
14504
|
-
inboxBucket: session.inboxBucket,
|
|
14505
|
-
surfaceHidden: session.surfaceHidden,
|
|
14506
|
-
controlValues: session.controlValues,
|
|
14507
|
-
providerControls: session.providerControls,
|
|
14508
|
-
acpConfigOptions: session.acpConfigOptions,
|
|
14509
|
-
acpModes: session.acpModes
|
|
14525
|
+
currentAutoApprove: session.currentAutoApprove
|
|
14510
14526
|
})),
|
|
14511
14527
|
p2p: payload.p2p,
|
|
14512
14528
|
timestamp: now,
|
|
14513
14529
|
detectedIdes: payload.detectedIdes,
|
|
14514
14530
|
availableProviders: payload.availableProviders
|
|
14515
14531
|
};
|
|
14532
|
+
const wsHash = this.simpleHash(JSON.stringify({
|
|
14533
|
+
...wsPayload,
|
|
14534
|
+
timestamp: void 0
|
|
14535
|
+
}));
|
|
14536
|
+
if (!opts?.forceServer && wsHash === this.lastServerStatusHash) {
|
|
14537
|
+
LOG.debug("Server", `skip duplicate status_report${opts?.reason ? ` (${opts.reason})` : ""}`);
|
|
14538
|
+
return;
|
|
14539
|
+
}
|
|
14540
|
+
this.lastServerStatusHash = wsHash;
|
|
14516
14541
|
serverConn.sendMessage("status_report", wsPayload);
|
|
14517
|
-
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
14542
|
+
LOG.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)${opts?.reason ? ` [${opts.reason}]` : ""}`);
|
|
14518
14543
|
}
|
|
14519
14544
|
// ─── P2P ─────────────────────────────────────────
|
|
14520
14545
|
sendP2PPayload(payload) {
|