grokbox 0.0.1 → 0.1.0-alpha.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 grokbox contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,34 +1,235 @@
1
1
  # grokbox
2
2
 
3
- Unofficial local CLI for inspecting and messaging a running Grok Bot host.
4
- It is not affiliated with or endorsed by Anysphere, Cursor, or xAI.
3
+ [English](./README.md) | [中文](./README.zh-CN.md)
5
4
 
6
- ## Requirements
5
+ Unofficial CLI and control plane for operating Grok Bot cloud computers from
6
+ inside or outside the box. The canonical command is `grokbox`; `gbox` is an
7
+ exact alias.
7
8
 
8
- - Bun 1.3 or newer
9
- - A reachable Grok Bot host on the same machine or network
9
+ This project is not affiliated with or endorsed by Anysphere, Cursor, xAI, or
10
+ Grok Bot. Grok Bot, Cursor, and related names identify compatible products and
11
+ remain the property of their respective owners.
12
+
13
+ > **Alpha:** current source is `0.1.0-alpha.5` and has not been published yet.
14
+ > npm's `next` dist-tag currently points to `0.1.0-alpha.0`; `0.0.1` is an
15
+ > earlier unsupported snapshot. `v0.1.0-alpha.1` through `v0.1.0-alpha.4` exist
16
+ > as Git tags only. Prereleases publish only after release checks and explicitly
17
+ > scoped external acceptance.
18
+
19
+ ## What it does
20
+
21
+ ```text
22
+ Profile -> local daemon -> local Grok Bot Gateway
23
+ -> remote daemon over private Tailscale Serve
24
+ -> explicit direct-local or Gateway compatibility path
25
+ -> explicit Cursor Sandbox or quota compatibility adapter
26
+ ```
27
+
28
+ Implemented command families:
29
+
30
+ ```text
31
+ init skills profile daemon doctor recover box quota
32
+ agents groups send history memory events is
33
+ fs exec jobs desktop
34
+ ```
35
+
36
+ Highlights:
37
+
38
+ - strict local and remote Profiles with separate credential authorities;
39
+ - finite Unix-socket/loopback daemon and private Tailscale Serve mapping;
40
+ - agent/group management, send, transcript, Memory, and bounded events;
41
+ - named-root governed file reads and mutations;
42
+ - literal structured execution with durable Jobs and bounded logs;
43
+ - layered read-only diagnosis and explicit recovery;
44
+ - opt-in Sandbox lifecycle, quota, and desktop compatibility adapters.
45
+
46
+ The daemon does not provide a generic raw RPC or shell. Gateway-only Profiles
47
+ never gain host filesystem or process authority.
48
+
49
+ ## Prerequisites and platform support
50
+
51
+ - Node.js 20+ for the published-style CLI runtime.
52
+ - Bun 1.3.14 for source development and the pre-release source shim.
53
+ - An existing Grok Bot cloud computer that you own or are authorized to use.
54
+ - Tailscale plus BatchMode SSH for remote bootstrap/recovery; bootstrap also
55
+ needs npm or Bun locally to repack the installed runtime for transfer.
56
+
57
+ | Role | Supported or tested |
58
+ | --- | --- |
59
+ | Source development | Linux and macOS |
60
+ | Node CLI | Linux and macOS |
61
+ | Box daemon, files, Jobs, desktop | Linux |
62
+ | Keychain secret references | macOS |
63
+ | Windows | Not currently supported or tested |
64
+
65
+ ## Five-minute source quick start
66
+
67
+ ```bash
68
+ git clone https://github.com/yoyooyooo/grokbox.git
69
+ cd grokbox
70
+ bun install --frozen-lockfile
71
+ bun run typecheck
72
+ bun run grokbox -- --help
73
+ bun run grokbox -- doctor
74
+ ```
75
+
76
+ `doctor` is read-only. It reports each configured boundary separately and does
77
+ not wake a Sandbox, alter Tailscale Serve, start a daemon, or rotate a
78
+ credential.
79
+
80
+ Inside a running Grok Bot box, the no-file `default` Profile discovers the
81
+ loopback Gateway from `/home/box/sand-data/gateway.json`. If no local Gateway or
82
+ configured Profile is available, commands fail closed.
10
83
 
11
84
  ## Install
12
85
 
13
86
  ```bash
14
- bun add --global grokbox
15
- grok-bot --help
87
+ npm install --global grokbox@next
88
+ grokbox --version
89
+ gbox --help
90
+ ```
91
+
92
+ Node.js 20 or newer is required. Bun is not required by the published package.
93
+
94
+ ## Source-backed global shim
95
+
96
+ To test an unpublished checkout, install `grokbox` and `gbox` into
97
+ `~/.local/bin` while executing its TypeScript entry directly through Bun:
98
+
99
+ ```bash
100
+ bun run shim:install
101
+ grokbox --version
102
+ gbox --help
103
+ grokbox doctor
16
104
  ```
17
105
 
18
- For a one-off run:
106
+ The installer is idempotent, writes both aliases atomically, refuses to replace
107
+ an unrelated command, and verifies each installed command from outside the
108
+ repository. It records the absolute checkout and Bun paths, so rerun it after
109
+ moving the repository or Bun executable. This is a local-real source harness;
110
+ it does not replace the separate Node tarball verification.
111
+
112
+ ## Remote initialization
113
+
114
+ Start with discovery and diagnosis. Bootstrap is an explicit privileged step:
19
115
 
20
116
  ```bash
21
- bunx grokbox --help
117
+ grokbox init remote --peer <tailnet-peer>
118
+ grokbox doctor --profile remote
119
+
120
+ # Installs/replaces the grokbox daemon, rotates its credential, and applies only
121
+ # the recorded private Serve mapping. Requires BatchMode SSH and confirmation.
122
+ grokbox init remote --peer <tailnet-peer> --bootstrap --yes
22
123
  ```
23
124
 
24
- ## Common commands
125
+ Home reads are a separate authority transition and are never implied by
126
+ bootstrap:
25
127
 
26
128
  ```bash
27
- grok-bot doctor
28
- grok-bot agents list
29
- grok-bot send <agent> "status only"
30
- grok-bot history tail <agent>
31
- grok-bot skills list
129
+ grokbox init remote --peer <tailnet-peer> --bootstrap --admit-home-read --yes
32
130
  ```
33
131
 
34
- Run `grok-bot --help` or `grok-bot <command> --help` for the complete command reference.
132
+ Review the named filesystem roots and process allowlist before enabling host
133
+ capabilities.
134
+
135
+ ## Common safe probes
136
+
137
+ ```bash
138
+ grokbox profile list --table
139
+ grokbox doctor
140
+ grokbox daemon status
141
+ grokbox agents list --table
142
+ grokbox groups list --table
143
+ grokbox history tail <target> --limit 20
144
+ grokbox memory list <agent>
145
+ grokbox fs stat workspace:/artifact.txt
146
+ grokbox jobs list --table
147
+ grokbox desktop status --table
148
+ ```
149
+
150
+ Mutating commands require explicit capability and, where destructive, explicit
151
+ confirmation. `desktop prune run` defaults to dry-run; `--yes` invokes the
152
+ upstream stop-window path and deletes that fork's Chrome profile.
153
+
154
+ ## Credentials
155
+
156
+ Never pass Gateway, daemon, Sandbox, quota, SSH, or tailnet credentials on
157
+ argv, in issues, fixtures, snapshots, or ordinary logs.
158
+
159
+ Secret references are purpose-specific:
160
+
161
+ ```text
162
+ env:<NAME>
163
+ file:<absolute-path>
164
+ keychain:<service>/<account>
165
+ ```
166
+
167
+ A `file:` reference must resolve to a regular file owned by the current POSIX
168
+ user with no group or other permission bits; symbolic links are rejected.
169
+ Profiles never store inline tokens. Gateway, daemon, Sandbox, and quota
170
+ credentials are separate capabilities and are never substituted for one
171
+ another.
172
+
173
+ ## Experimental compatibility surfaces
174
+
175
+ Grok Bot Gateway methods, Cursor Sandbox RPCs, the Cursor web quota endpoint,
176
+ and Grok Bot desktop layout are not documented upstream public APIs. Their
177
+ implementation may break without notice and does not imply provider
178
+ endorsement or authorization.
179
+
180
+ In particular:
181
+
182
+ - official Cursor OAuth has been observed to read Sandbox state but receive 401
183
+ from `EnsureSandBox`;
184
+ - App-free wake and 24–72 hour keeper behavior are not stable claims;
185
+ - quota requires an explicit independent source and has source-local account
186
+ binding;
187
+ - desktop prune is Linux/layout-specific and destructive when confirmed.
188
+
189
+ See [Compatibility and upstream boundary](docs/compatibility.md) before using
190
+ these surfaces. Users are responsible for the terms and policies applying to
191
+ their accounts and environments.
192
+
193
+ ## Development and verification
194
+
195
+ ```bash
196
+ bun install --frozen-lockfile
197
+ bun run check
198
+ ```
199
+
200
+ The package test builds and packs locally, installs into an isolated system
201
+ Trash fixture, verifies both aliases under Node, checks the exact package
202
+ allowlist, and confirms project and third-party licenses are present. The
203
+ release-candidate workflow builds a downloadable artifact only. Exact version
204
+ tags publish through the separate OIDC Trusted Publishing workflow with npm
205
+ provenance; prereleases use `next`, stable versions use `latest`, and a GitHub
206
+ Release is created only after registry readback succeeds. See the
207
+ [release runbook](docs/maintainers/release.md); local release commands only
208
+ precheck and push an immutable tag, never publish from the maintainer machine.
209
+
210
+ Real external validation is intentionally separate and requires explicitly
211
+ injected authorized targets. Set `GROKBOX_EXTERNAL_PACKAGE` to an exact registry
212
+ version to test what users install rather than a locally packed tarball.
213
+ Fake-provider or local results do not prove provider authorization, long-lived
214
+ lease behavior, or destructive recovery.
215
+
216
+ ## Documentation
217
+
218
+ - [Documentation map](https://github.com/yoyooyooo/grokbox/blob/main/docs/README.md)
219
+ - [Product contract](https://github.com/yoyooyooo/grokbox/blob/main/docs/product-contract.md)
220
+ - [Architecture](https://github.com/yoyooyooo/grokbox/blob/main/docs/architecture.md)
221
+ - [Compatibility boundary](https://github.com/yoyooyooo/grokbox/blob/main/docs/compatibility.md)
222
+ - [Upstream integration facts](https://github.com/yoyooyooo/grokbox/blob/main/docs/upstream-integration.md)
223
+ - [Security policy](SECURITY.md)
224
+ - [Support](SUPPORT.md)
225
+ - [Contributing](CONTRIBUTING.md)
226
+ - [Changelog](CHANGELOG.md)
227
+
228
+ Current behavior is owned by source and executable tests. Product and
229
+ architecture documents may describe accepted targets; roadmap entries and
230
+ GitHub issues do not prove delivery.
231
+
232
+ ## License
233
+
234
+ MIT. See [`LICENSE`](LICENSE). The published bundle's third-party attributions
235
+ are in [`THIRD_PARTY_NOTICES`](THIRD_PARTY_NOTICES).
@@ -0,0 +1,187 @@
1
+ # grokbox
2
+
3
+ [English](./README.md) | [中文](./README.zh-CN.md)
4
+
5
+ `grokbox` 是一个非官方 CLI 与控制面,用于从 Grok Bot 云电脑内部或外部进行操作。规范命令是 `grokbox`,`gbox` 是完全等价的别名。
6
+
7
+ 本项目与 Anysphere、Cursor、xAI 或 Grok Bot 没有隶属或背书关系。Grok Bot、Cursor 及相关名称仅用于标识兼容产品,其权利归各自所有者。
8
+
9
+ > **Alpha:** 当前源码版本是 `0.1.0-alpha.5`,尚未发布。npm 的 `next` dist-tag 目前指向 `0.1.0-alpha.0`;`0.0.1` 是更早且不再支持的快照。`v0.1.0-alpha.1` 到 `v0.1.0-alpha.4` 只存在于 Git tag。只有通过发布检查及明确范围的外部验收后,才会发布新的预发布版本。
10
+
11
+ ## 它能做什么
12
+
13
+ ```text
14
+ Profile -> 本机 daemon -> 本机 Grok Bot Gateway
15
+ -> 通过私有 Tailscale Serve 连接远端 daemon
16
+ -> 显式 direct-local 或 Gateway 兼容路径
17
+ -> 显式 Cursor Sandbox 或 quota 兼容适配器
18
+ ```
19
+
20
+ 已实现的命令族:
21
+
22
+ ```text
23
+ init skills profile daemon doctor recover box quota
24
+ agents groups send history memory events is
25
+ fs exec jobs desktop
26
+ ```
27
+
28
+ 主要能力:
29
+
30
+ - 严格区分本机与远端 Profile,并分离不同凭据权威;
31
+ - 有限的 Unix socket/loopback daemon 与私有 Tailscale Serve 映射;
32
+ - Agent/Group 管理、消息发送、Transcript、Memory 和有界事件读取;
33
+ - 通过命名根目录治理文件读取与变更;
34
+ - 字面量结构化执行、持久 Job 和有界日志;
35
+ - 分层只读诊断与显式恢复;
36
+ - 可选的 Sandbox 生命周期、quota 与桌面兼容适配器。
37
+
38
+ Daemon 不提供通用 raw RPC 或任意 shell。仅有 Gateway 权限的 Profile 不会获得 host 文件系统或进程权限。
39
+
40
+ ## 前置条件与平台支持
41
+
42
+ - 发布版 CLI 运行时需要 Node.js 20+。
43
+ - 源码开发与发布前源码 shim 需要 Bun 1.3.14。
44
+ - 需要一个你拥有或获准使用的 Grok Bot 云电脑。
45
+ - 远程 bootstrap/recovery 需要 Tailscale 与 BatchMode SSH;bootstrap 还需要本机 npm 或 Bun,以便重新打包已安装运行时并传输。
46
+
47
+ | 角色 | 支持或已测试平台 |
48
+ | --- | --- |
49
+ | 源码开发 | Linux 与 macOS |
50
+ | Node CLI | Linux 与 macOS |
51
+ | Box daemon、文件、Jobs、desktop | Linux |
52
+ | Keychain secret reference | macOS |
53
+ | Windows | 当前不支持,也未测试 |
54
+
55
+ ## 五分钟源码快速开始
56
+
57
+ ```bash
58
+ git clone https://github.com/yoyooyooo/grokbox.git
59
+ cd grokbox
60
+ bun install --frozen-lockfile
61
+ bun run typecheck
62
+ bun run grokbox -- --help
63
+ bun run grokbox -- doctor
64
+ ```
65
+
66
+ `doctor` 是只读命令。它会分别报告各项边界,不会唤醒 Sandbox、修改 Tailscale Serve、启动 daemon 或轮换凭据。
67
+
68
+ 在运行中的 Grok Bot box 内,没有 Profile 文件时,`default` Profile 会从 `/home/box/sand-data/gateway.json` 发现 loopback Gateway。若既没有本机 Gateway,也没有已配置 Profile,命令会安全失败。
69
+
70
+ ## 安装
71
+
72
+ ```bash
73
+ npm install --global grokbox@next
74
+ grokbox --version
75
+ gbox --help
76
+ ```
77
+
78
+ 需要 Node.js 20 或更高版本。发布后的 package 不需要 Bun。
79
+
80
+ ## 源码驱动的全局 shim
81
+
82
+ 若要验证尚未发布的 checkout,可把 `grokbox` 和 `gbox` 安装到 `~/.local/bin`,并让它们通过 Bun 直接执行 TypeScript 入口:
83
+
84
+ ```bash
85
+ bun run shim:install
86
+ grokbox --version
87
+ gbox --help
88
+ grokbox doctor
89
+ ```
90
+
91
+ 安装器可幂等运行,以原子方式写入两个别名,拒绝覆盖无关命令,并从仓库外验证每个命令。它记录 checkout 与 Bun 的绝对路径,因此仓库或 Bun 可执行文件移动后需要重新运行。该路径用于验证本机真实源码,不替代 Node tarball 验证。
92
+
93
+ ## 远程初始化
94
+
95
+ 先发现和诊断,再显式执行特权 bootstrap:
96
+
97
+ ```bash
98
+ grokbox init remote --peer <tailnet-peer>
99
+ grokbox doctor --profile remote
100
+
101
+ # 安装或替换 grokbox daemon、轮换 daemon 凭据,并且只应用被记录的
102
+ # 私有 Serve 映射。需要 BatchMode SSH 与明确确认。
103
+ grokbox init remote --peer <tailnet-peer> --bootstrap --yes
104
+ ```
105
+
106
+ 读取 home 是单独的权限变化,不会由 bootstrap 隐式开启:
107
+
108
+ ```bash
109
+ grokbox init remote --peer <tailnet-peer> --bootstrap --admit-home-read --yes
110
+ ```
111
+
112
+ 启用 host 能力前,请审阅命名文件系统根目录和进程 allowlist。
113
+
114
+ ## 常用安全探针
115
+
116
+ ```bash
117
+ grokbox profile list --table
118
+ grokbox doctor
119
+ grokbox daemon status
120
+ grokbox agents list --table
121
+ grokbox groups list --table
122
+ grokbox history tail <target> --limit 20
123
+ grokbox memory list <agent>
124
+ grokbox fs stat workspace:/artifact.txt
125
+ grokbox jobs list --table
126
+ grokbox desktop status --table
127
+ ```
128
+
129
+ 变更命令需要显式 capability;破坏性操作还需要显式确认。`desktop prune run` 默认 dry-run;传入 `--yes` 后会调用上游 stop-window 路径,并删除该 fork 的 Chrome profile。
130
+
131
+ ## 凭据
132
+
133
+ 不要把 Gateway、daemon、Sandbox、quota、SSH 或 tailnet 凭据放进 argv、Issue、fixture、snapshot 或普通日志。
134
+
135
+ Secret reference 按用途区分:
136
+
137
+ ```text
138
+ env:<NAME>
139
+ file:<absolute-path>
140
+ keychain:<service>/<account>
141
+ ```
142
+
143
+ `file:` 必须指向当前 POSIX 用户拥有、group/other 无权限位的普通文件;拒绝符号链接。Profile 不保存 inline token。Gateway、daemon、Sandbox 与 quota 凭据是分离的 capability,不能互相替代。
144
+
145
+ ## 实验性兼容表面
146
+
147
+ Grok Bot Gateway method、Cursor Sandbox RPC、Cursor Web quota endpoint 和 Grok Bot desktop 布局都不是上游公开 API,可能无预警失效,也不表示 provider 背书或授权。
148
+
149
+ 尤其需要注意:
150
+
151
+ - 已观察到官方 Cursor OAuth 可读取 Sandbox 状态,但调用 `EnsureSandBox` 会收到 401;
152
+ - 无 App 唤醒及 24–72 小时 keeper 行为不是稳定承诺;
153
+ - quota 需要显式独立来源,并受来源本地账号绑定;
154
+ - desktop prune 依赖 Linux/布局,确认执行时具有破坏性。
155
+
156
+ 使用这些表面前,请阅读[兼容性与上游边界](docs/compatibility.md)。用户需要自行遵守其账号和环境适用的条款与政策。
157
+
158
+ ## 开发与验证
159
+
160
+ ```bash
161
+ bun install --frozen-lockfile
162
+ bun run check
163
+ ```
164
+
165
+ Package 测试会在本机构建和打包,把产物安装到隔离的系统 Trash fixture,用 Node 验证两个别名,核对精确 package allowlist,并确认项目与第三方许可证存在。`Release candidate artifact` workflow 只生成可下载产物,不会发布。
166
+
167
+ 只有精确版本 tag 才会触发独立的 OIDC Trusted Publishing workflow:预发布版本进入 npm `next`,稳定版本进入 `latest`;registry 版本、channel 与 provenance 回读成功后才创建 GitHub Release。详见[发布手册](docs/maintainers/release.md)。本机 release 命令只做预检与推送不可变 tag,不会从维护者机器发布 npm。
168
+
169
+ 真实外部验证保持独立,并要求显式注入获授权的目标。设置 `GROKBOX_EXTERNAL_PACKAGE=grokbox@<version>`,可验证用户实际安装的精确 registry 版本,而不是本机 tarball。Fake-provider 或 local-real 结果不能证明 provider 授权、长期 lease 行为或破坏性恢复能力。
170
+
171
+ ## 文档
172
+
173
+ - [文档地图](docs/README.md)
174
+ - [产品契约](docs/product-contract.md)
175
+ - [架构](docs/architecture.md)
176
+ - [兼容性边界](docs/compatibility.md)
177
+ - [上游集成事实](docs/upstream-integration.md)
178
+ - [安全策略](SECURITY.md)
179
+ - [支持](SUPPORT.md)
180
+ - [贡献指南](CONTRIBUTING.md)
181
+ - [变更日志](CHANGELOG.md)
182
+
183
+ 当前行为由源码和可执行测试决定。产品与架构文档可能描述已接受目标;roadmap 和 GitHub Issue 不能证明功能已经交付。
184
+
185
+ ## 许可证
186
+
187
+ MIT,见 [`LICENSE`](LICENSE)。发布包中的第三方归属见 [`THIRD_PARTY_NOTICES`](THIRD_PARTY_NOTICES)。
@@ -0,0 +1,29 @@
1
+ Third-Party Notices
2
+ ===================
3
+
4
+ grokbox's published JavaScript bundle includes the following third-party
5
+ software. This notice is distributed with every grokbox package artifact.
6
+
7
+ Commander.js
8
+ ------------
9
+
10
+ Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining
13
+ a copy of this software and associated documentation files (the
14
+ 'Software'), to deal in the Software without restriction, including
15
+ without limitation the rights to use, copy, modify, merge, publish,
16
+ distribute, sublicense, and/or sell copies of the Software, and to
17
+ permit persons to whom the Software is furnished to do so, subject to
18
+ the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be
21
+ included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/bin/grokbox ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ RUNTIME_UNSUPPORTED_EXIT_CODE,
4
+ runtimeUnsupportedEnvelope,
5
+ supportsNodeRuntime,
6
+ } from "./runtime.js";
7
+
8
+ if (!supportsNodeRuntime(process.versions.node)) {
9
+ process.stderr.write(`${JSON.stringify(runtimeUnsupportedEnvelope(process.versions.node))}\n`);
10
+ process.exitCode = RUNTIME_UNSUPPORTED_EXIT_CODE;
11
+ } else {
12
+ await import("../dist/index.js");
13
+ }
@@ -0,0 +1,13 @@
1
+ export const MINIMUM_NODE_MAJOR: number;
2
+ export const RUNTIME_UNSUPPORTED_EXIT_CODE: number;
3
+ export function nodeMajor(version: unknown): number | null;
4
+ export function supportsNodeRuntime(version: unknown): boolean;
5
+ export function runtimeUnsupportedEnvelope(version: unknown): {
6
+ ok: false;
7
+ error: {
8
+ code: "runtime_unsupported";
9
+ message: string;
10
+ retryable: false;
11
+ runtime: { nodeMajor: number | null; minimumNodeMajor: number };
12
+ };
13
+ };
package/bin/runtime.js ADDED
@@ -0,0 +1,27 @@
1
+ export const MINIMUM_NODE_MAJOR = 20;
2
+ export const RUNTIME_UNSUPPORTED_EXIT_CODE = 59;
3
+
4
+ export function nodeMajor(version) {
5
+ const major = Number.parseInt(String(version).split(".", 1)[0] ?? "", 10);
6
+ return Number.isSafeInteger(major) ? major : null;
7
+ }
8
+
9
+ export function supportsNodeRuntime(version) {
10
+ const major = nodeMajor(version);
11
+ return major !== null && major >= MINIMUM_NODE_MAJOR;
12
+ }
13
+
14
+ export function runtimeUnsupportedEnvelope(version) {
15
+ return {
16
+ ok: false,
17
+ error: {
18
+ code: "runtime_unsupported",
19
+ message: `grokbox requires Node.js ${MINIMUM_NODE_MAJOR} or newer.`,
20
+ retryable: false,
21
+ runtime: {
22
+ nodeMajor: nodeMajor(version),
23
+ minimumNodeMajor: MINIMUM_NODE_MAJOR,
24
+ },
25
+ },
26
+ };
27
+ }