@ebowwa/sandbox 0.1.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.
- package/dist/compilers/index.d.ts +24 -0
- package/dist/compilers/index.d.ts.map +1 -0
- package/dist/compilers/index.js +42 -0
- package/dist/compilers/index.js.map +1 -0
- package/dist/compilers/javascript.d.ts +117 -0
- package/dist/compilers/javascript.d.ts.map +1 -0
- package/dist/compilers/javascript.js +462 -0
- package/dist/compilers/javascript.js.map +1 -0
- package/dist/compilers/python.d.ts +140 -0
- package/dist/compilers/python.d.ts.map +1 -0
- package/dist/compilers/python.js +650 -0
- package/dist/compilers/python.js.map +1 -0
- package/dist/compilers/typescript.d.ts +99 -0
- package/dist/compilers/typescript.d.ts.map +1 -0
- package/dist/compilers/typescript.js +323 -0
- package/dist/compilers/typescript.js.map +1 -0
- package/dist/core/cell.d.ts +160 -0
- package/dist/core/cell.d.ts.map +1 -0
- package/dist/core/cell.js +319 -0
- package/dist/core/cell.js.map +1 -0
- package/dist/core/compiler.d.ts +126 -0
- package/dist/core/compiler.d.ts.map +1 -0
- package/dist/core/compiler.js +123 -0
- package/dist/core/compiler.js.map +1 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/limits.d.ts +173 -0
- package/dist/core/limits.d.ts.map +1 -0
- package/dist/core/limits.js +440 -0
- package/dist/core/limits.js.map +1 -0
- package/dist/core/permissions.d.ts +103 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/core/permissions.js +341 -0
- package/dist/core/permissions.js.map +1 -0
- package/dist/core/runtime.d.ts +127 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +325 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/types.d.ts +380 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +67 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +279 -0
- package/dist/index.js.map +1 -0
- package/dist/multi/index.d.ts +9 -0
- package/dist/multi/index.d.ts.map +1 -0
- package/dist/multi/index.js +7 -0
- package/dist/multi/index.js.map +1 -0
- package/dist/multi/polyglot.d.ts +179 -0
- package/dist/multi/polyglot.d.ts.map +1 -0
- package/dist/multi/polyglot.js +319 -0
- package/dist/multi/polyglot.js.map +1 -0
- package/dist/runtimes/docker.d.ts +97 -0
- package/dist/runtimes/docker.d.ts.map +1 -0
- package/dist/runtimes/docker.js +368 -0
- package/dist/runtimes/docker.js.map +1 -0
- package/dist/runtimes/index.d.ts +11 -0
- package/dist/runtimes/index.d.ts.map +1 -0
- package/dist/runtimes/index.js +9 -0
- package/dist/runtimes/index.js.map +1 -0
- package/dist/runtimes/process.d.ts +47 -0
- package/dist/runtimes/process.d.ts.map +1 -0
- package/dist/runtimes/process.js +230 -0
- package/dist/runtimes/process.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +9 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/kernel.d.ts +199 -0
- package/dist/session/kernel.d.ts.map +1 -0
- package/dist/session/kernel.js +400 -0
- package/dist/session/kernel.js.map +1 -0
- package/dist/session/notebook.d.ts +168 -0
- package/dist/session/notebook.d.ts.map +1 -0
- package/dist/session/notebook.js +499 -0
- package/dist/session/notebook.js.map +1 -0
- package/dist/session/repl.d.ts +159 -0
- package/dist/session/repl.d.ts.map +1 -0
- package/dist/session/repl.js +409 -0
- package/dist/session/repl.js.map +1 -0
- package/package.json +142 -0
- package/src/compilers/index.ts +80 -0
- package/src/compilers/javascript.ts +571 -0
- package/src/compilers/python.ts +785 -0
- package/src/compilers/typescript.ts +442 -0
- package/src/core/cell.ts +439 -0
- package/src/core/compiler.ts +250 -0
- package/src/core/index.ts +123 -0
- package/src/core/limits.ts +508 -0
- package/src/core/permissions.ts +409 -0
- package/src/core/runtime.ts +499 -0
- package/src/core/types.ts +528 -0
- package/src/global.d.ts +59 -0
- package/src/index.ts +515 -0
- package/src/multi/index.ts +22 -0
- package/src/multi/polyglot.ts +461 -0
- package/src/runtimes/docker.ts +501 -0
- package/src/runtimes/index.ts +21 -0
- package/src/runtimes/process.ts +316 -0
- package/src/session/index.ts +41 -0
- package/src/session/kernel.ts +553 -0
- package/src/session/notebook.ts +635 -0
- package/src/session/repl.ts +521 -0
- package/src/wasm2wasm.d.ts +35 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limits Primitive
|
|
3
|
+
*
|
|
4
|
+
* Composable resource limits for sandbox execution.
|
|
5
|
+
* Enforces memory, time, CPU, and I/O constraints.
|
|
6
|
+
*/
|
|
7
|
+
import type { Limits } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Parsed limits in normalized units
|
|
10
|
+
*/
|
|
11
|
+
export interface ParsedLimits {
|
|
12
|
+
memoryBytes: number;
|
|
13
|
+
timeoutMs: number;
|
|
14
|
+
cpuTimeMs: number;
|
|
15
|
+
maxInstructions: number;
|
|
16
|
+
maxOutputBytes: number;
|
|
17
|
+
maxStackDepth: number;
|
|
18
|
+
network: {
|
|
19
|
+
maxBandwidthBytes: number;
|
|
20
|
+
maxConnections: number;
|
|
21
|
+
};
|
|
22
|
+
filesystem: {
|
|
23
|
+
maxFileBytes: number;
|
|
24
|
+
maxTotalBytes: number;
|
|
25
|
+
maxOpenFiles: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default limits for different isolation levels
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_LIMITS: Record<string, ParsedLimits>;
|
|
32
|
+
/**
|
|
33
|
+
* Limits Parser
|
|
34
|
+
*
|
|
35
|
+
* Converts human-readable limits to normalized values.
|
|
36
|
+
*/
|
|
37
|
+
export declare class LimitsParser {
|
|
38
|
+
/**
|
|
39
|
+
* Parse limits object to normalized values
|
|
40
|
+
*/
|
|
41
|
+
static parse(limits: Limits): ParsedLimits;
|
|
42
|
+
/**
|
|
43
|
+
* Parse memory string/number to bytes
|
|
44
|
+
*/
|
|
45
|
+
static parseMemory(mem: number | string | undefined): number;
|
|
46
|
+
/**
|
|
47
|
+
* Parse time string/number to milliseconds
|
|
48
|
+
*/
|
|
49
|
+
static parseTime(time: number | string | undefined): number;
|
|
50
|
+
/**
|
|
51
|
+
* Format bytes to human-readable string
|
|
52
|
+
*/
|
|
53
|
+
static formatMemory(bytes: number): string;
|
|
54
|
+
/**
|
|
55
|
+
* Format milliseconds to human-readable string
|
|
56
|
+
*/
|
|
57
|
+
static formatTime(ms: number): string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Limits Enforcer
|
|
61
|
+
*
|
|
62
|
+
* Tracks and enforces resource limits during execution.
|
|
63
|
+
*/
|
|
64
|
+
export declare class LimitsEnforcer {
|
|
65
|
+
private limits;
|
|
66
|
+
private startTime;
|
|
67
|
+
private instructionCount;
|
|
68
|
+
private memoryUsed;
|
|
69
|
+
private outputSize;
|
|
70
|
+
private networkBytes;
|
|
71
|
+
private openFiles;
|
|
72
|
+
private aborted;
|
|
73
|
+
private abortReason?;
|
|
74
|
+
constructor(limits: ParsedLimits);
|
|
75
|
+
/**
|
|
76
|
+
* Start tracking
|
|
77
|
+
*/
|
|
78
|
+
start(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Check if execution should continue
|
|
81
|
+
*/
|
|
82
|
+
check(): {
|
|
83
|
+
ok: boolean;
|
|
84
|
+
reason?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Track memory allocation
|
|
88
|
+
*/
|
|
89
|
+
trackMemory(bytes: number): {
|
|
90
|
+
ok: boolean;
|
|
91
|
+
reason?: string;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Track instruction execution
|
|
95
|
+
*/
|
|
96
|
+
trackInstructions(count: number): {
|
|
97
|
+
ok: boolean;
|
|
98
|
+
reason?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Track output size
|
|
102
|
+
*/
|
|
103
|
+
trackOutput(bytes: number): {
|
|
104
|
+
ok: boolean;
|
|
105
|
+
reason?: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Track network usage
|
|
109
|
+
*/
|
|
110
|
+
trackNetwork(direction: "in" | "out", bytes: number): {
|
|
111
|
+
ok: boolean;
|
|
112
|
+
reason?: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Track file open
|
|
116
|
+
*/
|
|
117
|
+
trackFileOpen(): {
|
|
118
|
+
ok: boolean;
|
|
119
|
+
reason?: string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Track file close
|
|
123
|
+
*/
|
|
124
|
+
trackFileClose(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get current usage stats
|
|
127
|
+
*/
|
|
128
|
+
getUsage(): {
|
|
129
|
+
elapsed: number;
|
|
130
|
+
memory: number;
|
|
131
|
+
instructions: number;
|
|
132
|
+
output: number;
|
|
133
|
+
networkIn: number;
|
|
134
|
+
networkOut: number;
|
|
135
|
+
openFiles: number;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Abort execution
|
|
139
|
+
*/
|
|
140
|
+
abort(reason: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Check if aborted
|
|
143
|
+
*/
|
|
144
|
+
isAborted(): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Get abort reason
|
|
147
|
+
*/
|
|
148
|
+
getAbortReason(): string | undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Limits Builder
|
|
152
|
+
*
|
|
153
|
+
* Fluent API for building limits.
|
|
154
|
+
*/
|
|
155
|
+
export declare class LimitsBuilder {
|
|
156
|
+
private limits;
|
|
157
|
+
memory(bytes: number | string): this;
|
|
158
|
+
timeout(ms: number | string): this;
|
|
159
|
+
cpuTime(ms: number): this;
|
|
160
|
+
instructions(max: number): this;
|
|
161
|
+
outputSize(bytes: number): this;
|
|
162
|
+
stackDepth(max: number): this;
|
|
163
|
+
network(options: Limits["network"]): this;
|
|
164
|
+
filesystem(options: Limits["filesystem"]): this;
|
|
165
|
+
build(): Limits;
|
|
166
|
+
parse(): ParsedLimits;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Merge limits (take minimums - most restrictive)
|
|
170
|
+
*/
|
|
171
|
+
export declare function mergeLimits(...limits: Limits[]): Limits;
|
|
172
|
+
export { parseMemory, parseTime } from "./types.js";
|
|
173
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/core/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE;QACP,iBAAiB,EAAE,MAAM,CAAC;QAC1B,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,UAAU,EAAE;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAuGvD,CAAC;AAEF;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;I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AI,YAAY;CAGtB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAsDvD;AAGD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limits Primitive
|
|
3
|
+
*
|
|
4
|
+
* Composable resource limits for sandbox execution.
|
|
5
|
+
* Enforces memory, time, CPU, and I/O constraints.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default limits for different isolation levels
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_LIMITS = {
|
|
11
|
+
isolated: {
|
|
12
|
+
memoryBytes: 16 * 1024 * 1024, // 16MB
|
|
13
|
+
timeoutMs: 5000, // 5s
|
|
14
|
+
cpuTimeMs: 1000, // 1s CPU time
|
|
15
|
+
maxInstructions: 10_000_000,
|
|
16
|
+
maxOutputBytes: 1024 * 1024, // 1MB
|
|
17
|
+
maxStackDepth: 100,
|
|
18
|
+
network: {
|
|
19
|
+
maxBandwidthBytes: 0,
|
|
20
|
+
maxConnections: 0,
|
|
21
|
+
},
|
|
22
|
+
filesystem: {
|
|
23
|
+
maxFileBytes: 0,
|
|
24
|
+
maxTotalBytes: 0,
|
|
25
|
+
maxOpenFiles: 0,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
readonly: {
|
|
29
|
+
memoryBytes: 64 * 1024 * 1024, // 64MB
|
|
30
|
+
timeoutMs: 30000, // 30s
|
|
31
|
+
cpuTimeMs: 5000, // 5s CPU time
|
|
32
|
+
maxInstructions: 100_000_000,
|
|
33
|
+
maxOutputBytes: 10 * 1024 * 1024, // 10MB
|
|
34
|
+
maxStackDepth: 500,
|
|
35
|
+
network: {
|
|
36
|
+
maxBandwidthBytes: 0,
|
|
37
|
+
maxConnections: 0,
|
|
38
|
+
},
|
|
39
|
+
filesystem: {
|
|
40
|
+
maxFileBytes: 10 * 1024 * 1024, // 10MB per file
|
|
41
|
+
maxTotalBytes: 100 * 1024 * 1024, // 100MB total
|
|
42
|
+
maxOpenFiles: 10,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
network: {
|
|
46
|
+
memoryBytes: 128 * 1024 * 1024, // 128MB
|
|
47
|
+
timeoutMs: 60000, // 60s
|
|
48
|
+
cpuTimeMs: 10000, // 10s CPU time
|
|
49
|
+
maxInstructions: 500_000_000,
|
|
50
|
+
maxOutputBytes: 50 * 1024 * 1024, // 50MB
|
|
51
|
+
maxStackDepth: 1000,
|
|
52
|
+
network: {
|
|
53
|
+
maxBandwidthBytes: 10 * 1024 * 1024, // 10MB/s
|
|
54
|
+
maxConnections: 10,
|
|
55
|
+
},
|
|
56
|
+
filesystem: {
|
|
57
|
+
maxFileBytes: 10 * 1024 * 1024,
|
|
58
|
+
maxTotalBytes: 100 * 1024 * 1024,
|
|
59
|
+
maxOpenFiles: 20,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
filesystem: {
|
|
63
|
+
memoryBytes: 256 * 1024 * 1024, // 256MB
|
|
64
|
+
timeoutMs: 120000, // 2min
|
|
65
|
+
cpuTimeMs: 30000, // 30s CPU time
|
|
66
|
+
maxInstructions: 1_000_000_000,
|
|
67
|
+
maxOutputBytes: 100 * 1024 * 1024, // 100MB
|
|
68
|
+
maxStackDepth: 2000,
|
|
69
|
+
network: {
|
|
70
|
+
maxBandwidthBytes: 50 * 1024 * 1024, // 50MB/s
|
|
71
|
+
maxConnections: 50,
|
|
72
|
+
},
|
|
73
|
+
filesystem: {
|
|
74
|
+
maxFileBytes: 100 * 1024 * 1024, // 100MB per file
|
|
75
|
+
maxTotalBytes: 1024 * 1024 * 1024, // 1GB total
|
|
76
|
+
maxOpenFiles: 100,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
admin: {
|
|
80
|
+
memoryBytes: 1024 * 1024 * 1024, // 1GB
|
|
81
|
+
timeoutMs: 300000, // 5min
|
|
82
|
+
cpuTimeMs: 60000, // 1min CPU time
|
|
83
|
+
maxInstructions: 5_000_000_000,
|
|
84
|
+
maxOutputBytes: 500 * 1024 * 1024, // 500MB
|
|
85
|
+
maxStackDepth: 5000,
|
|
86
|
+
network: {
|
|
87
|
+
maxBandwidthBytes: 100 * 1024 * 1024, // 100MB/s
|
|
88
|
+
maxConnections: 100,
|
|
89
|
+
},
|
|
90
|
+
filesystem: {
|
|
91
|
+
maxFileBytes: 1024 * 1024 * 1024, // 1GB per file
|
|
92
|
+
maxTotalBytes: 10 * 1024 * 1024 * 1024, // 10GB total
|
|
93
|
+
maxOpenFiles: 500,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
sudo: {
|
|
97
|
+
memoryBytes: 4 * 1024 * 1024 * 1024, // 4GB
|
|
98
|
+
timeoutMs: 600000, // 10min
|
|
99
|
+
cpuTimeMs: 300000, // 5min CPU time
|
|
100
|
+
maxInstructions: 10_000_000_000,
|
|
101
|
+
maxOutputBytes: 1024 * 1024 * 1024, // 1GB
|
|
102
|
+
maxStackDepth: 10000,
|
|
103
|
+
network: {
|
|
104
|
+
maxBandwidthBytes: 500 * 1024 * 1024, // 500MB/s
|
|
105
|
+
maxConnections: 500,
|
|
106
|
+
},
|
|
107
|
+
filesystem: {
|
|
108
|
+
maxFileBytes: 10 * 1024 * 1024 * 1024, // 10GB per file
|
|
109
|
+
maxTotalBytes: 100 * 1024 * 1024 * 1024, // 100GB total
|
|
110
|
+
maxOpenFiles: 1000,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Limits Parser
|
|
116
|
+
*
|
|
117
|
+
* Converts human-readable limits to normalized values.
|
|
118
|
+
*/
|
|
119
|
+
export class LimitsParser {
|
|
120
|
+
/**
|
|
121
|
+
* Parse limits object to normalized values
|
|
122
|
+
*/
|
|
123
|
+
static parse(limits) {
|
|
124
|
+
return {
|
|
125
|
+
memoryBytes: this.parseMemory(limits.memory),
|
|
126
|
+
timeoutMs: this.parseTime(limits.timeout),
|
|
127
|
+
cpuTimeMs: limits.cpuTime ?? 30000,
|
|
128
|
+
maxInstructions: limits.maxInstructions ?? 100_000_000,
|
|
129
|
+
maxOutputBytes: limits.maxOutputSize ?? 10 * 1024 * 1024,
|
|
130
|
+
maxStackDepth: limits.maxStackDepth ?? 1000,
|
|
131
|
+
network: {
|
|
132
|
+
maxBandwidthBytes: this.parseMemory(limits.network?.maxBandwidth),
|
|
133
|
+
maxConnections: limits.network?.maxConnections ?? 10,
|
|
134
|
+
},
|
|
135
|
+
filesystem: {
|
|
136
|
+
maxFileBytes: this.parseMemory(limits.filesystem?.maxFileSize),
|
|
137
|
+
maxTotalBytes: this.parseMemory(limits.filesystem?.maxTotalSize),
|
|
138
|
+
maxOpenFiles: limits.filesystem?.maxOpenFiles ?? 100,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse memory string/number to bytes
|
|
144
|
+
*/
|
|
145
|
+
static parseMemory(mem) {
|
|
146
|
+
if (mem === undefined)
|
|
147
|
+
return 16 * 1024 * 1024; // 16MB default
|
|
148
|
+
if (typeof mem === "number")
|
|
149
|
+
return mem;
|
|
150
|
+
const match = mem.match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb|tb)?$/i);
|
|
151
|
+
if (!match)
|
|
152
|
+
return 16 * 1024 * 1024;
|
|
153
|
+
const [, num, unit] = match;
|
|
154
|
+
const multipliers = {
|
|
155
|
+
b: 1,
|
|
156
|
+
kb: 1024,
|
|
157
|
+
mb: 1024 ** 2,
|
|
158
|
+
gb: 1024 ** 3,
|
|
159
|
+
tb: 1024 ** 4,
|
|
160
|
+
};
|
|
161
|
+
return Math.floor(parseFloat(num) * (multipliers[unit?.toLowerCase() ?? "b"] ?? 1));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Parse time string/number to milliseconds
|
|
165
|
+
*/
|
|
166
|
+
static parseTime(time) {
|
|
167
|
+
if (time === undefined)
|
|
168
|
+
return 30000; // 30s default
|
|
169
|
+
if (typeof time === "number")
|
|
170
|
+
return time;
|
|
171
|
+
const match = time.match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)?$/i);
|
|
172
|
+
if (!match)
|
|
173
|
+
return 30000;
|
|
174
|
+
const [, num, unit] = match;
|
|
175
|
+
const multipliers = {
|
|
176
|
+
ms: 1,
|
|
177
|
+
s: 1000,
|
|
178
|
+
m: 60000,
|
|
179
|
+
h: 3600000,
|
|
180
|
+
};
|
|
181
|
+
return Math.floor(parseFloat(num) * (multipliers[unit?.toLowerCase() ?? "ms"] ?? 1));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Format bytes to human-readable string
|
|
185
|
+
*/
|
|
186
|
+
static formatMemory(bytes) {
|
|
187
|
+
const units = ["b", "kb", "mb", "gb", "tb"];
|
|
188
|
+
let value = bytes;
|
|
189
|
+
let unitIndex = 0;
|
|
190
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
191
|
+
value /= 1024;
|
|
192
|
+
unitIndex++;
|
|
193
|
+
}
|
|
194
|
+
return `${value.toFixed(1)}${units[unitIndex]}`;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Format milliseconds to human-readable string
|
|
198
|
+
*/
|
|
199
|
+
static formatTime(ms) {
|
|
200
|
+
if (ms < 1000)
|
|
201
|
+
return `${ms}ms`;
|
|
202
|
+
if (ms < 60000)
|
|
203
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
204
|
+
if (ms < 3600000)
|
|
205
|
+
return `${(ms / 60000).toFixed(1)}m`;
|
|
206
|
+
return `${(ms / 3600000).toFixed(1)}h`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Limits Enforcer
|
|
211
|
+
*
|
|
212
|
+
* Tracks and enforces resource limits during execution.
|
|
213
|
+
*/
|
|
214
|
+
export class LimitsEnforcer {
|
|
215
|
+
limits;
|
|
216
|
+
startTime = 0;
|
|
217
|
+
instructionCount = 0;
|
|
218
|
+
memoryUsed = 0;
|
|
219
|
+
outputSize = 0;
|
|
220
|
+
networkBytes = { in: 0, out: 0 };
|
|
221
|
+
openFiles = 0;
|
|
222
|
+
aborted = false;
|
|
223
|
+
abortReason;
|
|
224
|
+
constructor(limits) {
|
|
225
|
+
this.limits = limits;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Start tracking
|
|
229
|
+
*/
|
|
230
|
+
start() {
|
|
231
|
+
this.startTime = Date.now();
|
|
232
|
+
this.aborted = false;
|
|
233
|
+
this.abortReason = undefined;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Check if execution should continue
|
|
237
|
+
*/
|
|
238
|
+
check() {
|
|
239
|
+
if (this.aborted) {
|
|
240
|
+
return { ok: false, reason: this.abortReason };
|
|
241
|
+
}
|
|
242
|
+
// Check timeout
|
|
243
|
+
const elapsed = Date.now() - this.startTime;
|
|
244
|
+
if (elapsed > this.limits.timeoutMs) {
|
|
245
|
+
return { ok: false, reason: `Timeout exceeded: ${elapsed}ms > ${this.limits.timeoutMs}ms` };
|
|
246
|
+
}
|
|
247
|
+
return { ok: true };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Track memory allocation
|
|
251
|
+
*/
|
|
252
|
+
trackMemory(bytes) {
|
|
253
|
+
this.memoryUsed += bytes;
|
|
254
|
+
if (this.memoryUsed > this.limits.memoryBytes) {
|
|
255
|
+
this.abort(`Memory limit exceeded: ${LimitsParser.formatMemory(this.memoryUsed)} > ${LimitsParser.formatMemory(this.limits.memoryBytes)}`);
|
|
256
|
+
return { ok: false, reason: this.abortReason };
|
|
257
|
+
}
|
|
258
|
+
return { ok: true };
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Track instruction execution
|
|
262
|
+
*/
|
|
263
|
+
trackInstructions(count) {
|
|
264
|
+
this.instructionCount += count;
|
|
265
|
+
if (this.instructionCount > this.limits.maxInstructions) {
|
|
266
|
+
this.abort(`Instruction limit exceeded: ${this.instructionCount} > ${this.limits.maxInstructions}`);
|
|
267
|
+
return { ok: false, reason: this.abortReason };
|
|
268
|
+
}
|
|
269
|
+
return { ok: true };
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Track output size
|
|
273
|
+
*/
|
|
274
|
+
trackOutput(bytes) {
|
|
275
|
+
this.outputSize += bytes;
|
|
276
|
+
if (this.outputSize > this.limits.maxOutputBytes) {
|
|
277
|
+
this.abort(`Output limit exceeded: ${LimitsParser.formatMemory(this.outputSize)} > ${LimitsParser.formatMemory(this.limits.maxOutputBytes)}`);
|
|
278
|
+
return { ok: false, reason: this.abortReason };
|
|
279
|
+
}
|
|
280
|
+
return { ok: true };
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Track network usage
|
|
284
|
+
*/
|
|
285
|
+
trackNetwork(direction, bytes) {
|
|
286
|
+
this.networkBytes[direction] += bytes;
|
|
287
|
+
// Could add bandwidth tracking here
|
|
288
|
+
return { ok: true };
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Track file open
|
|
292
|
+
*/
|
|
293
|
+
trackFileOpen() {
|
|
294
|
+
this.openFiles++;
|
|
295
|
+
if (this.openFiles > this.limits.filesystem.maxOpenFiles) {
|
|
296
|
+
this.openFiles--;
|
|
297
|
+
return { ok: false, reason: `Too many open files: ${this.openFiles} > ${this.limits.filesystem.maxOpenFiles}` };
|
|
298
|
+
}
|
|
299
|
+
return { ok: true };
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Track file close
|
|
303
|
+
*/
|
|
304
|
+
trackFileClose() {
|
|
305
|
+
this.openFiles = Math.max(0, this.openFiles - 1);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Get current usage stats
|
|
309
|
+
*/
|
|
310
|
+
getUsage() {
|
|
311
|
+
return {
|
|
312
|
+
elapsed: Date.now() - this.startTime,
|
|
313
|
+
memory: this.memoryUsed,
|
|
314
|
+
instructions: this.instructionCount,
|
|
315
|
+
output: this.outputSize,
|
|
316
|
+
networkIn: this.networkBytes.in,
|
|
317
|
+
networkOut: this.networkBytes.out,
|
|
318
|
+
openFiles: this.openFiles,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Abort execution
|
|
323
|
+
*/
|
|
324
|
+
abort(reason) {
|
|
325
|
+
this.aborted = true;
|
|
326
|
+
this.abortReason = reason;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Check if aborted
|
|
330
|
+
*/
|
|
331
|
+
isAborted() {
|
|
332
|
+
return this.aborted;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Get abort reason
|
|
336
|
+
*/
|
|
337
|
+
getAbortReason() {
|
|
338
|
+
return this.abortReason;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Limits Builder
|
|
343
|
+
*
|
|
344
|
+
* Fluent API for building limits.
|
|
345
|
+
*/
|
|
346
|
+
export class LimitsBuilder {
|
|
347
|
+
limits = {};
|
|
348
|
+
memory(bytes) {
|
|
349
|
+
this.limits.memory = bytes;
|
|
350
|
+
return this;
|
|
351
|
+
}
|
|
352
|
+
timeout(ms) {
|
|
353
|
+
this.limits.timeout = ms;
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
cpuTime(ms) {
|
|
357
|
+
this.limits.cpuTime = ms;
|
|
358
|
+
return this;
|
|
359
|
+
}
|
|
360
|
+
instructions(max) {
|
|
361
|
+
this.limits.maxInstructions = max;
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
outputSize(bytes) {
|
|
365
|
+
this.limits.maxOutputSize = bytes;
|
|
366
|
+
return this;
|
|
367
|
+
}
|
|
368
|
+
stackDepth(max) {
|
|
369
|
+
this.limits.maxStackDepth = max;
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
network(options) {
|
|
373
|
+
this.limits.network = options;
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
376
|
+
filesystem(options) {
|
|
377
|
+
this.limits.filesystem = options;
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
build() {
|
|
381
|
+
return this.limits;
|
|
382
|
+
}
|
|
383
|
+
parse() {
|
|
384
|
+
return LimitsParser.parse(this.limits);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Merge limits (take minimums - most restrictive)
|
|
389
|
+
*/
|
|
390
|
+
export function mergeLimits(...limits) {
|
|
391
|
+
const result = {};
|
|
392
|
+
// Memory - take minimum
|
|
393
|
+
const memories = limits
|
|
394
|
+
.map(l => l.memory)
|
|
395
|
+
.filter(Boolean);
|
|
396
|
+
if (memories.length > 0) {
|
|
397
|
+
const parsed = memories.map(m => LimitsParser.parseMemory(m));
|
|
398
|
+
result.memory = Math.min(...parsed);
|
|
399
|
+
}
|
|
400
|
+
// Timeout - take minimum
|
|
401
|
+
const timeouts = limits
|
|
402
|
+
.map(l => l.timeout)
|
|
403
|
+
.filter(Boolean);
|
|
404
|
+
if (timeouts.length > 0) {
|
|
405
|
+
const parsed = timeouts.map(t => LimitsParser.parseTime(t));
|
|
406
|
+
result.timeout = Math.min(...parsed);
|
|
407
|
+
}
|
|
408
|
+
// CPU time - take minimum
|
|
409
|
+
const cpuTimes = limits
|
|
410
|
+
.map(l => l.cpuTime)
|
|
411
|
+
.filter(Boolean);
|
|
412
|
+
if (cpuTimes.length > 0) {
|
|
413
|
+
result.cpuTime = Math.min(...cpuTimes);
|
|
414
|
+
}
|
|
415
|
+
// Instructions - take minimum
|
|
416
|
+
const instructions = limits
|
|
417
|
+
.map(l => l.maxInstructions)
|
|
418
|
+
.filter(Boolean);
|
|
419
|
+
if (instructions.length > 0) {
|
|
420
|
+
result.maxInstructions = Math.min(...instructions);
|
|
421
|
+
}
|
|
422
|
+
// Output size - take minimum
|
|
423
|
+
const outputSizes = limits
|
|
424
|
+
.map(l => l.maxOutputSize)
|
|
425
|
+
.filter(Boolean);
|
|
426
|
+
if (outputSizes.length > 0) {
|
|
427
|
+
result.maxOutputSize = Math.min(...outputSizes);
|
|
428
|
+
}
|
|
429
|
+
// Stack depth - take minimum
|
|
430
|
+
const stackDepths = limits
|
|
431
|
+
.map(l => l.maxStackDepth)
|
|
432
|
+
.filter(Boolean);
|
|
433
|
+
if (stackDepths.length > 0) {
|
|
434
|
+
result.maxStackDepth = Math.min(...stackDepths);
|
|
435
|
+
}
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
// Re-export parse functions from types
|
|
439
|
+
export { parseMemory, parseTime } from "./types.js";
|
|
440
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/core/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiC;IAC1D,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,OAAO;QACtC,SAAS,EAAE,IAAI,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI,EAAE,cAAc;QAC/B,eAAe,EAAE,UAAU;QAC3B,cAAc,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM;QACnC,aAAa,EAAE,GAAG;QAClB,OAAO,EAAE;YACP,iBAAiB,EAAE,CAAC;YACpB,cAAc,EAAE,CAAC;SAClB;QACD,UAAU,EAAE;YACV,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,CAAC;SAChB;KACF;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,OAAO;QACtC,SAAS,EAAE,KAAK,EAAE,MAAM;QACxB,SAAS,EAAE,IAAI,EAAE,cAAc;QAC/B,eAAe,E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