@composio/core 0.23.0 → 0.24.0

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.
@@ -51,6 +51,7 @@ import {
51
51
  transformToolRouterToolkitsParams,
52
52
  transformToolRouterMultiAccountParams,
53
53
  transformToolRouterInstantParams,
54
+ transformToolRouterProxyExecuteParams,
54
55
  resolveToolRouterSandboxConfig,
55
56
  } from '../lib/toolRouterParams';
56
57
  import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';
@@ -282,6 +283,9 @@ export class ToolRouter<
282
283
  ),
283
284
  workbench: sandboxPayload,
284
285
  multi_account: multiAccountPayload,
286
+ ...(routerConfig.proxyExecute !== undefined && {
287
+ proxy_execute: transformToolRouterProxyExecuteParams(routerConfig.proxyExecute),
288
+ }),
285
289
  preload: routerConfig.preload,
286
290
  ...(isDirectToolsPreset && {
287
291
  search: { enable: false },
@@ -21,6 +21,7 @@ import {
21
21
  ToolRouterSessionExecuteResponseSchema,
22
22
  ToolRouterSessionProxyExecuteResponse,
23
23
  ToolRouterSessionExecuteOptions,
24
+ ToolRouterSessionMetaToolSlug,
24
25
  ToolRouterSessionConfig,
25
26
  ToolRouterSessionMetadata,
26
27
  ToolRouterSessionPreloadConfig,
@@ -71,6 +72,7 @@ import type {
71
72
  import { ToolSchema, type Tool, type ToolExecuteResponse } from '../types/tool.types';
72
73
  import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
73
74
  import type {
75
+ SessionExecuteMetaParams,
74
76
  SessionExecuteParams,
75
77
  SessionLinkParams,
76
78
  SessionPatchParams,
@@ -742,6 +744,55 @@ export class ToolRouterSession<
742
744
  return ToolRouterSessionExecuteResponseSchema.parse(transformed);
743
745
  }
744
746
 
747
+ /**
748
+ * Execute a Composio meta tool (`COMPOSIO_*`) within the session.
749
+ *
750
+ * `session.execute()` also runs meta tools. This method only accepts meta
751
+ * tool slugs, so a typo is a type error instead of a failed request. The call
752
+ * is sent to the Composio backend as is: custom tools named in a
753
+ * `COMPOSIO_MULTI_EXECUTE_TOOL` call are not run in-process here.
754
+ *
755
+ * @param slug - The meta tool slug to execute
756
+ * @param arguments_ - Optional meta tool arguments
757
+ * @returns The tool execution result, in the same shape as `session.execute()`
758
+ * @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
759
+ *
760
+ * @example
761
+ * ```typescript
762
+ * const { data, resultType } = await session.executeMeta('COMPOSIO_SEARCH_TOOLS', {
763
+ * queries: [{ use_case: 'send an email' }],
764
+ * });
765
+ * ```
766
+ */
767
+ async executeMeta(
768
+ slug: ToolRouterSessionMetaToolSlug,
769
+ arguments_?: Record<string, unknown>,
770
+ requestOptions?: ComposioRequestOptions
771
+ ): Promise<ToolRouterSessionExecuteResponse> {
772
+ const executeMetaParams: SessionExecuteMetaParams = {
773
+ slug,
774
+ arguments: arguments_ ?? {},
775
+ };
776
+ const experimental = inlineCustomToolsExperimental<SessionExecuteMetaParams.Experimental>(
777
+ this.inlineCustomToolsPayload
778
+ );
779
+ if (experimental) {
780
+ executeMetaParams.experimental = experimental;
781
+ }
782
+
783
+ const response = await withCancellation(
784
+ () =>
785
+ this.client.toolRouter.session.executeMeta(
786
+ this.sessionId,
787
+ executeMetaParams,
788
+ withoutRetries(requestOptions)
789
+ ),
790
+ requestOptions?.signal
791
+ );
792
+ const transformed = transformExecuteResponse(response, slug);
793
+ return ToolRouterSessionExecuteResponseSchema.parse(transformed);
794
+ }
795
+
745
796
  /**
746
797
  * Proxy an API call through Composio's auth layer using the session's connected account.
747
798
  * The backend resolves the connected account from the toolkit within the session.
@@ -8,6 +8,7 @@ import { ConnectedAccountExperimentalSchema } from './connectedAccounts.types';
8
8
  import type {
9
9
  SessionConfigHistoryResponse,
10
10
  SessionCreateResponse,
11
+ SessionExecuteMetaParams,
11
12
  } from '@composio/client/resources/tool-router/session/session.mjs';
12
13
  import type {
13
14
  CustomTool,
@@ -131,6 +132,12 @@ export const ToolRouterInstantSchema = z.union([
131
132
  * usage on a Session set to `false`.
132
133
  */
133
134
  returnInstantCharge: z.boolean().optional(),
135
+ /**
136
+ * Experimental. Show each Instant tool's price in Session search
137
+ * results, under `toolkitConnectionStatuses[].instantAccount.prices`.
138
+ * Controls visibility only.
139
+ */
140
+ returnPricesInSearch: z.boolean().optional(),
134
141
  })
135
142
  .strict(),
136
143
  ]);
@@ -149,7 +156,16 @@ export const ToolRouterManageConnectionsConfigSchema = z.object({
149
156
 
150
157
  // Tags
151
158
  export const ToolRouterTagsParamSchema = z
152
- .array(z.enum(['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint']))
159
+ .array(
160
+ z.enum([
161
+ 'readOnlyHint',
162
+ 'createHint',
163
+ 'updateHint',
164
+ 'destructiveHint',
165
+ 'idempotentHint',
166
+ 'openWorldHint',
167
+ ])
168
+ )
153
169
  .describe('The tags to filter the tools by');
154
170
  export const ToolRouterTagsEnableDisableSchema = z
155
171
  .object({
@@ -233,6 +249,33 @@ export const ToolRouterConfigToolsSchema = z
233
249
  });
234
250
  export type ToolRouterConfigTools = z.infer<typeof ToolRouterConfigToolsSchema>;
235
251
 
252
+ /**
253
+ * Proxy execute settings for a session. `enable: true` exposes the
254
+ * `COMPOSIO_PROXY_EXECUTE` meta tool and `enable: false` also turns off the
255
+ * sandbox `proxy_execute()` helper. Leaving the block out keeps the meta tool
256
+ * off while `sandbox.enableProxyExecution` controls the helper.
257
+ */
258
+ export const ToolRouterProxyExecuteConfigSchema = z
259
+ .object({
260
+ enable: z
261
+ .boolean()
262
+ .describe(
263
+ 'true exposes the COMPOSIO_PROXY_EXECUTE meta tool. false also turns off the sandbox proxy_execute() helper.'
264
+ ),
265
+ })
266
+ .strict();
267
+ export type ToolRouterProxyExecuteConfig = z.infer<typeof ToolRouterProxyExecuteConfigSchema>;
268
+
269
+ /**
270
+ * `proxyExecute` as accepted by `sessions.create()` and `session.update()`:
271
+ * a boolean is shorthand for `{ enable: boolean }`.
272
+ */
273
+ export const ToolRouterProxyExecuteSchema = z.union([
274
+ z.boolean(),
275
+ ToolRouterProxyExecuteConfigSchema,
276
+ ]);
277
+ export type ToolRouterProxyExecute = z.infer<typeof ToolRouterProxyExecuteSchema>;
278
+
236
279
  const ToolRouterCreateSessionConfigBaseSchema = z
237
280
  .object({
238
281
  sessionPreset: z
@@ -319,6 +362,10 @@ const ToolRouterCreateSessionConfigBaseSchema = z
319
362
  .optional()
320
363
  .describe('Multi-account configuration for this session'),
321
364
 
365
+ proxyExecute: ToolRouterProxyExecuteSchema.optional().describe(
366
+ 'Proxy execute configuration for this session; a boolean is shorthand for `{ enable }`. Rejected by the API when enable is false and sandbox.enableProxyExecution is true.'
367
+ ),
368
+
322
369
  preload: z
323
370
  .object({
324
371
  tools: z
@@ -440,6 +487,8 @@ export const ToolRouterCreateSessionConfigSchema = z
440
487
  * @param {boolean} [multiAccount.enable] - When true, enables multi-account mode. Falls back to org/project-level config when not set.
441
488
  * @param {number} [multiAccount.maxAccountsPerToolkit] - Max connected accounts per toolkit (2-10, default 5)
442
489
  * @param {boolean} [multiAccount.requireExplicitSelection] - When true, require explicit account selection when multiple accounts are connected
490
+ * @param {boolean | object} [proxyExecute] - Proxy execute configuration for this session. A boolean is shorthand for `{ enable }`.
491
+ * @param {boolean} proxyExecute.enable - `true` exposes the `COMPOSIO_PROXY_EXECUTE` meta tool. `false` also turns off the sandbox `proxy_execute()` helper.
443
492
  * @param {object} [preload] - Tools to preload into session.tools() and the MCP tool list
444
493
  * @param {string[] | 'all'} [preload.tools] - Tool slugs to preload, or "all" to preload every app tool allowed by the session filters. "all" requires a positive filter such as toolkits, tools, or tags; the backend validates and caps the final tool set.
445
494
  * @param {object} [experimental] - Experimental features configuration. Not stable; may change or be removed.
@@ -609,7 +658,24 @@ const ToolRouterSessionSearchToolkitConnectionStatusSchema = z.object({
609
658
  connectionDetails: z.record(z.string(), z.unknown()).optional(),
610
659
  currentUserInfo: z.record(z.string(), z.unknown()).optional(),
611
660
  /** Present when the toolkit runs on a Composio Instant account; only these tools run on it. */
612
- instantAccount: z.object({ allowedToolSlugs: z.array(z.string()) }).optional(),
661
+ instantAccount: z
662
+ .object({
663
+ allowedToolSlugs: z.array(z.string()),
664
+ /**
665
+ * Price of each tool, keyed by tool slug. Present only when the Session
666
+ * sets `instant.returnPricesInSearch`.
667
+ */
668
+ prices: z
669
+ .record(
670
+ z.string(),
671
+ z.object({
672
+ description: z.string().optional(),
673
+ discount: z.string().nullable().optional(),
674
+ })
675
+ )
676
+ .optional(),
677
+ })
678
+ .optional(),
613
679
  });
614
680
 
615
681
  export const ToolRouterSessionSearchResponseSchema = z.object({
@@ -709,6 +775,18 @@ export interface ToolRouterSessionExecuteOptions {
709
775
  account?: string;
710
776
  }
711
777
 
778
+ /**
779
+ * Slug of a Composio meta tool (`COMPOSIO_*`) that `session.executeMeta()` can
780
+ * run, for example `COMPOSIO_SEARCH_TOOLS`.
781
+ */
782
+ export type ToolRouterSessionMetaToolSlug = SessionExecuteMetaParams['slug'];
783
+
784
+ export type ToolRouterSessionExecuteMetaFn = (
785
+ slug: ToolRouterSessionMetaToolSlug,
786
+ arguments_?: Record<string, unknown>,
787
+ requestOptions?: ComposioRequestOptions
788
+ ) => Promise<ToolRouterSessionExecuteResponse>;
789
+
712
790
  export type ToolRouterSessionPreloadConfig = SessionCreateResponse.Config.Preload;
713
791
 
714
792
  export type ToolRouterSessionWorkbenchConfig = SessionCreateResponse.Config.Workbench;
@@ -927,6 +1005,11 @@ export const ToolRouterUpdateSessionConfigSchema = z
927
1005
  .nullable()
928
1006
  .optional()
929
1007
  .describe('`null` removes the session override; the mode then resolves to disabled'),
1008
+ proxyExecute: ToolRouterProxyExecuteSchema.nullable()
1009
+ .optional()
1010
+ .describe(
1011
+ 'Replaces the proxy execute block; a boolean is shorthand for `{ enable }` and `null` removes it'
1012
+ ),
930
1013
  preload: z
931
1014
  .object({
932
1015
  tools: z.union([z.array(z.string()), z.literal('all')]).optional(),
@@ -1137,6 +1220,8 @@ export interface Session<
1137
1220
  search: ToolRouterSessionSearchFn;
1138
1221
  /** Execute a tool within the session */
1139
1222
  execute: ToolRouterSessionExecuteFn;
1223
+ /** Execute a Composio meta tool (`COMPOSIO_*`) within the session */
1224
+ executeMeta: ToolRouterSessionExecuteMetaFn;
1140
1225
  /** Update the session configuration. Mutates this session in-place and resolves to the updated `config`. */
1141
1226
  update: ToolRouterSessionUpdateFn;
1142
1227
  /** Delete the session. Deleted sessions are no longer retrievable or executable. */
@@ -103,7 +103,10 @@ interface RawToolkitConnectionStatus {
103
103
  status_message: string;
104
104
  connection_details?: Record<string, unknown>;
105
105
  current_user_info?: Record<string, unknown>;
106
- instant_account?: { allowed_tool_slugs: string[] };
106
+ instant_account?: {
107
+ allowed_tool_slugs: string[];
108
+ prices?: Record<string, { description?: string; discount?: string | null }>;
109
+ };
107
110
  }
108
111
 
109
112
  interface RawSearchResponse {
@@ -162,7 +165,10 @@ function transformToolkitConnectionStatus(raw: RawToolkitConnectionStatus) {
162
165
  connectionDetails: raw.connection_details,
163
166
  currentUserInfo: raw.current_user_info,
164
167
  ...(raw.instant_account !== undefined && {
165
- instantAccount: { allowedToolSlugs: raw.instant_account.allowed_tool_slugs },
168
+ instantAccount: {
169
+ allowedToolSlugs: raw.instant_account.allowed_tool_slugs,
170
+ ...(raw.instant_account.prices !== undefined && { prices: raw.instant_account.prices }),
171
+ },
166
172
  }),
167
173
  };
168
174
  }