bingocode 1.1.200-beta.20 → 1.1.200-beta.21
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 +1 -1
- package/src/tools/AgentTool/UI.tsx +65 -29
package/package.json
CHANGED
|
@@ -15,14 +15,14 @@ import { MessageResponse } from '../../components/MessageResponse.js';
|
|
|
15
15
|
import { ToolUseLoader } from '../../components/ToolUseLoader.js';
|
|
16
16
|
import { Box, Text } from '../../ink.js';
|
|
17
17
|
import { getDumpPromptsPath } from '../../services/api/dumpPrompts.js';
|
|
18
|
-
import { buildTool, findToolByName, type Tools } from '../../Tool.js';
|
|
18
|
+
import { buildTool, findToolByName, toolMatchesName, type Tool, type Tools } from '../../Tool.js';
|
|
19
19
|
import type { Message, ProgressMessage } from '../../types/message.js';
|
|
20
20
|
import type { AgentToolProgress } from '../../types/tools.js';
|
|
21
21
|
import { count } from '../../utils/array.js';
|
|
22
22
|
import { getSearchOrReadFromContent, getSearchReadSummaryText } from '../../utils/collapseReadSearch.js';
|
|
23
23
|
import { getDisplayPath } from '../../utils/file.js';
|
|
24
24
|
import { formatDuration, formatNumber } from '../../utils/format.js';
|
|
25
|
-
import { buildSubagentLookups, createAssistantMessage, EMPTY_LOOKUPS } from '../../utils/messages.js';
|
|
25
|
+
import { buildSubagentLookups, createAssistantMessage, EMPTY_LOOKUPS, type MessageLookups } from '../../utils/messages.js';
|
|
26
26
|
import type { ModelAlias } from '../../utils/model/aliases.js';
|
|
27
27
|
import { getMainLoopModel, parseUserSpecifiedModel, renderModelName } from '../../utils/model/model.js';
|
|
28
28
|
import type { Theme, ThemeName } from '../../utils/theme.js';
|
|
@@ -32,6 +32,58 @@ import { getAgentColor } from './agentColorManager.js';
|
|
|
32
32
|
import { GENERAL_PURPOSE_AGENT } from './built-in/generalPurposeAgent.js';
|
|
33
33
|
const MAX_PROGRESS_MESSAGES_TO_SHOW = 3;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Create a minimal fallback Tool object for a sub-agent tool name not present
|
|
37
|
+
* in the coordinator's tool set. Used in brain mode where the coordinator only
|
|
38
|
+
* has [Agent, AskUserQuestion] but sub-agents use Read/Grep/Bash/Edit/etc.
|
|
39
|
+
* Without fallbacks, findToolByName returns null and renders blank lines.
|
|
40
|
+
*/
|
|
41
|
+
function createFallbackTool(name: string): Tool {
|
|
42
|
+
return buildTool({
|
|
43
|
+
name,
|
|
44
|
+
inputSchema: z.object({}).passthrough(),
|
|
45
|
+
description: async () => `Sub-agent tool: ${name}`,
|
|
46
|
+
call: async () => ({ data: {} as unknown }) as any,
|
|
47
|
+
maxResultSizeChars: 100_000,
|
|
48
|
+
prompt: async () => '',
|
|
49
|
+
mapToolResultToToolResultBlockParam: (_content: unknown, toolUseID: string) => ({
|
|
50
|
+
tool_use_id: toolUseID,
|
|
51
|
+
content: [{ type: 'text' as const, text: '' }],
|
|
52
|
+
type: 'tool_result' as const,
|
|
53
|
+
}),
|
|
54
|
+
renderToolUseMessage: (input: Record<string, unknown>) => {
|
|
55
|
+
const keys = Object.keys(input);
|
|
56
|
+
if (keys.length === 0) return '';
|
|
57
|
+
return keys.map(k => {
|
|
58
|
+
const v = input[k];
|
|
59
|
+
let s = typeof v === 'string' ? v : JSON.stringify(v);
|
|
60
|
+
if (s.length > 80) s = s.slice(0, 80) + '\u2026';
|
|
61
|
+
return `${k}: ${s}`;
|
|
62
|
+
}).join(', ');
|
|
63
|
+
},
|
|
64
|
+
renderToolResultMessage: () => null,
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Given the result of buildSubagentLookups, create fallback Tool entries
|
|
70
|
+
* for any tool name not already in `tools`. Returns the original `tools`
|
|
71
|
+
* array if no new names are found. Avoids re-scanning progress data.
|
|
72
|
+
*/
|
|
73
|
+
function augmentToolsFromLookups(
|
|
74
|
+
tools: Tools,
|
|
75
|
+
lookups: MessageLookups,
|
|
76
|
+
): Tools {
|
|
77
|
+
const toolNames = new Set<string>()
|
|
78
|
+
for (const block of lookups.toolUseByToolUseID.values()) {
|
|
79
|
+
toolNames.add(block.name)
|
|
80
|
+
}
|
|
81
|
+
if (toolNames.size === 0) return tools
|
|
82
|
+
const missing = [...toolNames].filter(n => !tools.some(t => toolMatchesName(t, n)))
|
|
83
|
+
if (missing.length === 0) return tools
|
|
84
|
+
return [...tools, ...missing.map(createFallbackTool)]
|
|
85
|
+
}
|
|
86
|
+
|
|
35
87
|
/**
|
|
36
88
|
* Guard: checks if progress data has a `message` field (agent_progress or
|
|
37
89
|
* skill_progress). Other progress types (e.g. bash_progress forwarded from
|
|
@@ -262,12 +314,12 @@ function VerboseAgentTranscript(t0) {
|
|
|
262
314
|
lookups: agentLookups,
|
|
263
315
|
inProgressToolUseIDs
|
|
264
316
|
} = t1;
|
|
265
|
-
let t2;
|
|
317
|
+
const augmentedTools = augmentToolsFromLookups(tools, agentLookups); let t2;
|
|
266
318
|
if ($[2] !== agentLookups || $[3] !== inProgressToolUseIDs || $[4] !== progressMessages || $[5] !== tools || $[6] !== verbose) {
|
|
267
319
|
const filteredMessages = progressMessages.filter(_temp4);
|
|
268
320
|
let t3;
|
|
269
321
|
if ($[8] !== agentLookups || $[9] !== inProgressToolUseIDs || $[10] !== tools || $[11] !== verbose) {
|
|
270
|
-
t3 = progressMessage => <MessageResponse key={progressMessage.uuid} height={1}><MessageComponent message={progressMessage.data.message} lookups={agentLookups} addMargin={false} tools={
|
|
322
|
+
t3 = progressMessage => <MessageResponse key={progressMessage.uuid} height={1}><MessageComponent message={progressMessage.data.message} lookups={agentLookups} addMargin={false} tools={augmentedTools} commands={[]} verbose={verbose} inProgressToolUseIDs={inProgressToolUseIDs} progressMessagesForMessage={[]} shouldAnimate={false} shouldShowDot={false} isTranscriptMode={false} isStatic={true} /></MessageResponse>;
|
|
271
323
|
$[8] = agentLookups;
|
|
272
324
|
$[9] = inProgressToolUseIDs;
|
|
273
325
|
$[10] = tools;
|
|
@@ -384,6 +436,12 @@ export function renderToolResultMessage(data: Output, progressMessagesForMessage
|
|
|
384
436
|
speed: null
|
|
385
437
|
}
|
|
386
438
|
});
|
|
439
|
+
const agentProgressData = progressMessagesForMessage
|
|
440
|
+
.filter((pm): pm is ProgressMessage<AgentToolProgress> => hasProgressMessage(pm.data))
|
|
441
|
+
.map(pm => pm.data)
|
|
442
|
+
const { lookups: resultLookups } = buildSubagentLookups(agentProgressData)
|
|
443
|
+
const augmentedTools = augmentToolsFromLookups(tools, resultLookups)
|
|
444
|
+
|
|
387
445
|
return <Box flexDirection="column">
|
|
388
446
|
{"external" === 'ant' && <MessageResponse>
|
|
389
447
|
<Text color="warning">
|
|
@@ -394,13 +452,13 @@ export function renderToolResultMessage(data: Output, progressMessagesForMessage
|
|
|
394
452
|
<AgentPromptDisplay prompt={prompt} theme={theme} />
|
|
395
453
|
</MessageResponse>}
|
|
396
454
|
{isTranscriptMode ? <SubAgentProvider>
|
|
397
|
-
<VerboseAgentTranscript progressMessages={progressMessagesForMessage} tools={
|
|
455
|
+
<VerboseAgentTranscript progressMessages={progressMessagesForMessage} tools={augmentedTools} verbose={verbose} />
|
|
398
456
|
</SubAgentProvider> : null}
|
|
399
457
|
{isTranscriptMode && content && content.length > 0 && <MessageResponse>
|
|
400
458
|
<AgentResponseDisplay content={content} theme={theme} />
|
|
401
459
|
</MessageResponse>}
|
|
402
460
|
<MessageResponse height={1}>
|
|
403
|
-
<MessageComponent message={finalAssistantMessage} lookups={EMPTY_LOOKUPS} addMargin={false} tools={
|
|
461
|
+
<MessageComponent message={finalAssistantMessage} lookups={EMPTY_LOOKUPS} addMargin={false} tools={augmentedTools} commands={[]} verbose={verbose} inProgressToolUseIDs={new Set()} progressMessagesForMessage={[]} shouldAnimate={false} shouldShowDot={false} isTranscriptMode={false} isStatic={true} />
|
|
404
462
|
</MessageResponse>
|
|
405
463
|
{!isTranscriptMode && <Text dimColor>
|
|
406
464
|
{' '}
|
|
@@ -545,29 +603,7 @@ export function renderToolUseProgressMessage(progressMessages: ProgressMessage<P
|
|
|
545
603
|
// coordinator's tool set. In brain mode the coordinator only has
|
|
546
604
|
// [Agent, AskUserQuestion], but sub-agents call Read/Grep/Bash/Edit/etc.
|
|
547
605
|
// Without fallbacks, findToolByName returns null and renders blank lines.
|
|
548
|
-
const
|
|
549
|
-
let augmentedTools = tools
|
|
550
|
-
for (const block of subagentLookups.toolUseByToolUseID.values()) {
|
|
551
|
-
if (!knownToolNames.has(block.name)) {
|
|
552
|
-
knownToolNames.add(block.name)
|
|
553
|
-
const fallback = buildTool({
|
|
554
|
-
name: block.name,
|
|
555
|
-
inputSchema: z.object({}).passthrough(),
|
|
556
|
-
description: async () => `Sub-agent tool: ${block.name}`,
|
|
557
|
-
call: async () => ({ data: {} as unknown }) as any,
|
|
558
|
-
maxResultSizeChars: 100_000,
|
|
559
|
-
prompt: async () => '',
|
|
560
|
-
mapToolResultToToolResultBlockParam: (content: unknown, toolUseID: string) => ({
|
|
561
|
-
tool_use_id: toolUseID,
|
|
562
|
-
content: [{ type: 'text' as const, text: String(content) }],
|
|
563
|
-
type: 'tool_result' as const,
|
|
564
|
-
}),
|
|
565
|
-
renderToolUseMessage: () => block.name,
|
|
566
|
-
renderToolResultMessage: () => null,
|
|
567
|
-
})
|
|
568
|
-
augmentedTools = [...augmentedTools, fallback]
|
|
569
|
-
}
|
|
570
|
-
}
|
|
606
|
+
const augmentedTools = augmentToolsFromLookups(tools, subagentLookups);
|
|
571
607
|
|
|
572
608
|
return <MessageResponse>
|
|
573
609
|
<Box flexDirection="column">
|