mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(tooling): preserve native tool titles (#1133)
This commit is contained in:
@@ -444,6 +444,7 @@ describe('AcpMessageHandler', () => {
|
||||
);
|
||||
expect(toolCall).toBeDefined();
|
||||
expect(toolCall!.input).toEqual({ command: 'df -hT' });
|
||||
expect(toolCall).toMatchObject({ title: 'df -hT', kind: 'execute' });
|
||||
});
|
||||
|
||||
it('strips "Shell: " prefix from title when deriving execute input (Kimi)', () => {
|
||||
|
||||
@@ -704,7 +704,9 @@ export class AcpMessageHandler {
|
||||
id: toolCallId,
|
||||
name,
|
||||
input,
|
||||
status
|
||||
status,
|
||||
...(asString(update.title) ? { title: asString(update.title)! } : {}),
|
||||
...(asString(update.kind) ? { kind: asString(update.kind)! } : {})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -714,6 +716,10 @@ export class AcpMessageHandler {
|
||||
|
||||
const status = normalizeStatus(update.status);
|
||||
const existing = this.toolCalls.get(toolCallId);
|
||||
const presentation = {
|
||||
...(asString(update.title) ? { title: asString(update.title)! } : {}),
|
||||
...(asString(update.kind) ? { kind: asString(update.kind)! } : {})
|
||||
};
|
||||
|
||||
if (isUsableRawInput(update.rawInput)) {
|
||||
const derivedName = deriveToolNameFromUpdate(update);
|
||||
@@ -725,7 +731,8 @@ export class AcpMessageHandler {
|
||||
id: toolCallId,
|
||||
name,
|
||||
input,
|
||||
status
|
||||
status,
|
||||
...presentation
|
||||
});
|
||||
} else if (existing) {
|
||||
// Enrich existing.input from update's kind+title when initial tool_call
|
||||
@@ -758,7 +765,8 @@ export class AcpMessageHandler {
|
||||
id: toolCallId,
|
||||
name,
|
||||
input,
|
||||
status
|
||||
status,
|
||||
...presentation
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -784,7 +792,8 @@ export class AcpMessageHandler {
|
||||
id: toolCallId,
|
||||
name: hoisted.name,
|
||||
input: hoisted.input,
|
||||
status
|
||||
status,
|
||||
...presentation
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,23 @@ describe('convertAgentMessage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('preserves ACP native presentation metadata', () => {
|
||||
const converted = convertAgentMessage({
|
||||
type: 'tool_call',
|
||||
id: 'call-native',
|
||||
name: 'Bash',
|
||||
input: { command: 'free -h' },
|
||||
status: 'in_progress',
|
||||
title: 'Shell: free -h',
|
||||
kind: 'execute'
|
||||
});
|
||||
|
||||
expect(converted).toMatchObject({
|
||||
nativeTitle: 'Shell: free -h',
|
||||
nativeKind: 'execute'
|
||||
});
|
||||
});
|
||||
|
||||
it('marks failed tool results as error', () => {
|
||||
const converted = convertAgentMessage({
|
||||
type: 'tool_result',
|
||||
|
||||
@@ -24,6 +24,8 @@ export type CodexMessage =
|
||||
callId: string;
|
||||
input: unknown;
|
||||
status?: 'pending' | 'in_progress' | 'completed' | 'failed';
|
||||
nativeTitle?: string;
|
||||
nativeKind?: string;
|
||||
}
|
||||
| {
|
||||
type: 'tool-call-result';
|
||||
@@ -64,7 +66,9 @@ export function convertAgentMessage(message: AgentMessage): CodexMessage | null
|
||||
name: message.name,
|
||||
callId: message.id,
|
||||
input: message.input,
|
||||
status: message.status
|
||||
status: message.status,
|
||||
...(message.title ? { nativeTitle: message.title } : {}),
|
||||
...(message.kind ? { nativeKind: message.kind } : {})
|
||||
};
|
||||
case 'tool_result':
|
||||
return {
|
||||
|
||||
@@ -31,7 +31,15 @@ export type PlanItem = {
|
||||
export type AgentMessage =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'reasoning'; text: string; id?: string; live?: boolean }
|
||||
| { type: 'tool_call'; id: string; name: string; input: unknown; status: 'pending' | 'in_progress' | 'completed' | 'failed' }
|
||||
| {
|
||||
type: 'tool_call';
|
||||
id: string;
|
||||
name: string;
|
||||
input: unknown;
|
||||
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
||||
title?: string;
|
||||
kind?: string;
|
||||
}
|
||||
| { type: 'tool_result'; id: string; output: unknown; status: 'completed' | 'failed' }
|
||||
| {
|
||||
type: 'usage';
|
||||
|
||||
Reference in New Issue
Block a user