@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
package/dist/index.mjs
CHANGED
|
@@ -4213,6 +4213,7 @@ function buildCliParseInput(options) {
|
|
|
4213
4213
|
accumulatedRawBuffer,
|
|
4214
4214
|
recentOutputBuffer,
|
|
4215
4215
|
terminalScreenText,
|
|
4216
|
+
workingDir,
|
|
4216
4217
|
baseMessages,
|
|
4217
4218
|
partialResponse,
|
|
4218
4219
|
isWaitingForResponse,
|
|
@@ -4228,6 +4229,8 @@ function buildCliParseInput(options) {
|
|
|
4228
4229
|
rawBuffer,
|
|
4229
4230
|
recentBuffer,
|
|
4230
4231
|
screenText,
|
|
4232
|
+
workspace: workingDir,
|
|
4233
|
+
workingDir,
|
|
4231
4234
|
screen: buildCliScreenSnapshot(screenText),
|
|
4232
4235
|
bufferScreen: buildCliScreenSnapshot(buffer),
|
|
4233
4236
|
recentScreen: buildCliScreenSnapshot(recentBuffer),
|
|
@@ -4952,6 +4955,17 @@ ${lastSnapshot}`;
|
|
|
4952
4955
|
const stableMs = this.lastScreenChangeAt ? now - this.lastScreenChangeAt : 0;
|
|
4953
4956
|
if (stableMs < 2e3) return;
|
|
4954
4957
|
const startupModal = this.runParseApproval(this.recentOutputBuffer);
|
|
4958
|
+
const startupStatus = this.runDetectStatus(screenText || this.recentOutputBuffer);
|
|
4959
|
+
if (!startupModal && startupStatus !== "idle") {
|
|
4960
|
+
this.recordTrace("startup_settle_deferred", {
|
|
4961
|
+
trigger,
|
|
4962
|
+
startupStatus,
|
|
4963
|
+
stableMs,
|
|
4964
|
+
screenText: summarizeCliTraceText(screenText, 500)
|
|
4965
|
+
});
|
|
4966
|
+
this.scheduleStartupSettleCheck();
|
|
4967
|
+
return;
|
|
4968
|
+
}
|
|
4955
4969
|
this.startupParseGate = false;
|
|
4956
4970
|
if (this.startupSettleTimer) {
|
|
4957
4971
|
clearTimeout(this.startupSettleTimer);
|
|
@@ -5150,6 +5164,31 @@ ${lastSnapshot}`;
|
|
|
5150
5164
|
this.recordTrace("stale_idle_response_cleared", { reason });
|
|
5151
5165
|
return true;
|
|
5152
5166
|
}
|
|
5167
|
+
clearParsedIdleResponseGuard(reason, parsedStatus) {
|
|
5168
|
+
const parsedRawStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status.trim() : "";
|
|
5169
|
+
const parsedModal = parsedStatus?.activeModal ?? parsedStatus?.modal ?? null;
|
|
5170
|
+
const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
|
|
5171
|
+
if (!this.isWaitingForResponse || parsedRawStatus !== "idle" || !!parsedModal || !!blockingModal || !this.parsedStatusHasFinalAssistantMessage(parsedStatus)) {
|
|
5172
|
+
return false;
|
|
5173
|
+
}
|
|
5174
|
+
this.clearAllTimers();
|
|
5175
|
+
this.clearIdleFinishCandidate(reason);
|
|
5176
|
+
this.responseBuffer = "";
|
|
5177
|
+
this.isWaitingForResponse = false;
|
|
5178
|
+
this.responseSettleIgnoreUntil = 0;
|
|
5179
|
+
this.submitRetryUsed = false;
|
|
5180
|
+
this.submitRetryPromptSnippet = "";
|
|
5181
|
+
this.finishRetryCount = 0;
|
|
5182
|
+
this.currentTurnScope = null;
|
|
5183
|
+
this.activeModal = null;
|
|
5184
|
+
this.setStatus("idle", reason);
|
|
5185
|
+
this.recordTrace("parsed_idle_response_cleared", {
|
|
5186
|
+
reason,
|
|
5187
|
+
parsedStatus: parsedRawStatus,
|
|
5188
|
+
parsedMessageCount: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : 0
|
|
5189
|
+
});
|
|
5190
|
+
return true;
|
|
5191
|
+
}
|
|
5153
5192
|
hasMeaningfulResponseBuffer(promptSnippet) {
|
|
5154
5193
|
const raw = String(this.responseBuffer || "").trim();
|
|
5155
5194
|
if (!raw) return false;
|
|
@@ -5619,6 +5658,7 @@ ${lastSnapshot}`;
|
|
|
5619
5658
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
5620
5659
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
5621
5660
|
terminalScreenText: parseScreenText,
|
|
5661
|
+
workingDir: this.workingDir,
|
|
5622
5662
|
baseMessages: [],
|
|
5623
5663
|
partialResponse: this.responseBuffer,
|
|
5624
5664
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -5678,6 +5718,14 @@ ${lastSnapshot}`;
|
|
|
5678
5718
|
hasActionableApproval(startupModal = null) {
|
|
5679
5719
|
return !!(startupModal || this.activeModal);
|
|
5680
5720
|
}
|
|
5721
|
+
parsedStatusHasFinalAssistantMessage(parsed) {
|
|
5722
|
+
const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
|
|
5723
|
+
const lastAssistant = [...messages].reverse().find((message) => {
|
|
5724
|
+
if (!message || message.role !== "assistant") return false;
|
|
5725
|
+
return typeof message.content === "string" && message.content.trim().length > 0;
|
|
5726
|
+
});
|
|
5727
|
+
return !!lastAssistant;
|
|
5728
|
+
}
|
|
5681
5729
|
projectEffectiveStatus(startupModal = null) {
|
|
5682
5730
|
if (this.parseErrorMessage) return "error";
|
|
5683
5731
|
if (this.hasActionableApproval(startupModal)) return "waiting_approval";
|
|
@@ -5688,14 +5736,22 @@ ${lastSnapshot}`;
|
|
|
5688
5736
|
getStatus(options = {}) {
|
|
5689
5737
|
const allowParse = options.allowParse !== false;
|
|
5690
5738
|
const startupModal = allowParse && this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
5739
|
+
const startupDetectedStatus = allowParse && this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || this.terminalScreen.getText()) : null;
|
|
5691
5740
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
5692
5741
|
let effectiveModal = startupModal || this.activeModal;
|
|
5742
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
5743
|
+
effectiveStatus = "waiting_approval";
|
|
5744
|
+
}
|
|
5693
5745
|
if (allowParse && !startupModal && !effectiveModal) {
|
|
5694
5746
|
const parsed = this.getFreshParsedStatusCache();
|
|
5695
5747
|
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
5696
5748
|
if (parsed?.status === "waiting_approval" && parsedModal) {
|
|
5697
5749
|
effectiveStatus = "waiting_approval";
|
|
5698
5750
|
effectiveModal = parsedModal;
|
|
5751
|
+
} else if (effectiveStatus === "idle" && parsed?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
5752
|
+
effectiveStatus = "generating";
|
|
5753
|
+
} else if (effectiveStatus === "generating" && parsed?.status === "idle" && this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
5754
|
+
effectiveStatus = "idle";
|
|
5699
5755
|
}
|
|
5700
5756
|
}
|
|
5701
5757
|
const bufferState = this.getBufferState();
|
|
@@ -5765,6 +5821,7 @@ ${lastSnapshot}`;
|
|
|
5765
5821
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
5766
5822
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
5767
5823
|
terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
|
|
5824
|
+
workingDir: this.workingDir,
|
|
5768
5825
|
baseMessages: [],
|
|
5769
5826
|
partialResponse: this.responseBuffer,
|
|
5770
5827
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -6040,7 +6097,7 @@ ${lastSnapshot}`;
|
|
|
6040
6097
|
}
|
|
6041
6098
|
}
|
|
6042
6099
|
if (this.isWaitingForResponse && !allowInputDuringGeneration) {
|
|
6043
|
-
if (!this.clearStaleIdleResponseGuard("send_message_guard")) {
|
|
6100
|
+
if (!this.clearStaleIdleResponseGuard("send_message_guard") && !this.clearParsedIdleResponseGuard("send_message_parsed_idle_guard", parsedStatusBeforeSend)) {
|
|
6044
6101
|
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
6045
6102
|
}
|
|
6046
6103
|
}
|
|
@@ -6418,10 +6475,17 @@ ${lastSnapshot}`;
|
|
|
6418
6475
|
getDebugState() {
|
|
6419
6476
|
const screenText = sanitizeTerminalText(this.terminalScreen.getText());
|
|
6420
6477
|
const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
6421
|
-
const
|
|
6422
|
-
const effectiveReady = this.ready || !!startupModal;
|
|
6478
|
+
const startupDetectedStatus = this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || screenText) : null;
|
|
6479
|
+
const effectiveReady = this.ready || !!startupModal || startupDetectedStatus === "waiting_approval";
|
|
6423
6480
|
const parsedDebugState = this.getParsedDebugState();
|
|
6424
6481
|
const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
|
|
6482
|
+
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
6483
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
6484
|
+
effectiveStatus = "waiting_approval";
|
|
6485
|
+
}
|
|
6486
|
+
if (effectiveStatus === "idle" && parsedDebugState?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsedDebugState)) {
|
|
6487
|
+
effectiveStatus = "generating";
|
|
6488
|
+
}
|
|
6425
6489
|
return {
|
|
6426
6490
|
type: this.cliType,
|
|
6427
6491
|
name: this.cliName,
|
|
@@ -12871,17 +12935,18 @@ function normalizeProviderNativeHistoryRecords(agentType, historySessionId, reco
|
|
|
12871
12935
|
function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
12872
12936
|
const fn = getProviderNativeHistoryScript(scripts, canonicalHistory, "readSession");
|
|
12873
12937
|
if (!fn) return null;
|
|
12938
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
12874
12939
|
const result = fn({
|
|
12875
12940
|
agentType,
|
|
12876
|
-
sessionId:
|
|
12877
|
-
historySessionId,
|
|
12941
|
+
sessionId: normalizedSessionId,
|
|
12942
|
+
historySessionId: normalizedSessionId,
|
|
12878
12943
|
workspace,
|
|
12879
12944
|
format: canonicalHistory?.format,
|
|
12880
12945
|
watchPath: canonicalHistory?.watchPath,
|
|
12881
|
-
args: { sessionId:
|
|
12946
|
+
args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, workspace }
|
|
12882
12947
|
});
|
|
12883
12948
|
if (!result || typeof result !== "object") return null;
|
|
12884
|
-
const records = normalizeProviderNativeHistoryRecords(agentType,
|
|
12949
|
+
const records = normalizeProviderNativeHistoryRecords(agentType, normalizedSessionId, result.messages || result.records);
|
|
12885
12950
|
if (records.length === 0) return null;
|
|
12886
12951
|
return {
|
|
12887
12952
|
records,
|
|
@@ -12891,7 +12956,8 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
|
|
|
12891
12956
|
}
|
|
12892
12957
|
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
12893
12958
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
12894
|
-
|
|
12959
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
12960
|
+
if (!canonicalHistory || !normalizedSessionId && !normalizedWorkspace || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
|
|
12895
12961
|
return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace);
|
|
12896
12962
|
}
|
|
12897
12963
|
function materializeNativeHistoryToMirror(agentType, canonicalHistory, historySessionId, workspace, scripts) {
|
|
@@ -12920,7 +12986,7 @@ function isNativeSourceCanonicalHistory(canonicalHistory) {
|
|
|
12920
12986
|
return true;
|
|
12921
12987
|
}
|
|
12922
12988
|
function readProviderChatHistory(agentType, options = {}) {
|
|
12923
|
-
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && options.historySessionId) {
|
|
12989
|
+
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && (options.historySessionId || options.workspace)) {
|
|
12924
12990
|
const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace);
|
|
12925
12991
|
if (!nativeResult) return { messages: [], hasMore: false, source: "native-unavailable" };
|
|
12926
12992
|
return {
|
|
@@ -18285,7 +18351,8 @@ var DaemonCommandHandler = class {
|
|
|
18285
18351
|
"pty_resize",
|
|
18286
18352
|
"invoke_provider_script"
|
|
18287
18353
|
]);
|
|
18288
|
-
const
|
|
18354
|
+
const isReadOrDebugCmd = cmd === "read_chat" || cmd === "get_chat_debug_bundle";
|
|
18355
|
+
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);
|
|
18289
18356
|
if (this._currentRoute.sessionLookupFailed && sessionScopedCommands.has(cmd) && !allowsInactiveReadChatFallback) {
|
|
18290
18357
|
const result2 = {
|
|
18291
18358
|
success: false,
|
|
@@ -33196,7 +33263,16 @@ async function handleCliSend(ctx, req, res) {
|
|
|
33196
33263
|
return;
|
|
33197
33264
|
}
|
|
33198
33265
|
try {
|
|
33199
|
-
|
|
33266
|
+
if (target.category === "cli") {
|
|
33267
|
+
const bundle = getCliTargetBundle(ctx, type, instanceId);
|
|
33268
|
+
if (!bundle) {
|
|
33269
|
+
ctx.json(res, 404, { error: `No running CLI adapter found for: ${type || instanceId}` });
|
|
33270
|
+
return;
|
|
33271
|
+
}
|
|
33272
|
+
await bundle.adapter.sendMessage(text);
|
|
33273
|
+
} else {
|
|
33274
|
+
ctx.instanceManager.sendEvent(target.instanceId, "send_message", { text });
|
|
33275
|
+
}
|
|
33200
33276
|
ctx.json(res, 200, { sent: true, type: target.type, instanceId: target.instanceId });
|
|
33201
33277
|
} catch (e) {
|
|
33202
33278
|
ctx.json(res, 500, { error: `Send failed: ${e.message}` });
|