@composio/core 0.19.0 → 0.20.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.
Files changed (87) hide show
  1. package/dist/{CustomTool-CB5vm1Jc.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
  2. package/dist/{CustomTool-BMlZfJVz.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
  3. package/dist/{FileModifierErrors-BqFmpRsm.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
  4. package/dist/{SsrfErrors-C91YhASE.mjs → SsrfErrors-DiQldIdC.mjs} +18 -7
  5. package/dist/{Telemetry-HlftxMx6.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
  6. package/dist/{cancellation-CXpfmiVo.mjs → cancellation-Dwa9lGHA.mjs} +2 -2
  7. package/dist/{composio-DLGaeN70.d.mts → composio-B36OXii1.d.mts} +2691 -119
  8. package/dist/{customTool.types-BAmEh3MB.d.mts → customTool.types-C436M_D0.d.mts} +431 -98
  9. package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
  10. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +5 -2
  11. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
  12. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
  13. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
  14. package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
  15. package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
  16. package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
  17. package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
  18. package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
  19. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
  20. package/dist/docs/reference/sdk-reference/typescript/session.mdx +77 -27
  21. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
  22. package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +149 -12
  23. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
  24. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
  25. package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
  26. package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
  27. package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
  28. package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
  29. package/dist/{errors-BuEKehbI.mjs → errors-D_A4b2c2.mjs} +123 -4
  30. package/dist/experimental/index.d.mts +2 -2
  31. package/dist/experimental/index.mjs +1 -1
  32. package/dist/{fileUtils.node-L7XD8UPr.mjs → fileUtils.node-DNLhLg0W.mjs} +4 -4
  33. package/dist/index.d.mts +264 -51
  34. package/dist/index.mjs +2338 -168
  35. package/dist/models/Files.node.mjs +2 -2
  36. package/dist/{sensitiveFileUploadPaths-B6pBt9lO.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +1 -1
  37. package/dist/{ssrfGuard.node-B9xQB4za.mjs → ssrfGuard.node-BZ270bcu.mjs} +1 -1
  38. package/dist/{types-CxLPO0Xq.d.mts → types-Br3GBya5.d.mts} +2 -2
  39. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  40. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  41. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  42. package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
  43. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  44. package/dist/utils/ssrfGuard.node.mjs +1 -1
  45. package/dist/utils/ssrfGuard.workerd.mjs +1 -1
  46. package/package.json +2 -2
  47. package/src/composio.ts +207 -10
  48. package/src/errors/ConnectedAccountsErrors.ts +47 -0
  49. package/src/errors/SDKErrors.ts +52 -0
  50. package/src/errors/ToolRouterErrors.ts +57 -0
  51. package/src/errors/index.ts +3 -0
  52. package/src/index.ts +11 -0
  53. package/src/lib/toolRouterMcp.ts +132 -0
  54. package/src/lib/toolRouterParams.ts +116 -29
  55. package/src/models/ConnectedAccounts.ts +118 -2
  56. package/src/models/CustomToolkits.ts +169 -0
  57. package/src/models/Experimental.ts +27 -0
  58. package/src/models/Keyring.ts +65 -0
  59. package/src/models/Logs.ts +101 -0
  60. package/src/models/ToolRouter.ts +42 -14
  61. package/src/models/ToolRouterSession.ts +120 -9
  62. package/src/models/Toolkits.ts +180 -0
  63. package/src/models/Tools.ts +3 -1
  64. package/src/models/Triggers.ts +3 -88
  65. package/src/models/Usage.ts +119 -0
  66. package/src/models/Webhooks.ts +520 -0
  67. package/src/services/pusher/Pusher.ts +17 -6
  68. package/src/types/authConfigs.types.ts +2 -0
  69. package/src/types/connectedAccounts.types.ts +54 -0
  70. package/src/types/customToolkits.types.ts +102 -0
  71. package/src/types/keyring.types.ts +32 -0
  72. package/src/types/logs.types.ts +108 -0
  73. package/src/types/toolRouter.types.ts +205 -11
  74. package/src/types/toolkit.types.ts +144 -0
  75. package/src/types/usage.types.ts +81 -0
  76. package/src/types/webhooks.types.ts +143 -0
  77. package/src/utils/constants.ts +1 -5
  78. package/src/utils/logger.ts +39 -7
  79. package/src/utils/sdk.ts +385 -22
  80. package/src/utils/transformers/connectedAccounts.ts +37 -2
  81. package/src/utils/transformers/customToolkits.ts +98 -0
  82. package/src/utils/transformers/keyring.ts +24 -0
  83. package/src/utils/transformers/logs.ts +85 -0
  84. package/src/utils/transformers/toolkits.ts +106 -3
  85. package/src/utils/transformers/triggers.ts +2 -2
  86. package/src/utils/transformers/usage.ts +77 -0
  87. package/src/utils/transformers/webhooks.ts +139 -0
@@ -0,0 +1,102 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * How end users authenticate to a custom toolkit.
5
+ * **Experimental — custom toolkits are in pilot; shape may change.**
6
+ */
7
+ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
8
+ z.object({ mode: z.literal('NO_AUTH') }),
9
+ z.object({
10
+ mode: z.literal('API_KEY'),
11
+ /**
12
+ * Headers sent with each request. Write `{{generic_api_key}}` where the
13
+ * end user's API key goes, for example
14
+ * `{ Authorization: 'Bearer {{generic_api_key}}' }`.
15
+ */
16
+ headers: z.record(z.string(), z.string()),
17
+ /** End-user copy for the API key input on the connect page. */
18
+ apiKeyField: z
19
+ .object({
20
+ displayName: z.string().min(1).max(100).optional(),
21
+ description: z.string().min(1).max(500).optional(),
22
+ })
23
+ .optional(),
24
+ }),
25
+ z.object({
26
+ mode: z.literal('DCR_OAUTH'),
27
+ /**
28
+ * Where to fetch the full auth scheme, usually the
29
+ * `/.well-known/oauth-authorization-server` path of your MCP URL.
30
+ */
31
+ discoveryUrl: z.string().url(),
32
+ }),
33
+ ]);
34
+ export type CustomToolkitAuthScheme = z.infer<typeof CustomToolkitAuthSchemeSchema>;
35
+
36
+ /**
37
+ * Params for `composio.experimental.customToolkits.upsert()`.
38
+ * **Experimental — custom toolkits are in pilot; shape may change.**
39
+ */
40
+ export const CustomToolkitUpsertParamsSchema = z.object({
41
+ /**
42
+ * Letters, digits, underscores or spaces, up to 30 characters. The API
43
+ * prefixes it with `CUSTOM_` and turns spaces into underscores.
44
+ */
45
+ slug: z
46
+ .string()
47
+ .min(1)
48
+ .max(30)
49
+ .regex(/^[a-zA-Z0-9_\s]+$/),
50
+ toolkitConfig: z.object({
51
+ /** Human-readable toolkit name. */
52
+ name: z.string().min(1).max(200),
53
+ /** The app URL. For an MCP app, the MCP server URL. */
54
+ appUrl: z.string().url(),
55
+ /** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
56
+ logoFile: z
57
+ .object({
58
+ content: z.string().min(1),
59
+ mimeType: z.enum(['image/png', 'image/jpeg']),
60
+ })
61
+ .optional(),
62
+ /** At least one scheme. The schemes cannot change once the toolkit exists. */
63
+ authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
64
+ }),
65
+ });
66
+ export type CustomToolkitUpsertParams = z.infer<typeof CustomToolkitUpsertParamsSchema>;
67
+
68
+ export const CustomToolkitUpsertResponseSchema = z.object({
69
+ /** Slug of the created or updated toolkit. */
70
+ slug: z.string(),
71
+ });
72
+ export type CustomToolkitUpsertResponse = z.infer<typeof CustomToolkitUpsertResponseSchema>;
73
+
74
+ /**
75
+ * Params for `composio.experimental.customToolkits.sync()`.
76
+ * **Experimental — custom toolkits are in pilot; shape may change.**
77
+ */
78
+ export const CustomToolkitSyncParamsSchema = z.object({
79
+ /** Connected account to use when fetching the remote tool definitions. */
80
+ connectedAccountId: z.string().optional(),
81
+ });
82
+ export type CustomToolkitSyncParams = z.infer<typeof CustomToolkitSyncParamsSchema>;
83
+
84
+ export const CustomToolkitSyncResponseSchema = z.object({
85
+ slug: z.string(),
86
+ /** Toolkit version after the sync. */
87
+ version: z.string(),
88
+ /** Number of tools synced. */
89
+ syncedCount: z.number(),
90
+ });
91
+ export type CustomToolkitSyncResponse = z.infer<typeof CustomToolkitSyncResponseSchema>;
92
+
93
+ export const CustomToolkitDeleteResponseSchema = z.object({
94
+ /** Slug of the deleted toolkit. */
95
+ slug: z.string(),
96
+ deleted: z.boolean(),
97
+ /** Background jobs revoking the credentials of the toolkit's connected accounts. */
98
+ revokeJobIds: z.array(z.string()),
99
+ authConfigsDeleted: z.number(),
100
+ connectedAccountsDeleted: z.number(),
101
+ });
102
+ export type CustomToolkitDeleteResponse = z.infer<typeof CustomToolkitDeleteResponseSchema>;
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * A public JWK a secret can be sealed to. Fields keep their JWK names so a
5
+ * key can be handed straight to WebCrypto or a JOSE library.
6
+ */
7
+ export const KeyringTransferKeySchema = z.object({
8
+ /** Key type. Always `RSA`. */
9
+ kty: z.string(),
10
+ /** RSA modulus, base64url-encoded. */
11
+ n: z.string(),
12
+ /** RSA public exponent, base64url-encoded. */
13
+ e: z.string(),
14
+ /** Key-management algorithm for the JWE (`RSA-OAEP-256`). Pair it with `A256GCM` content encryption. */
15
+ alg: z.string(),
16
+ /** Key use. Always `enc`. */
17
+ use: z.string(),
18
+ /** Key identifier. Put it in the JWE protected header. */
19
+ kid: z.string(),
20
+ });
21
+ export type KeyringTransferKey = z.infer<typeof KeyringTransferKeySchema>;
22
+
23
+ /**
24
+ * Response of `composio.keyring.listTransferKeys()`.
25
+ */
26
+ export const KeyringTransferKeysResponseSchema = z.object({
27
+ /** The `kid` of the key to seal new secrets to. */
28
+ activeKid: z.string(),
29
+ /** Every currently accepted transfer key, newest first. */
30
+ keys: z.array(KeyringTransferKeySchema),
31
+ });
32
+ export type KeyringTransferKeysResponse = z.infer<typeof KeyringTransferKeysResponseSchema>;
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * Fields a tool-execution log search can filter on.
5
+ */
6
+ export const LogSearchFilterFieldSchema = z.enum([
7
+ 'tool_slug',
8
+ 'toolkit_slug',
9
+ 'connected_account_id',
10
+ 'auth_config_id',
11
+ 'status',
12
+ 'user_id',
13
+ 'session_id',
14
+ 'sandbox_id',
15
+ 'request_id',
16
+ 'log_id',
17
+ ]);
18
+ export type LogSearchFilterField = z.infer<typeof LogSearchFilterFieldSchema>;
19
+
20
+ export const LogSearchFilterOperatorSchema = z.enum(['==', '!=', 'contains', 'not_contains']);
21
+ export type LogSearchFilterOperator = z.infer<typeof LogSearchFilterOperatorSchema>;
22
+
23
+ export const LogSearchFilterSchema = z.object({
24
+ field: LogSearchFilterFieldSchema,
25
+ operator: LogSearchFilterOperatorSchema,
26
+ value: z.string(),
27
+ });
28
+ export type LogSearchFilter = z.infer<typeof LogSearchFilterSchema>;
29
+
30
+ export const LogSearchTimeRangeSchema = z.object({
31
+ /** Start time in epoch milliseconds (inclusive). */
32
+ from: z.number(),
33
+ /** End time in epoch milliseconds. */
34
+ to: z.number(),
35
+ });
36
+ export type LogSearchTimeRange = z.infer<typeof LogSearchTimeRangeSchema>;
37
+
38
+ /**
39
+ * Params for `composio.logs.search()`.
40
+ */
41
+ export const LogSearchParamsSchema = z.object({
42
+ limit: z.number().optional(),
43
+ cursor: z.string().nullable().optional(),
44
+ filters: z.array(LogSearchFilterSchema).optional(),
45
+ timeRange: LogSearchTimeRangeSchema.optional(),
46
+ });
47
+ export type LogSearchParams = z.infer<typeof LogSearchParamsSchema>;
48
+
49
+ export const ToolExecutionLogStatusSchema = z.enum(['success', 'failed']);
50
+ export const ToolExecutionLogLevelSchema = z.enum(['info', 'error', 'warn']);
51
+
52
+ export const ToolExecutionLogParentSchema = z
53
+ .object({
54
+ logId: z.string(),
55
+ toolSlug: z.string(),
56
+ })
57
+ .nullable();
58
+
59
+ /**
60
+ * A tool-execution log entry as returned by `composio.logs.search()`.
61
+ */
62
+ export const ToolExecutionLogSchema = z.object({
63
+ id: z.string(),
64
+ /** ISO 8601 timestamp. */
65
+ timestamp: z.string(),
66
+ /** Log event type, e.g. `tool.execution`. */
67
+ type: z.string(),
68
+ status: ToolExecutionLogStatusSchema,
69
+ level: ToolExecutionLogLevelSchema,
70
+ message: z.string().optional(),
71
+ metadata: z.record(z.string(), z.unknown()),
72
+ metrics: z.record(z.string(), z.unknown()),
73
+ parent: ToolExecutionLogParentSchema,
74
+ });
75
+ export type ToolExecutionLog = z.infer<typeof ToolExecutionLogSchema>;
76
+
77
+ export const LogSearchResponseSchema = z.object({
78
+ logs: z.array(ToolExecutionLogSchema),
79
+ nextCursor: z.string().nullable(),
80
+ });
81
+ export type LogSearchResponse = z.infer<typeof LogSearchResponseSchema>;
82
+
83
+ /**
84
+ * A single tool-execution log with its full detail, as returned by
85
+ * `composio.logs.get()`.
86
+ */
87
+ export const ToolExecutionLogDetailSchema = ToolExecutionLogSchema.extend({
88
+ timings: z
89
+ .object({
90
+ /** Epoch milliseconds. */
91
+ startTime: z.number(),
92
+ /** Epoch milliseconds. */
93
+ endTime: z.number(),
94
+ })
95
+ .optional(),
96
+ context: z.object({
97
+ sessionId: z.string().optional(),
98
+ traceId: z.string().optional(),
99
+ requestId: z.string().optional(),
100
+ }),
101
+ source: z.object({
102
+ host: z.string().optional(),
103
+ framework: z.string().optional(),
104
+ language: z.string().optional(),
105
+ }),
106
+ data: z.record(z.string(), z.unknown()),
107
+ });
108
+ export type ToolExecutionLogDetail = z.infer<typeof ToolExecutionLogDetailSchema>;
@@ -4,8 +4,11 @@ import { SessionMetaToolOptions } from './modifiers.types';
4
4
  import { ConnectionRequest } from './connectionRequest.types';
5
5
  import type { ComposioRequestOptions } from './requestOptions.types';
6
6
  import type { ToolRouterSessionFilesMount } from '../models/ToolRouterSessionFileMount';
7
- import type { SessionCreateResponse } from '@composio/client/resources/tool-router/session/session.mjs';
8
7
  import { ConnectedAccountExperimentalSchema } from './connectedAccounts.types';
8
+ import type {
9
+ SessionConfigHistoryResponse,
10
+ SessionCreateResponse,
11
+ } from '@composio/client/resources/tool-router/session/session.mjs';
9
12
  import type {
10
13
  CustomTool,
11
14
  CustomToolkit,
@@ -214,7 +217,7 @@ const ToolRouterCreateSessionConfigBaseSchema = z
214
217
  .boolean()
215
218
  .optional()
216
219
  .describe(
217
- 'When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp'
220
+ 'When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type, and an MCP URL that is not on the API base URL origin throws `ComposioMCPDestinationError` instead of leaving `session.mcp.headers` empty with a warning. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp'
218
221
  ),
219
222
 
220
223
  tools: z
@@ -652,6 +655,107 @@ export type ToolRouterSessionProxyExecuteFn = (
652
655
  params: SessionProxyExecuteParams
653
656
  ) => Promise<ToolRouterSessionProxyExecuteResponse>;
654
657
 
658
+ /**
659
+ * `manageConnections` shape accepted by `session.update()`. Unlike the create
660
+ * schema, `callbackUrl: null` removes the stored callback URL while leaving
661
+ * the sibling connection settings untouched.
662
+ */
663
+ export const ToolRouterUpdateManageConnectionsSchema = z
664
+ .object({
665
+ enable: z
666
+ .boolean()
667
+ .optional()
668
+ .describe(
669
+ 'Whether to use tools to manage connections in the tool router session. Defaults to true, if set to false, you need to manage connections manually'
670
+ ),
671
+ callbackUrl: z
672
+ .string()
673
+ .nullable()
674
+ .optional()
675
+ .describe(
676
+ 'The callback url to use in the tool router session. `null` removes the stored callback url; sibling settings are untouched'
677
+ ),
678
+ waitForConnections: z
679
+ .boolean()
680
+ .optional()
681
+ .describe(
682
+ 'Whether to wait for users to finish authenticating connections before proceeding to the next step. Defaults to false, if set to true, a wait for connections tool call will happen and finish when the connections are ready'
683
+ ),
684
+ enableConnectionRemoval: z
685
+ .boolean()
686
+ .nullable()
687
+ .optional()
688
+ .describe(
689
+ 'Whether the session exposes the connection removal tool. `null` removes the stored override'
690
+ ),
691
+ })
692
+ .strict();
693
+ export type ToolRouterUpdateManageConnectionsConfig = z.infer<
694
+ typeof ToolRouterUpdateManageConnectionsSchema
695
+ >;
696
+
697
+ const ToolRouterElicitationDefaultSchema = z.enum([
698
+ 'allow_all',
699
+ 'ask_every_call',
700
+ 'ask_once_per_session',
701
+ ]);
702
+ const ToolRouterElicitationOverrideSchema = z.enum([
703
+ 'always_allow',
704
+ 'always_deny',
705
+ 'ask_once',
706
+ 'ask_always',
707
+ ]);
708
+
709
+ /**
710
+ * `experimental` block accepted by `session.update()`. Each leaf follows the
711
+ * PATCH contract of the API: omit to keep the stored value, `null` to remove
712
+ * it, a value to replace it.
713
+ */
714
+ export const ToolRouterUpdateExperimentalSchema = z
715
+ .object({
716
+ permissions: z
717
+ .object({
718
+ default: ToolRouterElicitationDefaultSchema,
719
+ overrides: z.record(z.string(), ToolRouterElicitationOverrideSchema).optional(),
720
+ })
721
+ .strict()
722
+ .nullable()
723
+ .optional()
724
+ .describe('Per-tool elicitation permission config. `null` removes the stored block'),
725
+ linkUrlOverwrite: z
726
+ .string()
727
+ .nullable()
728
+ .optional()
729
+ .describe(
730
+ 'Base URL override for connection link redirects. `null` removes the stored override'
731
+ ),
732
+ fastMode: z
733
+ .boolean()
734
+ .nullable()
735
+ .optional()
736
+ .describe('Fast search mode. `null` removes the stored override'),
737
+ submitFeedback: z
738
+ .object({ enable: z.boolean() })
739
+ .strict()
740
+ .nullable()
741
+ .optional()
742
+ .describe(
743
+ 'Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block'
744
+ ),
745
+ sessionConfigId: z
746
+ .string()
747
+ .optional()
748
+ .describe('Apply the latest active Session config from this project to this session'),
749
+ })
750
+ .strict();
751
+ export type ToolRouterUpdateExperimentalConfig = z.infer<typeof ToolRouterUpdateExperimentalSchema>;
752
+
753
+ /**
754
+ * Options for `session.update()`. For every policy block, omitting the key
755
+ * preserves the stored value and `null` removes the stored override (which can
756
+ * increase access: `toolkits: null` restores the unrestricted default, unlike
757
+ * `toolkits: []`, which denies every app toolkit).
758
+ */
655
759
  export const ToolRouterUpdateSessionConfigSchema = z
656
760
  .object({
657
761
  toolkits: z
@@ -660,12 +764,24 @@ export const ToolRouterUpdateSessionConfigSchema = z
660
764
  ToolRouterToolkitsDisabledConfigSchema,
661
765
  ToolRouterToolkitsEnabledConfigSchema,
662
766
  ])
663
- .optional(),
767
+ .nullable()
768
+ .optional()
769
+ .describe(
770
+ 'Toolkit policy. An empty allowlist (`[]` or `{ enable: [] }`) is sent as-is and denies every app toolkit; `null` removes the stored policy and restores the unrestricted default'
771
+ ),
664
772
  tools: z
665
773
  .record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema]))
666
- .optional(),
667
- tags: ToolRouterConfigTagsSchema.optional(),
668
- authConfigs: z.record(z.string(), z.string()).optional(),
774
+ .nullable()
775
+ .optional()
776
+ .describe('Replaces the entire stored tools map; `null` removes the override'),
777
+ tags: ToolRouterConfigTagsSchema.nullable()
778
+ .optional()
779
+ .describe('Replaces the global tag policy; `null` removes the override'),
780
+ authConfigs: z
781
+ .record(z.string(), z.string())
782
+ .nullable()
783
+ .optional()
784
+ .describe('Replaces the entire stored auth config map; `null` removes the override'),
669
785
  connectedAccounts: z
670
786
  .record(z.string(), z.union([z.string(), z.array(z.string())]))
671
787
  .transform(rec => {
@@ -675,9 +791,11 @@ export const ToolRouterUpdateSessionConfigSchema = z
675
791
  }
676
792
  return out;
677
793
  })
678
- .optional(),
794
+ .nullable()
795
+ .optional()
796
+ .describe('Replaces the entire stored connected accounts map; `null` removes the override'),
679
797
  manageConnections: z
680
- .union([z.boolean(), ToolRouterConfigManageConnectionsSchema])
798
+ .union([z.boolean(), ToolRouterUpdateManageConnectionsSchema])
681
799
  .nullable()
682
800
  .optional(),
683
801
  sandbox: ToolRouterSandboxConfigSchema.partial().nullable().optional(),
@@ -685,17 +803,48 @@ export const ToolRouterUpdateSessionConfigSchema = z
685
803
  multiAccount: z
686
804
  .object({
687
805
  enable: z.boolean().optional(),
688
- maxAccountsPerToolkit: z.number().int().min(2).max(10).optional(),
806
+ maxAccountsPerToolkit: z
807
+ .number()
808
+ .int()
809
+ .min(2)
810
+ .max(10)
811
+ .nullable()
812
+ .optional()
813
+ .describe('`null` removes the stored maximum so the default applies again'),
689
814
  requireExplicitSelection: z.boolean().optional(),
690
815
  })
691
816
  .nullable()
692
- .optional(),
817
+ .optional()
818
+ .describe('`null` removes the session override; the mode then resolves to disabled'),
693
819
  preload: z
694
820
  .object({
695
821
  tools: z.union([z.array(z.string()), z.literal('all')]).optional(),
696
822
  })
697
823
  .strict()
698
- .optional(),
824
+ .nullable()
825
+ .optional()
826
+ .describe('Replaces the stored preload; `null` removes it'),
827
+ search: z
828
+ .object({ enable: z.boolean().optional() })
829
+ .strict()
830
+ .nullable()
831
+ .optional()
832
+ .describe('Replaces the search block; `null` removes it and restores the defaults'),
833
+ execute: z
834
+ .object({ enableMultiExecute: z.boolean().optional() })
835
+ .strict()
836
+ .nullable()
837
+ .optional()
838
+ .describe('Replaces the execute block; `null` removes it and restores the defaults'),
839
+ experimental: ToolRouterUpdateExperimentalSchema.nullable()
840
+ .optional()
841
+ .describe('Experimental settings; `null` removes the stored block'),
842
+ expectedConfigVersion: z
843
+ .union([z.number().int().positive(), z.literal(false)])
844
+ .optional()
845
+ .describe(
846
+ 'Precondition sent as `expected_config_version`. Omitted: the session sends the configVersion it last observed, so a concurrent change surfaces as ComposioSessionConfigConflictError instead of being overwritten. A positive integer sends that version instead. `false` sends no precondition (last writer wins)'
847
+ ),
699
848
  })
700
849
  .partial()
701
850
  .superRefine((config, ctx) => {
@@ -721,6 +870,49 @@ export const ToolRouterSessionDeleteResponseSchema = z.object({
721
870
  });
722
871
  export type ToolRouterSessionDeleteResponse = z.infer<typeof ToolRouterSessionDeleteResponseSchema>;
723
872
 
873
+ /**
874
+ * Options for `session.listConfigHistory()`.
875
+ */
876
+ export const ToolRouterSessionListConfigHistoryOptionsSchema = z.object({
877
+ /** Cursor from a previous response's `nextCursor`. */
878
+ cursor: z.string().optional(),
879
+ /** Number of items per page, max allowed is 100. */
880
+ limit: z.number().optional(),
881
+ });
882
+ export type ToolRouterSessionListConfigHistoryOptions = z.infer<
883
+ typeof ToolRouterSessionListConfigHistoryOptionsSchema
884
+ >;
885
+
886
+ /**
887
+ * The session configuration at one version, as stored by the API. This is
888
+ * the wire shape (snake_case), typed from the generated client.
889
+ */
890
+ export type ToolRouterSessionConfigHistoryConfig = SessionConfigHistoryResponse.Item.Config;
891
+
892
+ export type ToolRouterSessionConfigHistoryItem = {
893
+ /** The config version this entry represents. */
894
+ version: number;
895
+ /** ISO timestamp — for archived rows, when the version was superseded by an update. */
896
+ createdAt: string;
897
+ /** True only for the live (current) config, present on the first page. */
898
+ isCurrent: boolean;
899
+ /** The session configuration at this version. */
900
+ config: ToolRouterSessionConfigHistoryConfig;
901
+ };
902
+
903
+ export type ToolRouterSessionListConfigHistoryResponse = {
904
+ items: ToolRouterSessionConfigHistoryItem[];
905
+ nextCursor: string | null;
906
+ totalPages: number;
907
+ currentPage: number;
908
+ totalItems: number;
909
+ };
910
+
911
+ export type ToolRouterSessionListConfigHistoryFn = (
912
+ options?: ToolRouterSessionListConfigHistoryOptions,
913
+ requestOptions?: ComposioRequestOptions
914
+ ) => Promise<ToolRouterSessionListConfigHistoryResponse>;
915
+
724
916
  export type ToolRouterSessionDeleteFn = (
725
917
  requestOptions?: ComposioRequestOptions
726
918
  ) => Promise<ToolRouterSessionDeleteResponse>;
@@ -799,6 +991,8 @@ export interface Session<
799
991
  update: ToolRouterSessionUpdateFn;
800
992
  /** Delete the session. Deleted sessions are no longer retrievable or executable. */
801
993
  delete: ToolRouterSessionDeleteFn;
994
+ /** Page through the session's configuration history (newest first). */
995
+ listConfigHistory: ToolRouterSessionListConfigHistoryFn;
802
996
  /** Proxy an API call through Composio's auth layer using the session's connected account */
803
997
  proxyExecute: ToolRouterSessionProxyExecuteFn;
804
998
  /** List custom tools registered in this session, with their final slugs and schemas */
@@ -18,6 +18,14 @@ export type ToolkitMangedByEnum = z.infer<typeof ToolkitMangedByEnumSchema>;
18
18
  export type ToolkitSortByEnum = z.infer<typeof ToolkitSortByEnumSchema>;
19
19
  export type ToolkitListParams = z.infer<typeof ToolkitsListParamsSchema>;
20
20
 
21
+ /**
22
+ * Toolkit getMany params — the slugs to fetch plus the same filters `list`
23
+ * accepts.
24
+ */
25
+ export const ToolkitGetManySlugsSchema = z.array(z.string().min(1)).min(1);
26
+ export const ToolkitsGetManyParamsSchema = ToolkitsListParamsSchema;
27
+ export type ToolkitGetManyParams = z.infer<typeof ToolkitsGetManyParamsSchema>;
28
+
21
29
  /**
22
30
  * Toolkits response
23
31
  */
@@ -78,6 +86,13 @@ export const ToolkitAuthFieldSchema = z.object({
78
86
  * further documenting its semantics.
79
87
  */
80
88
  legacyTemplateName: z.string().optional(),
89
+ /**
90
+ * Whether the hosted connect flow shows this field to the end user, mapped
91
+ * from `user_visible`. A field with `false` is never required: its `default`
92
+ * applies unless the auth config supplies a value. Absent when the API omits
93
+ * the flag.
94
+ */
95
+ userVisible: z.boolean().optional(),
81
96
  });
82
97
  export const ToolkitAuthConfigDetailsSchema = z.object({
83
98
  name: z.string(),
@@ -87,6 +102,12 @@ export const ToolkitAuthConfigDetailsSchema = z.object({
87
102
  * authentication method, e.g. `https://github.com/settings/tokens`.
88
103
  */
89
104
  authHintUrl: z.string().nullable().optional(),
105
+ /**
106
+ * OAuth scopes always requested for this auth method regardless of the
107
+ * tool-specific scopes, such as token refresh (`offline_access`) and identity
108
+ * scopes. Mapped from `required_scopes`; absent when the API omits it.
109
+ */
110
+ requiredScopes: z.array(z.string()).optional(),
90
111
  fields: z.object({
91
112
  authConfigCreation: z.object({
92
113
  optional: z.array(ToolkitAuthFieldSchema),
@@ -138,6 +159,129 @@ export type ToolkitRetrieveCategoriesResponse = z.infer<
138
159
  typeof ToolkitRetrieveCategoriesResponseSchema
139
160
  >;
140
161
 
162
+ /**
163
+ * Toolkit changelog response
164
+ */
165
+ export const ToolkitVersionChangelogSchema = z.object({
166
+ version: z.string(),
167
+ changelog: z.string(),
168
+ });
169
+ export const ToolkitChangelogItemSchema = z.object({
170
+ slug: z.string(),
171
+ name: z.string(),
172
+ displayName: z.string(),
173
+ /** Most recent versions first; the API returns up to the last 10 per toolkit. */
174
+ versions: z.array(ToolkitVersionChangelogSchema),
175
+ });
176
+ export const ToolkitChangelogResponseSchema = z.object({
177
+ items: z.array(ToolkitChangelogItemSchema),
178
+ });
179
+
180
+ export type ToolkitVersionChangelog = z.infer<typeof ToolkitVersionChangelogSchema>;
181
+ export type ToolkitChangelogItem = z.infer<typeof ToolkitChangelogItemSchema>;
182
+ export type ToolkitChangelogResponse = z.infer<typeof ToolkitChangelogResponseSchema>;
183
+
184
+ /**
185
+ * Params for `composio.toolkits.recommendScopes()`.
186
+ * **Experimental — shape may change in future releases.**
187
+ */
188
+ export const ToolkitRecommendScopesParamsSchema = z.object({
189
+ /** Tool slugs to cover. Pass `[]` to cover every tool in the toolkit. */
190
+ tools: z.array(z.string()),
191
+ /** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
192
+ authScheme: AuthSchemeEnum.optional(),
193
+ /** Toolkit version to compute from. The API defaults to the latest published version. */
194
+ toolkitVersion: z.string().min(1).optional(),
195
+ /**
196
+ * Context the scopes will be granted in, as dimension → selected value,
197
+ * for example `{ account_type: 'Google Workspace' }`. Discover the
198
+ * dimensions with `composio.toolkits.listGrantContexts()`.
199
+ */
200
+ grantContext: z.record(z.string(), z.string()).optional(),
201
+ /** Scopes the recommendation must include, whether or not the tools need them. */
202
+ include: z.array(z.string()).optional(),
203
+ /** Scopes the recommendation must not include; the API picks documented alternatives or fails. */
204
+ exclude: z.array(z.string()).optional(),
205
+ /** Scopes your OAuth app can request. The recommendation never goes outside this list. */
206
+ availableScopes: z.array(z.string()).optional(),
207
+ });
208
+ export type ToolkitRecommendScopesParams = z.infer<typeof ToolkitRecommendScopesParamsSchema>;
209
+
210
+ export const ToolkitConditionalScopeSchema = z.object({
211
+ /** The scope needed only when the `when` guard matches. */
212
+ scope: z.string(),
213
+ /** Input field name → qualifying values. Any value matches within a field; all fields must match. */
214
+ when: z.record(z.string(), z.array(z.string())),
215
+ /** Tool slugs that need this scope under the guard. */
216
+ for: z.array(z.string()),
217
+ });
218
+ export type ToolkitConditionalScope = z.infer<typeof ToolkitConditionalScopeSchema>;
219
+
220
+ /**
221
+ * Response of `composio.toolkits.recommendScopes()`.
222
+ * **Experimental — shape may change in future releases.**
223
+ */
224
+ export const ToolkitRecommendScopesResponseSchema = z.object({
225
+ /** Auth scheme the recommendation was computed under. */
226
+ authScheme: z.string(),
227
+ /** Concrete toolkit version the answer was computed from; pass it back as `toolkitVersion` to pin. */
228
+ toolkitVersion: z.string(),
229
+ /** The effective grant context: the toolkit default overlaid with your overrides. */
230
+ grantContext: z.record(z.string(), z.string()),
231
+ scopes: z.object({
232
+ /** Narrowest documented option per requirement. */
233
+ leastPrivilege: z.array(z.string()),
234
+ /** Smallest scope set covering all requirements. */
235
+ fewest: z.array(z.string()),
236
+ /**
237
+ * Scopes needed only for particular call-time inputs. Both lists above
238
+ * already include them, so a caller that knows its inputs may drop the rest.
239
+ */
240
+ conditional: z.array(ToolkitConditionalScopeSchema),
241
+ }),
242
+ });
243
+ export type ToolkitRecommendScopesResponse = z.infer<typeof ToolkitRecommendScopesResponseSchema>;
244
+
245
+ /**
246
+ * Params for `composio.toolkits.listGrantContexts()`.
247
+ * **Experimental — shape may change in future releases.**
248
+ */
249
+ export const ToolkitListGrantContextsParamsSchema = z.object({
250
+ /** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
251
+ authScheme: AuthSchemeEnum.optional(),
252
+ /** Toolkit version to read the scope catalog from. The API defaults to the latest published version. */
253
+ toolkitVersion: z.string().min(1).optional(),
254
+ });
255
+ export type ToolkitListGrantContextsParams = z.infer<typeof ToolkitListGrantContextsParamsSchema>;
256
+
257
+ export const ToolkitGrantContextDimensionSchema = z.object({
258
+ /** Dimension name to use as a `grantContext` key. */
259
+ dimension: z.string(),
260
+ /** What the dimension means and when to pass it. */
261
+ description: z.string(),
262
+ /** Values the dimension can take. */
263
+ values: z.array(z.string()),
264
+ });
265
+ export type ToolkitGrantContextDimension = z.infer<typeof ToolkitGrantContextDimensionSchema>;
266
+
267
+ /**
268
+ * Response of `composio.toolkits.listGrantContexts()`.
269
+ * **Experimental — shape may change in future releases.**
270
+ */
271
+ export const ToolkitListGrantContextsResponseSchema = z.object({
272
+ /** Auth scheme whose scope catalog the dimensions were read from. */
273
+ authScheme: z.string(),
274
+ /** Concrete toolkit version the answer was computed from. */
275
+ toolkitVersion: z.string(),
276
+ /** Dimensions the toolkit accepts in `grantContext`; empty when no scope depends on one. */
277
+ grantContextDimensions: z.array(ToolkitGrantContextDimensionSchema),
278
+ /** The grant context assumed when you pass none. */
279
+ defaultGrantContext: z.record(z.string(), z.string()),
280
+ });
281
+ export type ToolkitListGrantContextsResponse = z.infer<
282
+ typeof ToolkitListGrantContextsResponseSchema
283
+ >;
284
+
141
285
  export const ToolkitAuthFieldsResponseSchema = z.array(
142
286
  ToolkitAuthFieldSchema.extend({
143
287
  required: z.boolean().optional(),