@exreve/exk 1.0.59 → 1.0.60
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/agentSession.js
CHANGED
|
@@ -151,7 +151,8 @@ function extractToolName(toolResult) {
|
|
|
151
151
|
}
|
|
152
152
|
catch { /* not JSON, fall through */ }
|
|
153
153
|
// SDK 0.2.x: content-only results from nested tool calls (no stdout/stderr wrapper)
|
|
154
|
-
|
|
154
|
+
// Don't default to Bash — the history lookup is authoritative
|
|
155
|
+
return 'unknown';
|
|
155
156
|
}
|
|
156
157
|
// ── Agent/Task output: {agentId, content, status}
|
|
157
158
|
if (r.agentId && Array.isArray(r.content) && r.status) {
|
|
@@ -508,6 +509,7 @@ export class AgentSessionManager {
|
|
|
508
509
|
this.sessions.set(sessionId, {
|
|
509
510
|
abortController,
|
|
510
511
|
messages: [],
|
|
512
|
+
toolNameMap: new Map(),
|
|
511
513
|
totalInputTokens: 0,
|
|
512
514
|
totalOutputTokens: 0,
|
|
513
515
|
totalCostUsd: 0,
|
|
@@ -1001,6 +1003,14 @@ export class AgentSessionManager {
|
|
|
1001
1003
|
content: msg.message,
|
|
1002
1004
|
timestamp: Date.now()
|
|
1003
1005
|
});
|
|
1006
|
+
// Populate toolNameMap from this assistant message's tool_use blocks
|
|
1007
|
+
if (Array.isArray(msg.message?.content)) {
|
|
1008
|
+
for (const block of msg.message.content) {
|
|
1009
|
+
if (block.type === 'tool_use' && block.id && block.name) {
|
|
1010
|
+
session.toolNameMap.set(block.id, block.name);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1004
1014
|
onOutput({
|
|
1005
1015
|
type: 'assistant',
|
|
1006
1016
|
data: msg.message,
|
|
@@ -1149,11 +1159,11 @@ export class AgentSessionManager {
|
|
|
1149
1159
|
}
|
|
1150
1160
|
}
|
|
1151
1161
|
if (toolResult) {
|
|
1152
|
-
//
|
|
1153
|
-
|
|
1154
|
-
const historyName = lookupToolNameFromHistory(session.messages, toolUseId);
|
|
1155
|
-
const detectedName = extractToolName(toolResult);
|
|
1156
|
-
const resolvedName =
|
|
1162
|
+
// Map lookup is O(1), falls back to O(n) history scan, then heuristic
|
|
1163
|
+
const mappedName = toolUseId ? session.toolNameMap.get(toolUseId) ?? null : null;
|
|
1164
|
+
const historyName = mappedName || lookupToolNameFromHistory(session.messages, toolUseId);
|
|
1165
|
+
const detectedName = historyName || extractToolName(toolResult);
|
|
1166
|
+
const resolvedName = detectedName;
|
|
1157
1167
|
onOutput({
|
|
1158
1168
|
type: 'tool_result',
|
|
1159
1169
|
data: toolResult,
|
|
@@ -1183,7 +1193,7 @@ export class AgentSessionManager {
|
|
|
1183
1193
|
const sysMsg = message;
|
|
1184
1194
|
onOutput({
|
|
1185
1195
|
type: 'system',
|
|
1186
|
-
data:
|
|
1196
|
+
data: sysMsg,
|
|
1187
1197
|
timestamp: Date.now(),
|
|
1188
1198
|
metadata: {
|
|
1189
1199
|
subtype: sysMsg.subtype,
|
|
@@ -161,19 +161,19 @@ export function registerSessionHandlers(socket, foreground, activeSessions, getS
|
|
|
161
161
|
});
|
|
162
162
|
},
|
|
163
163
|
onOutput: (output) => {
|
|
164
|
-
const dataString = typeof output.data === 'string' ? output.data : JSON.stringify(output.data);
|
|
165
164
|
if (!capturedPromptId) {
|
|
166
165
|
console.error(`[CLI] Missing promptId for session ${sessionId}, cannot emit prompt:output`);
|
|
167
166
|
return;
|
|
168
167
|
}
|
|
169
168
|
if (foreground && output.type === 'stdout') {
|
|
169
|
+
const dataString = typeof output.data === 'string' ? output.data : JSON.stringify(output.data);
|
|
170
170
|
process.stdout.write(dataString);
|
|
171
171
|
}
|
|
172
172
|
getSocket().emit('prompt:output', {
|
|
173
173
|
sessionId,
|
|
174
174
|
promptId: capturedPromptId,
|
|
175
175
|
type: output.type,
|
|
176
|
-
data:
|
|
176
|
+
data: output.data,
|
|
177
177
|
timestamp: output.timestamp,
|
|
178
178
|
metadata: output.metadata
|
|
179
179
|
});
|
package/dist/ttc-cli.tar.gz
CHANGED
|
Binary file
|