@composio/core 0.14.1 → 0.16.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/{BaseProvider-Dc5yKZhk.d.mts → BaseProvider-D7p2OPEx.d.mts} +267 -200
- package/dist/{CustomTool-4nVuwLzO.d.mts → CustomTool-Bk38kFp0.d.mts} +1 -1
- package/dist/{Telemetry-CF0rNHu2.mjs → Telemetry-DuGJSwUt.mjs} +2 -2
- package/dist/{cancellation-BbJ-UQ__.mjs → cancellation-NVtGf3St.mjs} +69 -1
- package/dist/{composio-ChU3eD9F.d.mts → composio-DSs-1AhC.d.mts} +8 -3
- package/dist/{customTool.types-CX2-LbfI.d.mts → customTool.types-cGHcIBX-.d.mts} +1 -1
- package/dist/experimental/index.d.mts +2 -2
- package/dist/{fileUtils.node-DOkW4PBg.mjs → fileUtils.node-BQ0fWge3.mjs} +5 -2
- package/dist/index.d.mts +20 -7
- package/dist/index.mjs +85 -43
- package/dist/models/Files.node.mjs +2 -2
- package/dist/platform/node.d.mts +1 -1
- package/dist/platform/node.mjs +24 -0
- package/dist/platform/workerd.d.mts +1 -1
- package/dist/platform/workerd.mjs +3 -0
- package/dist/{sensitiveFileUploadPaths-C43dHP7S.mjs → sensitiveFileUploadPaths-BVEt0peg.mjs} +12 -7
- package/dist/{types-D5N60gUD.d.mts → types-B4k-qoOf.d.mts} +2 -2
- package/dist/{types-DY1r-kN9.d.mts → types-D5A2wzBl.d.mts} +8 -0
- 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 +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +2 -2
- package/dist/utils/ssrfGuard.node.mjs +3 -2
- package/package.json +6 -5
- package/src/index.ts +1 -0
- package/src/models/ToolRouterSessionFileMount.ts +3 -0
- package/src/models/Tools.ts +108 -77
- package/src/platform/node.ts +40 -0
- package/src/platform/types.ts +9 -0
- package/src/platform/workerd.ts +5 -0
- package/src/telemetry/redact.ts +6 -1
- package/src/types/tool.types.ts +60 -10
- package/src/utils/fileUtils.node.ts +3 -0
- package/src/utils/jsonSchema.ts +86 -1
- package/src/utils/modifiers/FileToolModifier.node.ts +3 -3
- package/src/utils/modifiers/FileToolModifier.utils.neutral.ts +6 -4
- package/src/utils/sdk.ts +2 -2
- package/src/utils/sensitiveFileUploadPaths.ts +12 -9
- package/src/utils/ssrfGuard.node.ts +6 -2
- package/src/utils/version.ts +21 -20
|
@@ -12,7 +12,8 @@ import { ComposioSensitiveFilePathBlockedError } from '../errors/FileModifierErr
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Path segments (a single path component) that indicate a sensitive directory when
|
|
15
|
-
* they appear anywhere in a resolved local path.
|
|
15
|
+
* they appear anywhere in a resolved local path. Matching follows the case sensitivity
|
|
16
|
+
* of the filesystem containing that path.
|
|
16
17
|
*/
|
|
17
18
|
export const BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS: readonly string[] = [
|
|
18
19
|
'.ssh',
|
|
@@ -30,12 +31,10 @@ const SECRET_LIKE_BASENAME = /^(\.env(\.|$)|\.netrc$|\.pgpass$)/i;
|
|
|
30
31
|
/** Default SSH private key basenames (public keys like id_rsa.pub are allowed). */
|
|
31
32
|
const DEFAULT_PRIVATE_KEY_BASENAME = /^id_(rsa|ed25519|ecdsa|dsa|ecdsa_sk)(\.old)?$/i;
|
|
32
33
|
|
|
33
|
-
const isWindows = typeof process !== 'undefined' && process.platform === 'win32';
|
|
34
|
-
|
|
35
34
|
/**
|
|
36
35
|
* Returns normalized path segments, resolving symlinks when the path exists.
|
|
37
36
|
*/
|
|
38
|
-
function
|
|
37
|
+
function normalizePath(filePath: string): { resolvedPath: string; segments: string[] } {
|
|
39
38
|
const absolute = platform.resolvePath(filePath);
|
|
40
39
|
let resolved = absolute;
|
|
41
40
|
try {
|
|
@@ -45,7 +44,10 @@ function normalizePathSegments(filePath: string): string[] {
|
|
|
45
44
|
} catch {
|
|
46
45
|
// If realpath fails (e.g. race), use resolved path
|
|
47
46
|
}
|
|
48
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
resolvedPath: resolved,
|
|
49
|
+
segments: resolved.split(/[/\\]+/).filter(Boolean),
|
|
50
|
+
};
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -63,16 +65,17 @@ function getSensitiveFileUploadPathBlockReason(
|
|
|
63
65
|
filePath: string,
|
|
64
66
|
additionalDenySegments?: string[]
|
|
65
67
|
): string | null {
|
|
66
|
-
const segments =
|
|
68
|
+
const { resolvedPath, segments } = normalizePath(filePath);
|
|
69
|
+
const isCaseSensitive = platform.isFileSystemCaseSensitive?.(resolvedPath) ?? true;
|
|
70
|
+
const normalizeSegment = (segment: string) => (isCaseSensitive ? segment : segment.toLowerCase());
|
|
67
71
|
const deny = new Set(
|
|
68
72
|
[
|
|
69
73
|
...BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS,
|
|
70
74
|
...(additionalDenySegments ?? []).map(s => s.trim()).filter(Boolean),
|
|
71
|
-
].map(
|
|
75
|
+
].map(normalizeSegment)
|
|
72
76
|
);
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
const segmentsForMatch = isWindows ? segments.map(s => s.toLowerCase()) : segments;
|
|
78
|
+
const segmentsForMatch = isCaseSensitive ? segments : segments.map(normalizeSegment);
|
|
76
79
|
for (let i = 0; i < segments.length; i++) {
|
|
77
80
|
if (deny.has(segmentsForMatch[i]!)) {
|
|
78
81
|
return `path segment "${segments[i]}" is in the sensitive file upload denylist`;
|
|
@@ -171,8 +171,8 @@ export const assertSafeFetchTarget = async (rawUrl: string): Promise<void> => {
|
|
|
171
171
|
/**
|
|
172
172
|
* Drop-in replacement for `fetch` that blocks SSRF. Validates the target before
|
|
173
173
|
* connecting and re-validates every redirect hop (redirects are followed
|
|
174
|
-
* manually up to {@link MAX_REDIRECTS}).
|
|
175
|
-
* unchanged.
|
|
174
|
+
* manually up to {@link MAX_REDIRECTS}). Intermediate redirect bodies are
|
|
175
|
+
* cancelled; non-redirect responses are returned unchanged.
|
|
176
176
|
*/
|
|
177
177
|
export const ssrfSafeFetch = async (
|
|
178
178
|
rawUrl: string,
|
|
@@ -192,6 +192,10 @@ export const ssrfSafeFetch = async (
|
|
|
192
192
|
return response;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
// Only `location` is read from a redirect, so release its body explicitly rather
|
|
196
|
+
// than leaving it to the garbage collector (mirrors `readResponseBodyWithLimit`).
|
|
197
|
+
await response.body?.cancel().catch(() => undefined);
|
|
198
|
+
|
|
195
199
|
currentUrl = new URL(response.headers.get('location')!, currentUrl).toString();
|
|
196
200
|
}
|
|
197
201
|
|
package/src/utils/version.ts
CHANGED
|
@@ -2,26 +2,14 @@ import logger from './logger';
|
|
|
2
2
|
import { IS_DEVELOPMENT_OR_CI } from './constants';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* Compares two semantic versions and returns true if the first version is newer than the second.
|
|
7
|
-
* @param version1 The first version to compare
|
|
8
|
-
* @param version2 The second version to compare
|
|
9
|
-
* @returns boolean indicating if version1 is newer than version2
|
|
10
|
-
*/
|
|
11
|
-
export function isNewerVersion(version1: string, version2: string): boolean {
|
|
12
|
-
const v1 = version1.split('.').map(Number);
|
|
13
|
-
const v2 = version2.split('.').map(Number);
|
|
14
|
-
|
|
15
|
-
for (let i = 0; i < 3; i++) {
|
|
16
|
-
if (v1[i] > v2[i]) return true;
|
|
17
|
-
if (v1[i] < v2[i]) return false;
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
5
|
+
const VERSION_CHECK_TIMEOUT_MS = 2_000;
|
|
21
6
|
|
|
22
7
|
/**
|
|
23
8
|
* Checks for the latest version of the Composio SDK from NPM.
|
|
24
9
|
* If a newer version is available, it logs a warning to the console.
|
|
10
|
+
*
|
|
11
|
+
* Best-effort: never throws. The npm registry request is aborted after
|
|
12
|
+
* {@link VERSION_CHECK_TIMEOUT_MS} milliseconds.
|
|
25
13
|
*/
|
|
26
14
|
export async function checkForLatestVersionFromNPM(currentVersion: string) {
|
|
27
15
|
try {
|
|
@@ -42,14 +30,27 @@ export async function checkForLatestVersionFromNPM(currentVersion: string) {
|
|
|
42
30
|
return;
|
|
43
31
|
}
|
|
44
32
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
// Bound this best-effort request so a stalled registry cannot leave it pending
|
|
34
|
+
// indefinitely. A hand-rolled timer rather than AbortSignal.timeout so it can be
|
|
35
|
+
// cleared the moment the response lands: an uncleared timer is itself pending work,
|
|
36
|
+
// which on workerd pins the request context open for the full timeout on every
|
|
37
|
+
// successful check.
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
const timer = setTimeout(() => controller.abort(), VERSION_CHECK_TIMEOUT_MS);
|
|
40
|
+
let data;
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
43
|
+
signal: controller.signal,
|
|
44
|
+
});
|
|
45
|
+
data = await response.json();
|
|
46
|
+
} finally {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
}
|
|
48
49
|
const latestVersion = data.version;
|
|
49
50
|
|
|
50
51
|
if (semver.gt(latestVersion, currentVersionFromPackageJson) && !IS_DEVELOPMENT_OR_CI) {
|
|
51
52
|
logger.info(
|
|
52
|
-
`🚀 Upgrade available! Your
|
|
53
|
+
`🚀 Upgrade available! Your ${packageName} version (${currentVersionFromPackageJson}) is behind. Latest version: ${latestVersion}.`
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
56
|
} catch (_error) {
|