@composio/core 0.26.0 → 0.28.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.
- package/dist/{CustomTool-DfP4ldQl.d.mts → CustomTool-DyypijT6.d.mts} +2 -2
- package/dist/{Telemetry-41JkqpZ7.mjs → Telemetry-D2PJwXKx.mjs} +1 -1
- package/dist/{composio-BMDH-1Qj.d.mts → composio-CwHMpKXb.d.mts} +748 -70
- package/dist/{customTool.types-BoOELgJF.d.mts → customTool.types-DoItUHkO.d.mts} +780 -23
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +3 -3
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +5 -4
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +5 -1
- package/dist/experimental/index.d.mts +2 -2
- package/dist/{fileUtils.node-DNLhLg0W.mjs → fileUtils.node-ILI1IjnZ.mjs} +4 -3
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +420 -158
- package/dist/models/Files.node.mjs +2 -2
- package/dist/sensitiveFileUploadPaths-BaEORC7-.mjs +588 -0
- package/dist/{types-DHNV_T_z.d.mts → types-DWZWePfZ.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +7 -6
- package/src/lib/toolRouterParams.ts +33 -15
- package/src/lib/toolRouterSessionDelete.ts +1 -10
- package/src/models/ConnectedAccounts.ts +1 -1
- package/src/models/CustomTool.ts +1 -1
- package/src/models/CustomToolkits.ts +114 -8
- package/src/models/Experimental.ts +1 -1
- package/src/models/MCP.ts +1 -2
- package/src/models/SessionConfigs.ts +11 -3
- package/src/models/SessionContext.ts +6 -21
- package/src/models/ToolRouter.ts +5 -1
- package/src/models/ToolRouterSession.ts +21 -35
- package/src/models/Tools.ts +3 -3
- package/src/models/Triggers.ts +12 -5
- package/src/models/inlineCustomToolsPayload.ts +3 -3
- package/src/models/proxyParamsTransform.ts +1 -1
- package/src/types/customTool.types.ts +13 -5
- package/src/types/customToolkits.types.ts +89 -9
- package/src/types/sessionConfigs.types.ts +21 -7
- package/src/types/toolRouter.types.ts +169 -17
- package/src/types/triggers.types.ts +14 -0
- package/src/utils/fileUtils.node.ts +5 -2
- package/src/utils/mime.ts +347 -1
- package/src/utils/transformers/connectedAccounts.ts +2 -7
- package/src/utils/transformers/customToolkits.ts +78 -9
- package/src/utils/transformers/sessionConfigs.ts +3 -3
- package/src/utils/transformers/toolRouterResponseTransform.ts +71 -5
- package/src/utils/transformers/toolkits.ts +7 -13
- package/src/utils/transformers/triggers.ts +28 -18
- package/dist/sensitiveFileUploadPaths-BlLp-Yo2.mjs +0 -189
|
@@ -5,12 +5,13 @@ 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
|
|
14
|
+
} from '@composio/client/resources/tool-router/session';
|
|
14
15
|
import type {
|
|
15
16
|
CustomTool,
|
|
16
17
|
CustomToolkit,
|
|
@@ -329,6 +330,75 @@ export const ToolRouterProxyExecuteSchema = z.union([
|
|
|
329
330
|
]);
|
|
330
331
|
export type ToolRouterProxyExecute = z.infer<typeof ToolRouterProxyExecuteSchema>;
|
|
331
332
|
|
|
333
|
+
/** Which tool calls a hook runs on: `'all'`, or only calls to the listed toolkits (including their proxy calls). */
|
|
334
|
+
export const ToolRouterHookAppliesToSchema = z.union([
|
|
335
|
+
z.literal('all'),
|
|
336
|
+
z.object({ toolkits: z.array(z.string()).describe('Toolkit slugs') }).strict(),
|
|
337
|
+
]);
|
|
338
|
+
export type ToolRouterHookAppliesTo = z.infer<typeof ToolRouterHookAppliesToSchema>;
|
|
339
|
+
|
|
340
|
+
/** Blocks a call or result when it matches `condition`, a plain sentence describing what to block. */
|
|
341
|
+
export const ToolRouterHookConditionCheckHandlerSchema = z
|
|
342
|
+
.object({
|
|
343
|
+
type: z.literal('condition_check'),
|
|
344
|
+
condition: z
|
|
345
|
+
.string()
|
|
346
|
+
.describe(
|
|
347
|
+
'What to block, written as a plain sentence. For example: "Sending email to anyone outside example.org".'
|
|
348
|
+
),
|
|
349
|
+
action: z.literal('block'),
|
|
350
|
+
})
|
|
351
|
+
.strict();
|
|
352
|
+
export type ToolRouterHookConditionCheckHandler = z.infer<
|
|
353
|
+
typeof ToolRouterHookConditionCheckHandlerSchema
|
|
354
|
+
>;
|
|
355
|
+
|
|
356
|
+
/** A pre-defined check that blocks results with text that tries to give the agent instructions. */
|
|
357
|
+
export const ToolRouterHookPromptInjectionCheckHandlerSchema = z
|
|
358
|
+
.object({
|
|
359
|
+
type: z.literal('prompt_injection_check'),
|
|
360
|
+
action: z.literal('block'),
|
|
361
|
+
})
|
|
362
|
+
.strict();
|
|
363
|
+
export type ToolRouterHookPromptInjectionCheckHandler = z.infer<
|
|
364
|
+
typeof ToolRouterHookPromptInjectionCheckHandlerSchema
|
|
365
|
+
>;
|
|
366
|
+
|
|
367
|
+
const toolRouterHookIdentityFields = {
|
|
368
|
+
id: z.string().describe('Unique within the session. Shows up in results and logs.'),
|
|
369
|
+
name: z
|
|
370
|
+
.string()
|
|
371
|
+
.optional()
|
|
372
|
+
.describe('A readable name. The agent sees it when this hook blocks a call.'),
|
|
373
|
+
appliesTo: ToolRouterHookAppliesToSchema,
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* A hook on a session's tool calls. A `before_execute` hook can block a call
|
|
378
|
+
* before it runs; an `after_execute` hook can block its result before the
|
|
379
|
+
* agent sees it.
|
|
380
|
+
*/
|
|
381
|
+
export const ToolRouterHookSchema = z.discriminatedUnion('type', [
|
|
382
|
+
z
|
|
383
|
+
.object({
|
|
384
|
+
type: z.literal('before_execute'),
|
|
385
|
+
...toolRouterHookIdentityFields,
|
|
386
|
+
handler: ToolRouterHookConditionCheckHandlerSchema,
|
|
387
|
+
})
|
|
388
|
+
.strict(),
|
|
389
|
+
z
|
|
390
|
+
.object({
|
|
391
|
+
type: z.literal('after_execute'),
|
|
392
|
+
...toolRouterHookIdentityFields,
|
|
393
|
+
handler: z.discriminatedUnion('type', [
|
|
394
|
+
ToolRouterHookConditionCheckHandlerSchema,
|
|
395
|
+
ToolRouterHookPromptInjectionCheckHandlerSchema,
|
|
396
|
+
]),
|
|
397
|
+
})
|
|
398
|
+
.strict(),
|
|
399
|
+
]);
|
|
400
|
+
export type ToolRouterHook = z.infer<typeof ToolRouterHookSchema>;
|
|
401
|
+
|
|
332
402
|
const ToolRouterCreateSessionConfigBaseSchema = z
|
|
333
403
|
.object({
|
|
334
404
|
sessionPreset: z
|
|
@@ -414,6 +484,13 @@ const ToolRouterCreateSessionConfigBaseSchema = z
|
|
|
414
484
|
'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.'
|
|
415
485
|
),
|
|
416
486
|
|
|
487
|
+
hooks: z
|
|
488
|
+
.array(ToolRouterHookSchema)
|
|
489
|
+
.optional()
|
|
490
|
+
.describe(
|
|
491
|
+
"Hooks that run on this session's tool calls. A hook can block a call before it runs, or block its result before the agent sees it."
|
|
492
|
+
),
|
|
493
|
+
|
|
417
494
|
preload: z
|
|
418
495
|
.object({
|
|
419
496
|
tools: z
|
|
@@ -480,6 +557,7 @@ const ToolRouterCreateSessionConfigBaseSchema = z
|
|
|
480
557
|
config.toolkits !== undefined && 'toolkits',
|
|
481
558
|
config.tools !== undefined && 'tools',
|
|
482
559
|
config.tags !== undefined && 'tags',
|
|
560
|
+
config.hooks !== undefined && 'hooks',
|
|
483
561
|
config.experimental.customTools !== undefined && 'experimental.customTools',
|
|
484
562
|
config.experimental.customToolkits !== undefined && 'experimental.customToolkits',
|
|
485
563
|
].filter((field): field is string => field !== false)
|
|
@@ -544,10 +622,11 @@ export const ToolRouterCreateSessionConfigSchema = z
|
|
|
544
622
|
* @param {boolean} [multiAccount.requireExplicitSelection] - When true, require explicit account selection when multiple accounts are connected
|
|
545
623
|
* @param {boolean | object} [proxyExecute] - Proxy execute configuration for this session. A boolean is shorthand for `{ enable }`.
|
|
546
624
|
* @param {boolean} proxyExecute.enable - `true` exposes the `COMPOSIO_PROXY_EXECUTE` meta tool. `false` also turns off the sandbox `proxy_execute()` helper.
|
|
625
|
+
* @param {ToolRouterHook[]} [hooks] - Hooks that run on this session's tool calls. A `before_execute` hook can block a call before it runs; an `after_execute` hook can block its result before the agent sees it. Cannot be combined with `experimental.sessionConfigId`.
|
|
547
626
|
* @param {object} [preload] - Tools to preload into session.tools() and the MCP tool list
|
|
548
627
|
* @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.
|
|
549
628
|
* @param {object} [experimental] - Experimental features configuration. Not stable; may change or be removed.
|
|
550
|
-
* @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`, `experimental.customTools` or `experimental.customToolkits`. Per-session fields such as `authConfigs`, `connectedAccounts`, `manageConnections`, `sandbox`, `multiAccount` and `preload` stay allowed.
|
|
629
|
+
* @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.
|
|
551
630
|
*/
|
|
552
631
|
export type ToolRouterCreateSessionConfig =
|
|
553
632
|
InlineAccessCreateSessionConfig | SavedConfigCreateSessionConfig;
|
|
@@ -565,11 +644,12 @@ type InlineAccessCreateSessionConfig = Omit<ParsedCreateSessionConfig, 'experime
|
|
|
565
644
|
/** Create input that takes its access policy from a saved Session config. */
|
|
566
645
|
type SavedConfigCreateSessionConfig = Omit<
|
|
567
646
|
ParsedCreateSessionConfig,
|
|
568
|
-
'toolkits' | 'tools' | 'tags' | 'experimental'
|
|
647
|
+
'toolkits' | 'tools' | 'tags' | 'hooks' | 'experimental'
|
|
569
648
|
> & {
|
|
570
649
|
toolkits?: never;
|
|
571
650
|
tools?: never;
|
|
572
651
|
tags?: never;
|
|
652
|
+
hooks?: never;
|
|
573
653
|
experimental: Omit<
|
|
574
654
|
ParsedCreateSessionExperimental,
|
|
575
655
|
'sessionConfigId' | 'customTools' | 'customToolkits'
|
|
@@ -636,7 +716,7 @@ export type ToolRouterToolsFn<
|
|
|
636
716
|
|
|
637
717
|
export type ToolRouterAuthorizeFn = (
|
|
638
718
|
toolkit: string,
|
|
639
|
-
options?: { callbackUrl?: string; alias?: string }
|
|
719
|
+
options?: { callbackUrl?: string; alias?: string; experimental?: ConnectedAccountExperimental }
|
|
640
720
|
) => Promise<ConnectionRequest>;
|
|
641
721
|
|
|
642
722
|
export const ToolRouterToolkitsOptionsSchema = z.object({
|
|
@@ -745,6 +825,37 @@ export const ToolRouterSessionSearchResponseSchema = z.object({
|
|
|
745
825
|
});
|
|
746
826
|
export type ToolRouterSessionSearchResponse = z.infer<typeof ToolRouterSessionSearchResponseSchema>;
|
|
747
827
|
|
|
828
|
+
// --- Session hook results (camelCase) ---
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* What one session hook decided about a call. `unavailable` means the hook
|
|
832
|
+
* could not be evaluated (for example it timed out); it does not block the
|
|
833
|
+
* call.
|
|
834
|
+
*/
|
|
835
|
+
export const ToolRouterHookResultSchema = z.discriminatedUnion('status', [
|
|
836
|
+
z.object({
|
|
837
|
+
id: z.string().describe('The hook id'),
|
|
838
|
+
status: z.literal('evaluated'),
|
|
839
|
+
outcome: z.enum(['continue', 'block']).describe('What the hook decided'),
|
|
840
|
+
}),
|
|
841
|
+
z.object({
|
|
842
|
+
id: z.string().describe('The hook id'),
|
|
843
|
+
status: z.literal('unavailable'),
|
|
844
|
+
}),
|
|
845
|
+
]);
|
|
846
|
+
export type ToolRouterHookResult = z.infer<typeof ToolRouterHookResultSchema>;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Why a session hook blocked a call. `request_blocked`: a `before_execute` hook
|
|
850
|
+
* blocked it and the tool did not run. `response_blocked`: the tool ran and an
|
|
851
|
+
* `after_execute` hook blocked its result.
|
|
852
|
+
*/
|
|
853
|
+
export const ToolRouterBlockReasonSchema = z.object({
|
|
854
|
+
type: z.enum(['request_blocked', 'response_blocked']),
|
|
855
|
+
hookId: z.string(),
|
|
856
|
+
});
|
|
857
|
+
export type ToolRouterBlockReason = z.infer<typeof ToolRouterBlockReasonSchema>;
|
|
858
|
+
|
|
748
859
|
// --- Session execute response schema (camelCase) ---
|
|
749
860
|
|
|
750
861
|
export const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
@@ -752,13 +863,19 @@ export const ToolRouterSessionExecuteResponseSchema = z.object({
|
|
|
752
863
|
error: z.string().nullable(),
|
|
753
864
|
logId: z.string(),
|
|
754
865
|
/**
|
|
755
|
-
* Whether the tool ran and succeeded (`completed`)
|
|
756
|
-
* (`failed`)
|
|
757
|
-
*
|
|
866
|
+
* Whether the tool ran and succeeded (`completed`), ran and failed
|
|
867
|
+
* (`failed`), or was blocked by a session hook (`blocked`). A failed
|
|
868
|
+
* execution can carry a `null` or empty `error`, so read this rather than
|
|
869
|
+
* `error` to tell them apart. A blocked call has empty `data` and the
|
|
870
|
+
* agent-facing message in `error`.
|
|
758
871
|
*/
|
|
759
|
-
resultType: z.enum(['completed', 'failed']),
|
|
872
|
+
resultType: z.enum(['completed', 'failed', 'blocked']),
|
|
760
873
|
/** Actual Instant usage charge when the Session opts into returning it. */
|
|
761
874
|
instantCharge: z.unknown().optional(),
|
|
875
|
+
/** Set when `resultType` is `blocked`: which hook blocked the call, and at which stage. */
|
|
876
|
+
blockReason: ToolRouterBlockReasonSchema.optional(),
|
|
877
|
+
/** Every session hook that applied to this call. Absent when none applied. */
|
|
878
|
+
hookResults: z.array(ToolRouterHookResultSchema).optional(),
|
|
762
879
|
});
|
|
763
880
|
export type ToolRouterSessionExecuteResponse = z.infer<
|
|
764
881
|
typeof ToolRouterSessionExecuteResponseSchema
|
|
@@ -766,7 +883,9 @@ export type ToolRouterSessionExecuteResponse = z.infer<
|
|
|
766
883
|
|
|
767
884
|
// --- Session proxy execute response (matches ToolProxyResponse from client) ---
|
|
768
885
|
|
|
769
|
-
|
|
886
|
+
/** A proxied request that was sent. */
|
|
887
|
+
export interface ToolRouterSessionProxyExecuteCompleted {
|
|
888
|
+
resultType: 'completed';
|
|
770
889
|
/** The HTTP status code returned from the proxied API */
|
|
771
890
|
status: number;
|
|
772
891
|
/** The response data from the proxied API */
|
|
@@ -780,8 +899,28 @@ export interface ToolRouterSessionProxyExecuteResponse {
|
|
|
780
899
|
url: string;
|
|
781
900
|
expiresAt?: string;
|
|
782
901
|
};
|
|
902
|
+
/** Every session hook that applied to this request. Absent when none applied. */
|
|
903
|
+
hookResults?: ToolRouterHookResult[];
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/** A proxied request that a session hook blocked. */
|
|
907
|
+
export interface ToolRouterSessionProxyExecuteBlocked {
|
|
908
|
+
resultType: 'blocked';
|
|
909
|
+
/** Which hook blocked the request, and at which stage. */
|
|
910
|
+
blockReason: ToolRouterBlockReason;
|
|
911
|
+
/** A message for the agent. It names the hook when the hook has a `name`. */
|
|
912
|
+
message: string;
|
|
913
|
+
/** Every session hook that applied to this request. */
|
|
914
|
+
hookResults?: ToolRouterHookResult[];
|
|
783
915
|
}
|
|
784
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Result of `session.proxyExecute()`. Check `resultType` before reading
|
|
919
|
+
* `status`: a request a session hook blocked has no HTTP response.
|
|
920
|
+
*/
|
|
921
|
+
export type ToolRouterSessionProxyExecuteResponse =
|
|
922
|
+
ToolRouterSessionProxyExecuteCompleted | ToolRouterSessionProxyExecuteBlocked;
|
|
923
|
+
|
|
785
924
|
/**
|
|
786
925
|
* Experimental features on a tool router session.
|
|
787
926
|
* Contains features that may be modified or removed in future versions.
|
|
@@ -873,11 +1012,15 @@ export type ToolRouterSessionExecuteMetaFn = (
|
|
|
873
1012
|
requestOptions?: ComposioRequestOptions
|
|
874
1013
|
) => Promise<ToolRouterSessionExecuteResponse>;
|
|
875
1014
|
|
|
876
|
-
export type ToolRouterSessionPreloadConfig =
|
|
1015
|
+
export type ToolRouterSessionPreloadConfig = NonNullable<
|
|
1016
|
+
SessionCreateResponse['config']
|
|
1017
|
+
>['preload'];
|
|
877
1018
|
|
|
878
|
-
export type ToolRouterSessionWorkbenchConfig =
|
|
1019
|
+
export type ToolRouterSessionWorkbenchConfig = NonNullable<
|
|
1020
|
+
NonNullable<SessionCreateResponse['config']>['workbench']
|
|
1021
|
+
>;
|
|
879
1022
|
|
|
880
|
-
export type ToolRouterSessionWarning = SessionCreateResponse
|
|
1023
|
+
export type ToolRouterSessionWarning = NonNullable<SessionCreateResponse['warnings']>[number];
|
|
881
1024
|
|
|
882
1025
|
/**
|
|
883
1026
|
* Server-side session configuration as returned by the API: toolkit/tool
|
|
@@ -885,7 +1028,7 @@ export type ToolRouterSessionWarning = SessionCreateResponse.Warning;
|
|
|
885
1028
|
* preload, sandbox (`workbench`), search, execute, proxy execute and Instant
|
|
886
1029
|
* settings.
|
|
887
1030
|
*/
|
|
888
|
-
export type ToolRouterSessionConfig = SessionCreateResponse
|
|
1031
|
+
export type ToolRouterSessionConfig = NonNullable<SessionCreateResponse['config']>;
|
|
889
1032
|
|
|
890
1033
|
export interface ToolRouterSessionMetadata {
|
|
891
1034
|
/** Present on every session built from an API response; the constructor synthesises a minimal config when absent. */
|
|
@@ -1096,6 +1239,11 @@ export const ToolRouterUpdateSessionConfigSchema = z
|
|
|
1096
1239
|
.describe(
|
|
1097
1240
|
'Replaces the proxy execute block; a boolean is shorthand for `{ enable }` and `null` removes it'
|
|
1098
1241
|
),
|
|
1242
|
+
hooks: z
|
|
1243
|
+
.array(ToolRouterHookSchema)
|
|
1244
|
+
.nullable()
|
|
1245
|
+
.optional()
|
|
1246
|
+
.describe('Replaces the whole list of hooks; `null` removes every hook'),
|
|
1099
1247
|
preload: z
|
|
1100
1248
|
.object({
|
|
1101
1249
|
tools: z.union([z.array(z.string()), z.literal('all')]).optional(),
|
|
@@ -1136,6 +1284,7 @@ export const ToolRouterUpdateSessionConfigSchema = z
|
|
|
1136
1284
|
config.toolkits !== undefined && 'toolkits',
|
|
1137
1285
|
config.tools !== undefined && 'tools',
|
|
1138
1286
|
config.tags !== undefined && 'tags',
|
|
1287
|
+
config.hooks !== undefined && 'hooks',
|
|
1139
1288
|
].filter((field): field is string => field !== false)
|
|
1140
1289
|
);
|
|
1141
1290
|
}
|
|
@@ -1151,8 +1300,8 @@ export const ToolRouterUpdateSessionConfigSchema = z
|
|
|
1151
1300
|
|
|
1152
1301
|
/**
|
|
1153
1302
|
* Options for `session.update()`. `experimental.sessionConfigId` applies a
|
|
1154
|
-
* saved Session config and cannot be combined with `toolkits`, `tools
|
|
1155
|
-
* `tags` (including `null`).
|
|
1303
|
+
* saved Session config and cannot be combined with `toolkits`, `tools`,
|
|
1304
|
+
* `tags` or `hooks` (including `null`).
|
|
1156
1305
|
*/
|
|
1157
1306
|
export type ToolRouterUpdateSessionConfig =
|
|
1158
1307
|
InlineAccessUpdateSessionConfig | SavedConfigUpdateSessionConfig;
|
|
@@ -1169,11 +1318,12 @@ type InlineAccessUpdateSessionConfig = Omit<ParsedUpdateSessionConfig, 'experime
|
|
|
1169
1318
|
/** Update input that applies a saved Session config. */
|
|
1170
1319
|
type SavedConfigUpdateSessionConfig = Omit<
|
|
1171
1320
|
ParsedUpdateSessionConfig,
|
|
1172
|
-
'toolkits' | 'tools' | 'tags' | 'experimental'
|
|
1321
|
+
'toolkits' | 'tools' | 'tags' | 'hooks' | 'experimental'
|
|
1173
1322
|
> & {
|
|
1174
1323
|
toolkits?: never;
|
|
1175
1324
|
tools?: never;
|
|
1176
1325
|
tags?: never;
|
|
1326
|
+
hooks?: never;
|
|
1177
1327
|
experimental: Omit<ParsedUpdateSessionExperimental, 'sessionConfigId'> & {
|
|
1178
1328
|
sessionConfigId: string;
|
|
1179
1329
|
};
|
|
@@ -1206,7 +1356,9 @@ export type ToolRouterSessionListConfigHistoryOptions = z.infer<
|
|
|
1206
1356
|
* The session configuration at one version, as stored by the API. This is
|
|
1207
1357
|
* the wire shape (snake_case), with the Instant policy under `instant`.
|
|
1208
1358
|
*/
|
|
1209
|
-
export type ToolRouterSessionConfigHistoryConfig =
|
|
1359
|
+
export type ToolRouterSessionConfigHistoryConfig = NonNullable<
|
|
1360
|
+
SessionConfigHistoryResponse['items'][number]['config']
|
|
1361
|
+
>;
|
|
1210
1362
|
|
|
1211
1363
|
export type ToolRouterSessionConfigHistoryItem = {
|
|
1212
1364
|
/** The config version this entry represents. */
|
|
@@ -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
|
-
|
|
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:
|
|
166
|
+
mimeType: getMimeTypeFromFileName(filePath),
|
|
164
167
|
};
|
|
165
168
|
} catch (error) {
|
|
166
169
|
throw new Error(`Error reading file at ${filePath}: ${error}`);
|