@nimbus-sh/cli 0.1.7 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # @nimbus-sh/cli
2
2
 
3
- CLI for Nimbus: scaffolding, token mint/verify, session helpers, and runtime
4
- cache operations.
3
+ Scaffold a Nimbus Worker, mint and verify tokens, open sessions, and sync the
4
+ runtime cache.
5
5
 
6
6
  ## Install
7
7
 
@@ -24,9 +24,16 @@ bun packages/cli/src/scaffold-bin.ts my-app
24
24
  ### `nimbus init [directory]`
25
25
 
26
26
  Scaffolds a Nimbus-powered Workers project. `.` uses the current directory.
27
+
27
28
  The generated app embeds the interactive Nimbus UI and enables the
28
- authenticated remote sandbox API. Add application-specific auth routes in
29
- `src/index.ts` when you are ready to mint user tokens from your backend.
29
+ authenticated remote sandbox API. Add your own auth routes in `src/index.ts`
30
+ before you mint user tokens from the backend.
31
+
32
+ The app also carries the session agent UI. To configure Cloudflare OAuth and
33
+ Workers AI, add the non-secret `NIMBUS_CF_OAUTH_CLIENT_ID`,
34
+ `NIMBUS_CF_OAUTH_SCOPES`, `NIMBUS_AGENT_MODEL`, and
35
+ `NIMBUS_AGENT_GATEWAY_ID` vars. Then store `NIMBUS_AGENT_COOKIE_SECRET` with
36
+ `wrangler secret put`.
30
37
 
31
38
  ```bash
32
39
  nimbus init my-nimbus
@@ -111,9 +118,8 @@ Exit codes: 0 success, 65 token-validation failure, 78 env missing.
111
118
 
112
119
  ### `nimbus runtime sync`
113
120
 
114
- Uploads runtime blobs/manifests and updates the runtime catalog through the
115
- public CLI wrapper. This is the user-facing path for Python, Ruby, and clang
116
- runtime cache operations.
121
+ Uploads runtime blobs and manifests, then updates the runtime catalog. This
122
+ is the user-facing path for the Python, Ruby, and clang runtime caches.
117
123
 
118
124
  ```bash
119
125
  CLOUDFLARE_ACCOUNT_ID=<id> nimbus runtime sync --bucket nimbus-runtime-cache-public clang
@@ -139,6 +145,21 @@ NIMBUS_ENDPOINT=https://my-nimbus.workers.dev nimbus session new
139
145
  # {"sessionId":"pretty-otter-1234","url":"https://.../s/pretty-otter-1234/"}
140
146
  ```
141
147
 
148
+ Authenticated deployments can pass a token with `--token` or `NIMBUS_TOKEN`:
149
+
150
+ ```bash
151
+ NIMBUS_ENDPOINT=https://my-nimbus.workers.dev \
152
+ NIMBUS_TOKEN=<jwt-with-session-create> \
153
+ nimbus session new
154
+ ```
155
+
156
+ The token is sent only as an `Authorization: Bearer` header. It never
157
+ appears in any URL. The printed attach URL is the server's redirect Location
158
+ verbatim. On enforced deployments that URL carries a short-lived (90 s),
159
+ single-use bootstrap token pinned to the new session. Opening it once sets
160
+ the session cookie and redirects to the clean `/s/<id>/` URL. Reusing it
161
+ returns 401.
162
+
142
163
  ## Programmatic use
143
164
 
144
165
  Every verb is also exported as a function:
@@ -147,8 +168,8 @@ Every verb is also exported as a function:
147
168
  import { mintToken, syncRuntimes, scaffold } from '@nimbus-sh/cli';
148
169
  ```
149
170
 
150
- `mintToken(argv)` and friends return a Promise<number> (process exit
151
- code). Stdout / stderr write directly via `process.stdout`/`process.stderr`.
171
+ `mintToken(argv)` and its siblings return a Promise<number>, the process exit
172
+ code. They write to `process.stdout` and `process.stderr` directly.
152
173
 
153
174
  ## Engines
154
175
 
package/dist/bin.js CHANGED
@@ -67,7 +67,7 @@ Usage:
67
67
  nimbus token verify <token>
68
68
  nimbus runtime sync [--bucket <name>] [runtime[@version]...]
69
69
  nimbus runtime list
70
- nimbus session new [--endpoint <url>]
70
+ nimbus session new [--endpoint <url>] [--token <jwt>]
71
71
  nimbus setup cloudflare --name <worker-name>
72
72
  nimbus init [directory]
73
73
 
@@ -77,6 +77,7 @@ For embedder scaffolding:
77
77
  Env:
78
78
  JWT_SECRET Shared secret for HS256 (required for token mint/verify).
79
79
  NIMBUS_ENDPOINT Base URL for session new. Defaults to localhost:8787.
80
+ NIMBUS_TOKEN Bearer token for authenticated session new.
80
81
  CLOUDFLARE_ACCOUNT_ID Required for runtime sync.
81
82
  `);
82
83
  }
@@ -125,9 +125,9 @@ function renderPackageJson(name) {
125
125
  typecheck: 'tsc --noEmit',
126
126
  },
127
127
  dependencies: {
128
- '@nimbus-sh/config': '^0.1.3',
129
- '@nimbus-sh/worker': '^0.1.4',
130
- '@nimbus-sh/sdk': '^0.1.4',
128
+ '@nimbus-sh/config': '^0.1.4',
129
+ '@nimbus-sh/worker': '^0.2.0',
130
+ '@nimbus-sh/sdk': '^0.2.0',
131
131
  },
132
132
  devDependencies: {
133
133
  '@cloudflare/workers-types': '^4.20250327.0',
@@ -144,6 +144,10 @@ function renderWranglerJsonc(name) {
144
144
  "compatibility_date": "2026-04-01",
145
145
  "compatibility_flags": ["nodejs_compat"],
146
146
  "placement": { "mode": "smart" },
147
+ "vars": {
148
+ "NIMBUS_AGENT_MODEL": "@cf/moonshotai/kimi-k2.6",
149
+ "NIMBUS_AGENT_GATEWAY_ID": "default"
150
+ },
147
151
 
148
152
  "assets": {
149
153
  "directory": "node_modules/@nimbus-sh/worker/public",
@@ -155,7 +159,6 @@ function renderWranglerJsonc(name) {
155
159
  // not omit any of these — \`git clone\` will fail at runtime if any
156
160
  // are missing.
157
161
  "alias": {
158
- "@lifo-sh/ui": "./node_modules/@nimbus-sh/worker/dist/stubs/lifo-ui.js",
159
162
  "clean-git-ref": "clean-git-ref/lib/index.js",
160
163
  "is-git-ref-name-valid": "is-git-ref-name-valid/index.js",
161
164
  "crc-32": "crc-32",
@@ -171,10 +174,14 @@ function renderWranglerJsonc(name) {
171
174
  },
172
175
 
173
176
  "durable_objects": {
174
- "bindings": [{ "name": "NIMBUS_SESSION", "class_name": "NimbusSession" }]
177
+ "bindings": [
178
+ { "name": "NIMBUS_SESSION", "class_name": "NimbusSession" },
179
+ { "name": "NIMBUS_PUBLIC_DIRECTORY", "class_name": "NimbusPublicDirectory" }
180
+ ]
175
181
  },
176
182
  "migrations": [
177
- { "tag": "nimbus-v1", "new_sqlite_classes": ["NimbusSession"] }
183
+ { "tag": "nimbus-v1", "new_sqlite_classes": ["NimbusSession"] },
184
+ { "tag": "nimbus-v2", "new_sqlite_classes": ["NimbusPublicDirectory"] }
178
185
  ],
179
186
 
180
187
  "worker_loaders": [{ "binding": "LOADER" }],
@@ -207,6 +214,7 @@ import { defineNimbusConfig } from '@nimbus-sh/config';
207
214
  // auto-populate loopback bindings (env.SUPERVISOR, etc.).
208
215
  export {
209
216
  NimbusSession,
217
+ NimbusPublicDirectory,
210
218
  SupervisorRPC,
211
219
  NimbusAssetsRPC,
212
220
  NimbusLoaderRPC,
@@ -273,6 +281,48 @@ Then visit the URL wrangler prints.
273
281
  If setup reports Cloudflare R2 error 10042, enable R2 in the Cloudflare
274
282
  Dashboard once for this account, then rerun the setup command.
275
283
 
284
+ ## Session Agent
285
+
286
+ The session UI includes an Agent surface inside the editor workspace. It can
287
+ use the same sandbox tools as the terminal: shell exec, files, runtime
288
+ installs, processes, logs, and preview ports.
289
+
290
+ For user-owned Cloudflare Workers AI quota, create a Cloudflare OAuth client:
291
+
292
+ - Client Name: Nimbus Agent
293
+ - Response Type: Code
294
+ - Grant type: Authorization Code
295
+ - Token Authentication Method: None
296
+
297
+ Use this redirect URL:
298
+
299
+ \`\`\`
300
+ https://${wranglerName}.your-account.workers.dev/api/nimbus/oauth/callback
301
+ \`\`\`
302
+
303
+ Set the non-secret values in \`wrangler.jsonc\`:
304
+
305
+ \`\`\`jsonc
306
+ "vars": {
307
+ "NIMBUS_CF_OAUTH_CLIENT_ID": "<oauth-client-id>",
308
+ "NIMBUS_CF_OAUTH_SCOPES": "<scope-id-1> <scope-id-2>",
309
+ "NIMBUS_AGENT_MODEL": "@cf/moonshotai/kimi-k2.6",
310
+ "NIMBUS_AGENT_GATEWAY_ID": "default"
311
+ }
312
+ \`\`\`
313
+
314
+ Then store a 32+ character cookie encryption secret. Nimbus uses this to keep
315
+ Cloudflare OAuth tokens in encrypted HttpOnly browser cookies instead of
316
+ Durable Object storage:
317
+
318
+ \`\`\`bash
319
+ npx wrangler secret put NIMBUS_AGENT_COOKIE_SECRET
320
+ \`\`\`
321
+
322
+ For owner-token fallback, set \`NIMBUS_CLOUDFLARE_ACCOUNT_ID\` in
323
+ \`wrangler.jsonc\` and store \`NIMBUS_CLOUDFLARE_API_TOKEN\` with
324
+ \`wrangler secret put\`.
325
+
276
326
  ## Tokens
277
327
 
278
328
  By default tokens are enforced because \`JWT_SECRET\` is set. Mint a token for
@@ -1,5 +1,11 @@
1
1
  /**
2
2
  * cli/commands/session — `nimbus session new` — mint a session via POST /new.
3
+ *
4
+ * `--token` / `NIMBUS_TOKEN` travels ONLY as `Authorization: Bearer`.
5
+ * The printed attach URL is the server's redirect Location verbatim: on
6
+ * enforced deployments it carries a short-lived single-use bootstrap
7
+ * token (never the caller's long-lived token); on unauthenticated
8
+ * deployments it is the plain `/s/<id>/` URL.
3
9
  */
4
10
  /** Mint a fresh session and print its attach URL. */
5
11
  export declare function newSession(args: string[]): Promise<number>;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qDAAqD;AACrD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BhE"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qDAAqD;AACrD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BhE"}
@@ -1,5 +1,11 @@
1
1
  /**
2
2
  * cli/commands/session — `nimbus session new` — mint a session via POST /new.
3
+ *
4
+ * `--token` / `NIMBUS_TOKEN` travels ONLY as `Authorization: Bearer`.
5
+ * The printed attach URL is the server's redirect Location verbatim: on
6
+ * enforced deployments it carries a short-lived single-use bootstrap
7
+ * token (never the caller's long-lived token); on unauthenticated
8
+ * deployments it is the plain `/s/<id>/` URL.
3
9
  */
4
10
  /** Mint a fresh session and print its attach URL. */
5
11
  export async function newSession(args) {
@@ -7,11 +13,13 @@ export async function newSession(args) {
7
13
  const endpoint = parsed['--endpoint']
8
14
  ?? process.env.NIMBUS_ENDPOINT
9
15
  ?? 'http://127.0.0.1:8787';
16
+ const token = parsed['--token'] ?? process.env.NIMBUS_TOKEN ?? '';
10
17
  try {
11
18
  const baseUrl = new URL(endpoint);
12
19
  const r = await fetch(new URL('/new', baseUrl), {
13
20
  method: 'POST',
14
21
  redirect: 'manual',
22
+ headers: token ? { Authorization: `Bearer ${token}` } : undefined,
15
23
  });
16
24
  const loc = r.headers.get('Location');
17
25
  if (!loc) {
@@ -23,7 +31,7 @@ export async function newSession(args) {
23
31
  process.stderr.write(`nimbus session new: unexpected Location: ${loc}\n`);
24
32
  return 70;
25
33
  }
26
- const url = new URL(`/s/${encodeURIComponent(sessionId)}/`, baseUrl).toString();
34
+ const url = new URL(loc, baseUrl).toString();
27
35
  process.stdout.write(JSON.stringify({ sessionId, url }) + '\n');
28
36
  return 0;
29
37
  }
package/dist/version.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  * `require('./package.json')` because that breaks under bun's
4
4
  * single-file binary mode.
5
5
  */
6
- export declare const CLI_VERSION = "0.1.7";
6
+ export declare const CLI_VERSION = "0.1.8";
7
7
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * `require('./package.json')` because that breaks under bun's
4
4
  * single-file binary mode.
5
5
  */
6
- export const CLI_VERSION = '0.1.7';
6
+ export const CLI_VERSION = '0.1.8';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbus-sh/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
4
4
  "description": "Nimbus CLI — `create-nimbus-app` scaffolder + `token mint` + `runtime sync`.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -41,12 +41,12 @@
41
41
  ],
42
42
  "scripts": {
43
43
  "build": "tsc -p tsconfig.json --noCheck --noEmit false --declaration true --declarationMap true --outDir dist --rootDir src && chmod +x dist/bin.js dist/scaffold-bin.js",
44
- "prepack": "npm run build",
44
+ "prepack": "bun run build",
45
45
  "typecheck": "tsc --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@nimbus-sh/sdk": "^0.1.4",
49
- "@nimbus-sh/worker": "^0.1.4"
48
+ "@nimbus-sh/sdk": "^0.7.0",
49
+ "@nimbus-sh/worker": "^0.8.0"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=20"