@cuongtran001/kanna 0.56.4 → 0.57.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 +104 -43
- package/dist/client/assets/index-BNfrssw5.js +2716 -0
- package/dist/client/assets/index-DglLa3SU.css +32 -0
- package/dist/client/assets/{index-zcdDKOCt.js → index-jZ-zRgNM.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/export-viewer/assets/index-B60zOmQk.css +1 -0
- package/dist/export-viewer/assets/{index-3rm8yWdF.js → index-B6NqwibA.js} +1 -1
- package/dist/export-viewer/assets/{index-DDyZw7KP.js → index-_81r2Tyd.js} +1 -1
- package/dist/export-viewer/index.html +2 -2
- package/package.json +2 -1
- package/src/server/agent.pty-rotation.test.ts +331 -0
- package/src/server/agent.ts +78 -13
- package/src/server/claude-pty/auth.test.ts +34 -1
- package/src/server/claude-pty/auth.ts +26 -1
- package/src/server/claude-pty/driver.test.ts +177 -1
- package/src/server/claude-pty/driver.ts +281 -56
- package/src/server/claude-pty/jsonl-reader.ts +8 -3
- package/src/server/claude-pty/jsonl-to-event.test.ts +178 -1
- package/src/server/claude-pty/jsonl-to-event.ts +137 -1
- package/src/server/claude-pty/parity-matrix.test.ts +201 -0
- package/src/server/claude-pty/preflight/cache.test.ts +17 -2
- package/src/server/claude-pty/preflight/cache.ts +6 -1
- package/src/server/claude-pty/preflight/gate.test.ts +100 -0
- package/src/server/claude-pty/preflight/gate.ts +52 -11
- package/src/server/claude-pty/preflight/probe.ts +36 -1
- package/src/server/claude-pty/preflight/types.test.ts +4 -2
- package/src/server/claude-pty/preflight/types.ts +12 -0
- package/src/server/claude-pty/sandbox/platform.test.ts +1 -16
- package/src/server/claude-pty/sandbox/platform.ts +21 -10
- package/src/server/claude-pty/sandbox/preflight.ts +2 -2
- package/src/server/claude-pty/sandbox/profile-linux.test.ts +69 -18
- package/src/server/claude-pty/sandbox/profile-linux.ts +54 -15
- package/src/server/claude-pty/sandbox/profile-macos.test.ts +22 -0
- package/src/server/claude-pty/sandbox/profile-macos.ts +9 -2
- package/src/server/claude-pty/sandbox/wrap.ts +13 -2
- package/src/server/codex-app-server.test.ts +6 -3
- package/src/server/codex-app-server.ts +2 -2
- package/src/server/kanna-mcp-http.test.ts +122 -0
- package/src/server/kanna-mcp-http.ts +150 -0
- package/src/server/oauth-pool/oauth-token-pool.test.ts +131 -0
- package/src/server/oauth-pool/oauth-token-pool.ts +74 -19
- package/src/shared/kanna-system-prompt.ts +13 -0
- package/src/shared/projectFileUrl.test.ts +70 -1
- package/src/shared/projectFileUrl.ts +25 -0
- package/dist/client/assets/index-CvabLpkC.css +0 -32
- package/dist/client/assets/index-vwrALKHA.js +0 -2716
- package/dist/export-viewer/assets/index-pbfUT22T.css +0 -1
package/README.md
CHANGED
|
@@ -49,19 +49,51 @@ That's it. Kanna opens in your browser at [`localhost:3210`](http://localhost:32
|
|
|
49
49
|
|
|
50
50
|
## Features
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
**Providers & models**
|
|
53
|
+
|
|
54
|
+
- **Multi-provider support** — switch between Claude and Codex (OpenAI) from the chat input, with per-provider model selection, reasoning-effort controls, and Codex fast mode
|
|
55
|
+
- **OAuth token pool** — register multiple Claude OAuth tokens; Kanna rotates across them per chat
|
|
56
|
+
- **Subscription-billing PTY driver** — optional `KANNA_CLAUDE_DRIVER=pty` runs the `claude` CLI under a pseudo-terminal so Pro/Max subscription billing is preserved instead of API rates
|
|
57
|
+
|
|
58
|
+
**Chat & transcript**
|
|
59
|
+
|
|
60
|
+
- **Rich transcript rendering** — hydrated tool calls, collapsible tool groups, plan-mode dialogs, and interactive prompts with full result display
|
|
61
|
+
- **Inline diff viewer** — file and commit diffs rendered directly in the transcript
|
|
62
|
+
- **Embedded terminal** — per-project xterm terminal in a resizable side panel (macOS/Linux)
|
|
63
|
+
- **File & image uploads** — drag-and-drop attachments into the composer
|
|
64
|
+
- **Slash commands & @-mentions** — in-composer pickers for slash commands, file mentions, and subagents
|
|
65
|
+
- **Plan mode** — review and approve agent plans before execution
|
|
66
|
+
- **Subagent orchestration** — run and track parallel subagents within a turn
|
|
67
|
+
- **Background tasks** — long-running tasks tracked out-of-band with a status indicator
|
|
68
|
+
- **Auto-continue** — optionally continue a turn automatically when the agent stops short
|
|
69
|
+
- **Proactive compaction** — context-window meter with automatic transcript compaction before limits are hit
|
|
70
|
+
|
|
71
|
+
**Projects & sessions**
|
|
72
|
+
|
|
53
73
|
- **Project-first sidebar** — chats grouped under projects, with live status indicators (idle, running, waiting, failed)
|
|
54
74
|
- **Drag-and-drop project ordering** — reorder project groups in the sidebar with persistent ordering
|
|
55
75
|
- **Local project discovery** — auto-discovers projects from both Claude and Codex local history
|
|
56
76
|
- **Bulk import Claude Code sessions** — one-click import of existing `~/.claude/projects/` sessions with full transcript and seamless resume via the Claude Agent SDK
|
|
57
|
-
- **
|
|
58
|
-
- **Quick responses** — lightweight structured queries (e.g. title generation) via Haiku with automatic Codex fallback
|
|
59
|
-
- **Plan mode** — review and approve agent plans before execution
|
|
60
|
-
- **Persistent local history** — refresh-safe routes backed by JSONL event logs and compacted snapshots
|
|
61
|
-
- **Auto-generated titles** — chat titles generated in the background via Claude Haiku
|
|
77
|
+
- **Git worktree isolation** — run a chat in an isolated worktree without disturbing your working tree
|
|
62
78
|
- **Session resumption** — resume agent sessions with full context preservation
|
|
79
|
+
- **Auto-generated titles** — chat titles generated in the background via Claude Haiku
|
|
80
|
+
- **Quick responses** — lightweight structured queries (e.g. title generation) via Haiku with automatic Codex fallback
|
|
81
|
+
|
|
82
|
+
**Persistence & realtime**
|
|
83
|
+
|
|
84
|
+
- **Persistent local history** — refresh-safe routes backed by append-only JSONL event logs and compacted snapshots
|
|
63
85
|
- **WebSocket-driven** — real-time subscription model with reactive state broadcasting
|
|
86
|
+
- **Standalone transcript export** — export a chat as a self-contained HTML viewer
|
|
87
|
+
|
|
88
|
+
**Access & notifications**
|
|
89
|
+
|
|
90
|
+
- **Password protection** — optional launch password gating the app, WebSocket, and API routes
|
|
91
|
+
- **Public share link** — `--share` creates a temporary `trycloudflare.com` URL with a terminal QR code
|
|
64
92
|
- **Cloudflare tunnel via `expose_port` tool** — opt-in; the agent proactively calls the Kanna `expose_port` MCP tool with a port. In `always-ask` mode Kanna shows an inline "expose via Cloudflare" card for you to accept; in `auto-expose` mode `cloudflared tunnel --url` spawns immediately. Both modes are gated by the Cloudflare Tunnel setting
|
|
93
|
+
- **Web push & sound notifications** — browser push and sound alerts when a chat needs attention
|
|
94
|
+
- **Customizable keybindings** — user-editable keyboard shortcuts
|
|
95
|
+
- **In-app self-update** — one-click update that pulls, rebuilds, and hot-reloads (host-agnostic supervisor or pm2)
|
|
96
|
+
- **Mobile-friendly** — responsive layout, installable as a standalone PWA
|
|
65
97
|
|
|
66
98
|
## Architecture
|
|
67
99
|
|
|
@@ -69,14 +101,22 @@ That's it. Kanna opens in your browser at [`localhost:3210`](http://localhost:32
|
|
|
69
101
|
Browser (React + Zustand)
|
|
70
102
|
↕ WebSocket
|
|
71
103
|
Bun Server (HTTP + WS)
|
|
72
|
-
├──
|
|
73
|
-
├──
|
|
74
|
-
├──
|
|
75
|
-
├──
|
|
76
|
-
├──
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
104
|
+
├── Auth ───────────── optional password gate (HTTP/WS/API)
|
|
105
|
+
├── WSRouter ───────── subscription & command routing
|
|
106
|
+
├── AgentCoordinator ─ multi-provider turn management
|
|
107
|
+
├── ProviderCatalog ── provider/model/effort normalization
|
|
108
|
+
├── QuickResponse ──── structured queries with provider fallback
|
|
109
|
+
├── EventStore ─────── append-only JSONL + snapshot compaction
|
|
110
|
+
├── ReadModels ─────── derived views (sidebar, chat, projects)
|
|
111
|
+
├── DiffStore ──────── per-chat diff hydration
|
|
112
|
+
├── TerminalManager ── PTY sessions for the embedded terminal
|
|
113
|
+
├── Uploads ────────── drag-drop attachment intake
|
|
114
|
+
├── Discovery ──────── scan Claude/Codex local history
|
|
115
|
+
├── Push ───────────── web-push notifications
|
|
116
|
+
├── Share / Tunnel ─── trycloudflare + cloudflared
|
|
117
|
+
└── UpdateManager ──── self-update + reload strategy
|
|
118
|
+
↕ stdio / PTY
|
|
119
|
+
Claude Agent SDK · Claude CLI (PTY) · Codex App Server
|
|
80
120
|
↕
|
|
81
121
|
Local File System (~/.kanna/data/, project dirs)
|
|
82
122
|
```
|
|
@@ -85,7 +125,7 @@ Local File System (~/.kanna/data/, project dirs)
|
|
|
85
125
|
|
|
86
126
|
## Requirements
|
|
87
127
|
|
|
88
|
-
- [Bun](https://bun.sh) v1.3.
|
|
128
|
+
- [Bun](https://bun.sh) v1.3.11+
|
|
89
129
|
- A working [Claude Code](https://docs.anthropic.com/en/docs/claude-code) environment
|
|
90
130
|
- _(Optional)_ [Codex CLI](https://github.com/openai/codex) for Codex provider support
|
|
91
131
|
|
|
@@ -119,6 +159,7 @@ bun run build
|
|
|
119
159
|
```bash
|
|
120
160
|
kanna # start with defaults (localhost only)
|
|
121
161
|
kanna --port 4000 # custom port
|
|
162
|
+
kanna --strict-port # fail instead of trying another port
|
|
122
163
|
kanna --no-open # don't open browser
|
|
123
164
|
kanna --password <secret> # require a password before loading the app
|
|
124
165
|
kanna --share # create a public quick tunnel + terminal QR
|
|
@@ -223,43 +264,63 @@ bun run dev:server # http://localhost:5175
|
|
|
223
264
|
|
|
224
265
|
## Scripts
|
|
225
266
|
|
|
226
|
-
| Command | Description
|
|
227
|
-
| -------------------- |
|
|
228
|
-
| `bun run build` | Build
|
|
229
|
-
| `bun run check` | Typecheck
|
|
230
|
-
| `bun run
|
|
231
|
-
| `bun run dev
|
|
232
|
-
| `bun run dev:
|
|
233
|
-
| `bun run
|
|
267
|
+
| Command | Description |
|
|
268
|
+
| -------------------- | ------------------------------------ |
|
|
269
|
+
| `bun run build` | Build client + standalone export viewer |
|
|
270
|
+
| `bun run check` | Typecheck, lint, and build |
|
|
271
|
+
| `bun run lint` | ESLint over `src/` (zero-warning gate) |
|
|
272
|
+
| `bun run dev` | Run client + server together |
|
|
273
|
+
| `bun run dev:client` | Vite dev server only (`:5174`) |
|
|
274
|
+
| `bun run dev:server` | Bun backend only (`:5175`) |
|
|
275
|
+
| `bun run start` | Start production server |
|
|
276
|
+
| `bun test` | Run the test suite |
|
|
234
277
|
|
|
235
278
|
## Project Structure
|
|
236
279
|
|
|
280
|
+
Abridged — the actual tree has more modules, each with co-located `*.test.ts`:
|
|
281
|
+
|
|
237
282
|
```
|
|
238
283
|
src/
|
|
239
284
|
├── client/ React UI layer
|
|
240
285
|
│ ├── app/ App router, pages, central state hook, socket client
|
|
241
|
-
│ ├── components/
|
|
242
|
-
│ ├── hooks/
|
|
243
|
-
│ ├── stores/ Zustand stores (chat input, preferences,
|
|
244
|
-
│ └── lib/
|
|
286
|
+
│ ├── components/ chat-ui, messages, settings, ui primitives, modals
|
|
287
|
+
│ ├── hooks/ mobile/standalone detection, theme, mention/slash suggestions
|
|
288
|
+
│ ├── stores/ Zustand stores (chat input, preferences, terminal, tasks…)
|
|
289
|
+
│ └── lib/ formatters, path utils, transcript parsing, keybindings
|
|
245
290
|
├── server/ Bun backend
|
|
246
|
-
│ ├── cli.ts
|
|
247
|
-
│ ├── server.ts
|
|
248
|
-
│ ├──
|
|
249
|
-
│ ├──
|
|
250
|
-
│ ├──
|
|
251
|
-
│ ├──
|
|
252
|
-
│ ├──
|
|
253
|
-
│ ├──
|
|
254
|
-
│ ├──
|
|
255
|
-
│ ├──
|
|
256
|
-
│
|
|
291
|
+
│ ├── cli.ts · cli-runtime.ts CLI entry, flag parsing, supervisor
|
|
292
|
+
│ ├── server.ts HTTP/WS server + static serving
|
|
293
|
+
│ ├── auth.ts password gate for HTTP/WS/API
|
|
294
|
+
│ ├── ws-router.ts WebSocket routing & subscriptions
|
|
295
|
+
│ ├── agent.ts AgentCoordinator (multi-provider turns)
|
|
296
|
+
│ ├── codex-app-server.ts Codex App Server JSON-RPC client
|
|
297
|
+
│ ├── claude-pty/ PTY driver (subscription billing)
|
|
298
|
+
│ ├── oauth-pool/ Claude OAuth token rotation
|
|
299
|
+
│ ├── provider-catalog.ts provider/model/effort normalization
|
|
300
|
+
│ ├── quick-response.ts structured queries w/ provider fallback
|
|
301
|
+
│ ├── event-store.ts JSONL persistence, replay & compaction
|
|
302
|
+
│ ├── read-models.ts derived view models
|
|
303
|
+
│ ├── events.ts event type definitions
|
|
304
|
+
│ ├── discovery.ts auto-discover Claude/Codex projects
|
|
305
|
+
│ ├── claude-session-importer.ts bulk import existing sessions
|
|
306
|
+
│ ├── diff-store.ts per-chat diff hydration
|
|
307
|
+
│ ├── terminal-manager.ts embedded-terminal PTY sessions
|
|
308
|
+
│ ├── uploads.ts attachment intake
|
|
309
|
+
│ ├── subagent-orchestrator.ts parallel subagent runs
|
|
310
|
+
│ ├── background-tasks.ts out-of-band task tracking
|
|
311
|
+
│ ├── worktree-store.ts git worktree isolation
|
|
312
|
+
│ ├── push/ web-push notifications
|
|
313
|
+
│ ├── share.ts · cloudflare-tunnel/ trycloudflare / expose_port tunnels
|
|
314
|
+
│ ├── update-manager.ts · update-strategy.ts self-update
|
|
315
|
+
│ ├── kanna-mcp.ts Kanna MCP tools (built-in shims)
|
|
316
|
+
│ └── keybindings.ts persisted keybindings
|
|
257
317
|
└── shared/ Shared between client & server
|
|
258
|
-
├── types.ts
|
|
259
|
-
├── tools.ts
|
|
260
|
-
├── protocol.ts WebSocket
|
|
261
|
-
├── ports.ts
|
|
262
|
-
|
|
318
|
+
├── types.ts core domain types, provider catalog, transcript entries
|
|
319
|
+
├── tools.ts tool-call normalization & hydration
|
|
320
|
+
├── protocol.ts WebSocket wire envelopes
|
|
321
|
+
├── ports.ts default ports & dev-mode offsets
|
|
322
|
+
├── share.ts share/tunnel shared types
|
|
323
|
+
└── branding.ts app name & data-directory paths
|
|
263
324
|
```
|
|
264
325
|
|
|
265
326
|
## Data Storage
|