@utdk/isolate 0.1.0-dev.646adf4
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/.turbo/turbo-build.log +4 -0
- package/LICENSE +373 -0
- package/README.md +126 -0
- package/__tests__/bridge.test.ts +214 -0
- package/__tests__/isolate.test.ts +275 -0
- package/__tests__/sandbox.test.ts +126 -0
- package/dist/__tests__/bridge.test.d.ts +1 -0
- package/dist/__tests__/bridge.test.js +168 -0
- package/dist/__tests__/bridge.test.js.map +1 -0
- package/dist/__tests__/isolate.test.d.ts +11 -0
- package/dist/__tests__/isolate.test.js +218 -0
- package/dist/__tests__/isolate.test.js.map +1 -0
- package/dist/__tests__/sandbox.test.d.ts +1 -0
- package/dist/__tests__/sandbox.test.js +104 -0
- package/dist/__tests__/sandbox.test.js.map +1 -0
- package/dist/src/bridge.d.ts +71 -0
- package/dist/src/bridge.js +151 -0
- package/dist/src/bridge.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/isolate.d.ts +97 -0
- package/dist/src/isolate.js +174 -0
- package/dist/src/isolate.js.map +1 -0
- package/dist/src/sandbox.d.ts +40 -0
- package/dist/src/sandbox.js +116 -0
- package/dist/src/sandbox.js.map +1 -0
- package/dist/src/types.d.ts +63 -0
- package/dist/src/types.js +10 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +37 -0
- package/src/bridge.ts +219 -0
- package/src/index.ts +11 -0
- package/src/isolate.ts +202 -0
- package/src/sandbox.ts +139 -0
- package/src/types.ts +73 -0
- package/tsconfig.json +13 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for a single sandboxed tool call.
|
|
3
|
+
*/
|
|
4
|
+
export interface ExecuteOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Provider module specifier, e.g. `@utdk/github`.
|
|
7
|
+
* Resolved from the host Node.js module system, not from inside the sandbox.
|
|
8
|
+
*/
|
|
9
|
+
module: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Dot-notation path to the operation on the client object, e.g. `users.getByUsername`.
|
|
13
|
+
*/
|
|
14
|
+
operation: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Arguments passed to the operation.
|
|
18
|
+
*/
|
|
19
|
+
args?: Record<string, unknown>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Credentials injected by the gateway at call time.
|
|
23
|
+
* Keys are environment-variable-style names (e.g. `GITHUB_TOKEN`).
|
|
24
|
+
* These are NEVER written to `process.env`; the sandbox context has no
|
|
25
|
+
* access to `process` at all.
|
|
26
|
+
*/
|
|
27
|
+
credentials?: Record<string, string>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Execution timeout in milliseconds (default: 30 000).
|
|
31
|
+
* Once exceeded, the isolate rejects with a `TimeoutError`.
|
|
32
|
+
*/
|
|
33
|
+
timeout?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Result of a sandboxed execution.
|
|
38
|
+
*/
|
|
39
|
+
export interface ExecuteResult {
|
|
40
|
+
/** The value returned by the operation. */
|
|
41
|
+
data: unknown;
|
|
42
|
+
/** Wall-clock duration of the execution in milliseconds. */
|
|
43
|
+
durationMs: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A single entry from a provider's `utdk.auth` config array in `package.json`.
|
|
48
|
+
*/
|
|
49
|
+
export interface UtdkAuthConfig {
|
|
50
|
+
auth_type: "api_key" | "oauth2" | "basic" | "none";
|
|
51
|
+
/** For api_key: the header value pattern, e.g. "Bearer ${GITHUB_TOKEN}" */
|
|
52
|
+
api_key?: string;
|
|
53
|
+
/** For api_key: the header name, e.g. "Authorization" */
|
|
54
|
+
var_name?: string;
|
|
55
|
+
/** For oauth2: client id pattern, e.g. "${SPOTIFY_CLIENT_ID}" */
|
|
56
|
+
client_id?: string;
|
|
57
|
+
/** For oauth2: client secret pattern, e.g. "${SPOTIFY_CLIENT_SECRET}" */
|
|
58
|
+
client_secret?: string;
|
|
59
|
+
/** For oauth2: token URL */
|
|
60
|
+
token_url?: string;
|
|
61
|
+
/** For oauth2: flow type */
|
|
62
|
+
flow?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Error thrown when an execution exceeds its timeout.
|
|
67
|
+
*/
|
|
68
|
+
export class TimeoutError extends Error {
|
|
69
|
+
constructor(timeoutMs: number) {
|
|
70
|
+
super(`Isolate execution timed out after ${timeoutMs}ms`);
|
|
71
|
+
this.name = "TimeoutError";
|
|
72
|
+
}
|
|
73
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"moduleResolution": "Bundler",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"types": ["node"]
|
|
10
|
+
},
|
|
11
|
+
"include": ["./**/*.ts"],
|
|
12
|
+
"exclude": ["node_modules", "dist"]
|
|
13
|
+
}
|