@adhdev/daemon-core 0.8.88 → 0.8.90
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/cli-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/index.js +50 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -20
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +57 -18
- package/src/cli-adapters/provider-cli-parse.ts +4 -4
|
@@ -146,6 +146,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
146
146
|
private commitCurrentTranscript;
|
|
147
147
|
private runDetectStatus;
|
|
148
148
|
private runParseApproval;
|
|
149
|
+
private projectEffectiveStatus;
|
|
149
150
|
getStatus(): CliSessionStatus;
|
|
150
151
|
seedCommittedMessages(messages: SeedCliChatMessage[]): void;
|
|
151
152
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1664,8 +1664,8 @@ function buildCliParseInput(options) {
|
|
|
1664
1664
|
scope,
|
|
1665
1665
|
runtimeSettings
|
|
1666
1666
|
} = options;
|
|
1667
|
-
const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart)
|
|
1668
|
-
const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart)
|
|
1667
|
+
const buffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
|
|
1668
|
+
const rawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
|
|
1669
1669
|
const screenText = terminalScreenText;
|
|
1670
1670
|
const recentBuffer = buffer.slice(-1e3) || recentOutputBuffer;
|
|
1671
1671
|
return {
|
|
@@ -1697,8 +1697,8 @@ function summarizeCliTraceMessages(messages, limit = 3) {
|
|
|
1697
1697
|
}
|
|
1698
1698
|
function buildCliTraceParseSnapshot(options) {
|
|
1699
1699
|
const { accumulatedBuffer, accumulatedRawBuffer, responseBuffer, partialResponse, scope } = options;
|
|
1700
|
-
const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart)
|
|
1701
|
-
const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart)
|
|
1700
|
+
const scopedBuffer = scope ? sliceFromOffset(accumulatedBuffer, scope.bufferStart) : accumulatedBuffer;
|
|
1701
|
+
const scopedRawBuffer = scope ? sliceFromOffset(accumulatedRawBuffer, scope.rawBufferStart) : accumulatedRawBuffer;
|
|
1702
1702
|
return {
|
|
1703
1703
|
currentTurnScope: scope || null,
|
|
1704
1704
|
responseBuffer: summarizeCliTraceText(responseBuffer, 1200),
|
|
@@ -2362,6 +2362,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2362
2362
|
looksLikeClaudeGeneratingLine(line) {
|
|
2363
2363
|
const trimmed = String(line || "").trim();
|
|
2364
2364
|
if (!trimmed) return false;
|
|
2365
|
+
if (/^⏵⏵\s+accept edits on/i.test(trimmed)) return false;
|
|
2365
2366
|
if (/esc to (cancel|interrupt|stop)/i.test(trimmed)) return true;
|
|
2366
2367
|
if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+\S+.*\b(?:thinking|thought for \d+s?)\b/i.test(trimmed)) return true;
|
|
2367
2368
|
if (/^[✻✶✳✢✽⠂⠐⠒⠓⠦⠴⠶⠷⠿]+\s+[A-Z][A-Za-z-]{3,}ing\b.*(?:…|\.{3})/u.test(trimmed)) return true;
|
|
@@ -2462,8 +2463,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2462
2463
|
const buttons = Array.isArray(modal.buttons) ? modal.buttons : [];
|
|
2463
2464
|
if (buttons.length !== 1) return false;
|
|
2464
2465
|
const buttonLabel = String(buttons[0] || "").trim();
|
|
2465
|
-
|
|
2466
|
-
return looksLikeConfirmOnlyLabel(buttonLabel) || /Quick safety check|project trust|trust (?:this project|the contents of this directory|the files in this folder)|Enter to confirm/i.test(modalText);
|
|
2466
|
+
return looksLikeConfirmOnlyLabel(buttonLabel);
|
|
2467
2467
|
}
|
|
2468
2468
|
async waitForInteractivePrompt(maxWaitMs = 5e3) {
|
|
2469
2469
|
const startedAt = Date.now();
|
|
@@ -2675,7 +2675,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
2675
2675
|
`[${this.cliType}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope.prompt).slice(0, 140)} scriptStatus=${String(scriptStatus || "")} parsedStatus=${String(parsedTranscript?.status || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify(summarizeCliTraceText(lastParsedAssistant?.content || "", 120)).slice(0, 160)} visibleIdlePrompt=${String(visibleIdlePrompt)} visibleAssistantCandidate=${String(visibleAssistantCandidate)} responseBuffer=${JSON.stringify(summarizeCliTraceText(this.responseBuffer, 160)).slice(0, 220)} screen=${JSON.stringify(summarizeCliTraceText(screenText, 160)).slice(0, 220)}`
|
|
2676
2676
|
);
|
|
2677
2677
|
}
|
|
2678
|
-
const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate);
|
|
2678
|
+
const shouldHoldGenerating = scriptStatus === "idle" && this.isWaitingForResponse && !modal && recentInteractiveActivity && !(visibleIdlePrompt && visibleAssistantCandidate) && !(parsedTranscript?.status === "idle" && !!lastParsedAssistant);
|
|
2679
2679
|
if (shouldHoldGenerating) {
|
|
2680
2680
|
this.clearIdleFinishCandidate("hold_generating_recent_activity");
|
|
2681
2681
|
this.setStatus("generating", "recent_activity_hold");
|
|
@@ -3077,13 +3077,22 @@ var init_provider_cli_adapter = __esm({
|
|
|
3077
3077
|
return null;
|
|
3078
3078
|
}
|
|
3079
3079
|
}
|
|
3080
|
+
projectEffectiveStatus(startupModal = null) {
|
|
3081
|
+
if (this.parseErrorMessage) return "error";
|
|
3082
|
+
if (startupModal) return "waiting_approval";
|
|
3083
|
+
if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
|
|
3084
|
+
return this.currentStatus;
|
|
3085
|
+
}
|
|
3080
3086
|
// ─── Public API (CliAdapter) ───────────────────
|
|
3081
3087
|
getStatus() {
|
|
3088
|
+
const screenText = this.terminalScreen.getText() || "";
|
|
3089
|
+
const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
|
|
3090
|
+
const effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
3082
3091
|
return {
|
|
3083
|
-
status:
|
|
3092
|
+
status: effectiveStatus,
|
|
3084
3093
|
messages: [...this.committedMessages],
|
|
3085
3094
|
workingDir: this.workingDir,
|
|
3086
|
-
activeModal: this.activeModal,
|
|
3095
|
+
activeModal: startupModal || this.activeModal,
|
|
3087
3096
|
errorMessage: this.parseErrorMessage || void 0,
|
|
3088
3097
|
errorReason: this.parseErrorMessage ? "parse_error" : void 0
|
|
3089
3098
|
};
|
|
@@ -3137,7 +3146,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
3137
3146
|
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3138
3147
|
}));
|
|
3139
3148
|
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
3140
|
-
const
|
|
3149
|
+
const visibleIdlePrompt = this.looksLikeVisibleIdlePrompt(screenText);
|
|
3150
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedHydratedMessages.length > committedHydratedMessages.length && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && visibleIdlePrompt);
|
|
3141
3151
|
if (shouldAdoptParsedIdleReplay) {
|
|
3142
3152
|
this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
|
|
3143
3153
|
committedMessages: this.committedMessages,
|
|
@@ -3145,6 +3155,18 @@ var init_provider_cli_adapter = __esm({
|
|
|
3145
3155
|
lastOutputAt: this.lastOutputAt
|
|
3146
3156
|
});
|
|
3147
3157
|
this.syncMessageViews();
|
|
3158
|
+
if (this.currentStatus !== "idle" || this.isWaitingForResponse) {
|
|
3159
|
+
this.responseBuffer = "";
|
|
3160
|
+
this.isWaitingForResponse = false;
|
|
3161
|
+
this.responseSettleIgnoreUntil = 0;
|
|
3162
|
+
this.submitRetryUsed = false;
|
|
3163
|
+
this.submitRetryPromptSnippet = "";
|
|
3164
|
+
this.finishRetryCount = 0;
|
|
3165
|
+
this.currentTurnScope = null;
|
|
3166
|
+
this.activeModal = null;
|
|
3167
|
+
this.setStatus("idle", "parsed_idle_replay_commit");
|
|
3168
|
+
this.onStatusChange?.();
|
|
3169
|
+
}
|
|
3148
3170
|
}
|
|
3149
3171
|
const effectiveCommittedHydratedMessages = shouldAdoptParsedIdleReplay ? this.committedMessages.map((message, index) => buildChatMessage({
|
|
3150
3172
|
...message,
|
|
@@ -3755,8 +3777,9 @@ ${data.message || ""}`.trim();
|
|
|
3755
3777
|
this.ptyProcess?.write(data);
|
|
3756
3778
|
}
|
|
3757
3779
|
resolveModal(buttonIndex) {
|
|
3758
|
-
|
|
3759
|
-
const modal = this.activeModal;
|
|
3780
|
+
const screenText = this.terminalScreen.getText() || "";
|
|
3781
|
+
const modal = this.activeModal || this.getStartupConfirmationModal(screenText);
|
|
3782
|
+
if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !modal) return;
|
|
3760
3783
|
this.clearIdleFinishCandidate("resolve_modal");
|
|
3761
3784
|
this.recordTrace("resolve_modal", {
|
|
3762
3785
|
buttonIndex,
|
|
@@ -3771,7 +3794,10 @@ ${data.message || ""}`.trim();
|
|
|
3771
3794
|
}
|
|
3772
3795
|
this.setStatus("generating", "approval_resolved");
|
|
3773
3796
|
this.onStatusChange?.();
|
|
3774
|
-
|
|
3797
|
+
const startupTrustModal = /Quick safety check|project trust|Confirm Claude Code project trust|trust (?:this project|the contents of this directory|the files in this folder)/i.test(String(modal?.message || ""));
|
|
3798
|
+
if (startupTrustModal && buttonIndex in this.approvalKeys) {
|
|
3799
|
+
this.ptyProcess.write(`${this.approvalKeys[buttonIndex]}\r`);
|
|
3800
|
+
} else if (this.shouldResolveModalWithEnter(modal, buttonIndex)) {
|
|
3775
3801
|
this.ptyProcess.write("\r");
|
|
3776
3802
|
} else if (buttonIndex in this.approvalKeys) {
|
|
3777
3803
|
this.ptyProcess.write(this.approvalKeys[buttonIndex]);
|
|
@@ -3792,20 +3818,24 @@ ${data.message || ""}`.trim();
|
|
|
3792
3818
|
}
|
|
3793
3819
|
}
|
|
3794
3820
|
getDebugState() {
|
|
3821
|
+
const screenText = sanitizeTerminalText(this.terminalScreen.getText());
|
|
3822
|
+
const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
|
|
3823
|
+
const effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
3824
|
+
const effectiveReady = this.ready || !!startupModal;
|
|
3795
3825
|
return {
|
|
3796
3826
|
type: this.cliType,
|
|
3797
3827
|
name: this.cliName,
|
|
3798
3828
|
providerResolution: this.providerResolutionMeta,
|
|
3799
|
-
status:
|
|
3800
|
-
ready:
|
|
3829
|
+
status: effectiveStatus,
|
|
3830
|
+
ready: effectiveReady,
|
|
3801
3831
|
startupParseGate: this.startupParseGate,
|
|
3802
3832
|
spawnAt: this.spawnAt,
|
|
3803
3833
|
workingDir: this.workingDir,
|
|
3804
|
-
messages: this.messages
|
|
3805
|
-
committedMessages: this.committedMessages
|
|
3806
|
-
structuredMessages: this.structuredMessages
|
|
3834
|
+
messages: this.messages,
|
|
3835
|
+
committedMessages: this.committedMessages,
|
|
3836
|
+
structuredMessages: this.structuredMessages,
|
|
3807
3837
|
messageCount: this.committedMessages.length,
|
|
3808
|
-
screenText:
|
|
3838
|
+
screenText: screenText.slice(-4e3),
|
|
3809
3839
|
currentTurnScope: this.currentTurnScope,
|
|
3810
3840
|
startupBuffer: this.startupBuffer.slice(-4e3),
|
|
3811
3841
|
recentOutputBuffer: this.recentOutputBuffer.slice(-500),
|
|
@@ -3820,7 +3850,7 @@ ${data.message || ""}`.trim();
|
|
|
3820
3850
|
lastScreenChangeAt: this.lastScreenChangeAt,
|
|
3821
3851
|
lastScreenSnapshot: this.lastScreenSnapshot.slice(-500),
|
|
3822
3852
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
3823
|
-
activeModal: this.activeModal,
|
|
3853
|
+
activeModal: startupModal || this.activeModal,
|
|
3824
3854
|
lastApprovalResolvedAt: this.lastApprovalResolvedAt,
|
|
3825
3855
|
sendDelayMs: this.sendDelayMs,
|
|
3826
3856
|
sendKey: this.sendKey,
|