@exreve/exk 1.0.12 → 1.0.14
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/agentSession.js +51 -8
- package/dist/ttc-cli.tar.gz +0 -0
- package/package.json +1 -1
package/dist/agentSession.js
CHANGED
|
@@ -55,6 +55,9 @@ function extractToolName(toolResult) {
|
|
|
55
55
|
}
|
|
56
56
|
if (toolResult.stdout !== undefined || toolResult.stderr !== undefined)
|
|
57
57
|
return 'Bash';
|
|
58
|
+
// SDK 0.2.x: content-only results from nested tool calls (no stdout/stderr wrapper)
|
|
59
|
+
if (toolResult.content && typeof toolResult.content === 'string' && toolResult.type === 'text')
|
|
60
|
+
return 'Bash';
|
|
58
61
|
return 'unknown';
|
|
59
62
|
}
|
|
60
63
|
// AI config - loaded from server after registration, stored in ~/.talk-to-code/ai-config.json
|
|
@@ -647,13 +650,52 @@ export class AgentSessionManager {
|
|
|
647
650
|
}
|
|
648
651
|
else if (message.type === 'user') {
|
|
649
652
|
const msg = message;
|
|
653
|
+
// SDK 0.2.x: tool results can appear in two places:
|
|
654
|
+
// 1. msg.tool_use_result (top-level field, present in 0.1.x and some 0.2.x messages)
|
|
655
|
+
// 2. msg.message.content array with type='tool_result' blocks (common in 0.2.x subagent calls)
|
|
656
|
+
let toolResult = null;
|
|
657
|
+
let toolUseId = msg.parent_tool_use_id;
|
|
658
|
+
// Check top-level tool_use_result first
|
|
650
659
|
if (msg.tool_use_result) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
660
|
+
toolResult = msg.tool_use_result;
|
|
661
|
+
}
|
|
662
|
+
// Check message.content for tool_result blocks (SDK 0.2.x nested calls)
|
|
663
|
+
if (!toolResult && Array.isArray(msg.message?.content)) {
|
|
664
|
+
const contentBlocks = msg.message.content;
|
|
665
|
+
const toolResultBlock = contentBlocks.find((c) => c.type === 'tool_result');
|
|
666
|
+
if (toolResultBlock) {
|
|
667
|
+
// Extract tool use ID from the content block
|
|
668
|
+
if (toolResultBlock.tool_use_id) {
|
|
669
|
+
toolUseId = toolResultBlock.tool_use_id;
|
|
670
|
+
}
|
|
671
|
+
// The result content can be a string or array of content blocks
|
|
672
|
+
if (typeof toolResultBlock.content === 'string') {
|
|
673
|
+
try {
|
|
674
|
+
toolResult = JSON.parse(toolResultBlock.content);
|
|
675
|
+
}
|
|
676
|
+
catch {
|
|
677
|
+
toolResult = { content: toolResultBlock.content, type: 'text' };
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
else if (Array.isArray(toolResultBlock.content)) {
|
|
681
|
+
// Extract text from content blocks
|
|
682
|
+
const textParts = toolResultBlock.content
|
|
683
|
+
.filter((c) => c.type === 'text')
|
|
684
|
+
.map((c) => c.text);
|
|
685
|
+
const rawContent = textParts.join('\n');
|
|
686
|
+
try {
|
|
687
|
+
toolResult = JSON.parse(rawContent);
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
toolResult = { content: rawContent, type: 'text' };
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
toolResult = toolResultBlock;
|
|
695
|
+
}
|
|
656
696
|
}
|
|
697
|
+
}
|
|
698
|
+
if (toolResult) {
|
|
657
699
|
onOutput({
|
|
658
700
|
type: 'tool_result',
|
|
659
701
|
data: toolResult,
|
|
@@ -680,13 +722,14 @@ export class AgentSessionManager {
|
|
|
680
722
|
}
|
|
681
723
|
}
|
|
682
724
|
else if (message.type === 'system') {
|
|
725
|
+
const sysMsg = message;
|
|
683
726
|
onOutput({
|
|
684
727
|
type: 'system',
|
|
685
|
-
data:
|
|
728
|
+
data: { ...sysMsg, subtype: sysMsg.subtype },
|
|
686
729
|
timestamp: Date.now(),
|
|
687
730
|
metadata: {
|
|
688
|
-
subtype:
|
|
689
|
-
messageType:
|
|
731
|
+
subtype: sysMsg.subtype,
|
|
732
|
+
messageType: sysMsg.subtype || 'system'
|
|
690
733
|
}
|
|
691
734
|
});
|
|
692
735
|
}
|
package/dist/ttc-cli.tar.gz
CHANGED
|
Binary file
|