@redplanethq/corebrain 2.8.32 → 2.8.34
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 +229 -0
- package/dist/commands/gateway/llmproxy.d.ts +17 -0
- package/dist/commands/gateway/llmproxy.d.ts.map +1 -0
- package/dist/commands/gateway/llmproxy.js +312 -0
- package/dist/commands/gateway/llmproxy.js.map +1 -0
- package/dist/server/api/auth.d.ts.map +1 -1
- package/dist/server/api/auth.js +10 -1
- package/dist/server/api/auth.js.map +1 -1
- package/dist/server/api/llmproxy/index.d.ts +3 -0
- package/dist/server/api/llmproxy/index.d.ts.map +1 -0
- package/dist/server/api/llmproxy/index.js +227 -0
- package/dist/server/api/llmproxy/index.js.map +1 -0
- package/dist/server/api/server.d.ts.map +1 -1
- package/dist/server/api/server.js +12 -7
- package/dist/server/api/server.js.map +1 -1
- package/dist/tui/chat.d.ts.map +1 -1
- package/dist/tui/chat.js +19 -55
- package/dist/tui/chat.js.map +1 -1
- package/dist/tui/hooks/use-conversation.d.ts.map +1 -1
- package/dist/tui/hooks/use-conversation.js +3 -22
- package/dist/tui/hooks/use-conversation.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/assets/AppIcon.icns +0 -0
- package/dist/server/api/skills/index.d.ts +0 -9
- package/dist/server/api/skills/index.d.ts.map +0 -1
- package/dist/server/api/skills/index.js +0 -12
- package/dist/server/api/skills/index.js.map +0 -1
- package/dist/server/skills/install.d.ts +0 -35
- package/dist/server/skills/install.d.ts.map +0 -1
- package/dist/server/skills/install.js +0 -182
- package/dist/server/skills/install.js.map +0 -1
- package/dist/server/skills/skill-store.d.ts +0 -12
- package/dist/server/skills/skill-store.d.ts.map +0 -1
- package/dist/server/skills/skill-store.js +0 -76
- package/dist/server/skills/skill-store.js.map +0 -1
- package/dist/server/tools/skills-tools.d.ts +0 -14
- package/dist/server/tools/skills-tools.d.ts.map +0 -1
- package/dist/server/tools/skills-tools.js +0 -100
- package/dist/server/tools/skills-tools.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# @corebrain/cli — Gateway HTTP API
|
|
2
|
+
|
|
3
|
+
The `corebrain gateway start` command launches a local daemon that serves an HTTP + WebSocket API on `0.0.0.0:7787` (default). Every route lives in `src/server/api/`; this document is the authoritative index.
|
|
4
|
+
|
|
5
|
+
## Running a gateway
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
corebrain login # once, per host
|
|
9
|
+
corebrain gateway config # register this host with the control plane
|
|
10
|
+
corebrain gateway start # start as a background service (launchd / systemd)
|
|
11
|
+
corebrain gateway start --foreground # attach to stdout (Docker / Railway)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Port override: `COREBRAIN_GATEWAY_HTTP_PORT=8000` or `preferences.gateway.httpPort`.
|
|
15
|
+
|
|
16
|
+
## Auth
|
|
17
|
+
|
|
18
|
+
Every request needs a bearer token:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Authorization: Bearer <securityKey>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The raw key is set by `corebrain gateway register`; the gateway stores `sha256(key)` and compares in constant time. Two exceptions:
|
|
25
|
+
|
|
26
|
+
- `GET /healthz/public` — no auth.
|
|
27
|
+
- `GET /api/coding/coding_xterm_session` — accepts `?ticket=<hmac>&session_id=<id>` in place of Bearer, for browser-direct WebSocket attaches.
|
|
28
|
+
|
|
29
|
+
Any other request without a valid Bearer returns `401 {ok: false, error: {code: "UNAUTHORIZED", ...}}`.
|
|
30
|
+
|
|
31
|
+
## Response envelope
|
|
32
|
+
|
|
33
|
+
Tool routes (POST `/api/{group}/{tool_name}`) return:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{ "ok": true, "result": <tool-specific> }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
On failure:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "ok": false, "error": { "code": "TOOL_ERROR", "message": "..." } }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The fastify error handler shapes non-tool errors the same way.
|
|
46
|
+
|
|
47
|
+
## Slot toggles
|
|
48
|
+
|
|
49
|
+
The `coding`, `browser`, `exec`, `files` groups are gated by `preferences.gateway.slots.<slot>.enabled`. A disabled slot hides both the manifest entries and the HTTP routes. `utils`, `folders`, `shell` and ops are always on.
|
|
50
|
+
|
|
51
|
+
Env override: `COREBRAIN_SLOT_<SLOT>=false` (e.g. `COREBRAIN_SLOT_EXEC=false`) wins over the on-disk toggle.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Ops (always on)
|
|
56
|
+
|
|
57
|
+
| Method | Path | Description |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| GET | `/manifest` | Full gateway manifest — tools, folders, agents, capabilities. Emits `etag` header. |
|
|
60
|
+
| GET | `/healthz` | Authenticated liveness: `{status, manifestEtag, uptimeSec}`. |
|
|
61
|
+
| GET | `/healthz/public` | Unauthenticated ping: `{status: "ok"}`. |
|
|
62
|
+
| GET | `/verify` | Identity probe: `{ok, gatewayId, hostname, platform}`. Used during registration. |
|
|
63
|
+
|
|
64
|
+
Source: `src/server/api/ops.ts`.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## `/api/coding` (slot: `coding`)
|
|
69
|
+
|
|
70
|
+
Drives coding agents (`claude-code`, `codex-cli`, `opencode`) on registered folders.
|
|
71
|
+
|
|
72
|
+
### Tools
|
|
73
|
+
|
|
74
|
+
Each is `POST /api/coding/<name>` with a JSON body of the tool's params.
|
|
75
|
+
|
|
76
|
+
| Tool | Purpose |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `coding_ask` | Start or continue a session. Body: `{prompt, dir, agent?, sessionId?, model?, systemPrompt?, worktree?, baseBranch?, branch?}`. Poll with `coding_read_session` for output. |
|
|
79
|
+
| `coding_read_session` | Read structured conversation turns + `status` (`initializing` / `working` / `idle` / `ended` / `failed`). Body: `{sessionId}`. |
|
|
80
|
+
| `coding_list_sessions` | List sessions from on-disk agent transcripts. Body: `{agent?, since?, limit?, offset?}`. |
|
|
81
|
+
| `coding_search_sessions` | Search past session titles / first messages. Body: `{query, dir?, limit?}`. |
|
|
82
|
+
| `coding_close_session` | Stop a session. Body: `{sessionId}`. |
|
|
83
|
+
| `coding_close_all` | Stop every running session and clean up worktrees. Body: `{}`. |
|
|
84
|
+
| `coding_list_agents` | Which agents are configured, and which is default. Body: `{}`. |
|
|
85
|
+
|
|
86
|
+
### Interactive PTY
|
|
87
|
+
|
|
88
|
+
- `POST /api/coding/spawn` — spawn or resume an agent's TUI so a WebSocket has a PTY to attach to. Body: `{agent, dir, sessionId?}`. Returns `{sessionId, pid, status: "new"|"reconnect"|"resumed"}`. Webapp-only primitive; LLM callers use `coding_ask`.
|
|
89
|
+
- `GET /api/coding/coding_xterm_session?session_id=<id>` — **WebSocket**. Attaches to the PTY. Replays a scrollback buffer (≤256 KB), then streams live output. Send raw text or `{"kind":"input","data":"..."}` / `{"kind":"resize","cols":N,"rows":M}` JSON envelopes. Accepts HMAC `?ticket=` for browser-direct attaches.
|
|
90
|
+
|
|
91
|
+
Source: `src/server/api/coding/`, `src/server/tools/coding-tools.ts`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## `/api/browser` (slot: `browser`)
|
|
96
|
+
|
|
97
|
+
Playwright-driven Chromium sessions bound to persistent profiles.
|
|
98
|
+
|
|
99
|
+
### Tools
|
|
100
|
+
|
|
101
|
+
| Tool | Purpose |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `browser_navigate` | Go to a URL. |
|
|
104
|
+
| `browser_snapshot` | Get an ARIA accessibility tree — call before interacting to discover element refs. |
|
|
105
|
+
| `browser_click` | Click by text description or ref. |
|
|
106
|
+
| `browser_fill` | Clear then fill an input. |
|
|
107
|
+
| `browser_type` | Type character-by-character (real-user simulation). |
|
|
108
|
+
| `browser_press_key` | Press a key (Enter, Tab, ArrowDown, etc.). |
|
|
109
|
+
| `browser_select_option` | Choose a `<select>` option. |
|
|
110
|
+
| `browser_screenshot` | Base64 PNG of the viewport. |
|
|
111
|
+
| `browser_wait_for` | Wait on `load` / `domcontentloaded` / `networkidle`. |
|
|
112
|
+
| `browser_evaluate` | Run a JS expression in the page context. |
|
|
113
|
+
| `browser_go_back` / `browser_go_forward` | History navigation. |
|
|
114
|
+
| `browser_scroll` | Scroll by pixels. |
|
|
115
|
+
| `browser_list_sessions` | List configured sessions, their profiles, and live status. |
|
|
116
|
+
| `browser_create_session` | Bind a new session name to a profile. Body: `{session, profile}`. |
|
|
117
|
+
| `browser_delete_session` | Remove a session from config (closes it if running; profile data preserved). |
|
|
118
|
+
| `browser_close_session` | Close a live session (config kept). |
|
|
119
|
+
| `browser_close_all` | Close every running session. |
|
|
120
|
+
|
|
121
|
+
### Live view + lifecycle
|
|
122
|
+
|
|
123
|
+
- `POST /api/browser/launch` — lazy-launch (or reattach to) a session by name. Body: `{session}`. Always headless — live view goes over CDP.
|
|
124
|
+
- `GET /api/browser/cdp/:session` — **WebSocket** proxy for Chrome DevTools Protocol. Pipes frames between the client and the headless Chromium's `--remote-debugging-port`. Closes with `4404` if the session isn't running, `4502` if the upstream handshake fails.
|
|
125
|
+
|
|
126
|
+
Source: `src/server/api/browser/`, `src/server/tools/browser-tools.ts`.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## `/api/exec` (slot: `exec`)
|
|
131
|
+
|
|
132
|
+
- `POST /api/exec/exec_command` — run a shell command. Enforces the `slots.exec.allow` / `slots.exec.deny` patterns from preferences.
|
|
133
|
+
|
|
134
|
+
Source: `src/server/api/exec/`, `src/server/tools/exec-tools.ts`.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## `/api/files` (slot: `files`)
|
|
139
|
+
|
|
140
|
+
Scoped to folders registered with the `files` scope.
|
|
141
|
+
|
|
142
|
+
| Tool | Purpose |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `files_read` | Read a file as UTF-8 with `cat -n` style line numbers. |
|
|
145
|
+
| `files_write` | Create or overwrite a file (parent dirs auto-created). |
|
|
146
|
+
| `files_edit` | Replace an exact string region. Fails on non-unique matches unless `replace_all: true`. |
|
|
147
|
+
| `files_glob` | Glob search; returns absolute paths sorted by mtime (newest first). |
|
|
148
|
+
| `files_grep` | Ripgrep over file contents. Supports `path` / `glob` / `type` filters, three output modes, context lines. Requires `rg` on PATH. |
|
|
149
|
+
|
|
150
|
+
Source: `src/server/api/files/`, `src/server/tools/files-tools.ts`.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## `/api/utils` (always on)
|
|
155
|
+
|
|
156
|
+
- `POST /api/utils/sleep` — pause for 1–300 seconds. Body: `{seconds, reason?}`.
|
|
157
|
+
|
|
158
|
+
Source: `src/server/api/utils/`, `src/server/tools/utils-tools.ts`.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## `/api/folders` (always on)
|
|
163
|
+
|
|
164
|
+
Register the on-disk paths the gateway is allowed to touch.
|
|
165
|
+
|
|
166
|
+
| Method | Path | Body / Params | Description |
|
|
167
|
+
|---|---|---|---|
|
|
168
|
+
| GET | `/api/folders` | — | List registered folders. |
|
|
169
|
+
| POST | `/api/folders/local` | `{name?, path, scopes?}` | Register an existing directory. `scopes` defaults to `["files","coding","exec"]`. |
|
|
170
|
+
| POST | `/api/folders/git` | `{name?, url, branch?}` | `git clone --depth 1` into `COREBRAIN_DEFAULT_WORKSPACE` (default `/app`) and register the result. |
|
|
171
|
+
| DELETE | `/api/folders/:idOrName` | — | Unregister. Does not delete files. |
|
|
172
|
+
|
|
173
|
+
Source: `src/server/api/folders/index.ts`.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## `/api/shell` (always on)
|
|
178
|
+
|
|
179
|
+
Singleton PTY for the webapp Terminal tab.
|
|
180
|
+
|
|
181
|
+
- `POST /api/shell/spawn` — spawn or reattach. Body: `{cwd?, fresh?}`. Returns `{sessionId, pid, resumed}`. Resolves shell in order `$SHELL → /bin/zsh → /bin/bash → /bin/sh`. Attach to the returned `sessionId` over `/api/coding/coding_xterm_session` (same PTY manager).
|
|
182
|
+
|
|
183
|
+
Source: `src/server/api/shell/index.ts`.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Manifest shape
|
|
188
|
+
|
|
189
|
+
`GET /manifest` returns a validated `Manifest` (schema in `@redplanethq/gateway-protocol`):
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
{
|
|
193
|
+
protocolVersion: "1",
|
|
194
|
+
gateway: { id, name, description?, version, platform, hostname, deployMode },
|
|
195
|
+
capabilities: {
|
|
196
|
+
browser: { enabled, engines?: string[] },
|
|
197
|
+
directXterm?: boolean, // HMAC-ticket xterm auth supported
|
|
198
|
+
},
|
|
199
|
+
folders: Folder[], // registered on-disk paths + scopes
|
|
200
|
+
tools: GatewayTool[], // one per enabled tool, name/description/inputSchema
|
|
201
|
+
agents: string[], // configured coding agents
|
|
202
|
+
availableAgents: AvailableAgent[], // detected on PATH
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`deployMode` is `native` / `docker` / `railway`, derived from `COREBRAIN_DEPLOY_MODE` or `/.dockerenv`.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Errors
|
|
211
|
+
|
|
212
|
+
Consistent envelope on any failure:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{ "ok": false, "error": { "code": "UNAUTHORIZED" | "TOOL_ERROR" | "INTERNAL" | "...", "message": "..." } }
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Common statuses:
|
|
219
|
+
|
|
220
|
+
| Status | When |
|
|
221
|
+
|---|---|
|
|
222
|
+
| 400 | Missing or invalid params (zod validation, missing required body field). |
|
|
223
|
+
| 401 | Bearer / ticket verification failed. |
|
|
224
|
+
| 403 | Folder scope check rejected the path. |
|
|
225
|
+
| 404 | Resource not found (session, folder, browser session). |
|
|
226
|
+
| 500 | Internal — see gateway log (`~/.corebrain/logs/gateway.log`). |
|
|
227
|
+
| 502 | Upstream failure (git clone, CDP handshake). |
|
|
228
|
+
|
|
229
|
+
For WebSocket routes, close codes carry the same signal: `4400` (bad request), `4404` (not found), `4500` (server error), `4502` (upstream error), `1000` (normal close).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import zod from 'zod';
|
|
2
|
+
export declare const description = "Log in to a subscription (Claude, Codex, Antigravity, xAI) on a bundled gateway. Drives CLIProxyAPI\u2019s OAuth flow through the gateway so tokens land directly on it.";
|
|
3
|
+
export declare const options: zod.ZodObject<{
|
|
4
|
+
login: zod.ZodEnum<{
|
|
5
|
+
claude: "claude";
|
|
6
|
+
codex: "codex";
|
|
7
|
+
antigravity: "antigravity";
|
|
8
|
+
xai: "xai";
|
|
9
|
+
}>;
|
|
10
|
+
gateway: zod.ZodOptional<zod.ZodString>;
|
|
11
|
+
}, zod.core.$strip>;
|
|
12
|
+
type Props = {
|
|
13
|
+
options: zod.infer<typeof options>;
|
|
14
|
+
};
|
|
15
|
+
export default function GatewayLLMProxy({ options: opts }: Props): null;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=llmproxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmproxy.d.ts","sourceRoot":"","sources":["../../../src/commands/gateway/llmproxy.tsx"],"names":[],"mappings":"AAIA,OAAO,GAAG,MAAM,KAAK,CAAC;AAItB,eAAO,MAAM,WAAW,6KAC8I,CAAC;AAWvK,eAAO,MAAM,OAAO;;;;;;;;mBAQlB,CAAC;AAEH,KAAK,KAAK,GAAG;IAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAA;CAAC,CAAC;AAwXlD,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,EAAE,KAAK,QAM7D"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useApp } from 'ink';
|
|
3
|
+
import * as p from '@clack/prompts';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import zod from 'zod';
|
|
6
|
+
import http from 'node:http';
|
|
7
|
+
import { listGateways } from '../../server/api/gateways.js';
|
|
8
|
+
export const description = 'Log in to a subscription (Claude, Codex, Antigravity, xAI) on a bundled gateway. Drives CLIProxyAPI’s OAuth flow through the gateway so tokens land directly on it.';
|
|
9
|
+
/**
|
|
10
|
+
* Providers supported by the built-in gateway llmproxy. Kept as a string
|
|
11
|
+
* enum for CLI validation, but the authoritative list lives in
|
|
12
|
+
* `<gateway>/api/llmproxy/providers` — we bail with a clean error if the
|
|
13
|
+
* requested provider isn't in the gateway's response.
|
|
14
|
+
*/
|
|
15
|
+
const LOGIN_CHOICES = ['claude', 'codex', 'antigravity', 'xai'];
|
|
16
|
+
export const options = zod.object({
|
|
17
|
+
login: zod
|
|
18
|
+
.enum(LOGIN_CHOICES)
|
|
19
|
+
.describe('Which subscription to log in to. One of: claude, codex, antigravity, xai.'),
|
|
20
|
+
gateway: zod
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Gateway name or id (only needed when multiple gateways are registered).'),
|
|
24
|
+
});
|
|
25
|
+
/** Turn `https://foo/` + `/api/x` into `https://foo/api/x` (no double slash). */
|
|
26
|
+
function joinUrl(base, path) {
|
|
27
|
+
return `${base.replace(/\/$/, '')}${path.startsWith('/') ? path : `/${path}`}`;
|
|
28
|
+
}
|
|
29
|
+
async function fetchProviders(gatewayUrl) {
|
|
30
|
+
const res = await fetch(joinUrl(gatewayUrl, '/api/llmproxy/providers'), {
|
|
31
|
+
signal: AbortSignal.timeout(10_000),
|
|
32
|
+
});
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw new Error(`gateway did not return provider list (HTTP ${res.status}). Is this the bundled gateway image (with cliproxy)?`);
|
|
35
|
+
}
|
|
36
|
+
const body = (await res.json());
|
|
37
|
+
if (!body.providers)
|
|
38
|
+
throw new Error('malformed /api/llmproxy/providers response');
|
|
39
|
+
return body.providers;
|
|
40
|
+
}
|
|
41
|
+
async function startLogin(gatewayUrl, provider) {
|
|
42
|
+
const res = await fetch(joinUrl(gatewayUrl, `/api/llmproxy/login/${provider}`), {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
signal: AbortSignal.timeout(30_000),
|
|
45
|
+
});
|
|
46
|
+
const body = (await res.json());
|
|
47
|
+
if (!res.ok || !body.ok) {
|
|
48
|
+
throw new Error(body.error ?? `gateway returned HTTP ${res.status}`);
|
|
49
|
+
}
|
|
50
|
+
return body;
|
|
51
|
+
}
|
|
52
|
+
async function pollStatus(gatewayUrl, provider) {
|
|
53
|
+
const res = await fetch(joinUrl(gatewayUrl, `/api/llmproxy/login/${provider}/status`), {
|
|
54
|
+
signal: AbortSignal.timeout(5_000),
|
|
55
|
+
});
|
|
56
|
+
return (await res.json());
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Start a tiny local HTTP server on the OAuth callback port. When the user's
|
|
60
|
+
* browser is redirected to `http://localhost:<port>/callback?code=...` after
|
|
61
|
+
* approving on the provider's OAuth page, this catches the request, forwards
|
|
62
|
+
* the raw query to the gateway (`/llmproxy-oauth/<provider>/callback?...`),
|
|
63
|
+
* and returns a friendly page to the browser.
|
|
64
|
+
*/
|
|
65
|
+
function bindLocalCallback(provider, port, callbackPath, gatewayUrl) {
|
|
66
|
+
let resolve;
|
|
67
|
+
const received = new Promise((r) => {
|
|
68
|
+
resolve = r;
|
|
69
|
+
});
|
|
70
|
+
const server = http.createServer(async (req, res) => {
|
|
71
|
+
const path = req.url ?? '/';
|
|
72
|
+
// Only forward the actual callback — ignore favicon.ico, HEAD probes, etc.
|
|
73
|
+
// Match `callbackPath` optionally followed by `?...` (query string).
|
|
74
|
+
const pathOnly = path.split('?')[0] ?? path;
|
|
75
|
+
if (pathOnly !== callbackPath) {
|
|
76
|
+
res.writeHead(404, { 'content-type': 'text/plain' });
|
|
77
|
+
res.end('not the callback');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const query = path.includes('?') ? path.slice(path.indexOf('?')) : '';
|
|
81
|
+
const targetUrl = joinUrl(gatewayUrl, `/llmproxy-oauth/${provider}${callbackPath}${query}`);
|
|
82
|
+
try {
|
|
83
|
+
const forward = await fetch(targetUrl, {
|
|
84
|
+
method: 'GET',
|
|
85
|
+
signal: AbortSignal.timeout(30_000),
|
|
86
|
+
redirect: 'manual',
|
|
87
|
+
});
|
|
88
|
+
// CLIProxyAPI often responds with a 302 redirect to its own success
|
|
89
|
+
// page after processing the code, so anything 2xx or 3xx means the
|
|
90
|
+
// callback was delivered. Only 4xx/5xx indicate a real failure.
|
|
91
|
+
// Actual login success/failure is confirmed by the status poll —
|
|
92
|
+
// we just report "callback got through" here.
|
|
93
|
+
const delivered = forward.status < 400;
|
|
94
|
+
res.writeHead(delivered ? 200 : forward.status, { 'content-type': 'text/html' });
|
|
95
|
+
res.end(`<!doctype html>
|
|
96
|
+
<meta charset="utf-8">
|
|
97
|
+
<title>Login complete</title>
|
|
98
|
+
<div style="font-family: -apple-system, sans-serif; max-width: 480px; margin: 8rem auto; text-align: center;">
|
|
99
|
+
<h2>${delivered ? 'Login complete' : 'Login failed'}</h2>
|
|
100
|
+
<p>You can close this tab and return to your terminal.</p>
|
|
101
|
+
</div>`);
|
|
102
|
+
resolve({
|
|
103
|
+
ok: delivered,
|
|
104
|
+
error: delivered ? undefined : `gateway returned HTTP ${forward.status}`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
res.writeHead(502, { 'content-type': 'text/plain' });
|
|
109
|
+
res.end('failed to relay callback to gateway');
|
|
110
|
+
resolve({ ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
server.listen(port, '127.0.0.1');
|
|
114
|
+
const close = () => new Promise((r) => {
|
|
115
|
+
server.close(() => r());
|
|
116
|
+
});
|
|
117
|
+
return { close, received };
|
|
118
|
+
}
|
|
119
|
+
async function pickGateway(name) {
|
|
120
|
+
const gateways = await listGateways();
|
|
121
|
+
if (gateways.length === 0) {
|
|
122
|
+
p.log.error(`No gateways registered with your CORE workspace. Deploy one first (${chalk.cyan('corebrain gateway setup')}) or register via the webapp.`);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
if (name) {
|
|
126
|
+
const match = gateways.find((g) => g.id === name || g.name === name);
|
|
127
|
+
if (!match) {
|
|
128
|
+
p.log.error(`No gateway named or ID'd ${chalk.bold(name)}. Available:\n ${gateways
|
|
129
|
+
.map((g) => `${g.name} (${g.id})`)
|
|
130
|
+
.join('\n ')}`);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return match;
|
|
134
|
+
}
|
|
135
|
+
if (gateways.length === 1)
|
|
136
|
+
return gateways[0];
|
|
137
|
+
const choice = await p.select({
|
|
138
|
+
message: 'Which gateway do you want to log in to?',
|
|
139
|
+
options: gateways.map((g) => ({
|
|
140
|
+
value: g.id,
|
|
141
|
+
label: `${g.name} (${g.baseUrl})`,
|
|
142
|
+
hint: g.status === 'CONNECTED' ? 'connected' : 'disconnected',
|
|
143
|
+
})),
|
|
144
|
+
});
|
|
145
|
+
if (p.isCancel(choice))
|
|
146
|
+
return null;
|
|
147
|
+
return gateways.find((g) => g.id === choice) ?? null;
|
|
148
|
+
}
|
|
149
|
+
async function runLoginFlow(opts) {
|
|
150
|
+
const gateway = await pickGateway(opts.gateway);
|
|
151
|
+
if (!gateway) {
|
|
152
|
+
process.exitCode = 1;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
p.log.info(`Using gateway ${chalk.bold(gateway.name)} at ${gateway.baseUrl}`);
|
|
156
|
+
const providersSpinner = p.spinner();
|
|
157
|
+
providersSpinner.start('Fetching provider list from gateway...');
|
|
158
|
+
let providers;
|
|
159
|
+
try {
|
|
160
|
+
providers = await fetchProviders(gateway.baseUrl);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
providersSpinner.stop(chalk.red('Failed to reach gateway.'));
|
|
164
|
+
p.log.error(err instanceof Error ? err.message : String(err));
|
|
165
|
+
process.exitCode = 1;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
providersSpinner.stop(`Gateway supports ${Object.keys(providers).length} providers`);
|
|
169
|
+
const meta = providers[opts.login];
|
|
170
|
+
if (!meta) {
|
|
171
|
+
p.log.error(`Gateway does not expose the ${chalk.bold(opts.login)} provider. Available: ${Object.keys(providers).join(', ')}`);
|
|
172
|
+
process.exitCode = 1;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
// For callback flow: bind the local port BEFORE asking the gateway to
|
|
176
|
+
// start the login. If the port is taken, we'd rather fail here than after
|
|
177
|
+
// spawning the subprocess.
|
|
178
|
+
let localServer = null;
|
|
179
|
+
if (meta.flow === 'callback') {
|
|
180
|
+
if (!meta.port || !meta.callbackPath) {
|
|
181
|
+
p.log.error(`Provider ${opts.login} is marked as callback flow but missing port/callbackPath in the gateway config.`);
|
|
182
|
+
process.exitCode = 1;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
localServer = bindLocalCallback(opts.login, meta.port, meta.callbackPath, gateway.baseUrl);
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
p.log.error(`Could not bind localhost:${meta.port} for the OAuth callback. Another process may be listening there. ${err instanceof Error ? err.message : String(err)}`);
|
|
190
|
+
process.exitCode = 1;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const loginSpinner = p.spinner();
|
|
195
|
+
loginSpinner.start('Asking gateway to start the login flow...');
|
|
196
|
+
let start;
|
|
197
|
+
try {
|
|
198
|
+
start = await startLogin(gateway.baseUrl, opts.login);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
loginSpinner.stop(chalk.red('Gateway rejected the login request.'));
|
|
202
|
+
p.log.error(err instanceof Error ? err.message : String(err));
|
|
203
|
+
if (localServer)
|
|
204
|
+
await localServer.close();
|
|
205
|
+
process.exitCode = 1;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
loginSpinner.stop('Got login details from gateway');
|
|
209
|
+
// Print the URL raw (no box border) so the user can triple-click and copy
|
|
210
|
+
// without dragging in decorative characters — long OAuth URLs would
|
|
211
|
+
// otherwise wrap across `p.note()`'s vertical bar and break selection.
|
|
212
|
+
console.log();
|
|
213
|
+
console.log(chalk.bold(`Sign in to ${meta.displayName} — open this URL:`));
|
|
214
|
+
console.log();
|
|
215
|
+
console.log(chalk.cyan(start.authUrl ?? ''));
|
|
216
|
+
console.log();
|
|
217
|
+
if (meta.flow === 'device-code' && start.userCode) {
|
|
218
|
+
console.log(`${chalk.bold('Then enter this code on the page:')} ${chalk.yellow.bold(start.userCode)}`);
|
|
219
|
+
}
|
|
220
|
+
else if (meta.flow === 'callback') {
|
|
221
|
+
console.log(chalk.dim(`This CLI is listening on http://localhost:${meta.port}${meta.callbackPath} and will forward the OAuth callback to your gateway.`));
|
|
222
|
+
}
|
|
223
|
+
console.log();
|
|
224
|
+
const waitSpinner = p.spinner();
|
|
225
|
+
waitSpinner.start(meta.flow === 'device-code'
|
|
226
|
+
? 'Waiting for you to approve on the provider website...'
|
|
227
|
+
: 'Waiting for you to complete the browser flow...');
|
|
228
|
+
// The truthful signal for "is this login done?" is the status poll —
|
|
229
|
+
// the gateway subprocess transitions to `completed` / `failed` after
|
|
230
|
+
// exchanging the code. The local callback resolving just tells us the
|
|
231
|
+
// browser redirected; the actual token exchange happens after. So we
|
|
232
|
+
// poll status regardless, and only use the callback to speed up the
|
|
233
|
+
// last few seconds.
|
|
234
|
+
const timeoutMs = 5 * 60_000;
|
|
235
|
+
const startedAt = Date.now();
|
|
236
|
+
let callbackReported = null;
|
|
237
|
+
if (localServer) {
|
|
238
|
+
localServer.received.then((r) => {
|
|
239
|
+
callbackReported = r;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
let outcome = null;
|
|
243
|
+
while (Date.now() - startedAt < timeoutMs && !outcome) {
|
|
244
|
+
await new Promise((r) => setTimeout(r, 2_000));
|
|
245
|
+
try {
|
|
246
|
+
const status = await pollStatus(gateway.baseUrl, opts.login);
|
|
247
|
+
if (status.status === 'completed') {
|
|
248
|
+
outcome = { ok: true };
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
if (status.status === 'failed') {
|
|
252
|
+
outcome = { ok: false, error: status.error ?? 'unknown gateway error' };
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (status.status === 'idle') {
|
|
256
|
+
// Subprocess already exited and its entry was GC'd, but we never
|
|
257
|
+
// got a completed/failed reading. Trust the callback report.
|
|
258
|
+
if (callbackReported) {
|
|
259
|
+
outcome = callbackReported;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// transient poll failure — keep waiting
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (localServer)
|
|
269
|
+
await localServer.close();
|
|
270
|
+
if (!outcome) {
|
|
271
|
+
waitSpinner.stop(chalk.red('Timed out waiting for authorization.'));
|
|
272
|
+
p.log.error(`No response within ${timeoutMs / 1000}s. Re-run the command to try again.`);
|
|
273
|
+
process.exitCode = 1;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (!outcome.ok) {
|
|
277
|
+
waitSpinner.stop(chalk.red('Login failed.'));
|
|
278
|
+
p.log.error(outcome.error ?? 'unknown error');
|
|
279
|
+
process.exitCode = 1;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
waitSpinner.stop(chalk.green('Login complete'));
|
|
283
|
+
p.note([
|
|
284
|
+
`${chalk.bold('BYOK base URL:')} ${gateway.baseUrl.replace(/\/$/, '')}/llmproxy/v1`,
|
|
285
|
+
`${chalk.bold('API key:')} your ${chalk.dim('COREBRAIN_GATEWAY_SECURITY_KEY')} value`,
|
|
286
|
+
'',
|
|
287
|
+
`Paste both into ${chalk.cyan('CORE → Workspace Settings → Models → BYOK')}.`,
|
|
288
|
+
`Then set a workspace model like ${chalk.cyan(`openai/${defaultModelFor(opts.login)}`)}.`,
|
|
289
|
+
].join('\n'), 'Wire into CORE');
|
|
290
|
+
}
|
|
291
|
+
function defaultModelFor(provider) {
|
|
292
|
+
switch (provider) {
|
|
293
|
+
case 'claude':
|
|
294
|
+
return 'claude-sonnet-4-6';
|
|
295
|
+
case 'codex':
|
|
296
|
+
return 'gpt-4o';
|
|
297
|
+
case 'antigravity':
|
|
298
|
+
return 'gemini-2.0-flash';
|
|
299
|
+
case 'xai':
|
|
300
|
+
return 'grok-2-latest';
|
|
301
|
+
default:
|
|
302
|
+
return provider;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
export default function GatewayLLMProxy({ options: opts }) {
|
|
306
|
+
const { exit } = useApp();
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
runLoginFlow(opts).finally(() => setTimeout(() => exit(), 100));
|
|
309
|
+
}, [exit, opts]);
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=llmproxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmproxy.js","sourceRoot":"","sources":["../../../src/commands/gateway/llmproxy.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,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gB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GACf,OAAO,CAoCT;AAWD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,MAAM,EAAwB,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/server/api/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAG1D,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQvE;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GACf,OAAO,CAoCT;AAWD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,MAAM,EAAwB,IAKjC,KAAK,cAAc,EAAE,OAAO,YAAY,mBA6BvE"}
|
package/dist/server/api/auth.js
CHANGED
|
@@ -96,8 +96,17 @@ const TICKET_PATHS = new Set([
|
|
|
96
96
|
* Bearer securityKey — there is no loopback bypass.
|
|
97
97
|
*/
|
|
98
98
|
export function makeAuthHook(skip = ['/healthz/public']) {
|
|
99
|
+
// Entries ending in "/" match by prefix (e.g. "/api/llmproxy/" skips
|
|
100
|
+
// every subpath). Entries without a trailing slash match exactly, with
|
|
101
|
+
// an optional query string. Keep prefix entries narrow — they bypass the
|
|
102
|
+
// gateway's security key.
|
|
99
103
|
return async function authHook(req, reply) {
|
|
100
|
-
|
|
104
|
+
const matched = skip.some((s) => {
|
|
105
|
+
if (s.endsWith('/'))
|
|
106
|
+
return req.url === s.slice(0, -1) || req.url.startsWith(s);
|
|
107
|
+
return req.url === s || req.url.startsWith(s + '?');
|
|
108
|
+
});
|
|
109
|
+
if (matched)
|
|
101
110
|
return;
|
|
102
111
|
// Ticket auth for the browser-direct xterm WS. A request that targets
|
|
103
112
|
// a TICKET_PATH and supplies `?ticket=…` is verified via HMAC instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/server/api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAEjF,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEpD,MAAM,UAAU,OAAO,CAAC,GAAW;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,OAAO,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA4B;IAC7D,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC;IAC3D,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,C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