ai-zero-token 2.0.3 → 2.0.5

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +34 -2
  3. package/README.zh-CN.md +35 -3
  4. package/admin-ui/dist/assets/{accounts-DymL4WIa.js → accounts-ABMyXo4H.js} +3 -1
  5. package/admin-ui/dist/assets/{docs-DtO-AOWU.js → docs-Dh0aFha_.js} +3 -3
  6. package/admin-ui/dist/assets/{image-bed-yIVQ4dKs.js → image-bed-C1M7-0q1.js} +1 -1
  7. package/admin-ui/dist/assets/index--rNjdmzf.js +10 -0
  8. package/admin-ui/dist/assets/{index-By4r-wy3.css → index-DjtN30PC.css} +1 -1
  9. package/admin-ui/dist/assets/{launch-CQXYrl-h.js → launch-pB7YlWFI.js} +1 -1
  10. package/admin-ui/dist/assets/logs-B7McijSi.js +1 -0
  11. package/admin-ui/dist/assets/{network-detect-sSrnwZqf.js → network-detect-Bx3XmXPk.js} +1 -1
  12. package/admin-ui/dist/assets/{overview-BbSON0Jl.js → overview-CV0H2Nsq.js} +1 -1
  13. package/admin-ui/dist/assets/settings-ynCIdUvZ.js +7 -0
  14. package/admin-ui/dist/assets/{tester-CftPgRE9.js → tester-BG-up8qP.js} +1 -1
  15. package/admin-ui/dist/index.html +2 -2
  16. package/build/tray-icon-template.png +0 -0
  17. package/dist/core/providers/http-client.js +228 -3
  18. package/dist/core/providers/openai-codex/chat.js +160 -23
  19. package/dist/core/services/auth-service.js +14 -5
  20. package/dist/core/services/chat-service.js +1 -0
  21. package/dist/core/services/config-service.js +15 -5
  22. package/dist/core/store/codex-auth-store.js +295 -4
  23. package/dist/core/store/settings-store.js +54 -24
  24. package/dist/desktop/main.js +616 -15
  25. package/dist/server/app.js +859 -91
  26. package/dist/server/index.js +2 -1
  27. package/docs/API_USAGE.md +82 -1
  28. package/docs/DESKTOP_RELEASE.md +24 -0
  29. package/package.json +3 -1
  30. package/admin-ui/dist/assets/index-DRe-tByu.js +0 -10
  31. package/admin-ui/dist/assets/logs-awABDg1C.js +0 -1
  32. package/admin-ui/dist/assets/settings-DvRiHS7i.js +0 -1
@@ -41,7 +41,8 @@ async function startServer(params) {
41
41
  const app = createApp({
42
42
  corsOrigin: resolveCorsOrigin(),
43
43
  bodyLimit,
44
- onRestart: params?.onRestart
44
+ onRestart: params?.onRestart,
45
+ onRestartCodex: params?.onRestartCodex
45
46
  });
46
47
  try {
47
48
  await app.listen({
package/docs/API_USAGE.md CHANGED
@@ -41,6 +41,41 @@ Image model: gpt-image-2
41
41
 
42
42
  Use `GET /v1/models` to see the models available through the current local Codex cache.
43
43
 
44
+ ## OpenClaw Settings
45
+
46
+ Use the OpenAI-compatible provider mode in OpenClaw:
47
+
48
+ ```text
49
+ Provider: OpenAI compatible
50
+ Base URL: http://127.0.0.1:8787/v1
51
+ API Key: local
52
+ Model: gpt-5.4
53
+ Chat endpoint: /chat/completions
54
+ Streaming: enabled
55
+ Tools / function calling: enabled
56
+ ```
57
+
58
+ The gateway accepts OpenClaw-style `chat.completions` requests with `tools`, `tool_choice`, `parallel_tool_calls`, `reasoning_effort`, assistant `tool_calls`, and tool-role result messages. It translates those fields to the upstream Codex Responses shape and returns OpenAI-style chat responses.
59
+
60
+ OpenClaw requests are visible in the management console request log when the client sends an OpenClaw user agent. The log keeps safe summaries only; it does not store full access tokens.
61
+
62
+ ## Codex Custom Provider
63
+
64
+ Codex CLI/Desktop can route model traffic through AI Zero Token by using a custom Responses provider in `~/.codex/config.toml`. The management console Settings page can write this automatically with "接管 Codex 请求" and remove it with "解除接管":
65
+
66
+ ```toml
67
+ model = "gpt-5.4"
68
+ model_provider = "ai-zero-token"
69
+
70
+ [model_providers.ai-zero-token]
71
+ name = "AI Zero Token"
72
+ base_url = "http://127.0.0.1:8787/codex/v1"
73
+ wire_api = "responses"
74
+ supports_websockets = false
75
+ ```
76
+
77
+ Codex sends `POST /codex/v1/responses` with `Accept: text/event-stream`; the gateway forwards that request to the active Codex OAuth account and streams upstream Responses SSE events back to Codex. The regular `/v1/*` routes remain OpenAI-compatible API routes for non-Codex clients.
78
+
44
79
  ## Models
45
80
 
46
81
  ```bash
@@ -74,6 +109,50 @@ curl http://127.0.0.1:8787/v1/chat/completions \
74
109
  "messages": [
75
110
  { "role": "user", "content": "Reply with OK only." }
76
111
  ]
112
+ }'
113
+ ```
114
+
115
+ Streaming chat completions:
116
+
117
+ ```bash
118
+ curl http://127.0.0.1:8787/v1/chat/completions \
119
+ -H "Content-Type: application/json" \
120
+ -d '{
121
+ "model": "gpt-5.4",
122
+ "stream": true,
123
+ "messages": [
124
+ { "role": "user", "content": "Reply with OK only." }
125
+ ]
126
+ }'
127
+ ```
128
+
129
+ Tool-call compatible request:
130
+
131
+ ```bash
132
+ curl http://127.0.0.1:8787/v1/chat/completions \
133
+ -H "Content-Type: application/json" \
134
+ -d '{
135
+ "model": "gpt-5.4",
136
+ "messages": [
137
+ { "role": "user", "content": "What is the weather tool argument for Shanghai?" }
138
+ ],
139
+ "tools": [
140
+ {
141
+ "type": "function",
142
+ "function": {
143
+ "name": "get_weather",
144
+ "description": "Get weather for a city.",
145
+ "parameters": {
146
+ "type": "object",
147
+ "properties": {
148
+ "city": { "type": "string" }
149
+ },
150
+ "required": ["city"]
151
+ }
152
+ }
153
+ }
154
+ ],
155
+ "tool_choice": "auto"
77
156
  }'
78
157
  ```
79
158
 
@@ -134,5 +213,7 @@ console.log(response.choices[0]?.message?.content);
134
213
 
135
214
  - Login first through the management page or `azt login`.
136
215
  - A model appearing in `/v1/models` means the local Codex cache lists it. Final availability still depends on the active account.
137
- - `stream=true` is not supported yet.
216
+ - `stream=true` is supported for `/v1/chat/completions` through OpenAI-style SSE chunks. Codex passthrough streaming is isolated under `/codex/v1/responses`.
217
+ - `n > 1` is not supported for `/v1/chat/completions`.
218
+ - Tool/function calling is supported for common OpenAI-compatible clients, including OpenClaw, but exact upstream behavior still depends on the active Codex model and account.
138
219
  - The default listener is `0.0.0.0:8787`, so local-network clients can call the gateway by using the machine IP.
@@ -2,6 +2,27 @@
2
2
 
3
3
  This project ships the desktop app with Electron. The desktop main process starts the existing local Fastify gateway and loads the React management UI served by that gateway.
4
4
 
5
+ ## 2.0.5 Release Notes
6
+
7
+ Version `2.0.5` adds Codex custom provider routing and finer account rotation controls:
8
+
9
+ - Settings-page Codex provider setup for writing or removing the AI Zero Token managed `~/.codex/config.toml` provider.
10
+ - Local and remote Codex gateway URL modes, including automatic normalization to `/codex/v1`.
11
+ - Dedicated `POST /codex/v1/responses` passthrough route for Codex CLI/Desktop Responses SSE traffic.
12
+ - Provider status reporting in the management console, including active provider, base URL, and config path.
13
+ - Auto-switch exclusion list for accounts that should not participate in automatic quota rotation.
14
+ - Safer settings persistence through normalized loads, deduplicated profile IDs, queued saves, and atomic writes.
15
+
16
+ ## 2.0.4 Release Notes
17
+
18
+ Version `2.0.4` adds the macOS menu-bar account panel and OpenClaw compatibility work:
19
+
20
+ - Menu-bar quick account panel for switching gateway/Codex accounts.
21
+ - Menu actions for quota refresh, Base URL copy, console open, gateway restart, and quit.
22
+ - Desktop Codex restart hook after applying an account to local Codex.
23
+ - OpenClaw-compatible `chat.completions` streaming and tool-call fields.
24
+ - Real gateway request log entries for recent API traffic.
25
+
5
26
  ## 2.0.0 Release Notes
6
27
 
7
28
  Version `2.0.0` is the first desktop-focused major release. It includes:
@@ -93,6 +114,8 @@ AI Zero Token Setup {version}.exe
93
114
  AI Zero Token-{version}-win.zip
94
115
  ```
95
116
 
117
+ For `2.0.5`, replace `{version}` with `2.0.5`.
118
+
96
119
  Artifact purpose:
97
120
 
98
121
  - `AI Zero Token-{version}-mac-arm64.dmg`: macOS Apple Silicon builds for M1/M2/M3/M4 devices.
@@ -131,6 +154,7 @@ App icon files live in:
131
154
  build/icon.png
132
155
  build/icon.icns
133
156
  build/icon.ico
157
+ build/tray-icon-template.png
134
158
  ```
135
159
 
136
160
  They are included in Electron packaging and npm packing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-zero-token",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Local-first OpenAI-compatible AI CLI and gateway with Codex OAuth, multi-account management, and gpt-image-2 image generation/editing.",
5
5
  "license": "MIT",
6
6
  "author": "AI Zero Token Contributors",
@@ -90,6 +90,7 @@
90
90
  "dist/**/*",
91
91
  "admin-ui/dist/**/*",
92
92
  "build/icon.*",
93
+ "build/tray-icon-template.png",
93
94
  "package.json",
94
95
  "README.md",
95
96
  "README.zh-CN.md",
@@ -153,6 +154,7 @@
153
154
  "build/icon.png",
154
155
  "build/icon.icns",
155
156
  "build/icon.ico",
157
+ "build/tray-icon-template.png",
156
158
  "build/mac-install-guide.txt",
157
159
  "CHANGELOG.md",
158
160
  "docs/API_USAGE.md",