adhdev 0.8.49 → 0.8.52
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/cli/index.js +514 -80
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +485 -70
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/vendor/terminal-mux-cli/index.d.mts +1 -0
- package/vendor/terminal-mux-cli/index.d.ts +1 -0
- package/vendor/terminal-mux-cli/index.js +2056 -0
- package/vendor/terminal-mux-cli/index.mjs +2048 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.mts +427 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.ts +427 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js +617 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs +573 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/package.json +7 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.mts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.ts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.js +206 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.mjs +17 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-7RNMRPVZ.mjs +183 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-R4EFW6W3.mjs +46 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-XZWWVN5W.mjs +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.mts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.ts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.js +219 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.mjs +13 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.mts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.ts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.js +427 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.mjs +34 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/package.json +33 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.mts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.ts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.js +222 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.mjs +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.mts +162 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.ts +162 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.js +985 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.mjs +948 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/package.json +7 -0
package/dist/cli/index.js
CHANGED
|
@@ -4990,6 +4990,145 @@ var init_contracts = __esm({
|
|
|
4990
4990
|
}
|
|
4991
4991
|
});
|
|
4992
4992
|
|
|
4993
|
+
// ../../oss/packages/daemon-core/src/logging/debug-config.ts
|
|
4994
|
+
function normalizeCategories(categories) {
|
|
4995
|
+
if (!Array.isArray(categories)) return [];
|
|
4996
|
+
return categories.map((category) => String(category || "").trim()).filter(Boolean);
|
|
4997
|
+
}
|
|
4998
|
+
function resolveDebugRuntimeConfig(options = {}) {
|
|
4999
|
+
const dev = options.dev === true;
|
|
5000
|
+
return {
|
|
5001
|
+
logLevel: options.logLevel || (dev ? "debug" : DEFAULT_CONFIG2.logLevel),
|
|
5002
|
+
collectDebugTrace: typeof options.trace === "boolean" ? options.trace : dev,
|
|
5003
|
+
traceContent: options.traceContent === true,
|
|
5004
|
+
traceBufferSize: Number.isFinite(options.traceBufferSize) ? Math.max(10, Math.floor(options.traceBufferSize)) : dev ? DEV_TRACE_BUFFER_SIZE : DEFAULT_CONFIG2.traceBufferSize,
|
|
5005
|
+
traceCategories: normalizeCategories(options.traceCategories)
|
|
5006
|
+
};
|
|
5007
|
+
}
|
|
5008
|
+
function setDebugRuntimeConfig(config2) {
|
|
5009
|
+
currentConfig = {
|
|
5010
|
+
...config2,
|
|
5011
|
+
traceCategories: normalizeCategories(config2.traceCategories),
|
|
5012
|
+
traceBufferSize: Math.max(10, Math.floor(config2.traceBufferSize || DEFAULT_CONFIG2.traceBufferSize))
|
|
5013
|
+
};
|
|
5014
|
+
}
|
|
5015
|
+
function getDebugRuntimeConfig() {
|
|
5016
|
+
return { ...currentConfig, traceCategories: [...currentConfig.traceCategories] };
|
|
5017
|
+
}
|
|
5018
|
+
function resetDebugRuntimeConfig() {
|
|
5019
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
5020
|
+
}
|
|
5021
|
+
function shouldCollectTraceCategory(category) {
|
|
5022
|
+
const config2 = currentConfig;
|
|
5023
|
+
if (!config2.collectDebugTrace) return false;
|
|
5024
|
+
if (!category) return true;
|
|
5025
|
+
if (config2.traceCategories.length === 0) return true;
|
|
5026
|
+
return config2.traceCategories.includes(category);
|
|
5027
|
+
}
|
|
5028
|
+
var NORMAL_TRACE_BUFFER_SIZE, DEV_TRACE_BUFFER_SIZE, DEFAULT_CONFIG2, currentConfig;
|
|
5029
|
+
var init_debug_config = __esm({
|
|
5030
|
+
"../../oss/packages/daemon-core/src/logging/debug-config.ts"() {
|
|
5031
|
+
"use strict";
|
|
5032
|
+
NORMAL_TRACE_BUFFER_SIZE = 200;
|
|
5033
|
+
DEV_TRACE_BUFFER_SIZE = 1e3;
|
|
5034
|
+
DEFAULT_CONFIG2 = {
|
|
5035
|
+
logLevel: "info",
|
|
5036
|
+
collectDebugTrace: false,
|
|
5037
|
+
traceContent: false,
|
|
5038
|
+
traceBufferSize: NORMAL_TRACE_BUFFER_SIZE,
|
|
5039
|
+
traceCategories: []
|
|
5040
|
+
};
|
|
5041
|
+
currentConfig = { ...DEFAULT_CONFIG2 };
|
|
5042
|
+
}
|
|
5043
|
+
});
|
|
5044
|
+
|
|
5045
|
+
// ../../oss/packages/daemon-core/src/logging/debug-trace.ts
|
|
5046
|
+
function summarizeString(value) {
|
|
5047
|
+
return `[${value.length} chars]`;
|
|
5048
|
+
}
|
|
5049
|
+
function sanitizeTraceValue(value, traceContent) {
|
|
5050
|
+
if (traceContent) {
|
|
5051
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
5052
|
+
if (value && typeof value === "object") {
|
|
5053
|
+
return Object.fromEntries(
|
|
5054
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
5055
|
+
);
|
|
5056
|
+
}
|
|
5057
|
+
return value;
|
|
5058
|
+
}
|
|
5059
|
+
if (typeof value === "string") return summarizeString(value);
|
|
5060
|
+
if (Array.isArray(value)) return value.map((entry) => sanitizeTraceValue(entry, traceContent));
|
|
5061
|
+
if (value && typeof value === "object") {
|
|
5062
|
+
return Object.fromEntries(
|
|
5063
|
+
Object.entries(value).map(([key, nested]) => [key, sanitizeTraceValue(nested, traceContent)])
|
|
5064
|
+
);
|
|
5065
|
+
}
|
|
5066
|
+
return value;
|
|
5067
|
+
}
|
|
5068
|
+
function sanitizeTracePayload(payload) {
|
|
5069
|
+
if (!payload) return {};
|
|
5070
|
+
const { traceContent } = getDebugRuntimeConfig();
|
|
5071
|
+
return sanitizeTraceValue(payload, traceContent);
|
|
5072
|
+
}
|
|
5073
|
+
function createEntry(event) {
|
|
5074
|
+
return {
|
|
5075
|
+
id: `trace_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`,
|
|
5076
|
+
ts: Date.now(),
|
|
5077
|
+
...event,
|
|
5078
|
+
payload: sanitizeTracePayload(event.payload)
|
|
5079
|
+
};
|
|
5080
|
+
}
|
|
5081
|
+
function createDebugTraceStore(options) {
|
|
5082
|
+
const entries = [];
|
|
5083
|
+
const capacity = Math.max(1, Math.floor(options.capacity || 100));
|
|
5084
|
+
return {
|
|
5085
|
+
record(event) {
|
|
5086
|
+
if (!options.enabled) return null;
|
|
5087
|
+
const entry = createEntry(event);
|
|
5088
|
+
entries.push(entry);
|
|
5089
|
+
if (entries.length > capacity) {
|
|
5090
|
+
entries.splice(0, entries.length - capacity);
|
|
5091
|
+
}
|
|
5092
|
+
return entry;
|
|
5093
|
+
},
|
|
5094
|
+
list(query = {}) {
|
|
5095
|
+
const limit = Math.max(1, Math.floor(query.limit || 100));
|
|
5096
|
+
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 } : {} }));
|
|
5097
|
+
},
|
|
5098
|
+
clear() {
|
|
5099
|
+
entries.splice(0, entries.length);
|
|
5100
|
+
}
|
|
5101
|
+
};
|
|
5102
|
+
}
|
|
5103
|
+
function configureDebugTraceStore() {
|
|
5104
|
+
const config2 = getDebugRuntimeConfig();
|
|
5105
|
+
globalStore = createDebugTraceStore({
|
|
5106
|
+
enabled: config2.collectDebugTrace,
|
|
5107
|
+
capacity: config2.traceBufferSize
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
function recordDebugTrace(event) {
|
|
5111
|
+
if (!shouldCollectTraceCategory(event.category)) return null;
|
|
5112
|
+
return globalStore.record(event);
|
|
5113
|
+
}
|
|
5114
|
+
function getRecentDebugTrace(query = {}) {
|
|
5115
|
+
return globalStore.list(query);
|
|
5116
|
+
}
|
|
5117
|
+
function clearDebugTrace() {
|
|
5118
|
+
globalStore.clear();
|
|
5119
|
+
}
|
|
5120
|
+
function createInteractionId(prefix = "ix") {
|
|
5121
|
+
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
5122
|
+
}
|
|
5123
|
+
var globalStore;
|
|
5124
|
+
var init_debug_trace = __esm({
|
|
5125
|
+
"../../oss/packages/daemon-core/src/logging/debug-trace.ts"() {
|
|
5126
|
+
"use strict";
|
|
5127
|
+
init_debug_config();
|
|
5128
|
+
globalStore = createDebugTraceStore({ enabled: false, capacity: getDebugRuntimeConfig().traceBufferSize });
|
|
5129
|
+
}
|
|
5130
|
+
});
|
|
5131
|
+
|
|
4993
5132
|
// ../../oss/packages/daemon-core/src/commands/chat-commands.ts
|
|
4994
5133
|
function hashSignatureParts(parts) {
|
|
4995
5134
|
let hash2 = 2166136261;
|
|
@@ -5055,6 +5194,20 @@ function getHistorySessionId(h, args) {
|
|
|
5055
5194
|
const providerSessionId = typeof state?.providerSessionId === "string" ? state.providerSessionId.trim() : "";
|
|
5056
5195
|
return providerSessionId || targetSessionId;
|
|
5057
5196
|
}
|
|
5197
|
+
function getInteractionId(args) {
|
|
5198
|
+
return typeof args?._interactionId === "string" && args._interactionId.trim() ? args._interactionId.trim() : void 0;
|
|
5199
|
+
}
|
|
5200
|
+
function traceProviderEvent(args, category, stage, options) {
|
|
5201
|
+
recordDebugTrace({
|
|
5202
|
+
interactionId: getInteractionId(args),
|
|
5203
|
+
category,
|
|
5204
|
+
stage,
|
|
5205
|
+
level: options.level || "info",
|
|
5206
|
+
sessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId : options.h.currentSession?.sessionId,
|
|
5207
|
+
providerType: options.provider?.type || options.h.currentProviderType || options.h.currentSession?.providerType,
|
|
5208
|
+
payload: options.payload
|
|
5209
|
+
});
|
|
5210
|
+
}
|
|
5058
5211
|
function callLegacyTextScript(script, text) {
|
|
5059
5212
|
if (typeof script !== "function") return null;
|
|
5060
5213
|
return script(text);
|
|
@@ -5300,6 +5453,16 @@ async function handleReadChat(h, args) {
|
|
|
5300
5453
|
}
|
|
5301
5454
|
if (parsed && typeof parsed === "object") {
|
|
5302
5455
|
_log(`Extension OK: ${parsed.messages?.length || 0} msgs`);
|
|
5456
|
+
traceProviderEvent(args, "provider", "extension.read_chat.success", {
|
|
5457
|
+
h,
|
|
5458
|
+
provider,
|
|
5459
|
+
payload: {
|
|
5460
|
+
method: "evaluateProviderScript",
|
|
5461
|
+
result: evalResult.result,
|
|
5462
|
+
parsed,
|
|
5463
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
5464
|
+
}
|
|
5465
|
+
});
|
|
5303
5466
|
h.historyWriter.appendNewMessages(
|
|
5304
5467
|
provider?.type || "unknown_extension",
|
|
5305
5468
|
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
@@ -5312,6 +5475,12 @@ async function handleReadChat(h, args) {
|
|
|
5312
5475
|
}
|
|
5313
5476
|
} catch (e) {
|
|
5314
5477
|
_log(`Extension error: ${e.message}`);
|
|
5478
|
+
traceProviderEvent(args, "provider", "extension.read_chat.error", {
|
|
5479
|
+
h,
|
|
5480
|
+
provider,
|
|
5481
|
+
level: "warn",
|
|
5482
|
+
payload: { method: "evaluateProviderScript", error: e.message }
|
|
5483
|
+
});
|
|
5315
5484
|
}
|
|
5316
5485
|
if (h.agentStream) {
|
|
5317
5486
|
const cdp2 = h.getCdp();
|
|
@@ -5375,27 +5544,45 @@ async function handleReadChat(h, args) {
|
|
|
5375
5544
|
const script = h.getProviderScript("readChat") || h.getProviderScript("read_chat");
|
|
5376
5545
|
if (script) {
|
|
5377
5546
|
try {
|
|
5378
|
-
const
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5547
|
+
const evalResult = await h.evaluateProviderScript("readChat", void 0, 5e4);
|
|
5548
|
+
if (evalResult?.result) {
|
|
5549
|
+
let parsed = evalResult.result;
|
|
5550
|
+
if (typeof parsed === "string") {
|
|
5551
|
+
try {
|
|
5552
|
+
parsed = JSON.parse(parsed);
|
|
5553
|
+
} catch {
|
|
5554
|
+
}
|
|
5555
|
+
}
|
|
5556
|
+
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
5557
|
+
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
5558
|
+
traceProviderEvent(args, "provider", "ide.read_chat.success", {
|
|
5559
|
+
h,
|
|
5560
|
+
provider,
|
|
5561
|
+
payload: {
|
|
5562
|
+
method: "evaluate",
|
|
5563
|
+
result: evalResult.result,
|
|
5564
|
+
parsed,
|
|
5565
|
+
messageCount: Array.isArray(parsed.messages) ? parsed.messages.length : 0
|
|
5566
|
+
}
|
|
5567
|
+
});
|
|
5568
|
+
h.historyWriter.appendNewMessages(
|
|
5569
|
+
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
5570
|
+
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
5571
|
+
parsed.title,
|
|
5572
|
+
args?.targetSessionId,
|
|
5573
|
+
historySessionId
|
|
5574
|
+
);
|
|
5575
|
+
return buildReadChatCommandResult(parsed, args);
|
|
5384
5576
|
}
|
|
5385
|
-
}
|
|
5386
|
-
if (parsed && typeof parsed === "object" && parsed.messages?.length > 0) {
|
|
5387
|
-
_log(`OK: ${parsed.messages?.length} msgs`);
|
|
5388
|
-
h.historyWriter.appendNewMessages(
|
|
5389
|
-
provider?.type || getCurrentProviderType(h, "unknown_ide"),
|
|
5390
|
-
toHistoryPersistedMessages(normalizeReadChatMessages(parsed)),
|
|
5391
|
-
parsed.title,
|
|
5392
|
-
args?.targetSessionId,
|
|
5393
|
-
historySessionId
|
|
5394
|
-
);
|
|
5395
|
-
return buildReadChatCommandResult(parsed, args);
|
|
5396
5577
|
}
|
|
5397
5578
|
} catch (e) {
|
|
5398
5579
|
LOG.info("Command", `[read_chat] Script error: ${e.message}`);
|
|
5580
|
+
traceProviderEvent(args, "provider", "ide.read_chat.error", {
|
|
5581
|
+
h,
|
|
5582
|
+
provider,
|
|
5583
|
+
level: "warn",
|
|
5584
|
+
payload: { method: "evaluate", error: e.message }
|
|
5585
|
+
});
|
|
5399
5586
|
}
|
|
5400
5587
|
}
|
|
5401
5588
|
return buildReadChatCommandResult({ messages: [], status: "idle" }, args);
|
|
@@ -6043,6 +6230,7 @@ var init_chat_commands = __esm({
|
|
|
6043
6230
|
init_contracts();
|
|
6044
6231
|
init_chat_history();
|
|
6045
6232
|
init_logger();
|
|
6233
|
+
init_debug_trace();
|
|
6046
6234
|
RECENT_SEND_WINDOW_MS = 1200;
|
|
6047
6235
|
recentSendByTarget = /* @__PURE__ */ new Map();
|
|
6048
6236
|
}
|
|
@@ -28361,6 +28549,19 @@ var init_acp_provider_instance = __esm({
|
|
|
28361
28549
|
}
|
|
28362
28550
|
});
|
|
28363
28551
|
|
|
28552
|
+
// ../../oss/packages/daemon-core/src/commands/hosted-runtime-restore.ts
|
|
28553
|
+
function shouldRestoreHostedRuntime(record2, managerTag) {
|
|
28554
|
+
if (!managerTag) return true;
|
|
28555
|
+
const managedBy = typeof record2.managedBy === "string" ? record2.managedBy.trim() : "";
|
|
28556
|
+
if (!managedBy) return true;
|
|
28557
|
+
return managedBy === managerTag;
|
|
28558
|
+
}
|
|
28559
|
+
var init_hosted_runtime_restore = __esm({
|
|
28560
|
+
"../../oss/packages/daemon-core/src/commands/hosted-runtime-restore.ts"() {
|
|
28561
|
+
"use strict";
|
|
28562
|
+
}
|
|
28563
|
+
});
|
|
28564
|
+
|
|
28364
28565
|
// ../../oss/packages/daemon-core/src/commands/cli-manager.ts
|
|
28365
28566
|
function colorize(color, text) {
|
|
28366
28567
|
const fn = chalkApi?.[color];
|
|
@@ -28491,6 +28692,7 @@ var init_cli_manager = __esm({
|
|
|
28491
28692
|
init_cli_provider_instance();
|
|
28492
28693
|
init_acp_provider_instance();
|
|
28493
28694
|
init_logger();
|
|
28695
|
+
init_hosted_runtime_restore();
|
|
28494
28696
|
chalkModule = import_chalk.default;
|
|
28495
28697
|
chalkApi = typeof chalkModule.yellow === "function" ? chalkModule : chalkModule.default || null;
|
|
28496
28698
|
DaemonCliManager = class {
|
|
@@ -28875,8 +29077,16 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
28875
29077
|
const sessions = records || await this.deps.listHostedCliRuntimes?.() || [];
|
|
28876
29078
|
let restored = 0;
|
|
28877
29079
|
const restoredBindings = /* @__PURE__ */ new Set();
|
|
29080
|
+
const managerTag = this.deps.hostedRuntimeManagerTag;
|
|
28878
29081
|
for (const record2 of sessions) {
|
|
28879
29082
|
if (!record2?.runtimeId || !record2?.cliType || !record2?.workspace) continue;
|
|
29083
|
+
if (!shouldRestoreHostedRuntime(record2, managerTag)) {
|
|
29084
|
+
LOG.info(
|
|
29085
|
+
"CLI",
|
|
29086
|
+
`\u21B7 Skipping hosted runtime restore owned by ${record2.managedBy}: ${record2.runtimeKey || record2.runtimeId}`
|
|
29087
|
+
);
|
|
29088
|
+
continue;
|
|
29089
|
+
}
|
|
28880
29090
|
if (this.adapters.has(record2.runtimeId) || instanceManager.getInstance(record2.runtimeId)) continue;
|
|
28881
29091
|
const normalizedType = this.providerLoader.resolveAlias(record2.cliType);
|
|
28882
29092
|
const providerMeta = this.providerLoader.getMeta(normalizedType);
|
|
@@ -32503,6 +32713,7 @@ function logCommand(entry) {
|
|
|
32503
32713
|
ts: entry.ts,
|
|
32504
32714
|
cmd: entry.cmd,
|
|
32505
32715
|
src: entry.source,
|
|
32716
|
+
...entry.interactionId ? { interactionId: entry.interactionId } : {},
|
|
32506
32717
|
...entry.args ? { args: maskArgs(entry.args) } : {},
|
|
32507
32718
|
...entry.success !== void 0 ? { ok: entry.success } : {},
|
|
32508
32719
|
...entry.error ? { err: entry.error } : {},
|
|
@@ -32524,6 +32735,7 @@ function getRecentCommands(count = 50) {
|
|
|
32524
32735
|
ts: parsed.ts,
|
|
32525
32736
|
cmd: parsed.cmd,
|
|
32526
32737
|
source: parsed.src,
|
|
32738
|
+
interactionId: parsed.interactionId,
|
|
32527
32739
|
args: parsed.args,
|
|
32528
32740
|
success: parsed.ok,
|
|
32529
32741
|
error: parsed.err,
|
|
@@ -33030,6 +33242,13 @@ function normalizeCommandSource(source) {
|
|
|
33030
33242
|
return "unknown";
|
|
33031
33243
|
}
|
|
33032
33244
|
}
|
|
33245
|
+
function normalizeCommandArgsWithInteractionId(args) {
|
|
33246
|
+
const base = args && typeof args === "object" ? { ...args } : {};
|
|
33247
|
+
if (typeof base._interactionId !== "string" || !String(base._interactionId).trim()) {
|
|
33248
|
+
base._interactionId = createInteractionId();
|
|
33249
|
+
}
|
|
33250
|
+
return base;
|
|
33251
|
+
}
|
|
33033
33252
|
function toHostedCliRuntimeDescriptor(record2) {
|
|
33034
33253
|
if (!record2 || typeof record2 !== "object") return null;
|
|
33035
33254
|
const runtimeId = typeof record2.sessionId === "string" ? record2.sessionId : "";
|
|
@@ -33067,6 +33286,7 @@ var init_router = __esm({
|
|
|
33067
33286
|
init_logger();
|
|
33068
33287
|
init_command_log();
|
|
33069
33288
|
init_logger();
|
|
33289
|
+
init_debug_trace();
|
|
33070
33290
|
init_builders();
|
|
33071
33291
|
init_snapshot();
|
|
33072
33292
|
init_snapshot();
|
|
@@ -33099,20 +33319,50 @@ var init_router = __esm({
|
|
|
33099
33319
|
async execute(cmd, args, source = "unknown") {
|
|
33100
33320
|
const cmdStart = Date.now();
|
|
33101
33321
|
const logSource = normalizeCommandSource(source);
|
|
33322
|
+
const normalizedArgs = normalizeCommandArgsWithInteractionId(args);
|
|
33323
|
+
const interactionId = typeof normalizedArgs._interactionId === "string" ? normalizedArgs._interactionId : void 0;
|
|
33324
|
+
recordDebugTrace({
|
|
33325
|
+
interactionId,
|
|
33326
|
+
category: "command",
|
|
33327
|
+
stage: "received",
|
|
33328
|
+
level: "info",
|
|
33329
|
+
payload: { cmd, source: logSource }
|
|
33330
|
+
});
|
|
33102
33331
|
try {
|
|
33103
|
-
const daemonResult = await this.executeDaemonCommand(cmd,
|
|
33332
|
+
const daemonResult = await this.executeDaemonCommand(cmd, normalizedArgs);
|
|
33104
33333
|
if (daemonResult) {
|
|
33105
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
33334
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: daemonResult.success, durationMs: Date.now() - cmdStart });
|
|
33335
|
+
recordDebugTrace({
|
|
33336
|
+
interactionId,
|
|
33337
|
+
category: "command",
|
|
33338
|
+
stage: "completed",
|
|
33339
|
+
level: daemonResult.success ? "info" : "warn",
|
|
33340
|
+
payload: { cmd, source: logSource, success: daemonResult.success, durationMs: Date.now() - cmdStart }
|
|
33341
|
+
});
|
|
33106
33342
|
return daemonResult;
|
|
33107
33343
|
}
|
|
33108
|
-
const handlerResult = await this.deps.commandHandler.handle(cmd,
|
|
33109
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
33344
|
+
const handlerResult = await this.deps.commandHandler.handle(cmd, normalizedArgs);
|
|
33345
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: handlerResult.success, durationMs: Date.now() - cmdStart });
|
|
33346
|
+
recordDebugTrace({
|
|
33347
|
+
interactionId,
|
|
33348
|
+
category: "command",
|
|
33349
|
+
stage: "completed",
|
|
33350
|
+
level: handlerResult.success ? "info" : "warn",
|
|
33351
|
+
payload: { cmd, source: logSource, success: handlerResult.success, durationMs: Date.now() - cmdStart }
|
|
33352
|
+
});
|
|
33110
33353
|
if (CHAT_COMMANDS.includes(cmd) && this.deps.onPostChatCommand) {
|
|
33111
33354
|
this.deps.onPostChatCommand();
|
|
33112
33355
|
}
|
|
33113
33356
|
return handlerResult;
|
|
33114
33357
|
} catch (e) {
|
|
33115
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, args, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
33358
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd, source: logSource, interactionId, args: normalizedArgs, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
33359
|
+
recordDebugTrace({
|
|
33360
|
+
interactionId,
|
|
33361
|
+
category: "command",
|
|
33362
|
+
stage: "failed",
|
|
33363
|
+
level: "error",
|
|
33364
|
+
payload: { cmd, source: logSource, error: e?.message || String(e), durationMs: Date.now() - cmdStart }
|
|
33365
|
+
});
|
|
33116
33366
|
throw e;
|
|
33117
33367
|
}
|
|
33118
33368
|
}
|
|
@@ -33154,6 +33404,14 @@ var init_router = __esm({
|
|
|
33154
33404
|
return { success: false, error: e.message };
|
|
33155
33405
|
}
|
|
33156
33406
|
}
|
|
33407
|
+
case "get_debug_trace": {
|
|
33408
|
+
const count = parseInt(args?.count) || parseInt(args?.limit) || 100;
|
|
33409
|
+
const sinceTs = Number(args?.since) || 0;
|
|
33410
|
+
const interactionId = typeof args?.interactionId === "string" ? args.interactionId : void 0;
|
|
33411
|
+
const category = typeof args?.category === "string" ? args.category : void 0;
|
|
33412
|
+
const trace = getRecentDebugTrace({ interactionId, category, limit: count }).filter((entry) => !sinceTs || entry.ts > sinceTs);
|
|
33413
|
+
return { success: true, trace, count: trace.length };
|
|
33414
|
+
}
|
|
33157
33415
|
case "session_host_get_diagnostics": {
|
|
33158
33416
|
if (!this.deps.sessionHostControl) return { success: false, error: "Session host control unavailable" };
|
|
33159
33417
|
const diagnostics = await this.deps.sessionHostControl.getDiagnostics({
|
|
@@ -40623,6 +40881,22 @@ var init_session_host_transport = __esm({
|
|
|
40623
40881
|
}
|
|
40624
40882
|
});
|
|
40625
40883
|
|
|
40884
|
+
// ../../oss/packages/daemon-core/src/session-host/app-name.ts
|
|
40885
|
+
function resolveSessionHostAppName(options = {}) {
|
|
40886
|
+
const env = options.env || process.env;
|
|
40887
|
+
const explicit = typeof env.ADHDEV_SESSION_HOST_NAME === "string" ? env.ADHDEV_SESSION_HOST_NAME.trim() : "";
|
|
40888
|
+
if (explicit) return explicit;
|
|
40889
|
+
return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME;
|
|
40890
|
+
}
|
|
40891
|
+
var DEFAULT_SESSION_HOST_APP_NAME, DEFAULT_STANDALONE_SESSION_HOST_APP_NAME;
|
|
40892
|
+
var init_app_name = __esm({
|
|
40893
|
+
"../../oss/packages/daemon-core/src/session-host/app-name.ts"() {
|
|
40894
|
+
"use strict";
|
|
40895
|
+
DEFAULT_SESSION_HOST_APP_NAME = "adhdev";
|
|
40896
|
+
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = "adhdev-standalone";
|
|
40897
|
+
}
|
|
40898
|
+
});
|
|
40899
|
+
|
|
40626
40900
|
// ../../oss/packages/daemon-core/src/session-host/runtime-support.ts
|
|
40627
40901
|
async function canConnect(endpoint) {
|
|
40628
40902
|
const client = new SessionHostClient({ endpoint });
|
|
@@ -40669,7 +40943,8 @@ async function listHostedCliRuntimes(endpoint) {
|
|
|
40669
40943
|
cliType: record2.providerType,
|
|
40670
40944
|
workspace: record2.workspace,
|
|
40671
40945
|
cliArgs: Array.isArray(record2.meta?.cliArgs) ? record2.meta.cliArgs : [],
|
|
40672
|
-
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0
|
|
40946
|
+
providerSessionId: typeof record2.meta?.providerSessionId === "string" ? String(record2.meta.providerSessionId) : void 0,
|
|
40947
|
+
managedBy: typeof record2.meta?.managedBy === "string" ? String(record2.meta.managedBy) : void 0
|
|
40673
40948
|
}));
|
|
40674
40949
|
} finally {
|
|
40675
40950
|
await client.close().catch(() => {
|
|
@@ -41192,6 +41467,8 @@ __export(src_exports, {
|
|
|
41192
41467
|
CliProviderInstance: () => CliProviderInstance,
|
|
41193
41468
|
DAEMON_WS_PATH: () => DAEMON_WS_PATH,
|
|
41194
41469
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
41470
|
+
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
41471
|
+
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
41195
41472
|
DaemonAgentStreamManager: () => DaemonAgentStreamManager,
|
|
41196
41473
|
DaemonCdpInitializer: () => DaemonCdpInitializer,
|
|
41197
41474
|
DaemonCdpManager: () => DaemonCdpManager,
|
|
@@ -41213,7 +41490,11 @@ __export(src_exports, {
|
|
|
41213
41490
|
buildMachineInfo: () => buildMachineInfo,
|
|
41214
41491
|
buildSessionEntries: () => buildSessionEntries,
|
|
41215
41492
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
41493
|
+
clearDebugTrace: () => clearDebugTrace,
|
|
41494
|
+
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
41216
41495
|
connectCdpManager: () => connectCdpManager,
|
|
41496
|
+
createDebugTraceStore: () => createDebugTraceStore,
|
|
41497
|
+
createInteractionId: () => createInteractionId,
|
|
41217
41498
|
detectAllVersions: () => detectAllVersions,
|
|
41218
41499
|
detectCLIs: () => detectCLIs,
|
|
41219
41500
|
detectIDEs: () => detectIDEs,
|
|
@@ -41224,10 +41505,12 @@ __export(src_exports, {
|
|
|
41224
41505
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
41225
41506
|
getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
|
|
41226
41507
|
getDaemonLogDir: () => getDaemonLogDir,
|
|
41508
|
+
getDebugRuntimeConfig: () => getDebugRuntimeConfig,
|
|
41227
41509
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
41228
41510
|
getLogLevel: () => getLogLevel,
|
|
41229
41511
|
getRecentActivity: () => getRecentActivity,
|
|
41230
41512
|
getRecentCommands: () => getRecentCommands,
|
|
41513
|
+
getRecentDebugTrace: () => getRecentDebugTrace,
|
|
41231
41514
|
getRecentLogs: () => getRecentLogs,
|
|
41232
41515
|
getSavedProviderSessions: () => getSavedProviderSessions,
|
|
41233
41516
|
getWorkspaceState: () => getWorkspaceState,
|
|
@@ -41254,13 +41537,19 @@ __export(src_exports, {
|
|
|
41254
41537
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
41255
41538
|
probeCdpPort: () => probeCdpPort,
|
|
41256
41539
|
readChatHistory: () => readChatHistory,
|
|
41540
|
+
recordDebugTrace: () => recordDebugTrace,
|
|
41257
41541
|
registerExtensionProviders: () => registerExtensionProviders,
|
|
41258
41542
|
resetConfig: () => resetConfig,
|
|
41543
|
+
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
41259
41544
|
resetState: () => resetState,
|
|
41545
|
+
resolveDebugRuntimeConfig: () => resolveDebugRuntimeConfig,
|
|
41546
|
+
resolveSessionHostAppName: () => resolveSessionHostAppName,
|
|
41260
41547
|
saveConfig: () => saveConfig,
|
|
41261
41548
|
saveState: () => saveState,
|
|
41549
|
+
setDebugRuntimeConfig: () => setDebugRuntimeConfig,
|
|
41262
41550
|
setLogLevel: () => setLogLevel,
|
|
41263
41551
|
setupIdeInstance: () => setupIdeInstance,
|
|
41552
|
+
shouldCollectTraceCategory: () => shouldCollectTraceCategory,
|
|
41264
41553
|
shutdownDaemonComponents: () => shutdownDaemonComponents,
|
|
41265
41554
|
spawnDetachedDaemonUpgradeHelper: () => spawnDetachedDaemonUpgradeHelper,
|
|
41266
41555
|
startDaemonDevSupport: () => startDaemonDevSupport,
|
|
@@ -41291,6 +41580,8 @@ var init_src = __esm({
|
|
|
41291
41580
|
init_snapshot();
|
|
41292
41581
|
init_normalize();
|
|
41293
41582
|
init_logger();
|
|
41583
|
+
init_debug_config();
|
|
41584
|
+
init_debug_trace();
|
|
41294
41585
|
init_command_log();
|
|
41295
41586
|
init_cli_manager();
|
|
41296
41587
|
init_launch();
|
|
@@ -41309,6 +41600,7 @@ var init_src = __esm({
|
|
|
41309
41600
|
init_provider_cli_adapter();
|
|
41310
41601
|
init_pty_transport();
|
|
41311
41602
|
init_session_host_transport();
|
|
41603
|
+
init_app_name();
|
|
41312
41604
|
init_runtime_support();
|
|
41313
41605
|
init_installer();
|
|
41314
41606
|
init_daemon_lifecycle();
|
|
@@ -49638,18 +49930,6 @@ function killPid2(pid) {
|
|
|
49638
49930
|
}
|
|
49639
49931
|
function getWindowsProcessCommandLine(pid) {
|
|
49640
49932
|
const pidFilter = `ProcessId=${pid}`;
|
|
49641
|
-
try {
|
|
49642
|
-
const wmicOut = (0, import_child_process11.execFileSync)("wmic", [
|
|
49643
|
-
"process",
|
|
49644
|
-
"where",
|
|
49645
|
-
pidFilter,
|
|
49646
|
-
"get",
|
|
49647
|
-
"CommandLine"
|
|
49648
|
-
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
49649
|
-
const text = wmicOut.trim();
|
|
49650
|
-
if (text) return text;
|
|
49651
|
-
} catch {
|
|
49652
|
-
}
|
|
49653
49933
|
try {
|
|
49654
49934
|
const psOut = (0, import_child_process11.execFileSync)("powershell.exe", [
|
|
49655
49935
|
"-NoProfile",
|
|
@@ -49663,6 +49943,18 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
49663
49943
|
if (text) return text;
|
|
49664
49944
|
} catch {
|
|
49665
49945
|
}
|
|
49946
|
+
try {
|
|
49947
|
+
const wmicOut = (0, import_child_process11.execFileSync)("wmic", [
|
|
49948
|
+
"process",
|
|
49949
|
+
"where",
|
|
49950
|
+
pidFilter,
|
|
49951
|
+
"get",
|
|
49952
|
+
"CommandLine"
|
|
49953
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
49954
|
+
const text = wmicOut.trim();
|
|
49955
|
+
if (text) return text;
|
|
49956
|
+
} catch {
|
|
49957
|
+
}
|
|
49666
49958
|
return null;
|
|
49667
49959
|
}
|
|
49668
49960
|
function stopSessionHost() {
|
|
@@ -49671,7 +49963,7 @@ function stopSessionHost() {
|
|
|
49671
49963
|
try {
|
|
49672
49964
|
if (fs16.existsSync(pidFile)) {
|
|
49673
49965
|
const pid = Number.parseInt(fs16.readFileSync(pidFile, "utf8").trim(), 10);
|
|
49674
|
-
if (Number.isFinite(pid)) {
|
|
49966
|
+
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
49675
49967
|
stopped = killPid2(pid) || stopped;
|
|
49676
49968
|
}
|
|
49677
49969
|
}
|
|
@@ -49707,7 +49999,7 @@ function stopSessionHost() {
|
|
|
49707
49999
|
const raw = (0, import_child_process11.execFileSync)("pgrep", ["-f", "session-host-daemon"], { encoding: "utf8" }).trim();
|
|
49708
50000
|
for (const line of raw.split("\n")) {
|
|
49709
50001
|
const pid = Number.parseInt(line.trim(), 10);
|
|
49710
|
-
if (Number.isFinite(pid)) {
|
|
50002
|
+
if (Number.isFinite(pid) && pid !== process.pid && pid !== process.ppid) {
|
|
49711
50003
|
stopped = killPid2(pid) || stopped;
|
|
49712
50004
|
}
|
|
49713
50005
|
}
|
|
@@ -50047,11 +50339,21 @@ function removeDaemonPid() {
|
|
|
50047
50339
|
}
|
|
50048
50340
|
function isDaemonRunning() {
|
|
50049
50341
|
try {
|
|
50050
|
-
const
|
|
50051
|
-
const
|
|
50052
|
-
|
|
50053
|
-
|
|
50054
|
-
|
|
50342
|
+
const { execFileSync: execFileSync4 } = require("child_process");
|
|
50343
|
+
const probe = `
|
|
50344
|
+
const http = require('http');
|
|
50345
|
+
const req = http.get('http://127.0.0.1:${DEFAULT_DAEMON_PORT}/health', { timeout: 1500 }, (res) => {
|
|
50346
|
+
process.stdout.write(String(res.statusCode));
|
|
50347
|
+
res.resume();
|
|
50348
|
+
});
|
|
50349
|
+
req.on('error', () => process.stdout.write('0'));
|
|
50350
|
+
req.on('timeout', () => { req.destroy(); process.stdout.write('0'); });
|
|
50351
|
+
`;
|
|
50352
|
+
const result = execFileSync4(process.execPath, ["-e", probe], {
|
|
50353
|
+
encoding: "utf-8",
|
|
50354
|
+
timeout: 3e3,
|
|
50355
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
50356
|
+
}).trim();
|
|
50055
50357
|
if (result === "200") return true;
|
|
50056
50358
|
} catch {
|
|
50057
50359
|
}
|
|
@@ -50060,12 +50362,46 @@ function isDaemonRunning() {
|
|
|
50060
50362
|
if (!fs17.existsSync(pidFile)) return false;
|
|
50061
50363
|
const pid = parseInt(fs17.readFileSync(pidFile, "utf-8").trim());
|
|
50062
50364
|
process.kill(pid, 0);
|
|
50365
|
+
if (!isAdhdevProcess(pid)) {
|
|
50366
|
+
removeDaemonPid();
|
|
50367
|
+
return false;
|
|
50368
|
+
}
|
|
50063
50369
|
return true;
|
|
50064
50370
|
} catch {
|
|
50065
50371
|
removeDaemonPid();
|
|
50066
50372
|
return false;
|
|
50067
50373
|
}
|
|
50068
50374
|
}
|
|
50375
|
+
function isAdhdevProcess(pid) {
|
|
50376
|
+
try {
|
|
50377
|
+
if (process.platform === "win32") {
|
|
50378
|
+
const { execFileSync: execFileSync4 } = require("child_process");
|
|
50379
|
+
try {
|
|
50380
|
+
const psOut = execFileSync4("powershell.exe", [
|
|
50381
|
+
"-NoProfile",
|
|
50382
|
+
"-NonInteractive",
|
|
50383
|
+
"-ExecutionPolicy",
|
|
50384
|
+
"Bypass",
|
|
50385
|
+
"-Command",
|
|
50386
|
+
`(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CommandLine`
|
|
50387
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
50388
|
+
return /adhdev|daemon/i.test(psOut);
|
|
50389
|
+
} catch {
|
|
50390
|
+
return true;
|
|
50391
|
+
}
|
|
50392
|
+
} else {
|
|
50393
|
+
const { execFileSync: execFileSync4 } = require("child_process");
|
|
50394
|
+
const cmdline = execFileSync4("ps", ["-o", "command=", "-p", String(pid)], {
|
|
50395
|
+
encoding: "utf-8",
|
|
50396
|
+
timeout: 2e3,
|
|
50397
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
50398
|
+
}).trim();
|
|
50399
|
+
return /adhdev|daemon/i.test(cmdline);
|
|
50400
|
+
}
|
|
50401
|
+
} catch {
|
|
50402
|
+
return true;
|
|
50403
|
+
}
|
|
50404
|
+
}
|
|
50069
50405
|
function getDaemonPid() {
|
|
50070
50406
|
const pidFile = getDaemonPidFile();
|
|
50071
50407
|
try {
|
|
@@ -50107,7 +50443,7 @@ var init_adhdev_daemon = __esm({
|
|
|
50107
50443
|
import_ws3 = require("ws");
|
|
50108
50444
|
import_chalk2 = __toESM(require("chalk"));
|
|
50109
50445
|
init_version();
|
|
50110
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
50446
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.52" });
|
|
50111
50447
|
ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
|
|
50112
50448
|
"generating",
|
|
50113
50449
|
"waiting_approval",
|
|
@@ -50134,6 +50470,8 @@ var init_adhdev_daemon = __esm({
|
|
|
50134
50470
|
ideType = "unknown";
|
|
50135
50471
|
pendingMandatoryUpdate = null;
|
|
50136
50472
|
mandatoryUpgradeInFlight = false;
|
|
50473
|
+
debugConfig = resolveDebugRuntimeConfig();
|
|
50474
|
+
recentInteractionIdsBySession = /* @__PURE__ */ new Map();
|
|
50137
50475
|
static MANDATORY_UPDATE_BLOCKED_COMMANDS = /* @__PURE__ */ new Set([
|
|
50138
50476
|
"launch_ide",
|
|
50139
50477
|
"launch_cli",
|
|
@@ -50144,6 +50482,36 @@ var init_adhdev_daemon = __esm({
|
|
|
50144
50482
|
constructor() {
|
|
50145
50483
|
this.localPort = 19222;
|
|
50146
50484
|
}
|
|
50485
|
+
applyDebugRuntime(options) {
|
|
50486
|
+
this.debugConfig = resolveDebugRuntimeConfig({
|
|
50487
|
+
dev: options.dev,
|
|
50488
|
+
logLevel: options.logLevel,
|
|
50489
|
+
trace: options.trace,
|
|
50490
|
+
traceContent: options.traceContent,
|
|
50491
|
+
traceBufferSize: options.traceBufferSize,
|
|
50492
|
+
traceCategories: options.traceCategories
|
|
50493
|
+
});
|
|
50494
|
+
setDebugRuntimeConfig(this.debugConfig);
|
|
50495
|
+
configureDebugTraceStore();
|
|
50496
|
+
setLogLevel(this.debugConfig.logLevel);
|
|
50497
|
+
LOG.info("Daemon", `Debug runtime configured: level=${this.debugConfig.logLevel} trace=${this.debugConfig.collectDebugTrace ? "on" : "off"} traceContent=${this.debugConfig.traceContent ? "on" : "off"} traceBuffer=${this.debugConfig.traceBufferSize}`);
|
|
50498
|
+
}
|
|
50499
|
+
ensureInteractionContext(args) {
|
|
50500
|
+
const normalized = args && typeof args === "object" ? { ...args } : {};
|
|
50501
|
+
if (typeof normalized._interactionId !== "string" || !String(normalized._interactionId).trim()) {
|
|
50502
|
+
normalized._interactionId = createInteractionId();
|
|
50503
|
+
}
|
|
50504
|
+
const interactionId = String(normalized._interactionId);
|
|
50505
|
+
const targetSessionId = typeof normalized.targetSessionId === "string" ? normalized.targetSessionId : "";
|
|
50506
|
+
if (targetSessionId) {
|
|
50507
|
+
this.recentInteractionIdsBySession.set(targetSessionId, interactionId);
|
|
50508
|
+
}
|
|
50509
|
+
return normalized;
|
|
50510
|
+
}
|
|
50511
|
+
getSessionInteractionId(sessionId) {
|
|
50512
|
+
if (!sessionId) return void 0;
|
|
50513
|
+
return this.recentInteractionIdsBySession.get(sessionId);
|
|
50514
|
+
}
|
|
50147
50515
|
getCliPresentationMode(sessionId) {
|
|
50148
50516
|
if (!sessionId || !this.components) return null;
|
|
50149
50517
|
const instance = this.components.instanceManager.getInstance(sessionId);
|
|
@@ -50258,11 +50626,27 @@ var init_adhdev_daemon = __esm({
|
|
|
50258
50626
|
return null;
|
|
50259
50627
|
}
|
|
50260
50628
|
subscription.lastDeliveredSignature = deliverySignature;
|
|
50629
|
+
const interactionId = this.getSessionInteractionId(subscription.params.targetSessionId);
|
|
50630
|
+
recordDebugTrace({
|
|
50631
|
+
interactionId,
|
|
50632
|
+
category: "topic",
|
|
50633
|
+
stage: "session.chat_tail_published",
|
|
50634
|
+
level: "info",
|
|
50635
|
+
sessionId: subscription.params.targetSessionId,
|
|
50636
|
+
payload: {
|
|
50637
|
+
syncMode,
|
|
50638
|
+
totalMessages: Number(result.totalMessages || 0),
|
|
50639
|
+
replaceFrom: Number(result.replaceFrom || 0),
|
|
50640
|
+
hasModal: !!activeModal,
|
|
50641
|
+
hasTitle: typeof result.title === "string"
|
|
50642
|
+
}
|
|
50643
|
+
});
|
|
50261
50644
|
return {
|
|
50262
50645
|
topic: "session.chat_tail",
|
|
50263
50646
|
key: subscription.key,
|
|
50264
50647
|
sessionId: subscription.params.targetSessionId,
|
|
50265
50648
|
...subscription.params.historySessionId ? { historySessionId: subscription.params.historySessionId } : {},
|
|
50649
|
+
...interactionId ? { interactionId } : {},
|
|
50266
50650
|
seq: subscription.seq,
|
|
50267
50651
|
timestamp: Date.now(),
|
|
50268
50652
|
messages: Array.isArray(result.messages) ? result.messages : [],
|
|
@@ -50408,6 +50792,20 @@ var init_adhdev_daemon = __esm({
|
|
|
50408
50792
|
subscription.lastDeliveredSignature = deliverySignature;
|
|
50409
50793
|
subscription.seq += 1;
|
|
50410
50794
|
subscription.lastSentAt = now;
|
|
50795
|
+
const interactionId = this.getSessionInteractionId(subscription.params.targetSessionId);
|
|
50796
|
+
recordDebugTrace({
|
|
50797
|
+
interactionId,
|
|
50798
|
+
category: "topic",
|
|
50799
|
+
stage: "session.modal_published",
|
|
50800
|
+
level: "info",
|
|
50801
|
+
sessionId: subscription.params.targetSessionId,
|
|
50802
|
+
payload: {
|
|
50803
|
+
status,
|
|
50804
|
+
hasTitle: !!title,
|
|
50805
|
+
modalMessage: modalMessage ? modalMessage.slice(0, 140) : void 0,
|
|
50806
|
+
modalButtonCount: modalButtons.length
|
|
50807
|
+
}
|
|
50808
|
+
});
|
|
50411
50809
|
return {
|
|
50412
50810
|
topic: "session.modal",
|
|
50413
50811
|
key: subscription.key,
|
|
@@ -50416,6 +50814,7 @@ var init_adhdev_daemon = __esm({
|
|
|
50416
50814
|
...title ? { title } : {},
|
|
50417
50815
|
...modalMessage ? { modalMessage } : {},
|
|
50418
50816
|
...modalButtons.length > 0 ? { modalButtons } : {},
|
|
50817
|
+
...interactionId ? { interactionId } : {},
|
|
50419
50818
|
seq: subscription.seq,
|
|
50420
50819
|
timestamp: now
|
|
50421
50820
|
};
|
|
@@ -50461,6 +50860,7 @@ var init_adhdev_daemon = __esm({
|
|
|
50461
50860
|
}
|
|
50462
50861
|
async start(options = {}) {
|
|
50463
50862
|
installGlobalInterceptor();
|
|
50863
|
+
this.applyDebugRuntime(options);
|
|
50464
50864
|
process.on("uncaughtException", (err) => {
|
|
50465
50865
|
LOG.error("Daemon", `Uncaught exception: ${err?.message}
|
|
50466
50866
|
${err?.stack || ""}`);
|
|
@@ -50487,6 +50887,7 @@ ${err?.stack || ""}`);
|
|
|
50487
50887
|
console.log(import_chalk2.default.gray(" Run `adhdev setup` first.\n"));
|
|
50488
50888
|
process.exit(1);
|
|
50489
50889
|
}
|
|
50890
|
+
await this.startLocalIpcServer();
|
|
50490
50891
|
const sessionHostEndpoint = await ensureSessionHostReady2();
|
|
50491
50892
|
this.sessionHostEndpoint = sessionHostEndpoint;
|
|
50492
50893
|
this.sessionHostController = new SessionHostController(
|
|
@@ -50511,6 +50912,7 @@ ${err?.stack || ""}`);
|
|
|
50511
50912
|
}),
|
|
50512
50913
|
onStatusChange: () => this.statusReporter?.onStatusChange(),
|
|
50513
50914
|
removeAgentTracking: (key) => this.statusReporter?.removeAgentTracking(key),
|
|
50915
|
+
hostedRuntimeManagerTag: "adhdev-cloud",
|
|
50514
50916
|
createPtyTransportFactory: ({ runtimeId, providerType, workspace, cliArgs, providerSessionId, attachExisting }) => new SessionHostPtyTransportFactory({
|
|
50515
50917
|
endpoint: sessionHostEndpoint,
|
|
50516
50918
|
ensureReady: async () => {
|
|
@@ -50521,12 +50923,13 @@ ${err?.stack || ""}`);
|
|
|
50521
50923
|
runtimeId,
|
|
50522
50924
|
providerType,
|
|
50523
50925
|
workspace,
|
|
50926
|
+
attachExisting,
|
|
50524
50927
|
appName: process.env.ADHDEV_SESSION_HOST_NAME || "adhdev",
|
|
50525
50928
|
meta: {
|
|
50526
50929
|
cliArgs,
|
|
50527
|
-
providerSessionId
|
|
50528
|
-
|
|
50529
|
-
|
|
50930
|
+
providerSessionId,
|
|
50931
|
+
managedBy: "adhdev-cloud"
|
|
50932
|
+
}
|
|
50530
50933
|
}),
|
|
50531
50934
|
listHostedCliRuntimes: async () => listHostedCliRuntimes2(sessionHostEndpoint)
|
|
50532
50935
|
},
|
|
@@ -50549,7 +50952,6 @@ ${err?.stack || ""}`);
|
|
|
50549
50952
|
}
|
|
50550
50953
|
});
|
|
50551
50954
|
await this.components.cliManager.restoreHostedSessions();
|
|
50552
|
-
await this.startLocalIpcServer();
|
|
50553
50955
|
this.components.providerLoader.fetchLatest().then(({ updated }) => {
|
|
50554
50956
|
if (updated) {
|
|
50555
50957
|
this.components.providerLoader.reload();
|
|
@@ -50763,7 +51165,9 @@ ${err?.stack || ""}`);
|
|
|
50763
51165
|
});
|
|
50764
51166
|
}
|
|
50765
51167
|
async handleCommand(msg, cmd, args) {
|
|
50766
|
-
|
|
51168
|
+
const normalizedArgs = this.ensureInteractionContext(args);
|
|
51169
|
+
const interactionId = String(normalizedArgs._interactionId);
|
|
51170
|
+
LOG.info("Command", `${cmd}${normalizedArgs?.targetSessionId ? ` \u2192 session:${String(normalizedArgs.targetSessionId).split("_")[0]}` : ""} [${interactionId}]`);
|
|
50767
51171
|
const cmdStart = Date.now();
|
|
50768
51172
|
const source = msg.ipcWs ? "ext" : typeof msg.source === "string" && msg.source.trim() ? msg.source : "ws";
|
|
50769
51173
|
try {
|
|
@@ -50773,18 +51177,20 @@ ${err?.stack || ""}`);
|
|
|
50773
51177
|
code: "DAEMON_UPDATE_REQUIRED",
|
|
50774
51178
|
required: true,
|
|
50775
51179
|
latest: this.pendingMandatoryUpdate.targetVersion,
|
|
50776
|
-
reason: this.pendingMandatoryUpdate.reason
|
|
51180
|
+
reason: this.pendingMandatoryUpdate.reason,
|
|
51181
|
+
interactionId
|
|
50777
51182
|
});
|
|
50778
51183
|
return;
|
|
50779
51184
|
}
|
|
50780
51185
|
if (source === "api" && !loadConfig().allowServerApiProxy) {
|
|
50781
51186
|
this.sendResult(msg, false, {
|
|
50782
51187
|
error: "Server API relay is disabled on this daemon. Enable it explicitly with `adhdev daemon:api enable`.",
|
|
50783
|
-
code: "SERVER_API_DISABLED"
|
|
51188
|
+
code: "SERVER_API_DISABLED",
|
|
51189
|
+
interactionId
|
|
50784
51190
|
});
|
|
50785
51191
|
return;
|
|
50786
51192
|
}
|
|
50787
|
-
const result = await this.components.router.execute(cmd,
|
|
51193
|
+
const result = await this.components.router.execute(cmd, normalizedArgs, source);
|
|
50788
51194
|
if (cmd.startsWith("workspace_")) this.statusReporter?.throttledReport();
|
|
50789
51195
|
if (cmd === "get_status_metadata" || cmd.startsWith("workspace_") || cmd.startsWith("session_host_")) {
|
|
50790
51196
|
void this.flushP2PDaemonMetadataSubscriptions();
|
|
@@ -50795,24 +51201,34 @@ ${err?.stack || ""}`);
|
|
|
50795
51201
|
if (cmd === "resolve_action" || cmd === "send_chat" || cmd === "read_chat") {
|
|
50796
51202
|
void this.flushP2PSessionModalSubscriptions();
|
|
50797
51203
|
}
|
|
50798
|
-
this.sendResult(msg, result.success, result);
|
|
51204
|
+
this.sendResult(msg, result.success, { ...result, interactionId });
|
|
51205
|
+
recordDebugTrace({
|
|
51206
|
+
interactionId,
|
|
51207
|
+
category: "command",
|
|
51208
|
+
stage: "result_sent",
|
|
51209
|
+
level: result.success ? "info" : "warn",
|
|
51210
|
+
sessionId: typeof normalizedArgs.targetSessionId === "string" ? normalizedArgs.targetSessionId : void 0,
|
|
51211
|
+
payload: { cmd, source, durationMs: Date.now() - cmdStart, success: result.success }
|
|
51212
|
+
});
|
|
50799
51213
|
} catch (e) {
|
|
50800
51214
|
console.error(import_chalk2.default.red(` \u2717 Command failed: ${e.message}`));
|
|
50801
|
-
this.sendResult(msg, false, { error: e.message });
|
|
51215
|
+
this.sendResult(msg, false, { error: e.message, interactionId });
|
|
50802
51216
|
}
|
|
50803
51217
|
}
|
|
50804
51218
|
/** P2P command processing — P2P-only commands + unified router */
|
|
50805
51219
|
async handleP2PCommand(cmdType, data) {
|
|
51220
|
+
const normalizedData = this.ensureInteractionContext(data);
|
|
51221
|
+
const interactionId = String(normalizedData._interactionId);
|
|
50806
51222
|
const cmdStart = Date.now();
|
|
50807
51223
|
try {
|
|
50808
51224
|
switch (cmdType) {
|
|
50809
51225
|
case "get_runtime_snapshot": {
|
|
50810
|
-
const sessionId = typeof
|
|
50811
|
-
if (!sessionId) return { success: false, error: "sessionId is required" };
|
|
51226
|
+
const sessionId = typeof normalizedData.sessionId === "string" ? normalizedData.sessionId : "";
|
|
51227
|
+
if (!sessionId) return { success: false, error: "sessionId is required", interactionId };
|
|
50812
51228
|
if (!this.isCliSession(sessionId)) {
|
|
50813
|
-
return { success: false, error: "CLI session runtime unavailable", code: "CLI_RUNTIME_UNAVAILABLE" };
|
|
51229
|
+
return { success: false, error: "CLI session runtime unavailable", code: "CLI_RUNTIME_UNAVAILABLE", interactionId };
|
|
50814
51230
|
}
|
|
50815
|
-
if (!this.sessionHostEndpoint) return { success: false, error: "Session host unavailable" };
|
|
51231
|
+
if (!this.sessionHostEndpoint) return { success: false, error: "Session host unavailable", interactionId };
|
|
50816
51232
|
const client = new SessionHostClient({ endpoint: this.sessionHostEndpoint });
|
|
50817
51233
|
try {
|
|
50818
51234
|
await client.connect();
|
|
@@ -50821,31 +51237,30 @@ ${err?.stack || ""}`);
|
|
|
50821
51237
|
payload: { sessionId }
|
|
50822
51238
|
});
|
|
50823
51239
|
if (!snapshot.success || !snapshot.result) {
|
|
50824
|
-
return { success: false, error: snapshot.error || "Runtime snapshot unavailable" };
|
|
51240
|
+
return { success: false, error: snapshot.error || "Runtime snapshot unavailable", interactionId };
|
|
50825
51241
|
}
|
|
50826
|
-
return { success: true, result: snapshot.result };
|
|
51242
|
+
return { success: true, result: snapshot.result, interactionId };
|
|
50827
51243
|
} finally {
|
|
50828
51244
|
await client.close().catch(() => {
|
|
50829
51245
|
});
|
|
50830
51246
|
}
|
|
50831
51247
|
}
|
|
50832
51248
|
case "set_machine_nickname": {
|
|
50833
|
-
const nickname =
|
|
51249
|
+
const nickname = normalizedData.nickname?.trim() || null;
|
|
50834
51250
|
const config2 = loadConfig();
|
|
50835
51251
|
config2.machineNickname = nickname;
|
|
50836
51252
|
saveConfig(config2);
|
|
50837
51253
|
void this.flushP2PDaemonMetadataSubscriptions();
|
|
50838
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", args: { nickname }, success: true, durationMs: Date.now() - cmdStart });
|
|
50839
|
-
return { success: true, nickname };
|
|
51254
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", interactionId, args: { nickname }, success: true, durationMs: Date.now() - cmdStart });
|
|
51255
|
+
return { success: true, nickname, interactionId };
|
|
50840
51256
|
}
|
|
50841
51257
|
case "get_command_history": {
|
|
50842
|
-
const
|
|
50843
|
-
const
|
|
50844
|
-
|
|
50845
|
-
return { success: true, history };
|
|
51258
|
+
const count = parseInt(normalizedData.count) || 50;
|
|
51259
|
+
const history = getRecentCommands(count);
|
|
51260
|
+
return { success: true, history, interactionId };
|
|
50846
51261
|
}
|
|
50847
51262
|
}
|
|
50848
|
-
const routed = await this.components.router.execute(cmdType,
|
|
51263
|
+
const routed = await this.components.router.execute(cmdType, normalizedData, "p2p");
|
|
50849
51264
|
if (cmdType.startsWith("workspace_")) this.statusReporter?.throttledReport();
|
|
50850
51265
|
if (cmdType === "get_status_metadata" || cmdType.startsWith("workspace_") || cmdType.startsWith("session_host_")) {
|
|
50851
51266
|
void this.flushP2PDaemonMetadataSubscriptions();
|
|
@@ -50856,10 +51271,10 @@ ${err?.stack || ""}`);
|
|
|
50856
51271
|
if (cmdType === "resolve_action" || cmdType === "send_chat" || cmdType === "read_chat") {
|
|
50857
51272
|
void this.flushP2PSessionModalSubscriptions();
|
|
50858
51273
|
}
|
|
50859
|
-
return routed;
|
|
51274
|
+
return { ...routed, interactionId };
|
|
50860
51275
|
} catch (e) {
|
|
50861
|
-
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
50862
|
-
return { success: false, error: e.message };
|
|
51276
|
+
logCommand({ ts: (/* @__PURE__ */ new Date()).toISOString(), cmd: cmdType, source: "p2p", interactionId, success: false, error: e.message, durationMs: Date.now() - cmdStart });
|
|
51277
|
+
return { success: false, error: e.message, interactionId };
|
|
50863
51278
|
}
|
|
50864
51279
|
}
|
|
50865
51280
|
async startLocalIpcServer() {
|
|
@@ -52892,18 +53307,23 @@ function summarizeLatestTransition(diagnostics) {
|
|
|
52892
53307
|
return `${latest.action} ${status}${lifecycle}${detail} @ ${at}`;
|
|
52893
53308
|
}
|
|
52894
53309
|
function registerDaemonCommands(program2, pkgVersion3) {
|
|
52895
|
-
program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL for testing").option("--dev", "Enable Dev Mode \u2014 HTTP API on :19280 for script debugging").action(async (options) => {
|
|
53310
|
+
program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port", "19222").option("--server <url>", "Override server URL for testing").option("--dev", "Enable Dev Mode \u2014 HTTP API on :19280 for script debugging + structured trace collection").option("--log-level <level>", "Console log level (debug|info|warn|error)").option("--trace", "Enable structured debug trace collection").option("--trace-content", "Include richer content snapshots in debug traces").option("--trace-buffer-size <count>", "Structured trace ring buffer size").action(async (options) => {
|
|
52896
53311
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
52897
53312
|
const daemon = new AdhdevDaemon2();
|
|
52898
53313
|
await daemon.start({
|
|
52899
53314
|
localPort: parseInt(options.port) || 19222,
|
|
52900
53315
|
serverUrl: options.server,
|
|
52901
53316
|
foreground: true,
|
|
52902
|
-
dev: options.dev || false
|
|
53317
|
+
dev: options.dev || false,
|
|
53318
|
+
logLevel: options.logLevel,
|
|
53319
|
+
trace: options.trace || false,
|
|
53320
|
+
traceContent: options.traceContent || false,
|
|
53321
|
+
traceBufferSize: options.traceBufferSize ? parseInt(options.traceBufferSize, 10) || void 0 : void 0
|
|
52903
53322
|
});
|
|
52904
53323
|
});
|
|
52905
53324
|
program2.command("standalone").description("\u{1F5A5}\uFE0F Start ADHDev Standalone Server (Local Dashboard & Embedded Daemon)").option("-p, --port <port>", "Local HTTP/WS server port", "3847").option("--host <host>", "Bind to specific host (use 0.0.0.0 for LAN access)").option("--no-open", "Prevent opening browser automatically").option("--token <token>", "Require token authentication").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
52906
53325
|
const { spawn: spawn5, execSync: execSync8 } = await import("child_process");
|
|
53326
|
+
const { DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: DEFAULT_STANDALONE_SESSION_HOST_APP_NAME2, resolveSessionHostAppName: resolveSessionHostAppName2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
52907
53327
|
console.log(import_chalk5.default.cyan("\n Starting ADHDev Standalone Server..."));
|
|
52908
53328
|
const args = [];
|
|
52909
53329
|
if (options.port) args.push("--port", options.port);
|
|
@@ -52911,6 +53331,11 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
52911
53331
|
if (options.open === false) args.push("--no-open");
|
|
52912
53332
|
if (options.token) args.push("--token", options.token);
|
|
52913
53333
|
if (options.dev) args.push("--dev");
|
|
53334
|
+
const sessionHostName = resolveSessionHostAppName2({ standalone: true, env: process.env });
|
|
53335
|
+
const standaloneEnv = {
|
|
53336
|
+
...process.env,
|
|
53337
|
+
ADHDEV_SESSION_HOST_NAME: process.env.ADHDEV_SESSION_HOST_NAME || sessionHostName
|
|
53338
|
+
};
|
|
52914
53339
|
let bin = "npx";
|
|
52915
53340
|
const npxArgs = ["-y", "@adhdev/daemon-standalone@latest", ...args];
|
|
52916
53341
|
try {
|
|
@@ -52920,10 +53345,12 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
52920
53345
|
console.log(import_chalk5.default.gray(" Standalone server package not found locally."));
|
|
52921
53346
|
console.log(import_chalk5.default.gray(" Downloading and running via npx (this may take a moment)..."));
|
|
52922
53347
|
}
|
|
53348
|
+
console.log(import_chalk5.default.gray(` Session host namespace: ${sessionHostName}${sessionHostName === DEFAULT_STANDALONE_SESSION_HOST_APP_NAME2 ? " (default isolated standalone namespace)" : " (from ADHDEV_SESSION_HOST_NAME)"}`));
|
|
52923
53349
|
const spawnArgs = bin === "npx" ? npxArgs : args;
|
|
52924
53350
|
const child = spawn5(bin, spawnArgs, {
|
|
52925
53351
|
stdio: "inherit",
|
|
52926
|
-
shell: process.platform === "win32"
|
|
53352
|
+
shell: process.platform === "win32",
|
|
53353
|
+
env: standaloneEnv
|
|
52927
53354
|
});
|
|
52928
53355
|
child.on("error", (err) => {
|
|
52929
53356
|
console.error(import_chalk5.default.red(`
|
|
@@ -54900,6 +55327,9 @@ function rotateLogs() {
|
|
|
54900
55327
|
}
|
|
54901
55328
|
function buildPlist(nodeExe, cliExe) {
|
|
54902
55329
|
const brewPrefix = import_node_fs3.default.existsSync("/opt/homebrew/bin") ? "/opt/homebrew/bin" : "/usr/local/bin";
|
|
55330
|
+
const nodeDir = import_node_path2.default.dirname(nodeExe);
|
|
55331
|
+
const pathEntries = /* @__PURE__ */ new Set([nodeDir, brewPrefix, "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"]);
|
|
55332
|
+
const pathValue = [...pathEntries].join(":");
|
|
54903
55333
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
54904
55334
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
54905
55335
|
<plist version="1.0">
|
|
@@ -54920,7 +55350,7 @@ function buildPlist(nodeExe, cliExe) {
|
|
|
54920
55350
|
<false/>
|
|
54921
55351
|
</dict>
|
|
54922
55352
|
<key>ThrottleInterval</key>
|
|
54923
|
-
<integer>
|
|
55353
|
+
<integer>30</integer>
|
|
54924
55354
|
<key>StandardOutPath</key>
|
|
54925
55355
|
<string>${LOG_OUT}</string>
|
|
54926
55356
|
<key>StandardErrorPath</key>
|
|
@@ -54928,7 +55358,7 @@ function buildPlist(nodeExe, cliExe) {
|
|
|
54928
55358
|
<key>EnvironmentVariables</key>
|
|
54929
55359
|
<dict>
|
|
54930
55360
|
<key>PATH</key>
|
|
54931
|
-
<string>${
|
|
55361
|
+
<string>${pathValue}</string>
|
|
54932
55362
|
</dict>
|
|
54933
55363
|
</dict>
|
|
54934
55364
|
</plist>`;
|
|
@@ -54968,19 +55398,23 @@ function uninstallDarwin() {
|
|
|
54968
55398
|
function isInstalledDarwin() {
|
|
54969
55399
|
return import_node_fs3.default.existsSync(getDarwinPlistPath());
|
|
54970
55400
|
}
|
|
54971
|
-
function buildVbs(cliExe) {
|
|
55401
|
+
function buildVbs(nodeExe, cliExe) {
|
|
55402
|
+
const logFile = import_node_path2.default.join(ADHDEV_DIR, "daemon-service.log").replace(/\\/g, "\\\\");
|
|
55403
|
+
const escapedNodeExe = nodeExe.replace(/\\/g, "\\\\");
|
|
55404
|
+
const escapedCliExe = cliExe.replace(/\\/g, "\\\\");
|
|
54972
55405
|
return `' ADHDev Daemon Auto-Start (generated by adhdev service install)
|
|
54973
55406
|
Set WshShell = CreateObject("WScript.Shell")
|
|
54974
|
-
WshShell.Run "cmd.exe /c ""
|
|
55407
|
+
WshShell.Run "cmd.exe /c """"${escapedNodeExe}"""" """"${escapedCliExe}"""" daemon >> """"${logFile}"""" 2>&1", 0, False
|
|
54975
55408
|
`;
|
|
54976
55409
|
}
|
|
54977
|
-
function installWindows(cliExe) {
|
|
55410
|
+
function installWindows(nodeExe, cliExe) {
|
|
54978
55411
|
const vbsPath = getWindowsVbsPath();
|
|
54979
55412
|
ensureDir(ADHDEV_DIR);
|
|
54980
55413
|
ensureDir(import_node_path2.default.dirname(vbsPath));
|
|
54981
|
-
import_node_fs3.default.writeFileSync(vbsPath, buildVbs(cliExe), "utf-8");
|
|
55414
|
+
import_node_fs3.default.writeFileSync(vbsPath, buildVbs(nodeExe, cliExe), "utf-8");
|
|
54982
55415
|
console.log(import_chalk8.default.gray(` Startup script: ${vbsPath}`));
|
|
54983
55416
|
console.log(import_chalk8.default.green("\n \u2713 Registered in Startup folder \u2014 daemon will start on login (hidden)."));
|
|
55417
|
+
console.log(import_chalk8.default.gray(` Logs: ${import_node_path2.default.join(ADHDEV_DIR, "daemon-service.log")}`));
|
|
54984
55418
|
console.log(import_chalk8.default.gray(" To start now without rebooting, run: adhdev daemon"));
|
|
54985
55419
|
}
|
|
54986
55420
|
function uninstallWindows() {
|
|
@@ -55009,7 +55443,7 @@ function registerServiceCommands(program2) {
|
|
|
55009
55443
|
if (platform12 === "darwin") {
|
|
55010
55444
|
installDarwin(nodeExe, cliExe);
|
|
55011
55445
|
} else if (platform12 === "win32") {
|
|
55012
|
-
installWindows(cliExe);
|
|
55446
|
+
installWindows(nodeExe, cliExe);
|
|
55013
55447
|
} else {
|
|
55014
55448
|
console.log(import_chalk8.default.yellow("\n \u26A0 Auto-start service install is not supported on this platform."));
|
|
55015
55449
|
console.log(import_chalk8.default.gray(" On Linux, create a systemd user unit manually:"));
|