@unchartedfr/zapcode 1.0.0-beta.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/index.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ export interface ZapcodeOptions {
2
+ inputs?: string[];
3
+ externalFunctions?: string[];
4
+ memoryLimitMb?: number;
5
+ timeLimitMs?: number;
6
+ }
7
+
8
+ export interface ZapcodeResult {
9
+ completed: true;
10
+ output: unknown;
11
+ stdout: string;
12
+ }
13
+
14
+ export interface ZapcodeSuspension {
15
+ completed: false;
16
+ functionName: string;
17
+ args: unknown[];
18
+ snapshot: Buffer;
19
+ }
20
+
21
+ export class ZapcodeSnapshotHandle {
22
+ static load(bytes: Buffer): ZapcodeSnapshotHandle;
23
+ dump(): Buffer;
24
+ resume(returnValue: unknown): ZapcodeResult | ZapcodeSuspension;
25
+ }
26
+
27
+ export class Zapcode {
28
+ constructor(code: string, options?: ZapcodeOptions);
29
+ run(inputs?: Record<string, unknown>): ZapcodeResult;
30
+ start(inputs?: Record<string, unknown>): ZapcodeResult | ZapcodeSuspension;
31
+ }
package/index.js ADDED
@@ -0,0 +1,60 @@
1
+ const { existsSync, readFileSync } = require('fs')
2
+ const { join } = require('path')
3
+
4
+ const { platform, arch } = process
5
+
6
+ function isMusl() {
7
+ if (!process.report || typeof process.report.getReport !== 'function') {
8
+ try {
9
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
10
+ return readFileSync(lddPath, 'utf8').includes('musl')
11
+ } catch {
12
+ return true
13
+ }
14
+ } else {
15
+ const report = process.report.getReport()
16
+ const rpt = typeof report === 'string' ? JSON.parse(report) : report
17
+ return !rpt.header.glibcVersionRuntime
18
+ }
19
+ }
20
+
21
+ function getPlatformKey() {
22
+ let key = `${platform}-${arch}`
23
+ if (platform === 'linux') {
24
+ key = `linux-${arch === 'x64' ? 'x64' : 'arm64'}-${isMusl() ? 'musl' : 'gnu'}`
25
+ } else if (platform === 'darwin') {
26
+ key = `darwin-${arch === 'arm64' ? 'arm64' : 'x64'}`
27
+ } else if (platform === 'win32') {
28
+ key = `win32-${arch === 'arm64' ? 'arm64' : 'x64'}-msvc`
29
+ }
30
+ return key
31
+ }
32
+
33
+ function loadNativeBinding() {
34
+ const key = getPlatformKey()
35
+ const localFile = `zapcode.${key}.node`
36
+ const npmPkg = `@unchartedfr/zapcode-${key}`
37
+
38
+ // Try local .node file first (development)
39
+ const localPath = join(__dirname, localFile)
40
+ if (existsSync(localPath)) {
41
+ return require(localPath)
42
+ }
43
+
44
+ // Try platform-specific npm package (production install)
45
+ try {
46
+ return require(npmPkg)
47
+ } catch {
48
+ throw new Error(
49
+ `Failed to load native binding for ${platform}-${arch}.\n` +
50
+ `Looked for: ${localFile} (local) or ${npmPkg} (npm package).\n` +
51
+ `Try reinstalling: npm install @unchartedfr/zapcode`
52
+ )
53
+ }
54
+ }
55
+
56
+ const binding = loadNativeBinding()
57
+
58
+ module.exports = binding
59
+ module.exports.Zapcode = binding.Zapcode
60
+ module.exports.ZapcodeSnapshotHandle = binding.ZapcodeSnapshotHandle
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-darwin-arm64`
2
+
3
+ This is the **aarch64-apple-darwin** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-darwin-arm64",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "arm64"
6
+ ],
7
+ "main": "zapcode.darwin-arm64.node",
8
+ "files": [
9
+ "zapcode.darwin-arm64.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "darwin"
20
+ ]
21
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-darwin-x64`
2
+
3
+ This is the **x86_64-apple-darwin** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-darwin-x64",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "zapcode.darwin-x64.node",
8
+ "files": [
9
+ "zapcode.darwin-x64.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "darwin"
20
+ ]
21
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-linux-arm64-gnu`
2
+
3
+ This is the **aarch64-unknown-linux-gnu** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-linux-arm64-gnu",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "arm64"
6
+ ],
7
+ "main": "zapcode.linux-arm64-gnu.node",
8
+ "files": [
9
+ "zapcode.linux-arm64-gnu.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "linux"
20
+ ],
21
+ "libc": [
22
+ "glibc"
23
+ ]
24
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-linux-x64-gnu`
2
+
3
+ This is the **x86_64-unknown-linux-gnu** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-linux-x64-gnu",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "zapcode.linux-x64-gnu.node",
8
+ "files": [
9
+ "zapcode.linux-x64-gnu.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "linux"
20
+ ],
21
+ "libc": [
22
+ "glibc"
23
+ ]
24
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-linux-x64-musl`
2
+
3
+ This is the **x86_64-unknown-linux-musl** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-linux-x64-musl",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "zapcode.linux-x64-musl.node",
8
+ "files": [
9
+ "zapcode.linux-x64-musl.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "linux"
20
+ ],
21
+ "libc": [
22
+ "musl"
23
+ ]
24
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-win32-arm64-msvc`
2
+
3
+ This is the **aarch64-pc-windows-msvc** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-win32-arm64-msvc",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "arm64"
6
+ ],
7
+ "main": "zapcode.win32-arm64-msvc.node",
8
+ "files": [
9
+ "zapcode.win32-arm64-msvc.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "win32"
20
+ ]
21
+ }
@@ -0,0 +1,3 @@
1
+ # `@unchartedfr/zapcode-win32-x64-msvc`
2
+
3
+ This is the **x86_64-pc-windows-msvc** binary for `@unchartedfr/zapcode`
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode-win32-x64-msvc",
3
+ "version": "1.0.0-beta.1",
4
+ "cpu": [
5
+ "x64"
6
+ ],
7
+ "main": "zapcode.win32-x64-msvc.node",
8
+ "files": [
9
+ "zapcode.win32-x64-msvc.node"
10
+ ],
11
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/TheUncharted/zapcode.git",
16
+ "directory": "crates/zapcode-js"
17
+ },
18
+ "os": [
19
+ "win32"
20
+ ]
21
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@unchartedfr/zapcode",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "A minimal, secure TypeScript interpreter for AI agents — Node.js bindings",
5
+ "main": "index.js",
6
+ "module": "index.js",
7
+ "types": "index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js",
12
+ "require": "./index.js"
13
+ }
14
+ },
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/TheUncharted/zapcode.git",
19
+ "directory": "crates/zapcode-js"
20
+ },
21
+ "files": [
22
+ "index.js",
23
+ "index.d.ts",
24
+ "npm"
25
+ ],
26
+ "napi": {
27
+ "binaryName": "zapcode",
28
+ "targets": [
29
+ "x86_64-unknown-linux-gnu",
30
+ "x86_64-unknown-linux-musl",
31
+ "aarch64-unknown-linux-gnu",
32
+ "x86_64-apple-darwin",
33
+ "aarch64-apple-darwin",
34
+ "x86_64-pc-windows-msvc",
35
+ "aarch64-pc-windows-msvc"
36
+ ],
37
+ "packageName": "@unchartedfr/zapcode"
38
+ },
39
+ "scripts": {
40
+ "build": "napi build --release --platform --js index.js --dts index.d.ts",
41
+ "prepublishOnly": "napi prepublish -t npm",
42
+ "artifacts": "napi artifacts"
43
+ },
44
+ "devDependencies": {
45
+ "@napi-rs/cli": "^3.5.1"
46
+ },
47
+ "optionalDependencies": {
48
+ "@unchartedfr/zapcode-linux-x64-gnu": "1.0.0-beta.1",
49
+ "@unchartedfr/zapcode-linux-x64-musl": "1.0.0-beta.1",
50
+ "@unchartedfr/zapcode-linux-arm64-gnu": "1.0.0-beta.1",
51
+ "@unchartedfr/zapcode-darwin-x64": "1.0.0-beta.1",
52
+ "@unchartedfr/zapcode-darwin-arm64": "1.0.0-beta.1",
53
+ "@unchartedfr/zapcode-win32-x64-msvc": "1.0.0-beta.1",
54
+ "@unchartedfr/zapcode-win32-arm64-msvc": "1.0.0-beta.1"
55
+ }
56
+ }