kimiflare 0.21.0 → 0.22.0

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
@@ -16,6 +16,11 @@
16
16
  Moonshot's 1T-parameter open-source model, running directly on your Cloudflare account.
17
17
  </p>
18
18
 
19
+ > 💸 **Heads up — this runs on your Cloudflare account.**
20
+ > We recommend setting a [budget cap](https://developers.cloudflare.com/workers-ai/platform/pricing/) on Workers AI and checking your [Cloudflare billing](https://dash.cloudflare.com/) regularly while using KimiFlare.
21
+ >
22
+ > 🚀 **Stay up to date.** Newer versions are significantly more token-efficient and cheaper to run. Run `/update` inside KimiFlare or `npm update -g kimiflare` to get the latest release.
23
+
19
24
  <p align="center">
20
25
  <img src="docs/screenshot.png" alt="kimiflare TUI" width="900">
21
26
  </p>
@@ -24,7 +29,7 @@
24
29
 
25
30
  - **262k context window** — Read entire modules, large configs, and full stack traces without the model losing track.
26
31
  - **Image understanding** — Drop image paths into your prompt (PNG, JPG, WebP, GIF, BMP). The model sees them inline — great for UI reviews, diagrams, screenshots, and mockups.
27
- - **Direct to Cloudflare** — No AI Gateway, no proxy, no OpenAI SDK. Your traffic goes straight to Workers AI from your account.
32
+ - **Direct by default** — No proxy, no OpenAI SDK. Your traffic goes straight to Workers AI from your account, with optional AI Gateway routing for user-owned logging, caching, and analytics.
28
33
  - **Plan mode** — Ask the agent to research and produce a plan without touching your filesystem. Review it, then exit plan mode to execute.
29
34
 
30
35
  ## Quick start
@@ -57,6 +62,7 @@ Requires Node.js ≥ 20.
57
62
  | **Streaming reasoning** | Toggle the model's chain-of-thought with `/reasoning` or `Ctrl-R`. See how it thinks in real time. |
58
63
  | **Image understanding** | Drop image paths (PNG, JPG, WebP, GIF, BMP up to 5 MB) into any prompt. The model sees them inline — perfect for UI reviews, diagrams, and screenshots. |
59
64
  | **Live cost tracking** | Status bar shows real-time cost based on Cloudflare pricing: `$0.95/M input`, `$0.16/M cached`, `$4.00/M output`. |
65
+ | **Optional AI Gateway** | Route Workers AI traffic through your own Cloudflare AI Gateway for request logs, cache status, and analytics while keeping your API token local. |
60
66
  | **Session persistence** | Every turn is auto-saved. `/resume` lists past sessions (with message counts) in a paginated picker. |
61
67
  | **Smart permissions** | Bash session-allow is keyed by the first token (e.g., allow all `git` commands). Write/edit show a unified diff before you approve. |
62
68
  | **Project context (`/init`)** | Scans your repo and writes a concise `KIMI.md` — build commands, layout, conventions. Auto-loaded on every launch. |
@@ -76,6 +82,8 @@ Then either export them each shell:
76
82
  ```sh
77
83
  export CLOUDFLARE_ACCOUNT_ID=...
78
84
  export CLOUDFLARE_API_TOKEN=...
85
+ # Optional: route through a Cloudflare AI Gateway you own
86
+ export KIMIFLARE_AI_GATEWAY_ID=...
79
87
  ```
80
88
 
81
89
  or save them once (`chmod 600` automatically):
@@ -86,12 +94,36 @@ cat > ~/.config/kimiflare/config.json <<'EOF'
86
94
  {
87
95
  "accountId": "YOUR_ACCOUNT_ID",
88
96
  "apiToken": "YOUR_API_TOKEN",
89
- "model": "@cf/moonshotai/kimi-k2.6"
97
+ "model": "@cf/moonshotai/kimi-k2.6",
98
+ "aiGatewayId": "YOUR_GATEWAY_NAME"
90
99
  }
91
100
  EOF
92
101
  chmod 600 ~/.config/kimiflare/config.json
93
102
  ```
94
103
 
104
+ ### Optional AI Gateway
105
+
106
+ kimiflare talks directly to Workers AI unless `aiGatewayId` is configured. When set, chat completions are sent to Cloudflare's native Workers AI Gateway endpoint:
107
+
108
+ ```text
109
+ https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/workers-ai/{model_id}
110
+ ```
111
+
112
+ Create a gateway in the Cloudflare dashboard under **AI > AI Gateway**, then set `aiGatewayId` in `~/.config/kimiflare/config.json` or export `KIMIFLARE_AI_GATEWAY_ID`. The same Workers AI API token stays on your machine and is sent to Cloudflare.
113
+
114
+ Optional per-request controls:
115
+
116
+ ```json
117
+ {
118
+ "aiGatewayCacheTtl": 3600,
119
+ "aiGatewaySkipCache": false,
120
+ "aiGatewayCollectLogPayload": false,
121
+ "aiGatewayMetadata": { "tool": "kimiflare" }
122
+ }
123
+ ```
124
+
125
+ `cf-aig-cache-status` from AI Gateway is shown separately from Workers AI prompt-token caching (`cached_tokens`). If you enable gateway logs, kimiflare records metadata such as log id, cache hit/miss, tokens, duration, and status when Cloudflare returns it; prompt and response bodies are not stored by kimiflare.
126
+
95
127
  ## MCP servers (Model Context Protocol)
96
128
 
97
129
  kimiflare supports external tools via MCP. Add servers to your `~/.config/kimiflare/config.json`:
@@ -271,7 +303,7 @@ All tool calls show inline; mutating ones require per-call approval the first ti
271
303
  @cf/moonshotai/kimi-k2.6
272
304
  ```
273
305
 
274
- Direct `fetch` to Workers AI, OpenAI-compatible `messages` + `tools` payload, SSE stream with reasoning + content + tool-call deltas accumulated by index.
306
+ Direct `fetch` to Workers AI by default, or the native Workers AI AI Gateway endpoint when `aiGatewayId` is configured. The payload remains OpenAI-compatible `messages` + `tools`, with an SSE stream containing reasoning + content + tool-call deltas accumulated by index.
275
307
 
276
308
  ## Development
277
309