@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.
Files changed (49) hide show
  1. package/dist/{CustomTool-DfP4ldQl.d.mts → CustomTool-DyypijT6.d.mts} +2 -2
  2. package/dist/{Telemetry-41JkqpZ7.mjs → Telemetry-D2PJwXKx.mjs} +1 -1
  3. package/dist/{composio-BMDH-1Qj.d.mts → composio-CwHMpKXb.d.mts} +748 -70
  4. package/dist/{customTool.types-BoOELgJF.d.mts → customTool.types-DoItUHkO.d.mts} +780 -23
  5. package/dist/docs/reference/sdk-reference/typescript/composio.mdx +3 -3
  6. package/dist/docs/reference/sdk-reference/typescript/session.mdx +5 -4
  7. package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +5 -1
  8. package/dist/experimental/index.d.mts +2 -2
  9. package/dist/{fileUtils.node-DNLhLg0W.mjs → fileUtils.node-ILI1IjnZ.mjs} +4 -3
  10. package/dist/index.d.mts +10 -10
  11. package/dist/index.mjs +420 -158
  12. package/dist/models/Files.node.mjs +2 -2
  13. package/dist/sensitiveFileUploadPaths-BaEORC7-.mjs +588 -0
  14. package/dist/{types-DHNV_T_z.d.mts → types-DWZWePfZ.d.mts} +2 -2
  15. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
  16. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
  17. package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
  18. package/dist/utils/modifiers/FileToolModifier.node.mjs +1 -1
  19. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
  20. package/package.json +7 -6
  21. package/src/lib/toolRouterParams.ts +33 -15
  22. package/src/lib/toolRouterSessionDelete.ts +1 -10
  23. package/src/models/ConnectedAccounts.ts +1 -1
  24. package/src/models/CustomTool.ts +1 -1
  25. package/src/models/CustomToolkits.ts +114 -8
  26. package/src/models/Experimental.ts +1 -1
  27. package/src/models/MCP.ts +1 -2
  28. package/src/models/SessionConfigs.ts +11 -3
  29. package/src/models/SessionContext.ts +6 -21
  30. package/src/models/ToolRouter.ts +5 -1
  31. package/src/models/ToolRouterSession.ts +21 -35
  32. package/src/models/Tools.ts +3 -3
  33. package/src/models/Triggers.ts +12 -5
  34. package/src/models/inlineCustomToolsPayload.ts +3 -3
  35. package/src/models/proxyParamsTransform.ts +1 -1
  36. package/src/types/customTool.types.ts +13 -5
  37. package/src/types/customToolkits.types.ts +89 -9
  38. package/src/types/sessionConfigs.types.ts +21 -7
  39. package/src/types/toolRouter.types.ts +169 -17
  40. package/src/types/triggers.types.ts +14 -0
  41. package/src/utils/fileUtils.node.ts +5 -2
  42. package/src/utils/mime.ts +347 -1
  43. package/src/utils/transformers/connectedAccounts.ts +2 -7
  44. package/src/utils/transformers/customToolkits.ts +78 -9
  45. package/src/utils/transformers/sessionConfigs.ts +3 -3
  46. package/src/utils/transformers/toolRouterResponseTransform.ts +71 -5
  47. package/src/utils/transformers/toolkits.ts +7 -13
  48. package/src/utils/transformers/triggers.ts +28 -18
  49. package/dist/sensitiveFileUploadPaths-BlLp-Yo2.mjs +0 -189
@@ -2,7 +2,7 @@ import {
2
2
  TriggersTypeRetrieveResponse as RawTriggersTypeRetrieveResponse,
3
3
  TriggersTypeListResponse as RawTriggersTypeListResponse,
4
4
  } from '@composio/client/resources/triggers-types';
5
- import { TriggerInstanceListActiveResponse as RawTriggerInstanceListActiveResponse } from '@composio/client/resources/index';
5
+ import { TriggerInstanceListActiveResponse as RawTriggerInstanceListActiveResponse } from '@composio/client/resources/trigger-instances';
6
6
  import {
7
7
  IncomingTriggerPayload,
8
8
  IncomingTriggerPayloadSchema,
@@ -48,25 +48,32 @@ export function transformIncomingTriggerPayload(response: TriggerData): Incoming
48
48
  }));
49
49
  }
50
50
 
51
+ function toTriggerType(
52
+ response: RawTriggersTypeRetrieveResponse | RawTriggersTypeListResponse['items'][number]
53
+ ): TriggersTypeRetrieveResponse {
54
+ return {
55
+ slug: response.slug,
56
+ name: response.name,
57
+ description: response.description,
58
+ instructions: response.instructions,
59
+ toolkit: {
60
+ logo: response.toolkit.logo,
61
+ slug: response.toolkit.slug,
62
+ name: response.toolkit.name,
63
+ },
64
+ version: response.version,
65
+ payload: response.payload,
66
+ config: response.config,
67
+ type: response.type,
68
+ types: response.types,
69
+ requiresWebhookEndpointSetup: response.requires_webhook_endpoint_setup,
70
+ };
71
+ }
72
+
51
73
  export function transformTriggerTypeRetrieveResponse(
52
74
  response: RawTriggersTypeRetrieveResponse
53
75
  ): TriggersTypeRetrieveResponse {
54
- return transform(response)
55
- .with(TriggerTypeSchema)
56
- .using(response => ({
57
- slug: response.slug,
58
- name: response.name,
59
- description: response.description,
60
- instructions: response.instructions,
61
- toolkit: {
62
- logo: response.toolkit.logo,
63
- slug: response.toolkit.slug,
64
- name: response.toolkit.name,
65
- },
66
- version: response.version,
67
- payload: response.payload,
68
- config: response.config,
69
- }));
76
+ return transform(response).with(TriggerTypeSchema).using(toTriggerType);
70
77
  }
71
78
 
72
79
  export function transformTriggerTypeListResponse(
@@ -75,7 +82,7 @@ export function transformTriggerTypeListResponse(
75
82
  return transform(response)
76
83
  .with(TriggersTypeListResponseSchema)
77
84
  .using(response => ({
78
- items: response.items,
85
+ items: response.items.map(toTriggerType),
79
86
  nextCursor: response.next_cursor ?? null,
80
87
  totalPages: response.total_pages,
81
88
  }));
@@ -102,6 +109,9 @@ export function transformTriggerInstanceListActiveItem(
102
109
  updatedAt: response.updated_at,
103
110
  triggerData: response.trigger_data,
104
111
  uuid: response.uuid,
112
+ type: response.type,
113
+ fallbackReason: response.fallback_reason,
114
+ pollingInterval: response.polling_interval,
105
115
  }));
106
116
  }
107
117
 
@@ -1,189 +0,0 @@
1
- import { a as ComposioSensitiveFilePathBlockedError } from "./FileModifierErrors-CdGSABoq.mjs";
2
- import { platform } from "#platform";
3
-
4
- //#region src/utils/uuid.ts
5
- function getRandomUUID() {
6
- return globalThis.crypto.randomUUID();
7
- }
8
- function getRandomShortId() {
9
- return getRandomUUID().slice(0, 8).replace(/-/g, "");
10
- }
11
-
12
- //#endregion
13
- //#region src/utils/buffer.ts
14
- /**
15
- * Convert ArrayBuffer to base64.
16
- */
17
- function arrayBufferToBase64(buffer) {
18
- const bytes = new Uint8Array(buffer);
19
- let binary = "";
20
- for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
21
- return btoa(binary);
22
- }
23
- const base64ToUint8Array = (base64) => {
24
- const binary = atob(base64);
25
- const bytes = new Uint8Array(binary.length);
26
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
27
- return bytes;
28
- };
29
- const uint8ArrayToBase64 = (bytes) => {
30
- let binary = "";
31
- for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
32
- return btoa(binary);
33
- };
34
-
35
- //#endregion
36
- //#region src/utils/readResponseBody.ts
37
- /** Maximum size accepted for files fetched from user-supplied URLs (100 MiB). */
38
- const MAX_URL_UPLOAD_SIZE_BYTES = 104857600;
39
- const sizeLimitError = (actualSize, maxBytes) => /* @__PURE__ */ new Error(`File size (${actualSize} bytes) exceeds maximum allowed size (${maxBytes} bytes)`);
40
- /**
41
- * Read a fetch response without allowing an untrusted server to exhaust memory.
42
- *
43
- * `Content-Length` is checked as an early rejection, but the streamed byte
44
- * count is authoritative because the header can be absent or dishonest.
45
- */
46
- const readResponseBodyWithLimit = async (response, maxBytes = MAX_URL_UPLOAD_SIZE_BYTES) => {
47
- if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError("maxBytes must be a non-negative safe integer");
48
- const contentLength = response.headers.get("content-length")?.trim();
49
- if (contentLength && /^\d+$/.test(contentLength)) {
50
- const declaredSize = Number(contentLength);
51
- if (!Number.isSafeInteger(declaredSize) || declaredSize > maxBytes) {
52
- const error = sizeLimitError(declaredSize, maxBytes);
53
- await response.body?.cancel(error).catch(() => void 0);
54
- throw error;
55
- }
56
- }
57
- if (!response.body) return /* @__PURE__ */ new Uint8Array();
58
- const reader = response.body.getReader();
59
- const chunks = [];
60
- let totalBytes = 0;
61
- try {
62
- while (true) {
63
- const { done, value } = await reader.read();
64
- if (done) break;
65
- if (!value || value.byteLength === 0) continue;
66
- totalBytes += value.byteLength;
67
- if (totalBytes > maxBytes) {
68
- await reader.cancel(sizeLimitError(totalBytes, maxBytes));
69
- throw sizeLimitError(totalBytes, maxBytes);
70
- }
71
- chunks.push(value);
72
- }
73
- } finally {
74
- reader.releaseLock();
75
- }
76
- const body = new Uint8Array(totalBytes);
77
- let offset = 0;
78
- for (const chunk of chunks) {
79
- body.set(chunk, offset);
80
- offset += chunk.byteLength;
81
- }
82
- return body;
83
- };
84
-
85
- //#endregion
86
- //#region src/utils/sensitiveFileUploadPaths.ts
87
- /**
88
- * Blocks accidental upload of local files from well-known secret/credential locations
89
- * during auto file upload (and {@link getFileDataAfterUploadingToS3}).
90
- *
91
- * This is the single canonical guard shared by the core SDK and downstream
92
- * packages (e.g. `@composio/cli`). Filesystem access goes through the `#platform`
93
- * abstraction so this module stays free of static `node:*` imports and is safe to
94
- * re-export from the package root (edge/workerd builds included).
95
- */
96
- /**
97
- * Path segments (a single path component) that indicate a sensitive directory when
98
- * they appear anywhere in a resolved local path. Matching follows the case sensitivity
99
- * of the filesystem containing that path.
100
- */
101
- const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS = [
102
- ".ssh",
103
- ".aws",
104
- ".azure",
105
- ".gnupg",
106
- ".kube",
107
- ".docker",
108
- ".claude",
109
- ".password-store",
110
- "keychains"
111
- ];
112
- const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
113
- /** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
114
- const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
115
- const splitSegments = (aPath) => aPath.split(/[/\\]+/).filter(Boolean);
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.
131
- */
132
- function normalizePath(filePath) {
133
- const absolute = platform.resolvePath(filePath);
134
- let resolved = absolute;
135
- try {
136
- if (platform.existsSync(absolute)) resolved = platform.realpathSync(absolute);
137
- } catch {}
138
- return {
139
- resolvedPath: resolved,
140
- segments: splitSegments(resolved),
141
- writtenSegments: splitSegments(absolute)
142
- };
143
- }
144
- /**
145
- * True if the path is under a built-in or extra deny segment, or the basename
146
- * looks like an env / netrc / default SSH private key name.
147
- */
148
- function isBlockedSensitiveFileUploadPath(filePath, additionalDenySegments) {
149
- return getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) != null;
150
- }
151
- function getSensitiveFileUploadPathBlockReason(filePath, additionalDenySegments) {
152
- const { resolvedPath, segments, writtenSegments } = normalizePath(filePath);
153
- const isCaseSensitive = platform.isFileSystemCaseSensitive?.(resolvedPath) ?? true;
154
- const normalizeSegment = (segment) => isCaseSensitive ? segment : segment.toLowerCase();
155
- const deny = new Set([...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS, ...(additionalDenySegments ?? []).map((s) => s.trim()).filter(Boolean)].map(normalizeSegment));
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) {
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`;
163
- if (basename.toLowerCase() === "credentials") return "file name \"credentials\" is often used for cloud/API credential stores";
164
- }
165
- return null;
166
- }
167
- /**
168
- * Default remediation hint appended to the block message. Assumes an SDK caller
169
- * that exposes `sensitiveFileUploadProtection`. Callers without such an opt-out
170
- * (e.g. `@composio/cli`) should pass their own `remediation` so the message does
171
- * not advertise an option the caller cannot honor.
172
- */
173
- const DEFAULT_REMEDIATION = "To upload from this path anyway, set sensitiveFileUploadProtection: false on Composio (not recommended) or use a copy outside sensitive locations.";
174
- /**
175
- * @throws {ComposioSensitiveFilePathBlockedError} if the path is not allowed
176
- */
177
- function assertSafeFileUploadPath(filePath, options) {
178
- const reason = getSensitiveFileUploadPathBlockReason(filePath, options?.additionalDenySegments);
179
- if (reason) {
180
- const remediation = options?.remediation ?? DEFAULT_REMEDIATION;
181
- throw new ComposioSensitiveFilePathBlockedError(`Refusing to upload: ${reason}. ${remediation}`, { meta: {
182
- filePath,
183
- reason
184
- } });
185
- }
186
- }
187
-
188
- //#endregion
189
- export { readResponseBodyWithLimit as a, uint8ArrayToBase64 as c, MAX_URL_UPLOAD_SIZE_BYTES as i, getRandomShortId as l, assertSafeFileUploadPath as n, arrayBufferToBase64 as o, isBlockedSensitiveFileUploadPath as r, base64ToUint8Array as s, BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS as t, getRandomUUID as u };