@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
|
@@ -37,6 +37,7 @@ export interface CliAdapter {
|
|
|
37
37
|
sendMessage(text: string): Promise<void>;
|
|
38
38
|
getStatus(): CliAdapterStatus;
|
|
39
39
|
getScriptParsedStatus?(): unknown;
|
|
40
|
+
getDebugSnapshot?(): unknown;
|
|
40
41
|
invokeScript?(scriptName: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
41
42
|
getPartialResponse(): string;
|
|
42
43
|
saveAndStop?(): Promise<void>;
|
|
@@ -211,6 +211,7 @@ export declare class ProviderCliAdapter implements CliAdapter {
|
|
|
211
211
|
private waitForEchoAndSubmit;
|
|
212
212
|
sendMessage(text: string): Promise<void>;
|
|
213
213
|
getPartialResponse(): string;
|
|
214
|
+
getDebugSnapshot(): Record<string, unknown>;
|
|
214
215
|
getRuntimeMetadata(): PtyRuntimeMetadata | null;
|
|
215
216
|
updateRuntimeMeta(meta: Record<string, unknown>, replace?: boolean): void;
|
|
216
217
|
cancel(): void;
|
|
@@ -6,6 +6,14 @@ import type { CommandResult, CommandHelpers } from './handler.js';
|
|
|
6
6
|
import type { ChatMessage } from '../types.js';
|
|
7
7
|
export declare const READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25000;
|
|
8
8
|
export declare function collapseReplayDuplicatesFromReadChat(messages: ChatMessage[]): ChatMessage[];
|
|
9
|
+
interface DebugSanitizeOptions {
|
|
10
|
+
maxDepth?: number;
|
|
11
|
+
maxArrayLength?: number;
|
|
12
|
+
maxObjectKeys?: number;
|
|
13
|
+
maxStringLength?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function sanitizeDebugBundleValue(value: unknown, options?: DebugSanitizeOptions, depth?: number, keyHint?: string): unknown;
|
|
16
|
+
export declare function handleGetChatDebugBundle(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
9
17
|
export declare function handleChatHistory(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
10
18
|
export declare function handleReadChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
11
19
|
export declare function handleSendChat(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
@@ -16,3 +24,4 @@ export declare function handleSetMode(h: CommandHelpers, args: any): Promise<Com
|
|
|
16
24
|
export declare function handleChangeModel(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
17
25
|
export declare function handleSetThoughtLevel(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
18
26
|
export declare function handleResolveAction(h: CommandHelpers, args: any): Promise<CommandResult>;
|
|
27
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ExecFileSyncOptions } from 'child_process';
|
|
1
2
|
export interface DaemonUpgradeHelperPayload {
|
|
2
3
|
packageName: string;
|
|
3
4
|
targetVersion: string;
|
|
@@ -11,18 +12,18 @@ export interface CurrentGlobalInstallSurface {
|
|
|
11
12
|
npmArgsPrefix?: string[];
|
|
12
13
|
packageRoot: string | null;
|
|
13
14
|
installPrefix: string | null;
|
|
14
|
-
execOptions?:
|
|
15
|
-
shell: boolean;
|
|
16
|
-
};
|
|
15
|
+
execOptions?: NpmExecOptions;
|
|
17
16
|
}
|
|
18
17
|
export interface PinnedGlobalInstallCommand {
|
|
19
18
|
command: string;
|
|
20
19
|
args: string[];
|
|
21
20
|
surface: CurrentGlobalInstallSurface;
|
|
22
|
-
execOptions:
|
|
23
|
-
shell: boolean;
|
|
24
|
-
};
|
|
21
|
+
execOptions: NpmExecOptions;
|
|
25
22
|
}
|
|
23
|
+
export type NpmExecOptions = {
|
|
24
|
+
shell: boolean;
|
|
25
|
+
windowsHide?: boolean;
|
|
26
|
+
};
|
|
26
27
|
export declare function resolveCurrentGlobalInstallSurface(options: {
|
|
27
28
|
packageName: string;
|
|
28
29
|
currentCliPath?: string;
|
|
@@ -36,6 +37,8 @@ export declare function buildPinnedGlobalInstallCommand(options: {
|
|
|
36
37
|
nodeExecutable?: string;
|
|
37
38
|
platform?: NodeJS.Platform;
|
|
38
39
|
}): PinnedGlobalInstallCommand;
|
|
40
|
+
export declare function getNpmExecOptions(platform?: NodeJS.Platform): NpmExecOptions;
|
|
41
|
+
export declare function execNpmCommandSync(args: string[], options?: ExecFileSyncOptions, surface?: Pick<CurrentGlobalInstallSurface, 'npmExecutable' | 'npmArgsPrefix' | 'execOptions'>): Buffer | string;
|
|
39
42
|
export declare function stopSessionHostProcesses(appName: string): void;
|
|
40
43
|
export declare function spawnDetachedDaemonUpgradeHelper(payload: DaemonUpgradeHelperPayload): void;
|
|
41
44
|
export declare function maybeRunDaemonUpgradeHelperFromEnv(): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export { DaemonCommandHandler } from './commands/handler.js';
|
|
|
42
42
|
export type { CommandResult, CommandContext } from './commands/handler.js';
|
|
43
43
|
export { DaemonCommandRouter } from './commands/router.js';
|
|
44
44
|
export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
|
|
45
|
-
export { maybeRunDaemonUpgradeHelperFromEnv, spawnDetachedDaemonUpgradeHelper, resolveCurrentGlobalInstallSurface, buildPinnedGlobalInstallCommand, } from './commands/upgrade-helper.js';
|
|
46
|
-
export type { DaemonUpgradeHelperPayload, CurrentGlobalInstallSurface, PinnedGlobalInstallCommand, } from './commands/upgrade-helper.js';
|
|
45
|
+
export { maybeRunDaemonUpgradeHelperFromEnv, spawnDetachedDaemonUpgradeHelper, resolveCurrentGlobalInstallSurface, buildPinnedGlobalInstallCommand, execNpmCommandSync, getNpmExecOptions, } from './commands/upgrade-helper.js';
|
|
46
|
+
export type { DaemonUpgradeHelperPayload, CurrentGlobalInstallSurface, PinnedGlobalInstallCommand, NpmExecOptions, } from './commands/upgrade-helper.js';
|
|
47
47
|
export { DaemonStatusReporter } from './status/reporter.js';
|
|
48
48
|
export { buildSessionEntries, findCdpManager, hasCdpManager, isCdpConnected } from './status/builders.js';
|
|
49
49
|
export { buildStatusSnapshot, buildMachineInfo } from './status/snapshot.js';
|
package/dist/index.js
CHANGED
|
@@ -1472,7 +1472,12 @@ function findBinary(name) {
|
|
|
1472
1472
|
const isWin = os8.platform() === "win32";
|
|
1473
1473
|
try {
|
|
1474
1474
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
1475
|
-
return (0, import_child_process4.execSync)(cmd, {
|
|
1475
|
+
return (0, import_child_process4.execSync)(cmd, {
|
|
1476
|
+
encoding: "utf-8",
|
|
1477
|
+
timeout: 5e3,
|
|
1478
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1479
|
+
...isWin ? { windowsHide: true } : {}
|
|
1480
|
+
}).trim().split("\n")[0].trim();
|
|
1476
1481
|
} catch {
|
|
1477
1482
|
return isWin ? `${trimmed}.cmd` : trimmed;
|
|
1478
1483
|
}
|
|
@@ -4157,6 +4162,83 @@ var init_provider_cli_adapter = __esm({
|
|
|
4157
4162
|
if (!this.isWaitingForResponse) return "";
|
|
4158
4163
|
return this.responseBuffer;
|
|
4159
4164
|
}
|
|
4165
|
+
getDebugSnapshot() {
|
|
4166
|
+
const screenText = this.readTerminalScreenText();
|
|
4167
|
+
const parsedResult = this.parsedStatusCache?.result && typeof this.parsedStatusCache.result === "object" ? this.parsedStatusCache.result : null;
|
|
4168
|
+
return {
|
|
4169
|
+
cliType: this.cliType,
|
|
4170
|
+
cliName: this.cliName,
|
|
4171
|
+
workingDir: this.workingDir,
|
|
4172
|
+
currentStatus: this.currentStatus,
|
|
4173
|
+
ready: this.ready,
|
|
4174
|
+
isWaitingForResponse: this.isWaitingForResponse,
|
|
4175
|
+
activeModal: this.activeModal,
|
|
4176
|
+
parseErrorMessage: this.parseErrorMessage,
|
|
4177
|
+
messageCounts: {
|
|
4178
|
+
committed: this.committedMessages.length,
|
|
4179
|
+
structured: this.structuredMessages.length,
|
|
4180
|
+
visible: this.messages.length,
|
|
4181
|
+
parsedCache: Array.isArray(parsedResult?.messages) ? parsedResult.messages.length : void 0
|
|
4182
|
+
},
|
|
4183
|
+
buffers: {
|
|
4184
|
+
accumulatedLength: this.accumulatedBuffer.length,
|
|
4185
|
+
accumulatedRawLength: this.accumulatedRawBuffer.length,
|
|
4186
|
+
recentOutputLength: this.recentOutputBuffer.length,
|
|
4187
|
+
responseLength: this.responseBuffer.length,
|
|
4188
|
+
startupLength: this.startupBuffer.length,
|
|
4189
|
+
accumulatedTail: this.accumulatedBuffer.slice(-24e3),
|
|
4190
|
+
accumulatedRawTail: this.accumulatedRawBuffer.slice(-24e3),
|
|
4191
|
+
recentOutputTail: this.recentOutputBuffer.slice(-12e3),
|
|
4192
|
+
responseTail: this.responseBuffer.slice(-12e3)
|
|
4193
|
+
},
|
|
4194
|
+
terminal: {
|
|
4195
|
+
screenText,
|
|
4196
|
+
lastScreenSnapshot: this.lastScreenSnapshot,
|
|
4197
|
+
lastScreenText: this.lastScreenText,
|
|
4198
|
+
lastOutputAt: this.lastOutputAt,
|
|
4199
|
+
lastNonEmptyOutputAt: this.lastNonEmptyOutputAt,
|
|
4200
|
+
lastScreenChangeAt: this.lastScreenChangeAt,
|
|
4201
|
+
lastScreenSnapshotReadAt: this.lastScreenSnapshotReadAt
|
|
4202
|
+
},
|
|
4203
|
+
parser: {
|
|
4204
|
+
scriptNames: listCliScriptNames(this.cliScripts),
|
|
4205
|
+
traceSessionId: this.traceSessionId,
|
|
4206
|
+
traceSeq: this.traceSeq,
|
|
4207
|
+
currentTurnScope: this.currentTurnScope,
|
|
4208
|
+
parsedStatusCache: parsedResult ? {
|
|
4209
|
+
id: parsedResult.id,
|
|
4210
|
+
status: parsedResult.status,
|
|
4211
|
+
title: parsedResult.title,
|
|
4212
|
+
providerSessionId: parsedResult.providerSessionId,
|
|
4213
|
+
transcriptAuthority: parsedResult.transcriptAuthority,
|
|
4214
|
+
coverage: parsedResult.coverage,
|
|
4215
|
+
messageCount: Array.isArray(parsedResult.messages) ? parsedResult.messages.length : void 0,
|
|
4216
|
+
activeModal: parsedResult.activeModal
|
|
4217
|
+
} : null,
|
|
4218
|
+
pendingScriptStatus: this.pendingScriptStatus,
|
|
4219
|
+
pendingScriptStatusSince: this.pendingScriptStatusSince
|
|
4220
|
+
},
|
|
4221
|
+
runtimeMetadata: this.getRuntimeMetadata(),
|
|
4222
|
+
statusHistory: this.statusHistory.slice(-80),
|
|
4223
|
+
traceEntries: this.traceEntries.slice(-120),
|
|
4224
|
+
timing: {
|
|
4225
|
+
spawnAt: this.spawnAt,
|
|
4226
|
+
startupFirstOutputAt: this.startupFirstOutputAt,
|
|
4227
|
+
submitPendingUntil: this.submitPendingUntil,
|
|
4228
|
+
responseSettleIgnoreUntil: this.responseSettleIgnoreUntil,
|
|
4229
|
+
responseEpoch: this.responseEpoch,
|
|
4230
|
+
resizeSuppressUntil: this.resizeSuppressUntil,
|
|
4231
|
+
lastApprovalResolvedAt: this.lastApprovalResolvedAt,
|
|
4232
|
+
committedMessagesChangedAt: this.committedMessagesChangedAt
|
|
4233
|
+
},
|
|
4234
|
+
finish: {
|
|
4235
|
+
idleFinishCandidate: this.idleFinishCandidate,
|
|
4236
|
+
finishRetryCount: this.finishRetryCount,
|
|
4237
|
+
submitRetryUsed: this.submitRetryUsed,
|
|
4238
|
+
submitRetryPromptSnippet: this.submitRetryPromptSnippet
|
|
4239
|
+
}
|
|
4240
|
+
};
|
|
4241
|
+
}
|
|
4160
4242
|
getRuntimeMetadata() {
|
|
4161
4243
|
if (!this.ptyProcess || typeof this.ptyProcess.getMetadata !== "function") return null;
|
|
4162
4244
|
return this.ptyProcess.getMetadata();
|
|
@@ -4514,6 +4596,7 @@ __export(index_exports, {
|
|
|
4514
4596
|
detectCLIs: () => detectCLIs,
|
|
4515
4597
|
detectIDEs: () => detectIDEs,
|
|
4516
4598
|
ensureSessionHostReady: () => ensureSessionHostReady,
|
|
4599
|
+
execNpmCommandSync: () => execNpmCommandSync,
|
|
4517
4600
|
findCdpManager: () => findCdpManager,
|
|
4518
4601
|
flattenMessageParts: () => flattenMessageParts,
|
|
4519
4602
|
forwardAgentStreamsToIdeInstance: () => forwardAgentStreamsToIdeInstance,
|
|
@@ -4524,6 +4607,7 @@ __export(index_exports, {
|
|
|
4524
4607
|
getDebugRuntimeConfig: () => getDebugRuntimeConfig,
|
|
4525
4608
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
4526
4609
|
getLogLevel: () => getLogLevel,
|
|
4610
|
+
getNpmExecOptions: () => getNpmExecOptions,
|
|
4527
4611
|
getRecentActivity: () => getRecentActivity,
|
|
4528
4612
|
getRecentCommands: () => getRecentCommands,
|
|
4529
4613
|
getRecentDebugTrace: () => getRecentDebugTrace,
|
|
@@ -5268,7 +5352,11 @@ function resolveCommandPath(command) {
|
|
|
5268
5352
|
}
|
|
5269
5353
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
5270
5354
|
return new Promise((resolve12) => {
|
|
5271
|
-
const child = (0, import_child_process2.exec)(cmd, {
|
|
5355
|
+
const child = (0, import_child_process2.exec)(cmd, {
|
|
5356
|
+
encoding: "utf-8",
|
|
5357
|
+
timeout: timeoutMs,
|
|
5358
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
5359
|
+
}, (err, stdout) => {
|
|
5272
5360
|
if (err || !stdout?.trim()) {
|
|
5273
5361
|
resolve12(null);
|
|
5274
5362
|
} else {
|
|
@@ -10942,6 +11030,245 @@ function buildReadChatCommandResult(payload, args) {
|
|
|
10942
11030
|
...debugReadChat ? { debugReadChat } : {}
|
|
10943
11031
|
};
|
|
10944
11032
|
}
|
|
11033
|
+
var DEFAULT_DEBUG_SANITIZE_OPTIONS = {
|
|
11034
|
+
maxDepth: 8,
|
|
11035
|
+
maxArrayLength: 80,
|
|
11036
|
+
maxObjectKeys: 120,
|
|
11037
|
+
maxStringLength: 16e3
|
|
11038
|
+
};
|
|
11039
|
+
var SECRET_KEY_PATTERN = /(?:token|secret|password|passwd|authorization|cookie|api[_-]?key|access[_-]?key|refresh[_-]?token|client[_-]?secret|private[_-]?key)/i;
|
|
11040
|
+
function truncateDebugString(value, maxLength) {
|
|
11041
|
+
if (value.length <= maxLength) return value;
|
|
11042
|
+
return `${value.slice(0, maxLength)}\u2026[truncated ${value.length - maxLength} chars]`;
|
|
11043
|
+
}
|
|
11044
|
+
function redactDebugSecrets(value) {
|
|
11045
|
+
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]");
|
|
11046
|
+
}
|
|
11047
|
+
function sanitizeDebugBundleValue(value, options = {}, depth = 0, keyHint = "") {
|
|
11048
|
+
const normalizedOptions = { ...DEFAULT_DEBUG_SANITIZE_OPTIONS, ...options };
|
|
11049
|
+
if (value === null || value === void 0) return value;
|
|
11050
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
11051
|
+
if (typeof value === "bigint") return String(value);
|
|
11052
|
+
if (typeof value === "string") {
|
|
11053
|
+
if (SECRET_KEY_PATTERN.test(keyHint) && value.trim()) return "[REDACTED:secret-field]";
|
|
11054
|
+
return truncateDebugString(redactDebugSecrets(value), normalizedOptions.maxStringLength);
|
|
11055
|
+
}
|
|
11056
|
+
if (typeof value === "function") return `[Function ${value.name || "anonymous"}]`;
|
|
11057
|
+
if (typeof value !== "object") return String(value);
|
|
11058
|
+
if (depth >= normalizedOptions.maxDepth) return "[MaxDepth]";
|
|
11059
|
+
if (Array.isArray(value)) {
|
|
11060
|
+
const items = value.slice(0, normalizedOptions.maxArrayLength).map((item) => sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, keyHint));
|
|
11061
|
+
if (value.length > normalizedOptions.maxArrayLength) {
|
|
11062
|
+
items.push(`[truncated ${value.length - normalizedOptions.maxArrayLength} items]`);
|
|
11063
|
+
}
|
|
11064
|
+
return items;
|
|
11065
|
+
}
|
|
11066
|
+
const record = value;
|
|
11067
|
+
const result = {};
|
|
11068
|
+
const entries = Object.entries(record).slice(0, normalizedOptions.maxObjectKeys);
|
|
11069
|
+
for (const [key, item] of entries) {
|
|
11070
|
+
result[key] = sanitizeDebugBundleValue(item, normalizedOptions, depth + 1, key);
|
|
11071
|
+
}
|
|
11072
|
+
const remaining = Object.keys(record).length - entries.length;
|
|
11073
|
+
if (remaining > 0) result.__truncatedKeys = remaining;
|
|
11074
|
+
return result;
|
|
11075
|
+
}
|
|
11076
|
+
function summarizeProviderForDebug(provider) {
|
|
11077
|
+
if (!provider) return null;
|
|
11078
|
+
const scripts = provider.scripts && typeof provider.scripts === "object" ? Object.keys(provider.scripts) : [];
|
|
11079
|
+
const controls = Array.isArray(provider.controls) ? provider.controls.map((control) => ({
|
|
11080
|
+
id: control?.id,
|
|
11081
|
+
label: control?.label,
|
|
11082
|
+
type: control?.type,
|
|
11083
|
+
settingKey: control?.settingKey,
|
|
11084
|
+
invokeScript: control?.invokeScript,
|
|
11085
|
+
listScript: control?.listScript,
|
|
11086
|
+
location: control?.location
|
|
11087
|
+
})) : [];
|
|
11088
|
+
return {
|
|
11089
|
+
type: provider.type,
|
|
11090
|
+
name: provider.name,
|
|
11091
|
+
category: provider.category,
|
|
11092
|
+
version: provider.version,
|
|
11093
|
+
canonicalHistory: provider.canonicalHistory,
|
|
11094
|
+
historyBehavior: provider.historyBehavior,
|
|
11095
|
+
webviewMatchText: provider.webviewMatchText,
|
|
11096
|
+
scriptNames: scripts,
|
|
11097
|
+
controls,
|
|
11098
|
+
resume: provider.resume
|
|
11099
|
+
};
|
|
11100
|
+
}
|
|
11101
|
+
function summarizeSessionForDebug(session) {
|
|
11102
|
+
if (!session || typeof session !== "object") return null;
|
|
11103
|
+
return {
|
|
11104
|
+
sessionId: session.sessionId,
|
|
11105
|
+
instanceKey: session.instanceKey,
|
|
11106
|
+
adapterKey: session.adapterKey,
|
|
11107
|
+
providerType: session.providerType,
|
|
11108
|
+
providerName: session.providerName,
|
|
11109
|
+
transport: session.transport,
|
|
11110
|
+
kind: session.kind,
|
|
11111
|
+
cdpManagerKey: session.cdpManagerKey,
|
|
11112
|
+
parentSessionId: session.parentSessionId,
|
|
11113
|
+
providerSessionId: session.providerSessionId,
|
|
11114
|
+
workspace: session.workspace,
|
|
11115
|
+
title: session.title,
|
|
11116
|
+
status: session.status,
|
|
11117
|
+
mode: session.mode,
|
|
11118
|
+
capabilities: session.capabilities
|
|
11119
|
+
};
|
|
11120
|
+
}
|
|
11121
|
+
function summarizeStateForDebug(state) {
|
|
11122
|
+
if (!state || typeof state !== "object") return null;
|
|
11123
|
+
const activeChat = state.activeChat && typeof state.activeChat === "object" ? state.activeChat : null;
|
|
11124
|
+
return {
|
|
11125
|
+
type: state.type,
|
|
11126
|
+
name: state.name,
|
|
11127
|
+
category: state.category,
|
|
11128
|
+
status: state.status,
|
|
11129
|
+
instanceId: state.instanceId,
|
|
11130
|
+
providerSessionId: state.providerSessionId,
|
|
11131
|
+
title: state.title,
|
|
11132
|
+
transport: state.transport,
|
|
11133
|
+
mode: state.mode,
|
|
11134
|
+
workspace: state.workspace,
|
|
11135
|
+
runtime: state.runtime,
|
|
11136
|
+
errorMessage: state.errorMessage,
|
|
11137
|
+
errorReason: state.errorReason,
|
|
11138
|
+
activeChat: activeChat ? {
|
|
11139
|
+
status: activeChat.status,
|
|
11140
|
+
title: activeChat.title,
|
|
11141
|
+
messageCount: Array.isArray(activeChat.messages) ? activeChat.messages.length : void 0,
|
|
11142
|
+
activeModal: activeChat.activeModal,
|
|
11143
|
+
messagesTail: Array.isArray(activeChat.messages) ? activeChat.messages.slice(-10) : void 0
|
|
11144
|
+
} : null,
|
|
11145
|
+
controlValues: state.controlValues,
|
|
11146
|
+
summaryMetadata: state.summaryMetadata
|
|
11147
|
+
};
|
|
11148
|
+
}
|
|
11149
|
+
function buildDebugBundleText(bundle) {
|
|
11150
|
+
return [
|
|
11151
|
+
"# ADHDev Chat Debug Bundle",
|
|
11152
|
+
"",
|
|
11153
|
+
"```json",
|
|
11154
|
+
JSON.stringify(bundle, null, 2),
|
|
11155
|
+
"```"
|
|
11156
|
+
].join("\n");
|
|
11157
|
+
}
|
|
11158
|
+
async function handleGetChatDebugBundle(h, args) {
|
|
11159
|
+
const provider = h.getProvider(args?.agentType);
|
|
11160
|
+
const transport = getTargetTransport(h, provider);
|
|
11161
|
+
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
11162
|
+
const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
|
|
11163
|
+
const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
|
|
11164
|
+
const targetInstance = getTargetInstance(h, args);
|
|
11165
|
+
let adapterStatus = null;
|
|
11166
|
+
let parsedStatus = null;
|
|
11167
|
+
let adapterDebugSnapshot = null;
|
|
11168
|
+
let partialResponse = "";
|
|
11169
|
+
if (adapter) {
|
|
11170
|
+
try {
|
|
11171
|
+
adapterStatus = adapter.getStatus?.();
|
|
11172
|
+
} catch (error) {
|
|
11173
|
+
adapterStatus = { error: error?.message || String(error) };
|
|
11174
|
+
}
|
|
11175
|
+
try {
|
|
11176
|
+
parsedStatus = typeof adapter.getScriptParsedStatus === "function" ? parseMaybeJson(adapter.getScriptParsedStatus()) : null;
|
|
11177
|
+
} catch (error) {
|
|
11178
|
+
parsedStatus = { error: error?.message || String(error) };
|
|
11179
|
+
}
|
|
11180
|
+
try {
|
|
11181
|
+
adapterDebugSnapshot = typeof adapter.getDebugSnapshot === "function" ? adapter.getDebugSnapshot() : null;
|
|
11182
|
+
} catch (error) {
|
|
11183
|
+
adapterDebugSnapshot = { error: error?.message || String(error) };
|
|
11184
|
+
}
|
|
11185
|
+
try {
|
|
11186
|
+
partialResponse = adapter.getPartialResponse?.() || "";
|
|
11187
|
+
} catch {
|
|
11188
|
+
partialResponse = "";
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
11191
|
+
let instanceState = null;
|
|
11192
|
+
if (targetInstance?.getState) {
|
|
11193
|
+
try {
|
|
11194
|
+
instanceState = summarizeStateForDebug(targetInstance.getState());
|
|
11195
|
+
} catch (error) {
|
|
11196
|
+
instanceState = { error: error?.message || String(error) };
|
|
11197
|
+
}
|
|
11198
|
+
}
|
|
11199
|
+
let readChat = null;
|
|
11200
|
+
try {
|
|
11201
|
+
const readResult = await handleReadChat(h, { ...args, tailLimit: Math.max(1, Math.min(40, Number(args?.tailLimit || 40))) });
|
|
11202
|
+
readChat = readResult.success ? {
|
|
11203
|
+
success: true,
|
|
11204
|
+
status: readResult.status,
|
|
11205
|
+
title: readResult.title,
|
|
11206
|
+
totalMessages: readResult.totalMessages,
|
|
11207
|
+
returnedMessages: Array.isArray(readResult.messages) ? readResult.messages.length : void 0,
|
|
11208
|
+
syncMode: readResult.syncMode,
|
|
11209
|
+
replaceFrom: readResult.replaceFrom,
|
|
11210
|
+
lastMessageSignature: readResult.lastMessageSignature,
|
|
11211
|
+
providerSessionId: readResult.providerSessionId,
|
|
11212
|
+
transcriptAuthority: readResult.transcriptAuthority,
|
|
11213
|
+
coverage: readResult.coverage,
|
|
11214
|
+
activeModal: readResult.activeModal,
|
|
11215
|
+
messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
|
|
11216
|
+
debugReadChat: readResult.debugReadChat
|
|
11217
|
+
} : { success: false, error: readResult.error };
|
|
11218
|
+
} catch (error) {
|
|
11219
|
+
readChat = { success: false, error: error?.message || String(error) };
|
|
11220
|
+
}
|
|
11221
|
+
const cdp = h.getCdp();
|
|
11222
|
+
const rawBundle = {
|
|
11223
|
+
version: 1,
|
|
11224
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11225
|
+
target: {
|
|
11226
|
+
targetSessionId,
|
|
11227
|
+
providerType,
|
|
11228
|
+
transport,
|
|
11229
|
+
routeManagerKey: h.currentManagerKey,
|
|
11230
|
+
currentIdeType: h.currentIdeType
|
|
11231
|
+
},
|
|
11232
|
+
session: summarizeSessionForDebug(h.currentSession),
|
|
11233
|
+
provider: summarizeProviderForDebug(provider),
|
|
11234
|
+
daemon: {
|
|
11235
|
+
pid: process.pid,
|
|
11236
|
+
platform: process.platform,
|
|
11237
|
+
nodeVersion: process.version,
|
|
11238
|
+
cwd: process.cwd()
|
|
11239
|
+
},
|
|
11240
|
+
cdp: {
|
|
11241
|
+
requested: !!cdp,
|
|
11242
|
+
connected: !!cdp?.isConnected,
|
|
11243
|
+
managerKey: getCurrentManagerKey(h)
|
|
11244
|
+
},
|
|
11245
|
+
instanceState,
|
|
11246
|
+
cli: adapter ? {
|
|
11247
|
+
cliType: adapter.cliType,
|
|
11248
|
+
cliName: adapter.cliName,
|
|
11249
|
+
workingDir: adapter.workingDir,
|
|
11250
|
+
status: adapterStatus?.status,
|
|
11251
|
+
activeModal: adapterStatus?.activeModal,
|
|
11252
|
+
messageCount: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.length : void 0,
|
|
11253
|
+
messagesTail: Array.isArray(adapterStatus?.messages) ? adapterStatus.messages.slice(-20) : void 0,
|
|
11254
|
+
parsedStatus,
|
|
11255
|
+
partialResponse,
|
|
11256
|
+
ready: typeof adapter.isReady === "function" ? adapter.isReady() : void 0,
|
|
11257
|
+
processing: typeof adapter.isProcessing === "function" ? adapter.isProcessing() : void 0,
|
|
11258
|
+
debugSnapshot: adapterDebugSnapshot
|
|
11259
|
+
} : null,
|
|
11260
|
+
readChat,
|
|
11261
|
+
frontend: args?.frontendSnapshot && typeof args.frontendSnapshot === "object" ? args.frontendSnapshot : null,
|
|
11262
|
+
recentLogs: getRecentLogs(80, "debug"),
|
|
11263
|
+
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
11264
|
+
};
|
|
11265
|
+
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
11266
|
+
return {
|
|
11267
|
+
success: true,
|
|
11268
|
+
bundle,
|
|
11269
|
+
text: buildDebugBundleText(bundle)
|
|
11270
|
+
};
|
|
11271
|
+
}
|
|
10945
11272
|
function didProviderConfirmSend(result) {
|
|
10946
11273
|
const parsed = parseMaybeJson(result);
|
|
10947
11274
|
if (parsed === true) return true;
|
|
@@ -13138,6 +13465,8 @@ var DaemonCommandHandler = class {
|
|
|
13138
13465
|
// ─── Chat commands (chat-commands.ts) ───────────────
|
|
13139
13466
|
case "read_chat":
|
|
13140
13467
|
return handleReadChat(this, args);
|
|
13468
|
+
case "get_chat_debug_bundle":
|
|
13469
|
+
return handleGetChatDebugBundle(this, args);
|
|
13141
13470
|
case "chat_history":
|
|
13142
13471
|
return handleChatHistory(this, args);
|
|
13143
13472
|
case "send_chat":
|
|
@@ -14818,7 +15147,8 @@ var AcpProviderInstance = class {
|
|
|
14818
15147
|
cwd: this.workingDir,
|
|
14819
15148
|
env,
|
|
14820
15149
|
stdio: ["pipe", "pipe", "pipe"],
|
|
14821
|
-
shell: spawnConfig.shell || false
|
|
15150
|
+
shell: spawnConfig.shell || false,
|
|
15151
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
14822
15152
|
});
|
|
14823
15153
|
const AUTH_ERROR_PATTERNS = [
|
|
14824
15154
|
/unauthorized|unauthenticated/i,
|
|
@@ -15514,7 +15844,10 @@ function commandExists(command) {
|
|
|
15514
15844
|
return (0, import_fs5.existsSync)(expandExecutable(trimmed));
|
|
15515
15845
|
}
|
|
15516
15846
|
try {
|
|
15517
|
-
(0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15847
|
+
(0, import_child_process6.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
15848
|
+
stdio: "ignore",
|
|
15849
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
15850
|
+
});
|
|
15518
15851
|
return true;
|
|
15519
15852
|
} catch {
|
|
15520
15853
|
return false;
|
|
@@ -18447,7 +18780,7 @@ async function launchMacOS(ide, port, workspace, newWindow) {
|
|
|
18447
18780
|
const canUseAppLauncher = !!appName;
|
|
18448
18781
|
const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
|
|
18449
18782
|
if (!useAppLauncher && ide.cliCommand) {
|
|
18450
|
-
(0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore" }).unref();
|
|
18783
|
+
(0, import_child_process7.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18451
18784
|
} else if (appName) {
|
|
18452
18785
|
const openArgs = ["-a", appName, "--args", ...args];
|
|
18453
18786
|
(0, import_child_process7.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
|
|
@@ -18476,7 +18809,7 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
18476
18809
|
const args = ["--remote-debugging-port=" + port];
|
|
18477
18810
|
if (newWindow) args.push("--new-window");
|
|
18478
18811
|
if (workspace) args.push(workspace);
|
|
18479
|
-
(0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore" }).unref();
|
|
18812
|
+
(0, import_child_process7.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
18480
18813
|
}
|
|
18481
18814
|
function getAvailableIdeIds() {
|
|
18482
18815
|
return getProviderLoader().getAvailableIdeTypes();
|
|
@@ -18965,23 +19298,23 @@ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platfo
|
|
|
18965
19298
|
if (platform10 === "win32") {
|
|
18966
19299
|
const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
18967
19300
|
if (fs8.existsSync(npmCliPath)) {
|
|
18968
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19301
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18969
19302
|
}
|
|
18970
19303
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
18971
19304
|
const candidatePath = path16.join(binDir, candidate);
|
|
18972
19305
|
if (fs8.existsSync(candidatePath)) {
|
|
18973
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19306
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18974
19307
|
}
|
|
18975
19308
|
}
|
|
18976
|
-
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions:
|
|
19309
|
+
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform10) };
|
|
18977
19310
|
}
|
|
18978
19311
|
for (const candidate of ["npm"]) {
|
|
18979
19312
|
const candidatePath = path16.join(binDir, candidate);
|
|
18980
19313
|
if (fs8.existsSync(candidatePath)) {
|
|
18981
|
-
return { executable: candidatePath, argsPrefix: [], execOptions:
|
|
19314
|
+
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18982
19315
|
}
|
|
18983
19316
|
}
|
|
18984
|
-
return { executable: "npm", argsPrefix: [], execOptions:
|
|
19317
|
+
return { executable: "npm", argsPrefix: [], execOptions: getNpmExecOptions(platform10) };
|
|
18985
19318
|
}
|
|
18986
19319
|
function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
18987
19320
|
if (!currentCliPath) return null;
|
|
@@ -19052,13 +19385,28 @@ function buildPinnedGlobalInstallCommand(options) {
|
|
|
19052
19385
|
execOptions: surface.execOptions || getNpmExecOptions(options.platform)
|
|
19053
19386
|
};
|
|
19054
19387
|
}
|
|
19055
|
-
function getNpmExecOptions(
|
|
19388
|
+
function getNpmExecOptions(platform10 = process.platform) {
|
|
19389
|
+
if (platform10 === "win32") {
|
|
19390
|
+
return { shell: false, windowsHide: true };
|
|
19391
|
+
}
|
|
19056
19392
|
return { shell: false };
|
|
19057
19393
|
}
|
|
19394
|
+
function execNpmCommandSync(args, options = {}, surface) {
|
|
19395
|
+
const execOptions = surface?.execOptions || getNpmExecOptions();
|
|
19396
|
+
return (0, import_child_process8.execFileSync)(
|
|
19397
|
+
surface?.npmExecutable || "npm",
|
|
19398
|
+
[...surface?.npmArgsPrefix || [], ...args],
|
|
19399
|
+
{
|
|
19400
|
+
...options,
|
|
19401
|
+
...execOptions,
|
|
19402
|
+
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
19403
|
+
}
|
|
19404
|
+
);
|
|
19405
|
+
}
|
|
19058
19406
|
function killPid(pid) {
|
|
19059
19407
|
try {
|
|
19060
19408
|
if (process.platform === "win32") {
|
|
19061
|
-
(0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
|
|
19409
|
+
(0, import_child_process8.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
19062
19410
|
} else {
|
|
19063
19411
|
process.kill(pid, "SIGTERM");
|
|
19064
19412
|
}
|
|
@@ -19077,7 +19425,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
19077
19425
|
"Bypass",
|
|
19078
19426
|
"-Command",
|
|
19079
19427
|
`(Get-CimInstance Win32_Process -Filter "${pidFilter}").CommandLine`
|
|
19080
|
-
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19428
|
+
], { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
19081
19429
|
if (psOut) return psOut;
|
|
19082
19430
|
} catch {
|
|
19083
19431
|
}
|
|
@@ -19088,7 +19436,7 @@ function getWindowsProcessCommandLine(pid) {
|
|
|
19088
19436
|
pidFilter,
|
|
19089
19437
|
"get",
|
|
19090
19438
|
"CommandLine"
|
|
19091
|
-
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
19439
|
+
], { encoding: "utf8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }).trim();
|
|
19092
19440
|
if (wmicOut) return wmicOut;
|
|
19093
19441
|
} catch {
|
|
19094
19442
|
}
|
|
@@ -19149,9 +19497,9 @@ function removeDaemonPidFile() {
|
|
|
19149
19497
|
}
|
|
19150
19498
|
function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
19151
19499
|
const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
|
|
19152
|
-
const npmRoot = (
|
|
19500
|
+
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19153
19501
|
if (!npmRoot) return;
|
|
19154
|
-
const npmPrefix = surface.installPrefix || (
|
|
19502
|
+
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
19155
19503
|
const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
|
|
19156
19504
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
19157
19505
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
@@ -19936,18 +20284,18 @@ var DaemonCommandRouter = class {
|
|
|
19936
20284
|
case "daemon_upgrade": {
|
|
19937
20285
|
LOG.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
19938
20286
|
try {
|
|
19939
|
-
const { execSync: execSync7 } = await import("child_process");
|
|
19940
20287
|
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
19941
20288
|
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
19942
|
-
const
|
|
20289
|
+
const npmSurface = resolveCurrentGlobalInstallSurface({ packageName: pkgName });
|
|
20290
|
+
const latest = String(execNpmCommandSync(["view", pkgName, "version"], { encoding: "utf-8", timeout: 1e4 }, npmSurface)).trim();
|
|
19943
20291
|
LOG.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
19944
20292
|
let currentInstalled = null;
|
|
19945
20293
|
try {
|
|
19946
|
-
const currentJson =
|
|
20294
|
+
const currentJson = String(execNpmCommandSync(["ls", "-g", pkgName, "--depth=0", "--json"], {
|
|
19947
20295
|
encoding: "utf-8",
|
|
19948
20296
|
timeout: 1e4,
|
|
19949
20297
|
stdio: ["pipe", "pipe", "pipe"]
|
|
19950
|
-
}).trim();
|
|
20298
|
+
}, npmSurface)).trim();
|
|
19951
20299
|
const parsed = JSON.parse(currentJson);
|
|
19952
20300
|
currentInstalled = parsed?.dependencies?.[pkgName]?.version || null;
|
|
19953
20301
|
} catch {
|
|
@@ -28027,6 +28375,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
28027
28375
|
detectCLIs,
|
|
28028
28376
|
detectIDEs,
|
|
28029
28377
|
ensureSessionHostReady,
|
|
28378
|
+
execNpmCommandSync,
|
|
28030
28379
|
findCdpManager,
|
|
28031
28380
|
flattenMessageParts,
|
|
28032
28381
|
forwardAgentStreamsToIdeInstance,
|
|
@@ -28037,6 +28386,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
28037
28386
|
getDebugRuntimeConfig,
|
|
28038
28387
|
getHostMemorySnapshot,
|
|
28039
28388
|
getLogLevel,
|
|
28389
|
+
getNpmExecOptions,
|
|
28040
28390
|
getRecentActivity,
|
|
28041
28391
|
getRecentCommands,
|
|
28042
28392
|
getRecentDebugTrace,
|