@composio/core 0.18.0 → 0.18.1

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 (39) hide show
  1. package/dist/{CustomTool-C4tv-GL1.mjs → CustomTool-Bz0f52QR.mjs} +16 -6
  2. package/dist/{CustomTool-BKhHv2hJ.d.mts → CustomTool-VRfWzMix.d.mts} +1 -1
  3. package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-CwB-Inm9.mjs} +1 -1
  4. package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-xhdVE4yw.mjs} +123 -3
  5. package/dist/{Telemetry-CBtSnWrm.mjs → Telemetry-Dw9W5RSp.mjs} +2 -34
  6. package/dist/{cancellation-jUVItfHw.mjs → cancellation-P5YUlcfz.mjs} +2 -2
  7. package/dist/{composio-CldtZUyC.d.mts → composio-Cb3d1jFe.d.mts} +7 -7
  8. package/dist/{customTool.types-DC5fPOOi.d.mts → customTool.types-B6ej_8XZ.d.mts} +36 -34
  9. package/dist/docs/reference/sdk-reference/typescript/session.mdx +4 -3
  10. package/dist/{errors-DyZt79fi.mjs → errors-Ue9wMrPK.mjs} +2 -2
  11. package/dist/experimental/index.d.mts +2 -2
  12. package/dist/experimental/index.mjs +1 -1
  13. package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-KE5Fa-af.mjs} +7 -7
  14. package/dist/index.d.mts +7 -6
  15. package/dist/index.mjs +54 -34
  16. package/dist/models/Files.node.mjs +2 -2
  17. package/dist/{sensitiveFileUploadPaths-B0w8dqpv.mjs → sensitiveFileUploadPaths-QN7w4n8v.mjs} +1 -1
  18. package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-BLX6b-Rf.mjs} +96 -19
  19. package/dist/{types-BgsRW-XH.d.mts → types-CGdgK442.d.mts} +2 -2
  20. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  21. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  22. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  23. package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
  24. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  25. package/dist/utils/ssrfGuard.node.mjs +1 -1
  26. package/dist/utils/ssrfGuard.workerd.d.mts +1 -1
  27. package/dist/utils/ssrfGuard.workerd.mjs +2 -2
  28. package/package.json +20 -2
  29. package/src/models/CustomTool.ts +41 -6
  30. package/src/models/RemoteFile.ts +54 -36
  31. package/src/models/ToolRouterSession.ts +9 -4
  32. package/src/models/Triggers.ts +15 -0
  33. package/src/telemetry/redact.ts +133 -6
  34. package/src/utils/fileUtils.node.ts +10 -2
  35. package/src/utils/logger.ts +6 -6
  36. package/src/utils/pinnedDispatcher.node.ts +109 -13
  37. package/src/utils/sdk.ts +1 -1
  38. package/src/utils/ssrfGuard.node.ts +29 -17
  39. package/src/utils/ssrfGuard.workerd.ts +5 -1
@@ -1,7 +1,11 @@
1
1
  import { lookup } from 'node:dns/promises'; // we're in a Node.js-specific module
2
2
  import { isIP } from 'node:net';
3
3
  import { ComposioBlockedInternalUrlError } from '../errors/SsrfErrors';
4
- import { createPinnedDispatcher, hasCustomGlobalDispatcher } from './pinnedDispatcher.node';
4
+ import {
5
+ createPinnedDispatcher,
6
+ hasCustomGlobalDispatcher,
7
+ pinnedHttpFetch,
8
+ } from './pinnedDispatcher.node';
5
9
 
6
10
  /**
7
11
  * SSRF guard for user-supplied URL file inputs.
@@ -26,7 +30,8 @@ import { createPinnedDispatcher, hasCustomGlobalDispatcher } from './pinnedDispa
26
30
  * Residual: a hop whose effective dispatcher is a configured route — a
27
31
  * caller-supplied `init.dispatcher`, a non-stock global dispatcher (a
28
32
  * `ProxyAgent` or `EnvHttpProxyAgent` installed via `setGlobalDispatcher`), or
29
- * the runtime's env-proxy mode (`NODE_USE_ENV_PROXY`) — keeps only the
33
+ * the runtime's env-proxy mode (automatic on Bun, opt-in via
34
+ * `NODE_USE_ENV_PROXY` on Node) — keeps only the
30
35
  * pre-flight validation. Pinning would dial the validated address instead of
31
36
  * the proxy, and the proxy resolves the hostname itself where the SDK cannot
32
37
  * see or pin that resolution. The Python guard carries the same residual for
@@ -37,17 +42,18 @@ const MAX_REDIRECTS = 5;
37
42
 
38
43
  /**
39
44
  * Whether the runtime would route `url` through an env proxy the SDK cannot
40
- * see into. Only meaningful when `NODE_USE_ENV_PROXY` opts the built-in
41
- * `fetch` into env proxies (Node >= 24); without that flag the runtime's
42
- * `fetch` ignores `HTTP_PROXY`/`HTTPS_PROXY` entirely, so mirroring Python's
43
- * bare env-var check would drop pinning for users whose fetch never proxied.
45
+ * see into. Bun honors proxy environment variables automatically. Node's
46
+ * built-in `fetch` requires the `NODE_USE_ENV_PROXY` opt-in (Node >= 24), so
47
+ * a bare env-var check on Node would drop pinning for users whose fetch never
48
+ * proxied.
44
49
  *
45
50
  * `NO_PROXY=*` is the one bypass honored precisely (nothing is proxied, so
46
51
  * pinning is safe again); per-host `NO_PROXY` entries are treated
47
52
  * conservatively as proxied rather than parsed.
48
53
  */
49
- const envProxyApplies = (url: URL): boolean => {
50
- const useEnvProxy = ['1', 'true'].includes((process.env.NODE_USE_ENV_PROXY ?? '').toLowerCase());
54
+ const envProxyApplies = (url: URL, isBun: boolean): boolean => {
55
+ const useEnvProxy =
56
+ isBun || ['1', 'true'].includes((process.env.NODE_USE_ENV_PROXY ?? '').toLowerCase());
51
57
  if (!useEnvProxy) return false;
52
58
  if ((process.env.NO_PROXY ?? process.env.no_proxy ?? '') === '*') return false;
53
59
  const schemeVar = url.protocol === 'https:' ? 'HTTPS_PROXY' : 'HTTP_PROXY';
@@ -230,6 +236,7 @@ export const ssrfSafeFetch = async (
230
236
 
231
237
  for (let hop = 0; hop <= maxRedirects; hop++) {
232
238
  const addresses = await assertSafeFetchTarget(currentUrl);
239
+ const isBun = typeof process.versions.bun === 'string';
233
240
 
234
241
  // Pinning replaces the connect target; through a configured route that
235
242
  // would dial the validated origin instead of the route's next hop (the
@@ -237,20 +244,25 @@ export const ssrfSafeFetch = async (
237
244
  const callerDispatcher = (init as RequestInit & { dispatcher?: unknown }).dispatcher;
238
245
  const respectConfiguredRoute =
239
246
  callerDispatcher !== undefined ||
240
- envProxyApplies(new URL(currentUrl)) ||
247
+ envProxyApplies(new URL(currentUrl), isBun) ||
241
248
  hasCustomGlobalDispatcher();
242
249
 
243
- const dispatcher = respectConfiguredRoute ? undefined : await createPinnedDispatcher(addresses);
250
+ const dispatcher =
251
+ respectConfiguredRoute || isBun ? undefined : await createPinnedDispatcher(addresses);
244
252
 
245
253
  let response: Response;
246
254
  try {
247
- // `dispatcher` is a Node-only extension to `RequestInit`.
248
- response = await fetch(
249
- currentUrl,
250
- (dispatcher === undefined
251
- ? { ...init, redirect: 'manual' }
252
- : { ...init, redirect: 'manual', dispatcher }) as RequestInit
253
- );
255
+ if (isBun && !respectConfiguredRoute) {
256
+ response = await pinnedHttpFetch(currentUrl, { ...init, redirect: 'manual' }, addresses);
257
+ } else {
258
+ // `dispatcher` is a Node-only extension to `RequestInit`.
259
+ response = await fetch(
260
+ currentUrl,
261
+ (dispatcher === undefined
262
+ ? { ...init, redirect: 'manual' }
263
+ : { ...init, redirect: 'manual', dispatcher }) as RequestInit
264
+ );
265
+ }
254
266
  } catch (error) {
255
267
  if (dispatcher !== undefined) {
256
268
  await dispatcher.close().catch(() => undefined);
@@ -5,7 +5,11 @@ import { ComposioBlockedInternalUrlError } from '../errors/SsrfErrors';
5
5
  * hostname is publicly routable before connecting. Fail closed instead of
6
6
  * falling back to an unguarded fetch.
7
7
  */
8
- export const ssrfSafeFetch = async (rawUrl: string): Promise<Response> => {
8
+ export const ssrfSafeFetch = async (
9
+ rawUrl: string,
10
+ _init: RequestInit = {},
11
+ _maxRedirects?: number
12
+ ): Promise<Response> => {
9
13
  throw new ComposioBlockedInternalUrlError(
10
14
  'URL file uploads are not supported in edge runtimes because the destination cannot be safely validated',
11
15
  {