@adhdev/daemon-standalone 0.9.34 → 0.9.36
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 +152 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{index-4TARDjk2.js → index-CsRhFifV.js} +17 -17
- package/public/index.html +1 -1
- package/vendor/session-host-daemon/index.js +8 -1
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +8 -1
- package/vendor/session-host-daemon/index.mjs.map +1 -1
package/dist/index.js
CHANGED
|
@@ -29954,6 +29954,8 @@ var require_dist2 = __commonJS({
|
|
|
29954
29954
|
messages = [];
|
|
29955
29955
|
committedMessages = [];
|
|
29956
29956
|
structuredMessages = [];
|
|
29957
|
+
committedMessagesActivitySignature = "";
|
|
29958
|
+
committedMessagesChangedAt = 0;
|
|
29957
29959
|
currentStatus = "starting";
|
|
29958
29960
|
onStatusChange = null;
|
|
29959
29961
|
responseBuffer = "";
|
|
@@ -30035,10 +30037,35 @@ var require_dist2 = __commonJS({
|
|
|
30035
30037
|
providerResolutionMeta;
|
|
30036
30038
|
static FINISH_RETRY_DELAY_MS = 300;
|
|
30037
30039
|
static MAX_FINISH_RETRIES = 2;
|
|
30040
|
+
buildCommittedMessagesActivitySignature() {
|
|
30041
|
+
const last = this.committedMessages[this.committedMessages.length - 1];
|
|
30042
|
+
return [
|
|
30043
|
+
String(this.committedMessages.length),
|
|
30044
|
+
String(last?.role || ""),
|
|
30045
|
+
String(last?.kind || ""),
|
|
30046
|
+
String(last?.senderName || ""),
|
|
30047
|
+
String(last?.timestamp || ""),
|
|
30048
|
+
String(last?.receivedAt || ""),
|
|
30049
|
+
normalizeComparableMessageContent(last?.content || "").slice(-240)
|
|
30050
|
+
].join("|");
|
|
30051
|
+
}
|
|
30038
30052
|
syncMessageViews() {
|
|
30053
|
+
const signature = this.buildCommittedMessagesActivitySignature();
|
|
30054
|
+
if (signature !== this.committedMessagesActivitySignature) {
|
|
30055
|
+
this.committedMessagesActivitySignature = signature;
|
|
30056
|
+
this.committedMessagesChangedAt = Date.now();
|
|
30057
|
+
}
|
|
30039
30058
|
this.messages = [...this.committedMessages];
|
|
30040
30059
|
this.structuredMessages = [...this.committedMessages];
|
|
30041
30060
|
}
|
|
30061
|
+
getLastCommittedMessageActivityAt() {
|
|
30062
|
+
const last = this.committedMessages[this.committedMessages.length - 1];
|
|
30063
|
+
const messageTime = Math.max(
|
|
30064
|
+
typeof last?.receivedAt === "number" && Number.isFinite(last.receivedAt) ? last.receivedAt : 0,
|
|
30065
|
+
typeof last?.timestamp === "number" && Number.isFinite(last.timestamp) ? last.timestamp : 0
|
|
30066
|
+
);
|
|
30067
|
+
return Math.max(messageTime, this.committedMessagesChangedAt || 0);
|
|
30068
|
+
}
|
|
30042
30069
|
readTerminalScreenText(now = Date.now()) {
|
|
30043
30070
|
const screenText = this.terminalScreen.getText() || "";
|
|
30044
30071
|
this.lastScreenText = screenText;
|
|
@@ -30067,7 +30094,16 @@ var require_dist2 = __commonJS({
|
|
|
30067
30094
|
if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
|
|
30068
30095
|
return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
|
|
30069
30096
|
}
|
|
30097
|
+
messagesShareStableIdentity(left, right) {
|
|
30098
|
+
if (left === right) return true;
|
|
30099
|
+
if (!left || !right) return false;
|
|
30100
|
+
if ((left.role || "") !== (right.role || "")) return false;
|
|
30101
|
+
if (left.id && right.id && String(left.id) === String(right.id)) return true;
|
|
30102
|
+
if (typeof left.index === "number" && typeof right.index === "number" && left.index === right.index) return true;
|
|
30103
|
+
return false;
|
|
30104
|
+
}
|
|
30070
30105
|
messagesComparable(left, right) {
|
|
30106
|
+
if (this.messagesShareStableIdentity(left, right)) return true;
|
|
30071
30107
|
if (!left || !right) return false;
|
|
30072
30108
|
if ((left.role || "") !== (right.role || "")) return false;
|
|
30073
30109
|
const leftText = normalizeComparableTranscriptText(left.content);
|
|
@@ -30178,9 +30214,16 @@ var require_dist2 = __commonJS({
|
|
|
30178
30214
|
/** Inject CLI scripts after construction (e.g. when resolved by ProviderLoader) */
|
|
30179
30215
|
setCliScripts(scripts) {
|
|
30180
30216
|
this.cliScripts = scripts;
|
|
30217
|
+
this.parsedStatusCache = null;
|
|
30218
|
+
this.parseErrorMessage = null;
|
|
30181
30219
|
const scriptNames = listCliScriptNames(scripts);
|
|
30182
30220
|
LOG2.info("CLI", `[${this.cliType}] CLI scripts injected: [${scriptNames.join(", ")}]`);
|
|
30183
30221
|
}
|
|
30222
|
+
/** Refresh provider scripts/config used by this adapter without restarting the PTY runtime. */
|
|
30223
|
+
refreshProviderDefinition(provider) {
|
|
30224
|
+
this.provider = provider;
|
|
30225
|
+
this.setCliScripts(provider.scripts || {});
|
|
30226
|
+
}
|
|
30184
30227
|
updateRuntimeSettings(settings) {
|
|
30185
30228
|
this.runtimeSettings = { ...settings };
|
|
30186
30229
|
}
|
|
@@ -31211,6 +31254,69 @@ var require_dist2 = __commonJS({
|
|
|
31211
31254
|
this.committedMessages = normalized;
|
|
31212
31255
|
this.syncMessageViews();
|
|
31213
31256
|
}
|
|
31257
|
+
getSharedCommittedPrefixLength(parsedMessages) {
|
|
31258
|
+
const committedMessages = this.committedMessages;
|
|
31259
|
+
const max = Math.min(parsedMessages.length, committedMessages.length);
|
|
31260
|
+
let index = 0;
|
|
31261
|
+
while (index < max && this.messagesShareStableIdentity(parsedMessages[index], committedMessages[index])) {
|
|
31262
|
+
index += 1;
|
|
31263
|
+
}
|
|
31264
|
+
return index;
|
|
31265
|
+
}
|
|
31266
|
+
hydrateCommittedPrefixForParsedStatus(parsedMessages) {
|
|
31267
|
+
const sharedPrefixLength = this.getSharedCommittedPrefixLength(parsedMessages);
|
|
31268
|
+
if (sharedPrefixLength !== this.committedMessages.length) return null;
|
|
31269
|
+
const committedHydratedMessages = this.committedMessages.map((message, index) => {
|
|
31270
|
+
const timestamp = typeof message.timestamp === "number" && Number.isFinite(message.timestamp) ? message.timestamp : this.lastOutputAt || this.currentTurnScope?.startedAt || Date.now();
|
|
31271
|
+
const contentValue = message.content;
|
|
31272
|
+
return {
|
|
31273
|
+
role: message.role,
|
|
31274
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
31275
|
+
timestamp,
|
|
31276
|
+
receivedAt: typeof message.receivedAt === "number" && Number.isFinite(message.receivedAt) ? message.receivedAt : timestamp,
|
|
31277
|
+
kind: message.kind,
|
|
31278
|
+
id: message.id || `msg_${index}`,
|
|
31279
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
31280
|
+
meta: message.meta,
|
|
31281
|
+
senderName: message.senderName
|
|
31282
|
+
};
|
|
31283
|
+
});
|
|
31284
|
+
const extraMessages = parsedMessages.slice(sharedPrefixLength);
|
|
31285
|
+
if (extraMessages.length === 0) return committedHydratedMessages;
|
|
31286
|
+
const extraHydratedMessages = hydrateCliParsedMessages(extraMessages, {
|
|
31287
|
+
committedMessages: [],
|
|
31288
|
+
scope: this.currentTurnScope,
|
|
31289
|
+
lastOutputAt: this.lastOutputAt
|
|
31290
|
+
}).map((message, offset) => ({
|
|
31291
|
+
...message,
|
|
31292
|
+
id: message.id || `msg_${sharedPrefixLength + offset}`,
|
|
31293
|
+
index: typeof message.index === "number" ? message.index : sharedPrefixLength + offset
|
|
31294
|
+
}));
|
|
31295
|
+
return [...committedHydratedMessages, ...extraHydratedMessages];
|
|
31296
|
+
}
|
|
31297
|
+
hydrateParsedMessagesForStatus(parsedMessages) {
|
|
31298
|
+
return this.hydrateCommittedPrefixForParsedStatus(parsedMessages) || hydrateCliParsedMessages(parsedMessages, {
|
|
31299
|
+
committedMessages: this.committedMessages,
|
|
31300
|
+
scope: this.currentTurnScope,
|
|
31301
|
+
lastOutputAt: this.lastOutputAt
|
|
31302
|
+
});
|
|
31303
|
+
}
|
|
31304
|
+
buildCommittedChatMessages() {
|
|
31305
|
+
return this.committedMessages.map((message, index) => {
|
|
31306
|
+
const contentValue = message.content;
|
|
31307
|
+
return buildChatMessage({
|
|
31308
|
+
role: message.role,
|
|
31309
|
+
content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
|
|
31310
|
+
timestamp: message.timestamp,
|
|
31311
|
+
kind: message.kind,
|
|
31312
|
+
meta: message.meta,
|
|
31313
|
+
senderName: message.senderName,
|
|
31314
|
+
id: message.id || `msg_${index}`,
|
|
31315
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
31316
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31317
|
+
});
|
|
31318
|
+
});
|
|
31319
|
+
}
|
|
31214
31320
|
/**
|
|
31215
31321
|
* Script-based full parse — returns ReadChatResult.
|
|
31216
31322
|
* Called by command handler / dashboard for rich content rendering.
|
|
@@ -31236,7 +31342,7 @@ var require_dist2 = __commonJS({
|
|
|
31236
31342
|
this.onStatusChange?.();
|
|
31237
31343
|
}
|
|
31238
31344
|
}
|
|
31239
|
-
if (parsed && Array.isArray(parsed.messages)) {
|
|
31345
|
+
if (parsed && Array.isArray(parsed.messages) && this.provider.allowInputDuringGeneration === true) {
|
|
31240
31346
|
const hydratedForCommit = normalizeCliParsedMessages(parsed.messages, {
|
|
31241
31347
|
committedMessages: this.committedMessages,
|
|
31242
31348
|
scope: this.currentTurnScope,
|
|
@@ -31255,21 +31361,21 @@ var require_dist2 = __commonJS({
|
|
|
31255
31361
|
const shouldPreferCommittedMessages = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle";
|
|
31256
31362
|
let result;
|
|
31257
31363
|
if (parsed && Array.isArray(parsed.messages)) {
|
|
31258
|
-
const parsedHydratedMessages =
|
|
31259
|
-
committedMessages: this.committedMessages,
|
|
31260
|
-
scope: this.currentTurnScope,
|
|
31261
|
-
lastOutputAt: this.lastOutputAt
|
|
31262
|
-
});
|
|
31263
|
-
const committedHydratedMessages = this.committedMessages.map((message, index) => buildChatMessage({
|
|
31264
|
-
...message,
|
|
31265
|
-
id: message.id || `msg_${index}`,
|
|
31266
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
31267
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31268
|
-
}));
|
|
31364
|
+
const parsedHydratedMessages = this.hydrateParsedMessagesForStatus(parsed.messages);
|
|
31269
31365
|
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
31270
|
-
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages,
|
|
31366
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && !!parsedLastAssistant && parsedTranscriptIsRicherThanCommitted(parsedHydratedMessages, this.committedMessages) && (this.currentStatus === "idle" || this.currentStatus === "generating" && this.isWaitingForResponse && parsed.status === "idle" && this.runDetectStatus(this.recentOutputBuffer) === "idle");
|
|
31271
31367
|
if (shouldAdoptParsedIdleReplay) {
|
|
31272
|
-
this.committedMessages =
|
|
31368
|
+
this.committedMessages = this.getSharedCommittedPrefixLength(parsed.messages) === this.committedMessages.length ? parsedHydratedMessages.map((message) => ({
|
|
31369
|
+
role: message.role,
|
|
31370
|
+
content: typeof message.content === "string" ? message.content : String(message.content || ""),
|
|
31371
|
+
timestamp: message.timestamp,
|
|
31372
|
+
receivedAt: message.receivedAt,
|
|
31373
|
+
kind: message.kind,
|
|
31374
|
+
id: message.id,
|
|
31375
|
+
index: message.index,
|
|
31376
|
+
meta: message.meta,
|
|
31377
|
+
senderName: message.senderName
|
|
31378
|
+
})) : normalizeCliParsedMessages(parsed.messages, {
|
|
31273
31379
|
committedMessages: this.committedMessages,
|
|
31274
31380
|
scope: this.currentTurnScope,
|
|
31275
31381
|
lastOutputAt: this.lastOutputAt
|
|
@@ -31288,15 +31394,9 @@ var require_dist2 = __commonJS({
|
|
|
31288
31394
|
this.onStatusChange?.();
|
|
31289
31395
|
}
|
|
31290
31396
|
}
|
|
31291
|
-
const
|
|
31292
|
-
...message,
|
|
31293
|
-
id: message.id || `msg_${index}`,
|
|
31294
|
-
index: typeof message.index === "number" ? message.index : index,
|
|
31295
|
-
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
31296
|
-
})) : committedHydratedMessages;
|
|
31297
|
-
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
31397
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && this.committedMessages.length > parsedHydratedMessages.length;
|
|
31298
31398
|
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
31299
|
-
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ?
|
|
31399
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? this.buildCommittedChatMessages() : parsedHydratedMessages;
|
|
31300
31400
|
result = {
|
|
31301
31401
|
id: parsed.id || "cli_session",
|
|
31302
31402
|
status: parsed.status || this.currentStatus,
|
|
@@ -40747,7 +40847,14 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40747
40847
|
await this._ctx.providerLoader.fetchLatest().catch(() => {
|
|
40748
40848
|
});
|
|
40749
40849
|
this._ctx.providerLoader.reload();
|
|
40750
|
-
|
|
40850
|
+
this._ctx.providerLoader.registerToDetector();
|
|
40851
|
+
const refreshedInstances = this._ctx.instanceManager ? this._ctx.instanceManager.refreshProviderDefinitions((providerType) => this._ctx.providerLoader.resolve(providerType)) : 0;
|
|
40852
|
+
const providers = this._ctx.providerLoader.getAll().map((provider) => ({
|
|
40853
|
+
type: provider.type,
|
|
40854
|
+
name: provider.name,
|
|
40855
|
+
category: provider.category
|
|
40856
|
+
}));
|
|
40857
|
+
return { success: true, refreshedInstances, providers };
|
|
40751
40858
|
}
|
|
40752
40859
|
return { success: false, error: "ProviderLoader not initialized" };
|
|
40753
40860
|
}
|
|
@@ -40994,6 +41101,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
40994
41101
|
launchMode;
|
|
40995
41102
|
startedAt = Date.now();
|
|
40996
41103
|
onProviderSessionResolved;
|
|
41104
|
+
refreshProviderDefinition(provider) {
|
|
41105
|
+
if (provider.type !== this.type || provider.category !== "cli") return;
|
|
41106
|
+
this.provider = provider;
|
|
41107
|
+
this.adapter.refreshProviderDefinition(provider);
|
|
41108
|
+
}
|
|
40997
41109
|
// ─── Lifecycle ─────────────────────────────────
|
|
40998
41110
|
async init(context) {
|
|
40999
41111
|
this.context = context;
|
|
@@ -41204,9 +41316,11 @@ ${effect.notification.body || ""}`.trim();
|
|
|
41204
41316
|
const autoApproveActive = adapterStatus.status === "waiting_approval" && this.shouldAutoApprove();
|
|
41205
41317
|
const visibleStatus = autoApproveActive ? "generating" : adapterStatus.status;
|
|
41206
41318
|
const runtime = this.adapter.getRuntimeMetadata();
|
|
41319
|
+
const lastCommittedMessageActivityAt = typeof this.adapter.getLastCommittedMessageActivityAt === "function" ? this.adapter.getLastCommittedMessageActivityAt() : 0;
|
|
41207
41320
|
return {
|
|
41208
41321
|
id: this.instanceId,
|
|
41209
41322
|
status: visibleStatus,
|
|
41323
|
+
lastMessageAt: lastCommittedMessageActivityAt || void 0,
|
|
41210
41324
|
runtimeLifecycle: runtime?.lifecycle ?? null,
|
|
41211
41325
|
runtimeSurfaceKind: runtime?.surfaceKind,
|
|
41212
41326
|
runtimeRestoredFromStorage: runtime?.restoredFromStorage === true,
|
|
@@ -48643,6 +48757,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
48643
48757
|
const project = (item) => ({
|
|
48644
48758
|
id: item.instanceId,
|
|
48645
48759
|
status: item.activeChat?.status || item.status,
|
|
48760
|
+
unread: item.unread,
|
|
48761
|
+
inboxBucket: item.inboxBucket,
|
|
48762
|
+
lastMessageAt: item.lastMessageAt ?? item.activeChat?.lastMessageAt,
|
|
48646
48763
|
runtimeLifecycle: item.runtime?.lifecycle ?? null,
|
|
48647
48764
|
runtimeSurfaceKind: item.runtime?.surfaceKind,
|
|
48648
48765
|
runtimeRestoredFromStorage: item.runtime?.restoredFromStorage === true,
|
|
@@ -48850,6 +48967,17 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
48850
48967
|
}
|
|
48851
48968
|
return updated;
|
|
48852
48969
|
}
|
|
48970
|
+
refreshProviderDefinitions(resolveProvider) {
|
|
48971
|
+
let refreshed = 0;
|
|
48972
|
+
for (const instance of this.instances.values()) {
|
|
48973
|
+
if (typeof instance.refreshProviderDefinition !== "function") continue;
|
|
48974
|
+
const provider = resolveProvider(instance.type);
|
|
48975
|
+
if (!provider || typeof provider !== "object") continue;
|
|
48976
|
+
instance.refreshProviderDefinition(provider);
|
|
48977
|
+
refreshed += 1;
|
|
48978
|
+
}
|
|
48979
|
+
return refreshed;
|
|
48980
|
+
}
|
|
48853
48981
|
// ─── cleanup ──────────────────────────────────────
|
|
48854
48982
|
/**
|
|
48855
48983
|
* All terminate
|
|
@@ -53076,20 +53204,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
53076
53204
|
async handleReload(_req, res) {
|
|
53077
53205
|
try {
|
|
53078
53206
|
this.providerLoader.reload();
|
|
53079
|
-
|
|
53080
|
-
if (this.instanceManager) {
|
|
53081
|
-
for (const id of this.instanceManager.listInstanceIds()) {
|
|
53082
|
-
const instance = this.instanceManager.getInstance(id);
|
|
53083
|
-
const providerType = typeof instance?.type === "string" ? instance.type : "";
|
|
53084
|
-
if (!providerType) continue;
|
|
53085
|
-
const resolved = this.providerLoader.resolve(providerType);
|
|
53086
|
-
if (!resolved) continue;
|
|
53087
|
-
if (instance && typeof instance === "object" && "provider" in instance) {
|
|
53088
|
-
instance.provider = resolved;
|
|
53089
|
-
refreshedInstances += 1;
|
|
53090
|
-
}
|
|
53091
|
-
}
|
|
53092
|
-
}
|
|
53207
|
+
const refreshedInstances = this.instanceManager ? this.instanceManager.refreshProviderDefinitions((providerType) => this.providerLoader.resolve(providerType)) : 0;
|
|
53093
53208
|
const providers = this.providerLoader.getAll().map((p) => ({
|
|
53094
53209
|
type: p.type,
|
|
53095
53210
|
name: p.name,
|