flashcards-codex-bridge 0.0.0-stage → 0.1.1
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 +41 -2
- package/bin.mjs +2 -0
- package/dist/bin.mjs +3882 -0
- package/package.json +32 -4
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# flashcards-codex-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lets the Flashcards chat panel talk to the Codex CLI on your own machine.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx flashcards-codex-bridge
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Then open https://easyray-storybook.pages.dev/?id=Apps.Flashcards.TrainStationNotes&view=story&theme=dark (or sign in at https://osnovahq.com/) and press Chat. Chrome asks once whether the page may reach apps on this device ("local network access"): allow it.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- Node 22 or newer (tested on 25.2.1).
|
|
14
|
+
- Codex CLI installed and logged in: `npm install -g @openai/codex` (or `brew install codex`), then `codex login`. The bridge checks both at start-up (`codex --version`, `codex login status`) and says which is missing.
|
|
15
|
+
- Codex runs on your own default model (`~/.codex/config.toml`); the bridge asks for none.
|
|
16
|
+
|
|
17
|
+
## Why a local process is needed
|
|
18
|
+
|
|
19
|
+
`codex app-server --listen ws://127.0.0.1:PORT` (codex 0.169.0) refuses every WebSocket handshake that carries an Origin header, and every browser page sends one (probe 2026-11-26: Origin https://easyray-storybook.pages.dev → `Expected 101 status code: 403`; the same handshake without Origin → a normal `initialize` reply). So a page cannot reach codex directly; this bridge speaks to codex over stdio and checks the page's Origin itself.
|
|
20
|
+
|
|
21
|
+
## What it does
|
|
22
|
+
|
|
23
|
+
Listens on `127.0.0.1:3417` only, starts `codex app-server`, gives each browser tab its own Codex thread in a read-only sandbox, and, when the page names one of the two skills the chat offers, puts that skill's text in front of the turn. The page reaches the bridge only over the WebSocket: Chrome's Local Network Access may block a plain fetch from an https page to 127.0.0.1. The note tools run in the page, never on your disk.
|
|
24
|
+
|
|
25
|
+
## Origin rule
|
|
26
|
+
|
|
27
|
+
Any web page you open can reach a server on 127.0.0.1, so the bridge accepts the WebSocket only from these page origins and answers every other one with 403:
|
|
28
|
+
|
|
29
|
+
- https://osnovahq.com
|
|
30
|
+
- https://easyray-storybook.pages.dev
|
|
31
|
+
- http://localhost:3000, http://127.0.0.1:3000
|
|
32
|
+
|
|
33
|
+
Add one with `--allow-origin https://example.com` (repeatable) or `FLASHCARDS_BRIDGE_ORIGINS=https://a.example,https://b.example`.
|
|
34
|
+
|
|
35
|
+
## Options
|
|
36
|
+
|
|
37
|
+
- `--port N` or `FLASHCARDS_BRIDGE_PORT`: another port (the page connects to 3417, so only for tests).
|
|
38
|
+
- A taken port stops start-up with a message; it never moves to another port, since the page would not find it.
|
|
39
|
+
|
|
40
|
+
## Source and build
|
|
41
|
+
|
|
42
|
+
The router, codex protocol, origin rule and start-up checks are shared with the repo's dev bridge, `apps/product/flashcards/scripts/demo-codex-bridge.ts`; `src/serve-node.ts` adapts them to Node (`node:http`, `ws`, `node:child_process`). `bun run build` writes one file, `dist/bin.mjs`, with `ws`, the chat instructions and the two skills inlined. `npm pack` and `bun pm pack` run the build first (`prepack`). Until `bun install` links `ws` into this package, build with `NODE_PATH=<repo>/node_modules/.bun/ws@8.22.0/node_modules`.
|
package/bin.mjs
ADDED