46
}
47
48
/**
49
- * Execute function for custom tools.
49
+ * Execute function for local tools.
50
* Just return the result data, or throw an error. The SDK wraps it internally.
51
*
52
* Supports two call patterns:
53
* - `(input) => data` — for tools that don't need session context
54
* - `(input, ctx) => data` — for tools that need to call other tools or proxy APIs
55
*/
56
-export type CustomToolExecuteFn<T extends AnyZodSchema> = (
56
+export type LocalToolExecuteFn<T extends AnyZodSchema> = (
57
input: InferZodSchema<T>,
58
ctx: SessionContext
59
) => Promise<Record<string, unknown>>;
60
61
+/** @deprecated Use `LocalToolExecuteFn` instead; local tools were previously called custom tools. */
62
+export type CustomToolExecuteFn<T extends AnyZodSchema> = LocalToolExecuteFn<T>;
63
+
64
/**
65
* Zod schema for validating a custom tool slug.
66
* Alphanumeric, underscores, and hyphens only. No `LOCAL_` or `COMPOSIO_` prefix.
104
),
105
});
106
104
-/** Options for creating a custom tool via `createCustomTool()`. */
105
-export type CreateCustomToolParams<T extends AnyZodSchema> = z.infer<
107
+/** Options for creating local tools via `experimental_createTool()`. */
108
+export type CreateLocalToolParams<T extends AnyZodSchema> = z.infer<
109
typeof CreateCustomToolBaseSchema
110
> & {
111
/** Zod schema for input parameters */
113
/** Optional Zod schema for output parameters (sent to backend for documentation) */
114
outputParams?: AnyZodSchema;
115
/** The function that executes the tool */
113
- execute: CustomToolExecuteFn<T>;
116
+ execute: LocalToolExecuteFn<T>;
117
};
118
119
+/** @deprecated Use `CreateLocalToolParams` instead; local tools were previously called custom tools. */
120
+export type CreateCustomToolParams<T extends AnyZodSchema> = CreateLocalToolParams<T>;
121
+
122
/**
117
- * Custom tool definition returned from `createCustomTool()`.
118
- * Pass to `composio.create(userId, { experimental: { customTools: [...] } })` to bind to a session.
123
+ * One of your local tools, returned from `experimental_createTool()`; it runs in your process.
124
+ * Pass to `composio.create(userId, { experimental: { localTools: [...] } })` to bind to a session.
125
*/
120
-export interface CustomTool {
126
+export interface LocalTool {
127
readonly slug: string;
128
readonly name: string;
129
readonly description: string;
144
/** @internal Original Zod schema — used for runtime input validation (defaults, coercions, transforms) */
145
readonly inputParams: AnyZodSchema;
146
/** Direct reference to the execute function — useful for testing */
141
- readonly execute: CustomToolExecuteFn<AnyZodSchema>;
147
+ readonly execute: LocalToolExecuteFn<AnyZodSchema>;
148
}
149
150
+/** @deprecated Use `LocalTool` instead; local tools were previously called custom tools. */
151
+export type CustomTool = LocalTool;
152
+
153
/** Serialized tool definition sent to backend for search indexing. Uses official client type. */
154
export type CustomToolDefinition = NonNullable<
155
NonNullable<SessionCreateParams['experimental']>['custom_tools']
176
),
177
});
178
170
-/** Options for creating a custom toolkit via `createCustomToolkit()`. */
171
-export type CreateCustomToolkitParams = z.infer<typeof CreateCustomToolkitBaseSchema> & {
179
+/** Options for grouping local tools into a toolkit via `experimental_createToolkit()`. */
180
+export type CreateLocalToolkitParams = z.infer<typeof CreateCustomToolkitBaseSchema> & {
181
/** Tools to include in this toolkit. Must not have `extendsToolkit` set. */
173
- tools: CustomTool[];
182
+ tools: LocalTool[];
183
};
184
185
+/** @deprecated Use `CreateLocalToolkitParams` instead; local toolkits were previously called custom toolkits. */
186
+export type CreateCustomToolkitParams = CreateLocalToolkitParams;
187
+
188
/**
177
- * Custom toolkit definition returned from `createCustomToolkit()`.
178
- * Pass to `composio.create(userId, { experimental: { customToolkits: [...] } })`.
189
+ * A toolkit of local tools returned from `experimental_createToolkit()`.
190
+ * Pass to `composio.create(userId, { experimental: { localToolkits: [...] } })`.
191
*/
180
-export interface CustomToolkit {
192
+export interface LocalToolkit {
193
readonly slug: string;
194
readonly name: string;
195
readonly description: string;
198
* Tool-level preload values override this default.
199
*/
200
readonly preload?: boolean;
189
- readonly tools: readonly CustomTool[];
201
+ readonly tools: readonly LocalTool[];
202
}
203
204
+/** @deprecated Use `LocalToolkit` instead; local toolkits were previously called custom toolkits. */
205
+export type CustomToolkit = LocalToolkit;
206
+
207
/** Serialized toolkit definition sent to backend. Uses official client type. */
208
export type CustomToolkitDefinition = NonNullable<
209
NonNullable<NonNullable<SessionCreateParams['experimental']>['custom_toolkits']>[number]
222
223
/** @internal Entry in the per-session custom tools routing map. */
224
export type CustomToolsMapEntry = {
210
- handle: CustomTool;
225
+ handle: LocalTool;
226
/** @internal The final slug assigned by the prefixing rules (e.g. LOCAL_GREP, LOCAL_GMAIL_GET_EMAILS) */
227
finalSlug: string;
228
/** Resolved toolkit — from extendsToolkit, parent custom toolkit, or undefined for standalone */
239
byToolkitAndOriginalSlug?: Map<string, CustomToolsMapEntry>;
240
/** Original slugs that appear in multiple toolkits and cannot be resolved safely without the final slug */
241
ambiguousOriginalSlugs?: Set<string>;
227
- /** The original custom toolkits passed at session creation — used for session.customToolkits() */
228
- toolkits?: CustomToolkit[];
229
- /** The original standalone custom tools passed at session creation — kept for inline re-injection on later requests. */
230
- tools?: CustomTool[];
242
+ /** The original local toolkits passed at session creation — used for session.localToolkits() */
243
+ toolkits?: LocalToolkit[];
244
+ /** The original standalone local tools passed at session creation — kept for inline re-injection on later requests. */
245
+ tools?: LocalTool[];
246
};
247
248
// ────────────────────────────────────────────────────────────────
234
-// Registered custom tool types (returned by session.customTools())
249
+// Registered local tool types (returned by session.localTools())
250
// ────────────────────────────────────────────────────────────────
251
237
-/** A custom tool as registered in a session, with its final resolved slug. */
238
-export interface RegisteredCustomTool {
252
+/** One of your local tools as registered in a session, with its final resolved slug. */
253
+export interface RegisteredLocalTool {
254
/** The final slug as registered with the backend (e.g. LOCAL_GREP, LOCAL_GMAIL_GET_EMAILS) */
255
slug: string;
256
name: string;
257
description: string;
243
- /** Resolved toolkit — extendsToolkit value, custom toolkit slug, or undefined for standalone */
258
+ /** Resolved toolkit — extendsToolkit value, local toolkit slug, or undefined for standalone */
259
toolkit?: string;
260
inputSchema: Record<string, unknown>;
261
outputSchema?: Record<string, unknown>;
262
}
263
249
-/** A custom toolkit as registered in a session, with final slugs on nested tools. */
250
-export interface RegisteredCustomToolkit {
264
+/** A toolkit of local tools as registered in a session, with final slugs on nested tools. */
265
+export interface RegisteredLocalToolkit {
266
slug: string;
267
name: string;
268
description: string;
254
- tools: RegisteredCustomTool[];
269
+ tools: RegisteredLocalTool[];
270
}
271
272
+/** @deprecated Use `RegisteredLocalTool` instead; local tools were previously called custom tools. */
273
+export type RegisteredCustomTool = RegisteredLocalTool;
274
+
275
+/** @deprecated Use `RegisteredLocalToolkit` instead; local toolkits were previously called custom toolkits. */
276
+export type RegisteredCustomToolkit = RegisteredLocalToolkit;
277
+
278
// ────────────────────────────────────────────────────────────────
279
// Response types from the backend (slug + original_slug mapping)
280
// ────────────────────────────────────────────────────────────────