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/cli/index.js
CHANGED
|
@@ -3862,19 +3862,91 @@ function sanitizeHistoryMessage(agentType, message) {
|
|
|
3862
3862
|
content
|
|
3863
3863
|
};
|
|
3864
3864
|
}
|
|
3865
|
-
function
|
|
3865
|
+
function sanitizeHistoryFileSegment(value) {
|
|
3866
|
+
return String(value || "").replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3867
|
+
}
|
|
3868
|
+
function listHistoryFiles(dir, historySessionId) {
|
|
3869
|
+
const sanitizedSessionId = historySessionId ? sanitizeHistoryFileSegment(historySessionId) : "";
|
|
3870
|
+
return fs3.readdirSync(dir).filter((file2) => {
|
|
3871
|
+
if (!file2.endsWith(".jsonl")) return false;
|
|
3872
|
+
if (sanitizedSessionId) {
|
|
3873
|
+
return file2.startsWith(`${sanitizedSessionId}_`);
|
|
3874
|
+
}
|
|
3875
|
+
return true;
|
|
3876
|
+
}).sort().reverse();
|
|
3877
|
+
}
|
|
3878
|
+
function buildSavedHistoryCacheSignature(dir, files) {
|
|
3879
|
+
return files.map((file2) => {
|
|
3880
|
+
try {
|
|
3881
|
+
const stat4 = fs3.statSync(path7.join(dir, file2));
|
|
3882
|
+
return `${file2}:${stat4.size}:${Math.trunc(stat4.mtimeMs)}`;
|
|
3883
|
+
} catch {
|
|
3884
|
+
return `${file2}:missing`;
|
|
3885
|
+
}
|
|
3886
|
+
}).join("|");
|
|
3887
|
+
}
|
|
3888
|
+
function computeSavedHistorySessionSummaries(agentType, dir, files) {
|
|
3889
|
+
const groupedFiles = /* @__PURE__ */ new Map();
|
|
3890
|
+
const filePattern = /^([A-Za-z0-9_-]+)_\d{4}-\d{2}-\d{2}\.jsonl$/;
|
|
3891
|
+
for (const file2 of files) {
|
|
3892
|
+
const match = file2.match(filePattern);
|
|
3893
|
+
if (!match?.[1]) continue;
|
|
3894
|
+
const historySessionId = match[1];
|
|
3895
|
+
const grouped = groupedFiles.get(historySessionId) || [];
|
|
3896
|
+
grouped.push(file2);
|
|
3897
|
+
groupedFiles.set(historySessionId, grouped);
|
|
3898
|
+
}
|
|
3899
|
+
const summaries = [];
|
|
3900
|
+
for (const [historySessionId, grouped] of groupedFiles.entries()) {
|
|
3901
|
+
let messageCount = 0;
|
|
3902
|
+
let firstMessageAt = 0;
|
|
3903
|
+
let lastMessageAt = 0;
|
|
3904
|
+
let sessionTitle = "";
|
|
3905
|
+
let preview = "";
|
|
3906
|
+
let workspace = "";
|
|
3907
|
+
for (const file2 of grouped.sort()) {
|
|
3908
|
+
const filePath = path7.join(dir, file2);
|
|
3909
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
3910
|
+
const lines = content.split("\n").filter(Boolean);
|
|
3911
|
+
for (const line of lines) {
|
|
3912
|
+
let parsed = null;
|
|
3913
|
+
try {
|
|
3914
|
+
parsed = JSON.parse(line);
|
|
3915
|
+
} catch {
|
|
3916
|
+
parsed = null;
|
|
3917
|
+
}
|
|
3918
|
+
if (!parsed || parsed.historySessionId !== historySessionId) continue;
|
|
3919
|
+
if (parsed.kind === "session_start") {
|
|
3920
|
+
if (!workspace && parsed.workspace) workspace = parsed.workspace;
|
|
3921
|
+
continue;
|
|
3922
|
+
}
|
|
3923
|
+
messageCount += 1;
|
|
3924
|
+
if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
|
|
3925
|
+
if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
|
|
3926
|
+
if (parsed.sessionTitle) sessionTitle = parsed.sessionTitle;
|
|
3927
|
+
if (parsed.role !== "system" && parsed.content.trim()) preview = parsed.content.trim();
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
if (messageCount === 0 || !lastMessageAt) continue;
|
|
3931
|
+
summaries.push({
|
|
3932
|
+
historySessionId,
|
|
3933
|
+
sessionTitle: sessionTitle || void 0,
|
|
3934
|
+
messageCount,
|
|
3935
|
+
firstMessageAt,
|
|
3936
|
+
lastMessageAt,
|
|
3937
|
+
preview: preview || void 0,
|
|
3938
|
+
workspace: workspace || void 0
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
|
|
3942
|
+
return summaries;
|
|
3943
|
+
}
|
|
3944
|
+
function readChatHistory(agentType, offset = 0, limit = 30, historySessionId, excludeRecentCount = 0) {
|
|
3866
3945
|
try {
|
|
3867
3946
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3868
3947
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
3869
3948
|
if (!fs3.existsSync(dir)) return { messages: [], hasMore: false };
|
|
3870
|
-
const
|
|
3871
|
-
const files = fs3.readdirSync(dir).filter((f) => {
|
|
3872
|
-
if (!f.endsWith(".jsonl")) return false;
|
|
3873
|
-
if (sanitizedInstance) {
|
|
3874
|
-
return f.startsWith(`${sanitizedInstance}_`);
|
|
3875
|
-
}
|
|
3876
|
-
return true;
|
|
3877
|
-
}).sort().reverse();
|
|
3949
|
+
const files = listHistoryFiles(dir, historySessionId);
|
|
3878
3950
|
const allMessages = [];
|
|
3879
3951
|
const seen = /* @__PURE__ */ new Set();
|
|
3880
3952
|
for (const file2 of files) {
|
|
@@ -3905,8 +3977,13 @@ function readChatHistory(agentType, offset = 0, limit = 30, historySessionId) {
|
|
|
3905
3977
|
if (message.role !== "system") lastTurn = message;
|
|
3906
3978
|
}
|
|
3907
3979
|
const collapsed = collapseReplayAssistantTurns(agentType, chronological);
|
|
3908
|
-
const
|
|
3909
|
-
const
|
|
3980
|
+
const boundedLimit = Math.max(1, limit);
|
|
3981
|
+
const boundedOffset = Math.max(0, offset);
|
|
3982
|
+
const boundedExclude = Math.max(0, Math.min(excludeRecentCount, collapsed.length));
|
|
3983
|
+
const endExclusive = Math.max(0, collapsed.length - boundedExclude - boundedOffset);
|
|
3984
|
+
const startInclusive = Math.max(0, endExclusive - boundedLimit);
|
|
3985
|
+
const sliced = collapsed.slice(startInclusive, endExclusive);
|
|
3986
|
+
const hasMore = startInclusive > 0;
|
|
3910
3987
|
return { messages: sliced, hasMore };
|
|
3911
3988
|
} catch {
|
|
3912
3989
|
return { messages: [], hasMore: false };
|
|
@@ -3916,61 +3993,20 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
3916
3993
|
try {
|
|
3917
3994
|
const sanitized = agentType.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3918
3995
|
const dir = path7.join(HISTORY_DIR, sanitized);
|
|
3919
|
-
if (!fs3.existsSync(dir))
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
const summaries = [];
|
|
3932
|
-
for (const [historySessionId, files] of groupedFiles.entries()) {
|
|
3933
|
-
let messageCount = 0;
|
|
3934
|
-
let firstMessageAt = 0;
|
|
3935
|
-
let lastMessageAt = 0;
|
|
3936
|
-
let sessionTitle = "";
|
|
3937
|
-
let preview = "";
|
|
3938
|
-
let workspace = "";
|
|
3939
|
-
for (const file2 of files.sort()) {
|
|
3940
|
-
const filePath = path7.join(dir, file2);
|
|
3941
|
-
const content = fs3.readFileSync(filePath, "utf-8");
|
|
3942
|
-
const lines = content.split("\n").filter(Boolean);
|
|
3943
|
-
for (const line of lines) {
|
|
3944
|
-
let parsed = null;
|
|
3945
|
-
try {
|
|
3946
|
-
parsed = JSON.parse(line);
|
|
3947
|
-
} catch {
|
|
3948
|
-
parsed = null;
|
|
3949
|
-
}
|
|
3950
|
-
if (!parsed || parsed.historySessionId !== historySessionId) continue;
|
|
3951
|
-
if (parsed.kind === "session_start") {
|
|
3952
|
-
if (!workspace && parsed.workspace) workspace = parsed.workspace;
|
|
3953
|
-
continue;
|
|
3954
|
-
}
|
|
3955
|
-
messageCount += 1;
|
|
3956
|
-
if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
|
|
3957
|
-
if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
|
|
3958
|
-
if (parsed.sessionTitle) sessionTitle = parsed.sessionTitle;
|
|
3959
|
-
if (parsed.role !== "system" && parsed.content.trim()) preview = parsed.content.trim();
|
|
3960
|
-
}
|
|
3961
|
-
}
|
|
3962
|
-
if (messageCount === 0 || !lastMessageAt) continue;
|
|
3963
|
-
summaries.push({
|
|
3964
|
-
historySessionId,
|
|
3965
|
-
sessionTitle: sessionTitle || void 0,
|
|
3966
|
-
messageCount,
|
|
3967
|
-
firstMessageAt,
|
|
3968
|
-
lastMessageAt,
|
|
3969
|
-
preview: preview || void 0,
|
|
3970
|
-
workspace: workspace || void 0
|
|
3996
|
+
if (!fs3.existsSync(dir)) {
|
|
3997
|
+
savedHistorySessionCache.delete(sanitized);
|
|
3998
|
+
return { sessions: [], hasMore: false };
|
|
3999
|
+
}
|
|
4000
|
+
const files = listHistoryFiles(dir);
|
|
4001
|
+
const signature = buildSavedHistoryCacheSignature(dir, files);
|
|
4002
|
+
const cached2 = savedHistorySessionCache.get(sanitized);
|
|
4003
|
+
const summaries = cached2?.signature === signature ? cached2.summaries : computeSavedHistorySessionSummaries(agentType, dir, files);
|
|
4004
|
+
if (!cached2 || cached2.signature !== signature) {
|
|
4005
|
+
savedHistorySessionCache.set(sanitized, {
|
|
4006
|
+
signature,
|
|
4007
|
+
summaries
|
|
3971
4008
|
});
|
|
3972
4009
|
}
|
|
3973
|
-
summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
|
|
3974
4010
|
const offset = Math.max(0, options.offset || 0);
|
|
3975
4011
|
const limit = Math.max(1, options.limit || 30);
|
|
3976
4012
|
const sliced = summaries.slice(offset, offset + limit);
|
|
@@ -3982,7 +4018,7 @@ function listSavedHistorySessions(agentType, options = {}) {
|
|
|
3982
4018
|
return { sessions: [], hasMore: false };
|
|
3983
4019
|
}
|
|
3984
4020
|
}
|
|
3985
|
-
var fs3, path7, os6, HISTORY_DIR, RETAIN_DAYS, CODEX_STARTER_PROMPT_RE, ChatHistoryWriter;
|
|
4021
|
+
var fs3, path7, os6, HISTORY_DIR, RETAIN_DAYS, savedHistorySessionCache, CODEX_STARTER_PROMPT_RE, ChatHistoryWriter;
|
|
3986
4022
|
var init_chat_history = __esm({
|
|
3987
4023
|
"../../oss/packages/daemon-core/src/config/chat-history.ts"() {
|
|
3988
4024
|
"use strict";
|
|
@@ -3992,6 +4028,7 @@ var init_chat_history = __esm({
|
|
|
3992
4028
|
init_chat_message_normalization();
|
|
3993
4029
|
HISTORY_DIR = path7.join(os6.homedir(), ".adhdev", "history");
|
|
3994
4030
|
RETAIN_DAYS = 30;
|
|
4031
|
+
savedHistorySessionCache = /* @__PURE__ */ new Map();
|
|
3995
4032
|
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;
|
|
3996
4033
|
ChatHistoryWriter = class {
|
|
3997
4034
|
/** Last seen message count per agent (deduplication) */
|
|
@@ -4954,7 +4991,7 @@ var init_read_chat_contract = __esm({
|
|
|
4954
4991
|
|
|
4955
4992
|
// ../../oss/packages/daemon-core/src/providers/approval-utils.ts
|
|
4956
4993
|
function normalizeApprovalLabel(value) {
|
|
4957
|
-
return String(value || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
4994
|
+
return String(value || "").toLowerCase().replace(/^[\s\[(<{]*\d+(?:\s*[.)\]}>:-]|\s)+/, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
4958
4995
|
}
|
|
4959
4996
|
function getApprovalPositiveHints(provider) {
|
|
4960
4997
|
const customHints = Array.isArray(provider?.approvalPositiveHints) ? provider.approvalPositiveHints.map((hint) => normalizeApprovalLabel(String(hint || ""))).filter(Boolean) : [];
|
|
@@ -4988,19 +5025,19 @@ var init_approval_utils = __esm({
|
|
|
4988
5025
|
"../../oss/packages/daemon-core/src/providers/approval-utils.ts"() {
|
|
4989
5026
|
"use strict";
|
|
4990
5027
|
DEFAULT_APPROVAL_POSITIVE_HINTS = [
|
|
4991
|
-
"
|
|
5028
|
+
"yes",
|
|
5029
|
+
"allow once",
|
|
4992
5030
|
"approve",
|
|
4993
5031
|
"accept",
|
|
4994
|
-
"allow once",
|
|
4995
|
-
"always allow",
|
|
4996
|
-
"allow",
|
|
4997
|
-
"yes",
|
|
4998
|
-
"proceed",
|
|
4999
5032
|
"continue",
|
|
5033
|
+
"run",
|
|
5034
|
+
"proceed",
|
|
5000
5035
|
"confirm",
|
|
5001
5036
|
"save",
|
|
5002
5037
|
"ok",
|
|
5003
|
-
"trust"
|
|
5038
|
+
"trust",
|
|
5039
|
+
"allow",
|
|
5040
|
+
"always allow"
|
|
5004
5041
|
];
|
|
5005
5042
|
}
|
|
5006
5043
|
});
|
|
@@ -6831,6 +6868,41 @@ function normalizeReadChatMessages(payload) {
|
|
|
6831
6868
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
6832
6869
|
return normalizeChatMessages(messages);
|
|
6833
6870
|
}
|
|
6871
|
+
function buildReadChatReplayCollapseSignature(message) {
|
|
6872
|
+
if (!message) return "";
|
|
6873
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
6874
|
+
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
6875
|
+
const senderName = typeof message.senderName === "string" ? message.senderName.trim().toLowerCase() : "";
|
|
6876
|
+
const content = flattenContent(message.content || "").replace(/\s+/g, " ").trim();
|
|
6877
|
+
return `${role}:${kind}:${senderName}:${content}`;
|
|
6878
|
+
}
|
|
6879
|
+
function shouldCollapseReadChatReplayDuplicate(message) {
|
|
6880
|
+
if (!message) return false;
|
|
6881
|
+
const role = typeof message.role === "string" ? message.role.trim().toLowerCase() : "";
|
|
6882
|
+
if (role !== "assistant" && role !== "system") return false;
|
|
6883
|
+
const kind = typeof message.kind === "string" ? message.kind.trim().toLowerCase() : "standard";
|
|
6884
|
+
return kind === "tool" || kind === "terminal" || kind === "thought" || kind === "system";
|
|
6885
|
+
}
|
|
6886
|
+
function collapseReplayDuplicatesFromReadChat(messages) {
|
|
6887
|
+
const collapsed = [];
|
|
6888
|
+
let lastReplayTurnSignature = "";
|
|
6889
|
+
for (const message of messages) {
|
|
6890
|
+
const signature = buildReadChatReplayCollapseSignature(message);
|
|
6891
|
+
const previous = collapsed[collapsed.length - 1];
|
|
6892
|
+
const previousSignature = buildReadChatReplayCollapseSignature(previous);
|
|
6893
|
+
if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
|
|
6894
|
+
if (previousSignature === signature) continue;
|
|
6895
|
+
if (lastReplayTurnSignature === signature) continue;
|
|
6896
|
+
}
|
|
6897
|
+
collapsed.push(message);
|
|
6898
|
+
if (shouldCollapseReadChatReplayDuplicate(message) && signature) {
|
|
6899
|
+
lastReplayTurnSignature = signature;
|
|
6900
|
+
} else if ((message.role || "").toLowerCase() === "user") {
|
|
6901
|
+
lastReplayTurnSignature = "";
|
|
6902
|
+
}
|
|
6903
|
+
}
|
|
6904
|
+
return collapsed;
|
|
6905
|
+
}
|
|
6834
6906
|
function deriveHistoryDedupKey(message) {
|
|
6835
6907
|
const unitKey = typeof message._unitKey === "string" ? message._unitKey.trim() : "";
|
|
6836
6908
|
if (unitKey) return `read_chat:${unitKey}`;
|
|
@@ -6906,14 +6978,38 @@ function computeReadChatSync(messages, cursor) {
|
|
|
6906
6978
|
lastMessageSignature
|
|
6907
6979
|
};
|
|
6908
6980
|
}
|
|
6981
|
+
function hasNonEmptyModalButtons(activeModal) {
|
|
6982
|
+
if (!activeModal || typeof activeModal !== "object") return false;
|
|
6983
|
+
const buttons = activeModal.buttons;
|
|
6984
|
+
return Array.isArray(buttons) && buttons.some((button) => typeof button === "string" && button.trim().length > 0);
|
|
6985
|
+
}
|
|
6986
|
+
function normalizeReadChatCommandStatus(status, activeModal) {
|
|
6987
|
+
const raw = typeof status === "string" ? status.trim() : "";
|
|
6988
|
+
if (!raw) {
|
|
6989
|
+
return hasNonEmptyModalButtons(activeModal) ? "waiting_approval" : "idle";
|
|
6990
|
+
}
|
|
6991
|
+
switch (raw) {
|
|
6992
|
+
case "starting":
|
|
6993
|
+
return hasNonEmptyModalButtons(activeModal) ? "waiting_approval" : "generating";
|
|
6994
|
+
case "stopped":
|
|
6995
|
+
case "disconnected":
|
|
6996
|
+
case "not_monitored":
|
|
6997
|
+
return "error";
|
|
6998
|
+
default:
|
|
6999
|
+
return raw;
|
|
7000
|
+
}
|
|
7001
|
+
}
|
|
6909
7002
|
function buildReadChatCommandResult(payload, args) {
|
|
6910
7003
|
let validatedPayload;
|
|
6911
7004
|
try {
|
|
6912
|
-
validatedPayload = validateReadChatResultPayload(
|
|
7005
|
+
validatedPayload = validateReadChatResultPayload({
|
|
7006
|
+
...payload,
|
|
7007
|
+
status: normalizeReadChatCommandStatus(payload?.status, payload?.activeModal)
|
|
7008
|
+
}, "read_chat command result");
|
|
6913
7009
|
} catch (error48) {
|
|
6914
7010
|
return { success: false, error: error48?.message || String(error48) };
|
|
6915
7011
|
}
|
|
6916
|
-
const messages = normalizeReadChatMessages(validatedPayload);
|
|
7012
|
+
const messages = collapseReplayDuplicatesFromReadChat(normalizeReadChatMessages(validatedPayload));
|
|
6917
7013
|
const cursor = normalizeReadChatCursor(args);
|
|
6918
7014
|
if (!cursor.knownMessageCount && !cursor.lastMessageSignature && cursor.tailLimit > 0 && messages.length > cursor.tailLimit) {
|
|
6919
7015
|
const tailMessages = messages.slice(-cursor.tailLimit);
|
|
@@ -6995,7 +7091,15 @@ async function handleChatHistory(h, args) {
|
|
|
6995
7091
|
try {
|
|
6996
7092
|
const provider = h.getProvider(agentType);
|
|
6997
7093
|
const agentStr = provider?.type || agentType || getCurrentProviderType(h);
|
|
6998
|
-
const
|
|
7094
|
+
const transport = getTargetTransport(h, provider);
|
|
7095
|
+
let excludeRecentCount = Math.max(0, Number(args?.excludeRecentCount || 0));
|
|
7096
|
+
if (isCliLikeTransport(transport)) {
|
|
7097
|
+
const adapter = getTargetedCliAdapter(h, args, provider?.type);
|
|
7098
|
+
const status = adapter?.getStatus?.();
|
|
7099
|
+
const visibleCount = Array.isArray(status?.messages) ? status.messages.length : 0;
|
|
7100
|
+
if (visibleCount > excludeRecentCount) excludeRecentCount = visibleCount;
|
|
7101
|
+
}
|
|
7102
|
+
const result = readChatHistory(agentStr, offset || 0, limit || 30, historySessionId, excludeRecentCount);
|
|
6999
7103
|
return { success: true, ...result, agent: agentStr };
|
|
7000
7104
|
} catch (e) {
|
|
7001
7105
|
return { success: false, error: e.message };
|
|
@@ -8283,13 +8387,6 @@ var init_cli_script_results = __esm({
|
|
|
8283
8387
|
});
|
|
8284
8388
|
|
|
8285
8389
|
// ../../oss/packages/daemon-core/src/commands/stream-commands.ts
|
|
8286
|
-
function getCliPresentationMode(h, targetSessionId) {
|
|
8287
|
-
if (!targetSessionId) return null;
|
|
8288
|
-
const instance = h.ctx.instanceManager?.getInstance(targetSessionId);
|
|
8289
|
-
if (instance?.category !== "cli") return null;
|
|
8290
|
-
const mode = instance.getPresentationMode?.();
|
|
8291
|
-
return mode === "chat" || mode === "terminal" ? mode : null;
|
|
8292
|
-
}
|
|
8293
8390
|
function normalizeOpenPanelCommandResult(result) {
|
|
8294
8391
|
const payload = Object.prototype.hasOwnProperty.call(result, "result") ? result.result : result;
|
|
8295
8392
|
if (payload === true) return { opened: true, visible: true, focused: false };
|
|
@@ -8362,9 +8459,6 @@ async function handleOpenPanel(h, args) {
|
|
|
8362
8459
|
function handlePtyInput(h, args) {
|
|
8363
8460
|
const { cliType, data, targetSessionId } = args || {};
|
|
8364
8461
|
if (!data) return { success: false, error: "data required" };
|
|
8365
|
-
if (getCliPresentationMode(h, targetSessionId) === "chat") {
|
|
8366
|
-
return { success: false, error: "CLI session is in chat mode", code: "CLI_VIEW_MODE_NOT_TERMINAL" };
|
|
8367
|
-
}
|
|
8368
8462
|
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
8369
8463
|
if (!adapter || typeof adapter.writeRaw !== "function") {
|
|
8370
8464
|
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
@@ -8372,24 +8466,10 @@ function handlePtyInput(h, args) {
|
|
|
8372
8466
|
adapter.writeRaw(data);
|
|
8373
8467
|
return { success: true };
|
|
8374
8468
|
}
|
|
8375
|
-
function handlePtyResize(
|
|
8376
|
-
const {
|
|
8469
|
+
function handlePtyResize(_h, args) {
|
|
8470
|
+
const { cols, rows } = args || {};
|
|
8377
8471
|
if (!cols || !rows) return { success: false, error: "cols and rows required" };
|
|
8378
|
-
|
|
8379
|
-
return { success: false, error: "CLI session is in chat mode", code: "CLI_VIEW_MODE_NOT_TERMINAL" };
|
|
8380
|
-
}
|
|
8381
|
-
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
8382
|
-
if (!adapter || typeof adapter.resize !== "function") {
|
|
8383
|
-
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
8384
|
-
}
|
|
8385
|
-
const resize = adapter.resize;
|
|
8386
|
-
if (force) {
|
|
8387
|
-
resize(cols - 1, rows);
|
|
8388
|
-
setTimeout(() => resize(cols, rows), 50);
|
|
8389
|
-
} else {
|
|
8390
|
-
resize(cols, rows);
|
|
8391
|
-
}
|
|
8392
|
-
return { success: true };
|
|
8472
|
+
return { success: false, error: "PTY resize temporarily disabled", code: "PTY_RESIZE_DISABLED" };
|
|
8393
8473
|
}
|
|
8394
8474
|
function handleGetProviderSettings(h, args) {
|
|
8395
8475
|
const loader = h.ctx.providerLoader;
|
|
@@ -8476,15 +8556,45 @@ function normalizeProviderScriptArgs(args, scriptName) {
|
|
|
8476
8556
|
}
|
|
8477
8557
|
function buildControlScriptResult(scriptName, payload) {
|
|
8478
8558
|
if (!payload || typeof payload !== "object") return {};
|
|
8479
|
-
|
|
8480
|
-
|
|
8559
|
+
const legacyListPayload = (() => {
|
|
8560
|
+
if (Array.isArray(payload.options)) return payload;
|
|
8561
|
+
if (/^listmodels$/i.test(scriptName) && Array.isArray(payload.models)) {
|
|
8562
|
+
return {
|
|
8563
|
+
options: payload.models,
|
|
8564
|
+
currentValue: payload.currentValue ?? payload.current ?? payload.currentModel,
|
|
8565
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8566
|
+
};
|
|
8567
|
+
}
|
|
8568
|
+
if (/^listmodes$/i.test(scriptName) && Array.isArray(payload.modes)) {
|
|
8569
|
+
return {
|
|
8570
|
+
options: payload.modes,
|
|
8571
|
+
currentValue: payload.currentValue ?? payload.current ?? payload.currentMode ?? payload.mode,
|
|
8572
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8573
|
+
};
|
|
8574
|
+
}
|
|
8575
|
+
return null;
|
|
8576
|
+
})();
|
|
8577
|
+
if (legacyListPayload) {
|
|
8578
|
+
return { controlResult: normalizeControlListResult(legacyListPayload) };
|
|
8481
8579
|
}
|
|
8482
|
-
const
|
|
8580
|
+
const legacyMutationPayload = (() => {
|
|
8581
|
+
if (typeof payload.ok === "boolean") return payload;
|
|
8582
|
+
if (typeof payload.success === "boolean") {
|
|
8583
|
+
return {
|
|
8584
|
+
ok: payload.success,
|
|
8585
|
+
currentValue: payload.currentValue ?? payload.value ?? payload.model ?? payload.mode ?? payload.selectedModel ?? payload.selectedMode,
|
|
8586
|
+
...Array.isArray(payload.effects) ? { effects: payload.effects } : {},
|
|
8587
|
+
...typeof payload.error === "string" ? { error: payload.error } : {}
|
|
8588
|
+
};
|
|
8589
|
+
}
|
|
8590
|
+
return null;
|
|
8591
|
+
})();
|
|
8592
|
+
const looksLikeValueMutation = /^set|^change/i.test(scriptName) || payload.currentValue !== void 0 || payload.value !== void 0 || payload.success !== void 0;
|
|
8483
8593
|
if (looksLikeValueMutation) {
|
|
8484
|
-
return { controlResult: normalizeControlSetResult(payload) };
|
|
8594
|
+
return { controlResult: normalizeControlSetResult(legacyMutationPayload || payload) };
|
|
8485
8595
|
}
|
|
8486
8596
|
if (payload.ok !== void 0 || Array.isArray(payload.effects) || typeof payload.error === "string") {
|
|
8487
|
-
return { controlResult: normalizeControlInvokeResult(payload) };
|
|
8597
|
+
return { controlResult: normalizeControlInvokeResult(legacyMutationPayload || payload) };
|
|
8488
8598
|
}
|
|
8489
8599
|
return {};
|
|
8490
8600
|
}
|
|
@@ -8559,7 +8669,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
8559
8669
|
}
|
|
8560
8670
|
const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
|
|
8561
8671
|
const targetSessionId = managed?.cdpSessionId || null;
|
|
8562
|
-
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
8672
|
+
const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode", "listModels", "setModel", "setModelGui"] : ["listModes", "setMode", "listModels", "setModel"];
|
|
8563
8673
|
if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
|
|
8564
8674
|
if (targetSessionId) {
|
|
8565
8675
|
try {
|
|
@@ -12491,6 +12601,8 @@ ${data.message || ""}`.trim();
|
|
|
12491
12601
|
}
|
|
12492
12602
|
async sendMessage(text) {
|
|
12493
12603
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
12604
|
+
const allowInputDuringGeneration = this.provider.allowInputDuringGeneration === true;
|
|
12605
|
+
const allowInterventionPrompt = allowInputDuringGeneration && this.isWaitingForResponse && this.currentStatus !== "waiting_approval";
|
|
12494
12606
|
if (this.startupParseGate) {
|
|
12495
12607
|
const deadline = Date.now() + 1e4;
|
|
12496
12608
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
@@ -12498,7 +12610,9 @@ ${data.message || ""}`.trim();
|
|
|
12498
12610
|
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
12499
12611
|
}
|
|
12500
12612
|
}
|
|
12501
|
-
|
|
12613
|
+
if (!allowInterventionPrompt) {
|
|
12614
|
+
await this.waitForInteractivePrompt();
|
|
12615
|
+
}
|
|
12502
12616
|
if (!this.ready) {
|
|
12503
12617
|
this.resolveStartupState("send_precheck");
|
|
12504
12618
|
const screenText = this.terminalScreen.getText() || "";
|
|
@@ -12510,7 +12624,7 @@ ${data.message || ""}`.trim();
|
|
|
12510
12624
|
}
|
|
12511
12625
|
}
|
|
12512
12626
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
12513
|
-
if (this.isWaitingForResponse) {
|
|
12627
|
+
if (this.isWaitingForResponse && !allowInputDuringGeneration) {
|
|
12514
12628
|
throw new Error(`${this.cliName} is still processing the previous prompt`);
|
|
12515
12629
|
}
|
|
12516
12630
|
const blockingModal = this.activeModal || this.getStartupConfirmationModal(this.terminalScreen.getText() || "");
|
|
@@ -42802,6 +42916,20 @@ var init_dev_server = __esm({
|
|
|
42802
42916
|
async handleReload(_req, res) {
|
|
42803
42917
|
try {
|
|
42804
42918
|
this.providerLoader.reload();
|
|
42919
|
+
let refreshedInstances = 0;
|
|
42920
|
+
if (this.instanceManager) {
|
|
42921
|
+
for (const id of this.instanceManager.listInstanceIds()) {
|
|
42922
|
+
const instance = this.instanceManager.getInstance(id);
|
|
42923
|
+
const providerType = typeof instance?.type === "string" ? instance.type : "";
|
|
42924
|
+
if (!providerType) continue;
|
|
42925
|
+
const resolved = this.providerLoader.resolve(providerType);
|
|
42926
|
+
if (!resolved) continue;
|
|
42927
|
+
if (instance && typeof instance === "object" && "provider" in instance) {
|
|
42928
|
+
instance.provider = resolved;
|
|
42929
|
+
refreshedInstances += 1;
|
|
42930
|
+
}
|
|
42931
|
+
}
|
|
42932
|
+
}
|
|
42805
42933
|
const providers = this.providerLoader.getAll().map((p) => ({
|
|
42806
42934
|
type: p.type,
|
|
42807
42935
|
name: p.name,
|
|
@@ -42812,7 +42940,7 @@ var init_dev_server = __esm({
|
|
|
42812
42940
|
cdp.clearTargetId();
|
|
42813
42941
|
}
|
|
42814
42942
|
}
|
|
42815
|
-
this.json(res, 200, { reloaded: true, providers });
|
|
42943
|
+
this.json(res, 200, { reloaded: true, refreshedInstances, providers });
|
|
42816
42944
|
} catch (e) {
|
|
42817
42945
|
this.json(res, 500, { error: e.message });
|
|
42818
42946
|
}
|
|
@@ -76786,15 +76914,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
|
|
|
76786
76914
|
return;
|
|
76787
76915
|
}
|
|
76788
76916
|
if (parsed.type === "pty_resize") {
|
|
76789
|
-
|
|
76790
|
-
if (permission) {
|
|
76791
|
-
log(`pty_resize: REJECTED \u2014 permission=${permission} peer=${peerId}`);
|
|
76792
|
-
return;
|
|
76793
|
-
}
|
|
76794
|
-
const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
|
|
76795
|
-
if (handlers.ptyResizeHandler && parsed.cols && parsed.rows && sessionId) {
|
|
76796
|
-
handlers.ptyResizeHandler(sessionId, parsed.cols, parsed.rows);
|
|
76797
|
-
}
|
|
76917
|
+
logDebug(`pty_resize ignored: peer=${peerId} reason=temporarily_disabled`);
|
|
76798
76918
|
return;
|
|
76799
76919
|
}
|
|
76800
76920
|
handleFileRequest(peerId, parsed, peers, handlers);
|
|
@@ -85147,7 +85267,7 @@ var init_adhdev_daemon = __esm({
|
|
|
85147
85267
|
init_source();
|
|
85148
85268
|
init_version();
|
|
85149
85269
|
init_src();
|
|
85150
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.
|
|
85270
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.75" });
|
|
85151
85271
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
85152
85272
|
localHttpServer = null;
|
|
85153
85273
|
localWss = null;
|
|
@@ -85218,9 +85338,6 @@ var init_adhdev_daemon = __esm({
|
|
|
85218
85338
|
const mode = instance.getPresentationMode?.();
|
|
85219
85339
|
return mode === "chat" || mode === "terminal" ? mode : null;
|
|
85220
85340
|
}
|
|
85221
|
-
isTerminalCliSession(sessionId) {
|
|
85222
|
-
return this.getCliPresentationMode(sessionId) === "terminal";
|
|
85223
|
-
}
|
|
85224
85341
|
isCliSession(sessionId) {
|
|
85225
85342
|
const mode = this.getCliPresentationMode(sessionId);
|
|
85226
85343
|
return mode === "chat" || mode === "terminal";
|
|
@@ -85658,14 +85775,14 @@ ${err?.stack || ""}`);
|
|
|
85658
85775
|
}
|
|
85659
85776
|
});
|
|
85660
85777
|
this.p2p.onPtyInput((sessionId, data) => {
|
|
85661
|
-
if (!this.
|
|
85778
|
+
if (!this.isCliSession(sessionId)) return;
|
|
85662
85779
|
const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
|
|
85663
85780
|
if (found && typeof found.adapter.writeRaw === "function") {
|
|
85664
85781
|
found.adapter.writeRaw(data);
|
|
85665
85782
|
}
|
|
85666
85783
|
});
|
|
85667
85784
|
this.p2p.onPtyResize((sessionId, cols, rows) => {
|
|
85668
|
-
if (!this.
|
|
85785
|
+
if (!this.isCliSession(sessionId)) return;
|
|
85669
85786
|
const found = this.components.cliManager.findAdapter(sessionId, { instanceKey: sessionId });
|
|
85670
85787
|
if (found && typeof found.adapter.resize === "function") {
|
|
85671
85788
|
found.adapter.resize(cols, rows);
|