@adhdev/daemon-core 0.9.82-rc.69 → 0.9.82-rc.70
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 +2 -0
- package/dist/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/dist/index.js +87 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +91 -3
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +4 -0
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +2 -0
- package/src/commands/handler.ts +8 -1
- package/src/config/chat-history.ts +9 -7
- package/src/daemon/dev-cli-debug.ts +10 -1
|
@@ -154,6 +154,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
154
154
|
private waitForInteractivePrompt;
|
|
155
155
|
private clearAllTimers;
|
|
156
156
|
private clearStaleIdleResponseGuard;
|
|
157
|
+
private clearParsedIdleResponseGuard;
|
|
157
158
|
private hasMeaningfulResponseBuffer;
|
|
158
159
|
private evaluateSettled;
|
|
159
160
|
private applyPendingScriptStatusDebounce;
|
|
@@ -169,6 +170,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
169
170
|
private runDetectStatus;
|
|
170
171
|
private runParseApproval;
|
|
171
172
|
private hasActionableApproval;
|
|
173
|
+
private parsedStatusHasFinalAssistantMessage;
|
|
172
174
|
private projectEffectiveStatus;
|
|
173
175
|
getStatus(options?: {
|
|
174
176
|
allowParse?: boolean;
|
|
@@ -15,6 +15,7 @@ export declare function buildCliParseInput(options: {
|
|
|
15
15
|
accumulatedRawBuffer: string;
|
|
16
16
|
recentOutputBuffer: string;
|
|
17
17
|
terminalScreenText: string;
|
|
18
|
+
workingDir?: string;
|
|
18
19
|
baseMessages: CliChatMessage[];
|
|
19
20
|
partialResponse: string;
|
|
20
21
|
isWaitingForResponse?: boolean;
|
|
@@ -112,6 +112,8 @@ export interface CliScriptInput {
|
|
|
112
112
|
rawBuffer: string;
|
|
113
113
|
recentBuffer: string;
|
|
114
114
|
screenText: string;
|
|
115
|
+
workspace?: string;
|
|
116
|
+
workingDir?: string;
|
|
115
117
|
screen: CliScreenSnapshot;
|
|
116
118
|
bufferScreen: CliScreenSnapshot;
|
|
117
119
|
recentScreen: CliScreenSnapshot;
|
package/dist/index.js
CHANGED
|
@@ -4217,6 +4217,7 @@ function buildCliParseInput(options) {
|
|
|
4217
4217
|
accumulatedRawBuffer,
|
|
4218
4218
|
recentOutputBuffer,
|
|
4219
4219
|
terminalScreenText,
|
|
4220
|
+
workingDir,
|
|
4220
4221
|
baseMessages,
|
|
4221
4222
|
partialResponse,
|
|
4222
4223
|
isWaitingForResponse,
|
|
@@ -4232,6 +4233,8 @@ function buildCliParseInput(options) {
|
|
|
4232
4233
|
rawBuffer,
|
|
4233
4234
|
recentBuffer,
|
|
4234
4235
|
screenText,
|
|
4236
|
+
workspace: workingDir,
|
|
4237
|
+
workingDir,
|
|
4235
4238
|
screen: buildCliScreenSnapshot(screenText),
|
|
4236
4239
|
bufferScreen: buildCliScreenSnapshot(buffer),
|
|
4237
4240
|
recentScreen: buildCliScreenSnapshot(recentBuffer),
|
|
@@ -4957,6 +4960,17 @@ ${lastSnapshot}`;
|
|
|
4957
4960
|
const stableMs = this.lastScreenChangeAt ? now - this.lastScreenChangeAt : 0;
|
|
4958
4961
|
if (stableMs < 2e3) return;
|
|
4959
4962
|
const startupModal = this.runParseApproval(this.recentOutputBuffer);
|
|
4963
|
+
const startupStatus = this.runDetectStatus(screenText || this.recentOutputBuffer);
|
|
4964
|
+
if (!startupModal && startupStatus !== "idle") {
|
|
4965
|
+
this.recordTrace("startup_settle_deferred", {
|
|
4966
|
+
trigger,
|
|
4967
|
+
startupStatus,
|
|
4968
|
+
stableMs,
|
|
4969
|
+
screenText: summarizeCliTraceText(screenText, 500)
|
|
4970
|
+
});
|
|
4971
|
+
this.scheduleStartupSettleCheck();
|
|
4972
|
+
return;
|
|
4973
|
+
}
|
|
4960
4974
|
this.startupParseGate = false;
|
|
4961
4975
|
if (this.startupSettleTimer) {
|
|
4962
4976
|
clearTimeout(this.startupSettleTimer);
|
|
@@ -5155,6 +5169,31 @@ ${lastSnapshot}`;
|
|
|
5155
5169
|
this.recordTrace("stale_idle_response_cleared", { reason });
|
|
5156
5170
|
return true;
|
|
5157
5171
|
}
|
|
5172
|
+
clearParsedIdleResponseGuard(reason, parsedStatus) {
|
|
5173
|
+
const parsedRawStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status.trim() : "";
|
|
5174
|
+
const parsedModal = parsedStatus?.activeModal ?? parsedStatus?.modal ?? null;
|
|
5175
|
+
const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
|
|
5176
|
+
if (!this.isWaitingForResponse || parsedRawStatus !== "idle" || !!parsedModal || !!blockingModal || !this.parsedStatusHasFinalAssistantMessage(parsedStatus)) {
|
|
5177
|
+
return false;
|
|
5178
|
+
}
|
|
5179
|
+
this.clearAllTimers();
|
|
5180
|
+
this.clearIdleFinishCandidate(reason);
|
|
5181
|
+
this.responseBuffer = "";
|
|
5182
|
+
this.isWaitingForResponse = false;
|
|
5183
|
+
this.responseSettleIgnoreUntil = 0;
|
|
5184
|
+
this.submitRetryUsed = false;
|
|
5185
|
+
this.submitRetryPromptSnippet = "";
|
|
5186
|
+
this.finishRetryCount = 0;
|
|
5187
|
+
this.currentTurnScope = null;
|
|
5188
|
+
this.activeModal = null;
|
|
5189
|
+
this.setStatus("idle", reason);
|
|
5190
|
+
this.recordTrace("parsed_idle_response_cleared", {
|
|
5191
|
+
reason,
|
|
5192
|
+
parsedStatus: parsedRawStatus,
|
|
5193
|
+
parsedMessageCount: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : 0
|
|
5194
|
+
});
|
|
5195
|
+
return true;
|
|
5196
|
+
}
|
|
5158
5197
|
hasMeaningfulResponseBuffer(promptSnippet) {
|
|
5159
5198
|
const raw = String(this.responseBuffer || "").trim();
|
|
5160
5199
|
if (!raw) return false;
|
|
@@ -5624,6 +5663,7 @@ ${lastSnapshot}`;
|
|
|
5624
5663
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
5625
5664
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
5626
5665
|
terminalScreenText: parseScreenText,
|
|
5666
|
+
workingDir: this.workingDir,
|
|
5627
5667
|
baseMessages: [],
|
|
5628
5668
|
partialResponse: this.responseBuffer,
|
|
5629
5669
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -5683,6 +5723,14 @@ ${lastSnapshot}`;
|
|
|
5683
5723
|
hasActionableApproval(startupModal = null) {
|
|
5684
5724
|
return !!(startupModal || this.activeModal);
|
|
5685
5725
|
}
|
|
5726
|
+
parsedStatusHasFinalAssistantMessage(parsed) {
|
|
5727
|
+
const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
|
|
5728
|
+
const lastAssistant = [...messages].reverse().find((message) => {
|
|
5729
|
+
if (!message || message.role !== "assistant") return false;
|
|
5730
|
+
return typeof message.content === "string" && message.content.trim().length > 0;
|
|
5731
|
+
});
|
|
5732
|
+
return !!lastAssistant;
|
|
5733
|
+
}
|
|
5686
5734
|
projectEffectiveStatus(startupModal = null) {
|
|
5687
5735
|
if (this.parseErrorMessage) return "error";
|
|
5688
5736
|
if (this.hasActionableApproval(startupModal)) return "waiting_approval";
|
|
@@ -5693,14 +5741,22 @@ ${lastSnapshot}`;
|
|
|
5693
5741
|
getStatus(options = {}) {
|
|
5694
5742
|
const allowParse = options.allowParse !== false;
|
|
5695
5743
|
const startupModal = allowParse && this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
5744
|
+
const startupDetectedStatus = allowParse && this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || this.terminalScreen.getText()) : null;
|
|
5696
5745
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
5697
5746
|
let effectiveModal = startupModal || this.activeModal;
|
|
5747
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
5748
|
+
effectiveStatus = "waiting_approval";
|
|
5749
|
+
}
|
|
5698
5750
|
if (allowParse && !startupModal && !effectiveModal) {
|
|
5699
5751
|
const parsed = this.getFreshParsedStatusCache();
|
|
5700
5752
|
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
5701
5753
|
if (parsed?.status === "waiting_approval" && parsedModal) {
|
|
5702
5754
|
effectiveStatus = "waiting_approval";
|
|
5703
5755
|
effectiveModal = parsedModal;
|
|
5756
|
+
} else if (effectiveStatus === "idle" && parsed?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
5757
|
+
effectiveStatus = "generating";
|
|
5758
|
+
} else if (effectiveStatus === "generating" && parsed?.status === "idle" && this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
5759
|
+
effectiveStatus = "idle";
|
|
5704
5760
|
}
|
|
5705
5761
|
}
|
|
5706
5762
|
const bufferState = this.getBufferState();
|
|
@@ -5770,6 +5826,7 @@ ${lastSnapshot}`;
|
|
|
5770
5826
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
5771
5827
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
5772
5828
|
terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
|
|
5829
|
+
workingDir: this.workingDir,
|
|
5773
5830
|
baseMessages: [],
|
|
5774
5831
|
partialResponse: this.responseBuffer,
|
|
5775
5832
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -6045,7 +6102,7 @@ ${lastSnapshot}`;
|
|
|
6045
6102
|
}
|
|
6046
6103
|
}
|
|
6047
6104
|
if (this.isWaitingForResponse && !allowInputDuringGeneration) {
|
|
6048
|
-
if (!this.clearStaleIdleResponseGuard("send_message_guard")) {
|
|
6105
|
+
if (!this.clearStaleIdleResponseGuard("send_message_guard") && !this.clearParsedIdleResponseGuard("send_message_parsed_idle_guard", parsedStatusBeforeSend)) {
|
|
6049
6106
|
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
6050
6107
|
}
|
|
6051
6108
|
}
|
|
@@ -6423,10 +6480,17 @@ ${lastSnapshot}`;
|
|
|
6423
6480
|
getDebugState() {
|
|
6424
6481
|
const screenText = sanitizeTerminalText(this.terminalScreen.getText());
|
|
6425
6482
|
const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
6426
|
-
const
|
|
6427
|
-
const effectiveReady = this.ready || !!startupModal;
|
|
6483
|
+
const startupDetectedStatus = this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || screenText) : null;
|
|
6484
|
+
const effectiveReady = this.ready || !!startupModal || startupDetectedStatus === "waiting_approval";
|
|
6428
6485
|
const parsedDebugState = this.getParsedDebugState();
|
|
6429
6486
|
const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
|
|
6487
|
+
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
6488
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
6489
|
+
effectiveStatus = "waiting_approval";
|
|
6490
|
+
}
|
|
6491
|
+
if (effectiveStatus === "idle" && parsedDebugState?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsedDebugState)) {
|
|
6492
|
+
effectiveStatus = "generating";
|
|
6493
|
+
}
|
|
6430
6494
|
return {
|
|
6431
6495
|
type: this.cliType,
|
|
6432
6496
|
name: this.cliName,
|
|
@@ -13130,17 +13194,18 @@ function normalizeProviderNativeHistoryRecords(agentType, historySessionId, reco
|
|
|
13130
13194
|
function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
13131
13195
|
const fn = getProviderNativeHistoryScript(scripts, canonicalHistory, "readSession");
|
|
13132
13196
|
if (!fn) return null;
|
|
13197
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
13133
13198
|
const result = fn({
|
|
13134
13199
|
agentType,
|
|
13135
|
-
sessionId:
|
|
13136
|
-
historySessionId,
|
|
13200
|
+
sessionId: normalizedSessionId,
|
|
13201
|
+
historySessionId: normalizedSessionId,
|
|
13137
13202
|
workspace,
|
|
13138
13203
|
format: canonicalHistory?.format,
|
|
13139
13204
|
watchPath: canonicalHistory?.watchPath,
|
|
13140
|
-
args: { sessionId:
|
|
13205
|
+
args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, workspace }
|
|
13141
13206
|
});
|
|
13142
13207
|
if (!result || typeof result !== "object") return null;
|
|
13143
|
-
const records = normalizeProviderNativeHistoryRecords(agentType,
|
|
13208
|
+
const records = normalizeProviderNativeHistoryRecords(agentType, normalizedSessionId, result.messages || result.records);
|
|
13144
13209
|
if (records.length === 0) return null;
|
|
13145
13210
|
return {
|
|
13146
13211
|
records,
|
|
@@ -13150,7 +13215,8 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
|
|
|
13150
13215
|
}
|
|
13151
13216
|
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
13152
13217
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
13153
|
-
|
|
13218
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
13219
|
+
if (!canonicalHistory || !normalizedSessionId && !normalizedWorkspace || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
|
|
13154
13220
|
return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace);
|
|
13155
13221
|
}
|
|
13156
13222
|
function materializeNativeHistoryToMirror(agentType, canonicalHistory, historySessionId, workspace, scripts) {
|
|
@@ -13179,7 +13245,7 @@ function isNativeSourceCanonicalHistory(canonicalHistory) {
|
|
|
13179
13245
|
return true;
|
|
13180
13246
|
}
|
|
13181
13247
|
function readProviderChatHistory(agentType, options = {}) {
|
|
13182
|
-
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && options.historySessionId) {
|
|
13248
|
+
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && (options.historySessionId || options.workspace)) {
|
|
13183
13249
|
const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace);
|
|
13184
13250
|
if (!nativeResult) return { messages: [], hasMore: false, source: "native-unavailable" };
|
|
13185
13251
|
return {
|
|
@@ -18544,7 +18610,8 @@ var DaemonCommandHandler = class {
|
|
|
18544
18610
|
"pty_resize",
|
|
18545
18611
|
"invoke_provider_script"
|
|
18546
18612
|
]);
|
|
18547
|
-
const
|
|
18613
|
+
const isReadOrDebugCmd = cmd === "read_chat" || cmd === "get_chat_debug_bundle";
|
|
18614
|
+
const allowsInactiveReadChatFallback = isReadOrDebugCmd && !!this._currentRoute.providerType && (typeof args?.providerSessionId === "string" && args.providerSessionId.trim().length > 0 || typeof args?.historySessionId === "string" && args.historySessionId.trim().length > 0 || typeof args?.targetSessionId === "string" && args.targetSessionId.trim().length > 0);
|
|
18548
18615
|
if (this._currentRoute.sessionLookupFailed && sessionScopedCommands.has(cmd) && !allowsInactiveReadChatFallback) {
|
|
18549
18616
|
const result2 = {
|
|
18550
18617
|
success: false,
|
|
@@ -33450,7 +33517,16 @@ async function handleCliSend(ctx, req, res) {
|
|
|
33450
33517
|
return;
|
|
33451
33518
|
}
|
|
33452
33519
|
try {
|
|
33453
|
-
|
|
33520
|
+
if (target.category === "cli") {
|
|
33521
|
+
const bundle = getCliTargetBundle(ctx, type, instanceId);
|
|
33522
|
+
if (!bundle) {
|
|
33523
|
+
ctx.json(res, 404, { error: `No running CLI adapter found for: ${type || instanceId}` });
|
|
33524
|
+
return;
|
|
33525
|
+
}
|
|
33526
|
+
await bundle.adapter.sendMessage(text);
|
|
33527
|
+
} else {
|
|
33528
|
+
ctx.instanceManager.sendEvent(target.instanceId, "send_message", { text });
|
|
33529
|
+
}
|
|
33454
33530
|
ctx.json(res, 200, { sent: true, type: target.type, instanceId: target.instanceId });
|
|
33455
33531
|
} catch (e) {
|
|
33456
33532
|
ctx.json(res, 500, { error: `Send failed: ${e.message}` });
|