@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 26 lines 1.02 KB
Raw
1 /**
2 * @fileoverview Shared transform for converting SDK SessionProxyExecuteParams
3 * to the official @composio/client proxy execute params.
4 */
5 import type { SessionProxyExecuteParams } from '../types/toolRouter.types';
6 import type { SessionProxyExecuteParams as ClientProxyExecuteParams } from '@composio/client/resources/tool-router/session';
7
8 /**
9 * Transform SDK session proxy params to the official client request format.
10 * Converts SDK-facing `toolkit` → `toolkit_slug` and `parameters[].in` → `parameters[].type`.
11 */
12 export function transformProxyParams(params: SessionProxyExecuteParams): ClientProxyExecuteParams {
13 const parameters: ClientProxyExecuteParams['parameters'] = params.parameters?.map(p => ({
14 name: p.name,
15 type: p.in as 'header' | 'query',
16 value: p.value.toString(),
17 }));
18
19 return {
20 toolkit_slug: params.toolkit,
21 endpoint: params.endpoint,
22 method: params.method,
23 ...(params.body !== undefined ? { body: params.body } : {}),
24 ...(parameters?.length ? { parameters } : {}),
25 };
26 }