@nimbus-sh/cli 0.1.7 → 0.1.8
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 +20 -0
- package/dist/bin.js +2 -1
- package/dist/commands/scaffold.js +49 -4
- package/dist/commands/session.d.ts +6 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +9 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -27,6 +27,11 @@ Scaffolds a Nimbus-powered Workers project. `.` uses the current directory.
|
|
|
27
27
|
The generated app embeds the interactive Nimbus UI and enables the
|
|
28
28
|
authenticated remote sandbox API. Add application-specific auth routes in
|
|
29
29
|
`src/index.ts` when you are ready to mint user tokens from your backend.
|
|
30
|
+
It also includes the session Agent UI. Configure Cloudflare OAuth and Workers
|
|
31
|
+
AI by adding the non-secret `NIMBUS_CF_OAUTH_CLIENT_ID`,
|
|
32
|
+
`NIMBUS_CF_OAUTH_SCOPES`, `NIMBUS_AGENT_MODEL`, and
|
|
33
|
+
`NIMBUS_AGENT_GATEWAY_ID` vars, then store `NIMBUS_AGENT_COOKIE_SECRET`
|
|
34
|
+
with `wrangler secret put`.
|
|
30
35
|
|
|
31
36
|
```bash
|
|
32
37
|
nimbus init my-nimbus
|
|
@@ -139,6 +144,21 @@ NIMBUS_ENDPOINT=https://my-nimbus.workers.dev nimbus session new
|
|
|
139
144
|
# {"sessionId":"pretty-otter-1234","url":"https://.../s/pretty-otter-1234/"}
|
|
140
145
|
```
|
|
141
146
|
|
|
147
|
+
Authenticated deployments can pass a token with `--token` or `NIMBUS_TOKEN`:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
NIMBUS_ENDPOINT=https://my-nimbus.workers.dev \
|
|
151
|
+
NIMBUS_TOKEN=<jwt-with-session-create> \
|
|
152
|
+
nimbus session new
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The token is sent only as an `Authorization: Bearer` header — it never
|
|
156
|
+
appears in any URL. The printed attach URL is the server's redirect
|
|
157
|
+
Location verbatim: on enforced deployments it carries a short-lived
|
|
158
|
+
(90 s), single-use bootstrap token pinned to the new session. Opening it
|
|
159
|
+
once sets the session cookie and redirects to the clean `/s/<id>/` URL;
|
|
160
|
+
reusing it returns 401.
|
|
161
|
+
|
|
142
162
|
## Programmatic use
|
|
143
163
|
|
|
144
164
|
Every verb is also exported as a function:
|
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.
|
|
129
|
-
'@nimbus-sh/worker': '^0.
|
|
130
|
-
'@nimbus-sh/sdk': '^0.
|
|
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",
|
|
@@ -273,6 +276,48 @@ Then visit the URL wrangler prints.
|
|
|
273
276
|
If setup reports Cloudflare R2 error 10042, enable R2 in the Cloudflare
|
|
274
277
|
Dashboard once for this account, then rerun the setup command.
|
|
275
278
|
|
|
279
|
+
## Session Agent
|
|
280
|
+
|
|
281
|
+
The session UI includes an Agent surface inside the editor workspace. It can
|
|
282
|
+
use the same sandbox tools as the terminal: shell exec, files, runtime
|
|
283
|
+
installs, processes, logs, and preview ports.
|
|
284
|
+
|
|
285
|
+
For user-owned Cloudflare Workers AI quota, create a Cloudflare OAuth client:
|
|
286
|
+
|
|
287
|
+
- Client Name: Nimbus Agent
|
|
288
|
+
- Response Type: Code
|
|
289
|
+
- Grant type: Authorization Code
|
|
290
|
+
- Token Authentication Method: None
|
|
291
|
+
|
|
292
|
+
Use this redirect URL:
|
|
293
|
+
|
|
294
|
+
\`\`\`
|
|
295
|
+
https://${wranglerName}.your-account.workers.dev/api/nimbus/oauth/callback
|
|
296
|
+
\`\`\`
|
|
297
|
+
|
|
298
|
+
Set the non-secret values in \`wrangler.jsonc\`:
|
|
299
|
+
|
|
300
|
+
\`\`\`jsonc
|
|
301
|
+
"vars": {
|
|
302
|
+
"NIMBUS_CF_OAUTH_CLIENT_ID": "<oauth-client-id>",
|
|
303
|
+
"NIMBUS_CF_OAUTH_SCOPES": "<scope-id-1> <scope-id-2>",
|
|
304
|
+
"NIMBUS_AGENT_MODEL": "@cf/moonshotai/kimi-k2.6",
|
|
305
|
+
"NIMBUS_AGENT_GATEWAY_ID": "default"
|
|
306
|
+
}
|
|
307
|
+
\`\`\`
|
|
308
|
+
|
|
309
|
+
Then store a 32+ character cookie encryption secret. Nimbus uses this to keep
|
|
310
|
+
Cloudflare OAuth tokens in encrypted HttpOnly browser cookies instead of
|
|
311
|
+
Durable Object storage:
|
|
312
|
+
|
|
313
|
+
\`\`\`bash
|
|
314
|
+
npx wrangler secret put NIMBUS_AGENT_COOKIE_SECRET
|
|
315
|
+
\`\`\`
|
|
316
|
+
|
|
317
|
+
For owner-token fallback, set \`NIMBUS_CLOUDFLARE_ACCOUNT_ID\` in
|
|
318
|
+
\`wrangler.jsonc\` and store \`NIMBUS_CLOUDFLARE_API_TOKEN\` with
|
|
319
|
+
\`wrangler secret put\`.
|
|
320
|
+
|
|
276
321
|
## Tokens
|
|
277
322
|
|
|
278
323
|
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
|
|
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"}
|
package/dist/commands/session.js
CHANGED
|
@@ -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(
|
|
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
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Nimbus CLI — `create-nimbus-app` scaffolder + `token mint` + `runtime sync`.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typecheck": "tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@nimbus-sh/sdk": "^0.
|
|
49
|
-
"@nimbus-sh/worker": "^0.
|
|
48
|
+
"@nimbus-sh/sdk": "^0.2.0",
|
|
49
|
+
"@nimbus-sh/worker": "^0.2.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=20"
|