@composio/core 0.17.0 → 1.0.0-beta.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-Uip-fhPw.d.mts → CustomTool-CwpeQhz2.d.mts} +1 -1
- package/dist/FileToolModifier.utils.neutral-D_YkHwZP.mjs +188 -0
- package/dist/{Telemetry-DuGJSwUt.mjs → Telemetry-DK1uAWnD.mjs} +1 -1
- package/dist/{cancellation-NVtGf3St.mjs → cancellation-C-qy8rcj.mjs} +1 -1
- package/dist/{composio-B27X6i6A.d.mts → composio-XjF7EMEe.d.mts} +256 -250
- package/dist/{customTool.types-B2Ava_j5.d.mts → customTool.types-DpJbYY5m.d.mts} +167 -167
- package/dist/experimental/index.d.mts +2 -2
- package/dist/{fileUtils.node-B1Wn848p.mjs → fileUtils.node-BwpUOF0s.mjs} +2 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +58 -24
- package/dist/models/Files.node.mjs +2 -2
- package/dist/{sensitiveFileUploadPaths-BVEt0peg.mjs → sensitiveFileUploadPaths-B0w8dqpv.mjs} +23 -6
- package/dist/ssrfGuard.node-DlxO8uzr.mjs +307 -0
- package/dist/{types-DdZJuMm2.d.mts → types-C9kJAurw.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 +56 -100
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +14 -5
- package/dist/utils/ssrfGuard.node.mjs +1 -161
- package/package.json +7 -3
- package/src/models/ToolRouterSession.ts +36 -8
- package/src/models/Tools.ts +102 -39
- package/src/utils/modifiers/FileToolModifier.node.ts +85 -181
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +199 -0
- package/src/utils/pinnedDispatcher.node.ts +118 -0
- package/src/utils/sensitiveFileUploadPaths.ts +36 -9
- package/src/utils/ssrfGuard.node.ts +89 -11
- package/dist/FileToolModifier.utils.neutral-B5rT711M.mjs +0 -72
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-
|
|
2
|
-
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-DpJbYY5m.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-CwpeQhz2.mjs";
|
|
3
3
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, type SessionContext, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as COMPOSIO_DIR, i as logger, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
2
|
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-B8V8_3VE.mjs";
|
|
3
|
-
import { c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, o as base64ToUint8Array, s as uint8ArrayToBase64 } from "./sensitiveFileUploadPaths-
|
|
4
|
-
import { ssrfSafeFetch } from "./
|
|
3
|
+
import { c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, o as base64ToUint8Array, s as uint8ArrayToBase64 } from "./sensitiveFileUploadPaths-B0w8dqpv.mjs";
|
|
4
|
+
import { r as ssrfSafeFetch } from "./ssrfGuard.node-DlxO8uzr.mjs";
|
|
5
5
|
import { platform } from "#platform";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as ToolRouterSessionMetadata, $i as ToolExecuteResponse, $n as MCPGenerateURLParams, $r as Oauth1ActiveConnectionDataSchema, $t as ConnectedAccountExperimentalSchema, A as SessionProxyExecuteParams, Ai as BeforeFileUploadSource, An as UpdateConnectedAccountParamsSchema, Ar as McpUpdateResponseSchema, At as FileListResponseSchema, B as ToolRouterCreateSessionConfigSchema, Bi as beforeExecuteMetaModifier, Bn as ComposioMcpUpdateResponseSchema, Br as BaseConnectionFields, Bt as ToolRouterSessionFilesMountUploadOptionsSchema, C as MCPServerType, Ci as Oauth2InitiatedConnectionDataSchema, Cn as CreateConnectedAccountParamsSchema, Cr as McpRetrieveResponse, Ct as ToolkitConnectionStateSchema, D as Session, Di as Oauth2RevokedConnectionDataSchema, Dn as UpdateConnectedAccountAclParams, Dr as McpServerUrlInfo, Dt as FileDeleteResponse, E as SandboxSizeSchema, Ei as Oauth2RevokedConnectionData, En as DefaultCreateConnectedAccountParamsSchema, Er as McpServerGetResponse, Et as RemoteFile, F as ToolRouterConfigTags, Fi as SessionMetaToolOptions, Fn as ComposioGenerateURLParamsSchema, Fr as ExecuteToolFnOptions, Ft as ToolRouterSessionFilesMountDownloadOptions, G as ToolRouterSandboxConfigSchema, Gi as JSONSchemaProperty, Gn as GenerateURLParams, Gr as ConnectionStatuses, Gt as ConnectedAccountAclConfigResponse, H as ToolRouterMCPServerConfigSchema, Hi as beforeFileUploadModifier, Hn as CustomCreateResponse, Hr as ConnectionData, Ht as ConnectionRequest, I as ToolRouterConfigTagsSchema, Ii as ToolOptions, In as ComposioGenerateURLResponseSchema, Ir as GlobalExecuteToolFn, It as ToolRouterSessionFilesMountDownloadOptionsSchema, J as ToolRouterSessionDeleteResponseSchema, Ji as Tool, Jn as GenerateURLResponseSchema, Jr as CustomOauth1ConnectionData, Jt as ConnectedAccountAuthConfig, K as ToolRouterSessionDeleteFn, Ki as JSONSchemaPropertySchema, Kn as GenerateURLParamsSchema, Kr as CustomConnectionData, Kt as ConnectedAccountAclConfigResponseSchema, L as ToolRouterConfigTools, Li as TransformToolSchemaModifier, Ln as ComposioMcpDeleteResponseSchema, Lr as Provider, Lt as ToolRouterSessionFilesMountListOptions, M as SessionWithoutMcp, Mi as MetaToolArguments, Mn as BaseComposioProvider, Mr as McpUrlResponseCamelCase, Mt as RemoteFileDataSchema, N as ToolRouterAuthorizeFn, Ni as ProviderOptions, Nn as BaseNonAgenticProvider, Nr as McpUserConnectionStatus, Nt as ToolRouterSessionFilesMountDeleteOptions, O as SessionExperimental, Oi as RedirectableAuthSchemeSchema, On as UpdateConnectedAccountAclParamsSchema, Or as McpToolkitConnectionStatus, Ot as FileDeleteResponseSchema, P as ToolRouterConfigManageConnectionsSchema, Pi as SessionExecuteMetaModifiers, Pn as ComposioCustomCreateResponseSchema, Pr as ExecuteToolFn, Pt as ToolRouterSessionFilesMountDeleteOptionsSchema, Q as ToolRouterSessionExecuteResponseSchema, Qi as ToolExecuteParamsSchema, Qn as MCPCreateMethodResponse, Qr as Oauth1ActiveConnectionData, Qt as ConnectedAccountExperimentalResponseSchema, R as ToolRouterConfigToolsSchema, Ri as afterExecuteMetaModifier, Rn as ComposioMcpListResponseSchema, Rr as ToolCallExecutionTarget, Rt as ToolRouterSessionFilesMountListOptionsSchema, S as SessionContext, Si as Oauth2InitiatedConnectionData, Sn as CreateConnectedAccountParams, Sr as McpListResponseSchema, St as ToolkitConnectionState, T as SandboxSize, Ti as Oauth2InitiatingConnectionDataSchema, Tn as CreateConnectedAccountResponseSchema, Tr as McpServerCreateResponse, Tt as ToolkitConnectionsDetailsSchema, U as ToolRouterManageConnectionsConfigSchema, Ui as CustomAuthParams, Un as CustomCreateResponseSchema, Ur as ConnectionDataSchema, Ut as ConnectionRequestState, V as ToolRouterMCPServerConfig, Vi as beforeExecuteModifier, Vn as ConnectionStatus, Vr as BillcomAuthConnectionDataSchema, Vt as ComposioRequestOptions, W as ToolRouterSandboxConfig, Wi as CustomAuthParamsSchema, Wn as CustomCreateResponseValidated, Wr as ConnectionStatusEnum, Wt as ConnectedAccountAclConfig, X as ToolRouterSessionExecuteOptions, Xi as ToolExecuteMetaParamsSchema, Xn as MCPAuthOptions, Xr as CustomOauth2ConnectionData, Xt as ConnectedAccountExperimental, Y as ToolRouterSessionExecuteFn, Yi as ToolExecuteMetaParams, Yn as GenerateURLResponseValidated, Yr as CustomOauth1ConnectionDataSchema, Yt as ConnectedAccountAuthConfigSchema, Z as ToolRouterSessionExecuteResponse, Zi as ToolExecuteParams, Zn as MCPAuthOptionsSchema, Zr as CustomOauth2ConnectionDataSchema, Zt as ConnectedAccountExperimentalResponse, _ as CustomToolsMapEntry, _a as ToolkitVersionSchema, _i as Oauth2ExpiredConnectionDataSchema, _n as CreateConnectedAccountLinkOptionsSchema, _r as MCPToolkitConfigSchema, _t as ToolRouterToolsFn, a as CreateCustomToolkitParams, aa as ToolListResponseSchema, ai as Oauth1FailedConnectionDataSchema, an as ConnectedAccountRefreshOptions, ar as MCPMultiAppServerSchema, at as ToolRouterSessionSearchResponseSchema, b as RegisteredCustomTool, bi as Oauth2InactiveConnectionData, bn as CreateConnectedAccountOptions, br as McpDeleteResponseSchema, bt as ToolRouterUpdateSessionConfig, c as CustomToolExecuteFn, ca as ToolRetrievalOptions, ci as Oauth1InitiatedConnectionData, cn as ConnectedAccountRetrieveResponseSchema, cr as MCPServerCreateResponseSchema, ct as ToolRouterSessionWorkbenchConfig, d as CustomToolWireDefinition, da as ToolkitLatestVersion, di as Oauth1InitiatingConnectionDataSchema, dn as ConnectedAccountStatusSchema, dr as MCPServerSchema, dt as ToolRouterToolkitsDisabledConfigSchema, ea as ToolExecuteResponseSchema, ei as Oauth1ConnectionData, en as ConnectedAccountListParams, er as MCPGenerateURLParamsSchema, et as ToolRouterSessionPreloadConfig, f as CustomToolkit, fa as ToolkitLatestVersionSchema, fi as Oauth2ActiveConnectionData, fn as ConnectedAccountStatuses, fr as MCPServerUpdateParams, ft as ToolRouterToolkitsEnabledConfigSchema, g as CustomToolsMap, ga as ToolkitVersionParamSchema, gi as Oauth2ExpiredConnectionData, gn as CreateConnectedAccountLinkOptions, gr as MCPToolkitConfig, gt as ToolRouterToolkitsParamSchema, h as CustomToolkitWireDefinition, ha as ToolkitVersionParam, hi as Oauth2ConnectionDataSchema, hn as ConnectedAccountTypes, hr as MCPSingleAppServerSchema, ht as ToolRouterToolkitsOptionsSchema, i as CreateCustomToolkitBaseSchema, ia as ToolListResponse, ii as Oauth1FailedConnectionData, in as ConnectedAccountListResponseSchema, ir as MCPMultiAppServer, it as ToolRouterSessionSearchResponse, j as SessionProxyExecuteParamsSchema, ji as ExecuteToolModifiers, jn as BaseAgenticProvider, jr as McpUrlResponse, jt as RemoteFileData, k as SessionPreset, ki as AgenticToolOptions, kn as UpdateConnectedAccountParams, kr as McpUpdateResponse, kt as FileListResponse, l as CustomToolResponse, la as ToolSchema, li as Oauth1InitiatedConnectionDataSchema, ln as ConnectedAccountStatus, lr as MCPServerListResponse, lt as ToolRouterTagsEnableDisableSchema, m as CustomToolkitResponse, ma as ToolkitVersion, mi as Oauth2ConnectionData, mn as ConnectedAccountTypeSchema, mr as MCPSingleAppServer, mt as ToolRouterToolkitsOptions, n as CreateCustomToolBaseSchema, na as ToolListParams, ni as Oauth1ExpiredConnectionData, nn as ConnectedAccountListResponse, nr as MCPGetServerParamsSchema, nt as ToolRouterSessionProxyExecuteResponse, o as CustomTool, oa as ToolProxyParams, oi as Oauth1InactiveConnectionData, on as ConnectedAccountRefreshOptionsSchema, or as MCPServer, ot as ToolRouterSessionUpdateFn, p as CustomToolkitDefinition, pa as ToolkitSchema, pi as Oauth2ActiveConnectionDataSchema, pn as ConnectedAccountType, pr as MCPServerUpdateParamsSchema, pt as ToolRouterToolkitsFn, q as ToolRouterSessionDeleteResponse, qi as SchemaModifierOptions, qn as GenerateURLResponse, qr as CustomConnectionDataSchema, qt as ConnectedAccountAclConfigSchema, r as CreateCustomToolParams, ra as ToolListParamsSchema, ri as Oauth1ExpiredConnectionDataSchema, rn as ConnectedAccountListResponseItem, rr as MCPInstanceParams, rt as ToolRouterSessionSearchFn, s as CustomToolDefinition, sa as ToolProxyParamsSchema, si as Oauth1InactiveConnectionDataSchema, sn as ConnectedAccountRetrieveResponse, sr as MCPServerCreateResponse, st as ToolRouterSessionWarning, t as AnyZodSchema, ta as ToolList, ti as Oauth1ConnectionDataSchema, tn as ConnectedAccountListParamsSchema, tr as MCPGetServerParams, tt as ToolRouterSessionProxyExecuteFn, u as CustomToolSlugSchema, ua as Toolkit, ui as Oauth1InitiatingConnectionData, un as ConnectedAccountStatusEnum, ur as MCPServerListResponseSchema, ut as ToolRouterTagsParamSchema, v as InferZodSchema, va as ToolkitVersions, vi as Oauth2FailedConnectionData, vn as CreateConnectedAccountLinkResponse, vr as MCPToolkitConfigsArraySchema, vt as ToolRouterToolsParam, w as MCPServerTypeSchema, wi as Oauth2InitiatingConnectionData, wn as CreateConnectedAccountResponse, wr as McpRetrieveResponseSchema, wt as ToolkitConnectionsDetails, x as RegisteredCustomToolkit, xi as Oauth2InactiveConnectionDataSchema, xn as CreateConnectedAccountOptionsSchema, xr as McpListResponse, xt as ToolRouterUpdateSessionConfigSchema, y as InlineCustomToolsWirePayload, ya as ToolkitVersionsSchema, yi as Oauth2FailedConnectionDataSchema, yn as CreateConnectedAccountLinkResponseSchema, yr as McpDeleteResponse, yt as ToolRouterToolsParamSchema, z as ToolRouterCreateSessionConfig, zi as afterExecuteModifier, zn as ComposioMcpRetrieveResponseSchema, zr as ToolCallSession, zt as ToolRouterSessionFilesMountUploadOptions } from "./customTool.types-
|
|
2
|
-
import { n as createCustomToolkit, t as createCustomTool } from "./CustomTool-
|
|
3
|
-
import { $ as WebhookPayloadV3, $t as ToolkitsListParamsSchema, A as TriggerInstanceUpsertResponse, At as ToolKitItem, B as TriggersTypeListParamsSchema, Bt as ToolkitAuthFieldsResponse, C as TriggerInstanceManageDeleteResponseSchema, Ct as AuthSchemeTypes, D as TriggerInstanceManageUpdateResponseSchema, Dt as CreateAuthConfigResponseSchema, E as TriggerInstanceManageUpdateResponse, Et as CreateAuthConfigResponse, F as TriggerSubscribeParamSchema, Ft as ToolKitMetaSchema, G as VerifyWebhookParamsSchema, Gt as ToolkitMangedByEnum, H as TriggersTypeListResponseSchema, Ht as ToolkitCategory, I as TriggerSubscribeParams, It as ToolkitAuthConfigDetails, J as WebhookPayloadSchema, Jt as ToolkitRetrieveCategoriesResponseSchema, K as VerifyWebhookResult, Kt as ToolkitMangedByEnumSchema, L as TriggerType, Lt as ToolkitAuthConfigDetailsSchema, M as TriggerStatusEnum, Mt as ToolKitListResponse, N as TriggerStatusType, Nt as ToolKitListResponseSchema, O as TriggerInstanceUpsertParams, Ot as CreateComposioManagedAuthConfigParamsSchema, P as TriggerStatuses, Pt as ToolKitMeta, Q as WebhookPayloadV2Schema, Qt as ToolkitSortByEnumSchema, R as TriggerTypeSchema, Rt as ToolkitAuthField, S as TriggerInstanceManageDeleteResponse, St as AuthSchemeType, T as TriggerInstanceManageUpdateParamsSchema, Tt as CreateAuthConfigParamsSchema, U as TriggersTypeRetrieveResponse, Ut as ToolkitCategorySchema, V as TriggersTypeListResponse, Vt as ToolkitAuthFieldsResponseSchema, W as VerifyWebhookParams, Wt as ToolkitListParams, X as WebhookPayloadV1Schema, Xt as ToolkitRetrieveResponseSchema, Y as WebhookPayloadV1, Yt as ToolkitRetrieveResponse, Z as WebhookPayloadV2, Zt as ToolkitSortByEnum, _ as TriggerInstanceListActiveParamsSchema, _t as AuthConfigUpdateParams, a as MCP, at as WebhookVersion, b as TriggerInstanceListActiveResponseItemSchema, bt as AuthDefaultConfigUpdateParamsSchema, c as IncomingTriggerPayload, ct as AuthConfigListParams, d as SetWebhookSubscriptionParams, dt as AuthConfigListResponseSchema, et as WebhookPayloadV3Schema, f as SetWebhookSubscriptionParamsSchema, ft as AuthConfigRetrieveResponse, g as TriggerInstanceListActiveParams, gt as AuthConfigTypes, h as TriggerEventData, ht as AuthConfigType, i as OpenAIProvider, it as WebhookTriggerPayloadV3Schema, j as TriggerInstanceUpsertResponseSchema, jt as ToolKitItemSchema, k as TriggerInstanceUpsertParamsSchema, kt as CreateCustomAuthConfigParamsSchema, l as IncomingTriggerPayloadSchema, lt as AuthConfigListParamsSchema, m as TriggerEvent, mt as AuthConfigToolAccessConfigSchema, n as ComposioConfig, nt as WebhookSubscription, o as Experimental, ot as WebhookVersions, p as TriggerData, pt as AuthConfigRetrieveResponseSchema, q as WebhookPayload, qt as ToolkitRetrieveCategoriesResponse, r as Sessions, rt as WebhookTriggerPayloadV3, s as DefaultWebhookSubscriptionEvents, st as AuthConfigCreationToolAccessConfigSchema, t as Composio, tt as WebhookRequestLike, u as ParseWebhookOptions, ut as AuthConfigListResponse, v as TriggerInstanceListActiveResponse, vt as AuthConfigUpdateParamsSchema, w as TriggerInstanceManageUpdateParams, wt as CreateAuthConfigParams, x as TriggerInstanceListActiveResponseSchema, xt as AuthSchemeEnum, y as TriggerInstanceListActiveResponseItem, yt as AuthCustomConfigUpdateParamsSchema, z as TriggersTypeListParams, zt as ToolkitAuthFieldSchema } from "./composio-
|
|
1
|
+
import { $ as ToolRouterSessionMetadata, $i as ToolExecuteResponse, $n as MCPGenerateURLParams, $r as Oauth1ActiveConnectionDataSchema, $t as ConnectedAccountExperimentalSchema, A as SessionProxyExecuteParams, Ai as BeforeFileUploadSource, An as UpdateConnectedAccountParamsSchema, Ar as McpUpdateResponseSchema, At as FileListResponseSchema, B as ToolRouterCreateSessionConfigSchema, Bi as beforeExecuteMetaModifier, Bn as ComposioMcpUpdateResponseSchema, Br as BaseConnectionFields, Bt as ToolRouterSessionFilesMountUploadOptionsSchema, C as MCPServerType, Ci as Oauth2InitiatedConnectionDataSchema, Cn as CreateConnectedAccountParamsSchema, Cr as McpRetrieveResponse, Ct as ToolkitConnectionStateSchema, D as Session, Di as Oauth2RevokedConnectionDataSchema, Dn as UpdateConnectedAccountAclParams, Dr as McpServerUrlInfo, Dt as FileDeleteResponse, E as SandboxSizeSchema, Ei as Oauth2RevokedConnectionData, En as DefaultCreateConnectedAccountParamsSchema, Er as McpServerGetResponse, Et as RemoteFile, F as ToolRouterConfigTags, Fi as SessionMetaToolOptions, Fn as ComposioGenerateURLParamsSchema, Fr as ExecuteToolFnOptions, Ft as ToolRouterSessionFilesMountDownloadOptions, G as ToolRouterSandboxConfigSchema, Gi as JSONSchemaProperty, Gn as GenerateURLParams, Gr as ConnectionStatuses, Gt as ConnectedAccountAclConfigResponse, H as ToolRouterMCPServerConfigSchema, Hi as beforeFileUploadModifier, Hn as CustomCreateResponse, Hr as ConnectionData, Ht as ConnectionRequest, I as ToolRouterConfigTagsSchema, Ii as ToolOptions, In as ComposioGenerateURLResponseSchema, Ir as GlobalExecuteToolFn, It as ToolRouterSessionFilesMountDownloadOptionsSchema, J as ToolRouterSessionDeleteResponseSchema, Ji as Tool, Jn as GenerateURLResponseSchema, Jr as CustomOauth1ConnectionData, Jt as ConnectedAccountAuthConfig, K as ToolRouterSessionDeleteFn, Ki as JSONSchemaPropertySchema, Kn as GenerateURLParamsSchema, Kr as CustomConnectionData, Kt as ConnectedAccountAclConfigResponseSchema, L as ToolRouterConfigTools, Li as TransformToolSchemaModifier, Ln as ComposioMcpDeleteResponseSchema, Lr as Provider, Lt as ToolRouterSessionFilesMountListOptions, M as SessionWithoutMcp, Mi as MetaToolArguments, Mn as BaseComposioProvider, Mr as McpUrlResponseCamelCase, Mt as RemoteFileDataSchema, N as ToolRouterAuthorizeFn, Ni as ProviderOptions, Nn as BaseNonAgenticProvider, Nr as McpUserConnectionStatus, Nt as ToolRouterSessionFilesMountDeleteOptions, O as SessionExperimental, Oi as RedirectableAuthSchemeSchema, On as UpdateConnectedAccountAclParamsSchema, Or as McpToolkitConnectionStatus, Ot as FileDeleteResponseSchema, P as ToolRouterConfigManageConnectionsSchema, Pi as SessionExecuteMetaModifiers, Pn as ComposioCustomCreateResponseSchema, Pr as ExecuteToolFn, Pt as ToolRouterSessionFilesMountDeleteOptionsSchema, Q as ToolRouterSessionExecuteResponseSchema, Qi as ToolExecuteParamsSchema, Qn as MCPCreateMethodResponse, Qr as Oauth1ActiveConnectionData, Qt as ConnectedAccountExperimentalResponseSchema, R as ToolRouterConfigToolsSchema, Ri as afterExecuteMetaModifier, Rn as ComposioMcpListResponseSchema, Rr as ToolCallExecutionTarget, Rt as ToolRouterSessionFilesMountListOptionsSchema, S as SessionContext, Si as Oauth2InitiatedConnectionData, Sn as CreateConnectedAccountParams, Sr as McpListResponseSchema, St as ToolkitConnectionState, T as SandboxSize, Ti as Oauth2InitiatingConnectionDataSchema, Tn as CreateConnectedAccountResponseSchema, Tr as McpServerCreateResponse, Tt as ToolkitConnectionsDetailsSchema, U as ToolRouterManageConnectionsConfigSchema, Ui as CustomAuthParams, Un as CustomCreateResponseSchema, Ur as ConnectionDataSchema, Ut as ConnectionRequestState, V as ToolRouterMCPServerConfig, Vi as beforeExecuteModifier, Vn as ConnectionStatus, Vr as BillcomAuthConnectionDataSchema, Vt as ComposioRequestOptions, W as ToolRouterSandboxConfig, Wi as CustomAuthParamsSchema, Wn as CustomCreateResponseValidated, Wr as ConnectionStatusEnum, Wt as ConnectedAccountAclConfig, X as ToolRouterSessionExecuteOptions, Xi as ToolExecuteMetaParamsSchema, Xn as MCPAuthOptions, Xr as CustomOauth2ConnectionData, Xt as ConnectedAccountExperimental, Y as ToolRouterSessionExecuteFn, Yi as ToolExecuteMetaParams, Yn as GenerateURLResponseValidated, Yr as CustomOauth1ConnectionDataSchema, Yt as ConnectedAccountAuthConfigSchema, Z as ToolRouterSessionExecuteResponse, Zi as ToolExecuteParams, Zn as MCPAuthOptionsSchema, Zr as CustomOauth2ConnectionDataSchema, Zt as ConnectedAccountExperimentalResponse, _ as CustomToolsMapEntry, _a as ToolkitVersionSchema, _i as Oauth2ExpiredConnectionDataSchema, _n as CreateConnectedAccountLinkOptionsSchema, _r as MCPToolkitConfigSchema, _t as ToolRouterToolsFn, a as CreateCustomToolkitParams, aa as ToolListResponseSchema, ai as Oauth1FailedConnectionDataSchema, an as ConnectedAccountRefreshOptions, ar as MCPMultiAppServerSchema, at as ToolRouterSessionSearchResponseSchema, b as RegisteredCustomTool, bi as Oauth2InactiveConnectionData, bn as CreateConnectedAccountOptions, br as McpDeleteResponseSchema, bt as ToolRouterUpdateSessionConfig, c as CustomToolExecuteFn, ca as ToolRetrievalOptions, ci as Oauth1InitiatedConnectionData, cn as ConnectedAccountRetrieveResponseSchema, cr as MCPServerCreateResponseSchema, ct as ToolRouterSessionWorkbenchConfig, d as CustomToolWireDefinition, da as ToolkitLatestVersion, di as Oauth1InitiatingConnectionDataSchema, dn as ConnectedAccountStatusSchema, dr as MCPServerSchema, dt as ToolRouterToolkitsDisabledConfigSchema, ea as ToolExecuteResponseSchema, ei as Oauth1ConnectionData, en as ConnectedAccountListParams, er as MCPGenerateURLParamsSchema, et as ToolRouterSessionPreloadConfig, f as CustomToolkit, fa as ToolkitLatestVersionSchema, fi as Oauth2ActiveConnectionData, fn as ConnectedAccountStatuses, fr as MCPServerUpdateParams, ft as ToolRouterToolkitsEnabledConfigSchema, g as CustomToolsMap, ga as ToolkitVersionParamSchema, gi as Oauth2ExpiredConnectionData, gn as CreateConnectedAccountLinkOptions, gr as MCPToolkitConfig, gt as ToolRouterToolkitsParamSchema, h as CustomToolkitWireDefinition, ha as ToolkitVersionParam, hi as Oauth2ConnectionDataSchema, hn as ConnectedAccountTypes, hr as MCPSingleAppServerSchema, ht as ToolRouterToolkitsOptionsSchema, i as CreateCustomToolkitBaseSchema, ia as ToolListResponse, ii as Oauth1FailedConnectionData, in as ConnectedAccountListResponseSchema, ir as MCPMultiAppServer, it as ToolRouterSessionSearchResponse, j as SessionProxyExecuteParamsSchema, ji as ExecuteToolModifiers, jn as BaseAgenticProvider, jr as McpUrlResponse, jt as RemoteFileData, k as SessionPreset, ki as AgenticToolOptions, kn as UpdateConnectedAccountParams, kr as McpUpdateResponse, kt as FileListResponse, l as CustomToolResponse, la as ToolSchema, li as Oauth1InitiatedConnectionDataSchema, ln as ConnectedAccountStatus, lr as MCPServerListResponse, lt as ToolRouterTagsEnableDisableSchema, m as CustomToolkitResponse, ma as ToolkitVersion, mi as Oauth2ConnectionData, mn as ConnectedAccountTypeSchema, mr as MCPSingleAppServer, mt as ToolRouterToolkitsOptions, n as CreateCustomToolBaseSchema, na as ToolListParams, ni as Oauth1ExpiredConnectionData, nn as ConnectedAccountListResponse, nr as MCPGetServerParamsSchema, nt as ToolRouterSessionProxyExecuteResponse, o as CustomTool, oa as ToolProxyParams, oi as Oauth1InactiveConnectionData, on as ConnectedAccountRefreshOptionsSchema, or as MCPServer, ot as ToolRouterSessionUpdateFn, p as CustomToolkitDefinition, pa as ToolkitSchema, pi as Oauth2ActiveConnectionDataSchema, pn as ConnectedAccountType, pr as MCPServerUpdateParamsSchema, pt as ToolRouterToolkitsFn, q as ToolRouterSessionDeleteResponse, qi as SchemaModifierOptions, qn as GenerateURLResponse, qr as CustomConnectionDataSchema, qt as ConnectedAccountAclConfigSchema, r as CreateCustomToolParams, ra as ToolListParamsSchema, ri as Oauth1ExpiredConnectionDataSchema, rn as ConnectedAccountListResponseItem, rr as MCPInstanceParams, rt as ToolRouterSessionSearchFn, s as CustomToolDefinition, sa as ToolProxyParamsSchema, si as Oauth1InactiveConnectionDataSchema, sn as ConnectedAccountRetrieveResponse, sr as MCPServerCreateResponse, st as ToolRouterSessionWarning, t as AnyZodSchema, ta as ToolList, ti as Oauth1ConnectionDataSchema, tn as ConnectedAccountListParamsSchema, tr as MCPGetServerParams, tt as ToolRouterSessionProxyExecuteFn, u as CustomToolSlugSchema, ua as Toolkit, ui as Oauth1InitiatingConnectionData, un as ConnectedAccountStatusEnum, ur as MCPServerListResponseSchema, ut as ToolRouterTagsParamSchema, v as InferZodSchema, va as ToolkitVersions, vi as Oauth2FailedConnectionData, vn as CreateConnectedAccountLinkResponse, vr as MCPToolkitConfigsArraySchema, vt as ToolRouterToolsParam, w as MCPServerTypeSchema, wi as Oauth2InitiatingConnectionData, wn as CreateConnectedAccountResponse, wr as McpRetrieveResponseSchema, wt as ToolkitConnectionsDetails, x as RegisteredCustomToolkit, xi as Oauth2InactiveConnectionDataSchema, xn as CreateConnectedAccountOptionsSchema, xr as McpListResponse, xt as ToolRouterUpdateSessionConfigSchema, y as InlineCustomToolsWirePayload, ya as ToolkitVersionsSchema, yi as Oauth2FailedConnectionDataSchema, yn as CreateConnectedAccountLinkResponseSchema, yr as McpDeleteResponse, yt as ToolRouterToolsParamSchema, z as ToolRouterCreateSessionConfig, zi as afterExecuteModifier, zn as ComposioMcpRetrieveResponseSchema, zr as ToolCallSession, zt as ToolRouterSessionFilesMountUploadOptions } from "./customTool.types-DpJbYY5m.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "./CustomTool-CwpeQhz2.mjs";
|
|
3
|
+
import { $ as WebhookPayloadV3, $t as ToolkitsListParamsSchema, A as TriggerInstanceUpsertResponse, At as ToolKitItem, B as TriggersTypeListParamsSchema, Bt as ToolkitAuthFieldsResponse, C as TriggerInstanceManageDeleteResponseSchema, Ct as AuthSchemeTypes, D as TriggerInstanceManageUpdateResponseSchema, Dt as CreateAuthConfigResponseSchema, E as TriggerInstanceManageUpdateResponse, Et as CreateAuthConfigResponse, F as TriggerSubscribeParamSchema, Ft as ToolKitMetaSchema, G as VerifyWebhookParamsSchema, Gt as ToolkitMangedByEnum, H as TriggersTypeListResponseSchema, Ht as ToolkitCategory, I as TriggerSubscribeParams, It as ToolkitAuthConfigDetails, J as WebhookPayloadSchema, Jt as ToolkitRetrieveCategoriesResponseSchema, K as VerifyWebhookResult, Kt as ToolkitMangedByEnumSchema, L as TriggerType, Lt as ToolkitAuthConfigDetailsSchema, M as TriggerStatusEnum, Mt as ToolKitListResponse, N as TriggerStatusType, Nt as ToolKitListResponseSchema, O as TriggerInstanceUpsertParams, Ot as CreateComposioManagedAuthConfigParamsSchema, P as TriggerStatuses, Pt as ToolKitMeta, Q as WebhookPayloadV2Schema, Qt as ToolkitSortByEnumSchema, R as TriggerTypeSchema, Rt as ToolkitAuthField, S as TriggerInstanceManageDeleteResponse, St as AuthSchemeType, T as TriggerInstanceManageUpdateParamsSchema, Tt as CreateAuthConfigParamsSchema, U as TriggersTypeRetrieveResponse, Ut as ToolkitCategorySchema, V as TriggersTypeListResponse, Vt as ToolkitAuthFieldsResponseSchema, W as VerifyWebhookParams, Wt as ToolkitListParams, X as WebhookPayloadV1Schema, Xt as ToolkitRetrieveResponseSchema, Y as WebhookPayloadV1, Yt as ToolkitRetrieveResponse, Z as WebhookPayloadV2, Zt as ToolkitSortByEnum, _ as TriggerInstanceListActiveParamsSchema, _t as AuthConfigUpdateParams, a as MCP, at as WebhookVersion, b as TriggerInstanceListActiveResponseItemSchema, bt as AuthDefaultConfigUpdateParamsSchema, c as IncomingTriggerPayload, ct as AuthConfigListParams, d as SetWebhookSubscriptionParams, dt as AuthConfigListResponseSchema, et as WebhookPayloadV3Schema, f as SetWebhookSubscriptionParamsSchema, ft as AuthConfigRetrieveResponse, g as TriggerInstanceListActiveParams, gt as AuthConfigTypes, h as TriggerEventData, ht as AuthConfigType, i as OpenAIProvider, it as WebhookTriggerPayloadV3Schema, j as TriggerInstanceUpsertResponseSchema, jt as ToolKitItemSchema, k as TriggerInstanceUpsertParamsSchema, kt as CreateCustomAuthConfigParamsSchema, l as IncomingTriggerPayloadSchema, lt as AuthConfigListParamsSchema, m as TriggerEvent, mt as AuthConfigToolAccessConfigSchema, n as ComposioConfig, nt as WebhookSubscription, o as Experimental, ot as WebhookVersions, p as TriggerData, pt as AuthConfigRetrieveResponseSchema, q as WebhookPayload, qt as ToolkitRetrieveCategoriesResponse, r as Sessions, rt as WebhookTriggerPayloadV3, s as DefaultWebhookSubscriptionEvents, st as AuthConfigCreationToolAccessConfigSchema, t as Composio, tt as WebhookRequestLike, u as ParseWebhookOptions, ut as AuthConfigListResponse, v as TriggerInstanceListActiveResponse, vt as AuthConfigUpdateParamsSchema, w as TriggerInstanceManageUpdateParams, wt as CreateAuthConfigParams, x as TriggerInstanceListActiveResponseSchema, xt as AuthSchemeEnum, y as TriggerInstanceListActiveResponseItem, yt as AuthCustomConfigUpdateParamsSchema, z as TriggersTypeListParams, zt as ToolkitAuthFieldSchema } from "./composio-XjF7EMEe.mjs";
|
|
4
4
|
import { n as FileUploadData, t as FileDownloadData } from "./files.types-DeMC_mAW.mjs";
|
|
5
5
|
import ComposioClient, { Composio as Composio$1 } from "@composio/client";
|
|
6
6
|
import { z as z$1 } from "zod/v3";
|
|
@@ -469,6 +469,7 @@ declare class ToolRouterSession<TToolCollection, TTool, TProvider extends BaseCo
|
|
|
469
469
|
* is intercepted: local tools are executed in-process, remote tools are sent to the backend.
|
|
470
470
|
*/
|
|
471
471
|
tools(modifiers?: SessionMetaToolOptions, requestOptions?: ComposioRequestOptions): Promise<ReturnType<TProvider['wrapTools']>>;
|
|
472
|
+
private applySchemaModifier;
|
|
472
473
|
private addPreloadedCustomTools;
|
|
473
474
|
private getPreloadedCustomToolSchemas;
|
|
474
475
|
private customToolEntryToTool;
|
|
@@ -518,16 +519,16 @@ declare class ToolRouterSession<TToolCollection, TTool, TProvider extends BaseCo
|
|
|
518
519
|
*/
|
|
519
520
|
toolkits(options?: ToolRouterToolkitsOptions, requestOptions?: ComposioRequestOptions): Promise<{
|
|
520
521
|
items: {
|
|
521
|
-
name: string;
|
|
522
522
|
slug: string;
|
|
523
|
+
name: string;
|
|
523
524
|
isNoAuth: boolean;
|
|
524
525
|
logo?: string | undefined;
|
|
525
526
|
connection?: {
|
|
526
527
|
isActive: boolean;
|
|
527
528
|
authConfig?: {
|
|
528
529
|
id: string;
|
|
529
|
-
mode: string;
|
|
530
530
|
isComposioManaged: boolean;
|
|
531
|
+
mode: string;
|
|
531
532
|
} | null | undefined;
|
|
532
533
|
connectedAccount?: {
|
|
533
534
|
status: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as COMPOSIO_DIR, c as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, d as USER_DATA_FILE_NAME, f as constants_exports, i as logger, l as IS_DEVELOPMENT_OR_CI, m as getEnvsWithPrefix, n as SsrfErrorCodes, o as COMPOSIO_LOG_LEVEL, p as getEnvVariable, r as ComposioError, s as DEFAULT_BASE_URL, t as ComposioBlockedInternalUrlError, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
2
|
import { A as ToolErrorCodes, B as ComposioSharedAccessDeniedError, C as ComposioInvalidExecuteFunctionError, D as ComposioToolExecutionError, E as ComposioProviderNotDefinedError, F as ComposioAclOnlyForSharedError, H as ConnectedAccountErrorCodes, I as ComposioConnectedAccountNotFoundError, L as ComposioFailedToCreateConnectedAccountLink, M as ConnectionRequestErrorCodes, N as ConnectionRequestFailedError, O as ComposioToolNotFoundError, P as ConnectionRequestTimeoutError, R as ComposioLegacyConnectedAccountsEndpointRetiredError, S as ComposioGlobalExecuteToolFnNotSetError, T as ComposioInvalidToolArgumentsError, U as AuthConfigErrorCodes, V as ComposioSharedConnectionNotAccessibleError, W as ComposioAuthConfigNotFoundError, _ as ValidationError, a as ComposioFailedToSubscribeToPusherChannelError, b as ComposioToolkitNotFoundError, c as ComposioWebhookPayloadError, d as ComposioNoAPIKeyError, f as ComposioRequestCancelledError, g as JsonSchemaToZodError, h as JsonSchemaRefResolutionError, i as ComposioFailedToGetSDKRealtimeCredentialsError, j as handleToolExecutionError, k as ComposioToolVersionRequiredError, l as ComposioWebhookSignatureVerificationError, m as isRequestAbortError, n as RemoteFileErrorCodes, o as ComposioFailedToUnsubscribeFromPusherChannelError, p as SDKErrorCodes, r as ComposioFailedToCreatePusherClientError, s as ComposioTriggerTypeNotFoundError, t as RemoteFileDownloadError, u as TriggerErrorCodes, v as ValidationErrorCodes, w as ComposioInvalidModifierError, x as ToolkitErrorCodes, y as ComposioToolkitFetchError, z as ComposioMultipleConnectedAccountsError } from "./errors-BcEUHZbq.mjs";
|
|
3
3
|
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-B8V8_3VE.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { a as jsonSchemaToZodSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as removeNonRequiredProperties, r as dereferenceJsonSchema, t as withCancellation } from "./cancellation-
|
|
6
|
-
import { t as telemetry } from "./Telemetry-
|
|
7
|
-
import { a as arrayBufferToBase64, c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, r as isBlockedSensitiveFileUploadPath, t as BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS } from "./sensitiveFileUploadPaths-
|
|
4
|
+
import { n as dropEmptyFileUploads, o as isPlainObject, s as schemaHasFileUploadable } from "./FileToolModifier.utils.neutral-D_YkHwZP.mjs";
|
|
5
|
+
import { a as jsonSchemaToZodSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as removeNonRequiredProperties, r as dereferenceJsonSchema, t as withCancellation } from "./cancellation-C-qy8rcj.mjs";
|
|
6
|
+
import { t as telemetry } from "./Telemetry-DK1uAWnD.mjs";
|
|
7
|
+
import { a as arrayBufferToBase64, c as getRandomShortId, i as readResponseBodyWithLimit, n as assertSafeFileUploadPath, r as isBlockedSensitiveFileUploadPath, t as BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS } from "./sensitiveFileUploadPaths-B0w8dqpv.mjs";
|
|
8
8
|
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-l-j5HtEf.mjs";
|
|
9
9
|
import ComposioClient, { APIError, BadRequestError } from "@composio/client";
|
|
10
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
@@ -1328,11 +1328,32 @@ var Tools = class {
|
|
|
1328
1328
|
*/
|
|
1329
1329
|
async applyBeforeExecuteModifiers(tool, { toolSlug, toolkitSlug, params }, modifiers, requestOptions) {
|
|
1330
1330
|
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1331
|
+
let modifiedParams = await this.applyFileUploadModifiers(tool, {
|
|
1332
|
+
toolSlug,
|
|
1333
|
+
toolkitSlug,
|
|
1334
|
+
params
|
|
1335
|
+
}, modifiers?.beforeFileUpload, requestOptions);
|
|
1336
|
+
if (modifiers?.beforeExecute) if (typeof modifiers.beforeExecute === "function") {
|
|
1337
|
+
modifiedParams = await modifiers.beforeExecute({
|
|
1338
|
+
toolSlug,
|
|
1339
|
+
toolkitSlug,
|
|
1340
|
+
params: modifiedParams
|
|
1341
|
+
});
|
|
1342
|
+
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1343
|
+
} else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1344
|
+
return modifiedParams;
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Applies schema-aware file preprocessing shared by direct and Tool Router
|
|
1348
|
+
* session execution. This always runs before the caller's `beforeExecute`
|
|
1349
|
+
* hook so the hook observes the exact arguments sent to the backend.
|
|
1350
|
+
*/
|
|
1351
|
+
async applyFileUploadModifiers(tool, { toolSlug, toolkitSlug, params }, beforeFileUpload, requestOptions) {
|
|
1331
1352
|
let modifiedParams = params;
|
|
1332
1353
|
if (this.autoUploadDownloadFiles) {
|
|
1333
1354
|
modifiedParams = await new FileToolModifier(this.client, {
|
|
1334
1355
|
...this.fileUploadPathOptions,
|
|
1335
|
-
beforeFileUpload
|
|
1356
|
+
beforeFileUpload
|
|
1336
1357
|
}).fileUploadModifier(tool, {
|
|
1337
1358
|
toolSlug,
|
|
1338
1359
|
toolkitSlug,
|
|
@@ -1340,18 +1361,16 @@ var Tools = class {
|
|
|
1340
1361
|
signal: requestOptions?.signal
|
|
1341
1362
|
});
|
|
1342
1363
|
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1343
|
-
} else if (
|
|
1344
|
-
|
|
1345
|
-
|
|
1364
|
+
} else if (tool.inputParameters && schemaHasFileUploadable(tool.inputParameters)) {
|
|
1365
|
+
if (modifiedParams.arguments) modifiedParams = {
|
|
1366
|
+
...modifiedParams,
|
|
1367
|
+
arguments: await dropEmptyFileUploads(modifiedParams.arguments, dereferenceJsonSchema(tool.inputParameters, { onUnresolved: "sentinel" }))
|
|
1368
|
+
};
|
|
1369
|
+
if (!this.warnedAutoUploadDisabledForTool.has(toolSlug)) {
|
|
1370
|
+
this.warnedAutoUploadDisabledForTool.add(toolSlug);
|
|
1371
|
+
logger.warn(`Tool "${toolSlug}" (toolkit "${toolkitSlug}") has a file-uploadable input, but \`dangerouslyAllowAutoUploadDownloadFiles\` is disabled. The SDK will forward the file argument as-is; if it isn't already a staged { name, mimetype, s3key } descriptor, the backend will reject the call. Either:\n 1) Stage the file yourself: \`const f = await composio.files.upload({ file, toolSlug, toolkitSlug }); await composio.tools.execute('${toolSlug}', { userId, arguments: { <fileField>: f } })\`, or\n 2) Enable auto-upload with a scoped allowlist: \`new Composio({ dangerouslyAllowAutoUploadDownloadFiles: true, fileUploadDirs: ['/safe/dir'] })\`.`);
|
|
1372
|
+
}
|
|
1346
1373
|
}
|
|
1347
|
-
if (modifiers?.beforeExecute) if (typeof modifiers.beforeExecute === "function") {
|
|
1348
|
-
modifiedParams = await modifiers.beforeExecute({
|
|
1349
|
-
toolSlug,
|
|
1350
|
-
toolkitSlug,
|
|
1351
|
-
params: modifiedParams
|
|
1352
|
-
});
|
|
1353
|
-
if (requestOptions?.signal?.aborted) throw new ComposioRequestCancelledError();
|
|
1354
|
-
} else throw new ComposioInvalidModifierError("Invalid beforeExecute modifier. Not a function.");
|
|
1355
1374
|
return modifiedParams;
|
|
1356
1375
|
}
|
|
1357
1376
|
/**
|
|
@@ -1651,8 +1670,8 @@ var Tools = class {
|
|
|
1651
1670
|
* @param {SessionExecuteMetaModifiers} modifiers - The modifiers to apply to the tool
|
|
1652
1671
|
* @returns {Tool[]} The wrapped tools
|
|
1653
1672
|
*/
|
|
1654
|
-
wrapToolsForToolRouter(sessionId, tools, modifiers) {
|
|
1655
|
-
const executeToolFn = this.createExecuteToolFnForToolRouter(sessionId,
|
|
1673
|
+
wrapToolsForToolRouter(sessionId, tools, modifiers, rawTools = tools.map((tool) => ToolSchema.parse(tool))) {
|
|
1674
|
+
const executeToolFn = this.createExecuteToolFnForToolRouter(sessionId, rawTools, modifiers);
|
|
1656
1675
|
return this.provider.wrapTools(tools, executeToolFn);
|
|
1657
1676
|
}
|
|
1658
1677
|
/**
|
|
@@ -1857,6 +1876,11 @@ var Tools = class {
|
|
|
1857
1876
|
if (!executeParams.success) throw new ValidationError("Invalid tool execute session parameters", { cause: executeParams.error });
|
|
1858
1877
|
let modifiedParams = body.arguments ?? {};
|
|
1859
1878
|
const toolkitSlug = tool?.toolkit?.slug ?? "composio";
|
|
1879
|
+
if (tool) modifiedParams = (await this.applyFileUploadModifiers(tool, {
|
|
1880
|
+
toolSlug,
|
|
1881
|
+
toolkitSlug,
|
|
1882
|
+
params: { arguments: modifiedParams }
|
|
1883
|
+
}, void 0, requestOptions)).arguments ?? {};
|
|
1860
1884
|
if (modifiers?.beforeExecute) modifiedParams = await modifiers.beforeExecute({
|
|
1861
1885
|
toolSlug,
|
|
1862
1886
|
toolkitSlug,
|
|
@@ -5989,7 +6013,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
5989
6013
|
|
|
5990
6014
|
//#endregion
|
|
5991
6015
|
//#region package.json
|
|
5992
|
-
var version = "0.
|
|
6016
|
+
var version = "1.0.0-beta.0";
|
|
5993
6017
|
|
|
5994
6018
|
//#endregion
|
|
5995
6019
|
//#region src/utils/session.ts
|
|
@@ -7302,21 +7326,31 @@ var ToolRouterSession = class {
|
|
|
7302
7326
|
*/
|
|
7303
7327
|
async tools(modifiers, requestOptions) {
|
|
7304
7328
|
const ToolsModel = new Tools(this.client, this.config);
|
|
7305
|
-
const
|
|
7329
|
+
const rawTools = await ToolsModel.getRawToolRouterSessionTools(this.sessionId, void 0, requestOptions);
|
|
7330
|
+
const tools = await this.applySchemaModifier(rawTools, modifiers?.modifySchema);
|
|
7306
7331
|
const sessionTools = await this.addPreloadedCustomTools(tools, modifiers);
|
|
7307
|
-
const
|
|
7332
|
+
const rawToolBySlug = new Map(rawTools.map((tool) => [tool.slug.toUpperCase(), tool]));
|
|
7308
7333
|
if (this.hasCustomTools()) {
|
|
7309
7334
|
const routingExecuteFn = async (toolSlug, input) => {
|
|
7310
|
-
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel,
|
|
7335
|
+
if (toolSlug === COMPOSIO_MULTI_EXECUTE_TOOL) return this.routeMultiExecute(input, ToolsModel, rawTools, modifiers);
|
|
7311
7336
|
const customTool = findCustomTool(this.customToolsMap, toolSlug);
|
|
7312
7337
|
if (customTool) return executeCustomTool(customTool, input, this.sessionContext);
|
|
7313
7338
|
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
7314
|
-
return this.executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers,
|
|
7339
|
+
return this.executeBackendSessionTool(ToolsModel, toolSlug, input, modifiers, rawToolBySlug.get(toolSlug.toUpperCase()));
|
|
7315
7340
|
};
|
|
7316
7341
|
if (!this.config?.provider) throw new Error("A provider is required when using custom tools with session.tools(). Pass a provider in the Composio constructor.");
|
|
7317
7342
|
return this.config.provider.wrapTools(sessionTools, routingExecuteFn);
|
|
7318
7343
|
}
|
|
7319
|
-
return ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers);
|
|
7344
|
+
return modifiers?.modifySchema ? ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers, rawTools) : ToolsModel.wrapToolsForToolRouter(this.sessionId, sessionTools, modifiers);
|
|
7345
|
+
}
|
|
7346
|
+
async applySchemaModifier(tools, modifier) {
|
|
7347
|
+
if (!modifier) return tools;
|
|
7348
|
+
if (typeof modifier !== "function") throw new ComposioInvalidModifierError("Invalid schema modifier. Not a function.");
|
|
7349
|
+
return Promise.all(tools.map((tool) => modifier({
|
|
7350
|
+
toolSlug: tool.slug,
|
|
7351
|
+
toolkitSlug: tool.toolkit?.slug ?? "unknown",
|
|
7352
|
+
schema: ToolSchema.parse(tool)
|
|
7353
|
+
})));
|
|
7320
7354
|
}
|
|
7321
7355
|
async addPreloadedCustomTools(tools, modifiers) {
|
|
7322
7356
|
const customTools = await this.getPreloadedCustomToolSchemas(modifiers);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as telemetry } from "../Telemetry-
|
|
2
|
-
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-
|
|
1
|
+
import { t as telemetry } from "../Telemetry-DK1uAWnD.mjs";
|
|
2
|
+
import { n as getFileDataAfterUploadingToS3, t as downloadFileFromS3 } from "../fileUtils.node-BwpUOF0s.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/models/Files.node.ts
|
|
5
5
|
var Files = class {
|
package/dist/{sensitiveFileUploadPaths-BVEt0peg.mjs → sensitiveFileUploadPaths-B0w8dqpv.mjs}
RENAMED
|
@@ -112,8 +112,22 @@ const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS = [
|
|
|
112
112
|
const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
|
|
113
113
|
/** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
|
|
114
114
|
const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
|
|
115
|
+
const splitSegments = (aPath) => aPath.split(/[/\\]+/).filter(Boolean);
|
|
115
116
|
/**
|
|
116
117
|
* Returns normalized path segments, resolving symlinks when the path exists.
|
|
118
|
+
*
|
|
119
|
+
* Both the written path and the symlink-resolved one are returned, because a
|
|
120
|
+
* denied segment can be hidden by a symlink in either direction:
|
|
121
|
+
*
|
|
122
|
+
* - `~/innocent-name` -> `~/nested/.aws/creds` hides `.aws` from the written
|
|
123
|
+
* path, so the denylist has to see the resolved one.
|
|
124
|
+
* - `~/.claude` -> `/state/claude` hides `.claude` from the *resolved* path,
|
|
125
|
+
* so the denylist also has to see the written one. Dotfile managers
|
|
126
|
+
* (chezmoi, stow, yadm) and containerised home directories produce exactly
|
|
127
|
+
* this layout.
|
|
128
|
+
*
|
|
129
|
+
* Matching only the resolved path silently turns the denylist off for the
|
|
130
|
+
* second case.
|
|
117
131
|
*/
|
|
118
132
|
function normalizePath(filePath) {
|
|
119
133
|
const absolute = platform.resolvePath(filePath);
|
|
@@ -123,7 +137,8 @@ function normalizePath(filePath) {
|
|
|
123
137
|
} catch {}
|
|
124
138
|
return {
|
|
125
139
|
resolvedPath: resolved,
|
|
126
|
-
segments: resolved
|
|
140
|
+
segments: splitSegments(resolved),
|
|
141
|
+
writtenSegments: splitSegments(absolute)
|
|
127
142
|
};
|
|
128
143
|
}
|
|
129
144
|
/**
|
|
@@ -134,14 +149,16 @@ function isBlockedSensitiveFileUploadPath(filePath, additionalDenySegments) {
|
|
|
134
149
|
return getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) != null;
|
|
135
150
|
}
|
|
136
151
|
function getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) {
|
|
137
|
-
const { resolvedPath, segments } = normalizePath(filePath);
|
|
152
|
+
const { resolvedPath, segments, writtenSegments } = normalizePath(filePath);
|
|
138
153
|
const isCaseSensitive = platform.isFileSystemCaseSensitive?.(resolvedPath) ?? true;
|
|
139
154
|
const normalizeSegment = (segment) => isCaseSensitive ? segment : segment.toLowerCase();
|
|
140
155
|
const deny = new Set([...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, ...(additionalDenySegments ?? []).map((s) => s.trim()).filter(Boolean)].map(normalizeSegment));
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
for (const candidate of [segments, writtenSegments]) {
|
|
157
|
+
const segmentsForMatch = isCaseSensitive ? candidate : candidate.map(normalizeSegment);
|
|
158
|
+
for (let i = 0; i < candidate.length; i++) if (deny.has(segmentsForMatch[i])) return `path segment "${candidate[i]}" is in the sensitive file upload denylist`;
|
|
159
|
+
}
|
|
160
|
+
const basenames = [segments.at(-1), writtenSegments.at(-1)].filter((name) => !!name);
|
|
161
|
+
for (const basename of basenames) {
|
|
145
162
|
if (SECRET_LIKE_BASENAME.test(basename) || DEFAULT_PRIVATE_KEY_BASENAME.test(basename)) return `file name "${basename}" looks like a credential, env, or private key file`;
|
|
146
163
|
if (basename.toLowerCase() === "credentials") return "file name \"credentials\" is often used for cloud/API credential stores";
|
|
147
164
|
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { t as ComposioBlockedInternalUrlError } from "./SsrfErrors-DNJt57GL.mjs";
|
|
2
|
+
import { lookup } from "node:dns/promises";
|
|
3
|
+
import { isIP } from "node:net";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/pinnedDispatcher.node.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `globalThis` symbols that hold the process-wide dispatcher `fetch` falls
|
|
8
|
+
* back to. Every undici in the process shares them — including the one inside
|
|
9
|
+
* the Node runtime — and `setGlobalDispatcher` writes both, so reading them
|
|
10
|
+
* directly sees the same dispatcher the runtime's own `fetch` would use.
|
|
11
|
+
*
|
|
12
|
+
* Read rather than imported: importing `undici` installs a dispatcher of its
|
|
13
|
+
* own as an import side effect (see {@link loadUndici}), which is exactly what
|
|
14
|
+
* this module must not do at load time.
|
|
15
|
+
*/
|
|
16
|
+
const GLOBAL_DISPATCHER_SYMBOLS = [Symbol.for("undici.globalDispatcher.1"), Symbol.for("undici.globalDispatcher.2")];
|
|
17
|
+
/**
|
|
18
|
+
* `undici`, imported on first use rather than at module load.
|
|
19
|
+
*
|
|
20
|
+
* Importing it runs `if (getGlobalDispatcher() === undefined) setGlobalDispatcher(new Agent())`
|
|
21
|
+
* as a side effect, which would hand every unrelated `fetch` in the host
|
|
22
|
+
* application this package's undici instead of the runtime's own — a global
|
|
23
|
+
* change no caller asked for by importing `@composio/core`. Deferring the
|
|
24
|
+
* import to the first pinned request keeps that side effect on the code path
|
|
25
|
+
* that actually needs undici, and behind the `hasCustomGlobalDispatcher` check
|
|
26
|
+
* that reads the slot's true, pre-import state.
|
|
27
|
+
*
|
|
28
|
+
* A process that does make a pinned request still ends up on this package's
|
|
29
|
+
* `Agent` if nothing had claimed the slot yet. That much is not reversible:
|
|
30
|
+
* undici defines the slot non-configurable and writable, so it cannot be
|
|
31
|
+
* cleared back to empty — assigning `undefined` leaves the runtime's own
|
|
32
|
+
* `fetch` asserting on a missing dispatcher.
|
|
33
|
+
*/
|
|
34
|
+
let undici;
|
|
35
|
+
const loadUndici = () => undici ??= import("undici");
|
|
36
|
+
/**
|
|
37
|
+
* A `fetch` dispatcher that connects to `addresses` instead of resolving the
|
|
38
|
+
* hostname again.
|
|
39
|
+
*
|
|
40
|
+
* The SSRF guard resolves a hostname to decide whether a URL is safe to fetch.
|
|
41
|
+
* `fetch` would then resolve that hostname a second time when it opens the
|
|
42
|
+
* socket, and the two answers need not match: a short-TTL record can answer
|
|
43
|
+
* with a public address for the check and an internal one for the connect
|
|
44
|
+
* (DNS rebinding). Pinning the connect to the address that was validated
|
|
45
|
+
* removes the second lookup, so there is nothing left to rebind.
|
|
46
|
+
*
|
|
47
|
+
* Only the connect target is replaced. The request still carries the original
|
|
48
|
+
* hostname in `Host` and offers it as TLS SNI, so certificate verification is
|
|
49
|
+
* unchanged — connecting by IP with the IP as SNI would fail against every
|
|
50
|
+
* origin whose certificate names a hostname.
|
|
51
|
+
*
|
|
52
|
+
* The dispatcher is handed to the runtime's own `fetch`, so callers that stub
|
|
53
|
+
* `globalThis.fetch` keep working. That does tie the `undici` major to the one
|
|
54
|
+
* Node's `fetch` speaks — undici 8 dispatchers are rejected by the Node
|
|
55
|
+
* versions this package supports — which is why the dependency is pinned to
|
|
56
|
+
* `^7`, and why `pinnedDispatcher.node.test.ts` exercises a real socket on
|
|
57
|
+
* every Node version in CI rather than mocking the transport.
|
|
58
|
+
*/
|
|
59
|
+
const createPinnedDispatcher = async (addresses) => {
|
|
60
|
+
const { Agent } = await loadUndici();
|
|
61
|
+
return new Agent({ connect: { lookup: (_hostname, options, callback) => {
|
|
62
|
+
if (options.all) {
|
|
63
|
+
callback(null, addresses.map((address) => ({
|
|
64
|
+
address,
|
|
65
|
+
family: isIP(address)
|
|
66
|
+
})));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const [address] = addresses;
|
|
70
|
+
callback(null, address, isIP(address));
|
|
71
|
+
} } });
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Whether the process-wide dispatcher `fetch` falls back to (when a request
|
|
75
|
+
* carries no `dispatcher` of its own) is something other than a stock `Agent`.
|
|
76
|
+
*
|
|
77
|
+
* A `ProxyAgent`, `EnvHttpProxyAgent`, or custom dispatcher installed through
|
|
78
|
+
* `setGlobalDispatcher` is visible here, and pinning stands down for it: the
|
|
79
|
+
* connect would dial the validated origin instead of that route's next hop.
|
|
80
|
+
*
|
|
81
|
+
* Nothing installed yet is *not* custom. The dispatcher slot is empty until
|
|
82
|
+
* either the runtime's `fetch` or an undici import fills it, so an absent
|
|
83
|
+
* dispatcher means no caller has configured a route — treating it as custom
|
|
84
|
+
* would disable pinning for every process that had not yet made a request.
|
|
85
|
+
*
|
|
86
|
+
* Stock-ness is compared by constructor *name*, deliberately not with
|
|
87
|
+
* `instanceof Agent`: an `Agent` created by the runtime's internal undici is a
|
|
88
|
+
* different class from this package's `Agent`, so once the runtime's own
|
|
89
|
+
* `fetch` has initialized its default dispatcher, an `instanceof` check would
|
|
90
|
+
* report a stock setup as custom and silently disable pinning.
|
|
91
|
+
*/
|
|
92
|
+
const hasCustomGlobalDispatcher = () => {
|
|
93
|
+
const slots = globalThis;
|
|
94
|
+
const dispatcher = GLOBAL_DISPATCHER_SYMBOLS.map((symbol) => slots[symbol]).find((installed) => installed !== void 0);
|
|
95
|
+
return dispatcher !== void 0 && dispatcher.constructor?.name !== "Agent";
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/utils/ssrfGuard.node.ts
|
|
100
|
+
/**
|
|
101
|
+
* SSRF guard for user-supplied URL file inputs.
|
|
102
|
+
*
|
|
103
|
+
* `composio.files.upload(url)`, Tool Router session file uploads, and automatic
|
|
104
|
+
* file upload during tool execution fetch arbitrary user-provided URLs. Without
|
|
105
|
+
* a guard, a caller (or a tool argument produced by an LLM) can point the SDK at
|
|
106
|
+
* internal infrastructure — loopback, RFC1918 ranges, link-local cloud-metadata
|
|
107
|
+
* endpoints (`169.254.169.254`), or a public URL that 3xx-redirects into internal
|
|
108
|
+
* space — turning the SDK into a server-side request forgery probe.
|
|
109
|
+
*
|
|
110
|
+
* This module validates the *resolved* address (not just the hostname string,
|
|
111
|
+
* which defeats decimal/octal/hex IP obfuscation) before every fetch, and
|
|
112
|
+
* follows redirects manually so each hop is re-validated.
|
|
113
|
+
*
|
|
114
|
+
* The address that was validated is also the address connected to: `fetch` gets
|
|
115
|
+
* a dispatcher pinned to it (see {@link createPinnedDispatcher}), so the
|
|
116
|
+
* hostname is never resolved a second time. Without that, a name could resolve
|
|
117
|
+
* to a public address during validation and rebind to an internal one before
|
|
118
|
+
* the connect — a TOCTOU window the Python guard closes the same way.
|
|
119
|
+
*
|
|
120
|
+
* Residual: a hop whose effective dispatcher is a configured route — a
|
|
121
|
+
* caller-supplied `init.dispatcher`, a non-stock global dispatcher (a
|
|
122
|
+
* `ProxyAgent` or `EnvHttpProxyAgent` installed via `setGlobalDispatcher`), or
|
|
123
|
+
* the runtime's env-proxy mode (`NODE_USE_ENV_PROXY`) — keeps only the
|
|
124
|
+
* pre-flight validation. Pinning would dial the validated address instead of
|
|
125
|
+
* the proxy, and the proxy resolves the hostname itself where the SDK cannot
|
|
126
|
+
* see or pin that resolution. The Python guard carries the same residual for
|
|
127
|
+
* the same reason (`_proxy_applies`).
|
|
128
|
+
*/
|
|
129
|
+
const MAX_REDIRECTS = 5;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the runtime would route `url` through an env proxy the SDK cannot
|
|
132
|
+
* see into. Only meaningful when `NODE_USE_ENV_PROXY` opts the built-in
|
|
133
|
+
* `fetch` into env proxies (Node >= 24); without that flag the runtime's
|
|
134
|
+
* `fetch` ignores `HTTP_PROXY`/`HTTPS_PROXY` entirely, so mirroring Python's
|
|
135
|
+
* bare env-var check would drop pinning for users whose fetch never proxied.
|
|
136
|
+
*
|
|
137
|
+
* `NO_PROXY=*` is the one bypass honored precisely (nothing is proxied, so
|
|
138
|
+
* pinning is safe again); per-host `NO_PROXY` entries are treated
|
|
139
|
+
* conservatively as proxied rather than parsed.
|
|
140
|
+
*/
|
|
141
|
+
const envProxyApplies = (url) => {
|
|
142
|
+
if (!["1", "true"].includes((process.env.NODE_USE_ENV_PROXY ?? "").toLowerCase())) return false;
|
|
143
|
+
if ((process.env.NO_PROXY ?? process.env.no_proxy ?? "") === "*") return false;
|
|
144
|
+
const schemeVar = url.protocol === "https:" ? "HTTPS_PROXY" : "HTTP_PROXY";
|
|
145
|
+
return Boolean(process.env[schemeVar] ?? process.env[schemeVar.toLowerCase()]);
|
|
146
|
+
};
|
|
147
|
+
const ipv4ToLong = (ip) => {
|
|
148
|
+
const [a, b, c, d] = ip.split(".").map(Number);
|
|
149
|
+
return (a << 24 >>> 0 | b << 16 | c << 8 | d) >>> 0;
|
|
150
|
+
};
|
|
151
|
+
const IPV4_BLOCKED_CIDRS = [
|
|
152
|
+
["0.0.0.0", 8],
|
|
153
|
+
["10.0.0.0", 8],
|
|
154
|
+
["100.64.0.0", 10],
|
|
155
|
+
["127.0.0.0", 8],
|
|
156
|
+
["169.254.0.0", 16],
|
|
157
|
+
["172.16.0.0", 12],
|
|
158
|
+
["192.0.0.0", 24],
|
|
159
|
+
["192.0.2.0", 24],
|
|
160
|
+
["192.168.0.0", 16],
|
|
161
|
+
["198.18.0.0", 15],
|
|
162
|
+
["198.51.100.0", 24],
|
|
163
|
+
["203.0.113.0", 24],
|
|
164
|
+
["224.0.0.0", 4],
|
|
165
|
+
["240.0.0.0", 4]
|
|
166
|
+
];
|
|
167
|
+
const isBlockedIpv4Long = (long) => IPV4_BLOCKED_CIDRS.some(([base, bits]) => {
|
|
168
|
+
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
169
|
+
return (long & mask) === (ipv4ToLong(base) & mask);
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* Expand an IPv6 string into its 8 16-bit groups, converting any trailing
|
|
173
|
+
* dotted-quad (e.g. `::ffff:1.2.3.4`) into hex groups first. Returns `null` when
|
|
174
|
+
* the input cannot be parsed.
|
|
175
|
+
*/
|
|
176
|
+
const expandIpv6 = (ip) => {
|
|
177
|
+
let addr = ip;
|
|
178
|
+
const v4Match = addr.match(/^(.*:)(\d+\.\d+\.\d+\.\d+)$/);
|
|
179
|
+
if (v4Match) {
|
|
180
|
+
const long = ipv4ToLong(v4Match[2]);
|
|
181
|
+
addr = `${v4Match[1]}${(long >>> 16 & 65535).toString(16)}:${(long & 65535).toString(16)}`;
|
|
182
|
+
}
|
|
183
|
+
const halves = addr.split("::");
|
|
184
|
+
if (halves.length > 2) return null;
|
|
185
|
+
const head = halves[0] ? halves[0].split(":") : [];
|
|
186
|
+
const tail = halves.length === 2 ? halves[1] ? halves[1].split(":") : [] : [];
|
|
187
|
+
let groups;
|
|
188
|
+
if (halves.length === 2) {
|
|
189
|
+
const missing = 8 - head.length - tail.length;
|
|
190
|
+
if (missing < 0) return null;
|
|
191
|
+
groups = [
|
|
192
|
+
...head,
|
|
193
|
+
...Array(missing).fill("0"),
|
|
194
|
+
...tail
|
|
195
|
+
];
|
|
196
|
+
} else groups = head;
|
|
197
|
+
if (groups.length !== 8) return null;
|
|
198
|
+
return groups.map((g) => parseInt(g || "0", 16));
|
|
199
|
+
};
|
|
200
|
+
const isBlockedIpv6 = (ip) => {
|
|
201
|
+
const h = expandIpv6(ip);
|
|
202
|
+
if (!h) return true;
|
|
203
|
+
if (h.every((x) => x === 0)) return true;
|
|
204
|
+
if (h.slice(0, 7).every((x) => x === 0) && h[7] === 1) return true;
|
|
205
|
+
const isMappedOrCompat = h[0] === 0 && h[1] === 0 && h[2] === 0 && h[3] === 0 && h[4] === 0 && (h[5] === 65535 || h[5] === 0);
|
|
206
|
+
const isNat64 = h[0] === 100 && h[1] === 65435 && h[2] === 0 && h[3] === 0 && h[4] === 0 && h[5] === 0;
|
|
207
|
+
if (isMappedOrCompat || isNat64) return isBlockedIpv4Long((h[6] << 16 >>> 0 | h[7]) >>> 0);
|
|
208
|
+
if ((h[0] & 65024) === 64512) return true;
|
|
209
|
+
if ((h[0] & 65472) === 65152) return true;
|
|
210
|
+
if ((h[0] & 65280) === 65280) return true;
|
|
211
|
+
return false;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* True when `ip` is a private, loopback, link-local, or otherwise
|
|
215
|
+
* non-publicly-routable address. Fails closed (returns `true`) for anything that
|
|
216
|
+
* is not a valid IPv4/IPv6 literal.
|
|
217
|
+
*/
|
|
218
|
+
const isBlockedIp = (ip) => {
|
|
219
|
+
const family = isIP(ip);
|
|
220
|
+
if (family === 4) return isBlockedIpv4Long(ipv4ToLong(ip));
|
|
221
|
+
if (family === 6) return isBlockedIpv6(ip);
|
|
222
|
+
return true;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Validate a single URL: it must be http(s), its host must resolve, and every
|
|
226
|
+
* resolved address must be publicly routable. Throws
|
|
227
|
+
* {@link ComposioBlockedInternalUrlError} otherwise.
|
|
228
|
+
*
|
|
229
|
+
* @returns the validated addresses to connect to, in resolver order. Callers
|
|
230
|
+
* must connect to *those* rather than let the client resolve the hostname
|
|
231
|
+
* again; see {@link ssrfSafeFetch}.
|
|
232
|
+
*/
|
|
233
|
+
const assertSafeFetchTarget = async (rawUrl) => {
|
|
234
|
+
let url;
|
|
235
|
+
try {
|
|
236
|
+
url = new URL(rawUrl);
|
|
237
|
+
} catch {
|
|
238
|
+
throw new ComposioBlockedInternalUrlError("Refusing to fetch a malformed URL", { url: rawUrl });
|
|
239
|
+
}
|
|
240
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") throw new ComposioBlockedInternalUrlError(`Refusing to fetch a non-http(s) URL (scheme "${url.protocol}")`, { url: rawUrl });
|
|
241
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
242
|
+
let resolved;
|
|
243
|
+
try {
|
|
244
|
+
resolved = await lookup(host, {
|
|
245
|
+
all: true,
|
|
246
|
+
verbatim: true
|
|
247
|
+
});
|
|
248
|
+
} catch {
|
|
249
|
+
throw new ComposioBlockedInternalUrlError(`Could not resolve host "${host}"`, { url: rawUrl });
|
|
250
|
+
}
|
|
251
|
+
if (resolved.length === 0) throw new ComposioBlockedInternalUrlError(`Could not resolve host "${host}"`, { url: rawUrl });
|
|
252
|
+
for (const { address } of resolved) if (isBlockedIp(address)) throw new ComposioBlockedInternalUrlError(`Refusing to fetch "${host}" — it resolves to a private, loopback, or link-local address`, {
|
|
253
|
+
url: rawUrl,
|
|
254
|
+
resolvedIp: address
|
|
255
|
+
});
|
|
256
|
+
return resolved.map(({ address }) => address);
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target, then
|
|
260
|
+
* connects to the address it validated, and re-validates and re-pins every
|
|
261
|
+
* redirect hop (redirects are followed manually up to {@link MAX_REDIRECTS}).
|
|
262
|
+
* Intermediate redirect bodies are cancelled; non-redirect responses are
|
|
263
|
+
* returned unchanged.
|
|
264
|
+
*
|
|
265
|
+
* A hop whose effective dispatcher is a configured route (caller-supplied
|
|
266
|
+
* `init.dispatcher`, non-stock global dispatcher, env-proxy mode) is *not*
|
|
267
|
+
* pinned — see the module residual above.
|
|
268
|
+
*/
|
|
269
|
+
const ssrfSafeFetch = async (rawUrl, init = {}, maxRedirects = MAX_REDIRECTS) => {
|
|
270
|
+
let currentUrl = rawUrl;
|
|
271
|
+
for (let hop = 0; hop <= maxRedirects; hop++) {
|
|
272
|
+
const addresses = await assertSafeFetchTarget(currentUrl);
|
|
273
|
+
const dispatcher = init.dispatcher !== void 0 || envProxyApplies(new URL(currentUrl)) || hasCustomGlobalDispatcher() ? void 0 : await createPinnedDispatcher(addresses);
|
|
274
|
+
let response;
|
|
275
|
+
try {
|
|
276
|
+
response = await fetch(currentUrl, dispatcher === void 0 ? {
|
|
277
|
+
...init,
|
|
278
|
+
redirect: "manual"
|
|
279
|
+
} : {
|
|
280
|
+
...init,
|
|
281
|
+
redirect: "manual",
|
|
282
|
+
dispatcher
|
|
283
|
+
});
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (dispatcher !== void 0) await dispatcher.close().catch(() => void 0);
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
if (dispatcher !== void 0) dispatcher.close().catch(() => void 0);
|
|
289
|
+
if (!(response.status >= 300 && response.status < 400 && response.headers.has("location"))) return response;
|
|
290
|
+
await response.body?.cancel().catch(() => void 0);
|
|
291
|
+
currentUrl = new URL(response.headers.get("location"), currentUrl).toString();
|
|
292
|
+
}
|
|
293
|
+
throw new ComposioBlockedInternalUrlError(`Refusing to fetch: too many redirects (max ${maxRedirects})`, { url: rawUrl });
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* {@link ssrfSafeFetch} for call sites that must keep working on every runtime.
|
|
297
|
+
*
|
|
298
|
+
* `ssrfSafeFetch` fails closed in edge runtimes, which is right for a URL the
|
|
299
|
+
* caller chose to upload — the alternative is fetching it unvalidated — but not
|
|
300
|
+
* for Tool Router session file transfers, where refusing would remove a working
|
|
301
|
+
* feature from Workers rather than close a hole reachable there. On Node this
|
|
302
|
+
* is the full guard; only the edge build differs.
|
|
303
|
+
*/
|
|
304
|
+
const ssrfSafeFetchWhereSupported = ssrfSafeFetch;
|
|
305
|
+
|
|
306
|
+
//#endregion
|
|
307
|
+
export { ssrfSafeFetchWhereSupported as i, isBlockedIp as n, ssrfSafeFetch as r, assertSafeFetchTarget as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Mn as BaseComposioProvider } from "./customTool.types-
|
|
2
|
-
import { n as ComposioConfig } from "./composio-
|
|
1
|
+
import { Mn as BaseComposioProvider } from "./customTool.types-DpJbYY5m.mjs";
|
|
2
|
+
import { n as ComposioConfig } from "./composio-XjF7EMEe.mjs";
|
|
3
3
|
//#region src/utils/config-defaults/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Configuration defaults for Composio.
|