Skip to content

Commit 37925cc

Browse files
committed
Use lowercase Composio tool names
1 parent 8d9fd31 commit 37925cc

9 files changed

Lines changed: 85 additions & 65 deletions

File tree

common/src/constants/composio.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
export const COMPOSIO_API_KEY_ENV_VAR = 'COMPOSIO_API_KEY'
22

33
export const COMPOSIO_META_TOOL_NAMES = [
4-
'COMPOSIO_MANAGE_CONNECTIONS',
5-
'COMPOSIO_MULTI_EXECUTE_TOOL',
6-
'COMPOSIO_SEARCH_TOOLS',
7-
'COMPOSIO_GET_TOOL_SCHEMAS',
4+
'composio_manage_connections',
5+
'composio_multi_execute_tool',
6+
'composio_search_tools',
7+
'composio_get_tool_schemas',
88
] as const
99

1010
export type ComposioMetaToolName = (typeof COMPOSIO_META_TOOL_NAMES)[number]
1111

12+
export const COMPOSIO_META_TOOL_NAME_TO_UPSTREAM = {
13+
composio_manage_connections: 'COMPOSIO_MANAGE_CONNECTIONS',
14+
composio_multi_execute_tool: 'COMPOSIO_MULTI_EXECUTE_TOOL',
15+
composio_search_tools: 'COMPOSIO_SEARCH_TOOLS',
16+
composio_get_tool_schemas: 'COMPOSIO_GET_TOOL_SCHEMAS',
17+
} as const satisfies Record<ComposioMetaToolName, string>
18+
19+
export type ComposioUpstreamMetaToolName =
20+
(typeof COMPOSIO_META_TOOL_NAME_TO_UPSTREAM)[ComposioMetaToolName]
21+
1222
const COMPOSIO_META_TOOL_NAME_SET = new Set<string>(COMPOSIO_META_TOOL_NAMES)
1323

1424
export function isComposioMetaToolName(
1525
toolName: string,
1626
): toolName is ComposioMetaToolName {
1727
return COMPOSIO_META_TOOL_NAME_SET.has(toolName)
1828
}
29+
30+
export function getComposioUpstreamToolName(
31+
toolName: ComposioMetaToolName,
32+
): ComposioUpstreamMetaToolName {
33+
return COMPOSIO_META_TOOL_NAME_TO_UPSTREAM[toolName]
34+
}

common/src/tools/list.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ export const clientToolCallSchema = z.discriminatedUnion('toolName', [
154154
input: FileChangeSchema,
155155
}),
156156
z.object({
157-
toolName: z.literal('COMPOSIO_MANAGE_CONNECTIONS'),
158-
input: toolParams.COMPOSIO_MANAGE_CONNECTIONS.inputSchema,
157+
toolName: z.literal('composio_manage_connections'),
158+
input: toolParams.composio_manage_connections.inputSchema,
159159
}),
160160
z.object({
161-
toolName: z.literal('COMPOSIO_MULTI_EXECUTE_TOOL'),
162-
input: toolParams.COMPOSIO_MULTI_EXECUTE_TOOL.inputSchema,
161+
toolName: z.literal('composio_multi_execute_tool'),
162+
input: toolParams.composio_multi_execute_tool.inputSchema,
163163
}),
164164
z.object({
165-
toolName: z.literal('COMPOSIO_SEARCH_TOOLS'),
166-
input: toolParams.COMPOSIO_SEARCH_TOOLS.inputSchema,
165+
toolName: z.literal('composio_search_tools'),
166+
input: toolParams.composio_search_tools.inputSchema,
167167
}),
168168
z.object({
169-
toolName: z.literal('COMPOSIO_GET_TOOL_SCHEMAS'),
170-
input: toolParams.COMPOSIO_GET_TOOL_SCHEMAS.inputSchema,
169+
toolName: z.literal('composio_get_tool_schemas'),
170+
input: toolParams.composio_get_tool_schemas.inputSchema,
171171
}),
172172
])
173173
export const clientToolNames = clientToolCallSchema.def.options.map(

common/src/tools/params/tool/composio.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import type { $ToolParams } from '../../constants'
88
const sessionIdParam = z
99
.string()
1010
.optional()
11-
.describe('Session ID returned by COMPOSIO_SEARCH_TOOLS, when available.')
11+
.describe('Session ID returned by composio_search_tools, when available.')
1212

1313
const composioMetaToolInputSchemas = {
14-
COMPOSIO_SEARCH_TOOLS: z
14+
composio_search_tools: z
1515
.object({
1616
queries: z
1717
.array(z.unknown())
@@ -31,7 +31,7 @@ const composioMetaToolInputSchemas = {
3131
model: z.string().optional().describe('Client LLM model name.'),
3232
})
3333
.catchall(z.unknown()),
34-
COMPOSIO_GET_TOOL_SCHEMAS: z
34+
composio_get_tool_schemas: z
3535
.object({
3636
tool_slugs: z
3737
.array(z.string())
@@ -44,7 +44,7 @@ const composioMetaToolInputSchemas = {
4444
session_id: sessionIdParam,
4545
})
4646
.catchall(z.unknown()),
47-
COMPOSIO_MANAGE_CONNECTIONS: z
47+
composio_manage_connections: z
4848
.object({
4949
toolkits: z
5050
.array(z.string())
@@ -57,7 +57,7 @@ const composioMetaToolInputSchemas = {
5757
session_id: sessionIdParam,
5858
})
5959
.catchall(z.unknown()),
60-
COMPOSIO_MULTI_EXECUTE_TOOL: z
60+
composio_multi_execute_tool: z
6161
.object({
6262
tools: z
6363
.array(z.record(z.string(), z.unknown()))
@@ -77,13 +77,13 @@ const composioMetaToolInputSchemas = {
7777
}
7878

7979
const composioMetaToolDescriptions = {
80-
COMPOSIO_SEARCH_TOOLS:
80+
composio_search_tools:
8181
'Discover relevant Composio tools across external apps. Use this first for requests involving services like Gmail, GitHub, Slack, Linear, Notion, Google Calendar, or Google Sheets.',
82-
COMPOSIO_GET_TOOL_SCHEMAS:
83-
'Retrieve complete input schemas for specific Composio tool slugs returned by COMPOSIO_SEARCH_TOOLS.',
84-
COMPOSIO_MANAGE_CONNECTIONS:
82+
composio_get_tool_schemas:
83+
'Retrieve complete input schemas for specific Composio tool slugs returned by composio_search_tools.',
84+
composio_manage_connections:
8585
'Check or initiate user authentication for external app toolkits. Use when search/execution indicates a toolkit is not connected.',
86-
COMPOSIO_MULTI_EXECUTE_TOOL:
86+
composio_multi_execute_tool:
8787
'Execute one or more discovered Composio app tools in the current workflow session. Do not use workbench offloading.',
8888
}
8989

@@ -98,32 +98,32 @@ const composioOutputSchema = jsonToolResultSchema(
9898
)
9999

100100
export const composioMetaToolParams = {
101-
COMPOSIO_MANAGE_CONNECTIONS: {
102-
toolName: 'COMPOSIO_MANAGE_CONNECTIONS',
101+
composio_manage_connections: {
102+
toolName: 'composio_manage_connections',
103103
endsAgentStep: true,
104-
description: composioMetaToolDescriptions.COMPOSIO_MANAGE_CONNECTIONS,
105-
inputSchema: composioMetaToolInputSchemas.COMPOSIO_MANAGE_CONNECTIONS,
104+
description: composioMetaToolDescriptions.composio_manage_connections,
105+
inputSchema: composioMetaToolInputSchemas.composio_manage_connections,
106106
outputSchema: composioOutputSchema,
107107
},
108-
COMPOSIO_MULTI_EXECUTE_TOOL: {
109-
toolName: 'COMPOSIO_MULTI_EXECUTE_TOOL',
108+
composio_multi_execute_tool: {
109+
toolName: 'composio_multi_execute_tool',
110110
endsAgentStep: true,
111-
description: composioMetaToolDescriptions.COMPOSIO_MULTI_EXECUTE_TOOL,
112-
inputSchema: composioMetaToolInputSchemas.COMPOSIO_MULTI_EXECUTE_TOOL,
111+
description: composioMetaToolDescriptions.composio_multi_execute_tool,
112+
inputSchema: composioMetaToolInputSchemas.composio_multi_execute_tool,
113113
outputSchema: composioOutputSchema,
114114
},
115-
COMPOSIO_SEARCH_TOOLS: {
116-
toolName: 'COMPOSIO_SEARCH_TOOLS',
115+
composio_search_tools: {
116+
toolName: 'composio_search_tools',
117117
endsAgentStep: true,
118-
description: composioMetaToolDescriptions.COMPOSIO_SEARCH_TOOLS,
119-
inputSchema: composioMetaToolInputSchemas.COMPOSIO_SEARCH_TOOLS,
118+
description: composioMetaToolDescriptions.composio_search_tools,
119+
inputSchema: composioMetaToolInputSchemas.composio_search_tools,
120120
outputSchema: composioOutputSchema,
121121
},
122-
COMPOSIO_GET_TOOL_SCHEMAS: {
123-
toolName: 'COMPOSIO_GET_TOOL_SCHEMAS',
122+
composio_get_tool_schemas: {
123+
toolName: 'composio_get_tool_schemas',
124124
endsAgentStep: true,
125-
description: composioMetaToolDescriptions.COMPOSIO_GET_TOOL_SCHEMAS,
126-
inputSchema: composioMetaToolInputSchemas.COMPOSIO_GET_TOOL_SCHEMAS,
125+
description: composioMetaToolDescriptions.composio_get_tool_schemas,
126+
inputSchema: composioMetaToolInputSchemas.composio_get_tool_schemas,
127127
outputSchema: composioOutputSchema,
128128
},
129129
} satisfies {

packages/agent-runtime/src/tools/handlers/list.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export const codebuffToolHandlers: {
6161
ask_user: handleAskUser,
6262
browser_logs: handleBrowserLogs,
6363
code_search: handleCodeSearch,
64-
COMPOSIO_MANAGE_CONNECTIONS: handleComposioManageConnections,
65-
COMPOSIO_MULTI_EXECUTE_TOOL: handleComposioMultiExecute,
66-
COMPOSIO_SEARCH_TOOLS: handleComposioSearchTools,
67-
COMPOSIO_GET_TOOL_SCHEMAS: handleComposioGetToolSchemas,
64+
composio_manage_connections: handleComposioManageConnections,
65+
composio_multi_execute_tool: handleComposioMultiExecute,
66+
composio_search_tools: handleComposioSearchTools,
67+
composio_get_tool_schemas: handleComposioGetToolSchemas,
6868
create_plan: handleCreatePlan,
6969
end_turn: handleEndTurn,
7070
find_files: handleFindFiles,

packages/agent-runtime/src/tools/handlers/tool/composio.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ function makeComposioHandler<
2727
}
2828
}
2929

30-
export const handleComposioManageConnections: CodebuffToolHandlerFunction<'COMPOSIO_MANAGE_CONNECTIONS'> =
31-
makeComposioHandler<'COMPOSIO_MANAGE_CONNECTIONS'>()
32-
export const handleComposioMultiExecute: CodebuffToolHandlerFunction<'COMPOSIO_MULTI_EXECUTE_TOOL'> =
33-
makeComposioHandler<'COMPOSIO_MULTI_EXECUTE_TOOL'>()
34-
export const handleComposioSearchTools: CodebuffToolHandlerFunction<'COMPOSIO_SEARCH_TOOLS'> =
35-
makeComposioHandler<'COMPOSIO_SEARCH_TOOLS'>()
36-
export const handleComposioGetToolSchemas: CodebuffToolHandlerFunction<'COMPOSIO_GET_TOOL_SCHEMAS'> =
37-
makeComposioHandler<'COMPOSIO_GET_TOOL_SCHEMAS'>()
30+
export const handleComposioManageConnections: CodebuffToolHandlerFunction<'composio_manage_connections'> =
31+
makeComposioHandler<'composio_manage_connections'>()
32+
export const handleComposioMultiExecute: CodebuffToolHandlerFunction<'composio_multi_execute_tool'> =
33+
makeComposioHandler<'composio_multi_execute_tool'>()
34+
export const handleComposioSearchTools: CodebuffToolHandlerFunction<'composio_search_tools'> =
35+
makeComposioHandler<'composio_search_tools'>()
36+
export const handleComposioGetToolSchemas: CodebuffToolHandlerFunction<'composio_get_tool_schemas'> =
37+
makeComposioHandler<'composio_get_tool_schemas'>()

sdk/src/__tests__/composio.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Composio SDK tools', () => {
3232
'Content-Type': 'application/json',
3333
})
3434
expect(JSON.parse(String(init?.body))).toEqual({
35-
toolName: 'COMPOSIO_SEARCH_TOOLS',
35+
toolName: 'composio_search_tools',
3636
input: {
3737
queries: ['find gmail tools'],
3838
session: { generate_id: true },
@@ -50,7 +50,7 @@ describe('Composio SDK tools', () => {
5050

5151
const output = await executeComposioToolViaServer({
5252
apiKey: 'codebuff-api-key',
53-
toolName: 'COMPOSIO_SEARCH_TOOLS',
53+
toolName: 'composio_search_tools',
5454
input: {
5555
queries: ['find gmail tools'],
5656
session: { generate_id: true },
@@ -68,7 +68,7 @@ describe('Composio SDK tools', () => {
6868

6969
const output = await executeComposioToolViaServer({
7070
apiKey: 'codebuff-api-key',
71-
toolName: 'COMPOSIO_SEARCH_TOOLS',
71+
toolName: 'composio_search_tools',
7272
input: {
7373
queries: ['find gmail tools'],
7474
session: { generate_id: true },

web/src/app/api/v1/composio/__tests__/composio.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('/api/v1/composio', () => {
8686
method: 'POST',
8787
headers: { Authorization: 'Bearer valid-key' },
8888
body: JSON.stringify({
89-
toolName: 'COMPOSIO_SEARCH_TOOLS',
89+
toolName: 'composio_search_tools',
9090
input: {
9191
queries: ['find gmail tools'],
9292
session: { generate_id: true },
@@ -110,7 +110,7 @@ describe('/api/v1/composio', () => {
110110
db: mockDb,
111111
userId: 'user-123',
112112
logger,
113-
toolName: 'COMPOSIO_SEARCH_TOOLS',
113+
toolName: 'composio_search_tools',
114114
input: {
115115
queries: ['find gmail tools'],
116116
session: { generate_id: true },
@@ -127,7 +127,7 @@ describe('/api/v1/composio', () => {
127127
method: 'POST',
128128
headers: { Authorization: 'Bearer valid-key' },
129129
body: JSON.stringify({
130-
toolName: 'COMPOSIO_SEARCH_TOOLS',
130+
toolName: 'composio_search_tools',
131131
input: {},
132132
}),
133133
})
@@ -158,7 +158,7 @@ describe('/api/v1/composio', () => {
158158
method: 'POST',
159159
headers: { Authorization: 'Bearer valid-key' },
160160
body: JSON.stringify({
161-
toolName: 'COMPOSIO_SEARCH_TOOLS',
161+
toolName: 'composio_search_tools',
162162
input: {},
163163
}),
164164
})
@@ -243,7 +243,7 @@ describe('/api/v1/composio', () => {
243243
method: 'POST',
244244
headers: { Authorization: 'Bearer banned-key' },
245245
body: JSON.stringify({
246-
toolName: 'COMPOSIO_SEARCH_TOOLS',
246+
toolName: 'composio_search_tools',
247247
input: {},
248248
}),
249249
})

web/src/server/__tests__/composio.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('executeComposioTool', () => {
109109
userId: 'user-123',
110110
logger,
111111
apiKey: 'test-composio-api-key',
112-
toolName: 'COMPOSIO_SEARCH_TOOLS',
112+
toolName: 'composio_search_tools',
113113
input: { queries: ['gmail'], session: { generate_id: true } },
114114
})
115115

@@ -138,7 +138,7 @@ describe('executeComposioTool', () => {
138138
userId: 'user-123',
139139
logger,
140140
apiKey: 'test-composio-api-key',
141-
toolName: 'COMPOSIO_SEARCH_TOOLS',
141+
toolName: 'composio_search_tools',
142142
input: { queries: ['gmail'], session: { generate_id: true } },
143143
})
144144

@@ -166,7 +166,7 @@ describe('executeComposioTool', () => {
166166
userId: 'user-123',
167167
logger,
168168
apiKey: 'test-composio-api-key',
169-
toolName: 'COMPOSIO_MULTI_EXECUTE_TOOL',
169+
toolName: 'composio_multi_execute_tool',
170170
input: {
171171
tools: [{ slug: 'GMAIL_FETCH_EMAILS', arguments: {} }],
172172
sync_response_to_workbench: true,
@@ -195,7 +195,7 @@ describe('executeComposioTool', () => {
195195
userId: 'user-123',
196196
logger,
197197
apiKey: 'test-composio-api-key',
198-
toolName: 'COMPOSIO_SEARCH_TOOLS',
198+
toolName: 'composio_search_tools',
199199
input: { queries: ['gmail'], session: { generate_id: true } },
200200
}),
201201
).rejects.toThrow('Composio unavailable')

web/src/server/composio.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { existsSync, readFileSync } from 'fs'
44
import { homedir } from 'os'
55
import path from 'path'
66

7-
import { COMPOSIO_API_KEY_ENV_VAR } from '@codebuff/common/constants/composio'
7+
import {
8+
COMPOSIO_API_KEY_ENV_VAR,
9+
getComposioUpstreamToolName,
10+
} from '@codebuff/common/constants/composio'
811
import { getErrorObject } from '@codebuff/common/util/error'
912
import { env } from '@codebuff/internal/env'
1013
import * as schema from '@codebuff/internal/db/schema'
@@ -312,13 +315,14 @@ export async function executeComposioTool(params: {
312315

313316
try {
314317
const input =
315-
params.toolName === 'COMPOSIO_MULTI_EXECUTE_TOOL'
318+
params.toolName === 'composio_multi_execute_tool'
316319
? {
317320
...params.input,
318321
sync_response_to_workbench: false,
319322
}
320323
: params.input
321-
const result = await cached.session.execute(params.toolName, input)
324+
const upstreamToolName = getComposioUpstreamToolName(params.toolName)
325+
const result = await cached.session.execute(upstreamToolName, input)
322326
return [{ type: 'json', value: toJsonValue(result) }]
323327
} catch (error) {
324328
params.logger.warn(

0 commit comments

Comments
 (0)