@adhdev/daemon-standalone 0.9.31 → 0.9.32
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
CHANGED
|
@@ -28204,14 +28204,13 @@ var require_dist2 = __commonJS({
|
|
|
28204
28204
|
const shouldOutput = LEVEL_NUM[level] >= LEVEL_NUM[currentLevel];
|
|
28205
28205
|
const label = LEVEL_LABEL[level];
|
|
28206
28206
|
const line = `[${ts2()}] [${label}] [${category}] ${msg}`;
|
|
28207
|
+
if (!shouldOutput) return;
|
|
28207
28208
|
writeToFile(line);
|
|
28208
28209
|
ringBuffer.push({ ts: Date.now(), level, category, message: msg });
|
|
28209
28210
|
if (ringBuffer.length > RING_BUFFER_SIZE) {
|
|
28210
28211
|
ringBuffer.splice(0, ringBuffer.length - RING_BUFFER_SIZE);
|
|
28211
28212
|
}
|
|
28212
|
-
|
|
28213
|
-
origConsoleLog(line);
|
|
28214
|
-
}
|
|
28213
|
+
origConsoleLog(line);
|
|
28215
28214
|
}
|
|
28216
28215
|
function installGlobalInterceptor() {
|
|
28217
28216
|
if (interceptorInstalled) return;
|
|
@@ -30031,6 +30030,7 @@ var require_dist2 = __commonJS({
|
|
|
30031
30030
|
static STATUS_HOT_PATH_PARSE_MIN_INTERVAL_MS = 1e3;
|
|
30032
30031
|
static SCREEN_SNAPSHOT_MIN_INTERVAL_MS = 250;
|
|
30033
30032
|
static MAX_TRACE_ENTRIES = 250;
|
|
30033
|
+
static PARSE_MESSAGE_TAIL_LIMIT = 100;
|
|
30034
30034
|
providerResolutionMeta;
|
|
30035
30035
|
static FINISH_RETRY_DELAY_MS = 300;
|
|
30036
30036
|
static MAX_FINISH_RETRIES = 2;
|
|
@@ -30062,6 +30062,32 @@ var require_dist2 = __commonJS({
|
|
|
30062
30062
|
}
|
|
30063
30063
|
return null;
|
|
30064
30064
|
}
|
|
30065
|
+
selectParseBaseMessages(baseMessages) {
|
|
30066
|
+
if (baseMessages.length <= _ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT) return baseMessages;
|
|
30067
|
+
return baseMessages.slice(-_ProviderCliAdapter.PARSE_MESSAGE_TAIL_LIMIT);
|
|
30068
|
+
}
|
|
30069
|
+
messagesComparable(left, right) {
|
|
30070
|
+
if (!left || !right) return false;
|
|
30071
|
+
if ((left.role || "") !== (right.role || "")) return false;
|
|
30072
|
+
const leftText = normalizeComparableTranscriptText(left.content);
|
|
30073
|
+
const rightText = normalizeComparableTranscriptText(right.content);
|
|
30074
|
+
return !!leftText && leftText === rightText;
|
|
30075
|
+
}
|
|
30076
|
+
stitchParsedMessagesWithCommittedBase(parsedMessages, fullBaseMessages, parseBaseMessages) {
|
|
30077
|
+
if (!Array.isArray(parsedMessages) || parsedMessages.length === 0) return parsedMessages;
|
|
30078
|
+
if (fullBaseMessages.length <= parseBaseMessages.length) return parsedMessages;
|
|
30079
|
+
const parsedFirst = parsedMessages[0];
|
|
30080
|
+
const fullFirst = fullBaseMessages[0];
|
|
30081
|
+
if (parsedMessages.length >= fullBaseMessages.length && this.messagesComparable(parsedFirst, fullFirst)) {
|
|
30082
|
+
return parsedMessages;
|
|
30083
|
+
}
|
|
30084
|
+
const tailFirst = parseBaseMessages[0];
|
|
30085
|
+
if (tailFirst && this.messagesComparable(parsedFirst, tailFirst)) {
|
|
30086
|
+
const prefixLength = fullBaseMessages.length - parseBaseMessages.length;
|
|
30087
|
+
return [...fullBaseMessages.slice(0, prefixLength), ...parsedMessages];
|
|
30088
|
+
}
|
|
30089
|
+
return [...fullBaseMessages, ...parsedMessages];
|
|
30090
|
+
}
|
|
30065
30091
|
getIdleFinishConfirmMs() {
|
|
30066
30092
|
return this.timeouts.idleFinishConfirm;
|
|
30067
30093
|
}
|
|
@@ -30647,7 +30673,7 @@ var require_dist2 = __commonJS({
|
|
|
30647
30673
|
const ctx = { now, modal, status, parsedMessages, lastParsedAssistant, parsedStatus: parsedStatus || null, prevStatus };
|
|
30648
30674
|
if (!this.applyPendingScriptStatusDebounce(ctx)) return;
|
|
30649
30675
|
const recentInteractiveActivity = this.hasRecentInteractiveActivity(now);
|
|
30650
|
-
LOG2.
|
|
30676
|
+
LOG2.debug(
|
|
30651
30677
|
"CLI",
|
|
30652
30678
|
`[${this.cliType}] settled diagnostics prompt=${JSON.stringify(this.currentTurnScope?.prompt || "").slice(0, 140)} status=${String(status || "")} parsedStatus=${String(parsedStatus || "")} parsedMsgCount=${parsedMessages.length} lastParsedAssistant=${JSON.stringify(summarizeCliTraceText(lastParsedAssistant?.content || "", 120)).slice(0, 160)} responseBuffer=${JSON.stringify(summarizeCliTraceText(this.responseBuffer, 160)).slice(0, 220)} screen=${JSON.stringify(summarizeCliTraceText(screenText, 160)).slice(0, 220)}`
|
|
30653
30679
|
);
|
|
@@ -31014,18 +31040,26 @@ var require_dist2 = __commonJS({
|
|
|
31014
31040
|
try {
|
|
31015
31041
|
const screenText = this.terminalScreen.getText();
|
|
31016
31042
|
const tail = this.recentOutputBuffer.slice(-500);
|
|
31043
|
+
const parseBaseMessages = this.selectParseBaseMessages(this.committedMessages);
|
|
31017
31044
|
const input = buildCliParseInput({
|
|
31018
31045
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
31019
31046
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
31020
31047
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
31021
31048
|
terminalScreenText: screenText,
|
|
31022
|
-
baseMessages:
|
|
31049
|
+
baseMessages: parseBaseMessages,
|
|
31023
31050
|
partialResponse: this.responseBuffer,
|
|
31024
31051
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
31025
31052
|
scope: this.currentTurnScope,
|
|
31026
31053
|
runtimeSettings: this.runtimeSettings
|
|
31027
31054
|
});
|
|
31028
31055
|
const session = this.cliScripts.parseSession({ ...input, tail, tailScreen: buildCliScreenSnapshot(tail) });
|
|
31056
|
+
if (session && typeof session === "object" && Array.isArray(session.messages)) {
|
|
31057
|
+
session.messages = this.stitchParsedMessagesWithCommittedBase(
|
|
31058
|
+
session.messages,
|
|
31059
|
+
this.committedMessages,
|
|
31060
|
+
parseBaseMessages
|
|
31061
|
+
);
|
|
31062
|
+
}
|
|
31029
31063
|
this.parseErrorMessage = null;
|
|
31030
31064
|
return session && typeof session === "object" ? session : null;
|
|
31031
31065
|
} catch (e) {
|
|
@@ -31346,12 +31380,13 @@ var require_dist2 = __commonJS({
|
|
|
31346
31380
|
}
|
|
31347
31381
|
try {
|
|
31348
31382
|
const screenText = typeof screenTextOverride === "string" ? screenTextOverride : this.terminalScreen.getText();
|
|
31383
|
+
const parseBaseMessages = this.selectParseBaseMessages(baseMessages);
|
|
31349
31384
|
const input = buildCliParseInput({
|
|
31350
31385
|
accumulatedBuffer: this.accumulatedBuffer,
|
|
31351
31386
|
accumulatedRawBuffer: this.accumulatedRawBuffer,
|
|
31352
31387
|
recentOutputBuffer: this.recentOutputBuffer,
|
|
31353
31388
|
terminalScreenText: screenText,
|
|
31354
|
-
baseMessages,
|
|
31389
|
+
baseMessages: parseBaseMessages,
|
|
31355
31390
|
partialResponse,
|
|
31356
31391
|
isWaitingForResponse: this.isWaitingForResponse,
|
|
31357
31392
|
scope,
|
|
@@ -31363,6 +31398,11 @@ var require_dist2 = __commonJS({
|
|
|
31363
31398
|
}
|
|
31364
31399
|
const normalizedParsed = this.suppressStaleParsedApproval(parsed, input.recentBuffer, input.screenText);
|
|
31365
31400
|
if (normalizedParsed && Array.isArray(normalizedParsed.messages)) {
|
|
31401
|
+
normalizedParsed.messages = this.stitchParsedMessagesWithCommittedBase(
|
|
31402
|
+
normalizedParsed.messages,
|
|
31403
|
+
baseMessages,
|
|
31404
|
+
parseBaseMessages
|
|
31405
|
+
);
|
|
31366
31406
|
this.trimLastAssistantEcho(normalizedParsed.messages, scope?.prompt || getLastUserPromptText(baseMessages));
|
|
31367
31407
|
}
|
|
31368
31408
|
this.parseErrorMessage = null;
|
|
@@ -31972,7 +32012,7 @@ var require_dist2 = __commonJS({
|
|
|
31972
32012
|
DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
|
|
31973
32013
|
DEFAULT_CDP_DISCOVERY_INTERVAL_MS: () => DEFAULT_CDP_DISCOVERY_INTERVAL_MS,
|
|
31974
32014
|
DEFAULT_CDP_SCAN_INTERVAL_MS: () => DEFAULT_CDP_SCAN_INTERVAL_MS,
|
|
31975
|
-
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () =>
|
|
32015
|
+
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS2,
|
|
31976
32016
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
31977
32017
|
DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS2,
|
|
31978
32018
|
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
@@ -32955,7 +32995,7 @@ var require_dist2 = __commonJS({
|
|
|
32955
32995
|
"waiting_approval",
|
|
32956
32996
|
"starting"
|
|
32957
32997
|
]);
|
|
32958
|
-
var
|
|
32998
|
+
var DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS2 = 8e3;
|
|
32959
32999
|
var LIVE_RUNTIME_LIFECYCLES = /* @__PURE__ */ new Set(["starting", "running", "stopping", "interrupted"]);
|
|
32960
33000
|
function parseMessageTimestamp(value) {
|
|
32961
33001
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
@@ -32986,9 +33026,10 @@ var require_dist2 = __commonJS({
|
|
|
32986
33026
|
const now = options.now ?? Date.now();
|
|
32987
33027
|
const recentMessageGraceMs = Math.max(
|
|
32988
33028
|
0,
|
|
32989
|
-
Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) :
|
|
33029
|
+
Number.isFinite(options.recentMessageGraceMs) ? Number(options.recentMessageGraceMs) : DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS2
|
|
32990
33030
|
);
|
|
32991
33031
|
const activeStatuses = options.activeStatuses ?? DEFAULT_ACTIVE_CHAT_POLL_STATUSES;
|
|
33032
|
+
const activeSessionIds = options.activeSessionIds ?? /* @__PURE__ */ new Set();
|
|
32992
33033
|
const active = /* @__PURE__ */ new Set();
|
|
32993
33034
|
const excluded = /* @__PURE__ */ new Set();
|
|
32994
33035
|
for (const session of sessions) {
|
|
@@ -32998,6 +33039,10 @@ var require_dist2 = __commonJS({
|
|
|
32998
33039
|
excluded.add(sessionId);
|
|
32999
33040
|
continue;
|
|
33000
33041
|
}
|
|
33042
|
+
if (activeSessionIds.has(sessionId)) {
|
|
33043
|
+
active.add(sessionId);
|
|
33044
|
+
continue;
|
|
33045
|
+
}
|
|
33001
33046
|
const status = String(session?.status || "").toLowerCase();
|
|
33002
33047
|
const unread = session?.unread === true;
|
|
33003
33048
|
const inboxBucket = String(session?.inboxBucket || "").toLowerCase();
|
|
@@ -43859,6 +43904,9 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
43859
43904
|
log(msg) {
|
|
43860
43905
|
this.logFn(`[ProviderLoader] ${msg}`);
|
|
43861
43906
|
}
|
|
43907
|
+
debugLog(msg) {
|
|
43908
|
+
LOG2.debug("Provider", `[ProviderLoader] ${msg}`);
|
|
43909
|
+
}
|
|
43862
43910
|
// ─── Public API ────────────────────────────────
|
|
43863
43911
|
/**
|
|
43864
43912
|
* User override root (~/.adhdev/providers by default).
|
|
@@ -44465,7 +44513,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44465
44513
|
const loaded = this.loadScriptsFromDir(type, entry.scriptDir);
|
|
44466
44514
|
if (loaded) {
|
|
44467
44515
|
resolved.scripts = loaded;
|
|
44468
|
-
this.
|
|
44516
|
+
this.debugLog(` [compatibility] ${type} v${currentVersion} \u2192 ${entry.scriptDir}`);
|
|
44469
44517
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
44470
44518
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
44471
44519
|
if (providerDir) {
|
|
@@ -44481,7 +44529,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44481
44529
|
const loaded = this.loadScriptsFromDir(type, base.defaultScriptDir);
|
|
44482
44530
|
if (loaded) {
|
|
44483
44531
|
resolved.scripts = loaded;
|
|
44484
|
-
this.
|
|
44532
|
+
this.debugLog(` [compatibility] ${type} v${currentVersion} \u2192 default: ${base.defaultScriptDir}`);
|
|
44485
44533
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
44486
44534
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
44487
44535
|
if (providerDir) {
|
|
@@ -44516,7 +44564,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
44516
44564
|
const loaded = this.loadScriptsFromDir(type, base.defaultScriptDir);
|
|
44517
44565
|
if (loaded) {
|
|
44518
44566
|
resolved.scripts = loaded;
|
|
44519
|
-
this.
|
|
44567
|
+
this.debugLog(` [compatibility] ${type} no version detected \u2192 default: ${base.defaultScriptDir}`);
|
|
44520
44568
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
44521
44569
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
44522
44570
|
if (providerDir) {
|
|
@@ -55536,6 +55584,8 @@ async function getWorkspaceSocketInfo(workspaceName) {
|
|
|
55536
55584
|
var import_daemon_core3 = __toESM(require_dist2());
|
|
55537
55585
|
var DEFAULT_PORT = 3847;
|
|
55538
55586
|
var STATUS_INTERVAL = 2e3;
|
|
55587
|
+
var CHAT_OUTPUT_ACTIVITY_HOT_MS = import_daemon_core3.DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS;
|
|
55588
|
+
var CHAT_OUTPUT_FLUSH_DEBOUNCE_MS = 700;
|
|
55539
55589
|
var STANDALONE_AUTH_SESSION_COOKIE = "adhdev_standalone_session";
|
|
55540
55590
|
var STANDALONE_PASSWORD_CONFIG_FILE = "standalone-auth.json";
|
|
55541
55591
|
var STANDALONE_PREFERENCES_CONFIG_FILE = "standalone-network.json";
|
|
@@ -55736,6 +55786,8 @@ var StandaloneServer = class {
|
|
|
55736
55786
|
wsChatFlushInFlight = false;
|
|
55737
55787
|
pendingWsChatFlush = null;
|
|
55738
55788
|
hotWsChatSessionIds = /* @__PURE__ */ new Set();
|
|
55789
|
+
wsChatOutputActiveAt = /* @__PURE__ */ new Map();
|
|
55790
|
+
wsChatOutputFlushTimer = null;
|
|
55739
55791
|
running = false;
|
|
55740
55792
|
components = null;
|
|
55741
55793
|
devServer = null;
|
|
@@ -55785,6 +55837,26 @@ var StandaloneServer = class {
|
|
|
55785
55837
|
const mode = this.getCliPresentationMode(sessionId);
|
|
55786
55838
|
return mode === "chat" || mode === "terminal";
|
|
55787
55839
|
}
|
|
55840
|
+
getRecentlyOutputActiveChatSessionIds(now) {
|
|
55841
|
+
const active = /* @__PURE__ */ new Set();
|
|
55842
|
+
for (const [sessionId, lastOutputAt] of this.wsChatOutputActiveAt) {
|
|
55843
|
+
if (now - lastOutputAt <= CHAT_OUTPUT_ACTIVITY_HOT_MS) {
|
|
55844
|
+
active.add(sessionId);
|
|
55845
|
+
} else {
|
|
55846
|
+
this.wsChatOutputActiveAt.delete(sessionId);
|
|
55847
|
+
}
|
|
55848
|
+
}
|
|
55849
|
+
return active;
|
|
55850
|
+
}
|
|
55851
|
+
markWsChatOutputActivity(sessionId) {
|
|
55852
|
+
if (!sessionId || !this.isCliSession(sessionId)) return;
|
|
55853
|
+
this.wsChatOutputActiveAt.set(sessionId, Date.now());
|
|
55854
|
+
if (this.wsChatOutputFlushTimer || this.clients.size === 0) return;
|
|
55855
|
+
this.wsChatOutputFlushTimer = setTimeout(() => {
|
|
55856
|
+
this.wsChatOutputFlushTimer = null;
|
|
55857
|
+
void this.flushWsChatSubscriptions(void 0, { onlyActive: true });
|
|
55858
|
+
}, CHAT_OUTPUT_FLUSH_DEBOUNCE_MS);
|
|
55859
|
+
}
|
|
55788
55860
|
hasPasswordAuth() {
|
|
55789
55861
|
return !!this.passwordConfig;
|
|
55790
55862
|
}
|
|
@@ -55882,6 +55954,7 @@ var StandaloneServer = class {
|
|
|
55882
55954
|
getP2p: () => ({
|
|
55883
55955
|
broadcastSessionOutput: (key, data) => {
|
|
55884
55956
|
if (this.clients.size === 0 || !this.isCliSession(key)) return;
|
|
55957
|
+
this.markWsChatOutputActivity(key);
|
|
55885
55958
|
const msg = JSON.stringify({ type: "session_output", sessionId: key, data });
|
|
55886
55959
|
for (const client of this.clients) {
|
|
55887
55960
|
if (client.readyState === 1) {
|
|
@@ -56642,10 +56715,12 @@ var StandaloneServer = class {
|
|
|
56642
56715
|
return prepared.update;
|
|
56643
56716
|
}
|
|
56644
56717
|
getHotChatSessionIdsForWsFlush() {
|
|
56718
|
+
const now = Date.now();
|
|
56645
56719
|
const snapshot = this.buildSharedSnapshot("live");
|
|
56646
56720
|
const hotSessions = (0, import_daemon_core3.classifyHotChatSessionsForSubscriptionFlush)(
|
|
56647
56721
|
snapshot.sessions,
|
|
56648
|
-
this.hotWsChatSessionIds
|
|
56722
|
+
this.hotWsChatSessionIds,
|
|
56723
|
+
{ now, activeSessionIds: this.getRecentlyOutputActiveChatSessionIds(now) }
|
|
56649
56724
|
);
|
|
56650
56725
|
this.hotWsChatSessionIds = hotSessions.active;
|
|
56651
56726
|
return hotSessions;
|