adhdev 0.8.73 → 0.8.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +244 -127
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +244 -127
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3342,19 +3342,91 @@ function sanitizeHistoryMessage(agentType, message) {
|
|
|
3342
3342
|
content
|
|
3343
3343
|
};
|
|
3344
3344
|
}
|
|
3345
|
-
function
|
|
3345
|
+
function sanitizeHistoryFileSegment(value) {
|
|
3346
|
+
return String(value || "").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3347
|
+
}
|
|
3348
|
+
function listHistoryFiles(dir, historySessionId) {
|
|
3349
|
+
const sanitizedSessionId = historySessionId ? sanitizeHistoryFileSegment(historySessionId) : "";
|
|
3350
|
+
return fs3.readdirSync(dir).filter((file2) => {
|
|
3351
|
+
if (!file2.endsWith(".jsonl")) return false;
|
|
3352
|
+
if (sanitizedSessionId) {
|
|
3353
|
+
return file2.startsWith(`${sanitizedSessionId}_`);
|
|
3354
|
+
}
|
|
3355
|
+
return true;
|
|
3356
|
+
}).sort().reverse();
|
|
3357
|
+
}
|
|
3358
|
+
function buildSavedHistoryCacheSignature(dir, files) {
|
|
3359
|
+
return files.map((file2) => {
|
|
3360
|
+
try {
|
|
3361
|
+
const stat4 = fs3.statSync(path7.join(dir, file2));
|
|
3362
|
+
return `${file2}:${stat4.size}:${Math.trunc(stat4.mtimeMs)}`;
|
|
3363
|
+
} catch {
|
|
3364
|
+
return `${file2}:missing`;
|
|
3365
|
+
}
|
|
3366
|
+
}).join("|");
|
|
3367
|
+
}
|
|
3368
|
+
function computeSavedHistorySessionSummaries(agentType, dir, files) {
|
|
3369
|
+
const groupedFiles = /* @__PURE__ */ new Map();
|
|
3370
|
+
const filePattern = /^([A-Za-z0-9_-]+)_\d{4}-\d{2}-\d{2}\.jsonl$/;
|
|
3371
|
+
for (const file2 of files) {
|
|
3372
|
+
const match = file2.match(filePattern);
|
|
3373
|
+
if (!match?.[1]) continue;
|
|
3374
|
+
const historySessionId = match[1];
|
|
3375
|
+
const grouped = groupedFiles.get(historySessionId) || [];
|
|
3376
|
+
grouped.push(file2);
|
|
3377
|
+
groupedFiles.set(historySessionId, grouped);
|
|
3378
|
+
}
|
|
3379
|
+
const summaries = [];
|
|
3380
|
+
for (const [historySessionId, grouped] of groupedFiles.entries()) {
|
|
3381
|
+
let messageCount = 0;
|
|
3382
|
+
let firstMessageAt = 0;
|
|
3383
|
+
let lastMessageAt = 0;
|
|
3384
|
+
let sessionTitle = "";
|
|
3385
|
+
let preview = "";
|
|
3386
|
+
let workspace = "";
|
|
3387
|
+
for (const file2 of grouped.sort()) {
|
|
3388
|
+
const filePath = path7.join(dir, file2);
|
|
3389
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
3390
|
+
const lines = content.split("\n").filter(Boolean);
|
|
3391
|
+
for (const line of lines) {
|
|
3392
|
+
let parsed = null;
|
|
3393
|
+
try {
|
|
3394
|
+
parsed = JSON.parse(line);
|
|
3395
|
+
} catch {
|
|
3396
|
+
parsed = null;
|
|
3397
|
+
}
|
|
3398
|
+
if (!parsed || parsed.historySessionId !== historySessionId) continue;
|
|
3399
|
+
if (parsed.kind === "session_start") {
|
|
3400
|
+
if (!workspace && parsed.workspace) workspace = parsed.workspace;
|
|
3401
|
+
continue;
|
|
3402
|
+
}
|
|
3403
|
+
messageCount += 1;
|
|
3404
|
+
if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
|
|
3405
|
+
if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
|
|
3406
|
+
if (parsed.sessionTitle) sessionTitle = parsed.sessionTitle;
|
|
3407
|
+
if (parsed.role !== "system" && parsed.content.trim()) preview = parsed.content.trim();
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
if (messageCount === 0 || !lastMessageAt) continue;
|
|
3411
|
+
summaries.push({
|
|
3412
|
+
historySessionId,
|
|
3413
|
+
sessionTitle: sessionTitle || void 0,
|
|
3414
|
+
messageCount,
|
|
3415
|
+
firstMessageAt,
|
|
3416
|
+
lastMessageAt,
|
|
3417
|
+
preview: preview || void 0,
|
|
3418
|
+
workspace: workspace || void 0
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
|
|
3422
|
+
return summaries;
|
|
3423
|
+
}
|
|
3424
|
+
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0) {
|
|
3346
3425
|
try {
|
|
3347
3426
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3348
3427
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
3349
3428
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
3350
|
-
const
|
|
3351
|
-
const files = fs3.readdirSync(dir).filter((f) => {
|
|
3352
|
-
if (!f.endsWith(".jsonl")) return false;
|
|
3353
|
-
if (sanitizedInstance) {
|
|
3354
|
-
return f.startsWith(`${sanitizedInstance}_`);
|
|
3355
|
-
}
|
|
3356
|
-
return true;
|
|
3357
|
-
}).sort().reverse();
|
|
3429
|
+
const files = listHistoryFiles(dir, historySessionId);
|
|
3358
3430
|
const allMessages = [];
|
|
3359
3431
|
const seen = /* @__PURE__ */ new Set();
|
|
3360
3432
|
for (const file2 of files) {
|
|
@@ -3385,8 +3457,13 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId) {
|
|
|
3385
3457
|
if (message.role !== "system") lastTurn = message;
|
|
3386
3458
|
}
|
|
3387
3459
|
const collapsed = collapseReplayAssistantTurns(agentType, chronological);
|
|
3388
|
-
const
|
|
3389
|
-
const
|
|
3460
|
+
const boundedLimit = Math.max(1, limit);
|
|
3461
|
+
const boundedOffset = Math.max(0, offset);
|
|
3462
|
+
const boundedExclude = Math.max(0, Math.min(excludeRecentCount, collapsed.length));
|
|
3463
|
+
const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
|
|
3464
|
+
const startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
3465
|
+
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
3466
|
+
const hasMore = startInclusive > 0;
|
|
3390
3467
|
return { messages: sliced, hasMore };
|
|
3391
3468
|
} catch {
|
|
3392
3469
|
return { messages: [], hasMore: false };
|
|
@@ -3396,61 +3473,20 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
3396
3473
|
try {
|
|
3397
3474
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3398
3475
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
3399
|
-
if (!fs3.existsSync(dir))
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
const summaries = [];
|
|
3412
|
-
for (const [historySessionId, files] of groupedFiles.entries()) {
|
|
3413
|
-
let messageCount = 0;
|
|
3414
|
-
let firstMessageAt = 0;
|
|
3415
|
-
let lastMessageAt = 0;
|
|
3416
|
-
let sessionTitle = "";
|
|
3417
|
-
let preview = "";
|
|
3418
|
-
let workspace = "";
|
|
3419
|
-
for (const file2 of files.sort()) {
|
|
3420
|
-
const filePath = path7.join(dir, file2);
|
|
3421
|
-
const content = fs3.readFileSync(filePath, "utf-8");
|
|
3422
|
-
const lines = content.split("\n").filter(Boolean);
|
|
3423
|
-
for (const line of lines) {
|
|
3424
|
-
let parsed = null;
|
|
3425
|
-
try {
|
|
3426
|
-
parsed = JSON.parse(line);
|
|
3427
|
-
} catch {
|
|
3428
|
-
parsed = null;
|
|
3429
|
-
}
|
|
3430
|
-
if (!parsed || parsed.historySessionId !== historySessionId) continue;
|
|
3431
|
-
if (parsed.kind === "session_start") {
|
|
3432
|
-
if (!workspace && parsed.workspace) workspace = parsed.workspace;
|
|
3433
|
-
continue;
|
|
3434
|
-
}
|
|
3435
|
-
messageCount += 1;
|
|
3436
|
-
if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
|
|
3437
|
-
if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
|
|
3438
|
-
if (parsed.sessionTitle) sessionTitle = parsed.sessionTitle;
|
|
3439
|
-
if (parsed.role !== "system" && parsed.content.trim()) preview = parsed.content.trim();
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
if (messageCount === 0 || !lastMessageAt) continue;
|
|
3443
|
-
summaries.push({
|
|
3444
|
-
historySessionId,
|
|
3445
|
-
sessionTitle: sessionTitle || void 0,
|
|
3446
|
-
messageCount,
|
|
3447
|
-
firstMessageAt,
|
|
3448
|
-
lastMessageAt,
|
|
3449
|
-
preview: preview || void 0,
|
|
3450
|
-
workspace: workspace || void 0
|
|
3476
|
+
if (!fs3.existsSync(dir)) {
|
|
3477
|
+
savedHistorySessionCache.delete(sanitized);
|
|
3478
|
+
return { sessions: [], hasMore: false };
|
|
3479
|
+
}
|
|
3480
|
+
const files = listHistoryFiles(dir);
|
|
3481
|
+
const signature = buildSavedHistoryCacheSignature(dir, files);
|
|
3482
|
+
const cached2 = savedHistorySessionCache.get(sanitized);
|
|
3483
|
+
const summaries = cached2?.signature === signature ? cached2.summaries : computeSavedHistorySessionSummaries(agentType, dir, files);
|
|
3484
|
+
if (!cached2 || cached2.signature !== signature) {
|
|
3485
|
+
savedHistorySessionCache.set(sanitized, {
|
|
3486
|
+
signature,
|
|
3487
|
+
summaries
|
|
3451
3488
|
});
|
|
3452
3489
|
}
|
|
3453
|
-
summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
|
|
3454
3490
|
const offset = Math.max(0, options.offset || 0);
|
|
3455
3491
|
const limit = Math.max(1, options.limit || 30);
|
|
3456
3492
|
const sliced = summaries.slice(offset, offset + limit);
|
|
@@ -3462,7 +3498,7 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
3462
3498
|
return { sessions: [], hasMore: false };
|
|
3463
3499
|
}
|
|
3464
3500
|
}
|
|
3465
|
-
var fs3, path7, os5, HISTORY_DIR, RETAIN_DAYS, CODEX_STARTER_PROMPT_RE, ChatHistoryWriter;
|
|
3501
|
+
var fs3, path7, os5, HISTORY_DIR, RETAIN_DAYS, savedHistorySessionCache, CODEX_STARTER_PROMPT_RE, ChatHistoryWriter;
|
|
3466
3502
|
var init_chat_history = __esm({
|
|
3467
3503
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
3468
3504
|
"use strict";
|
|
@@ -3472,6 +3508,7 @@ var init_chat_history = __esm({
|
|
|
3472
3508
|
init_chat_message_normalization();
|
|
3473
3509
|
HISTORY_DIR = path7.join(os5.homedir(), ".adhdev", "history");
|
|
3474
3510
|
RETAIN_DAYS = 30;
|
|
3511
|
+
savedHistorySessionCache = /* @__PURE__ */ new Map();
|
|
3475
3512
|
CODEX_STARTER_PROMPT_RE = /^(?:[›❯]\s*)?(?:Find and fix a bug in @filename|Improve documentation in @filename|Write tests for @filename|Explain this codebase|Summarize recent commits|Implement \{feature\}|Use \/skills(?: to list available skills)?|Run \/review on my current changes)$/i;
|
|
3476
3513
|
ChatHistoryWriter = class {
|
|
3477
3514
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -4434,7 +4471,7 @@ var init_read_chat_contract = __esm({
|
|
|
4434
4471
|
|
|
4435
4472
|
// ../../oss/packages/daemon-core/src/providers/approval-utils.ts
|
|
4436
4473
|
function normalizeApprovalLabel(value) {
|
|
4437
|
-
return String(value || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
4474
|
+
return String(value || "").toLowerCase().replace(/^[\s\[(<{]*\d+(?:\s*[.)\]}>:-]|\s)+/, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
4438
4475
|
}
|
|
4439
4476
|
function getApprovalPositiveHints(provider) {
|
|
4440
4477
|
const customHints = Array.isArray(provider?.approvalPositiveHints) ? provider.approvalPositiveHints.map((hint) => normalizeApprovalLabel(String(hint || ""))).filter(Boolean) : [];
|
|
@@ -4468,19 +4505,19 @@ var init_approval_utils = __esm({
|
|
|
4468
4505
|
"../../oss/packages/daemon-core/src/providers/approval-utils.ts"() {
|
|
4469
4506
|
"use strict";
|
|
4470
4507
|
DEFAULT_APPROVAL_POSITIVE_HINTS = [
|
|
4471
|
-
"
|
|
4508
|
+
"yes",
|
|
4509
|
+
"allow once",
|
|
4472
4510
|
"approve",
|
|
4473
4511
|
"accept",
|
|
4474
|
-
"allow once",
|
|
4475
|
-
"always allow",
|
|
4476
|
-
"allow",
|
|
4477
|
-
"yes",
|
|
4478
|
-
"proceed",
|
|
4479
4512
|
"continue",
|
|
4513
|
+
"run",
|
|
4514
|
+
"proceed",
|
|
4480
4515
|
"confirm",
|
|
4481
4516
|
"save",
|
|
4482
4517
|
"ok",
|
|
4483
|
-
"trust"
|
|
4518
|
+
"trust",
|
|
4519
|
+
"allow",
|
|
4520
|
+
"always allow"
|
|
4484
4521
|
];
|
|
4485
4522
|
}
|
|
4486
4523
|
});
|
|
@@ -6311,6 +6348,41 @@ function normalizeReadChatMessages(payload) {
|
|
|
6311
6348
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
6312
6349
|
return normalizeChatMessages(messages);
|
|
6313
6350
|
}
|
|
6351
|
+
function buildReadChatReplayCollapseSignature(message) {
|
|
6352
|
+
if (!message) return "";
|
|
6353
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
6354
|
+
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
6355
|
+
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
6356
|
+
const content = flattenContent(message.content || "").replace(/\s+/g, " ").trim();
|
|
6357
|
+
return `${role}:${kind}:${senderName}:${content}`;
|
|
6358
|
+
}
|
|
6359
|
+
function shouldCollapseReadChatReplayDuplicate(message) {
|
|
6360
|
+
if (!message) return false;
|
|
6361
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
6362
|
+
if (role !== "assistant" && role !== "system") return false;
|
|
6363
|
+
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
6364
|
+
return kind === "tool" || kind === "terminal" || kind === "thought" || kind === "system";
|
|
6365
|
+
}
|
|
6366
|
+
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
6367
|
+
const collapsed = [];
|
|
6368
|
+
let lastReplayTurnSignature = "";
|
|
6369
|
+
for (const message of messages) {
|
|
6370
|
+
const signature = buildReadChatReplayCollapseSignature(message);
|
|
6371
|
+
const previous = collapsed[collapsed.length - 1];
|
|
6372
|
+
const previousSignature = buildReadChatReplayCollapseSignature(previous);
|
|
6373
|
+
if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
|
|
6374
|
+
if (previousSignature === signature) continue;
|
|
6375
|
+
if (lastReplayTurnSignature === signature) continue;
|
|
6376
|
+
}
|
|
6377
|
+
collapsed.push(message);
|
|
6378
|
+
if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
|
|
6379
|
+
lastReplayTurnSignature = signature;
|
|
6380
|
+
} else if ((message.role || "").toLowerCase() === "user") {
|
|
6381
|
+
lastReplayTurnSignature = "";
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
return collapsed;
|
|
6385
|
+
}
|
|
6314
6386
|
function deriveHistoryDedupKey(message) {
|
|
6315
6387
|
const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
|
|
6316
6388
|
if (unitKey) return `read_chat:${unitKey}`;
|
|
@@ -6386,14 +6458,38 @@ function computeReadChatSync(messages, cursor) {
|
|
|
6386
6458
|
lastMessageSignature
|
|
6387
6459
|
};
|
|
6388
6460
|
}
|
|
6461
|
+
function hasNonEmptyModalButtons(activeModal) {
|
|
6462
|
+
if (!activeModal || typeof activeModal !== "object") return false;
|
|
6463
|
+
const buttons = activeModal.buttons;
|
|
6464
|
+
return Array.isArray(buttons) && buttons.some((button) => typeof button === "string" && button.trim().length > 0);
|
|
6465
|
+
}
|
|
6466
|
+
function normalizeReadChatCommandStatus(status, activeModal) {
|
|
6467
|
+
const raw = typeof status === "string" ? status.trim() : "";
|
|
6468
|
+
if (!raw) {
|
|
6469
|
+
return hasNonEmptyModalButtons(activeModal) ? "waiting_approval" : "idle";
|
|
6470
|
+
}
|
|
6471
|
+
switch (raw) {
|
|
6472
|
+
case "starting":
|
|
6473
|
+
return hasNonEmptyModalButtons(activeModal) ? "waiting_approval" : "generating";
|
|
6474
|
+
case "stopped":
|
|
6475
|
+
case "disconnected":
|
|
6476
|
+
case "not_monitored":
|
|
6477
|
+
return "error";
|
|
6478
|
+
default:
|
|
6479
|
+
return raw;
|
|
6480
|
+
}
|
|
6481
|
+
}
|
|
6389
6482
|
function buildReadChatCommandResult(payload, args) {
|
|
6390
6483
|
let validatedPayload;
|
|
6391
6484
|
try {
|
|
6392
|
-
validatedPayload = validateReadChatResultPayload(
|
|
6485
|
+
validatedPayload = validateReadChatResultPayload({
|
|
6486
|
+
...payload,
|
|
6487
|
+
status: normalizeReadChatCommandStatus(payload?.status, payload?.activeModal)
|
|
6488
|
+
}, "read_chat command result");
|
|
6393
6489
|
} catch (error48) {
|
|
6394
6490
|
return { success: false, error: error48?.message || String(error48) };
|
|
6395
6491
|
}
|
|
6396
|
-
const messages = normalizeReadChatMessages(validatedPayload);
|
|
6492
|
+
const messages = collapseReplayDuplicatesFromReadChat(normalizeReadChatMessages(validatedPayload));
|
|
6397
6493
|
const cursor = normalizeReadChatCursor(args);
|
|
6398
6494
|
if (!cursor.knownMessageCount && !cursor.lastMessageSignature && cursor.tailLimit > 0 && messages.length > cursor.tailLimit) {
|
|
6399
6495
|
const tailMessages = messages.slice(-cursor.tailLimit);
|
|
@@ -6475,7 +6571,15 @@ async function handleChatHistory(h, args) {
|
|
|
6475
6571
|
try {
|
|
6476
6572
|
const provider = h.getProvider(agentType);
|
|
6477
6573
|
const agentStr = provider?.type || agentType || getCurrentProviderType(h);
|
|
6478
|
-
const
|
|
6574
|
+
const transport = getTargetTransport(h, provider);
|
|
6575
|
+
let excludeRecentCount = Math.max(0, Number(args?.excludeRecentCount || 0));
|
|
6576
|
+
if (isCliLikeTransport(transport)) {
|
|
6577
|
+
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
6578
|
+
const status = adapter?.getStatus?.();
|
|
6579
|
+
const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
|
|
6580
|
+
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
6581
|
+
}
|
|
6582
|
+
const result = readChatHistory(agentStr, offset || 0, limit || 30, historySessionId, excludeRecentCount);
|
|
6479
6583
|
return { success: true, ...result, agent: agentStr };
|
|
6480
6584
|
} catch (e) {
|
|
6481
6585
|
return { success: false, error: e.message };
|
|
@@ -7763,13 +7867,6 @@ var init_cli_script_results = __esm({
|
|
|
7763
7867
|
});
|
|
7764
7868
|
|
|
7765
7869
|
// ../../oss/packages/daemon-core/src/commands/stream-commands.ts
|
|
7766
|
-
function getCliPresentationMode(h, targetSessionId) {
|
|
7767
|
-
if (!targetSessionId) return null;
|
|
7768
|
-
const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
|
|
7769
|
-
if (instance?.category !== "cli") return null;
|
|
7770
|
-
const mode = instance.getPresentationMode?.();
|
|
7771
|
-
return mode === "chat" || mode === "terminal" ? mode : null;
|
|
7772
|
-
}
|
|
7773
7870
|
function normalizeOpenPanelCommandResult(result) {
|
|
7774
7871
|
const payload = Object.prototype.hasOwnProperty.call(result, "result") ? result.result : result;
|
|
7775
7872
|
if (payload === true) return { opened: true, visible: true, focused: false };
|
|
@@ -7842,9 +7939,6 @@ async function handleOpenPanel(h, args) {
|
|
|
7842
7939
|
function handlePtyInput(h, args) {
|
|
7843
7940
|
const { cliType, data, targetSessionId } = args || {};
|
|
7844
7941
|
if (!data) return { success: false, error: "data required" };
|
|
7845
|
-
if (getCliPresentationMode(h, targetSessionId) === "chat") {
|
|
7846
|
-
return { success: false, error: "CLI session is in chat mode", code: "CLI_VIEW_MODE_NOT_TERMINAL" };
|
|
7847
|
-
}
|
|
7848
7942
|
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
7849
7943
|
if (!adapter || typeof adapter.writeRaw !== "function") {
|
|
7850
7944
|
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
@@ -7852,24 +7946,10 @@ function handlePtyInput(h, args) {
|
|
|
7852
7946
|
adapter.writeRaw(data);
|
|
7853
7947
|
return { success: true };
|
|
7854
7948
|
}
|
|
7855
|
-
function handlePtyResize(
|
|
7856
|
-
const {
|
|
7949
|
+
function handlePtyResize(_h, args) {
|
|
7950
|
+
const { cols, rows } = args || {};
|
|
7857
7951
|
if (!cols || !rows) return { success: false, error: "cols and rows required" };
|
|
7858
|
-
|
|
7859
|
-
return { success: false, error: "CLI session is in chat mode", code: "CLI_VIEW_MODE_NOT_TERMINAL" };
|
|
7860
|
-
}
|
|
7861
|
-
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
7862
|
-
if (!adapter || typeof adapter.resize !== "function") {
|
|
7863
|
-
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
7864
|
-
}
|
|
7865
|
-
const resize = adapter.resize;
|
|
7866
|
-
if (force) {
|
|
7867
|
-
resize(cols - 1, rows);
|
|
7868
|
-
setTimeout(() => resize(cols, rows), 50);
|
|
7869
|
-
} else {
|
|
7870
|
-
resize(cols, rows);
|
|
7871
|
-
}
|
|
7872
|
-
return { success: true };
|
|
7952
|
+
return { success: false, error: "PTY resize temporarily disabled", code: "PTY_RESIZE_DISABLED" };
|
|
7873
7953
|
}
|
|
7874
7954
|
function handleGetProviderSettings(h, args) {
|
|
7875
7955
|
const loader = h.ctx.providerLoader;
|
|
@@ -7956,15 +8036,45 @@ function normalizeProviderScriptArgs(args, scriptName) {
|
|
|
7956
8036
|
}
|
|
7957
8037
|
function buildControlScriptResult(scriptName, payload) {
|
|
7958
8038
|
if (!payload || typeof payload !== "object") return {};
|
|
7959
|
-
|
|
7960
|
-
|
|
8039
|
+
const legacyListPayload = (() => {
|
|
8040
|
+
if (Array.isArray(payload.options)) return payload;
|
|
8041
|
+
if (/^listmodels$/i.test(scriptName) && Array.isArray(payload.models)) {
|
|
8042
|
+
return {
|
|
8043
|
+
options: payload.models,
|
|
8044
|
+
currentValue: payload.currentValue ?? payload.current ?? payload.currentModel,
|
|
8045
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8046
|
+
};
|
|
8047
|
+
}
|
|
8048
|
+
if (/^listmodes$/i.test(scriptName) && Array.isArray(payload.modes)) {
|
|
8049
|
+
return {
|
|
8050
|
+
options: payload.modes,
|
|
8051
|
+
currentValue: payload.currentValue ?? payload.current ?? payload.currentMode ?? payload.mode,
|
|
8052
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8053
|
+
};
|
|
8054
|
+
}
|
|
8055
|
+
return null;
|
|
8056
|
+
})();
|
|
8057
|
+
if (legacyListPayload) {
|
|
8058
|
+
return { controlResult: normalizeControlListResult(legacyListPayload) };
|
|
7961
8059
|
}
|
|
7962
|
-
const
|
|
8060
|
+
const legacyMutationPayload = (() => {
|
|
8061
|
+
if (typeof payload.ok === "boolean") return payload;
|
|
8062
|
+
if (typeof payload.success === "boolean") {
|
|
8063
|
+
return {
|
|
8064
|
+
ok: payload.success,
|
|
8065
|
+
currentValue: payload.currentValue ?? payload.value ?? payload.model ?? payload.mode ?? payload.selectedModel ?? payload.selectedMode,
|
|
8066
|
+
...Array.isArray(payload.effects) ? { effects: payload.effects } : {},
|
|
8067
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8068
|
+
};
|
|
8069
|
+
}
|
|
8070
|
+
return null;
|
|
8071
|
+
})();
|
|
8072
|
+
const looksLikeValueMutation = /^set|^change/i.test(scriptName) || payload.currentValue !== void 0 || payload.value !== void 0 || payload.success !== void 0;
|
|
7963
8073
|
if (looksLikeValueMutation) {
|
|
7964
|
-
return { controlResult: normalizeControlSetResult(payload) };
|
|
8074
|
+
return { controlResult: normalizeControlSetResult(legacyMutationPayload || payload) };
|
|
7965
8075
|
}
|
|
7966
8076
|
if (payload.ok !== void 0 || Array.isArray(payload.effects) || typeof payload.error === "string") {
|
|
7967
|
-
return { controlResult: normalizeControlInvokeResult(payload) };
|
|
8077
|
+
return { controlResult: normalizeControlInvokeResult(legacyMutationPayload || payload) };
|
|
7968
8078
|
}
|
|
7969
8079
|
return {};
|
|
7970
8080
|
}
|
|
@@ -8039,7 +8149,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
8039
8149
|
}
|
|
8040
8150
|
const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
|
|
8041
8151
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
8042
|
-
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
8152
|
+
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode", "listModels", "setModel", "setModelGui"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
8043
8153
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
8044
8154
|
if (targetSessionId) {
|
|
8045
8155
|
try {
|
|
@@ -11550,6 +11660,8 @@ ${data.message || ""}`.trim();
|
|
|
11550
11660
|
}
|
|
11551
11661
|
async sendMessage(text) {
|
|
11552
11662
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
11663
|
+
const allowInputDuringGeneration = this.provider.allowInputDuringGeneration === true;
|
|
11664
|
+
const allowInterventionPrompt = allowInputDuringGeneration && this.isWaitingForResponse && this.currentStatus !== "waiting_approval";
|
|
11553
11665
|
if (this.startupParseGate) {
|
|
11554
11666
|
const deadline = Date.now() + 1e4;
|
|
11555
11667
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
@@ -11557,7 +11669,9 @@ ${data.message || ""}`.trim();
|
|
|
11557
11669
|
await new Promise((resolve15) => setTimeout(resolve15, 50));
|
|
11558
11670
|
}
|
|
11559
11671
|
}
|
|
11560
|
-
|
|
11672
|
+
if (!allowInterventionPrompt) {
|
|
11673
|
+
await this.waitForInteractivePrompt();
|
|
11674
|
+
}
|
|
11561
11675
|
if (!this.ready) {
|
|
11562
11676
|
this.resolveStartupState("send_precheck");
|
|
11563
11677
|
const screenText = this.terminalScreen.getText() || "";
|
|
@@ -11569,7 +11683,7 @@ ${data.message || ""}`.trim();
|
|
|
11569
11683
|
}
|
|
11570
11684
|
}
|
|
11571
11685
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
11572
|
-
if (this.isWaitingForResponse) {
|
|
11686
|
+
if (this.isWaitingForResponse && !allowInputDuringGeneration) {
|
|
11573
11687
|
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
11574
11688
|
}
|
|
11575
11689
|
const blockingModal = this.activeModal || this.getStartupConfirmationModal(this.terminalScreen.getText() || "");
|
|
@@ -41861,6 +41975,20 @@ var init_dev_server = __esm({
|
|
|
41861
41975
|
async handleReload(_req, res) {
|
|
41862
41976
|
try {
|
|
41863
41977
|
this.providerLoader.reload();
|
|
41978
|
+
let refreshedInstances = 0;
|
|
41979
|
+
if (this.instanceManager) {
|
|
41980
|
+
for (const id of this.instanceManager.listInstanceIds()) {
|
|
41981
|
+
const instance = this.instanceManager.getInstance(id);
|
|
41982
|
+
const providerType = typeof instance?.type === "string" ? instance.type : "";
|
|
41983
|
+
if (!providerType) continue;
|
|
41984
|
+
const resolved = this.providerLoader.resolve(providerType);
|
|
41985
|
+
if (!resolved) continue;
|
|
41986
|
+
if (instance && typeof instance === "object" && "provider" in instance) {
|
|
41987
|
+
instance.provider = resolved;
|
|
41988
|
+
refreshedInstances += 1;
|
|
41989
|
+
}
|
|
41990
|
+
}
|
|
41991
|
+
}
|
|
41864
41992
|
const providers = this.providerLoader.getAll().map((p) => ({
|
|
41865
41993
|
type: p.type,
|
|
41866
41994
|
name: p.name,
|
|
@@ -41871,7 +41999,7 @@ var init_dev_server = __esm({
|
|
|
41871
41999
|
cdp.clearTargetId();
|
|
41872
42000
|
}
|
|
41873
42001
|
}
|
|
41874
|
-
this.json(res, 200, { reloaded: true, providers });
|
|
42002
|
+
this.json(res, 200, { reloaded: true, refreshedInstances, providers });
|
|
41875
42003
|
} catch (e) {
|
|
41876
42004
|
this.json(res, 500, { error: e.message });
|
|
41877
42005
|
}
|
|
@@ -44615,15 +44743,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
|
|
|
44615
44743
|
return;
|
|
44616
44744
|
}
|
|
44617
44745
|
if (parsed.type === "pty_resize") {
|
|
44618
|
-
|
|
44619
|
-
if (permission) {
|
|
44620
|
-
log(`pty_resize: REJECTED \u2014 permission=${permission} peer=${peerId}`);
|
|
44621
|
-
return;
|
|
44622
|
-
}
|
|
44623
|
-
const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
|
|
44624
|
-
if (handlers.ptyResizeHandler && parsed.cols && parsed.rows && sessionId) {
|
|
44625
|
-
handlers.ptyResizeHandler(sessionId, parsed.cols, parsed.rows);
|
|
44626
|
-
}
|
|
44746
|
+
logDebug(`pty_resize ignored: peer=${peerId} reason=temporarily_disabled`);
|
|
44627
44747
|
return;
|
|
44628
44748
|
}
|
|
44629
44749
|
handleFileRequest(peerId, parsed, peers, handlers);
|
|
@@ -53443,7 +53563,7 @@ var init_adhdev_daemon = __esm({
|
|
|
53443
53563
|
init_source2();
|
|
53444
53564
|
init_version();
|
|
53445
53565
|
init_src();
|
|
53446
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
53566
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.75" });
|
|
53447
53567
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
53448
53568
|
localHttpServer = null;
|
|
53449
53569
|
localWss = null;
|
|
@@ -53514,9 +53634,6 @@ var init_adhdev_daemon = __esm({
|
|
|
53514
53634
|
const mode = instance.getPresentationMode?.();
|
|
53515
53635
|
return mode === "chat" || mode === "terminal" ? mode : null;
|
|
53516
53636
|
}
|
|
53517
|
-
isTerminalCliSession(sessionId) {
|
|
53518
|
-
return this.getCliPresentationMode(sessionId) === "terminal";
|
|
53519
|
-
}
|
|
53520
53637
|
isCliSession(sessionId) {
|
|
53521
53638
|
const mode = this.getCliPresentationMode(sessionId);
|
|
53522
53639
|
return mode === "chat" || mode === "terminal";
|
|
@@ -53954,14 +54071,14 @@ ${err?.stack || ""}`);
|
|
|
53954
54071
|
}
|
|
53955
54072
|
});
|
|
53956
54073
|
this.p2p.onPtyInput((sessionId, data) => {
|
|
53957
|
-
if (!this.
|
|
54074
|
+
if (!this.isCliSession(sessionId)) return;
|
|
53958
54075
|
const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
|
|
53959
54076
|
if (found && typeof found.adapter.writeRaw === "function") {
|
|
53960
54077
|
found.adapter.writeRaw(data);
|
|
53961
54078
|
}
|
|
53962
54079
|
});
|
|
53963
54080
|
this.p2p.onPtyResize((sessionId, cols, rows) => {
|
|
53964
|
-
if (!this.
|
|
54081
|
+
if (!this.isCliSession(sessionId)) return;
|
|
53965
54082
|
const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
|
|
53966
54083
|
if (found && typeof found.adapter.resize === "function") {
|
|
53967
54084
|
found.adapter.resize(cols, rows);
|