@adhdev/daemon-core 0.8.48 → 0.8.50
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.d.ts +5 -0
- package/dist/index.js +283 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +269 -22
- package/dist/index.mjs.map +1 -1
- package/dist/logging/command-log.d.ts +1 -0
- package/dist/logging/debug-config.d.ts +21 -0
- package/dist/logging/debug-trace.d.ts +35 -0
- package/dist/session-host/app-name.d.ts +6 -0
- package/dist/shared-types.d.ts +2 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +76 -13
- package/src/commands/router.ts +55 -5
- package/src/index.ts +22 -0
- package/src/logging/command-log.ts +3 -0
- package/src/logging/debug-config.ts +75 -0
- package/src/logging/debug-trace.ts +130 -0
- package/src/session-host/app-name.ts +15 -0
- package/src/shared-types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export type { ManagedStatus } from './status/normalize.js';
|
|
|
51
51
|
export type { StatusSnapshotOptions, StatusSnapshot } from './status/snapshot.js';
|
|
52
52
|
export { LOG, installGlobalInterceptor, setLogLevel, getLogLevel, getRecentLogs, getDaemonLogDir, getCurrentDaemonLogPath, } from './logging/logger.js';
|
|
53
53
|
export type { ScopedLogger, LogLevel, LogEntry } from './logging/logger.js';
|
|
54
|
+
export { resolveDebugRuntimeConfig, setDebugRuntimeConfig, getDebugRuntimeConfig, resetDebugRuntimeConfig, shouldCollectTraceCategory, } from './logging/debug-config.js';
|
|
55
|
+
export type { DebugRuntimeOptions, DebugRuntimeConfig } from './logging/debug-config.js';
|
|
56
|
+
export { createDebugTraceStore, configureDebugTraceStore, recordDebugTrace, getRecentDebugTrace, clearDebugTrace, createInteractionId, } from './logging/debug-trace.js';
|
|
57
|
+
export type { DebugTraceEvent, DebugTraceEntry, DebugTraceQuery, DebugTraceStore, DebugTraceLevel } from './logging/debug-trace.js';
|
|
54
58
|
export { logCommand, getRecentCommands } from './logging/command-log.js';
|
|
55
59
|
export { DaemonCliManager } from './commands/cli-manager.js';
|
|
56
60
|
export { launchWithCdp, getAvailableIdeIds, killIdeProcess, isIdeRunning } from './launch.js';
|
|
@@ -75,6 +79,7 @@ export { NodePtyTransportFactory } from './cli-adapters/pty-transport.js';
|
|
|
75
79
|
export type { PtyRuntimeTransport, PtyTransportFactory, PtySpawnOptions } from './cli-adapters/pty-transport.js';
|
|
76
80
|
export { SessionHostPtyTransportFactory } from './cli-adapters/session-host-transport.js';
|
|
77
81
|
export type { HostedCliRuntimeDescriptor, CliTransportFactoryParams } from './commands/cli-manager.js';
|
|
82
|
+
export { DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME, resolveSessionHostAppName, } from './session-host/app-name.js';
|
|
78
83
|
export { ensureSessionHostReady, listHostedCliRuntimes } from './session-host/runtime-support.js';
|
|
79
84
|
export type { SessionHostEndpoint } from '@adhdev/session-host-core';
|
|
80
85
|
export { getAIExtensions, installExtensions, launchIDE, isExtensionInstalled } from './installer.js';
|
package/dist/index.js
CHANGED
|
@@ -3009,6 +3009,8 @@ __export(index_exports, {
|
|
|
3009
3009
|
CliProviderInstance: () => CliProviderInstance,
|
|
3010
3010
|
DAEMON_WS_PATH: () => DAEMON_WS_PATH,
|
|
3011
3011
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
3012
|
+
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
3013
|
+
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
3012
3014
|
DaemonAgentStreamManager: () => DaemonAgentStreamManager,
|
|
3013
3015
|
DaemonCdpInitializer: () => DaemonCdpInitializer,
|
|
3014
3016
|
DaemonCdpManager: () => DaemonCdpManager,
|
|
@@ -3030,7 +3032,11 @@ __export(index_exports, {
|
|
|
3030
3032
|
buildMachineInfo: () => buildMachineInfo,
|
|
3031
3033
|
buildSessionEntries: () => buildSessionEntries,
|
|
3032
3034
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
3035
|
+
clearDebugTrace: () => clearDebugTrace,
|
|
3036
|
+
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
3033
3037
|
connectCdpManager: () => connectCdpManager,
|
|
3038
|
+
createDebugTraceStore: () => createDebugTraceStore,
|
|
3039
|
+
createInteractionId: () => createInteractionId,
|
|
3034
3040
|
detectAllVersions: () => detectAllVersions,
|
|
3035
3041
|
detectCLIs: () => detectCLIs,
|
|
3036
3042
|
detectIDEs: () => detectIDEs,
|
|
@@ -3041,10 +3047,12 @@ __export(index_exports, {
|
|
|
3041
3047
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
3042
3048
|
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
3043
3049
|
getDaemonLogDir: () => getDaemonLogDir,
|
|
3050
|
+
getDebugRuntimeConfig: () => getDebugRuntimeConfig,
|
|
3044
3051
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
3045
3052
|
getLogLevel: () => getLogLevel,
|
|
3046
3053
|
getRecentActivity: () => getRecentActivity,
|
|
3047
3054
|
getRecentCommands: () => getRecentCommands,
|
|
3055
|
+
getRecentDebugTrace: () => getRecentDebugTrace,
|
|
3048
3056
|
getRecentLogs: () => getRecentLogs,
|
|
3049
3057
|
getSavedProviderSessions: () => getSavedProviderSessions,
|
|
3050
3058
|
getWorkspaceState: () => getWorkspaceState,
|
|
@@ -3071,13 +3079,19 @@ __export(index_exports, {
|
|
|
3071
3079
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
3072
3080
|
probeCdpPort: () => probeCdpPort,
|
|
3073
3081
|
readChatHistory: () => readChatHistory,
|
|
3082
|
+
recordDebugTrace: () => recordDebugTrace,
|
|
3074
3083
|
registerExtensionProviders: () => registerExtensionProviders,
|
|
3075
3084
|
resetConfig: () => resetConfig,
|
|
3085
|
+
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
3076
3086
|
resetState: () => resetState,
|
|
3087
|
+
resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
|
|
3088
|
+
resolveSessionHostAppName: () => resolveSessionHostAppName,
|
|
3077
3089
|
saveConfig: () => saveConfig,
|
|
3078
3090
|
saveState: () => saveState,
|
|
3091
|
+
setDebugRuntimeConfig: () => setDebugRuntimeConfig,
|
|
3079
3092
|
setLogLevel: () => setLogLevel,
|
|
3080
3093
|
setupIdeInstance: () => setupIdeInstance,
|
|
3094
|
+
shouldCollectTraceCategory: () => shouldCollectTraceCategory,
|
|
3081
3095
|
shutdownDaemonComponents: () => shutdownDaemonComponents,
|
|
3082
3096
|
spawnDetachedDaemonUpgradeHelper: () => spawnDetachedDaemonUpgradeHelper,
|
|
3083
3097
|
startDaemonDevSupport: () => startDaemonDevSupport,
|
|
@@ -7485,6 +7499,134 @@ function flattenContent(content) {
|
|
|
7485
7499
|
|
|
7486
7500
|
// src/commands/chat-commands.ts
|
|
7487
7501
|
init_logger();
|
|
7502
|
+
|
|
7503
|
+
// src/logging/debug-config.ts
|
|
7504
|
+
var NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
7505
|
+
var DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
7506
|
+
var DEFAULT_CONFIG2 = {
|
|
7507
|
+
logLevel: "info",
|
|
7508
|
+
collectDebugTrace: false,
|
|
7509
|
+
traceContent: false,
|
|
7510
|
+
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
7511
|
+
traceCategories: []
|
|
7512
|
+
};
|
|
7513
|
+
var currentConfig = { ...DEFAULT_CONFIG2 };
|
|
7514
|
+
function normalizeCategories(categories) {
|
|
7515
|
+
if (!Array.isArray(categories)) return [];
|
|
7516
|
+
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
7517
|
+
}
|
|
7518
|
+
function resolveDebugRuntimeConfig(options = {}) {
|
|
7519
|
+
const dev = options.dev === true;
|
|
7520
|
+
return {
|
|
7521
|
+
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
7522
|
+
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
7523
|
+
traceContent: options.traceContent === true,
|
|
7524
|
+
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
7525
|
+
traceCategories: normalizeCategories(options.traceCategories)
|
|
7526
|
+
};
|
|
7527
|
+
}
|
|
7528
|
+
function setDebugRuntimeConfig(config) {
|
|
7529
|
+
currentConfig = {
|
|
7530
|
+
...config,
|
|
7531
|
+
traceCategories: normalizeCategories(config.traceCategories),
|
|
7532
|
+
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
7533
|
+
};
|
|
7534
|
+
}
|
|
7535
|
+
function getDebugRuntimeConfig() {
|
|
7536
|
+
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
7537
|
+
}
|
|
7538
|
+
function resetDebugRuntimeConfig() {
|
|
7539
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
7540
|
+
}
|
|
7541
|
+
function shouldCollectTraceCategory(category) {
|
|
7542
|
+
const config = currentConfig;
|
|
7543
|
+
if (!config.collectDebugTrace) return false;
|
|
7544
|
+
if (!category) return true;
|
|
7545
|
+
if (config.traceCategories.length === 0) return true;
|
|
7546
|
+
return config.traceCategories.includes(category);
|
|
7547
|
+
}
|
|
7548
|
+
|
|
7549
|
+
// src/logging/debug-trace.ts
|
|
7550
|
+
function summarizeString(value) {
|
|
7551
|
+
return `[${value.length} chars]`;
|
|
7552
|
+
}
|
|
7553
|
+
function sanitizeTraceValue(value, traceContent) {
|
|
7554
|
+
if (traceContent) {
|
|
7555
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
7556
|
+
if (value && typeof value === "object") {
|
|
7557
|
+
return Object.fromEntries(
|
|
7558
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
7559
|
+
);
|
|
7560
|
+
}
|
|
7561
|
+
return value;
|
|
7562
|
+
}
|
|
7563
|
+
if (typeof value === "string") return summarizeString(value);
|
|
7564
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
7565
|
+
if (value && typeof value === "object") {
|
|
7566
|
+
return Object.fromEntries(
|
|
7567
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
7568
|
+
);
|
|
7569
|
+
}
|
|
7570
|
+
return value;
|
|
7571
|
+
}
|
|
7572
|
+
function sanitizeTracePayload(payload) {
|
|
7573
|
+
if (!payload) return {};
|
|
7574
|
+
const { traceContent } = getDebugRuntimeConfig();
|
|
7575
|
+
return sanitizeTraceValue(payload, traceContent);
|
|
7576
|
+
}
|
|
7577
|
+
function createEntry(event) {
|
|
7578
|
+
return {
|
|
7579
|
+
id: `trace_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`,
|
|
7580
|
+
ts: Date.now(),
|
|
7581
|
+
...event,
|
|
7582
|
+
payload: sanitizeTracePayload(event.payload)
|
|
7583
|
+
};
|
|
7584
|
+
}
|
|
7585
|
+
function createDebugTraceStore(options) {
|
|
7586
|
+
const entries = [];
|
|
7587
|
+
const capacity = Math.max(1, Math.floor(options.capacity || 100));
|
|
7588
|
+
return {
|
|
7589
|
+
record(event) {
|
|
7590
|
+
if (!options.enabled) return null;
|
|
7591
|
+
const entry = createEntry(event);
|
|
7592
|
+
entries.push(entry);
|
|
7593
|
+
if (entries.length > capacity) {
|
|
7594
|
+
entries.splice(0, entries.length - capacity);
|
|
7595
|
+
}
|
|
7596
|
+
return entry;
|
|
7597
|
+
},
|
|
7598
|
+
list(query = {}) {
|
|
7599
|
+
const limit = Math.max(1, Math.floor(query.limit || 100));
|
|
7600
|
+
return entries.filter((entry) => !query.interactionId || entry.interactionId === query.interactionId).filter((entry) => !query.category || entry.category === query.category).slice(-limit).map((entry) => ({ ...entry, payload: entry.payload ? { ...entry.payload } : {} }));
|
|
7601
|
+
},
|
|
7602
|
+
clear() {
|
|
7603
|
+
entries.splice(0, entries.length);
|
|
7604
|
+
}
|
|
7605
|
+
};
|
|
7606
|
+
}
|
|
7607
|
+
var globalStore = createDebugTraceStore({ enabled: false, capacity: getDebugRuntimeConfig().traceBufferSize });
|
|
7608
|
+
function configureDebugTraceStore() {
|
|
7609
|
+
const config = getDebugRuntimeConfig();
|
|
7610
|
+
globalStore = createDebugTraceStore({
|
|
7611
|
+
enabled: config.collectDebugTrace,
|
|
7612
|
+
capacity: config.traceBufferSize
|
|
7613
|
+
});
|
|
7614
|
+
}
|
|
7615
|
+
function recordDebugTrace(event) {
|
|
7616
|
+
if (!shouldCollectTraceCategory(event.category)) return null;
|
|
7617
|
+
return globalStore.record(event);
|
|
7618
|
+
}
|
|
7619
|
+
function getRecentDebugTrace(query = {}) {
|
|
7620
|
+
return globalStore.list(query);
|
|
7621
|
+
}
|
|
7622
|
+
function clearDebugTrace() {
|
|
7623
|
+
globalStore.clear();
|
|
7624
|
+
}
|
|
7625
|
+
function createInteractionId(prefix = "ix") {
|
|
7626
|
+
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
7627
|
+
}
|
|
7628
|
+
|
|
7629
|
+
// src/commands/chat-commands.ts
|
|
7488
7630
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
7489
7631
|
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
7490
7632
|
function hashSignatureParts(parts) {
|
|
@@ -7551,6 +7693,20 @@ function getHistorySessionId(h, args) {
|
|
|
7551
7693
|
const providerSessionId = typeof state?.providerSessionId === "string" ? state.providerSessionId.trim() : "";
|
|
7552
7694
|
return providerSessionId || targetSessionId;
|
|
7553
7695
|
}
|
|
7696
|
+
function getInteractionId(args) {
|
|
7697
|
+
return typeof args?._interactionId === "string" && args._interactionId.trim() ? args._interactionId.trim() : void 0;
|
|
7698
|
+
}
|
|
7699
|
+
function traceProviderEvent(args, category, stage, options) {
|
|
7700
|
+
recordDebugTrace({
|
|
7701
|
+
interactionId: getInteractionId(args),
|
|
7702
|
+
category,
|
|
7703
|
+
stage,
|
|
7704
|
+
level: options.level || "info",
|
|
7705
|
+
sessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : options.h.currentSession?.sessionId,
|
|
7706
|
+
providerType: options.provider?.type || options.h.currentProviderType || options.h.currentSession?.providerType,
|
|
7707
|
+
payload: options.payload
|
|
7708
|
+
});
|
|
7709
|
+
}
|
|
7554
7710
|
function callLegacyTextScript(script, text) {
|
|
7555
7711
|
if (typeof script !== "function") return null;
|
|
7556
7712
|
return script(text);
|
|
@@ -7796,6 +7952,16 @@ async function handleReadChat(h, args) {
|
|
|
7796
7952
|
}
|
|
7797
7953
|
if (parsed && typeof parsed === "object") {
|
|
7798
7954
|
_log(`Extension OK: ${parsed.messages?.length || 0} msgs`);
|
|
7955
|
+
traceProviderEvent(args, "provider", "extension.read_chat.success", {
|
|
7956
|
+
h,
|
|
7957
|
+
provider,
|
|
7958
|
+
payload: {
|
|
7959
|
+
method: "evaluateProviderScript",
|
|
7960
|
+
result: evalResult.result,
|
|
7961
|
+
parsed,
|
|
7962
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
7963
|
+
}
|
|
7964
|
+
});
|
|
7799
7965
|
h.historyWriter.appendNewMessages(
|
|
7800
7966
|
provider?.type || "unknown_extension",
|
|
7801
7967
|
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
@@ -7808,6 +7974,12 @@ async function handleReadChat(h, args) {
|
|
|
7808
7974
|
}
|
|
7809
7975
|
} catch (e) {
|
|
7810
7976
|
_log(`Extension error: ${e.message}`);
|
|
7977
|
+
traceProviderEvent(args, "provider", "extension.read_chat.error", {
|
|
7978
|
+
h,
|
|
7979
|
+
provider,
|
|
7980
|
+
level: "warn",
|
|
7981
|
+
payload: { method: "evaluateProviderScript", error: e.message }
|
|
7982
|
+
});
|
|
7811
7983
|
}
|
|
7812
7984
|
if (h.agentStream) {
|
|
7813
7985
|
const cdp2 = h.getCdp();
|
|
@@ -7871,27 +8043,45 @@ async function handleReadChat(h, args) {
|
|
|
7871
8043
|
const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
|
|
7872
8044
|
if (script) {
|
|
7873
8045
|
try {
|
|
7874
|
-
const
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
8046
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
|
|
8047
|
+
if (evalResult?.result) {
|
|
8048
|
+
let parsed = evalResult.result;
|
|
8049
|
+
if (typeof parsed === "string") {
|
|
8050
|
+
try {
|
|
8051
|
+
parsed = JSON.parse(parsed);
|
|
8052
|
+
} catch {
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
8056
|
+
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
8057
|
+
traceProviderEvent(args, "provider", "ide.read_chat.success", {
|
|
8058
|
+
h,
|
|
8059
|
+
provider,
|
|
8060
|
+
payload: {
|
|
8061
|
+
method: "evaluate",
|
|
8062
|
+
result: evalResult.result,
|
|
8063
|
+
parsed,
|
|
8064
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
8065
|
+
}
|
|
8066
|
+
});
|
|
8067
|
+
h.historyWriter.appendNewMessages(
|
|
8068
|
+
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
8069
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
8070
|
+
parsed.title,
|
|
8071
|
+
args?.targetSessionId,
|
|
8072
|
+
historySessionId
|
|
8073
|
+
);
|
|
8074
|
+
return buildReadChatCommandResult(parsed, args);
|
|
7880
8075
|
}
|
|
7881
|
-
}
|
|
7882
|
-
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
7883
|
-
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
7884
|
-
h.historyWriter.appendNewMessages(
|
|
7885
|
-
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
7886
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
7887
|
-
parsed.title,
|
|
7888
|
-
args?.targetSessionId,
|
|
7889
|
-
historySessionId
|
|
7890
|
-
);
|
|
7891
|
-
return buildReadChatCommandResult(parsed, args);
|
|
7892
8076
|
}
|
|
7893
8077
|
} catch (e) {
|
|
7894
8078
|
LOG.info("Command", `[read_chat] Script error: ${e.message}`);
|
|
8079
|
+
traceProviderEvent(args, "provider", "ide.read_chat.error", {
|
|
8080
|
+
h,
|
|
8081
|
+
provider,
|
|
8082
|
+
level: "warn",
|
|
8083
|
+
payload: { method: "evaluate", error: e.message }
|
|
8084
|
+
});
|
|
7895
8085
|
}
|
|
7896
8086
|
}
|
|
7897
8087
|
return buildReadChatCommandResult({ messages: [], status: "idle" }, args);
|
|
@@ -13779,6 +13969,7 @@ function logCommand(entry) {
|
|
|
13779
13969
|
ts: entry.ts,
|
|
13780
13970
|
cmd: entry.cmd,
|
|
13781
13971
|
src: entry.source,
|
|
13972
|
+
...entry.interactionId ? { interactionId: entry.interactionId } : {},
|
|
13782
13973
|
...entry.args ? { args: maskArgs(entry.args) } : {},
|
|
13783
13974
|
...entry.success !== void 0 ? { ok: entry.success } : {},
|
|
13784
13975
|
...entry.error ? { err: entry.error } : {},
|
|
@@ -13800,6 +13991,7 @@ function getRecentCommands(count = 50) {
|
|
|
13800
13991
|
ts: parsed.ts,
|
|
13801
13992
|
cmd: parsed.cmd,
|
|
13802
13993
|
source: parsed.src,
|
|
13994
|
+
interactionId: parsed.interactionId,
|
|
13803
13995
|
args: parsed.args,
|
|
13804
13996
|
success: parsed.ok,
|
|
13805
13997
|
error: parsed.err,
|
|
@@ -14267,6 +14459,13 @@ function normalizeCommandSource(source) {
|
|
|
14267
14459
|
return "unknown";
|
|
14268
14460
|
}
|
|
14269
14461
|
}
|
|
14462
|
+
function normalizeCommandArgsWithInteractionId(args) {
|
|
14463
|
+
const base = args && typeof args === "object" ? { ...args } : {};
|
|
14464
|
+
if (typeof base._interactionId !== "string" || !String(base._interactionId).trim()) {
|
|
14465
|
+
base._interactionId = createInteractionId();
|
|
14466
|
+
}
|
|
14467
|
+
return base;
|
|
14468
|
+
}
|
|
14270
14469
|
function toHostedCliRuntimeDescriptor(record) {
|
|
14271
14470
|
if (!record || typeof record !== "object") return null;
|
|
14272
14471
|
const runtimeId = typeof record.sessionId === "string" ? record.sessionId : "";
|
|
@@ -14305,20 +14504,50 @@ var DaemonCommandRouter = class {
|
|
|
14305
14504
|
async execute(cmd, args, source = "unknown") {
|
|
14306
14505
|
const cmdStart = Date.now();
|
|
14307
14506
|
const logSource = normalizeCommandSource(source);
|
|
14507
|
+
const normalizedArgs = normalizeCommandArgsWithInteractionId(args);
|
|
14508
|
+
const interactionId = typeof normalizedArgs._interactionId === "string" ? normalizedArgs._interactionId : void 0;
|
|
14509
|
+
recordDebugTrace({
|
|
14510
|
+
interactionId,
|
|
14511
|
+
category: "command",
|
|
14512
|
+
stage: "received",
|
|
14513
|
+
level: "info",
|
|
14514
|
+
payload: { cmd, source: logSource }
|
|
14515
|
+
});
|
|
14308
14516
|
try {
|
|
14309
|
-
const daemonResult = await this.executeDaemonCommand(cmd,
|
|
14517
|
+
const daemonResult = await this.executeDaemonCommand(cmd, normalizedArgs);
|
|
14310
14518
|
if (daemonResult) {
|
|
14311
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
14519
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
14520
|
+
recordDebugTrace({
|
|
14521
|
+
interactionId,
|
|
14522
|
+
category: "command",
|
|
14523
|
+
stage: "completed",
|
|
14524
|
+
level: daemonResult.success ? "info" : "warn",
|
|
14525
|
+
payload: { cmd, source: logSource, success: daemonResult.success, durationMs: Date.now() - cmdStart }
|
|
14526
|
+
});
|
|
14312
14527
|
return daemonResult;
|
|
14313
14528
|
}
|
|
14314
|
-
const handlerResult = await this.deps.commandHandler.handle(cmd,
|
|
14315
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
14529
|
+
const handlerResult = await this.deps.commandHandler.handle(cmd, normalizedArgs);
|
|
14530
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
14531
|
+
recordDebugTrace({
|
|
14532
|
+
interactionId,
|
|
14533
|
+
category: "command",
|
|
14534
|
+
stage: "completed",
|
|
14535
|
+
level: handlerResult.success ? "info" : "warn",
|
|
14536
|
+
payload: { cmd, source: logSource, success: handlerResult.success, durationMs: Date.now() - cmdStart }
|
|
14537
|
+
});
|
|
14316
14538
|
if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
|
|
14317
14539
|
this.deps.onPostChatCommand();
|
|
14318
14540
|
}
|
|
14319
14541
|
return handlerResult;
|
|
14320
14542
|
} catch (e) {
|
|
14321
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
14543
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
14544
|
+
recordDebugTrace({
|
|
14545
|
+
interactionId,
|
|
14546
|
+
category: "command",
|
|
14547
|
+
stage: "failed",
|
|
14548
|
+
level: "error",
|
|
14549
|
+
payload: { cmd, source: logSource, error: e?.message || String(e), durationMs: Date.now() - cmdStart }
|
|
14550
|
+
});
|
|
14322
14551
|
throw e;
|
|
14323
14552
|
}
|
|
14324
14553
|
}
|
|
@@ -14360,6 +14589,14 @@ var DaemonCommandRouter = class {
|
|
|
14360
14589
|
return { success: false, error: e.message };
|
|
14361
14590
|
}
|
|
14362
14591
|
}
|
|
14592
|
+
case "get_debug_trace": {
|
|
14593
|
+
const count = parseInt(args?.count) || parseInt(args?.limit) || 100;
|
|
14594
|
+
const sinceTs = Number(args?.since) || 0;
|
|
14595
|
+
const interactionId = typeof args?.interactionId === "string" ? args.interactionId : void 0;
|
|
14596
|
+
const category = typeof args?.category === "string" ? args.category : void 0;
|
|
14597
|
+
const trace = getRecentDebugTrace({ interactionId, category, limit: count }).filter((entry) => !sinceTs || entry.ts > sinceTs);
|
|
14598
|
+
return { success: true, trace, count: trace.length };
|
|
14599
|
+
}
|
|
14363
14600
|
case "session_host_get_diagnostics": {
|
|
14364
14601
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
14365
14602
|
const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
|
|
@@ -21723,6 +21960,16 @@ var SessionHostPtyTransportFactory = class {
|
|
|
21723
21960
|
}
|
|
21724
21961
|
};
|
|
21725
21962
|
|
|
21963
|
+
// src/session-host/app-name.ts
|
|
21964
|
+
var DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
21965
|
+
var DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
21966
|
+
function resolveSessionHostAppName(options = {}) {
|
|
21967
|
+
const env = options.env || process.env;
|
|
21968
|
+
const explicit = typeof env.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
21969
|
+
if (explicit) return explicit;
|
|
21970
|
+
return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
|
|
21971
|
+
}
|
|
21972
|
+
|
|
21726
21973
|
// src/session-host/runtime-support.ts
|
|
21727
21974
|
var import_session_host_core3 = require("@adhdev/session-host-core");
|
|
21728
21975
|
var STARTUP_TIMEOUT_MS = 8e3;
|
|
@@ -22253,6 +22500,8 @@ async function shutdownDaemonComponents(components) {
|
|
|
22253
22500
|
CliProviderInstance,
|
|
22254
22501
|
DAEMON_WS_PATH,
|
|
22255
22502
|
DEFAULT_DAEMON_PORT,
|
|
22503
|
+
DEFAULT_SESSION_HOST_APP_NAME,
|
|
22504
|
+
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
22256
22505
|
DaemonAgentStreamManager,
|
|
22257
22506
|
DaemonCdpInitializer,
|
|
22258
22507
|
DaemonCdpManager,
|
|
@@ -22274,7 +22523,11 @@ async function shutdownDaemonComponents(components) {
|
|
|
22274
22523
|
buildMachineInfo,
|
|
22275
22524
|
buildSessionEntries,
|
|
22276
22525
|
buildStatusSnapshot,
|
|
22526
|
+
clearDebugTrace,
|
|
22527
|
+
configureDebugTraceStore,
|
|
22277
22528
|
connectCdpManager,
|
|
22529
|
+
createDebugTraceStore,
|
|
22530
|
+
createInteractionId,
|
|
22278
22531
|
detectAllVersions,
|
|
22279
22532
|
detectCLIs,
|
|
22280
22533
|
detectIDEs,
|
|
@@ -22285,10 +22538,12 @@ async function shutdownDaemonComponents(components) {
|
|
|
22285
22538
|
getAvailableIdeIds,
|
|
22286
22539
|
getCurrentDaemonLogPath,
|
|
22287
22540
|
getDaemonLogDir,
|
|
22541
|
+
getDebugRuntimeConfig,
|
|
22288
22542
|
getHostMemorySnapshot,
|
|
22289
22543
|
getLogLevel,
|
|
22290
22544
|
getRecentActivity,
|
|
22291
22545
|
getRecentCommands,
|
|
22546
|
+
getRecentDebugTrace,
|
|
22292
22547
|
getRecentLogs,
|
|
22293
22548
|
getSavedProviderSessions,
|
|
22294
22549
|
getWorkspaceState,
|
|
@@ -22315,13 +22570,19 @@ async function shutdownDaemonComponents(components) {
|
|
|
22315
22570
|
normalizeManagedStatus,
|
|
22316
22571
|
probeCdpPort,
|
|
22317
22572
|
readChatHistory,
|
|
22573
|
+
recordDebugTrace,
|
|
22318
22574
|
registerExtensionProviders,
|
|
22319
22575
|
resetConfig,
|
|
22576
|
+
resetDebugRuntimeConfig,
|
|
22320
22577
|
resetState,
|
|
22578
|
+
resolveDebugRuntimeConfig,
|
|
22579
|
+
resolveSessionHostAppName,
|
|
22321
22580
|
saveConfig,
|
|
22322
22581
|
saveState,
|
|
22582
|
+
setDebugRuntimeConfig,
|
|
22323
22583
|
setLogLevel,
|
|
22324
22584
|
setupIdeInstance,
|
|
22585
|
+
shouldCollectTraceCategory,
|
|
22325
22586
|
shutdownDaemonComponents,
|
|
22326
22587
|
spawnDetachedDaemonUpgradeHelper,
|
|
22327
22588
|
startDaemonDevSupport,
|