@devries-cameron20 / composio-1 / commits / 22c205235
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.

refactor(core): define ToolRouterUpdateSessionConfigSchema with Zod

Same pattern as ToolRouterCreateSessionConfigSchema — own Zod schema with no defaults and nullable clearing fields. No longer references create config types that have incompatible defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Abir Taheer committed May 7, 2026 at 03:29 UTC 22c205235d6491001368b8967e2508676bd87eeb
1 file changed +55 -22
ts/packages/core/src/types/toolRouter.types.ts
+55 -22
@@ -612,28 +612,61 @@ export type ToolRouterSessionProxyExecuteFn = (
612 params: SessionProxyExecuteParams
613 ) => Promise<ToolRouterSessionProxyExecuteResponse>;
614
615 -/**
616 - * Config accepted by `session.update()`. Same camelCase shape as
617 - * `ToolRouterCreateSessionConfig` but every field is optional and
618 - * `manageConnections`, `workbench`, and `multiAccount` accept `null`
619 - * to clear the stored value. `sessionPreset` and custom tools/toolkits
620 - * are not supported on update.
621 - */
622 -export interface ToolRouterUpdateSessionConfig {
623 - toolkits?: ToolRouterCreateSessionConfig['toolkits'];
624 - tools?: ToolRouterCreateSessionConfig['tools'];
625 - tags?: ToolRouterCreateSessionConfig['tags'];
626 - authConfigs?: Record<string, string>;
627 - connectedAccounts?: Record<string, string | string[]>;
628 - manageConnections?: ToolRouterCreateSessionConfig['manageConnections'] | null;
629 - workbench?: ToolRouterCreateSessionConfig['workbench'] | null;
630 - multiAccount?: {
631 - enable?: boolean;
632 - maxAccountsPerToolkit?: number;
633 - requireExplicitSelection?: boolean;
634 - } | null;
635 - preload?: ToolRouterCreateSessionConfig['preload'];
636 -}
615 +export const ToolRouterUpdateSessionConfigSchema = z
616 + .object({
617 + toolkits: z
618 + .union([
619 + ToolRouterToolkitsParamSchema,
620 + ToolRouterToolkitsDisabledConfigSchema,
621 + ToolRouterToolkitsEnabledConfigSchema,
622 + ])
623 + .optional(),
624 + tools: z
625 + .record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema]))
626 + .optional(),
627 + tags: ToolRouterConfigTagsSchema.optional(),
628 + authConfigs: z.record(z.string(), z.string()).optional(),
629 + connectedAccounts: z
630 + .record(z.string(), z.union([z.string(), z.array(z.string())]))
631 + .transform((rec) => {
632 + const out: Record<string, string[]> = {};
633 + for (const [k, v] of Object.entries(rec)) {
634 + out[k] = typeof v === 'string' ? [v] : v;
635 + }
636 + return out;
637 + })
638 + .optional(),
639 + manageConnections: z
640 + .union([z.boolean(), ToolRouterConfigManageConnectionsSchema])
641 + .nullable()
642 + .optional(),
643 + workbench: z
644 + .object({
645 + enable: z.boolean().optional(),
646 + enableProxyExecution: z.boolean().optional(),
647 + autoOffloadThreshold: z.number().optional(),
648 + sandboxSize: SandboxSizeSchema.optional(),
649 + })
650 + .nullable()
651 + .optional(),
652 + multiAccount: z
653 + .object({
654 + enable: z.boolean().optional(),
655 + maxAccountsPerToolkit: z.number().int().min(2).max(10).optional(),
656 + requireExplicitSelection: z.boolean().optional(),
657 + })
658 + .nullable()
659 + .optional(),
660 + preload: z
661 + .object({
662 + tools: z.union([z.array(z.string()), z.literal('all')]).optional(),
663 + })
664 + .strict()
665 + .optional(),
666 + })
667 + .partial();
668 +
669 +export type ToolRouterUpdateSessionConfig = z.infer<typeof ToolRouterUpdateSessionConfigSchema>;
670
671 export type ToolRouterSessionUpdateFn = (config: ToolRouterUpdateSessionConfig) => Promise<void>;
672