@adhdev/daemon-standalone 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/index.js +87 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26378,6 +26378,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
26378
26378
|
accumulatedRawBuffer,
|
|
26379
26379
|
recentOutputBuffer,
|
|
26380
26380
|
terminalScreenText,
|
|
26381
|
+
workingDir,
|
|
26381
26382
|
baseMessages,
|
|
26382
26383
|
partialResponse,
|
|
26383
26384
|
isWaitingForResponse,
|
|
@@ -26393,6 +26394,8 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
26393
26394
|
rawBuffer,
|
|
26394
26395
|
recentBuffer,
|
|
26395
26396
|
screenText,
|
|
26397
|
+
workspace: workingDir,
|
|
26398
|
+
workingDir,
|
|
26396
26399
|
screen: buildCliScreenSnapshot(screenText),
|
|
26397
26400
|
bufferScreen: buildCliScreenSnapshot(buffer),
|
|
26398
26401
|
recentScreen: buildCliScreenSnapshot(recentBuffer),
|
|
@@ -27115,6 +27118,17 @@ ${lastSnapshot}`;
|
|
|
27115
27118
|
const stableMs = this.lastScreenChangeAt ? now - this.lastScreenChangeAt : 0;
|
|
27116
27119
|
if (stableMs < 2e3) return;
|
|
27117
27120
|
const startupModal = this.runParseApproval(this.recentOutputBuffer);
|
|
27121
|
+
const startupStatus = this.runDetectStatus(screenText || this.recentOutputBuffer);
|
|
27122
|
+
if (!startupModal && startupStatus !== "idle") {
|
|
27123
|
+
this.recordTrace("startup_settle_deferred", {
|
|
27124
|
+
trigger,
|
|
27125
|
+
startupStatus,
|
|
27126
|
+
stableMs,
|
|
27127
|
+
screenText: summarizeCliTraceText(screenText, 500)
|
|
27128
|
+
});
|
|
27129
|
+
this.scheduleStartupSettleCheck();
|
|
27130
|
+
return;
|
|
27131
|
+
}
|
|
27118
27132
|
this.startupParseGate = false;
|
|
27119
27133
|
if (this.startupSettleTimer) {
|
|
27120
27134
|
clearTimeout(this.startupSettleTimer);
|
|
@@ -27313,6 +27327,31 @@ ${lastSnapshot}`;
|
|
|
27313
27327
|
this.recordTrace("stale_idle_response_cleared", { reason });
|
|
27314
27328
|
return true;
|
|
27315
27329
|
}
|
|
27330
|
+
clearParsedIdleResponseGuard(reason, parsedStatus) {
|
|
27331
|
+
const parsedRawStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status.trim() : "";
|
|
27332
|
+
const parsedModal = parsedStatus?.activeModal ?? parsedStatus?.modal ?? null;
|
|
27333
|
+
const blockingModal = this.activeModal || this.runParseApproval(this.recentOutputBuffer);
|
|
27334
|
+
if (!this.isWaitingForResponse || parsedRawStatus !== "idle" || !!parsedModal || !!blockingModal || !this.parsedStatusHasFinalAssistantMessage(parsedStatus)) {
|
|
27335
|
+
return false;
|
|
27336
|
+
}
|
|
27337
|
+
this.clearAllTimers();
|
|
27338
|
+
this.clearIdleFinishCandidate(reason);
|
|
27339
|
+
this.responseBuffer = "";
|
|
27340
|
+
this.isWaitingForResponse = false;
|
|
27341
|
+
this.responseSettleIgnoreUntil = 0;
|
|
27342
|
+
this.submitRetryUsed = false;
|
|
27343
|
+
this.submitRetryPromptSnippet = "";
|
|
27344
|
+
this.finishRetryCount = 0;
|
|
27345
|
+
this.currentTurnScope = null;
|
|
27346
|
+
this.activeModal = null;
|
|
27347
|
+
this.setStatus("idle", reason);
|
|
27348
|
+
this.recordTrace("parsed_idle_response_cleared", {
|
|
27349
|
+
reason,
|
|
27350
|
+
parsedStatus: parsedRawStatus,
|
|
27351
|
+
parsedMessageCount: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : 0
|
|
27352
|
+
});
|
|
27353
|
+
return true;
|
|
27354
|
+
}
|
|
27316
27355
|
hasMeaningfulResponseBuffer(promptSnippet) {
|
|
27317
27356
|
const raw = String(this.responseBuffer || "").trim();
|
|
27318
27357
|
if (!raw) return false;
|
|
@@ -27782,6 +27821,7 @@ ${lastSnapshot}`;
|
|
|
27782
27821
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
27783
27822
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
27784
27823
|
terminalScreenText: parseScreenText,
|
|
27824
|
+
workingDir: this.workingDir,
|
|
27785
27825
|
baseMessages: [],
|
|
27786
27826
|
partialResponse: this.responseBuffer,
|
|
27787
27827
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -27841,6 +27881,14 @@ ${lastSnapshot}`;
|
|
|
27841
27881
|
hasActionableApproval(startupModal = null) {
|
|
27842
27882
|
return !!(startupModal || this.activeModal);
|
|
27843
27883
|
}
|
|
27884
|
+
parsedStatusHasFinalAssistantMessage(parsed) {
|
|
27885
|
+
const messages = Array.isArray(parsed?.messages) ? parsed.messages : [];
|
|
27886
|
+
const lastAssistant = [...messages].reverse().find((message) => {
|
|
27887
|
+
if (!message || message.role !== "assistant") return false;
|
|
27888
|
+
return typeof message.content === "string" && message.content.trim().length > 0;
|
|
27889
|
+
});
|
|
27890
|
+
return !!lastAssistant;
|
|
27891
|
+
}
|
|
27844
27892
|
projectEffectiveStatus(startupModal = null) {
|
|
27845
27893
|
if (this.parseErrorMessage) return "error";
|
|
27846
27894
|
if (this.hasActionableApproval(startupModal)) return "waiting_approval";
|
|
@@ -27851,14 +27899,22 @@ ${lastSnapshot}`;
|
|
|
27851
27899
|
getStatus(options = {}) {
|
|
27852
27900
|
const allowParse = options.allowParse !== false;
|
|
27853
27901
|
const startupModal = allowParse && this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
27902
|
+
const startupDetectedStatus = allowParse && this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || this.terminalScreen.getText()) : null;
|
|
27854
27903
|
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
27855
27904
|
let effectiveModal = startupModal || this.activeModal;
|
|
27905
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
27906
|
+
effectiveStatus = "waiting_approval";
|
|
27907
|
+
}
|
|
27856
27908
|
if (allowParse && !startupModal && !effectiveModal) {
|
|
27857
27909
|
const parsed = this.getFreshParsedStatusCache();
|
|
27858
27910
|
const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
|
|
27859
27911
|
if (parsed?.status === "waiting_approval" && parsedModal) {
|
|
27860
27912
|
effectiveStatus = "waiting_approval";
|
|
27861
27913
|
effectiveModal = parsedModal;
|
|
27914
|
+
} else if (effectiveStatus === "idle" && parsed?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
27915
|
+
effectiveStatus = "generating";
|
|
27916
|
+
} else if (effectiveStatus === "generating" && parsed?.status === "idle" && this.parsedStatusHasFinalAssistantMessage(parsed)) {
|
|
27917
|
+
effectiveStatus = "idle";
|
|
27862
27918
|
}
|
|
27863
27919
|
}
|
|
27864
27920
|
const bufferState = this.getBufferState();
|
|
@@ -27928,6 +27984,7 @@ ${lastSnapshot}`;
|
|
|
27928
27984
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
27929
27985
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
27930
27986
|
terminalScreenText: this.getParseScreenText(this.terminalScreen.getText()),
|
|
27987
|
+
workingDir: this.workingDir,
|
|
27931
27988
|
baseMessages: [],
|
|
27932
27989
|
partialResponse: this.responseBuffer,
|
|
27933
27990
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
@@ -28203,7 +28260,7 @@ ${lastSnapshot}`;
|
|
|
28203
28260
|
}
|
|
28204
28261
|
}
|
|
28205
28262
|
if (this.isWaitingForResponse && !allowInputDuringGeneration) {
|
|
28206
|
-
if (!this.clearStaleIdleResponseGuard("send_message_guard")) {
|
|
28263
|
+
if (!this.clearStaleIdleResponseGuard("send_message_guard") && !this.clearParsedIdleResponseGuard("send_message_parsed_idle_guard", parsedStatusBeforeSend)) {
|
|
28207
28264
|
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
28208
28265
|
}
|
|
28209
28266
|
}
|
|
@@ -28581,10 +28638,17 @@ ${lastSnapshot}`;
|
|
|
28581
28638
|
getDebugState() {
|
|
28582
28639
|
const screenText = sanitizeTerminalText(this.terminalScreen.getText());
|
|
28583
28640
|
const startupModal = this.startupParseGate ? this.runParseApproval(this.recentOutputBuffer) : null;
|
|
28584
|
-
const
|
|
28585
|
-
const effectiveReady = this.ready || !!startupModal;
|
|
28641
|
+
const startupDetectedStatus = this.startupParseGate && !startupModal ? this.runDetectStatus(this.recentOutputBuffer || screenText) : null;
|
|
28642
|
+
const effectiveReady = this.ready || !!startupModal || startupDetectedStatus === "waiting_approval";
|
|
28586
28643
|
const parsedDebugState = this.getParsedDebugState();
|
|
28587
28644
|
const parsedMessages = Array.isArray(parsedDebugState?.messages) ? parsedDebugState.messages : [];
|
|
28645
|
+
let effectiveStatus = this.projectEffectiveStatus(startupModal);
|
|
28646
|
+
if (startupDetectedStatus === "waiting_approval") {
|
|
28647
|
+
effectiveStatus = "waiting_approval";
|
|
28648
|
+
}
|
|
28649
|
+
if (effectiveStatus === "idle" && parsedDebugState?.status === "generating" && !this.parsedStatusHasFinalAssistantMessage(parsedDebugState)) {
|
|
28650
|
+
effectiveStatus = "generating";
|
|
28651
|
+
}
|
|
28588
28652
|
return {
|
|
28589
28653
|
type: this.cliType,
|
|
28590
28654
|
name: this.cliName,
|
|
@@ -35206,17 +35270,18 @@ ${cleanBody}`;
|
|
|
35206
35270
|
function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
35207
35271
|
const fn = getProviderNativeHistoryScript(scripts, canonicalHistory, "readSession");
|
|
35208
35272
|
if (!fn) return null;
|
|
35273
|
+
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
35209
35274
|
const result = fn({
|
|
35210
35275
|
agentType,
|
|
35211
|
-
sessionId:
|
|
35212
|
-
historySessionId,
|
|
35276
|
+
sessionId: normalizedSessionId,
|
|
35277
|
+
historySessionId: normalizedSessionId,
|
|
35213
35278
|
workspace,
|
|
35214
35279
|
format: canonicalHistory?.format,
|
|
35215
35280
|
watchPath: canonicalHistory?.watchPath,
|
|
35216
|
-
args: { sessionId:
|
|
35281
|
+
args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, workspace }
|
|
35217
35282
|
});
|
|
35218
35283
|
if (!result || typeof result !== "object") return null;
|
|
35219
|
-
const records = normalizeProviderNativeHistoryRecords(agentType,
|
|
35284
|
+
const records = normalizeProviderNativeHistoryRecords(agentType, normalizedSessionId, result.messages || result.records);
|
|
35220
35285
|
if (records.length === 0) return null;
|
|
35221
35286
|
return {
|
|
35222
35287
|
records,
|
|
@@ -35226,7 +35291,8 @@ ${cleanBody}`;
|
|
|
35226
35291
|
}
|
|
35227
35292
|
function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace) {
|
|
35228
35293
|
const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
|
|
35229
|
-
|
|
35294
|
+
const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
|
|
35295
|
+
if (!canonicalHistory || !normalizedSessionId && !normalizedWorkspace || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
|
|
35230
35296
|
return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace);
|
|
35231
35297
|
}
|
|
35232
35298
|
function materializeNativeHistoryToMirror(agentType, canonicalHistory, historySessionId, workspace, scripts) {
|
|
@@ -35255,7 +35321,7 @@ ${cleanBody}`;
|
|
|
35255
35321
|
return true;
|
|
35256
35322
|
}
|
|
35257
35323
|
function readProviderChatHistory(agentType, options = {}) {
|
|
35258
|
-
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && options.historySessionId) {
|
|
35324
|
+
if (isNativeSourceCanonicalHistory(options.canonicalHistory) && (options.historySessionId || options.workspace)) {
|
|
35259
35325
|
const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace);
|
|
35260
35326
|
if (!nativeResult) return { messages: [], hasMore: false, source: "native-unavailable" };
|
|
35261
35327
|
return {
|
|
@@ -40560,7 +40626,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40560
40626
|
"pty_resize",
|
|
40561
40627
|
"invoke_provider_script"
|
|
40562
40628
|
]);
|
|
40563
|
-
const
|
|
40629
|
+
const isReadOrDebugCmd = cmd === "read_chat" || cmd === "get_chat_debug_bundle";
|
|
40630
|
+
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);
|
|
40564
40631
|
if (this._currentRoute.sessionLookupFailed && sessionScopedCommands.has(cmd) && !allowsInactiveReadChatFallback) {
|
|
40565
40632
|
const result2 = {
|
|
40566
40633
|
success: false,
|
|
@@ -55390,7 +55457,16 @@ async (params) => {
|
|
|
55390
55457
|
return;
|
|
55391
55458
|
}
|
|
55392
55459
|
try {
|
|
55393
|
-
|
|
55460
|
+
if (target.category === "cli") {
|
|
55461
|
+
const bundle = getCliTargetBundle(ctx, type, instanceId);
|
|
55462
|
+
if (!bundle) {
|
|
55463
|
+
ctx.json(res, 404, { error: `No running CLI adapter found for: ${type || instanceId}` });
|
|
55464
|
+
return;
|
|
55465
|
+
}
|
|
55466
|
+
await bundle.adapter.sendMessage(text);
|
|
55467
|
+
} else {
|
|
55468
|
+
ctx.instanceManager.sendEvent(target.instanceId, "send_message", { text });
|
|
55469
|
+
}
|
|
55394
55470
|
ctx.json(res, 200, { sent: true, type: target.type, instanceId: target.instanceId });
|
|
55395
55471
|
} catch (e) {
|
|
55396
55472
|
ctx.json(res, 500, { error: `Send failed: ${e.message}` });
|