@composio/core 0.27.0 → 0.29.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 (64) hide show
  1. package/README.md +2 -0
  2. package/dist/{CustomTool-BYHB7sPs.mjs → CustomTool-Bd1KdWvo.mjs} +9 -8
  3. package/dist/{CustomTool-CqPoLUD6.d.mts → CustomTool-CMW-d2ZN.d.mts} +10 -9
  4. package/dist/{Telemetry-41JkqpZ7.mjs → Telemetry-D2PJwXKx.mjs} +1 -1
  5. package/dist/{cancellation-ZoRh6EJQ.mjs → cancellation-BoJjs34Y.mjs} +1 -1
  6. package/dist/{composio-BUa10iB3.d.mts → composio-D5UV5HXN.d.mts} +799 -100
  7. package/dist/{customTool.types-gX421uPT.d.mts → customTool.types-B9fs34dv.d.mts} +105 -60
  8. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +1 -1
  9. package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +2 -2
  10. package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +86 -3
  11. package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +1 -1
  12. package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +1 -1
  13. package/dist/docs/reference/sdk-reference/typescript/session.mdx +51 -13
  14. package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +6 -6
  15. package/dist/docs/reference/sdk-reference/typescript/tools.mdx +4 -4
  16. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +5 -1
  17. package/dist/{errors-Cly0vXFh.mjs → errors-BK6Xc7Ia.mjs} +65 -1
  18. package/dist/experimental/index.d.mts +3 -3
  19. package/dist/experimental/index.mjs +1 -1
  20. package/dist/{fileUtils.node-DNLhLg0W.mjs → fileUtils.node-ILI1IjnZ.mjs} +4 -3
  21. package/dist/index.d.mts +46 -16
  22. package/dist/index.mjs +2973 -2778
  23. package/dist/models/Files.node.mjs +2 -2
  24. package/dist/sensitiveFileUploadPaths-BaEORC7-.mjs +588 -0
  25. package/dist/{types-DXxfzBX3.d.mts → types-CaP2SytR.d.mts} +2 -2
  26. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  27. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  28. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  29. package/dist/utils/modifiers/FileToolModifier.node.mjs +3 -3
  30. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  31. package/package.json +7 -6
  32. package/src/errors/ToolErrors.ts +73 -1
  33. package/src/experimental/index.ts +6 -1
  34. package/src/lib/toolRouterParams.ts +68 -33
  35. package/src/lib/toolRouterSessionDelete.ts +1 -10
  36. package/src/models/ConnectedAccounts.ts +3 -3
  37. package/src/models/ConnectionRequest.ts +38 -34
  38. package/src/models/CustomTool.ts +26 -31
  39. package/src/models/CustomToolkits.ts +116 -10
  40. package/src/models/Experimental.ts +1 -1
  41. package/src/models/MCP.ts +1 -2
  42. package/src/models/SessionConfigs.ts +11 -3
  43. package/src/models/SessionContext.ts +4 -4
  44. package/src/models/ToolRouter.ts +26 -17
  45. package/src/models/ToolRouterSession.ts +39 -24
  46. package/src/models/Tools.ts +60 -14
  47. package/src/models/Triggers.ts +12 -5
  48. package/src/models/inlineCustomToolsPayload.ts +3 -3
  49. package/src/models/proxyParamsTransform.ts +1 -1
  50. package/src/types/customTool.types.ts +62 -33
  51. package/src/types/customToolkits.types.ts +91 -11
  52. package/src/types/sessionConfigs.types.ts +21 -7
  53. package/src/types/toolRouter.types.ts +53 -24
  54. package/src/types/triggers.types.ts +14 -0
  55. package/src/utils/fileUtils.node.ts +5 -2
  56. package/src/utils/mime.ts +347 -1
  57. package/src/utils/rateLimit.ts +25 -0
  58. package/src/utils/transformers/connectedAccounts.ts +2 -7
  59. package/src/utils/transformers/customToolkits.ts +79 -10
  60. package/src/utils/transformers/sessionConfigs.ts +3 -3
  61. package/src/utils/transformers/toolRouterResponseTransform.ts +23 -75
  62. package/src/utils/transformers/toolkits.ts +7 -13
  63. package/src/utils/transformers/triggers.ts +28 -18
  64. package/dist/sensitiveFileUploadPaths-BlLp-Yo2.mjs +0 -189
@@ -1,5 +1,11 @@
1
1
  import { z } from 'zod/v3';
2
2
 
3
+ const CustomToolkitApiKeyFieldSchema = z.object({
4
+ displayName: z.string().min(1).max(100).optional(),
5
+ description: z.string().min(1).max(500).optional(),
6
+ });
7
+ export type CustomToolkitApiKeyField = z.infer<typeof CustomToolkitApiKeyFieldSchema>;
8
+
3
9
  /**
4
10
  * How end users authenticate to a custom toolkit.
5
11
  * **Experimental — custom toolkits are in pilot; shape may change.**
@@ -15,10 +21,14 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
15
21
  */
16
22
  headers: z.record(z.string(), z.string()),
17
23
  /** End-user copy for the API key input on the connect page. */
18
- apiKeyField: z
24
+ apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
25
+ /** Additional connect-page input used by `{{generic_id}}` in headers. */
26
+ additionalFields: z
19
27
  .object({
20
- displayName: z.string().min(1).max(100).optional(),
21
- description: z.string().min(1).max(500).optional(),
28
+ genericId: z.object({
29
+ displayName: z.string().min(1).max(100),
30
+ description: z.string().min(1).max(500).optional(),
31
+ }),
22
32
  })
23
33
  .optional(),
24
34
  }),
@@ -33,9 +43,84 @@ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
33
43
  ]);
34
44
  export type CustomToolkitAuthScheme = z.infer<typeof CustomToolkitAuthSchemeSchema>;
35
45
 
46
+ const CustomToolkitLogoFileSchema = z.object({
47
+ content: z.string().min(1),
48
+ mimeType: z.enum(['image/png', 'image/jpeg']),
49
+ });
50
+ export type CustomToolkitLogoFile = z.infer<typeof CustomToolkitLogoFileSchema>;
51
+
52
+ /**
53
+ * Params for `composio.experimental.customToolkits.create()`.
54
+ * **Experimental — custom toolkits are in pilot; shape may change.**
55
+ */
56
+ export const CustomToolkitCreateParamsSchema = z.object({
57
+ /** Human-readable toolkit name. */
58
+ name: z.string().min(1).max(200),
59
+ /** The MCP server URL. Must use https. */
60
+ mcpUrl: z.string().url(),
61
+ /** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the MCP logo. */
62
+ logoFile: CustomToolkitLogoFileSchema.optional(),
63
+ /** At least one scheme. Cannot be changed after create. */
64
+ authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
65
+ /**
66
+ * `'all'` to share the toolkit with every user in the project, or a user ID
67
+ * to make it private to that user. Cannot be changed after create.
68
+ */
69
+ userId: z.string().min(1),
70
+ /** Where to send the user after they connect. Used only for `connectLink`. */
71
+ callbackUrl: z.string().url().optional(),
72
+ });
73
+ export type CustomToolkitCreateParams = z.infer<typeof CustomToolkitCreateParamsSchema>;
74
+
75
+ export const CustomToolkitCreateResponseSchema = z.object({
76
+ /** Slug of the created toolkit. Store it to update, sync or delete the toolkit later. */
77
+ slug: z.string(),
78
+ /**
79
+ * Hosted connect page for a private toolkit's user. `null` for shared or
80
+ * no-auth toolkits, or if the link could not be created.
81
+ */
82
+ connectLink: z
83
+ .object({
84
+ redirectUrl: z.string(),
85
+ expiresAt: z.string(),
86
+ connectedAccountId: z.string(),
87
+ })
88
+ .nullable(),
89
+ });
90
+ export type CustomToolkitCreateResponse = z.infer<typeof CustomToolkitCreateResponseSchema>;
91
+
92
+ /**
93
+ * Params for `composio.experimental.customToolkits.update()`.
94
+ * **Experimental — custom toolkits are in pilot; shape may change.**
95
+ */
96
+ export const CustomToolkitUpdateParamsSchema = z
97
+ .object({
98
+ name: z.string().min(1).max(200).optional(),
99
+ logoFile: CustomToolkitLogoFileSchema.optional(),
100
+ /** End-user copy for the API key input on the connect page. API_KEY toolkits only. */
101
+ apiKeyField: CustomToolkitApiKeyFieldSchema.optional(),
102
+ /**
103
+ * The user the toolkit is private to. Required to update a private toolkit
104
+ * when the project has 2FA enabled.
105
+ */
106
+ userId: z.string().min(1).optional(),
107
+ })
108
+ .refine(
109
+ params => [params.name, params.logoFile, params.apiKeyField].some(value => value !== undefined),
110
+ { message: 'Provide at least one of name, logoFile, apiKeyField' }
111
+ );
112
+ export type CustomToolkitUpdateParams = z.infer<typeof CustomToolkitUpdateParamsSchema>;
113
+
114
+ export const CustomToolkitUpdateResponseSchema = z.object({
115
+ success: z.literal(true),
116
+ });
117
+ export type CustomToolkitUpdateResponse = z.infer<typeof CustomToolkitUpdateResponseSchema>;
118
+
36
119
  /**
37
120
  * Params for `composio.experimental.customToolkits.upsert()`.
38
121
  * **Experimental — custom toolkits are in pilot; shape may change.**
122
+ *
123
+ * @deprecated Use `CustomToolkitCreateParams` with `create()`.
39
124
  */
40
125
  export const CustomToolkitUpsertParamsSchema = z.object({
41
126
  /**
@@ -50,15 +135,10 @@ export const CustomToolkitUpsertParamsSchema = z.object({
50
135
  toolkitConfig: z.object({
51
136
  /** Human-readable toolkit name. */
52
137
  name: z.string().min(1).max(200),
53
- /** The app URL. For an MCP app, the MCP server URL. */
54
- appUrl: z.string().url(),
138
+ /** The MCP server URL. Must use https. */
139
+ mcpUrl: z.string().url(),
55
140
  /** 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(),
141
+ logoFile: CustomToolkitLogoFileSchema.optional(),
62
142
  /** At least one scheme. The schemes cannot change once the toolkit exists. */
63
143
  authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
64
144
  }),
@@ -6,7 +6,10 @@ import { ToolRouterTagsParamSchema } from './toolRouter.types';
6
6
  * active configs only, 20 per page, at most 100.
7
7
  */
8
8
  export const SessionConfigListParamsSchema = z.object({
9
- /** Case-insensitive substring match against the config name. */
9
+ /**
10
+ * @deprecated The Composio API no longer accepts this field. It is ignored
11
+ * and `list()` logs a warning when it is set; filter `items` by name instead.
12
+ */
10
13
  search: z.string().optional(),
11
14
  /** `true` returns only archived configs. Omitted returns active configs. */
12
15
  archived: z.boolean().optional(),
@@ -43,25 +46,36 @@ export type SessionConfigListResponse = z.infer<typeof SessionConfigListResponse
43
46
  const SessionConfigTagPolicySchema = z.object({
44
47
  enable: z.array(ToolRouterTagsParamSchema.element).optional(),
45
48
  disable: z.array(ToolRouterTagsParamSchema.element).optional(),
49
+ /** Tags whose tools need the user's approval before they run. */
50
+ require_approval: z.array(ToolRouterTagsParamSchema.element).optional(),
46
51
  });
47
52
 
53
+ /** What in a policy entry needs the user's approval before it runs. */
54
+ const requireApproval = { require_approval: z.array(z.string()).optional() };
55
+ const ApprovalOnlyPolicySchema = z.object({ require_approval: z.array(z.string()) });
56
+
48
57
  /**
49
58
  * The access policy stored in a saved Session config, in the backend's
50
- * `enable`/`disable` shape. Toolkit slug keys and tag names are kept exactly
51
- * as the backend sends them.
59
+ * `enable`/`disable`/`require_approval` shape. Toolkit slug keys and tag names
60
+ * are kept exactly as the backend sends them.
52
61
  */
53
62
  export const SessionConfigPolicySchema = z.object({
54
63
  toolkits: z
55
- .union([z.object({ enable: z.array(z.string()) }), z.object({ disable: z.array(z.string()) })])
64
+ .union([
65
+ z.object({ enable: z.array(z.string()), ...requireApproval }),
66
+ z.object({ disable: z.array(z.string()), ...requireApproval }),
67
+ ApprovalOnlyPolicySchema,
68
+ ])
56
69
  .optional(),
57
70
  /** Per-toolkit tool policy, keyed by toolkit slug. */
58
71
  tools: z
59
72
  .record(
60
73
  z.string(),
61
74
  z.union([
62
- z.object({ enable: z.array(z.string()) }),
63
- z.object({ disable: z.array(z.string()) }),
64
- z.object({ tags: SessionConfigTagPolicySchema }),
75
+ z.object({ enable: z.array(z.string()), ...requireApproval }),
76
+ z.object({ disable: z.array(z.string()), ...requireApproval }),
77
+ z.object({ tags: SessionConfigTagPolicySchema, ...requireApproval }),
78
+ ApprovalOnlyPolicySchema,
65
79
  ])
66
80
  )
67
81
  .optional(),
@@ -5,18 +5,19 @@ import { ConnectionRequest } from './connectionRequest.types';
5
5
  import type { ComposioRequestOptions } from './requestOptions.types';
6
6
  import type { ToolRouterSessionFilesMount } from '../models/ToolRouterSessionFileMount';
7
7
  import { ConnectedAccountExperimentalSchema } from './connectedAccounts.types';
8
+ import type { ConnectedAccountExperimental } from './connectedAccounts.types';
8
9
  import type {
9
10
  SessionConfigHistoryResponse,
10
11
  SessionCreateResponse,
11
12
  SessionExecuteMetaParams,
12
13
  SessionExecuteParams,
13
- } from '@composio/client/resources/tool-router/session/session.mjs';
14
+ } from '@composio/client/resources/tool-router/session';
14
15
  import type {
15
- CustomTool,
16
- CustomToolkit,
16
+ LocalTool,
17
+ LocalToolkit,
17
18
  InlineCustomToolsWirePayload,
18
- RegisteredCustomTool,
19
- RegisteredCustomToolkit,
19
+ RegisteredLocalTool,
20
+ RegisteredLocalToolkit,
20
21
  } from './customTool.types';
21
22
  import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';
22
23
  import { addSessionConfigConflictIssue } from '../lib/sessionConfigConflict';
@@ -516,24 +517,34 @@ const ToolRouterCreateSessionConfigBaseSchema = z
516
517
  })
517
518
  .optional()
518
519
  .describe('Configuration for assistive prompt generation'),
519
- customTools: z
520
- .array(z.custom<CustomTool>())
520
+ localTools: z
521
+ .array(z.custom<LocalTool>())
521
522
  .optional()
522
523
  .describe(
523
- 'Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental.'
524
+ 'Local tools to include in this session. They run in your process. Created via experimental_createTool() from @composio/core.'
524
525
  ),
525
- customToolkits: z
526
- .array(z.custom<CustomToolkit>())
526
+ localToolkits: z
527
+ .array(z.custom<LocalToolkit>())
527
528
  .optional()
528
529
  .describe(
529
- 'Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental.'
530
+ 'Toolkits of local tools to include in this session. Created via experimental_createToolkit() from @composio/core.'
530
531
  ),
532
+ /** @deprecated Use `localTools` instead. */
533
+ customTools: z
534
+ .array(z.custom<LocalTool>())
535
+ .optional()
536
+ .describe('Deprecated alias for localTools. Accepted for backwards compatibility.'),
537
+ /** @deprecated Use `localToolkits` instead. */
538
+ customToolkits: z
539
+ .array(z.custom<LocalToolkit>())
540
+ .optional()
541
+ .describe('Deprecated alias for localToolkits. Accepted for backwards compatibility.'),
531
542
  sessionConfigId: z
532
543
  .string()
533
544
  .min(1)
534
545
  .optional()
535
546
  .describe(
536
- 'ID of a saved Session config (`sc_…`) to apply when the session is created. Cannot be combined with toolkits, tools, tags, customTools or customToolkits.'
547
+ 'ID of a saved Session config (`sc_…`) to apply when the session is created. Cannot be combined with toolkits, tools, tags, localTools or localToolkits.'
537
548
  ),
538
549
  /**
539
550
  * What happens to a call that needs the user's approval when the
@@ -557,6 +568,8 @@ const ToolRouterCreateSessionConfigBaseSchema = z
557
568
  config.tools !== undefined && 'tools',
558
569
  config.tags !== undefined && 'tags',
559
570
  config.hooks !== undefined && 'hooks',
571
+ config.experimental.localTools !== undefined && 'experimental.localTools',
572
+ config.experimental.localToolkits !== undefined && 'experimental.localToolkits',
560
573
  config.experimental.customTools !== undefined && 'experimental.customTools',
561
574
  config.experimental.customToolkits !== undefined && 'experimental.customToolkits',
562
575
  ].filter((field): field is string => field !== false)
@@ -625,7 +638,11 @@ export const ToolRouterCreateSessionConfigSchema = z
625
638
  * @param {object} [preload] - Tools to preload into session.tools() and the MCP tool list
626
639
  * @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.
627
640
  * @param {object} [experimental] - Experimental features configuration. Not stable; may change or be removed.
628
- * @param {string} [experimental.sessionConfigId] - ID of a saved Session config (`sc_…`) to apply at creation; see `composio.sessionConfigs`. Cannot be combined with `toolkits`, `tools`, `tags`, `hooks`, `experimental.customTools` or `experimental.customToolkits`. Per-session fields such as `authConfigs`, `connectedAccounts`, `manageConnections`, `sandbox`, `multiAccount` and `preload` stay allowed.
641
+ * @param {LocalTool[]} [experimental.localTools] - Local tools to include in this session, created with `experimental_createTool()`. They run in your process.
642
+ * @param {LocalToolkit[]} [experimental.localToolkits] - Toolkits of local tools to include in this session, created with `experimental_createToolkit()`.
643
+ * @param {LocalTool[]} [experimental.customTools] - Deprecated alias for `experimental.localTools`.
644
+ * @param {LocalToolkit[]} [experimental.customToolkits] - Deprecated alias for `experimental.localToolkits`.
645
+ * @param {string} [experimental.sessionConfigId] - ID of a saved Session config (`sc_…`) to apply at creation; see `composio.sessionConfigs`. Cannot be combined with `toolkits`, `tools`, `tags`, `hooks`, `experimental.localTools` or `experimental.localToolkits` (or their deprecated aliases `experimental.customTools` / `experimental.customToolkits`). Per-session fields such as `authConfigs`, `connectedAccounts`, `manageConnections`, `sandbox`, `multiAccount` and `preload` stay allowed.
629
646
  */
630
647
  export type ToolRouterCreateSessionConfig =
631
648
  InlineAccessCreateSessionConfig | SavedConfigCreateSessionConfig;
@@ -651,9 +668,11 @@ type SavedConfigCreateSessionConfig = Omit<
651
668
  hooks?: never;
652
669
  experimental: Omit<
653
670
  ParsedCreateSessionExperimental,
654
- 'sessionConfigId' | 'customTools' | 'customToolkits'
671
+ 'sessionConfigId' | 'localTools' | 'localToolkits' | 'customTools' | 'customToolkits'
655
672
  > & {
656
673
  sessionConfigId: string;
674
+ localTools?: never;
675
+ localToolkits?: never;
657
676
  customTools?: never;
658
677
  customToolkits?: never;
659
678
  };
@@ -715,7 +734,7 @@ export type ToolRouterToolsFn<
715
734
 
716
735
  export type ToolRouterAuthorizeFn = (
717
736
  toolkit: string,
718
- options?: { callbackUrl?: string; alias?: string }
737
+ options?: { callbackUrl?: string; alias?: string; experimental?: ConnectedAccountExperimental }
719
738
  ) => Promise<ConnectionRequest>;
720
739
 
721
740
  export const ToolRouterToolkitsOptionsSchema = z.object({
@@ -1011,11 +1030,15 @@ export type ToolRouterSessionExecuteMetaFn = (
1011
1030
  requestOptions?: ComposioRequestOptions
1012
1031
  ) => Promise<ToolRouterSessionExecuteResponse>;
1013
1032
 
1014
- export type ToolRouterSessionPreloadConfig = SessionCreateResponse.Config.Preload;
1033
+ export type ToolRouterSessionPreloadConfig = NonNullable<
1034
+ SessionCreateResponse['config']
1035
+ >['preload'];
1015
1036
 
1016
- export type ToolRouterSessionWorkbenchConfig = SessionCreateResponse.Config.Workbench;
1037
+ export type ToolRouterSessionWorkbenchConfig = NonNullable<
1038
+ NonNullable<SessionCreateResponse['config']>['workbench']
1039
+ >;
1017
1040
 
1018
- export type ToolRouterSessionWarning = SessionCreateResponse.Warning;
1041
+ export type ToolRouterSessionWarning = NonNullable<SessionCreateResponse['warnings']>[number];
1019
1042
 
1020
1043
  /**
1021
1044
  * Server-side session configuration as returned by the API: toolkit/tool
@@ -1023,7 +1046,7 @@ export type ToolRouterSessionWarning = SessionCreateResponse.Warning;
1023
1046
  * preload, sandbox (`workbench`), search, execute, proxy execute and Instant
1024
1047
  * settings.
1025
1048
  */
1026
- export type ToolRouterSessionConfig = SessionCreateResponse.Config;
1049
+ export type ToolRouterSessionConfig = NonNullable<SessionCreateResponse['config']>;
1027
1050
 
1028
1051
  export interface ToolRouterSessionMetadata {
1029
1052
  /** Present on every session built from an API response; the constructor synthesises a minimal config when absent. */
@@ -1351,7 +1374,9 @@ export type ToolRouterSessionListConfigHistoryOptions = z.infer<
1351
1374
  * The session configuration at one version, as stored by the API. This is
1352
1375
  * the wire shape (snake_case), with the Instant policy under `instant`.
1353
1376
  */
1354
- export type ToolRouterSessionConfigHistoryConfig = SessionConfigHistoryResponse.Item.Config;
1377
+ export type ToolRouterSessionConfigHistoryConfig = NonNullable<
1378
+ SessionConfigHistoryResponse['items'][number]['config']
1379
+ >;
1355
1380
 
1356
1381
  export type ToolRouterSessionConfigHistoryItem = {
1357
1382
  /** The config version this entry represents. */
@@ -1461,10 +1486,14 @@ export interface Session<
1461
1486
  listConfigHistory: ToolRouterSessionListConfigHistoryFn;
1462
1487
  /** Proxy an API call through Composio's auth layer using the session's connected account */
1463
1488
  proxyExecute: ToolRouterSessionProxyExecuteFn;
1464
- /** List custom tools registered in this session, with their final slugs and schemas */
1465
- customTools: (options?: { toolkit?: string }) => RegisteredCustomTool[];
1466
- /** List custom toolkits registered in this session, with final slugs on nested tools */
1467
- customToolkits: () => RegisteredCustomToolkit[];
1489
+ /** List local tools registered in this session, with their final slugs and schemas */
1490
+ localTools: (options?: { toolkit?: string }) => RegisteredLocalTool[];
1491
+ /** List toolkits of local tools registered in this session, with final slugs on nested tools */
1492
+ localToolkits: () => RegisteredLocalToolkit[];
1493
+ /** @deprecated Use `localTools()` instead. */
1494
+ customTools: (options?: { toolkit?: string }) => RegisteredLocalTool[];
1495
+ /** @deprecated Use `localToolkits()` instead. */
1496
+ customToolkits: () => RegisteredLocalToolkit[];
1468
1497
  /** Experimental features (files, assistive prompt, etc.) */
1469
1498
  experimental: SessionExperimental;
1470
1499
  }
@@ -30,6 +30,9 @@ export const TriggerInstanceListActiveParamsSchema = z.object({
30
30
 
31
31
  export type TriggerInstanceListActiveParams = z.infer<typeof TriggerInstanceListActiveParamsSchema>;
32
32
 
33
+ export const TriggerInstanceTypeSchema = z.enum(['webhook', 'poll']);
34
+ export type TriggerInstanceType = z.infer<typeof TriggerInstanceTypeSchema>;
35
+
33
36
  export const TriggerInstanceListActiveResponseItemSchema = z.object({
34
37
  id: z.string(),
35
38
  connectedAccountId: z.string(),
@@ -40,6 +43,9 @@ export const TriggerInstanceListActiveResponseItemSchema = z.object({
40
43
  updatedAt: z.string(),
41
44
  triggerData: z.string().optional(),
42
45
  uuid: z.string().optional(),
46
+ type: TriggerInstanceTypeSchema,
47
+ fallbackReason: z.string().nullable(),
48
+ pollingInterval: z.number().nullable(),
43
49
  });
44
50
 
45
51
  export const TriggerInstanceListActiveResponseSchema = z.object({
@@ -58,12 +64,17 @@ export type TriggerInstanceListActiveResponseItem = z.infer<
58
64
  export const TriggerInstanceUpsertParamsSchema = z.object({
59
65
  connectedAccountId: z.string().optional(),
60
66
  triggerConfig: z.record(z.unknown()).optional(),
67
+ type: TriggerInstanceTypeSchema.optional(),
68
+ pollingInterval: z.number().int().positive().optional(),
61
69
  });
62
70
 
63
71
  export type TriggerInstanceUpsertParams = z.infer<typeof TriggerInstanceUpsertParamsSchema>;
64
72
 
65
73
  export const TriggerInstanceUpsertResponseSchema = z.object({
66
74
  triggerId: z.string(),
75
+ type: TriggerInstanceTypeSchema,
76
+ fallbackReason: z.string().nullable(),
77
+ pollingInterval: z.number().nullable(),
67
78
  });
68
79
 
69
80
  export type TriggerInstanceUpsertResponse = z.infer<typeof TriggerInstanceUpsertResponseSchema>;
@@ -162,6 +173,9 @@ export const TriggerTypeSchema = z.object({
162
173
  payload: z.record(z.unknown()),
163
174
  config: z.record(z.unknown()),
164
175
  version: z.string().optional(),
176
+ type: TriggerInstanceTypeSchema,
177
+ types: z.array(TriggerInstanceTypeSchema),
178
+ requiresWebhookEndpointSetup: z.boolean().optional(),
165
179
  });
166
180
 
167
181
  export type TriggerType = z.infer<typeof TriggerTypeSchema>;
@@ -11,6 +11,7 @@ import { assertSafeFileUploadPath } from './sensitiveFileUploadPaths';
11
11
  import { assertPathInsideUploadDirs } from './uploadDirAllowlist.node';
12
12
  import { ssrfSafeFetch } from './ssrfGuard.node';
13
13
  import { readResponseBodyWithLimit } from './readResponseBody';
14
+ import { getMimeTypeFromFileName } from './mime';
14
15
 
15
16
  /**
16
17
  * Options for {@link getFileDataAfterUploadingToS3} (S3 presigned upload from local path, URL, or File).
@@ -66,6 +67,7 @@ const getExtensionFromMimeType = (mimeType: string): string => {
66
67
  'text/plain': 'txt',
67
68
  'text/html': 'html',
68
69
  'text/css': 'css',
70
+ 'text/csv': 'csv',
69
71
  'text/javascript': 'js',
70
72
  'application/json': 'json',
71
73
  'application/xml': 'xml',
@@ -102,7 +104,8 @@ const getExtensionFromMimeType = (mimeType: string): string => {
102
104
  const cleanMimeType = mimeType.split(';')[0].toLowerCase().trim();
103
105
 
104
106
  // Try exact match first
105
- if (mimeToExt[cleanMimeType]) {
107
+ // An own property only: `constructor` or `__proto__` must not reach Object.prototype.
108
+ if (Object.hasOwn(mimeToExt, cleanMimeType)) {
106
109
  return mimeToExt[cleanMimeType];
107
110
  }
108
111
 
@@ -160,7 +163,7 @@ const readFileContent = async (
160
163
  content instanceof Uint8Array
161
164
  ? uint8ArrayToBase64(content)
162
165
  : uint8ArrayToBase64(new TextEncoder().encode(content)),
163
- mimeType: 'application/octet-stream',
166
+ mimeType: getMimeTypeFromFileName(filePath),
164
167
  };
165
168
  } catch (error) {
166
169
  throw new Error(`Error reading file at ${filePath}: ${error}`);