@adhdev/daemon-core 0.8.49 → 0.8.51
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/boot/daemon-lifecycle.d.ts +1 -0
- package/dist/commands/cli-manager.d.ts +2 -0
- package/dist/commands/hosted-runtime-restore.d.ts +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +303 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -23
- 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/boot/daemon-lifecycle.ts +1 -0
- package/src/commands/chat-commands.ts +76 -13
- package/src/commands/cli-manager.ts +11 -0
- package/src/commands/hosted-runtime-restore.ts +9 -0
- 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/session-host/runtime-support.ts +1 -0
- package/src/shared-types.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -7398,6 +7398,134 @@ function flattenContent(content) {
|
|
|
7398
7398
|
|
|
7399
7399
|
// src/commands/chat-commands.ts
|
|
7400
7400
|
init_logger();
|
|
7401
|
+
|
|
7402
|
+
// src/logging/debug-config.ts
|
|
7403
|
+
var NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
7404
|
+
var DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
7405
|
+
var DEFAULT_CONFIG2 = {
|
|
7406
|
+
logLevel: "info",
|
|
7407
|
+
collectDebugTrace: false,
|
|
7408
|
+
traceContent: false,
|
|
7409
|
+
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
7410
|
+
traceCategories: []
|
|
7411
|
+
};
|
|
7412
|
+
var currentConfig = { ...DEFAULT_CONFIG2 };
|
|
7413
|
+
function normalizeCategories(categories) {
|
|
7414
|
+
if (!Array.isArray(categories)) return [];
|
|
7415
|
+
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
7416
|
+
}
|
|
7417
|
+
function resolveDebugRuntimeConfig(options = {}) {
|
|
7418
|
+
const dev = options.dev === true;
|
|
7419
|
+
return {
|
|
7420
|
+
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
7421
|
+
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
7422
|
+
traceContent: options.traceContent === true,
|
|
7423
|
+
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
7424
|
+
traceCategories: normalizeCategories(options.traceCategories)
|
|
7425
|
+
};
|
|
7426
|
+
}
|
|
7427
|
+
function setDebugRuntimeConfig(config) {
|
|
7428
|
+
currentConfig = {
|
|
7429
|
+
...config,
|
|
7430
|
+
traceCategories: normalizeCategories(config.traceCategories),
|
|
7431
|
+
traceBufferSize: Math.max(10, Math.floor(config.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
7432
|
+
};
|
|
7433
|
+
}
|
|
7434
|
+
function getDebugRuntimeConfig() {
|
|
7435
|
+
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
7436
|
+
}
|
|
7437
|
+
function resetDebugRuntimeConfig() {
|
|
7438
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
7439
|
+
}
|
|
7440
|
+
function shouldCollectTraceCategory(category) {
|
|
7441
|
+
const config = currentConfig;
|
|
7442
|
+
if (!config.collectDebugTrace) return false;
|
|
7443
|
+
if (!category) return true;
|
|
7444
|
+
if (config.traceCategories.length === 0) return true;
|
|
7445
|
+
return config.traceCategories.includes(category);
|
|
7446
|
+
}
|
|
7447
|
+
|
|
7448
|
+
// src/logging/debug-trace.ts
|
|
7449
|
+
function summarizeString(value) {
|
|
7450
|
+
return `[${value.length} chars]`;
|
|
7451
|
+
}
|
|
7452
|
+
function sanitizeTraceValue(value, traceContent) {
|
|
7453
|
+
if (traceContent) {
|
|
7454
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
7455
|
+
if (value && typeof value === "object") {
|
|
7456
|
+
return Object.fromEntries(
|
|
7457
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
7458
|
+
);
|
|
7459
|
+
}
|
|
7460
|
+
return value;
|
|
7461
|
+
}
|
|
7462
|
+
if (typeof value === "string") return summarizeString(value);
|
|
7463
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
7464
|
+
if (value && typeof value === "object") {
|
|
7465
|
+
return Object.fromEntries(
|
|
7466
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
7467
|
+
);
|
|
7468
|
+
}
|
|
7469
|
+
return value;
|
|
7470
|
+
}
|
|
7471
|
+
function sanitizeTracePayload(payload) {
|
|
7472
|
+
if (!payload) return {};
|
|
7473
|
+
const { traceContent } = getDebugRuntimeConfig();
|
|
7474
|
+
return sanitizeTraceValue(payload, traceContent);
|
|
7475
|
+
}
|
|
7476
|
+
function createEntry(event) {
|
|
7477
|
+
return {
|
|
7478
|
+
id: `trace_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`,
|
|
7479
|
+
ts: Date.now(),
|
|
7480
|
+
...event,
|
|
7481
|
+
payload: sanitizeTracePayload(event.payload)
|
|
7482
|
+
};
|
|
7483
|
+
}
|
|
7484
|
+
function createDebugTraceStore(options) {
|
|
7485
|
+
const entries = [];
|
|
7486
|
+
const capacity = Math.max(1, Math.floor(options.capacity || 100));
|
|
7487
|
+
return {
|
|
7488
|
+
record(event) {
|
|
7489
|
+
if (!options.enabled) return null;
|
|
7490
|
+
const entry = createEntry(event);
|
|
7491
|
+
entries.push(entry);
|
|
7492
|
+
if (entries.length > capacity) {
|
|
7493
|
+
entries.splice(0, entries.length - capacity);
|
|
7494
|
+
}
|
|
7495
|
+
return entry;
|
|
7496
|
+
},
|
|
7497
|
+
list(query = {}) {
|
|
7498
|
+
const limit = Math.max(1, Math.floor(query.limit || 100));
|
|
7499
|
+
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 } : {} }));
|
|
7500
|
+
},
|
|
7501
|
+
clear() {
|
|
7502
|
+
entries.splice(0, entries.length);
|
|
7503
|
+
}
|
|
7504
|
+
};
|
|
7505
|
+
}
|
|
7506
|
+
var globalStore = createDebugTraceStore({ enabled: false, capacity: getDebugRuntimeConfig().traceBufferSize });
|
|
7507
|
+
function configureDebugTraceStore() {
|
|
7508
|
+
const config = getDebugRuntimeConfig();
|
|
7509
|
+
globalStore = createDebugTraceStore({
|
|
7510
|
+
enabled: config.collectDebugTrace,
|
|
7511
|
+
capacity: config.traceBufferSize
|
|
7512
|
+
});
|
|
7513
|
+
}
|
|
7514
|
+
function recordDebugTrace(event) {
|
|
7515
|
+
if (!shouldCollectTraceCategory(event.category)) return null;
|
|
7516
|
+
return globalStore.record(event);
|
|
7517
|
+
}
|
|
7518
|
+
function getRecentDebugTrace(query = {}) {
|
|
7519
|
+
return globalStore.list(query);
|
|
7520
|
+
}
|
|
7521
|
+
function clearDebugTrace() {
|
|
7522
|
+
globalStore.clear();
|
|
7523
|
+
}
|
|
7524
|
+
function createInteractionId(prefix = "ix") {
|
|
7525
|
+
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
7526
|
+
}
|
|
7527
|
+
|
|
7528
|
+
// src/commands/chat-commands.ts
|
|
7401
7529
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
7402
7530
|
var recentSendByTarget = /* @__PURE__ */ new Map();
|
|
7403
7531
|
function hashSignatureParts(parts) {
|
|
@@ -7464,6 +7592,20 @@ function getHistorySessionId(h, args) {
|
|
|
7464
7592
|
const providerSessionId = typeof state?.providerSessionId === "string" ? state.providerSessionId.trim() : "";
|
|
7465
7593
|
return providerSessionId || targetSessionId;
|
|
7466
7594
|
}
|
|
7595
|
+
function getInteractionId(args) {
|
|
7596
|
+
return typeof args?._interactionId === "string" && args._interactionId.trim() ? args._interactionId.trim() : void 0;
|
|
7597
|
+
}
|
|
7598
|
+
function traceProviderEvent(args, category, stage, options) {
|
|
7599
|
+
recordDebugTrace({
|
|
7600
|
+
interactionId: getInteractionId(args),
|
|
7601
|
+
category,
|
|
7602
|
+
stage,
|
|
7603
|
+
level: options.level || "info",
|
|
7604
|
+
sessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : options.h.currentSession?.sessionId,
|
|
7605
|
+
providerType: options.provider?.type || options.h.currentProviderType || options.h.currentSession?.providerType,
|
|
7606
|
+
payload: options.payload
|
|
7607
|
+
});
|
|
7608
|
+
}
|
|
7467
7609
|
function callLegacyTextScript(script, text) {
|
|
7468
7610
|
if (typeof script !== "function") return null;
|
|
7469
7611
|
return script(text);
|
|
@@ -7709,6 +7851,16 @@ async function handleReadChat(h, args) {
|
|
|
7709
7851
|
}
|
|
7710
7852
|
if (parsed && typeof parsed === "object") {
|
|
7711
7853
|
_log(`Extension OK: ${parsed.messages?.length || 0} msgs`);
|
|
7854
|
+
traceProviderEvent(args, "provider", "extension.read_chat.success", {
|
|
7855
|
+
h,
|
|
7856
|
+
provider,
|
|
7857
|
+
payload: {
|
|
7858
|
+
method: "evaluateProviderScript",
|
|
7859
|
+
result: evalResult.result,
|
|
7860
|
+
parsed,
|
|
7861
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
7862
|
+
}
|
|
7863
|
+
});
|
|
7712
7864
|
h.historyWriter.appendNewMessages(
|
|
7713
7865
|
provider?.type || "unknown_extension",
|
|
7714
7866
|
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
@@ -7721,6 +7873,12 @@ async function handleReadChat(h, args) {
|
|
|
7721
7873
|
}
|
|
7722
7874
|
} catch (e) {
|
|
7723
7875
|
_log(`Extension error: ${e.message}`);
|
|
7876
|
+
traceProviderEvent(args, "provider", "extension.read_chat.error", {
|
|
7877
|
+
h,
|
|
7878
|
+
provider,
|
|
7879
|
+
level: "warn",
|
|
7880
|
+
payload: { method: "evaluateProviderScript", error: e.message }
|
|
7881
|
+
});
|
|
7724
7882
|
}
|
|
7725
7883
|
if (h.agentStream) {
|
|
7726
7884
|
const cdp2 = h.getCdp();
|
|
@@ -7784,27 +7942,45 @@ async function handleReadChat(h, args) {
|
|
|
7784
7942
|
const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
|
|
7785
7943
|
if (script) {
|
|
7786
7944
|
try {
|
|
7787
|
-
const
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7945
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
|
|
7946
|
+
if (evalResult?.result) {
|
|
7947
|
+
let parsed = evalResult.result;
|
|
7948
|
+
if (typeof parsed === "string") {
|
|
7949
|
+
try {
|
|
7950
|
+
parsed = JSON.parse(parsed);
|
|
7951
|
+
} catch {
|
|
7952
|
+
}
|
|
7953
|
+
}
|
|
7954
|
+
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
7955
|
+
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
7956
|
+
traceProviderEvent(args, "provider", "ide.read_chat.success", {
|
|
7957
|
+
h,
|
|
7958
|
+
provider,
|
|
7959
|
+
payload: {
|
|
7960
|
+
method: "evaluate",
|
|
7961
|
+
result: evalResult.result,
|
|
7962
|
+
parsed,
|
|
7963
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
7964
|
+
}
|
|
7965
|
+
});
|
|
7966
|
+
h.historyWriter.appendNewMessages(
|
|
7967
|
+
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
7968
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
7969
|
+
parsed.title,
|
|
7970
|
+
args?.targetSessionId,
|
|
7971
|
+
historySessionId
|
|
7972
|
+
);
|
|
7973
|
+
return buildReadChatCommandResult(parsed, args);
|
|
7793
7974
|
}
|
|
7794
|
-
}
|
|
7795
|
-
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
7796
|
-
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
7797
|
-
h.historyWriter.appendNewMessages(
|
|
7798
|
-
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
7799
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
7800
|
-
parsed.title,
|
|
7801
|
-
args?.targetSessionId,
|
|
7802
|
-
historySessionId
|
|
7803
|
-
);
|
|
7804
|
-
return buildReadChatCommandResult(parsed, args);
|
|
7805
7975
|
}
|
|
7806
7976
|
} catch (e) {
|
|
7807
7977
|
LOG.info("Command", `[read_chat] Script error: ${e.message}`);
|
|
7978
|
+
traceProviderEvent(args, "provider", "ide.read_chat.error", {
|
|
7979
|
+
h,
|
|
7980
|
+
provider,
|
|
7981
|
+
level: "warn",
|
|
7982
|
+
payload: { method: "evaluate", error: e.message }
|
|
7983
|
+
});
|
|
7808
7984
|
}
|
|
7809
7985
|
}
|
|
7810
7986
|
return buildReadChatCommandResult({ messages: [], status: "idle" }, args);
|
|
@@ -11306,6 +11482,16 @@ var AcpProviderInstance = class {
|
|
|
11306
11482
|
|
|
11307
11483
|
// src/commands/cli-manager.ts
|
|
11308
11484
|
init_logger();
|
|
11485
|
+
|
|
11486
|
+
// src/commands/hosted-runtime-restore.ts
|
|
11487
|
+
function shouldRestoreHostedRuntime(record, managerTag) {
|
|
11488
|
+
if (!managerTag) return true;
|
|
11489
|
+
const managedBy = typeof record.managedBy === "string" ? record.managedBy.trim() : "";
|
|
11490
|
+
if (!managedBy) return true;
|
|
11491
|
+
return managedBy === managerTag;
|
|
11492
|
+
}
|
|
11493
|
+
|
|
11494
|
+
// src/commands/cli-manager.ts
|
|
11309
11495
|
var chalkModule = chalk;
|
|
11310
11496
|
var chalkApi = typeof chalkModule.yellow === "function" ? chalkModule : chalkModule.default || null;
|
|
11311
11497
|
function colorize(color, text) {
|
|
@@ -11801,8 +11987,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
11801
11987
|
const sessions = records || await this.deps.listHostedCliRuntimes?.() || [];
|
|
11802
11988
|
let restored = 0;
|
|
11803
11989
|
const restoredBindings = /* @__PURE__ */ new Set();
|
|
11990
|
+
const managerTag = this.deps.hostedRuntimeManagerTag;
|
|
11804
11991
|
for (const record of sessions) {
|
|
11805
11992
|
if (!record?.runtimeId || !record?.cliType || !record?.workspace) continue;
|
|
11993
|
+
if (!shouldRestoreHostedRuntime(record, managerTag)) {
|
|
11994
|
+
LOG.info(
|
|
11995
|
+
"CLI",
|
|
11996
|
+
`\u21B7 Skipping hosted runtime restore owned by ${record.managedBy}: ${record.runtimeKey || record.runtimeId}`
|
|
11997
|
+
);
|
|
11998
|
+
continue;
|
|
11999
|
+
}
|
|
11806
12000
|
if (this.adapters.has(record.runtimeId) || instanceManager.getInstance(record.runtimeId)) continue;
|
|
11807
12001
|
const normalizedType = this.providerLoader.resolveAlias(record.cliType);
|
|
11808
12002
|
const providerMeta = this.providerLoader.getMeta(normalizedType);
|
|
@@ -13697,6 +13891,7 @@ function logCommand(entry) {
|
|
|
13697
13891
|
ts: entry.ts,
|
|
13698
13892
|
cmd: entry.cmd,
|
|
13699
13893
|
src: entry.source,
|
|
13894
|
+
...entry.interactionId ? { interactionId: entry.interactionId } : {},
|
|
13700
13895
|
...entry.args ? { args: maskArgs(entry.args) } : {},
|
|
13701
13896
|
...entry.success !== void 0 ? { ok: entry.success } : {},
|
|
13702
13897
|
...entry.error ? { err: entry.error } : {},
|
|
@@ -13718,6 +13913,7 @@ function getRecentCommands(count = 50) {
|
|
|
13718
13913
|
ts: parsed.ts,
|
|
13719
13914
|
cmd: parsed.cmd,
|
|
13720
13915
|
source: parsed.src,
|
|
13916
|
+
interactionId: parsed.interactionId,
|
|
13721
13917
|
args: parsed.args,
|
|
13722
13918
|
success: parsed.ok,
|
|
13723
13919
|
error: parsed.err,
|
|
@@ -14185,6 +14381,13 @@ function normalizeCommandSource(source) {
|
|
|
14185
14381
|
return "unknown";
|
|
14186
14382
|
}
|
|
14187
14383
|
}
|
|
14384
|
+
function normalizeCommandArgsWithInteractionId(args) {
|
|
14385
|
+
const base = args && typeof args === "object" ? { ...args } : {};
|
|
14386
|
+
if (typeof base._interactionId !== "string" || !String(base._interactionId).trim()) {
|
|
14387
|
+
base._interactionId = createInteractionId();
|
|
14388
|
+
}
|
|
14389
|
+
return base;
|
|
14390
|
+
}
|
|
14188
14391
|
function toHostedCliRuntimeDescriptor(record) {
|
|
14189
14392
|
if (!record || typeof record !== "object") return null;
|
|
14190
14393
|
const runtimeId = typeof record.sessionId === "string" ? record.sessionId : "";
|
|
@@ -14223,20 +14426,50 @@ var DaemonCommandRouter = class {
|
|
|
14223
14426
|
async execute(cmd, args, source = "unknown") {
|
|
14224
14427
|
const cmdStart = Date.now();
|
|
14225
14428
|
const logSource = normalizeCommandSource(source);
|
|
14429
|
+
const normalizedArgs = normalizeCommandArgsWithInteractionId(args);
|
|
14430
|
+
const interactionId = typeof normalizedArgs._interactionId === "string" ? normalizedArgs._interactionId : void 0;
|
|
14431
|
+
recordDebugTrace({
|
|
14432
|
+
interactionId,
|
|
14433
|
+
category: "command",
|
|
14434
|
+
stage: "received",
|
|
14435
|
+
level: "info",
|
|
14436
|
+
payload: { cmd, source: logSource }
|
|
14437
|
+
});
|
|
14226
14438
|
try {
|
|
14227
|
-
const daemonResult = await this.executeDaemonCommand(cmd,
|
|
14439
|
+
const daemonResult = await this.executeDaemonCommand(cmd, normalizedArgs);
|
|
14228
14440
|
if (daemonResult) {
|
|
14229
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
14441
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
14442
|
+
recordDebugTrace({
|
|
14443
|
+
interactionId,
|
|
14444
|
+
category: "command",
|
|
14445
|
+
stage: "completed",
|
|
14446
|
+
level: daemonResult.success ? "info" : "warn",
|
|
14447
|
+
payload: { cmd, source: logSource, success: daemonResult.success, durationMs: Date.now() - cmdStart }
|
|
14448
|
+
});
|
|
14230
14449
|
return daemonResult;
|
|
14231
14450
|
}
|
|
14232
|
-
const handlerResult = await this.deps.commandHandler.handle(cmd,
|
|
14233
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
14451
|
+
const handlerResult = await this.deps.commandHandler.handle(cmd, normalizedArgs);
|
|
14452
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
14453
|
+
recordDebugTrace({
|
|
14454
|
+
interactionId,
|
|
14455
|
+
category: "command",
|
|
14456
|
+
stage: "completed",
|
|
14457
|
+
level: handlerResult.success ? "info" : "warn",
|
|
14458
|
+
payload: { cmd, source: logSource, success: handlerResult.success, durationMs: Date.now() - cmdStart }
|
|
14459
|
+
});
|
|
14234
14460
|
if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
|
|
14235
14461
|
this.deps.onPostChatCommand();
|
|
14236
14462
|
}
|
|
14237
14463
|
return handlerResult;
|
|
14238
14464
|
} catch (e) {
|
|
14239
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
14465
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
14466
|
+
recordDebugTrace({
|
|
14467
|
+
interactionId,
|
|
14468
|
+
category: "command",
|
|
14469
|
+
stage: "failed",
|
|
14470
|
+
level: "error",
|
|
14471
|
+
payload: { cmd, source: logSource, error: e?.message || String(e), durationMs: Date.now() - cmdStart }
|
|
14472
|
+
});
|
|
14240
14473
|
throw e;
|
|
14241
14474
|
}
|
|
14242
14475
|
}
|
|
@@ -14278,6 +14511,14 @@ var DaemonCommandRouter = class {
|
|
|
14278
14511
|
return { success: false, error: e.message };
|
|
14279
14512
|
}
|
|
14280
14513
|
}
|
|
14514
|
+
case "get_debug_trace": {
|
|
14515
|
+
const count = parseInt(args?.count) || parseInt(args?.limit) || 100;
|
|
14516
|
+
const sinceTs = Number(args?.since) || 0;
|
|
14517
|
+
const interactionId = typeof args?.interactionId === "string" ? args.interactionId : void 0;
|
|
14518
|
+
const category = typeof args?.category === "string" ? args.category : void 0;
|
|
14519
|
+
const trace = getRecentDebugTrace({ interactionId, category, limit: count }).filter((entry) => !sinceTs || entry.ts > sinceTs);
|
|
14520
|
+
return { success: true, trace, count: trace.length };
|
|
14521
|
+
}
|
|
14281
14522
|
case "session_host_get_diagnostics": {
|
|
14282
14523
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
14283
14524
|
const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
|
|
@@ -21643,6 +21884,16 @@ var SessionHostPtyTransportFactory = class {
|
|
|
21643
21884
|
}
|
|
21644
21885
|
};
|
|
21645
21886
|
|
|
21887
|
+
// src/session-host/app-name.ts
|
|
21888
|
+
var DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
21889
|
+
var DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
21890
|
+
function resolveSessionHostAppName(options = {}) {
|
|
21891
|
+
const env = options.env || process.env;
|
|
21892
|
+
const explicit = typeof env.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
21893
|
+
if (explicit) return explicit;
|
|
21894
|
+
return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
|
|
21895
|
+
}
|
|
21896
|
+
|
|
21646
21897
|
// src/session-host/runtime-support.ts
|
|
21647
21898
|
import {
|
|
21648
21899
|
SessionHostClient as SessionHostClient2,
|
|
@@ -21695,7 +21946,8 @@ async function listHostedCliRuntimes(endpoint) {
|
|
|
21695
21946
|
cliType: record.providerType,
|
|
21696
21947
|
workspace: record.workspace,
|
|
21697
21948
|
cliArgs: Array.isArray(record.meta?.cliArgs) ? record.meta.cliArgs : [],
|
|
21698
|
-
providerSessionId: typeof record.meta?.providerSessionId === "string" ? String(record.meta.providerSessionId) : void 0
|
|
21949
|
+
providerSessionId: typeof record.meta?.providerSessionId === "string" ? String(record.meta.providerSessionId) : void 0,
|
|
21950
|
+
managedBy: typeof record.meta?.managedBy === "string" ? String(record.meta.managedBy) : void 0
|
|
21699
21951
|
}));
|
|
21700
21952
|
} finally {
|
|
21701
21953
|
await client.close().catch(() => {
|
|
@@ -22175,6 +22427,8 @@ export {
|
|
|
22175
22427
|
CliProviderInstance,
|
|
22176
22428
|
DAEMON_WS_PATH,
|
|
22177
22429
|
DEFAULT_DAEMON_PORT,
|
|
22430
|
+
DEFAULT_SESSION_HOST_APP_NAME,
|
|
22431
|
+
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
22178
22432
|
DaemonAgentStreamManager,
|
|
22179
22433
|
DaemonCdpInitializer,
|
|
22180
22434
|
DaemonCdpManager,
|
|
@@ -22196,7 +22450,11 @@ export {
|
|
|
22196
22450
|
buildMachineInfo,
|
|
22197
22451
|
buildSessionEntries,
|
|
22198
22452
|
buildStatusSnapshot,
|
|
22453
|
+
clearDebugTrace,
|
|
22454
|
+
configureDebugTraceStore,
|
|
22199
22455
|
connectCdpManager,
|
|
22456
|
+
createDebugTraceStore,
|
|
22457
|
+
createInteractionId,
|
|
22200
22458
|
detectAllVersions,
|
|
22201
22459
|
detectCLIs,
|
|
22202
22460
|
detectIDEs,
|
|
@@ -22207,10 +22465,12 @@ export {
|
|
|
22207
22465
|
getAvailableIdeIds,
|
|
22208
22466
|
getCurrentDaemonLogPath,
|
|
22209
22467
|
getDaemonLogDir,
|
|
22468
|
+
getDebugRuntimeConfig,
|
|
22210
22469
|
getHostMemorySnapshot,
|
|
22211
22470
|
getLogLevel,
|
|
22212
22471
|
getRecentActivity,
|
|
22213
22472
|
getRecentCommands,
|
|
22473
|
+
getRecentDebugTrace,
|
|
22214
22474
|
getRecentLogs,
|
|
22215
22475
|
getSavedProviderSessions,
|
|
22216
22476
|
getWorkspaceState,
|
|
@@ -22237,13 +22497,19 @@ export {
|
|
|
22237
22497
|
normalizeManagedStatus,
|
|
22238
22498
|
probeCdpPort,
|
|
22239
22499
|
readChatHistory,
|
|
22500
|
+
recordDebugTrace,
|
|
22240
22501
|
registerExtensionProviders,
|
|
22241
22502
|
resetConfig,
|
|
22503
|
+
resetDebugRuntimeConfig,
|
|
22242
22504
|
resetState,
|
|
22505
|
+
resolveDebugRuntimeConfig,
|
|
22506
|
+
resolveSessionHostAppName,
|
|
22243
22507
|
saveConfig,
|
|
22244
22508
|
saveState,
|
|
22509
|
+
setDebugRuntimeConfig,
|
|
22245
22510
|
setLogLevel,
|
|
22246
22511
|
setupIdeInstance,
|
|
22512
|
+
shouldCollectTraceCategory,
|
|
22247
22513
|
shutdownDaemonComponents,
|
|
22248
22514
|
spawnDetachedDaemonUpgradeHelper,
|
|
22249
22515
|
startDaemonDevSupport,
|