@adhdev/daemon-core 0.9.47 → 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 +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +405 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -29
- package/dist/index.mjs.map +1 -1
- package/dist/providers/cli-script-results.d.ts +1 -0
- 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/stream-commands.ts +5 -0
- package/src/commands/upgrade-helper.d.ts +26 -0
- package/src/commands/upgrade-helper.ts +63 -19
- 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/src/providers/cli-provider-instance.ts +5 -0
- package/src/providers/cli-script-results.ts +5 -2
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;
|
|
@@ -12180,7 +12505,8 @@ function getCliScriptCommand(payload) {
|
|
|
12180
12505
|
if (command.type !== "send_message" && command.type !== "pty_write") return null;
|
|
12181
12506
|
const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
|
|
12182
12507
|
if (!text) return null;
|
|
12183
|
-
|
|
12508
|
+
const enterCount = Number.isInteger(command.enterCount) && command.enterCount > 0 && command.enterCount <= 5 ? command.enterCount : void 0;
|
|
12509
|
+
return { type: command.type, text, ...enterCount ? { enterCount } : {} };
|
|
12184
12510
|
}
|
|
12185
12511
|
|
|
12186
12512
|
// src/commands/stream-commands.ts
|
|
@@ -12438,7 +12764,12 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
12438
12764
|
if (cliCommand?.type === "send_message" && cliCommand.text) {
|
|
12439
12765
|
await adapter.sendMessage(cliCommand.text);
|
|
12440
12766
|
} else if (cliCommand?.type === "pty_write" && cliCommand.text && adapter.writeRaw) {
|
|
12767
|
+
const enterCount = cliCommand.enterCount || 1;
|
|
12441
12768
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
12769
|
+
for (let i = 1; i < enterCount; i += 1) {
|
|
12770
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
12771
|
+
await adapter.writeRaw("\r");
|
|
12772
|
+
}
|
|
12442
12773
|
}
|
|
12443
12774
|
applyProviderPatch(h, args, parsed.payload);
|
|
12444
12775
|
return {
|
|
@@ -12979,6 +13310,8 @@ var DaemonCommandHandler = class {
|
|
|
12979
13310
|
// ─── Chat commands (chat-commands.ts) ───────────────
|
|
12980
13311
|
case "read_chat":
|
|
12981
13312
|
return handleReadChat(this, args);
|
|
13313
|
+
case "get_chat_debug_bundle":
|
|
13314
|
+
return handleGetChatDebugBundle(this, args);
|
|
12982
13315
|
case "chat_history":
|
|
12983
13316
|
return handleChatHistory(this, args);
|
|
12984
13317
|
case "send_chat":
|
|
@@ -13645,7 +13978,12 @@ var CliProviderInstance = class {
|
|
|
13645
13978
|
if (cliCommand?.type === "send_message" && cliCommand.text) {
|
|
13646
13979
|
await this.adapter.sendMessage(cliCommand.text);
|
|
13647
13980
|
} else if (cliCommand?.type === "pty_write" && cliCommand.text) {
|
|
13981
|
+
const enterCount = cliCommand.enterCount || 1;
|
|
13648
13982
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
13983
|
+
for (let i = 1; i < enterCount; i += 1) {
|
|
13984
|
+
await new Promise((resolve12) => setTimeout(resolve12, 50));
|
|
13985
|
+
await this.adapter.writeRaw("\r");
|
|
13986
|
+
}
|
|
13649
13987
|
}
|
|
13650
13988
|
this.applyProviderResponse(parsed.payload, { phase: "immediate" });
|
|
13651
13989
|
}
|
|
@@ -14659,7 +14997,8 @@ var AcpProviderInstance = class {
|
|
|
14659
14997
|
cwd: this.workingDir,
|
|
14660
14998
|
env,
|
|
14661
14999
|
stdio: ["pipe", "pipe", "pipe"],
|
|
14662
|
-
shell: spawnConfig.shell || false
|
|
15000
|
+
shell: spawnConfig.shell || false,
|
|
15001
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
14663
15002
|
});
|
|
14664
15003
|
const AUTH_ERROR_PATTERNS = [
|
|
14665
15004
|
/unauthorized|unauthenticated/i,
|
|
@@ -15355,7 +15694,10 @@ function commandExists(command) {
|
|
|
15355
15694
|
return existsSync10(expandExecutable(trimmed));
|
|
15356
15695
|
}
|
|
15357
15696
|
try {
|
|
15358
|
-
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
|
+
});
|
|
15359
15701
|
return true;
|
|
15360
15702
|
} catch {
|
|
15361
15703
|
return false;
|
|
@@ -18288,7 +18630,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
18288
18630
|
const canUseAppLauncher = !!appName;
|
|
18289
18631
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
18290
18632
|
if (!useAppLauncher && ide.cliCommand) {
|
|
18291
|
-
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
|
|
18633
|
+
spawn2(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18292
18634
|
} else if (appName) {
|
|
18293
18635
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
18294
18636
|
spawn2("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
@@ -18317,7 +18659,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
18317
18659
|
const args = ["--remote-debugging-port=" + port];
|
|
18318
18660
|
if (newWindow) args.push("--new-window");
|
|
18319
18661
|
if (workspace) args.push(workspace);
|
|
18320
|
-
spawn2(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
18662
|
+
spawn2(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18321
18663
|
}
|
|
18322
18664
|
function getAvailableIdeIds() {
|
|
18323
18665
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -18801,16 +19143,28 @@ function appendUpgradeLog(message) {
|
|
|
18801
19143
|
} catch {
|
|
18802
19144
|
}
|
|
18803
19145
|
}
|
|
18804
|
-
function
|
|
19146
|
+
function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
|
|
18805
19147
|
const binDir = path16.dirname(nodeExecutable);
|
|
18806
|
-
|
|
18807
|
-
|
|
19148
|
+
if (platform10 === "win32") {
|
|
19149
|
+
const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
19150
|
+
if (fs8.existsSync(npmCliPath)) {
|
|
19151
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
19152
|
+
}
|
|
19153
|
+
for (const candidate of ["npm.exe", "npm"]) {
|
|
19154
|
+
const candidatePath = path16.join(binDir, candidate);
|
|
19155
|
+
if (fs8.existsSync(candidatePath)) {
|
|
19156
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
19157
|
+
}
|
|
19158
|
+
}
|
|
19159
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
19160
|
+
}
|
|
19161
|
+
for (const candidate of ["npm"]) {
|
|
18808
19162
|
const candidatePath = path16.join(binDir, candidate);
|
|
18809
19163
|
if (fs8.existsSync(candidatePath)) {
|
|
18810
|
-
return candidatePath;
|
|
19164
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18811
19165
|
}
|
|
18812
19166
|
}
|
|
18813
|
-
return "npm";
|
|
19167
|
+
return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18814
19168
|
}
|
|
18815
19169
|
function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
18816
19170
|
if (!currentCliPath) return null;
|
|
@@ -18859,31 +19213,50 @@ function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
|
18859
19213
|
}
|
|
18860
19214
|
function resolveCurrentGlobalInstallSurface(options) {
|
|
18861
19215
|
const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
|
|
19216
|
+
const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
|
|
18862
19217
|
return {
|
|
18863
|
-
npmExecutable:
|
|
19218
|
+
npmExecutable: npmInvocation.executable,
|
|
19219
|
+
npmArgsPrefix: npmInvocation.argsPrefix,
|
|
18864
19220
|
packageRoot,
|
|
18865
|
-
installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null
|
|
19221
|
+
installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null,
|
|
19222
|
+
execOptions: npmInvocation.execOptions
|
|
18866
19223
|
};
|
|
18867
19224
|
}
|
|
18868
19225
|
function buildPinnedGlobalInstallCommand(options) {
|
|
18869
19226
|
const surface = resolveCurrentGlobalInstallSurface(options);
|
|
18870
|
-
const args = ["install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
|
|
19227
|
+
const args = [...surface.npmArgsPrefix || [], "install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
|
|
18871
19228
|
if (surface.installPrefix) {
|
|
18872
19229
|
args.push("--prefix", surface.installPrefix);
|
|
18873
19230
|
}
|
|
18874
19231
|
return {
|
|
18875
19232
|
command: surface.npmExecutable,
|
|
18876
19233
|
args,
|
|
18877
|
-
surface
|
|
19234
|
+
surface,
|
|
19235
|
+
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
18878
19236
|
};
|
|
18879
19237
|
}
|
|
18880
|
-
function getNpmExecOptions() {
|
|
18881
|
-
|
|
19238
|
+
function getNpmExecOptions(platform10 = process.platform) {
|
|
19239
|
+
if (platform10 === "win32") {
|
|
19240
|
+
return { shell: false, windowsHide: true };
|
|
19241
|
+
}
|
|
19242
|
+
return { shell: false };
|
|
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
|
+
);
|
|
18882
19255
|
}
|
|
18883
19256
|
function killPid(pid) {
|
|
18884
19257
|
try {
|
|
18885
19258
|
if (process.platform === "win32") {
|
|
18886
|
-
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
19259
|
+
execFileSync2("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
18887
19260
|
} else {
|
|
18888
19261
|
process.kill(pid, "SIGTERM");
|
|
18889
19262
|
}
|
|
@@ -18902,7 +19275,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18902
19275
|
"Bypass",
|
|
18903
19276
|
"-Command",
|
|
18904
19277
|
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
18905
|
-
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19278
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18906
19279
|
if (psOut) return psOut;
|
|
18907
19280
|
} catch {
|
|
18908
19281
|
}
|
|
@@ -18913,7 +19286,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
18913
19286
|
pidFilter,
|
|
18914
19287
|
"get",
|
|
18915
19288
|
"CommandLine"
|
|
18916
|
-
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19289
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
18917
19290
|
if (wmicOut) return wmicOut;
|
|
18918
19291
|
} catch {
|
|
18919
19292
|
}
|
|
@@ -18973,11 +19346,10 @@ function removeDaemonPidFile() {
|
|
|
18973
19346
|
}
|
|
18974
19347
|
}
|
|
18975
19348
|
function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
18976
|
-
const npmExecOpts = getNpmExecOptions();
|
|
18977
19349
|
const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
|
|
18978
|
-
const npmRoot =
|
|
19350
|
+
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
18979
19351
|
if (!npmRoot) return;
|
|
18980
|
-
const npmPrefix = surface.installPrefix ||
|
|
19352
|
+
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
18981
19353
|
const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
|
|
18982
19354
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
18983
19355
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
@@ -19047,7 +19419,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
19047
19419
|
encoding: "utf8",
|
|
19048
19420
|
stdio: "pipe",
|
|
19049
19421
|
maxBuffer: 20 * 1024 * 1024,
|
|
19050
|
-
...
|
|
19422
|
+
...installCommand.execOptions
|
|
19051
19423
|
}
|
|
19052
19424
|
);
|
|
19053
19425
|
if (installOutput.trim()) {
|
|
@@ -19762,18 +20134,18 @@ var DaemonCommandRouter = class {
|
|
|
19762
20134
|
case "daemon_upgrade": {
|
|
19763
20135
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
19764
20136
|
try {
|
|
19765
|
-
const { execSync: execSync7 } = await import("child_process");
|
|
19766
20137
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
19767
20138
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
19768
|
-
const
|
|
20139
|
+
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
20140
|
+
const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
19769
20141
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
19770
20142
|
let currentInstalled = null;
|
|
19771
20143
|
try {
|
|
19772
|
-
const currentJson =
|
|
20144
|
+
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
19773
20145
|
encoding: "utf-8",
|
|
19774
20146
|
timeout: 1e4,
|
|
19775
20147
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19776
|
-
}).trim();
|
|
20148
|
+
}, npmSurface)).trim();
|
|
19777
20149
|
const parsed = JSON.parse(currentJson);
|
|
19778
20150
|
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
19779
20151
|
} catch {
|
|
@@ -27857,6 +28229,7 @@ export {
|
|
|
27857
28229
|
detectCLIs,
|
|
27858
28230
|
detectIDEs,
|
|
27859
28231
|
ensureSessionHostReady,
|
|
28232
|
+
execNpmCommandSync,
|
|
27860
28233
|
findCdpManager,
|
|
27861
28234
|
flattenMessageParts,
|
|
27862
28235
|
forwardAgentStreamsToIdeInstance,
|
|
@@ -27867,6 +28240,7 @@ export {
|
|
|
27867
28240
|
getDebugRuntimeConfig,
|
|
27868
28241
|
getHostMemorySnapshot,
|
|
27869
28242
|
getLogLevel,
|
|
28243
|
+
getNpmExecOptions,
|
|
27870
28244
|
getRecentActivity,
|
|
27871
28245
|
getRecentCommands,
|
|
27872
28246
|
getRecentDebugTrace,
|