@adhdev/daemon-core 0.9.48 → 0.9.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +380 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +378 -23
- 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 +271 -2
- package/src/commands/cli-manager.ts +4 -1
- package/src/commands/handler.ts +2 -0
- package/src/commands/router.ts +17 -8
- 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,248 @@ 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 targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
11005
|
+
if (!targetSessionId && !h.currentSession) {
|
|
11006
|
+
return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
|
|
11007
|
+
}
|
|
11008
|
+
const provider = h.getProvider(args?.agentType);
|
|
11009
|
+
const transport = getTargetTransport(h, provider);
|
|
11010
|
+
const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
|
|
11011
|
+
const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
|
|
11012
|
+
const targetInstance = getTargetInstance(h, args);
|
|
11013
|
+
let adapterStatus = null;
|
|
11014
|
+
let parsedStatus = null;
|
|
11015
|
+
let adapterDebugSnapshot = null;
|
|
11016
|
+
let partialResponse = "";
|
|
11017
|
+
if (adapter) {
|
|
11018
|
+
try {
|
|
11019
|
+
adapterStatus = adapter.getStatus?.();
|
|
11020
|
+
} catch (error) {
|
|
11021
|
+
adapterStatus = { error: error?.message || String(error) };
|
|
11022
|
+
}
|
|
11023
|
+
try {
|
|
11024
|
+
parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
|
|
11025
|
+
} catch (error) {
|
|
11026
|
+
parsedStatus = { error: error?.message || String(error) };
|
|
11027
|
+
}
|
|
11028
|
+
try {
|
|
11029
|
+
adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
|
|
11030
|
+
} catch (error) {
|
|
11031
|
+
adapterDebugSnapshot = { error: error?.message || String(error) };
|
|
11032
|
+
}
|
|
11033
|
+
try {
|
|
11034
|
+
partialResponse = adapter.getPartialResponse?.() || "";
|
|
11035
|
+
} catch {
|
|
11036
|
+
partialResponse = "";
|
|
11037
|
+
}
|
|
11038
|
+
}
|
|
11039
|
+
let instanceState = null;
|
|
11040
|
+
if (targetInstance?.getState) {
|
|
11041
|
+
try {
|
|
11042
|
+
instanceState = summarizeStateForDebug(targetInstance.getState());
|
|
11043
|
+
} catch (error) {
|
|
11044
|
+
instanceState = { error: error?.message || String(error) };
|
|
11045
|
+
}
|
|
11046
|
+
}
|
|
11047
|
+
let readChat = null;
|
|
11048
|
+
try {
|
|
11049
|
+
const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
|
|
11050
|
+
readChat = readResult.success ? {
|
|
11051
|
+
success: true,
|
|
11052
|
+
status: readResult.status,
|
|
11053
|
+
title: readResult.title,
|
|
11054
|
+
totalMessages: readResult.totalMessages,
|
|
11055
|
+
returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
|
|
11056
|
+
syncMode: readResult.syncMode,
|
|
11057
|
+
replaceFrom: readResult.replaceFrom,
|
|
11058
|
+
lastMessageSignature: readResult.lastMessageSignature,
|
|
11059
|
+
providerSessionId: readResult.providerSessionId,
|
|
11060
|
+
transcriptAuthority: readResult.transcriptAuthority,
|
|
11061
|
+
coverage: readResult.coverage,
|
|
11062
|
+
activeModal: readResult.activeModal,
|
|
11063
|
+
messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
|
|
11064
|
+
debugReadChat: readResult.debugReadChat
|
|
11065
|
+
} : { success: false, error: readResult.error };
|
|
11066
|
+
} catch (error) {
|
|
11067
|
+
readChat = { success: false, error: error?.message || String(error) };
|
|
11068
|
+
}
|
|
11069
|
+
const cdp = h.getCdp();
|
|
11070
|
+
const rawBundle = {
|
|
11071
|
+
version: 1,
|
|
11072
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11073
|
+
target: {
|
|
11074
|
+
targetSessionId,
|
|
11075
|
+
providerType,
|
|
11076
|
+
transport,
|
|
11077
|
+
routeManagerKey: h.currentManagerKey,
|
|
11078
|
+
currentIdeType: h.currentIdeType
|
|
11079
|
+
},
|
|
11080
|
+
session: summarizeSessionForDebug(h.currentSession),
|
|
11081
|
+
provider: summarizeProviderForDebug(provider),
|
|
11082
|
+
daemon: {
|
|
11083
|
+
pid: process.pid,
|
|
11084
|
+
platform: process.platform,
|
|
11085
|
+
nodeVersion: process.version,
|
|
11086
|
+
cwd: process.cwd()
|
|
11087
|
+
},
|
|
11088
|
+
cdp: {
|
|
11089
|
+
requested: !!cdp,
|
|
11090
|
+
connected: !!cdp?.isConnected,
|
|
11091
|
+
managerKey: getCurrentManagerKey(h)
|
|
11092
|
+
},
|
|
11093
|
+
instanceState,
|
|
11094
|
+
cli: adapter ? {
|
|
11095
|
+
cliType: adapter.cliType,
|
|
11096
|
+
cliName: adapter.cliName,
|
|
11097
|
+
workingDir: adapter.workingDir,
|
|
11098
|
+
status: adapterStatus?.status,
|
|
11099
|
+
activeModal: adapterStatus?.activeModal,
|
|
11100
|
+
messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
|
|
11101
|
+
messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
|
|
11102
|
+
parsedStatus,
|
|
11103
|
+
partialResponse,
|
|
11104
|
+
ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
|
|
11105
|
+
processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
|
|
11106
|
+
debugSnapshot: adapterDebugSnapshot
|
|
11107
|
+
} : null,
|
|
11108
|
+
readChat,
|
|
11109
|
+
frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
|
|
11110
|
+
recentLogs: getRecentLogs(80, "debug"),
|
|
11111
|
+
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
11112
|
+
};
|
|
11113
|
+
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
11114
|
+
return {
|
|
11115
|
+
success: true,
|
|
11116
|
+
bundle,
|
|
11117
|
+
text: buildDebugBundleText(bundle)
|
|
11118
|
+
};
|
|
11119
|
+
}
|
|
10792
11120
|
function didProviderConfirmSend(result) {
|
|
10793
11121
|
const parsed = parseMaybeJson(result);
|
|
10794
11122
|
if (parsed === true) return true;
|
|
@@ -12938,6 +13266,7 @@ var DaemonCommandHandler = class {
|
|
|
12938
13266
|
this.logCommandStart(cmd, args);
|
|
12939
13267
|
const sessionScopedCommands = /* @__PURE__ */ new Set([
|
|
12940
13268
|
"read_chat",
|
|
13269
|
+
"get_chat_debug_bundle",
|
|
12941
13270
|
"send_chat",
|
|
12942
13271
|
"list_chats",
|
|
12943
13272
|
"new_chat",
|
|
@@ -12985,6 +13314,8 @@ var DaemonCommandHandler = class {
|
|
|
12985
13314
|
// ─── Chat commands (chat-commands.ts) ───────────────
|
|
12986
13315
|
case "read_chat":
|
|
12987
13316
|
return handleReadChat(this, args);
|
|
13317
|
+
case "get_chat_debug_bundle":
|
|
13318
|
+
return handleGetChatDebugBundle(this, args);
|
|
12988
13319
|
case "chat_history":
|
|
12989
13320
|
return handleChatHistory(this, args);
|
|
12990
13321
|
case "send_chat":
|
|
@@ -14670,7 +15001,8 @@ var AcpProviderInstance = class {
|
|
|
14670
15001
|
cwd: this.workingDir,
|
|
14671
15002
|
env,
|
|
14672
15003
|
stdio: ["pipe", "pipe", "pipe"],
|
|
14673
|
-
shell: spawnConfig.shell || false
|
|
15004
|
+
shell: spawnConfig.shell || false,
|
|
15005
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
14674
15006
|
});
|
|
14675
15007
|
const AUTH_ERROR_PATTERNS = [
|
|
14676
15008
|
/unauthorized|unauthenticated/i,
|
|
@@ -15366,7 +15698,10 @@ function commandExists(command) {
|
|
|
15366
15698
|
return existsSync10(expandExecutable(trimmed));
|
|
15367
15699
|
}
|
|
15368
15700
|
try {
|
|
15369
|
-
execFileSync(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15701
|
+
execFileSync(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15702
|
+
stdio: "ignore",
|
|
15703
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
15704
|
+
});
|
|
15370
15705
|
return true;
|
|
15371
15706
|
} catch {
|
|
15372
15707
|
return false;
|
|
@@ -18299,7 +18634,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
18299
18634
|
const canUseAppLauncher = !!appName;
|
|
18300
18635
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
18301
18636
|
if (!useAppLauncher && ide.cliCommand) {
|
|
18302
|
-
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
|
|
18637
|
+
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18303
18638
|
} else if (appName) {
|
|
18304
18639
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
18305
18640
|
spawn2("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
@@ -18328,7 +18663,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
18328
18663
|
const args = ["--remote-debugging-port=" + port];
|
|
18329
18664
|
if (newWindow) args.push("--new-window");
|
|
18330
18665
|
if (workspace) args.push(workspace);
|
|
18331
|
-
spawn2(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
18666
|
+
spawn2(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18332
18667
|
}
|
|
18333
18668
|
function getAvailableIdeIds() {
|
|
18334
18669
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -18817,23 +19152,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
|
|
|
18817
19152
|
if (platform10 === "win32") {
|
|
18818
19153
|
const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
18819
19154
|
if (fs8.existsSync(npmCliPath)) {
|
|
18820
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19155
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18821
19156
|
}
|
|
18822
19157
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
18823
19158
|
const candidatePath = path16.join(binDir, candidate);
|
|
18824
19159
|
if (fs8.existsSync(candidatePath)) {
|
|
18825
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19160
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18826
19161
|
}
|
|
18827
19162
|
}
|
|
18828
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19163
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18829
19164
|
}
|
|
18830
19165
|
for (const candidate of ["npm"]) {
|
|
18831
19166
|
const candidatePath = path16.join(binDir, candidate);
|
|
18832
19167
|
if (fs8.existsSync(candidatePath)) {
|
|
18833
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19168
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18834
19169
|
}
|
|
18835
19170
|
}
|
|
18836
|
-
return { executable: "npm", argsPrefix: [], execOptions:
|
|
19171
|
+
return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18837
19172
|
}
|
|
18838
19173
|
function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
18839
19174
|
if (!currentCliPath) return null;
|
|
@@ -18904,13 +19239,28 @@ function buildPinnedGlobalInstallCommand(options) {
|
|
|
18904
19239
|
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
18905
19240
|
};
|
|
18906
19241
|
}
|
|
18907
|
-
function getNpmExecOptions(
|
|
19242
|
+
function getNpmExecOptions(platform10 = process.platform) {
|
|
19243
|
+
if (platform10 === "win32") {
|
|
19244
|
+
return { shell: false, windowsHide: true };
|
|
19245
|
+
}
|
|
18908
19246
|
return { shell: false };
|
|
18909
19247
|
}
|
|
19248
|
+
function execNpmCommandSync(args, options = {}, surface) {
|
|
19249
|
+
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
19250
|
+
return execFileSync2(
|
|
19251
|
+
surface?.npmExecutable || "npm",
|
|
19252
|
+
[...surface?.npmArgsPrefix || [], ...args],
|
|
19253
|
+
{
|
|
19254
|
+
...options,
|
|
19255
|
+
...execOptions,
|
|
19256
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
19257
|
+
}
|
|
19258
|
+
);
|
|
19259
|
+
}
|
|
18910
19260
|
function killPid(pid) {
|
|
18911
19261
|
try {
|
|
18912
19262
|
if (process.platform === "win32") {
|
|
18913
|
-
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
19263
|
+
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
18914
19264
|
} else {
|
|
18915
19265
|
process.kill(pid, "SIGTERM");
|
|
18916
19266
|
}
|
|
@@ -18929,7 +19279,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18929
19279
|
"Bypass",
|
|
18930
19280
|
"-Command",
|
|
18931
19281
|
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
18932
|
-
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19282
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18933
19283
|
if (psOut) return psOut;
|
|
18934
19284
|
} catch {
|
|
18935
19285
|
}
|
|
@@ -18940,7 +19290,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18940
19290
|
pidFilter,
|
|
18941
19291
|
"get",
|
|
18942
19292
|
"CommandLine"
|
|
18943
|
-
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19293
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18944
19294
|
if (wmicOut) return wmicOut;
|
|
18945
19295
|
} catch {
|
|
18946
19296
|
}
|
|
@@ -19001,9 +19351,9 @@ function removeDaemonPidFile() {
|
|
|
19001
19351
|
}
|
|
19002
19352
|
function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
19003
19353
|
const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
|
|
19004
|
-
const npmRoot =
|
|
19354
|
+
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19005
19355
|
if (!npmRoot) return;
|
|
19006
|
-
const npmPrefix = surface.installPrefix ||
|
|
19356
|
+
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19007
19357
|
const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
|
|
19008
19358
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
19009
19359
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
@@ -19494,6 +19844,8 @@ var DaemonCommandRouter = class {
|
|
|
19494
19844
|
const wantsAll = args?.all === true;
|
|
19495
19845
|
const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
|
|
19496
19846
|
const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
|
|
19847
|
+
const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
19848
|
+
const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
|
|
19497
19849
|
const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
|
|
19498
19850
|
const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
|
|
19499
19851
|
canonicalHistory: providerMeta?.canonicalHistory,
|
|
@@ -19513,6 +19865,7 @@ var DaemonCommandRouter = class {
|
|
|
19513
19865
|
sessions: historySessions.map((session) => {
|
|
19514
19866
|
const saved = savedSessionById.get(session.historySessionId);
|
|
19515
19867
|
const recent = recentSessionById.get(session.historySessionId);
|
|
19868
|
+
const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
|
|
19516
19869
|
return {
|
|
19517
19870
|
id: session.historySessionId,
|
|
19518
19871
|
providerSessionId: session.historySessionId,
|
|
@@ -19520,13 +19873,13 @@ var DaemonCommandRouter = class {
|
|
|
19520
19873
|
providerName: saved?.providerName || recent?.providerName || providerType,
|
|
19521
19874
|
kind: saved?.kind || recent?.kind || kind,
|
|
19522
19875
|
title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
|
|
19523
|
-
workspace
|
|
19876
|
+
workspace,
|
|
19524
19877
|
summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
|
|
19525
19878
|
preview: session.preview,
|
|
19526
19879
|
messageCount: session.messageCount,
|
|
19527
19880
|
firstMessageAt: session.firstMessageAt,
|
|
19528
19881
|
lastMessageAt: session.lastMessageAt,
|
|
19529
|
-
canResume: !!
|
|
19882
|
+
canResume: !!workspace && canResumeById,
|
|
19530
19883
|
historySource: session.source,
|
|
19531
19884
|
sourcePath: session.sourcePath,
|
|
19532
19885
|
sourceMtimeMs: session.sourceMtimeMs
|
|
@@ -19788,18 +20141,18 @@ var DaemonCommandRouter = class {
|
|
|
19788
20141
|
case "daemon_upgrade": {
|
|
19789
20142
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
19790
20143
|
try {
|
|
19791
|
-
const { execSync: execSync7 } = await import("child_process");
|
|
19792
20144
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
19793
20145
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
19794
|
-
const
|
|
20146
|
+
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
20147
|
+
const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
19795
20148
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
19796
20149
|
let currentInstalled = null;
|
|
19797
20150
|
try {
|
|
19798
|
-
const currentJson =
|
|
20151
|
+
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
19799
20152
|
encoding: "utf-8",
|
|
19800
20153
|
timeout: 1e4,
|
|
19801
20154
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19802
|
-
}).trim();
|
|
20155
|
+
}, npmSurface)).trim();
|
|
19803
20156
|
const parsed = JSON.parse(currentJson);
|
|
19804
20157
|
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
19805
20158
|
} catch {
|
|
@@ -27883,6 +28236,7 @@ export {
|
|
|
27883
28236
|
detectCLIs,
|
|
27884
28237
|
detectIDEs,
|
|
27885
28238
|
ensureSessionHostReady,
|
|
28239
|
+
execNpmCommandSync,
|
|
27886
28240
|
findCdpManager,
|
|
27887
28241
|
flattenMessageParts,
|
|
27888
28242
|
forwardAgentStreamsToIdeInstance,
|
|
@@ -27893,6 +28247,7 @@ export {
|
|
|
27893
28247
|
getDebugRuntimeConfig,
|
|
27894
28248
|
getHostMemorySnapshot,
|
|
27895
28249
|
getLogLevel,
|
|
28250
|
+
getNpmExecOptions,
|
|
27896
28251
|
getRecentActivity,
|
|
27897
28252
|
getRecentCommands,
|
|
27898
28253
|
getRecentDebugTrace,
|