@adhdev/daemon-standalone 0.9.76-rc.40 → 0.9.76-rc.42
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/package.json
CHANGED
|
@@ -55938,6 +55938,53 @@ async function listDaemons(transport, args = {}) {
|
|
|
55938
55938
|
${lines.join("\n")}`;
|
|
55939
55939
|
}
|
|
55940
55940
|
|
|
55941
|
+
// src/tools/chat-compact.ts
|
|
55942
|
+
function messageContent(message) {
|
|
55943
|
+
const content = message?.content;
|
|
55944
|
+
if (typeof content === "string") return content;
|
|
55945
|
+
if (Array.isArray(content)) {
|
|
55946
|
+
return content.map((part) => typeof part === "string" ? part : part?.text ?? "").join("");
|
|
55947
|
+
}
|
|
55948
|
+
return "";
|
|
55949
|
+
}
|
|
55950
|
+
function isCoordinatorVisibleMessage(message) {
|
|
55951
|
+
if (!message || typeof message !== "object") return false;
|
|
55952
|
+
const role = String(message.role ?? "").toLowerCase();
|
|
55953
|
+
if (role === "tool" || role === "system" || role === "debug") return false;
|
|
55954
|
+
const kind = String(message.kind ?? message.type ?? message.messageKind ?? "").toLowerCase();
|
|
55955
|
+
if (["tool", "tool_call", "tool_result", "terminal", "internal", "control", "debug", "status"].includes(kind)) return false;
|
|
55956
|
+
const meta3 = message.meta ?? message.metadata;
|
|
55957
|
+
if (meta3?.internal === true || meta3?.debug === true || meta3?.control === true || meta3?.userVisible === false || meta3?.user_visible === false) return false;
|
|
55958
|
+
return role === "user" || role === "assistant" || role === "agent";
|
|
55959
|
+
}
|
|
55960
|
+
function compactChatPayload(payload, opts = {}) {
|
|
55961
|
+
const rawMessages = Array.isArray(payload?.messages) ? payload.messages : [];
|
|
55962
|
+
const visible = rawMessages.filter(isCoordinatorVisibleMessage);
|
|
55963
|
+
const limit = Math.max(1, Math.min(opts.limit ?? 10, 10));
|
|
55964
|
+
const messages = visible.slice(-limit);
|
|
55965
|
+
const finalAssistant = [...visible].reverse().find((message) => {
|
|
55966
|
+
const role = String(message?.role ?? "").toLowerCase();
|
|
55967
|
+
return (role === "assistant" || role === "agent") && messageContent(message).trim();
|
|
55968
|
+
});
|
|
55969
|
+
const summary = typeof payload?.summary === "string" && payload.summary.trim() ? payload.summary.trim() : messageContent(finalAssistant).trim();
|
|
55970
|
+
return {
|
|
55971
|
+
success: payload?.success !== false,
|
|
55972
|
+
compact: true,
|
|
55973
|
+
...opts.nodeId ? { nodeId: opts.nodeId } : {},
|
|
55974
|
+
...opts.sessionId !== void 0 ? { sessionId: opts.sessionId } : {},
|
|
55975
|
+
status: payload?.status ?? null,
|
|
55976
|
+
providerSessionId: payload?.providerSessionId ?? null,
|
|
55977
|
+
totalMessages: rawMessages.length,
|
|
55978
|
+
visibleMessages: visible.length,
|
|
55979
|
+
filteredMessages: visible.length,
|
|
55980
|
+
omittedMessages: Math.max(0, rawMessages.length - visible.length),
|
|
55981
|
+
summary,
|
|
55982
|
+
...payload?.changedFiles !== void 0 ? { changedFiles: payload.changedFiles } : {},
|
|
55983
|
+
...payload?.testsRun !== void 0 ? { testsRun: payload.testsRun } : {},
|
|
55984
|
+
messages
|
|
55985
|
+
};
|
|
55986
|
+
}
|
|
55987
|
+
|
|
55941
55988
|
// src/tools/read-chat.ts
|
|
55942
55989
|
var READ_CHAT_TOOL = {
|
|
55943
55990
|
name: "read_chat",
|
|
@@ -55957,6 +56004,10 @@ var READ_CHAT_TOOL = {
|
|
|
55957
56004
|
type: "string",
|
|
55958
56005
|
description: "Daemon ID (cloud mode only). Omit for local mode."
|
|
55959
56006
|
},
|
|
56007
|
+
compact: {
|
|
56008
|
+
type: "boolean",
|
|
56009
|
+
description: "Opt-in compact mode: filters tool/terminal/system/internal/control/debug/status chatter and returns user-visible messages plus lightweight summary metadata."
|
|
56010
|
+
},
|
|
55960
56011
|
...FORMAT_PROP
|
|
55961
56012
|
},
|
|
55962
56013
|
required: []
|
|
@@ -55969,34 +56020,49 @@ async function readChat(transport, args) {
|
|
|
55969
56020
|
...args.session_id ? { targetSessionId: args.session_id } : {},
|
|
55970
56021
|
tailLimit: limit
|
|
55971
56022
|
});
|
|
55972
|
-
return formatChatResult(result2, args.session_id, args.format, limit);
|
|
56023
|
+
return formatChatResult(result2, args.session_id, args.format, limit, args.compact);
|
|
55973
56024
|
}
|
|
55974
56025
|
if (!args.daemon_id) throw new Error("daemon_id is required in cloud mode");
|
|
55975
56026
|
const targetId = args.session_id ? `${args.daemon_id}:session:${args.session_id}` : args.daemon_id;
|
|
55976
56027
|
const result = await transport.readChat(targetId, { limit, sessionId: args.session_id });
|
|
55977
|
-
return formatChatResult(result, args.session_id, args.format, limit);
|
|
56028
|
+
return formatChatResult(result, args.session_id, args.format, limit, args.compact);
|
|
55978
56029
|
}
|
|
55979
|
-
function formatChatResult(result, sessionId, format, limit = 50) {
|
|
56030
|
+
function formatChatResult(result, sessionId, format, limit = 50, compact = false) {
|
|
55980
56031
|
if (!result?.success && result?.error) {
|
|
55981
56032
|
if (format === "json") return JSON.stringify({ error: result.error, messages: [] }, null, 2);
|
|
55982
56033
|
return `Error: ${result.error}`;
|
|
55983
56034
|
}
|
|
55984
56035
|
const messages = result?.messages ?? result?.data?.messages ?? [];
|
|
56036
|
+
const source = { ...result, messages };
|
|
56037
|
+
const compactPayload = compact ? compactChatPayload(source, { sessionId: sessionId ?? null, limit }) : null;
|
|
56038
|
+
const outputMessages = compact ? compactPayload.messages : messages;
|
|
55985
56039
|
if (format === "json") {
|
|
56040
|
+
if (compact && compactPayload) {
|
|
56041
|
+
return JSON.stringify({
|
|
56042
|
+
session_id: sessionId ?? null,
|
|
56043
|
+
...compactPayload,
|
|
56044
|
+
messages: compactPayload.messages.map((m) => ({
|
|
56045
|
+
role: m.role,
|
|
56046
|
+
kind: m.kind ?? null,
|
|
56047
|
+
content: messageContent(m),
|
|
56048
|
+
timestamp: m.timestamp ?? null
|
|
56049
|
+
}))
|
|
56050
|
+
}, null, 2);
|
|
56051
|
+
}
|
|
55986
56052
|
return JSON.stringify({
|
|
55987
56053
|
session_id: sessionId ?? null,
|
|
55988
|
-
messages:
|
|
56054
|
+
messages: outputMessages.slice(-limit).map((m) => ({
|
|
55989
56055
|
role: m.role,
|
|
55990
56056
|
kind: m.kind ?? null,
|
|
55991
|
-
content:
|
|
56057
|
+
content: messageContent(m),
|
|
55992
56058
|
timestamp: m.timestamp ?? null
|
|
55993
56059
|
}))
|
|
55994
56060
|
}, null, 2);
|
|
55995
56061
|
}
|
|
55996
|
-
if (
|
|
55997
|
-
const lines =
|
|
56062
|
+
if (outputMessages.length === 0) return "No messages in chat.";
|
|
56063
|
+
const lines = outputMessages.slice(-limit).map((m) => {
|
|
55998
56064
|
const role = m.role === "user" ? "User" : m.role === "assistant" ? "Agent" : m.role;
|
|
55999
|
-
const content =
|
|
56065
|
+
const content = messageContent(m);
|
|
56000
56066
|
const truncated = content.length > 500 ? `${content.slice(0, 500)}\u2026` : content;
|
|
56001
56067
|
return `[${role}] ${truncated}`;
|
|
56002
56068
|
});
|
|
@@ -57042,14 +57108,15 @@ var MESH_SEND_TASK_TOOL = {
|
|
|
57042
57108
|
};
|
|
57043
57109
|
var MESH_READ_CHAT_TOOL = {
|
|
57044
57110
|
name: "mesh_read_chat",
|
|
57045
|
-
description: "Read recent chat messages from a delegated agent session on a mesh node. Use
|
|
57111
|
+
description: "Read recent chat messages from a delegated agent session on a mesh node. Use compact=true for coordinator context-efficient review: it filters tool/internal/debug chatter and returns the final user-visible summary plus recent key messages. If the runtime session has completed, provider_session_id can explicitly target provider transcript history.",
|
|
57046
57112
|
inputSchema: {
|
|
57047
57113
|
type: "object",
|
|
57048
57114
|
properties: {
|
|
57049
57115
|
node_id: { type: "string", description: "Target node ID." },
|
|
57050
57116
|
session_id: { type: "string", description: "Agent session ID to read from." },
|
|
57051
57117
|
provider_session_id: { type: "string", description: "Optional provider transcript/session ID for completed sessions." },
|
|
57052
|
-
tail: { type: "number", description: "Number of recent messages to return (default: 10)." }
|
|
57118
|
+
tail: { type: "number", description: "Number of recent messages to return (default: 10)." },
|
|
57119
|
+
compact: { type: "boolean", description: "When true, return a compact coordinator summary instead of the full transcript: tool/internal/control/debug messages are excluded and only recent user-visible key messages plus the final assistant summary are included." }
|
|
57053
57120
|
},
|
|
57054
57121
|
required: ["node_id", "session_id"]
|
|
57055
57122
|
}
|
|
@@ -57286,6 +57353,13 @@ async function meshReadChat(ctx, args) {
|
|
|
57286
57353
|
tailLimit: args.tail ?? 10
|
|
57287
57354
|
});
|
|
57288
57355
|
const payload = unwrapCommandPayload(result);
|
|
57356
|
+
if (args.compact) {
|
|
57357
|
+
return JSON.stringify(compactChatPayload(payload, {
|
|
57358
|
+
nodeId: args.node_id,
|
|
57359
|
+
sessionId: args.session_id,
|
|
57360
|
+
limit: args.tail ?? 10
|
|
57361
|
+
}), null, 2);
|
|
57362
|
+
}
|
|
57289
57363
|
return JSON.stringify(payload, null, 2);
|
|
57290
57364
|
} else {
|
|
57291
57365
|
return JSON.stringify({ error: "Cloud mesh read_chat not yet implemented" });
|