@@ -7,6 +7,7 @@ import { browserLogsParams } from './params/tool/browser-logs'
77import { codeSearchParams } from './params/tool/code-search'
88import { createPlanParams } from './params/tool/create-plan'
99import { endTurnParams } from './params/tool/end-turn'
10+ import { fileUpdatesResultSchema } from './params/tool/file-updates'
1011import { findFilesParams } from './params/tool/find-files'
1112import { readDocsParams } from './params/tool/read-docs'
1213import { readFilesParams } from './params/tool/read-files'
@@ -23,7 +24,12 @@ import { updateSubgoalParams } from './params/tool/update-subgoal'
2324import { webSearchParams } from './params/tool/web-search'
2425import { writeFileParams } from './params/tool/write-file'
2526
26- import type { ToolName , $ToolParams , PublishedToolName } from './constants'
27+ import type {
28+ $ToolParams ,
29+ $ToolResults ,
30+ PublishedToolName ,
31+ ToolName ,
32+ } from './constants'
2733import type { ToolMessage } from '../types/messages/codebuff-message'
2834import type {
2935 ToolCallPart ,
@@ -56,6 +62,11 @@ export const $toolParams = {
5662 [ K in ToolName ] : $ToolParams < K >
5763}
5864
65+ export const additionalToolResultSchemas = {
66+ file_updates : fileUpdatesResultSchema ,
67+ } satisfies Record < string , $ToolResults >
68+ type ResultOnlyToolName = keyof typeof additionalToolResultSchemas
69+
5970// Tool call from LLM
6071export type CodebuffToolCall < T extends ToolName = ToolName > = {
6172 [ K in ToolName ] : {
@@ -64,19 +75,33 @@ export type CodebuffToolCall<T extends ToolName = ToolName> = {
6475 } & Omit < ToolCallPart , 'type' >
6576} [ T ]
6677
67- export type CodebuffToolOutput < T extends ToolName = ToolName > = {
68- [ K in ToolName ] : z . infer < ( typeof $toolParams ) [ K ] [ 'outputs' ] >
69- } [ T ]
70- export type CodebuffToolResult < T extends ToolName = ToolName > = {
71- [ K in ToolName ] : {
78+ export type CodebuffToolOutput <
79+ T extends ToolName | ResultOnlyToolName = ToolName ,
80+ > = T extends ToolName
81+ ? {
82+ [ K in ToolName ] : z . infer < ( typeof $toolParams ) [ K ] [ 'outputs' ] >
83+ } [ T ]
84+ : T extends ResultOnlyToolName
85+ ? {
86+ [ K in ResultOnlyToolName ] : z . infer <
87+ ( typeof additionalToolResultSchemas ) [ K ] [ 'outputs' ]
88+ >
89+ } [ T ]
90+ : never
91+ export type CodebuffToolResult <
92+ T extends ToolName | ResultOnlyToolName = ToolName ,
93+ > = {
94+ [ K in ToolName | ResultOnlyToolName ] : {
7295 toolName : K
7396 output : CodebuffToolOutput < K >
7497 } & Omit < ToolResultPart , 'type' >
7598} [ T ]
7699
77- export type CodebuffToolMessage < T extends ToolName = ToolName > = ToolMessage &
100+ export type CodebuffToolMessage <
101+ T extends ToolName | ResultOnlyToolName = ToolName ,
102+ > = ToolMessage &
78103 {
79- [ K in ToolName ] : {
104+ [ K in ToolName | ResultOnlyToolName ] : {
80105 toolName : K
81106 content : {
82107 output : CodebuffToolOutput < K >
@@ -126,4 +151,4 @@ export type ClientToolCall<T extends ClientToolName = ClientToolName> = z.infer<
126151 typeof clientToolCallSchema
127152> & { toolName : T } & Omit < ToolCallPart , 'type' >
128153
129- export type PublishedClientToolName = ClientToolName & PublishedToolName
154+ export type PublishedClientToolName = ClientToolName & PublishedToolName
0 commit comments