@composio/core 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,31 +1,93 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.4.0",
3
+ "type": "module",
4
+ "version": "0.5.0",
4
5
  "description": "",
5
6
  "main": "dist/index.mjs",
6
- "type": "module",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
+ "imports": {
11
+ "#platform": {
12
+ "workerd": "./dist/platform/workerd.mjs",
13
+ "edge-light": "./dist/platform/workerd.mjs",
14
+ "node": {
15
+ "import": "./dist/platform/node.mjs",
16
+ "require": "./dist/platform/node.cjs"
17
+ },
18
+ "default": {
19
+ "import": "./dist/platform/node.mjs",
20
+ "require": "./dist/platform/node.cjs"
21
+ }
22
+ },
23
+ "#files": {
24
+ "workerd": "./dist/models/Files.workerd.mjs",
25
+ "edge-light": "./dist/models/Files.workerd.mjs",
26
+ "node": {
27
+ "import": "./dist/models/Files.node.mjs",
28
+ "require": "./dist/models/Files.node.cjs"
29
+ },
30
+ "default": {
31
+ "import": "./dist/models/Files.node.mjs",
32
+ "require": "./dist/models/Files.node.cjs"
33
+ }
34
+ }
35
+ },
10
36
  "exports": {
11
37
  ".": {
12
- "import": "./dist/index.mjs",
13
- "types": {
14
- "import": "./dist/index.d.mts",
15
- "require": "./dist/index.d.cts",
16
- "default": "./dist/index.d.cts"
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ },
46
+ "default": {
47
+ "types": "./dist/index.d.cts",
48
+ "default": "./dist/index.cjs"
49
+ }
50
+ },
51
+ "./platform": {
52
+ "workerd": {
53
+ "types": "./dist/platform/workerd.d.mts",
54
+ "default": "./dist/platform/workerd.mjs"
55
+ },
56
+ "edge-light": {
57
+ "types": "./dist/platform/workerd.d.mts",
58
+ "default": "./dist/platform/workerd.mjs"
59
+ },
60
+ "node": {
61
+ "import": {
62
+ "types": "./dist/platform/node.d.mts",
63
+ "default": "./dist/platform/node.mjs"
64
+ },
65
+ "require": {
66
+ "types": "./dist/platform/node.d.cts",
67
+ "default": "./dist/platform/node.cjs"
68
+ }
17
69
  },
18
- "require": "./dist/index.cjs"
70
+ "default": {
71
+ "import": {
72
+ "types": "./dist/platform/node.d.mts",
73
+ "default": "./dist/platform/node.mjs"
74
+ },
75
+ "require": {
76
+ "types": "./dist/platform/node.d.cts",
77
+ "default": "./dist/platform/node.cjs"
78
+ }
79
+ }
19
80
  },
20
81
  "./generated": {
21
- "import": "./generated/index.js",
22
- "types": "./generated/index.d.ts"
82
+ "types": "./generated/index.d.ts",
83
+ "default": "./generated/index.js"
23
84
  }
24
85
  },
25
86
  "files": [
26
87
  "README.md",
27
88
  "dist",
28
- "generated"
89
+ "generated",
90
+ "src/platform"
29
91
  ],
30
92
  "keywords": [],
31
93
  "author": "",
@@ -33,8 +95,7 @@
33
95
  "devDependencies": {
34
96
  "@type-challenges/utils": "^0.1.1",
35
97
  "@types/semver": "^7.7.0",
36
- "tsdown": "^0.16.8",
37
- "tsup": "^8.5.0",
98
+ "tsdown": "^0.18.4",
38
99
  "tsx": "^4.20.5",
39
100
  "typedoc": "^0.28.5",
40
101
  "typescript": "^5.9.2",
@@ -51,7 +112,6 @@
51
112
  "openai": "^5.16.0",
52
113
  "pusher-js": "^8.4.0",
53
114
  "semver": "^7.7.2",
54
- "uuid": "^13.0.0",
55
115
  "zod-to-json-schema": "^3.25.1",
56
116
  "@composio/json-schema-to-zod": "0.1.19"
57
117
  },
@@ -0,0 +1,2 @@
1
+ export type { Platform } from './types';
2
+ export { platform } from '#platform';
@@ -0,0 +1,51 @@
1
+ import * as fs from 'node:fs';
2
+ import * as os from 'node:os';
3
+ import * as path from 'node:path';
4
+ import type { Platform } from './types';
5
+
6
+ /**
7
+ * Node.js platform implementation.
8
+ * Provides full file system and OS operations using Node.js built-in modules.
9
+ */
10
+ export const platform: Platform = {
11
+ supportsFileSystem: true,
12
+
13
+ homedir(): string | null {
14
+ try {
15
+ return os.homedir();
16
+ } catch {
17
+ return null;
18
+ }
19
+ },
20
+
21
+ joinPath(...paths: string[]): string {
22
+ return path.join(...paths);
23
+ },
24
+
25
+ basename(filePath: string): string {
26
+ return path.basename(filePath);
27
+ },
28
+
29
+ existsSync(filePath: string): boolean {
30
+ return fs.existsSync(filePath);
31
+ },
32
+
33
+ mkdirSync(dirPath: string): void {
34
+ fs.mkdirSync(dirPath, { recursive: true });
35
+ },
36
+
37
+ readFileSync(filePath: string, encoding?: BufferEncoding): string | Buffer {
38
+ if (encoding) {
39
+ return fs.readFileSync(filePath, encoding);
40
+ }
41
+ return fs.readFileSync(filePath);
42
+ },
43
+
44
+ writeFileSync(filePath: string, content: string | Buffer, encoding?: BufferEncoding): void {
45
+ if (encoding && typeof content === 'string') {
46
+ fs.writeFileSync(filePath, content, encoding);
47
+ } else {
48
+ fs.writeFileSync(filePath, content);
49
+ }
50
+ },
51
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Platform abstraction for file system and OS operations.
3
+ * This interface allows different implementations for Node.js and edge runtimes (e.g., Cloudflare Workers).
4
+ */
5
+ export interface Platform {
6
+ /**
7
+ * Returns the user's home directory path.
8
+ * @returns The home directory path, or null if unavailable (e.g., in edge runtimes).
9
+ */
10
+ homedir(): string | null;
11
+
12
+ /**
13
+ * Joins path segments into a single path.
14
+ * @param paths - Path segments to join.
15
+ * @returns The joined path.
16
+ */
17
+ joinPath(...paths: string[]): string;
18
+
19
+ /**
20
+ * Returns the last portion of a path (the filename).
21
+ * @param filePath - The path to extract the basename from.
22
+ * @returns The basename of the path.
23
+ */
24
+ basename(filePath: string): string;
25
+
26
+ /**
27
+ * Checks if a file or directory exists at the given path.
28
+ * @param filePath - The path to check.
29
+ * @returns True if the path exists, false otherwise.
30
+ */
31
+ existsSync(filePath: string): boolean;
32
+
33
+ /**
34
+ * Creates a directory at the given path, including parent directories if needed.
35
+ * @param dirPath - The directory path to create.
36
+ */
37
+ mkdirSync(dirPath: string): void;
38
+
39
+ /**
40
+ * Reads a file synchronously and returns its contents.
41
+ * @param filePath - The path to the file.
42
+ * @param encoding - Optional encoding (e.g., 'utf8'). If not provided, returns a Buffer.
43
+ * @returns The file contents as a string (if encoding provided) or Buffer.
44
+ */
45
+ readFileSync(filePath: string, encoding?: BufferEncoding): string | Buffer;
46
+
47
+ /**
48
+ * Writes content to a file synchronously.
49
+ * @param filePath - The path to the file.
50
+ * @param content - The content to write (string or Buffer).
51
+ * @param encoding - Optional encoding for string content.
52
+ */
53
+ writeFileSync(filePath: string, content: string | Buffer, encoding?: BufferEncoding): void;
54
+
55
+ /**
56
+ * Indicates whether this platform supports file system operations.
57
+ * Edge runtimes like Cloudflare Workers return false.
58
+ */
59
+ readonly supportsFileSystem: boolean;
60
+ }
@@ -0,0 +1,57 @@
1
+ import type { Platform } from './types';
2
+
3
+ /**
4
+ * Cloudflare Workers / Edge runtime platform implementation.
5
+ * Provides stub implementations for file system operations that are unavailable in edge runtimes.
6
+ * All file system operations gracefully return null/empty values or throw descriptive errors.
7
+ */
8
+ export const platform: Platform = {
9
+ supportsFileSystem: false,
10
+
11
+ homedir(): string | null {
12
+ // Home directory is not available in edge runtimes
13
+ return null;
14
+ },
15
+
16
+ joinPath(...paths: string[]): string {
17
+ // Simple path joining without Node.js path module
18
+ return paths
19
+ .map((segment, index) => {
20
+ if (index === 0) {
21
+ return segment.replace(/\/+$/, '');
22
+ }
23
+ return segment.replace(/^\/+|\/+$/g, '');
24
+ })
25
+ .filter(Boolean)
26
+ .join('/');
27
+ },
28
+
29
+ basename(filePath: string): string {
30
+ // Simple basename extraction without Node.js path module
31
+ const segments = filePath.replace(/\/+$/, '').split('/');
32
+ return segments[segments.length - 1] || '';
33
+ },
34
+
35
+ existsSync(_filePath: string): boolean {
36
+ // File system is not available in edge runtimes
37
+ return false;
38
+ },
39
+
40
+ mkdirSync(_dirPath: string): void {
41
+ // No-op in edge runtimes - directories cannot be created
42
+ },
43
+
44
+ readFileSync(_filePath: string, _encoding?: BufferEncoding): never {
45
+ throw new Error(
46
+ 'File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). ' +
47
+ 'Use environment variables or external storage services instead.'
48
+ );
49
+ },
50
+
51
+ writeFileSync(_filePath: string, _content: string | Buffer, _encoding?: BufferEncoding): never {
52
+ throw new Error(
53
+ 'File system operations are not supported in this runtime environment (Cloudflare Workers/Edge). ' +
54
+ 'Use environment variables or external storage services instead.'
55
+ );
56
+ },
57
+ };