@adhdev/daemon-core 0.9.48 → 0.9.49
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-adapter-types.d.ts +1 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +1 -0
- package/dist/commands/chat-commands.d.ts +9 -0
- package/dist/commands/upgrade-helper.d.ts +9 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +371 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +369 -21
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/cli-adapter-types.ts +1 -0
- package/src/cli-adapters/provider-cli-adapter.ts +82 -0
- package/src/cli-adapters/provider-cli-shared.ts +6 -1
- package/src/commands/chat-commands.ts +267 -2
- package/src/commands/cli-manager.ts +4 -1
- package/src/commands/handler.ts +1 -0
- package/src/commands/router.ts +5 -6
- package/src/commands/upgrade-helper.ts +37 -15
- package/src/detection/cli-detector.ts +5 -1
- package/src/index.d.ts +2 -2
- package/src/index.ts +10 -7
- package/src/launch.ts +2 -2
- package/src/providers/acp-provider-instance.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1473,7 +1473,12 @@ function findBinary(name) {
|
|
|
1473
1473
|
const isWin = os8.platform() === "win32";
|
|
1474
1474
|
try {
|
|
1475
1475
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
1476
|
-
return execSync3(cmd, {
|
|
1476
|
+
return execSync3(cmd, {
|
|
1477
|
+
encoding: "utf-8",
|
|
1478
|
+
timeout: 5e3,
|
|
1479
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1480
|
+
...isWin ? { windowsHide: true } : {}
|
|
1481
|
+
}).trim().split("\n")[0].trim();
|
|
1477
1482
|
} catch {
|
|
1478
1483
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
1479
1484
|
}
|
|
@@ -4154,6 +4159,83 @@ var init_provider_cli_adapter = __esm({
|
|
|
4154
4159
|
if (!this.isWaitingForResponse) return "";
|
|
4155
4160
|
return this.responseBuffer;
|
|
4156
4161
|
}
|
|
4162
|
+
getDebugSnapshot() {
|
|
4163
|
+
const screenText = this.readTerminalScreenText();
|
|
4164
|
+
const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
|
|
4165
|
+
return {
|
|
4166
|
+
cliType: this.cliType,
|
|
4167
|
+
cliName: this.cliName,
|
|
4168
|
+
workingDir: this.workingDir,
|
|
4169
|
+
currentStatus: this.currentStatus,
|
|
4170
|
+
ready: this.ready,
|
|
4171
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
4172
|
+
activeModal: this.activeModal,
|
|
4173
|
+
parseErrorMessage: this.parseErrorMessage,
|
|
4174
|
+
messageCounts: {
|
|
4175
|
+
committed: this.committedMessages.length,
|
|
4176
|
+
structured: this.structuredMessages.length,
|
|
4177
|
+
visible: this.messages.length,
|
|
4178
|
+
parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
|
|
4179
|
+
},
|
|
4180
|
+
buffers: {
|
|
4181
|
+
accumulatedLength: this.accumulatedBuffer.length,
|
|
4182
|
+
accumulatedRawLength: this.accumulatedRawBuffer.length,
|
|
4183
|
+
recentOutputLength: this.recentOutputBuffer.length,
|
|
4184
|
+
responseLength: this.responseBuffer.length,
|
|
4185
|
+
startupLength: this.startupBuffer.length,
|
|
4186
|
+
accumulatedTail: this.accumulatedBuffer.slice(-24e3),
|
|
4187
|
+
accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
|
|
4188
|
+
recentOutputTail: this.recentOutputBuffer.slice(-12e3),
|
|
4189
|
+
responseTail: this.responseBuffer.slice(-12e3)
|
|
4190
|
+
},
|
|
4191
|
+
terminal: {
|
|
4192
|
+
screenText,
|
|
4193
|
+
lastScreenSnapshot: this.lastScreenSnapshot,
|
|
4194
|
+
lastScreenText: this.lastScreenText,
|
|
4195
|
+
lastOutputAt: this.lastOutputAt,
|
|
4196
|
+
lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
|
|
4197
|
+
lastScreenChangeAt: this.lastScreenChangeAt,
|
|
4198
|
+
lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
|
|
4199
|
+
},
|
|
4200
|
+
parser: {
|
|
4201
|
+
scriptNames: listCliScriptNames(this.cliScripts),
|
|
4202
|
+
traceSessionId: this.traceSessionId,
|
|
4203
|
+
traceSeq: this.traceSeq,
|
|
4204
|
+
currentTurnScope: this.currentTurnScope,
|
|
4205
|
+
parsedStatusCache: parsedResult ? {
|
|
4206
|
+
id: parsedResult.id,
|
|
4207
|
+
status: parsedResult.status,
|
|
4208
|
+
title: parsedResult.title,
|
|
4209
|
+
providerSessionId: parsedResult.providerSessionId,
|
|
4210
|
+
transcriptAuthority: parsedResult.transcriptAuthority,
|
|
4211
|
+
coverage: parsedResult.coverage,
|
|
4212
|
+
messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
|
|
4213
|
+
activeModal: parsedResult.activeModal
|
|
4214
|
+
} : null,
|
|
4215
|
+
pendingScriptStatus: this.pendingScriptStatus,
|
|
4216
|
+
pendingScriptStatusSince: this.pendingScriptStatusSince
|
|
4217
|
+
},
|
|
4218
|
+
runtimeMetadata: this.getRuntimeMetadata(),
|
|
4219
|
+
statusHistory: this.statusHistory.slice(-80),
|
|
4220
|
+
traceEntries: this.traceEntries.slice(-120),
|
|
4221
|
+
timing: {
|
|
4222
|
+
spawnAt: this.spawnAt,
|
|
4223
|
+
startupFirstOutputAt: this.startupFirstOutputAt,
|
|
4224
|
+
submitPendingUntil: this.submitPendingUntil,
|
|
4225
|
+
responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
|
|
4226
|
+
responseEpoch: this.responseEpoch,
|
|
4227
|
+
resizeSuppressUntil: this.resizeSuppressUntil,
|
|
4228
|
+
lastApprovalResolvedAt: this.lastApprovalResolvedAt,
|
|
4229
|
+
committedMessagesChangedAt: this.committedMessagesChangedAt
|
|
4230
|
+
},
|
|
4231
|
+
finish: {
|
|
4232
|
+
idleFinishCandidate: this.idleFinishCandidate,
|
|
4233
|
+
finishRetryCount: this.finishRetryCount,
|
|
4234
|
+
submitRetryUsed: this.submitRetryUsed,
|
|
4235
|
+
submitRetryPromptSnippet: this.submitRetryPromptSnippet
|
|
4236
|
+
}
|
|
4237
|
+
};
|
|
4238
|
+
}
|
|
4157
4239
|
getRuntimeMetadata() {
|
|
4158
4240
|
if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
|
|
4159
4241
|
return this.ptyProcess.getMetadata();
|
|
@@ -5115,7 +5197,11 @@ function resolveCommandPath(command) {
|
|
|
5115
5197
|
}
|
|
5116
5198
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
5117
5199
|
return new Promise((resolve12) => {
|
|
5118
|
-
const child = exec(cmd, {
|
|
5200
|
+
const child = exec(cmd, {
|
|
5201
|
+
encoding: "utf-8",
|
|
5202
|
+
timeout: timeoutMs,
|
|
5203
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
5204
|
+
}, (err, stdout) => {
|
|
5119
5205
|
if (err || !stdout?.trim()) {
|
|
5120
5206
|
resolve12(null);
|
|
5121
5207
|
} else {
|
|
@@ -10789,6 +10875,245 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
10789
10875
|
...debugReadChat ? { debugReadChat } : {}
|
|
10790
10876
|
};
|
|
10791
10877
|
}
|
|
10878
|
+
var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
|
|
10879
|
+
maxDepth: 8,
|
|
10880
|
+
maxArrayLength: 80,
|
|
10881
|
+
maxObjectKeys: 120,
|
|
10882
|
+
maxStringLength: 16e3
|
|
10883
|
+
};
|
|
10884
|
+
var SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
|
|
10885
|
+
function truncateDebugString(value, maxLength) {
|
|
10886
|
+
if (value.length <= maxLength) return value;
|
|
10887
|
+
return `${value.slice(0, maxLength)}\u2026[truncated ${value.length - maxLength} chars]`;
|
|
10888
|
+
}
|
|
10889
|
+
function redactDebugSecrets(value) {
|
|
10890
|
+
return value.replace(/(Authorization\s*:\s*Bearer\s+)[^\s'"`]+/gi, "$1[REDACTED:bearer]").replace(/(Bearer\s+)[A-Za-z0-9._~+\/-]{16,}=*/gi, "$1[REDACTED:bearer]").replace(/\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]{20,}\b/g, "[REDACTED:github-token]").replace(/\bsk-[A-Za-z0-9_-]{16,}\b/g, "[REDACTED:api-key]").replace(/\bxox[baprs]-[A-Za-z0-9-]{12,}\b/g, "[REDACTED:slack-token]").replace(/\b(?:adk|adm)_[A-Za-z0-9_-]{16,}\b/g, "[REDACTED:adhdev-token]").replace(/((?:api[_-]?key|token|secret|password|passwd|client[_-]?secret)\s*[:=]\s*)[^\s,'"`}&]+/gi, "$1[REDACTED:secret]").replace(/([?&](?:api[_-]?key|token|secret|password|client_secret)=)[^&#\s]+/gi, "$1[REDACTED:secret]");
|
|
10891
|
+
}
|
|
10892
|
+
function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "") {
|
|
10893
|
+
const normalizedOptions = { ...DEFAULT_DEBUG_SANITIZE_OPTIONS, ...options };
|
|
10894
|
+
if (value === null || value === void 0) return value;
|
|
10895
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
10896
|
+
if (typeof value === "bigint") return String(value);
|
|
10897
|
+
if (typeof value === "string") {
|
|
10898
|
+
if (SECRET_KEY_PATTERN.test(keyHint) && value.trim()) return "[REDACTED:secret-field]";
|
|
10899
|
+
return truncateDebugString(redactDebugSecrets(value), normalizedOptions.maxStringLength);
|
|
10900
|
+
}
|
|
10901
|
+
if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
|
|
10902
|
+
if (typeof value !== "object") return String(value);
|
|
10903
|
+
if (depth >= normalizedOptions.maxDepth) return "[MaxDepth]";
|
|
10904
|
+
if (Array.isArray(value)) {
|
|
10905
|
+
const items = value.slice(0, normalizedOptions.maxArrayLength).map((item) => sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, keyHint));
|
|
10906
|
+
if (value.length > normalizedOptions.maxArrayLength) {
|
|
10907
|
+
items.push(`[truncated ${value.length - normalizedOptions.maxArrayLength} items]`);
|
|
10908
|
+
}
|
|
10909
|
+
return items;
|
|
10910
|
+
}
|
|
10911
|
+
const record = value;
|
|
10912
|
+
const result = {};
|
|
10913
|
+
const entries = Object.entries(record).slice(0, normalizedOptions.maxObjectKeys);
|
|
10914
|
+
for (const [key, item] of entries) {
|
|
10915
|
+
result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
|
|
10916
|
+
}
|
|
10917
|
+
const remaining = Object.keys(record).length - entries.length;
|
|
10918
|
+
if (remaining > 0) result.__truncatedKeys = remaining;
|
|
10919
|
+
return result;
|
|
10920
|
+
}
|
|
10921
|
+
function summarizeProviderForDebug(provider) {
|
|
10922
|
+
if (!provider) return null;
|
|
10923
|
+
const scripts = provider.scripts && typeof provider.scripts === "object" ? Object.keys(provider.scripts) : [];
|
|
10924
|
+
const controls = Array.isArray(provider.controls) ? provider.controls.map((control) => ({
|
|
10925
|
+
id: control?.id,
|
|
10926
|
+
label: control?.label,
|
|
10927
|
+
type: control?.type,
|
|
10928
|
+
settingKey: control?.settingKey,
|
|
10929
|
+
invokeScript: control?.invokeScript,
|
|
10930
|
+
listScript: control?.listScript,
|
|
10931
|
+
location: control?.location
|
|
10932
|
+
})) : [];
|
|
10933
|
+
return {
|
|
10934
|
+
type: provider.type,
|
|
10935
|
+
name: provider.name,
|
|
10936
|
+
category: provider.category,
|
|
10937
|
+
version: provider.version,
|
|
10938
|
+
canonicalHistory: provider.canonicalHistory,
|
|
10939
|
+
historyBehavior: provider.historyBehavior,
|
|
10940
|
+
webviewMatchText: provider.webviewMatchText,
|
|
10941
|
+
scriptNames: scripts,
|
|
10942
|
+
controls,
|
|
10943
|
+
resume: provider.resume
|
|
10944
|
+
};
|
|
10945
|
+
}
|
|
10946
|
+
function summarizeSessionForDebug(session) {
|
|
10947
|
+
if (!session || typeof session !== "object") return null;
|
|
10948
|
+
return {
|
|
10949
|
+
sessionId: session.sessionId,
|
|
10950
|
+
instanceKey: session.instanceKey,
|
|
10951
|
+
adapterKey: session.adapterKey,
|
|
10952
|
+
providerType: session.providerType,
|
|
10953
|
+
providerName: session.providerName,
|
|
10954
|
+
transport: session.transport,
|
|
10955
|
+
kind: session.kind,
|
|
10956
|
+
cdpManagerKey: session.cdpManagerKey,
|
|
10957
|
+
parentSessionId: session.parentSessionId,
|
|
10958
|
+
providerSessionId: session.providerSessionId,
|
|
10959
|
+
workspace: session.workspace,
|
|
10960
|
+
title: session.title,
|
|
10961
|
+
status: session.status,
|
|
10962
|
+
mode: session.mode,
|
|
10963
|
+
capabilities: session.capabilities
|
|
10964
|
+
};
|
|
10965
|
+
}
|
|
10966
|
+
function summarizeStateForDebug(state) {
|
|
10967
|
+
if (!state || typeof state !== "object") return null;
|
|
10968
|
+
const activeChat = state.activeChat && typeof state.activeChat === "object" ? state.activeChat : null;
|
|
10969
|
+
return {
|
|
10970
|
+
type: state.type,
|
|
10971
|
+
name: state.name,
|
|
10972
|
+
category: state.category,
|
|
10973
|
+
status: state.status,
|
|
10974
|
+
instanceId: state.instanceId,
|
|
10975
|
+
providerSessionId: state.providerSessionId,
|
|
10976
|
+
title: state.title,
|
|
10977
|
+
transport: state.transport,
|
|
10978
|
+
mode: state.mode,
|
|
10979
|
+
workspace: state.workspace,
|
|
10980
|
+
runtime: state.runtime,
|
|
10981
|
+
errorMessage: state.errorMessage,
|
|
10982
|
+
errorReason: state.errorReason,
|
|
10983
|
+
activeChat: activeChat ? {
|
|
10984
|
+
status: activeChat.status,
|
|
10985
|
+
title: activeChat.title,
|
|
10986
|
+
messageCount: Array.isArray(activeChat.messages) ? activeChat.messages.length : void 0,
|
|
10987
|
+
activeModal: activeChat.activeModal,
|
|
10988
|
+
messagesTail: Array.isArray(activeChat.messages) ? activeChat.messages.slice(-10) : void 0
|
|
10989
|
+
} : null,
|
|
10990
|
+
controlValues: state.controlValues,
|
|
10991
|
+
summaryMetadata: state.summaryMetadata
|
|
10992
|
+
};
|
|
10993
|
+
}
|
|
10994
|
+
function buildDebugBundleText(bundle) {
|
|
10995
|
+
return [
|
|
10996
|
+
"# ADHDev Chat Debug Bundle",
|
|
10997
|
+
"",
|
|
10998
|
+
"```json",
|
|
10999
|
+
JSON.stringify(bundle, null, 2),
|
|
11000
|
+
"```"
|
|
11001
|
+
].join("\n");
|
|
11002
|
+
}
|
|
11003
|
+
async function handleGetChatDebugBundle(h, args) {
|
|
11004
|
+
const provider = h.getProvider(args?.agentType);
|
|
11005
|
+
const transport = getTargetTransport(h, provider);
|
|
11006
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
11007
|
+
const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
|
|
11008
|
+
const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
|
|
11009
|
+
const targetInstance = getTargetInstance(h, args);
|
|
11010
|
+
let adapterStatus = null;
|
|
11011
|
+
let parsedStatus = null;
|
|
11012
|
+
let adapterDebugSnapshot = null;
|
|
11013
|
+
let partialResponse = "";
|
|
11014
|
+
if (adapter) {
|
|
11015
|
+
try {
|
|
11016
|
+
adapterStatus = adapter.getStatus?.();
|
|
11017
|
+
} catch (error) {
|
|
11018
|
+
adapterStatus = { error: error?.message || String(error) };
|
|
11019
|
+
}
|
|
11020
|
+
try {
|
|
11021
|
+
parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
|
|
11022
|
+
} catch (error) {
|
|
11023
|
+
parsedStatus = { error: error?.message || String(error) };
|
|
11024
|
+
}
|
|
11025
|
+
try {
|
|
11026
|
+
adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
|
|
11027
|
+
} catch (error) {
|
|
11028
|
+
adapterDebugSnapshot = { error: error?.message || String(error) };
|
|
11029
|
+
}
|
|
11030
|
+
try {
|
|
11031
|
+
partialResponse = adapter.getPartialResponse?.() || "";
|
|
11032
|
+
} catch {
|
|
11033
|
+
partialResponse = "";
|
|
11034
|
+
}
|
|
11035
|
+
}
|
|
11036
|
+
let instanceState = null;
|
|
11037
|
+
if (targetInstance?.getState) {
|
|
11038
|
+
try {
|
|
11039
|
+
instanceState = summarizeStateForDebug(targetInstance.getState());
|
|
11040
|
+
} catch (error) {
|
|
11041
|
+
instanceState = { error: error?.message || String(error) };
|
|
11042
|
+
}
|
|
11043
|
+
}
|
|
11044
|
+
let readChat = null;
|
|
11045
|
+
try {
|
|
11046
|
+
const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
|
|
11047
|
+
readChat = readResult.success ? {
|
|
11048
|
+
success: true,
|
|
11049
|
+
status: readResult.status,
|
|
11050
|
+
title: readResult.title,
|
|
11051
|
+
totalMessages: readResult.totalMessages,
|
|
11052
|
+
returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
|
|
11053
|
+
syncMode: readResult.syncMode,
|
|
11054
|
+
replaceFrom: readResult.replaceFrom,
|
|
11055
|
+
lastMessageSignature: readResult.lastMessageSignature,
|
|
11056
|
+
providerSessionId: readResult.providerSessionId,
|
|
11057
|
+
transcriptAuthority: readResult.transcriptAuthority,
|
|
11058
|
+
coverage: readResult.coverage,
|
|
11059
|
+
activeModal: readResult.activeModal,
|
|
11060
|
+
messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
|
|
11061
|
+
debugReadChat: readResult.debugReadChat
|
|
11062
|
+
} : { success: false, error: readResult.error };
|
|
11063
|
+
} catch (error) {
|
|
11064
|
+
readChat = { success: false, error: error?.message || String(error) };
|
|
11065
|
+
}
|
|
11066
|
+
const cdp = h.getCdp();
|
|
11067
|
+
const rawBundle = {
|
|
11068
|
+
version: 1,
|
|
11069
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11070
|
+
target: {
|
|
11071
|
+
targetSessionId,
|
|
11072
|
+
providerType,
|
|
11073
|
+
transport,
|
|
11074
|
+
routeManagerKey: h.currentManagerKey,
|
|
11075
|
+
currentIdeType: h.currentIdeType
|
|
11076
|
+
},
|
|
11077
|
+
session: summarizeSessionForDebug(h.currentSession),
|
|
11078
|
+
provider: summarizeProviderForDebug(provider),
|
|
11079
|
+
daemon: {
|
|
11080
|
+
pid: process.pid,
|
|
11081
|
+
platform: process.platform,
|
|
11082
|
+
nodeVersion: process.version,
|
|
11083
|
+
cwd: process.cwd()
|
|
11084
|
+
},
|
|
11085
|
+
cdp: {
|
|
11086
|
+
requested: !!cdp,
|
|
11087
|
+
connected: !!cdp?.isConnected,
|
|
11088
|
+
managerKey: getCurrentManagerKey(h)
|
|
11089
|
+
},
|
|
11090
|
+
instanceState,
|
|
11091
|
+
cli: adapter ? {
|
|
11092
|
+
cliType: adapter.cliType,
|
|
11093
|
+
cliName: adapter.cliName,
|
|
11094
|
+
workingDir: adapter.workingDir,
|
|
11095
|
+
status: adapterStatus?.status,
|
|
11096
|
+
activeModal: adapterStatus?.activeModal,
|
|
11097
|
+
messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
|
|
11098
|
+
messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
|
|
11099
|
+
parsedStatus,
|
|
11100
|
+
partialResponse,
|
|
11101
|
+
ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
|
|
11102
|
+
processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
|
|
11103
|
+
debugSnapshot: adapterDebugSnapshot
|
|
11104
|
+
} : null,
|
|
11105
|
+
readChat,
|
|
11106
|
+
frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
|
|
11107
|
+
recentLogs: getRecentLogs(80, "debug"),
|
|
11108
|
+
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
11109
|
+
};
|
|
11110
|
+
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
11111
|
+
return {
|
|
11112
|
+
success: true,
|
|
11113
|
+
bundle,
|
|
11114
|
+
text: buildDebugBundleText(bundle)
|
|
11115
|
+
};
|
|
11116
|
+
}
|
|
10792
11117
|
function didProviderConfirmSend(result) {
|
|
10793
11118
|
const parsed = parseMaybeJson(result);
|
|
10794
11119
|
if (parsed === true) return true;
|
|
@@ -12985,6 +13310,8 @@ var DaemonCommandHandler = class {
|
|
|
12985
13310
|
// ─── Chat commands (chat-commands.ts) ───────────────
|
|
12986
13311
|
case "read_chat":
|
|
12987
13312
|
return handleReadChat(this, args);
|
|
13313
|
+
case "get_chat_debug_bundle":
|
|
13314
|
+
return handleGetChatDebugBundle(this, args);
|
|
12988
13315
|
case "chat_history":
|
|
12989
13316
|
return handleChatHistory(this, args);
|
|
12990
13317
|
case "send_chat":
|
|
@@ -14670,7 +14997,8 @@ var AcpProviderInstance = class {
|
|
|
14670
14997
|
cwd: this.workingDir,
|
|
14671
14998
|
env,
|
|
14672
14999
|
stdio: ["pipe", "pipe", "pipe"],
|
|
14673
|
-
shell: spawnConfig.shell || false
|
|
15000
|
+
shell: spawnConfig.shell || false,
|
|
15001
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
14674
15002
|
});
|
|
14675
15003
|
const AUTH_ERROR_PATTERNS = [
|
|
14676
15004
|
/unauthorized|unauthenticated/i,
|
|
@@ -15366,7 +15694,10 @@ function commandExists(command) {
|
|
|
15366
15694
|
return existsSync10(expandExecutable(trimmed));
|
|
15367
15695
|
}
|
|
15368
15696
|
try {
|
|
15369
|
-
execFileSync(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15697
|
+
execFileSync(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15698
|
+
stdio: "ignore",
|
|
15699
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
15700
|
+
});
|
|
15370
15701
|
return true;
|
|
15371
15702
|
} catch {
|
|
15372
15703
|
return false;
|
|
@@ -18299,7 +18630,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
18299
18630
|
const canUseAppLauncher = !!appName;
|
|
18300
18631
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
18301
18632
|
if (!useAppLauncher && ide.cliCommand) {
|
|
18302
|
-
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
|
|
18633
|
+
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18303
18634
|
} else if (appName) {
|
|
18304
18635
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
18305
18636
|
spawn2("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
@@ -18328,7 +18659,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
18328
18659
|
const args = ["--remote-debugging-port=" + port];
|
|
18329
18660
|
if (newWindow) args.push("--new-window");
|
|
18330
18661
|
if (workspace) args.push(workspace);
|
|
18331
|
-
spawn2(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
18662
|
+
spawn2(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18332
18663
|
}
|
|
18333
18664
|
function getAvailableIdeIds() {
|
|
18334
18665
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -18817,23 +19148,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
|
|
|
18817
19148
|
if (platform10 === "win32") {
|
|
18818
19149
|
const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
18819
19150
|
if (fs8.existsSync(npmCliPath)) {
|
|
18820
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19151
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18821
19152
|
}
|
|
18822
19153
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
18823
19154
|
const candidatePath = path16.join(binDir, candidate);
|
|
18824
19155
|
if (fs8.existsSync(candidatePath)) {
|
|
18825
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19156
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18826
19157
|
}
|
|
18827
19158
|
}
|
|
18828
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19159
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18829
19160
|
}
|
|
18830
19161
|
for (const candidate of ["npm"]) {
|
|
18831
19162
|
const candidatePath = path16.join(binDir, candidate);
|
|
18832
19163
|
if (fs8.existsSync(candidatePath)) {
|
|
18833
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19164
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18834
19165
|
}
|
|
18835
19166
|
}
|
|
18836
|
-
return { executable: "npm", argsPrefix: [], execOptions:
|
|
19167
|
+
return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18837
19168
|
}
|
|
18838
19169
|
function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
18839
19170
|
if (!currentCliPath) return null;
|
|
@@ -18904,13 +19235,28 @@ function buildPinnedGlobalInstallCommand(options) {
|
|
|
18904
19235
|
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
18905
19236
|
};
|
|
18906
19237
|
}
|
|
18907
|
-
function getNpmExecOptions(
|
|
19238
|
+
function getNpmExecOptions(platform10 = process.platform) {
|
|
19239
|
+
if (platform10 === "win32") {
|
|
19240
|
+
return { shell: false, windowsHide: true };
|
|
19241
|
+
}
|
|
18908
19242
|
return { shell: false };
|
|
18909
19243
|
}
|
|
19244
|
+
function execNpmCommandSync(args, options = {}, surface) {
|
|
19245
|
+
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
19246
|
+
return execFileSync2(
|
|
19247
|
+
surface?.npmExecutable || "npm",
|
|
19248
|
+
[...surface?.npmArgsPrefix || [], ...args],
|
|
19249
|
+
{
|
|
19250
|
+
...options,
|
|
19251
|
+
...execOptions,
|
|
19252
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
19253
|
+
}
|
|
19254
|
+
);
|
|
19255
|
+
}
|
|
18910
19256
|
function killPid(pid) {
|
|
18911
19257
|
try {
|
|
18912
19258
|
if (process.platform === "win32") {
|
|
18913
|
-
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
19259
|
+
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
18914
19260
|
} else {
|
|
18915
19261
|
process.kill(pid, "SIGTERM");
|
|
18916
19262
|
}
|
|
@@ -18929,7 +19275,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18929
19275
|
"Bypass",
|
|
18930
19276
|
"-Command",
|
|
18931
19277
|
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
18932
|
-
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19278
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18933
19279
|
if (psOut) return psOut;
|
|
18934
19280
|
} catch {
|
|
18935
19281
|
}
|
|
@@ -18940,7 +19286,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18940
19286
|
pidFilter,
|
|
18941
19287
|
"get",
|
|
18942
19288
|
"CommandLine"
|
|
18943
|
-
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19289
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18944
19290
|
if (wmicOut) return wmicOut;
|
|
18945
19291
|
} catch {
|
|
18946
19292
|
}
|
|
@@ -19001,9 +19347,9 @@ function removeDaemonPidFile() {
|
|
|
19001
19347
|
}
|
|
19002
19348
|
function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
19003
19349
|
const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
|
|
19004
|
-
const npmRoot =
|
|
19350
|
+
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19005
19351
|
if (!npmRoot) return;
|
|
19006
|
-
const npmPrefix = surface.installPrefix ||
|
|
19352
|
+
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19007
19353
|
const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
|
|
19008
19354
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
19009
19355
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
@@ -19788,18 +20134,18 @@ var DaemonCommandRouter = class {
|
|
|
19788
20134
|
case "daemon_upgrade": {
|
|
19789
20135
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
19790
20136
|
try {
|
|
19791
|
-
const { execSync: execSync7 } = await import("child_process");
|
|
19792
20137
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
19793
20138
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
19794
|
-
const
|
|
20139
|
+
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
20140
|
+
const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
19795
20141
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
19796
20142
|
let currentInstalled = null;
|
|
19797
20143
|
try {
|
|
19798
|
-
const currentJson =
|
|
20144
|
+
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
19799
20145
|
encoding: "utf-8",
|
|
19800
20146
|
timeout: 1e4,
|
|
19801
20147
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19802
|
-
}).trim();
|
|
20148
|
+
}, npmSurface)).trim();
|
|
19803
20149
|
const parsed = JSON.parse(currentJson);
|
|
19804
20150
|
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
19805
20151
|
} catch {
|
|
@@ -27883,6 +28229,7 @@ export {
|
|
|
27883
28229
|
detectCLIs,
|
|
27884
28230
|
detectIDEs,
|
|
27885
28231
|
ensureSessionHostReady,
|
|
28232
|
+
execNpmCommandSync,
|
|
27886
28233
|
findCdpManager,
|
|
27887
28234
|
flattenMessageParts,
|
|
27888
28235
|
forwardAgentStreamsToIdeInstance,
|
|
@@ -27893,6 +28240,7 @@ export {
|
|
|
27893
28240
|
getDebugRuntimeConfig,
|
|
27894
28241
|
getHostMemorySnapshot,
|
|
27895
28242
|
getLogLevel,
|
|
28243
|
+
getNpmExecOptions,
|
|
27896
28244
|
getRecentActivity,
|
|
27897
28245
|
getRecentCommands,
|
|
27898
28246
|
getRecentDebugTrace,
|