@adhdev/daemon-core 0.9.82-rc.174 → 0.9.82-rc.175
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 +86 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -10
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-provider-instance.d.ts +3 -0
- package/dist/providers/spec/driver.d.ts +10 -0
- package/package.json +1 -1
- package/src/providers/cli-provider-instance.ts +90 -13
- package/src/providers/spec/driver.ts +39 -1
package/dist/index.js
CHANGED
|
@@ -27711,6 +27711,18 @@ function interpolate(template, state, sections) {
|
|
|
27711
27711
|
init_loader();
|
|
27712
27712
|
var STARTUP_GRACE_MS = 2500;
|
|
27713
27713
|
var BUSY_HOLD_MS = 6e3;
|
|
27714
|
+
var SUBMIT_DELAY_FLOOR_MS = 200;
|
|
27715
|
+
function countNewlines(s) {
|
|
27716
|
+
let n = 0;
|
|
27717
|
+
for (let i = 0; i < s.length; i += 1) if (s.charCodeAt(i) === 10) n += 1;
|
|
27718
|
+
return n;
|
|
27719
|
+
}
|
|
27720
|
+
function resolveSubmitDelayMs(specBeforeSubmit, text) {
|
|
27721
|
+
const lines = countNewlines(text);
|
|
27722
|
+
const linesBonus = Math.min(800, lines * 80);
|
|
27723
|
+
const spec = typeof specBeforeSubmit === "number" && specBeforeSubmit > 0 ? specBeforeSubmit : 0;
|
|
27724
|
+
return Math.max(spec, SUBMIT_DELAY_FLOOR_MS + linesBonus);
|
|
27725
|
+
}
|
|
27714
27726
|
var SpecDriver = class {
|
|
27715
27727
|
constructor(opts) {
|
|
27716
27728
|
this.opts = opts;
|
|
@@ -27938,7 +27950,7 @@ var SpecDriver = class {
|
|
|
27938
27950
|
actuallySendMessage(text) {
|
|
27939
27951
|
const sm = this.spec.send_message;
|
|
27940
27952
|
const perChar = sm.delay_ms_per_char ?? 0;
|
|
27941
|
-
const beforeSubmit = sm.delay_ms_before_submit
|
|
27953
|
+
const beforeSubmit = resolveSubmitDelayMs(sm.delay_ms_before_submit, text);
|
|
27942
27954
|
if (perChar === 0) {
|
|
27943
27955
|
this.adapter.send_keys(text);
|
|
27944
27956
|
if (beforeSubmit > 0) setTimeout(() => this.adapter.send_keys(sm.submit_key), beforeSubmit);
|
|
@@ -29088,6 +29100,50 @@ var CliProviderInstance = class {
|
|
|
29088
29100
|
if (looksLikeActiveApprovalPromptText(content)) return false;
|
|
29089
29101
|
return true;
|
|
29090
29102
|
}
|
|
29103
|
+
readExternalCompletionMessages() {
|
|
29104
|
+
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
29105
|
+
if (!adapterOwnsMessagesElsewhere) return null;
|
|
29106
|
+
if (!this.providerSessionId) return null;
|
|
29107
|
+
if (!isNativeSourceCanonicalHistory(this.provider.nativeHistory)) return null;
|
|
29108
|
+
const restoredHistory = readProviderChatHistory(this.type, {
|
|
29109
|
+
canonicalHistory: this.provider.nativeHistory,
|
|
29110
|
+
historySessionId: this.providerSessionId,
|
|
29111
|
+
workspace: this.workingDir,
|
|
29112
|
+
offset: 0,
|
|
29113
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
29114
|
+
historyBehavior: this.provider.historyBehavior,
|
|
29115
|
+
scripts: this.provider.scripts,
|
|
29116
|
+
sessionStartedAtMs: this.startedAt
|
|
29117
|
+
});
|
|
29118
|
+
if (restoredHistory.source !== "provider-native") return null;
|
|
29119
|
+
return restoredHistory.messages;
|
|
29120
|
+
}
|
|
29121
|
+
completionFinalAssistantEvidence(parsedMessages) {
|
|
29122
|
+
if (this.completionHasFinalAssistantMessage(parsedMessages)) {
|
|
29123
|
+
return {
|
|
29124
|
+
present: true,
|
|
29125
|
+
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
29126
|
+
source: "parsed"
|
|
29127
|
+
};
|
|
29128
|
+
}
|
|
29129
|
+
const externalMessages = this.readExternalCompletionMessages();
|
|
29130
|
+
if (externalMessages) {
|
|
29131
|
+
return {
|
|
29132
|
+
present: this.completionHasFinalAssistantMessage(externalMessages),
|
|
29133
|
+
messages: externalMessages,
|
|
29134
|
+
source: "external-native"
|
|
29135
|
+
};
|
|
29136
|
+
}
|
|
29137
|
+
return {
|
|
29138
|
+
present: false,
|
|
29139
|
+
messages: Array.isArray(parsedMessages) ? parsedMessages : [],
|
|
29140
|
+
source: "unavailable"
|
|
29141
|
+
};
|
|
29142
|
+
}
|
|
29143
|
+
completionFinalSummary(parsedMessages) {
|
|
29144
|
+
const evidence = this.completionFinalAssistantEvidence(parsedMessages);
|
|
29145
|
+
return extractFinalSummaryFromMessages(evidence.messages);
|
|
29146
|
+
}
|
|
29091
29147
|
buildCompletedFinalizationDiagnostic(args) {
|
|
29092
29148
|
let parsed = null;
|
|
29093
29149
|
let parseError;
|
|
@@ -29096,7 +29152,8 @@ var CliProviderInstance = class {
|
|
|
29096
29152
|
} catch (error) {
|
|
29097
29153
|
parseError = error?.message || String(error);
|
|
29098
29154
|
}
|
|
29099
|
-
const
|
|
29155
|
+
const evidence = this.completionFinalAssistantEvidence(parsed?.messages);
|
|
29156
|
+
const visibleMessages = (Array.isArray(evidence.messages) ? evidence.messages : []).filter((message) => isUserFacingChatMessage(message));
|
|
29100
29157
|
const lastVisible = visibleMessages[visibleMessages.length - 1];
|
|
29101
29158
|
const lastVisibleRole = typeof lastVisible?.role === "string" ? lastVisible.role.trim().toLowerCase() : null;
|
|
29102
29159
|
const lastVisibleKind = typeof lastVisible?.kind === "string" ? lastVisible.kind : null;
|
|
@@ -29114,7 +29171,8 @@ var CliProviderInstance = class {
|
|
|
29114
29171
|
latestVisibleStatus: args.latestVisibleStatus,
|
|
29115
29172
|
parsedStatus: typeof parsed?.status === "string" ? parsed.status : parseError ? "parse_error" : "unknown",
|
|
29116
29173
|
parseError: parseError || void 0,
|
|
29117
|
-
finalAssistantPresent:
|
|
29174
|
+
finalAssistantPresent: evidence.present,
|
|
29175
|
+
finalAssistantEvidenceSource: evidence.source,
|
|
29118
29176
|
visibleMessageCount: visibleMessages.length,
|
|
29119
29177
|
lastVisibleRole,
|
|
29120
29178
|
lastVisibleKind,
|
|
@@ -29177,8 +29235,21 @@ var CliProviderInstance = class {
|
|
|
29177
29235
|
}
|
|
29178
29236
|
if (parsed?.activeModal || parsed?.modal) return { reason: "parsed_modal_active", terminal: true };
|
|
29179
29237
|
const adapterOwnsMessagesElsewhere = this.adapter?.chatMessagesOwnedExternally === true;
|
|
29180
|
-
|
|
29181
|
-
|
|
29238
|
+
const finalAssistantEvidence = this.completionFinalAssistantEvidence(parsed?.messages);
|
|
29239
|
+
if (!finalAssistantEvidence.present) {
|
|
29240
|
+
if (adapterOwnsMessagesElsewhere) {
|
|
29241
|
+
if (finalAssistantEvidence.source === "external-native") {
|
|
29242
|
+
return { reason: "missing_final_assistant", terminal: true };
|
|
29243
|
+
}
|
|
29244
|
+
if (this.provider.requiresFinalAssistantBeforeIdle === true) {
|
|
29245
|
+
return { reason: "missing_final_assistant", terminal: true };
|
|
29246
|
+
}
|
|
29247
|
+
} else {
|
|
29248
|
+
return {
|
|
29249
|
+
reason: "missing_final_assistant",
|
|
29250
|
+
terminal: this.provider.requiresFinalAssistantBeforeIdle === true
|
|
29251
|
+
};
|
|
29252
|
+
}
|
|
29182
29253
|
}
|
|
29183
29254
|
try {
|
|
29184
29255
|
const screenText = typeof this.adapter.getScreenText === "function" ? String(this.adapter.getScreenText() || "") : "";
|
|
@@ -29237,7 +29308,7 @@ var CliProviderInstance = class {
|
|
|
29237
29308
|
chatTitle: pending.chatTitle,
|
|
29238
29309
|
duration: pending.duration,
|
|
29239
29310
|
timestamp: pending.timestamp,
|
|
29240
|
-
finalSummary: blockReason.startsWith("parsed_status:") ? "" :
|
|
29311
|
+
finalSummary: blockReason.startsWith("parsed_status:") ? "" : this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages),
|
|
29241
29312
|
completionDiagnostic
|
|
29242
29313
|
});
|
|
29243
29314
|
this.completedDebouncePending = null;
|
|
@@ -29252,7 +29323,7 @@ var CliProviderInstance = class {
|
|
|
29252
29323
|
chatTitle: pending.chatTitle,
|
|
29253
29324
|
duration: pending.duration,
|
|
29254
29325
|
timestamp: pending.timestamp,
|
|
29255
|
-
finalSummary:
|
|
29326
|
+
finalSummary: this.completionFinalSummary(this.adapter?.getScriptParsedStatus()?.messages)
|
|
29256
29327
|
});
|
|
29257
29328
|
this.completedDebouncePending = null;
|
|
29258
29329
|
this.completedDebounceTimer = null;
|
|
@@ -29385,11 +29456,15 @@ var CliProviderInstance = class {
|
|
|
29385
29456
|
this.generatingDebouncePending = null;
|
|
29386
29457
|
this.generatingStartedAt = 0;
|
|
29387
29458
|
let shortFinalSummary;
|
|
29459
|
+
let shortEvidenceSource = "unavailable";
|
|
29388
29460
|
try {
|
|
29389
|
-
|
|
29461
|
+
const parsedMessages = this.adapter?.getScriptParsedStatus()?.messages;
|
|
29462
|
+
const evidence = this.completionFinalAssistantEvidence(parsedMessages);
|
|
29463
|
+
shortEvidenceSource = evidence.source;
|
|
29464
|
+
shortFinalSummary = extractFinalSummaryFromMessages(evidence.messages);
|
|
29390
29465
|
} catch {
|
|
29391
29466
|
}
|
|
29392
|
-
if (this.provider.requiresFinalAssistantBeforeIdle === true && !shortFinalSummary) {
|
|
29467
|
+
if ((this.provider.requiresFinalAssistantBeforeIdle === true || shortEvidenceSource === "external-native") && !shortFinalSummary) {
|
|
29393
29468
|
LOG.info("CLI", `[${this.type}] suppressed short completion without final assistant evidence`);
|
|
29394
29469
|
} else {
|
|
29395
29470
|
this.pushEvent({
|
|
@@ -29400,7 +29475,8 @@ var CliProviderInstance = class {
|
|
|
29400
29475
|
finalSummary: shortFinalSummary,
|
|
29401
29476
|
completionDiagnostic: {
|
|
29402
29477
|
reason: "short_generating_suppressed",
|
|
29403
|
-
shortDurationMs
|
|
29478
|
+
shortDurationMs,
|
|
29479
|
+
finalAssistantEvidenceSource: shortEvidenceSource
|
|
29404
29480
|
}
|
|
29405
29481
|
});
|
|
29406
29482
|
}
|