@papert-code/sdk-typescript 0.1.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/README.md +372 -0
- package/dist/LICENSE +203 -0
- package/dist/agent.d.ts +47 -0
- package/dist/cli/cli.js +77 -0
- package/dist/cli/sandbox-macos-permissive-closed.sb +32 -0
- package/dist/cli/sandbox-macos-permissive-open.sb +25 -0
- package/dist/cli/sandbox-macos-permissive-proxied.sb +37 -0
- package/dist/cli/sandbox-macos-restrictive-closed.sb +93 -0
- package/dist/cli/sandbox-macos-restrictive-open.sb +96 -0
- package/dist/cli/sandbox-macos-restrictive-proxied.sb +98 -0
- package/dist/cli/vendor/ripgrep/COPYING +3 -0
- package/dist/cli/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/dist/cli/vendor/ripgrep/arm64-linux/rg +0 -0
- package/dist/cli/vendor/ripgrep/x64-darwin/rg +0 -0
- package/dist/cli/vendor/ripgrep/x64-linux/rg +0 -0
- package/dist/cli/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/dist/client.d.ts +32 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.ts +839 -0
- package/dist/index.mjs +20 -0
- package/package.json +76 -0
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Force strict mode and setup for ESM
|
|
3
|
+
"use strict";
|
|
4
|
+
import "./chunks/chunk-RMKGXYYI.js";
|
|
5
|
+
import "./chunks/chunk-ICOYQZHB.js";
|
|
6
|
+
import "./chunks/chunk-VTNP3O6A.js";
|
|
7
|
+
import "./chunks/chunk-7FXB5MJS.js";
|
|
8
|
+
import "./chunks/chunk-G2NP25TN.js";
|
|
9
|
+
import "./chunks/chunk-EM5S27RC.js";
|
|
10
|
+
import "./chunks/chunk-P4DPKRC2.js";
|
|
11
|
+
import "./chunks/chunk-THDY5NFO.js";
|
|
12
|
+
import "./chunks/chunk-FS5UPVZW.js";
|
|
13
|
+
import "./chunks/chunk-IV6H2XE4.js";
|
|
14
|
+
import {
|
|
15
|
+
FatalError
|
|
16
|
+
} from "./chunks/chunk-OVTXUA3U.js";
|
|
17
|
+
import {
|
|
18
|
+
__name,
|
|
19
|
+
init_esbuild_shims
|
|
20
|
+
} from "./chunks/chunk-4HTLIVVR.js";
|
|
21
|
+
|
|
22
|
+
// packages/cli/index.ts
|
|
23
|
+
init_esbuild_shims();
|
|
24
|
+
function isServerCommand(argv) {
|
|
25
|
+
return argv.includes("server");
|
|
26
|
+
}
|
|
27
|
+
__name(isServerCommand, "isServerCommand");
|
|
28
|
+
async function mainEntrypoint() {
|
|
29
|
+
if (isServerCommand(process.argv.slice(2))) {
|
|
30
|
+
const { serverCommand } = await import("./chunks/server-3DEIAIVB.js");
|
|
31
|
+
const rawArgs = process.argv.slice(2);
|
|
32
|
+
const getArgValue = /* @__PURE__ */ __name((name) => {
|
|
33
|
+
const idx = rawArgs.indexOf(name);
|
|
34
|
+
if (idx === -1) return void 0;
|
|
35
|
+
return rawArgs[idx + 1];
|
|
36
|
+
}, "getArgValue");
|
|
37
|
+
const hasFlag = /* @__PURE__ */ __name((name) => rawArgs.includes(name), "hasFlag");
|
|
38
|
+
const portRaw = getArgValue("--port");
|
|
39
|
+
const tokenRaw = getArgValue("--token");
|
|
40
|
+
const hostRaw = getArgValue("--host");
|
|
41
|
+
const ttlRaw = getArgValue("--session-ttl-ms");
|
|
42
|
+
const argv = {
|
|
43
|
+
port: portRaw ? Number(portRaw) : void 0,
|
|
44
|
+
token: tokenRaw,
|
|
45
|
+
host: hostRaw,
|
|
46
|
+
"session-ttl-ms": ttlRaw ? Number(ttlRaw) : void 0,
|
|
47
|
+
docs: hasFlag("--docs")
|
|
48
|
+
};
|
|
49
|
+
await serverCommand.handler(argv);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { main } = await import("./chunks/gemini-7AQ6BAIN.js");
|
|
53
|
+
await main();
|
|
54
|
+
}
|
|
55
|
+
__name(mainEntrypoint, "mainEntrypoint");
|
|
56
|
+
mainEntrypoint().catch((error) => {
|
|
57
|
+
if (error instanceof FatalError) {
|
|
58
|
+
let errorMessage = error.message;
|
|
59
|
+
if (!process.env["NO_COLOR"]) {
|
|
60
|
+
errorMessage = `\x1B[31m${errorMessage}\x1B[0m`;
|
|
61
|
+
}
|
|
62
|
+
console.error(errorMessage);
|
|
63
|
+
process.exit(error.exitCode);
|
|
64
|
+
}
|
|
65
|
+
console.error("An unexpected critical error occurred:");
|
|
66
|
+
if (error instanceof Error) {
|
|
67
|
+
console.error(error.stack);
|
|
68
|
+
} else {
|
|
69
|
+
console.error(String(error));
|
|
70
|
+
}
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* @license
|
|
75
|
+
* * Copyright 2026 Papert-code
|
|
76
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
77
|
+
*/
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; allow everything by default
|
|
4
|
+
(allow default)
|
|
5
|
+
|
|
6
|
+
;; deny all writes EXCEPT under specific paths
|
|
7
|
+
(deny file-write*)
|
|
8
|
+
(allow file-write*
|
|
9
|
+
(subpath (param "TARGET_DIR"))
|
|
10
|
+
(subpath (param "TMP_DIR"))
|
|
11
|
+
(subpath (param "CACHE_DIR"))
|
|
12
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
13
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
14
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
15
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
16
|
+
;; Allow writes to included directories from --include-directories
|
|
17
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
18
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
19
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
20
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
21
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
22
|
+
(literal "/dev/stdout")
|
|
23
|
+
(literal "/dev/stderr")
|
|
24
|
+
(literal "/dev/null")
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
;; deny all inbound network traffic EXCEPT on debugger port
|
|
28
|
+
(deny network-inbound)
|
|
29
|
+
(allow network-inbound (local ip "localhost:9229"))
|
|
30
|
+
|
|
31
|
+
;; deny all outbound network traffic
|
|
32
|
+
(deny network-outbound)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; allow everything by default
|
|
4
|
+
(allow default)
|
|
5
|
+
|
|
6
|
+
;; deny all writes EXCEPT under specific paths
|
|
7
|
+
(deny file-write*)
|
|
8
|
+
(allow file-write*
|
|
9
|
+
(subpath (param "TARGET_DIR"))
|
|
10
|
+
(subpath (param "TMP_DIR"))
|
|
11
|
+
(subpath (param "CACHE_DIR"))
|
|
12
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
13
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
14
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
15
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
16
|
+
;; Allow writes to included directories from --include-directories
|
|
17
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
18
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
19
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
20
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
21
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
22
|
+
(literal "/dev/stdout")
|
|
23
|
+
(literal "/dev/stderr")
|
|
24
|
+
(literal "/dev/null")
|
|
25
|
+
)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; allow everything by default
|
|
4
|
+
(allow default)
|
|
5
|
+
|
|
6
|
+
;; deny all writes EXCEPT under specific paths
|
|
7
|
+
(deny file-write*)
|
|
8
|
+
(allow file-write*
|
|
9
|
+
(subpath (param "TARGET_DIR"))
|
|
10
|
+
(subpath (param "TMP_DIR"))
|
|
11
|
+
(subpath (param "CACHE_DIR"))
|
|
12
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
13
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
14
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
15
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
16
|
+
;; Allow writes to included directories from --include-directories
|
|
17
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
18
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
19
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
20
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
21
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
22
|
+
(literal "/dev/stdout")
|
|
23
|
+
(literal "/dev/stderr")
|
|
24
|
+
(literal "/dev/null")
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
;; deny all inbound network traffic EXCEPT on debugger port
|
|
28
|
+
(deny network-inbound)
|
|
29
|
+
(allow network-inbound (local ip "localhost:9229"))
|
|
30
|
+
|
|
31
|
+
;; deny all outbound network traffic EXCEPT through proxy on localhost:8877
|
|
32
|
+
;; set `GEMINI_SANDBOX_PROXY_COMMAND=<command>` to run proxy alongside sandbox
|
|
33
|
+
;; proxy must listen on :::8877 (see docs/examples/proxy-script.md)
|
|
34
|
+
(deny network-outbound)
|
|
35
|
+
(allow network-outbound (remote tcp "localhost:8877"))
|
|
36
|
+
|
|
37
|
+
(allow network-bind (local ip "*:*"))
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; deny everything by default
|
|
4
|
+
(deny default)
|
|
5
|
+
|
|
6
|
+
;; allow reading files from anywhere on host
|
|
7
|
+
(allow file-read*)
|
|
8
|
+
|
|
9
|
+
;; allow exec/fork (children inherit policy)
|
|
10
|
+
(allow process-exec)
|
|
11
|
+
(allow process-fork)
|
|
12
|
+
|
|
13
|
+
;; allow signals to self, e.g. SIGPIPE on write to closed pipe
|
|
14
|
+
(allow signal (target self))
|
|
15
|
+
|
|
16
|
+
;; allow read access to specific information about system
|
|
17
|
+
;; from https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/common.sb;l=273-319;drc=7b3962fe2e5fc9e2ee58000dc8fbf3429d84d3bd
|
|
18
|
+
(allow sysctl-read
|
|
19
|
+
(sysctl-name "hw.activecpu")
|
|
20
|
+
(sysctl-name "hw.busfrequency_compat")
|
|
21
|
+
(sysctl-name "hw.byteorder")
|
|
22
|
+
(sysctl-name "hw.cacheconfig")
|
|
23
|
+
(sysctl-name "hw.cachelinesize_compat")
|
|
24
|
+
(sysctl-name "hw.cpufamily")
|
|
25
|
+
(sysctl-name "hw.cpufrequency_compat")
|
|
26
|
+
(sysctl-name "hw.cputype")
|
|
27
|
+
(sysctl-name "hw.l1dcachesize_compat")
|
|
28
|
+
(sysctl-name "hw.l1icachesize_compat")
|
|
29
|
+
(sysctl-name "hw.l2cachesize_compat")
|
|
30
|
+
(sysctl-name "hw.l3cachesize_compat")
|
|
31
|
+
(sysctl-name "hw.logicalcpu_max")
|
|
32
|
+
(sysctl-name "hw.machine")
|
|
33
|
+
(sysctl-name "hw.ncpu")
|
|
34
|
+
(sysctl-name "hw.nperflevels")
|
|
35
|
+
(sysctl-name "hw.optional.arm.FEAT_BF16")
|
|
36
|
+
(sysctl-name "hw.optional.arm.FEAT_DotProd")
|
|
37
|
+
(sysctl-name "hw.optional.arm.FEAT_FCMA")
|
|
38
|
+
(sysctl-name "hw.optional.arm.FEAT_FHM")
|
|
39
|
+
(sysctl-name "hw.optional.arm.FEAT_FP16")
|
|
40
|
+
(sysctl-name "hw.optional.arm.FEAT_I8MM")
|
|
41
|
+
(sysctl-name "hw.optional.arm.FEAT_JSCVT")
|
|
42
|
+
(sysctl-name "hw.optional.arm.FEAT_LSE")
|
|
43
|
+
(sysctl-name "hw.optional.arm.FEAT_RDM")
|
|
44
|
+
(sysctl-name "hw.optional.arm.FEAT_SHA512")
|
|
45
|
+
(sysctl-name "hw.optional.armv8_2_sha512")
|
|
46
|
+
(sysctl-name "hw.packages")
|
|
47
|
+
(sysctl-name "hw.pagesize_compat")
|
|
48
|
+
(sysctl-name "hw.physicalcpu_max")
|
|
49
|
+
(sysctl-name "hw.tbfrequency_compat")
|
|
50
|
+
(sysctl-name "hw.vectorunit")
|
|
51
|
+
(sysctl-name "kern.hostname")
|
|
52
|
+
(sysctl-name "kern.maxfilesperproc")
|
|
53
|
+
(sysctl-name "kern.osproductversion")
|
|
54
|
+
(sysctl-name "kern.osrelease")
|
|
55
|
+
(sysctl-name "kern.ostype")
|
|
56
|
+
(sysctl-name "kern.osvariant_status")
|
|
57
|
+
(sysctl-name "kern.osversion")
|
|
58
|
+
(sysctl-name "kern.secure_kernel")
|
|
59
|
+
(sysctl-name "kern.usrstack64")
|
|
60
|
+
(sysctl-name "kern.version")
|
|
61
|
+
(sysctl-name "sysctl.proc_cputype")
|
|
62
|
+
(sysctl-name-prefix "hw.perflevel")
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
;; allow writes to specific paths
|
|
66
|
+
(allow file-write*
|
|
67
|
+
(subpath (param "TARGET_DIR"))
|
|
68
|
+
(subpath (param "TMP_DIR"))
|
|
69
|
+
(subpath (param "CACHE_DIR"))
|
|
70
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
71
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
72
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
73
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
74
|
+
;; Allow writes to included directories from --include-directories
|
|
75
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
76
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
77
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
78
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
79
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
80
|
+
(literal "/dev/stdout")
|
|
81
|
+
(literal "/dev/stderr")
|
|
82
|
+
(literal "/dev/null")
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
;; allow communication with sysmond for process listing (e.g. for pgrep)
|
|
86
|
+
(allow mach-lookup (global-name "com.apple.sysmond"))
|
|
87
|
+
|
|
88
|
+
;; enable terminal access required by ink
|
|
89
|
+
;; fixes setRawMode EPERM failure (at node:tty:81:24)
|
|
90
|
+
(allow file-ioctl (regex #"^/dev/tty.*"))
|
|
91
|
+
|
|
92
|
+
;; allow inbound network traffic on debugger port
|
|
93
|
+
(allow network-inbound (local ip "localhost:9229"))
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; deny everything by default
|
|
4
|
+
(deny default)
|
|
5
|
+
|
|
6
|
+
;; allow reading files from anywhere on host
|
|
7
|
+
(allow file-read*)
|
|
8
|
+
|
|
9
|
+
;; allow exec/fork (children inherit policy)
|
|
10
|
+
(allow process-exec)
|
|
11
|
+
(allow process-fork)
|
|
12
|
+
|
|
13
|
+
;; allow signals to self, e.g. SIGPIPE on write to closed pipe
|
|
14
|
+
(allow signal (target self))
|
|
15
|
+
|
|
16
|
+
;; allow read access to specific information about system
|
|
17
|
+
;; from https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/common.sb;l=273-319;drc=7b3962fe2e5fc9e2ee58000dc8fbf3429d84d3bd
|
|
18
|
+
(allow sysctl-read
|
|
19
|
+
(sysctl-name "hw.activecpu")
|
|
20
|
+
(sysctl-name "hw.busfrequency_compat")
|
|
21
|
+
(sysctl-name "hw.byteorder")
|
|
22
|
+
(sysctl-name "hw.cacheconfig")
|
|
23
|
+
(sysctl-name "hw.cachelinesize_compat")
|
|
24
|
+
(sysctl-name "hw.cpufamily")
|
|
25
|
+
(sysctl-name "hw.cpufrequency_compat")
|
|
26
|
+
(sysctl-name "hw.cputype")
|
|
27
|
+
(sysctl-name "hw.l1dcachesize_compat")
|
|
28
|
+
(sysctl-name "hw.l1icachesize_compat")
|
|
29
|
+
(sysctl-name "hw.l2cachesize_compat")
|
|
30
|
+
(sysctl-name "hw.l3cachesize_compat")
|
|
31
|
+
(sysctl-name "hw.logicalcpu_max")
|
|
32
|
+
(sysctl-name "hw.machine")
|
|
33
|
+
(sysctl-name "hw.ncpu")
|
|
34
|
+
(sysctl-name "hw.nperflevels")
|
|
35
|
+
(sysctl-name "hw.optional.arm.FEAT_BF16")
|
|
36
|
+
(sysctl-name "hw.optional.arm.FEAT_DotProd")
|
|
37
|
+
(sysctl-name "hw.optional.arm.FEAT_FCMA")
|
|
38
|
+
(sysctl-name "hw.optional.arm.FEAT_FHM")
|
|
39
|
+
(sysctl-name "hw.optional.arm.FEAT_FP16")
|
|
40
|
+
(sysctl-name "hw.optional.arm.FEAT_I8MM")
|
|
41
|
+
(sysctl-name "hw.optional.arm.FEAT_JSCVT")
|
|
42
|
+
(sysctl-name "hw.optional.arm.FEAT_LSE")
|
|
43
|
+
(sysctl-name "hw.optional.arm.FEAT_RDM")
|
|
44
|
+
(sysctl-name "hw.optional.arm.FEAT_SHA512")
|
|
45
|
+
(sysctl-name "hw.optional.armv8_2_sha512")
|
|
46
|
+
(sysctl-name "hw.packages")
|
|
47
|
+
(sysctl-name "hw.pagesize_compat")
|
|
48
|
+
(sysctl-name "hw.physicalcpu_max")
|
|
49
|
+
(sysctl-name "hw.tbfrequency_compat")
|
|
50
|
+
(sysctl-name "hw.vectorunit")
|
|
51
|
+
(sysctl-name "kern.hostname")
|
|
52
|
+
(sysctl-name "kern.maxfilesperproc")
|
|
53
|
+
(sysctl-name "kern.osproductversion")
|
|
54
|
+
(sysctl-name "kern.osrelease")
|
|
55
|
+
(sysctl-name "kern.ostype")
|
|
56
|
+
(sysctl-name "kern.osvariant_status")
|
|
57
|
+
(sysctl-name "kern.osversion")
|
|
58
|
+
(sysctl-name "kern.secure_kernel")
|
|
59
|
+
(sysctl-name "kern.usrstack64")
|
|
60
|
+
(sysctl-name "kern.version")
|
|
61
|
+
(sysctl-name "sysctl.proc_cputype")
|
|
62
|
+
(sysctl-name-prefix "hw.perflevel")
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
;; allow writes to specific paths
|
|
66
|
+
(allow file-write*
|
|
67
|
+
(subpath (param "TARGET_DIR"))
|
|
68
|
+
(subpath (param "TMP_DIR"))
|
|
69
|
+
(subpath (param "CACHE_DIR"))
|
|
70
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
71
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
72
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
73
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
74
|
+
;; Allow writes to included directories from --include-directories
|
|
75
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
76
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
77
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
78
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
79
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
80
|
+
(literal "/dev/stdout")
|
|
81
|
+
(literal "/dev/stderr")
|
|
82
|
+
(literal "/dev/null")
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
;; allow communication with sysmond for process listing (e.g. for pgrep)
|
|
86
|
+
(allow mach-lookup (global-name "com.apple.sysmond"))
|
|
87
|
+
|
|
88
|
+
;; enable terminal access required by ink
|
|
89
|
+
;; fixes setRawMode EPERM failure (at node:tty:81:24)
|
|
90
|
+
(allow file-ioctl (regex #"^/dev/tty.*"))
|
|
91
|
+
|
|
92
|
+
;; allow inbound network traffic on debugger port
|
|
93
|
+
(allow network-inbound (local ip "localhost:9229"))
|
|
94
|
+
|
|
95
|
+
;; allow all outbound network traffic
|
|
96
|
+
(allow network-outbound)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
(version 1)
|
|
2
|
+
|
|
3
|
+
;; deny everything by default
|
|
4
|
+
(deny default)
|
|
5
|
+
|
|
6
|
+
;; allow reading files from anywhere on host
|
|
7
|
+
(allow file-read*)
|
|
8
|
+
|
|
9
|
+
;; allow exec/fork (children inherit policy)
|
|
10
|
+
(allow process-exec)
|
|
11
|
+
(allow process-fork)
|
|
12
|
+
|
|
13
|
+
;; allow signals to self, e.g. SIGPIPE on write to closed pipe
|
|
14
|
+
(allow signal (target self))
|
|
15
|
+
|
|
16
|
+
;; allow read access to specific information about system
|
|
17
|
+
;; from https://source.chromium.org/chromium/chromium/src/+/main:sandbox/policy/mac/common.sb;l=273-319;drc=7b3962fe2e5fc9e2ee58000dc8fbf3429d84d3bd
|
|
18
|
+
(allow sysctl-read
|
|
19
|
+
(sysctl-name "hw.activecpu")
|
|
20
|
+
(sysctl-name "hw.busfrequency_compat")
|
|
21
|
+
(sysctl-name "hw.byteorder")
|
|
22
|
+
(sysctl-name "hw.cacheconfig")
|
|
23
|
+
(sysctl-name "hw.cachelinesize_compat")
|
|
24
|
+
(sysctl-name "hw.cpufamily")
|
|
25
|
+
(sysctl-name "hw.cpufrequency_compat")
|
|
26
|
+
(sysctl-name "hw.cputype")
|
|
27
|
+
(sysctl-name "hw.l1dcachesize_compat")
|
|
28
|
+
(sysctl-name "hw.l1icachesize_compat")
|
|
29
|
+
(sysctl-name "hw.l2cachesize_compat")
|
|
30
|
+
(sysctl-name "hw.l3cachesize_compat")
|
|
31
|
+
(sysctl-name "hw.logicalcpu_max")
|
|
32
|
+
(sysctl-name "hw.machine")
|
|
33
|
+
(sysctl-name "hw.ncpu")
|
|
34
|
+
(sysctl-name "hw.nperflevels")
|
|
35
|
+
(sysctl-name "hw.optional.arm.FEAT_BF16")
|
|
36
|
+
(sysctl-name "hw.optional.arm.FEAT_DotProd")
|
|
37
|
+
(sysctl-name "hw.optional.arm.FEAT_FCMA")
|
|
38
|
+
(sysctl-name "hw.optional.arm.FEAT_FHM")
|
|
39
|
+
(sysctl-name "hw.optional.arm.FEAT_FP16")
|
|
40
|
+
(sysctl-name "hw.optional.arm.FEAT_I8MM")
|
|
41
|
+
(sysctl-name "hw.optional.arm.FEAT_JSCVT")
|
|
42
|
+
(sysctl-name "hw.optional.arm.FEAT_LSE")
|
|
43
|
+
(sysctl-name "hw.optional.arm.FEAT_RDM")
|
|
44
|
+
(sysctl-name "hw.optional.arm.FEAT_SHA512")
|
|
45
|
+
(sysctl-name "hw.optional.armv8_2_sha512")
|
|
46
|
+
(sysctl-name "hw.packages")
|
|
47
|
+
(sysctl-name "hw.pagesize_compat")
|
|
48
|
+
(sysctl-name "hw.physicalcpu_max")
|
|
49
|
+
(sysctl-name "hw.tbfrequency_compat")
|
|
50
|
+
(sysctl-name "hw.vectorunit")
|
|
51
|
+
(sysctl-name "kern.hostname")
|
|
52
|
+
(sysctl-name "kern.maxfilesperproc")
|
|
53
|
+
(sysctl-name "kern.osproductversion")
|
|
54
|
+
(sysctl-name "kern.osrelease")
|
|
55
|
+
(sysctl-name "kern.ostype")
|
|
56
|
+
(sysctl-name "kern.osvariant_status")
|
|
57
|
+
(sysctl-name "kern.osversion")
|
|
58
|
+
(sysctl-name "kern.secure_kernel")
|
|
59
|
+
(sysctl-name "kern.usrstack64")
|
|
60
|
+
(sysctl-name "kern.version")
|
|
61
|
+
(sysctl-name "sysctl.proc_cputype")
|
|
62
|
+
(sysctl-name-prefix "hw.perflevel")
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
;; allow writes to specific paths
|
|
66
|
+
(allow file-write*
|
|
67
|
+
(subpath (param "TARGET_DIR"))
|
|
68
|
+
(subpath (param "TMP_DIR"))
|
|
69
|
+
(subpath (param "CACHE_DIR"))
|
|
70
|
+
(subpath (string-append (param "HOME_DIR") "/.papert"))
|
|
71
|
+
(subpath (string-append (param "HOME_DIR") "/.npm"))
|
|
72
|
+
(subpath (string-append (param "HOME_DIR") "/.cache"))
|
|
73
|
+
(subpath (string-append (param "HOME_DIR") "/.gitconfig"))
|
|
74
|
+
;; Allow writes to included directories from --include-directories
|
|
75
|
+
(subpath (param "INCLUDE_DIR_0"))
|
|
76
|
+
(subpath (param "INCLUDE_DIR_1"))
|
|
77
|
+
(subpath (param "INCLUDE_DIR_2"))
|
|
78
|
+
(subpath (param "INCLUDE_DIR_3"))
|
|
79
|
+
(subpath (param "INCLUDE_DIR_4"))
|
|
80
|
+
(literal "/dev/stdout")
|
|
81
|
+
(literal "/dev/stderr")
|
|
82
|
+
(literal "/dev/null")
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
;; allow communication with sysmond for process listing (e.g. for pgrep)
|
|
86
|
+
(allow mach-lookup (global-name "com.apple.sysmond"))
|
|
87
|
+
|
|
88
|
+
;; enable terminal access required by ink
|
|
89
|
+
;; fixes setRawMode EPERM failure (at node:tty:81:24)
|
|
90
|
+
(allow file-ioctl (regex #"^/dev/tty.*"))
|
|
91
|
+
|
|
92
|
+
;; allow inbound network traffic on debugger port
|
|
93
|
+
(allow network-inbound (local ip "localhost:9229"))
|
|
94
|
+
|
|
95
|
+
;; allow outbound network traffic through proxy on localhost:8877
|
|
96
|
+
;; set `GEMINI_SANDBOX_PROXY_COMMAND=<command>` to run proxy alongside sandbox
|
|
97
|
+
;; proxy must listen on :::8877 (see docs/examples/proxy-script.md)
|
|
98
|
+
(allow network-outbound (remote tcp "localhost:8877"))
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SDKMessage } from './types/protocol.js';
|
|
2
|
+
import type { QueryOptions } from './types/types.js';
|
|
3
|
+
import type { Query } from './query/Query.js';
|
|
4
|
+
export interface CreateSessionOptions {
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
options?: QueryOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare class PapertClient {
|
|
9
|
+
private readonly options;
|
|
10
|
+
private readonly sessions;
|
|
11
|
+
constructor(options?: QueryOptions);
|
|
12
|
+
createSession({ sessionId, options, }?: CreateSessionOptions): PapertClientSession;
|
|
13
|
+
getSession(sessionId: string): PapertClientSession | undefined;
|
|
14
|
+
getDefaultOptions(): QueryOptions;
|
|
15
|
+
unregisterSession(sessionId: string): void;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare class PapertClientSession {
|
|
19
|
+
private readonly sessionId;
|
|
20
|
+
private readonly client;
|
|
21
|
+
private readonly options;
|
|
22
|
+
private readonly activeQueries;
|
|
23
|
+
private closed;
|
|
24
|
+
constructor(sessionId: string, client: PapertClient, options?: QueryOptions);
|
|
25
|
+
getSessionId(): string;
|
|
26
|
+
isClosed(): boolean;
|
|
27
|
+
stream(prompt: string, options?: QueryOptions): Query;
|
|
28
|
+
send(prompt: string, options?: QueryOptions): Promise<SDKMessage[]>;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
private createPromptStream;
|
|
31
|
+
}
|
|
32
|
+
export declare function createClient(options?: QueryOptions): PapertClient;
|